@shopware-ag/dive 1.18.5-beta.0 → 1.18.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/AR-B-g0updz.js +1450 -0
- package/build/AR-B-g0updz.js.map +1 -0
- package/build/AR-BWQebw6-.cjs +153 -0
- package/build/AR-BWQebw6-.cjs.map +1 -0
- package/build/IO-BgiJzKrU.js +1257 -0
- package/build/IO-BgiJzKrU.js.map +1 -0
- package/build/IO-CuYml7Y5.cjs +2 -0
- package/build/IO-CuYml7Y5.cjs.map +1 -0
- package/build/MediaCreator-4zmvmUWH.js +22 -0
- package/build/MediaCreator-4zmvmUWH.js.map +1 -0
- package/build/MediaCreator-BNxZVYyZ.cjs +2 -0
- package/build/MediaCreator-BNxZVYyZ.cjs.map +1 -0
- package/build/TextureUtils-CxpuVgwF.js +38 -0
- package/build/TextureUtils-CxpuVgwF.js.map +1 -0
- package/build/TextureUtils-DNG-yR77.cjs +19 -0
- package/build/TextureUtils-DNG-yR77.cjs.map +1 -0
- package/build/dive-Mi8g8Khn.js +24852 -0
- package/build/dive-Mi8g8Khn.js.map +1 -0
- package/build/dive-_-yiZbhn.cjs +3857 -0
- package/build/dive-_-yiZbhn.cjs.map +1 -0
- package/build/dive.cjs +1 -3856
- package/build/dive.cjs.map +1 -1
- package/build/dive.js +6 -24721
- package/build/dive.js.map +1 -1
- package/build/src/com/actions/media/generatemedia.d.ts +2 -3
- package/package.json +1 -1
- package/src/ar/arquicklook/ARQuickLook.ts +3 -1
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +1 -1
- package/src/camera/PerspectiveCamera.ts +1 -1
- package/src/com/Communication.ts +86 -31
- package/src/com/__test__/Communication.test.ts +18 -9
- package/src/com/actions/media/generatemedia.ts +2 -3
|
@@ -0,0 +1,1450 @@
|
|
|
1
|
+
import { c as Jt, N as Kt, O as wt, o as te, p as ee, q as kt, M as dt, V as k, r as ie, Q as et, s as Z, t as st, W as se } from "./dive-Mi8g8Khn.js";
|
|
2
|
+
import { d as re } from "./TextureUtils-CxpuVgwF.js";
|
|
3
|
+
function ne(e, t) {
|
|
4
|
+
return e ? t in e : !1;
|
|
5
|
+
}
|
|
6
|
+
function Lt(e, t) {
|
|
7
|
+
if (e)
|
|
8
|
+
return ne(e, t) ? e : Lt(e.parent, t);
|
|
9
|
+
}
|
|
10
|
+
/*!
|
|
11
|
+
fflate - fast JavaScript compression/decompression
|
|
12
|
+
<https://101arrowz.github.io/fflate>
|
|
13
|
+
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
14
|
+
version 0.8.2
|
|
15
|
+
*/
|
|
16
|
+
var T = Uint8Array, I = Uint16Array, yt = Int32Array, xt = new T([
|
|
17
|
+
0,
|
|
18
|
+
0,
|
|
19
|
+
0,
|
|
20
|
+
0,
|
|
21
|
+
0,
|
|
22
|
+
0,
|
|
23
|
+
0,
|
|
24
|
+
0,
|
|
25
|
+
1,
|
|
26
|
+
1,
|
|
27
|
+
1,
|
|
28
|
+
1,
|
|
29
|
+
2,
|
|
30
|
+
2,
|
|
31
|
+
2,
|
|
32
|
+
2,
|
|
33
|
+
3,
|
|
34
|
+
3,
|
|
35
|
+
3,
|
|
36
|
+
3,
|
|
37
|
+
4,
|
|
38
|
+
4,
|
|
39
|
+
4,
|
|
40
|
+
4,
|
|
41
|
+
5,
|
|
42
|
+
5,
|
|
43
|
+
5,
|
|
44
|
+
5,
|
|
45
|
+
0,
|
|
46
|
+
/* unused */
|
|
47
|
+
0,
|
|
48
|
+
0,
|
|
49
|
+
/* impossible */
|
|
50
|
+
0
|
|
51
|
+
]), Mt = new T([
|
|
52
|
+
0,
|
|
53
|
+
0,
|
|
54
|
+
0,
|
|
55
|
+
0,
|
|
56
|
+
1,
|
|
57
|
+
1,
|
|
58
|
+
2,
|
|
59
|
+
2,
|
|
60
|
+
3,
|
|
61
|
+
3,
|
|
62
|
+
4,
|
|
63
|
+
4,
|
|
64
|
+
5,
|
|
65
|
+
5,
|
|
66
|
+
6,
|
|
67
|
+
6,
|
|
68
|
+
7,
|
|
69
|
+
7,
|
|
70
|
+
8,
|
|
71
|
+
8,
|
|
72
|
+
9,
|
|
73
|
+
9,
|
|
74
|
+
10,
|
|
75
|
+
10,
|
|
76
|
+
11,
|
|
77
|
+
11,
|
|
78
|
+
12,
|
|
79
|
+
12,
|
|
80
|
+
13,
|
|
81
|
+
13,
|
|
82
|
+
/* unused */
|
|
83
|
+
0,
|
|
84
|
+
0
|
|
85
|
+
]), Pt = new T([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), zt = function(e, t) {
|
|
86
|
+
for (var i = new I(31), s = 0; s < 31; ++s)
|
|
87
|
+
i[s] = t += 1 << e[s - 1];
|
|
88
|
+
for (var r = new yt(i[30]), s = 1; s < 30; ++s)
|
|
89
|
+
for (var n = i[s]; n < i[s + 1]; ++n)
|
|
90
|
+
r[n] = n - i[s] << 5 | s;
|
|
91
|
+
return { b: i, r };
|
|
92
|
+
}, Bt = zt(xt, 2), oe = Bt.b, _t = Bt.r;
|
|
93
|
+
oe[28] = 258, _t[258] = 28;
|
|
94
|
+
var ae = zt(Mt, 0), Ht = ae.r, pt = new I(32768);
|
|
95
|
+
for (var m = 0; m < 32768; ++m) {
|
|
96
|
+
var W = (m & 43690) >> 1 | (m & 21845) << 1;
|
|
97
|
+
W = (W & 52428) >> 2 | (W & 13107) << 2, W = (W & 61680) >> 4 | (W & 3855) << 4, pt[m] = ((W & 65280) >> 8 | (W & 255) << 8) >> 1;
|
|
98
|
+
}
|
|
99
|
+
var it = function(e, t, i) {
|
|
100
|
+
for (var s = e.length, r = 0, n = new I(t); r < s; ++r)
|
|
101
|
+
e[r] && ++n[e[r] - 1];
|
|
102
|
+
var o = new I(t);
|
|
103
|
+
for (r = 1; r < t; ++r)
|
|
104
|
+
o[r] = o[r - 1] + n[r - 1] << 1;
|
|
105
|
+
var h;
|
|
106
|
+
if (i) {
|
|
107
|
+
h = new I(1 << t);
|
|
108
|
+
var c = 15 - t;
|
|
109
|
+
for (r = 0; r < s; ++r)
|
|
110
|
+
if (e[r])
|
|
111
|
+
for (var u = r << 4 | e[r], a = t - e[r], l = o[e[r] - 1]++ << a, d = l | (1 << a) - 1; l <= d; ++l)
|
|
112
|
+
h[pt[l] >> c] = u;
|
|
113
|
+
} else
|
|
114
|
+
for (h = new I(s), r = 0; r < s; ++r)
|
|
115
|
+
e[r] && (h[r] = pt[o[e[r] - 1]++] >> 15 - e[r]);
|
|
116
|
+
return h;
|
|
117
|
+
}, F = new T(288);
|
|
118
|
+
for (var m = 0; m < 144; ++m)
|
|
119
|
+
F[m] = 8;
|
|
120
|
+
for (var m = 144; m < 256; ++m)
|
|
121
|
+
F[m] = 9;
|
|
122
|
+
for (var m = 256; m < 280; ++m)
|
|
123
|
+
F[m] = 7;
|
|
124
|
+
for (var m = 280; m < 288; ++m)
|
|
125
|
+
F[m] = 8;
|
|
126
|
+
var nt = new T(32);
|
|
127
|
+
for (var m = 0; m < 32; ++m)
|
|
128
|
+
nt[m] = 5;
|
|
129
|
+
var ce = /* @__PURE__ */ it(F, 9, 0), he = /* @__PURE__ */ it(nt, 5, 0), Vt = function(e) {
|
|
130
|
+
return (e + 7) / 8 | 0;
|
|
131
|
+
}, Nt = function(e, t, i) {
|
|
132
|
+
return (i == null || i > e.length) && (i = e.length), new T(e.subarray(t, i));
|
|
133
|
+
}, le = [
|
|
134
|
+
"unexpected EOF",
|
|
135
|
+
"invalid block type",
|
|
136
|
+
"invalid length/literal",
|
|
137
|
+
"invalid distance",
|
|
138
|
+
"stream finished",
|
|
139
|
+
"no stream handler",
|
|
140
|
+
,
|
|
141
|
+
"no callback",
|
|
142
|
+
"invalid UTF-8 data",
|
|
143
|
+
"extra field too long",
|
|
144
|
+
"date not in range 1980-2099",
|
|
145
|
+
"filename too long",
|
|
146
|
+
"stream finishing",
|
|
147
|
+
"invalid zip data"
|
|
148
|
+
// determined by unknown compression method
|
|
149
|
+
], at = function(e, t, i) {
|
|
150
|
+
var s = new Error(t || le[e]);
|
|
151
|
+
if (s.code = e, Error.captureStackTrace && Error.captureStackTrace(s, at), !i)
|
|
152
|
+
throw s;
|
|
153
|
+
return s;
|
|
154
|
+
}, N = function(e, t, i) {
|
|
155
|
+
i <<= t & 7;
|
|
156
|
+
var s = t / 8 | 0;
|
|
157
|
+
e[s] |= i, e[s + 1] |= i >> 8;
|
|
158
|
+
}, K = function(e, t, i) {
|
|
159
|
+
i <<= t & 7;
|
|
160
|
+
var s = t / 8 | 0;
|
|
161
|
+
e[s] |= i, e[s + 1] |= i >> 8, e[s + 2] |= i >> 16;
|
|
162
|
+
}, ft = function(e, t) {
|
|
163
|
+
for (var i = [], s = 0; s < e.length; ++s)
|
|
164
|
+
e[s] && i.push({ s, f: e[s] });
|
|
165
|
+
var r = i.length, n = i.slice();
|
|
166
|
+
if (!r)
|
|
167
|
+
return { t: Wt, l: 0 };
|
|
168
|
+
if (r == 1) {
|
|
169
|
+
var o = new T(i[0].s + 1);
|
|
170
|
+
return o[i[0].s] = 1, { t: o, l: 1 };
|
|
171
|
+
}
|
|
172
|
+
i.sort(function($, P) {
|
|
173
|
+
return $.f - P.f;
|
|
174
|
+
}), i.push({ s: -1, f: 25001 });
|
|
175
|
+
var h = i[0], c = i[1], u = 0, a = 1, l = 2;
|
|
176
|
+
for (i[0] = { s: -1, f: h.f + c.f, l: h, r: c }; a != r - 1; )
|
|
177
|
+
h = i[i[u].f < i[l].f ? u++ : l++], c = i[u != a && i[u].f < i[l].f ? u++ : l++], i[a++] = { s: -1, f: h.f + c.f, l: h, r: c };
|
|
178
|
+
for (var d = n[0].s, s = 1; s < r; ++s)
|
|
179
|
+
n[s].s > d && (d = n[s].s);
|
|
180
|
+
var f = new I(d + 1), p = vt(i[a - 1], f, 0);
|
|
181
|
+
if (p > t) {
|
|
182
|
+
var s = 0, g = 0, S = p - t, C = 1 << S;
|
|
183
|
+
for (n.sort(function(P, R) {
|
|
184
|
+
return f[R.s] - f[P.s] || P.f - R.f;
|
|
185
|
+
}); s < r; ++s) {
|
|
186
|
+
var O = n[s].s;
|
|
187
|
+
if (f[O] > t)
|
|
188
|
+
g += C - (1 << p - f[O]), f[O] = t;
|
|
189
|
+
else
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
for (g >>= S; g > 0; ) {
|
|
193
|
+
var L = n[s].s;
|
|
194
|
+
f[L] < t ? g -= 1 << t - f[L]++ - 1 : ++s;
|
|
195
|
+
}
|
|
196
|
+
for (; s >= 0 && g; --s) {
|
|
197
|
+
var w = n[s].s;
|
|
198
|
+
f[w] == t && (--f[w], ++g);
|
|
199
|
+
}
|
|
200
|
+
p = t;
|
|
201
|
+
}
|
|
202
|
+
return { t: new T(f), l: p };
|
|
203
|
+
}, vt = function(e, t, i) {
|
|
204
|
+
return e.s == -1 ? Math.max(vt(e.l, t, i + 1), vt(e.r, t, i + 1)) : t[e.s] = i;
|
|
205
|
+
}, At = function(e) {
|
|
206
|
+
for (var t = e.length; t && !e[--t]; )
|
|
207
|
+
;
|
|
208
|
+
for (var i = new I(++t), s = 0, r = e[0], n = 1, o = function(c) {
|
|
209
|
+
i[s++] = c;
|
|
210
|
+
}, h = 1; h <= t; ++h)
|
|
211
|
+
if (e[h] == r && h != t)
|
|
212
|
+
++n;
|
|
213
|
+
else {
|
|
214
|
+
if (!r && n > 2) {
|
|
215
|
+
for (; n > 138; n -= 138)
|
|
216
|
+
o(32754);
|
|
217
|
+
n > 2 && (o(n > 10 ? n - 11 << 5 | 28690 : n - 3 << 5 | 12305), n = 0);
|
|
218
|
+
} else if (n > 3) {
|
|
219
|
+
for (o(r), --n; n > 6; n -= 6)
|
|
220
|
+
o(8304);
|
|
221
|
+
n > 2 && (o(n - 3 << 5 | 8208), n = 0);
|
|
222
|
+
}
|
|
223
|
+
for (; n--; )
|
|
224
|
+
o(r);
|
|
225
|
+
n = 1, r = e[h];
|
|
226
|
+
}
|
|
227
|
+
return { c: i.subarray(0, s), n: t };
|
|
228
|
+
}, tt = function(e, t) {
|
|
229
|
+
for (var i = 0, s = 0; s < t.length; ++s)
|
|
230
|
+
i += e[s] * t[s];
|
|
231
|
+
return i;
|
|
232
|
+
}, jt = function(e, t, i) {
|
|
233
|
+
var s = i.length, r = Vt(t + 2);
|
|
234
|
+
e[r] = s & 255, e[r + 1] = s >> 8, e[r + 2] = e[r] ^ 255, e[r + 3] = e[r + 1] ^ 255;
|
|
235
|
+
for (var n = 0; n < s; ++n)
|
|
236
|
+
e[r + n + 4] = i[n];
|
|
237
|
+
return (r + 4 + s) * 8;
|
|
238
|
+
}, It = function(e, t, i, s, r, n, o, h, c, u, a) {
|
|
239
|
+
N(t, a++, i), ++r[256];
|
|
240
|
+
for (var l = ft(r, 15), d = l.t, f = l.l, p = ft(n, 15), g = p.t, S = p.l, C = At(d), O = C.c, L = C.n, w = At(g), $ = w.c, P = w.n, R = new I(19), v = 0; v < O.length; ++v)
|
|
241
|
+
++R[O[v] & 31];
|
|
242
|
+
for (var v = 0; v < $.length; ++v)
|
|
243
|
+
++R[$[v] & 31];
|
|
244
|
+
for (var _ = ft(R, 7), H = _.t, q = _.l, A = 19; A > 4 && !H[Pt[A - 1]]; --A)
|
|
245
|
+
;
|
|
246
|
+
var G = u + 5 << 3, D = tt(r, F) + tt(n, nt) + o, X = tt(r, d) + tt(n, g) + o + 14 + 3 * A + tt(R, H) + 2 * R[16] + 3 * R[17] + 7 * R[18];
|
|
247
|
+
if (c >= 0 && G <= D && G <= X)
|
|
248
|
+
return jt(t, a, e.subarray(c, c + u));
|
|
249
|
+
var z, y, U, j;
|
|
250
|
+
if (N(t, a, 1 + (X < D)), a += 2, X < D) {
|
|
251
|
+
z = it(d, f, 0), y = d, U = it(g, S, 0), j = g;
|
|
252
|
+
var ct = it(H, q, 0);
|
|
253
|
+
N(t, a, L - 257), N(t, a + 5, P - 1), N(t, a + 10, A - 4), a += 14;
|
|
254
|
+
for (var v = 0; v < A; ++v)
|
|
255
|
+
N(t, a + 3 * v, H[Pt[v]]);
|
|
256
|
+
a += 3 * A;
|
|
257
|
+
for (var B = [O, $], J = 0; J < 2; ++J)
|
|
258
|
+
for (var Q = B[J], v = 0; v < Q.length; ++v) {
|
|
259
|
+
var V = Q[v] & 31;
|
|
260
|
+
N(t, a, ct[V]), a += H[V], V > 15 && (N(t, a, Q[v] >> 5 & 127), a += Q[v] >> 12);
|
|
261
|
+
}
|
|
262
|
+
} else
|
|
263
|
+
z = ce, y = F, U = he, j = nt;
|
|
264
|
+
for (var v = 0; v < h; ++v) {
|
|
265
|
+
var M = s[v];
|
|
266
|
+
if (M > 255) {
|
|
267
|
+
var V = M >> 18 & 31;
|
|
268
|
+
K(t, a, z[V + 257]), a += y[V + 257], V > 7 && (N(t, a, M >> 23 & 31), a += xt[V]);
|
|
269
|
+
var Y = M & 31;
|
|
270
|
+
K(t, a, U[Y]), a += j[Y], Y > 3 && (K(t, a, M >> 5 & 8191), a += Mt[Y]);
|
|
271
|
+
} else
|
|
272
|
+
K(t, a, z[M]), a += y[M];
|
|
273
|
+
}
|
|
274
|
+
return K(t, a, z[256]), a + y[256];
|
|
275
|
+
}, ue = /* @__PURE__ */ new yt([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]), Wt = /* @__PURE__ */ new T(0), fe = function(e, t, i, s, r, n) {
|
|
276
|
+
var o = n.z || e.length, h = new T(s + o + 5 * (1 + Math.ceil(o / 7e3)) + r), c = h.subarray(s, h.length - r), u = n.l, a = (n.r || 0) & 7;
|
|
277
|
+
if (t) {
|
|
278
|
+
a && (c[0] = n.r >> 3);
|
|
279
|
+
for (var l = ue[t - 1], d = l >> 13, f = l & 8191, p = (1 << i) - 1, g = n.p || new I(32768), S = n.h || new I(p + 1), C = Math.ceil(i / 3), O = 2 * C, L = function(ut) {
|
|
280
|
+
return (e[ut] ^ e[ut + 1] << C ^ e[ut + 2] << O) & p;
|
|
281
|
+
}, w = new yt(25e3), $ = new I(288), P = new I(32), R = 0, v = 0, _ = n.i || 0, H = 0, q = n.w || 0, A = 0; _ + 2 < o; ++_) {
|
|
282
|
+
var G = L(_), D = _ & 32767, X = S[G];
|
|
283
|
+
if (g[D] = X, S[G] = D, q <= _) {
|
|
284
|
+
var z = o - _;
|
|
285
|
+
if ((R > 7e3 || H > 24576) && (z > 423 || !u)) {
|
|
286
|
+
a = It(e, c, 0, w, $, P, v, H, A, _ - A, a), H = R = v = 0, A = _;
|
|
287
|
+
for (var y = 0; y < 286; ++y)
|
|
288
|
+
$[y] = 0;
|
|
289
|
+
for (var y = 0; y < 30; ++y)
|
|
290
|
+
P[y] = 0;
|
|
291
|
+
}
|
|
292
|
+
var U = 2, j = 0, ct = f, B = D - X & 32767;
|
|
293
|
+
if (z > 2 && G == L(_ - B))
|
|
294
|
+
for (var J = Math.min(d, z) - 1, Q = Math.min(32767, _), V = Math.min(258, z); B <= Q && --ct && D != X; ) {
|
|
295
|
+
if (e[_ + U] == e[_ + U - B]) {
|
|
296
|
+
for (var M = 0; M < V && e[_ + M] == e[_ + M - B]; ++M)
|
|
297
|
+
;
|
|
298
|
+
if (M > U) {
|
|
299
|
+
if (U = M, j = B, M > J)
|
|
300
|
+
break;
|
|
301
|
+
for (var Y = Math.min(B, M - 2), Tt = 0, y = 0; y < Y; ++y) {
|
|
302
|
+
var ht = _ - B + y & 32767, Zt = g[ht], Et = ht - Zt & 32767;
|
|
303
|
+
Et > Tt && (Tt = Et, X = ht);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
D = X, X = g[D], B += D - X & 32767;
|
|
308
|
+
}
|
|
309
|
+
if (j) {
|
|
310
|
+
w[H++] = 268435456 | _t[U] << 18 | Ht[j];
|
|
311
|
+
var $t = _t[U] & 31, Ct = Ht[j] & 31;
|
|
312
|
+
v += xt[$t] + Mt[Ct], ++$[257 + $t], ++P[Ct], q = _ + U, ++R;
|
|
313
|
+
} else
|
|
314
|
+
w[H++] = e[_], ++$[e[_]];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
for (_ = Math.max(_, q); _ < o; ++_)
|
|
318
|
+
w[H++] = e[_], ++$[e[_]];
|
|
319
|
+
a = It(e, c, u, w, $, P, v, H, A, _ - A, a), u || (n.r = a & 7 | c[a / 8 | 0] << 3, a -= 7, n.h = S, n.p = g, n.i = _, n.w = q);
|
|
320
|
+
} else {
|
|
321
|
+
for (var _ = n.w || 0; _ < o + u; _ += 65535) {
|
|
322
|
+
var lt = _ + 65535;
|
|
323
|
+
lt >= o && (c[a / 8 | 0] = u, lt = o), a = jt(c, a + 1, e.subarray(_, lt));
|
|
324
|
+
}
|
|
325
|
+
n.i = o;
|
|
326
|
+
}
|
|
327
|
+
return Nt(h, 0, s + Vt(a) + r);
|
|
328
|
+
}, de = /* @__PURE__ */ function() {
|
|
329
|
+
for (var e = new Int32Array(256), t = 0; t < 256; ++t) {
|
|
330
|
+
for (var i = t, s = 9; --s; )
|
|
331
|
+
i = (i & 1 && -306674912) ^ i >>> 1;
|
|
332
|
+
e[t] = i;
|
|
333
|
+
}
|
|
334
|
+
return e;
|
|
335
|
+
}(), _e = function() {
|
|
336
|
+
var e = -1;
|
|
337
|
+
return {
|
|
338
|
+
p: function(t) {
|
|
339
|
+
for (var i = e, s = 0; s < t.length; ++s)
|
|
340
|
+
i = de[i & 255 ^ t[s]] ^ i >>> 8;
|
|
341
|
+
e = i;
|
|
342
|
+
},
|
|
343
|
+
d: function() {
|
|
344
|
+
return ~e;
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}, pe = function(e, t, i, s, r) {
|
|
348
|
+
if (!r && (r = { l: 1 }, t.dictionary)) {
|
|
349
|
+
var n = t.dictionary.subarray(-32768), o = new T(n.length + e.length);
|
|
350
|
+
o.set(n), o.set(e, n.length), e = o, r.w = n.length;
|
|
351
|
+
}
|
|
352
|
+
return fe(e, t.level == null ? 6 : t.level, t.mem == null ? r.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(e.length))) * 1.5) : 20 : 12 + t.mem, i, s, r);
|
|
353
|
+
}, Ft = function(e, t) {
|
|
354
|
+
var i = {};
|
|
355
|
+
for (var s in e)
|
|
356
|
+
i[s] = e[s];
|
|
357
|
+
for (var s in t)
|
|
358
|
+
i[s] = t[s];
|
|
359
|
+
return i;
|
|
360
|
+
}, x = function(e, t, i) {
|
|
361
|
+
for (; i; ++t)
|
|
362
|
+
e[t] = i, i >>>= 8;
|
|
363
|
+
};
|
|
364
|
+
function ve(e, t) {
|
|
365
|
+
return pe(e, t || {}, 0, 0);
|
|
366
|
+
}
|
|
367
|
+
var qt = function(e, t, i, s) {
|
|
368
|
+
for (var r in e) {
|
|
369
|
+
var n = e[r], o = t + r, h = s;
|
|
370
|
+
Array.isArray(n) && (h = Ft(s, n[1]), n = n[0]), n instanceof T ? i[o] = [n, h] : (i[o += "/"] = [new T(0), h], qt(n, o, i, s));
|
|
371
|
+
}
|
|
372
|
+
}, Ot = typeof TextEncoder < "u" && /* @__PURE__ */ new TextEncoder(), ge = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), me = 0;
|
|
373
|
+
try {
|
|
374
|
+
ge.decode(Wt, { stream: !0 }), me = 1;
|
|
375
|
+
} catch {
|
|
376
|
+
}
|
|
377
|
+
function ot(e, t) {
|
|
378
|
+
var i;
|
|
379
|
+
if (Ot)
|
|
380
|
+
return Ot.encode(e);
|
|
381
|
+
for (var s = e.length, r = new T(e.length + (e.length >> 1)), n = 0, o = function(u) {
|
|
382
|
+
r[n++] = u;
|
|
383
|
+
}, i = 0; i < s; ++i) {
|
|
384
|
+
if (n + 5 > r.length) {
|
|
385
|
+
var h = new T(n + 8 + (s - i << 1));
|
|
386
|
+
h.set(r), r = h;
|
|
387
|
+
}
|
|
388
|
+
var c = e.charCodeAt(i);
|
|
389
|
+
c < 128 || t ? o(c) : c < 2048 ? (o(192 | c >> 6), o(128 | c & 63)) : c > 55295 && c < 57344 ? (c = 65536 + (c & 1047552) | e.charCodeAt(++i) & 1023, o(240 | c >> 18), o(128 | c >> 12 & 63), o(128 | c >> 6 & 63), o(128 | c & 63)) : (o(224 | c >> 12), o(128 | c >> 6 & 63), o(128 | c & 63));
|
|
390
|
+
}
|
|
391
|
+
return Nt(r, 0, n);
|
|
392
|
+
}
|
|
393
|
+
var gt = function(e) {
|
|
394
|
+
var t = 0;
|
|
395
|
+
if (e)
|
|
396
|
+
for (var i in e) {
|
|
397
|
+
var s = e[i].length;
|
|
398
|
+
s > 65535 && at(9), t += s + 4;
|
|
399
|
+
}
|
|
400
|
+
return t;
|
|
401
|
+
}, Dt = function(e, t, i, s, r, n, o, h) {
|
|
402
|
+
var c = s.length, u = i.extra, a = h && h.length, l = gt(u);
|
|
403
|
+
x(e, t, o != null ? 33639248 : 67324752), t += 4, o != null && (e[t++] = 20, e[t++] = i.os), e[t] = 20, t += 2, e[t++] = i.flag << 1 | (n < 0 && 8), e[t++] = r && 8, e[t++] = i.compression & 255, e[t++] = i.compression >> 8;
|
|
404
|
+
var d = new Date(i.mtime == null ? Date.now() : i.mtime), f = d.getFullYear() - 1980;
|
|
405
|
+
if ((f < 0 || f > 119) && at(10), x(e, t, f << 25 | d.getMonth() + 1 << 21 | d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 | d.getSeconds() >> 1), t += 4, n != -1 && (x(e, t, i.crc), x(e, t + 4, n < 0 ? -n - 2 : n), x(e, t + 8, i.size)), x(e, t + 12, c), x(e, t + 14, l), t += 16, o != null && (x(e, t, a), x(e, t + 6, i.attrs), x(e, t + 10, o), t += 14), e.set(s, t), t += c, l)
|
|
406
|
+
for (var p in u) {
|
|
407
|
+
var g = u[p], S = g.length;
|
|
408
|
+
x(e, t, +p), x(e, t + 2, S), e.set(g, t + 4), t += 4 + S;
|
|
409
|
+
}
|
|
410
|
+
return a && (e.set(h, t), t += a), t;
|
|
411
|
+
}, Re = function(e, t, i, s, r) {
|
|
412
|
+
x(e, t, 101010256), x(e, t + 8, i), x(e, t + 10, i), x(e, t + 12, s), x(e, t + 16, r);
|
|
413
|
+
};
|
|
414
|
+
function Se(e, t) {
|
|
415
|
+
t || (t = {});
|
|
416
|
+
var i = {}, s = [];
|
|
417
|
+
qt(e, "", i, t);
|
|
418
|
+
var r = 0, n = 0;
|
|
419
|
+
for (var o in i) {
|
|
420
|
+
var h = i[o], c = h[0], u = h[1], a = u.level == 0 ? 0 : 8, l = ot(o), d = l.length, f = u.comment, p = f && ot(f), g = p && p.length, S = gt(u.extra);
|
|
421
|
+
d > 65535 && at(11);
|
|
422
|
+
var C = a ? ve(c, u) : c, O = C.length, L = _e();
|
|
423
|
+
L.p(c), s.push(Ft(u, {
|
|
424
|
+
size: c.length,
|
|
425
|
+
crc: L.d(),
|
|
426
|
+
c: C,
|
|
427
|
+
f: l,
|
|
428
|
+
m: p,
|
|
429
|
+
u: d != o.length || p && f.length != g,
|
|
430
|
+
o: r,
|
|
431
|
+
compression: a
|
|
432
|
+
})), r += 30 + d + S + O, n += 76 + 2 * (d + S) + (g || 0) + O;
|
|
433
|
+
}
|
|
434
|
+
for (var w = new T(n + 22), $ = r, P = n - r, R = 0; R < s.length; ++R) {
|
|
435
|
+
var l = s[R];
|
|
436
|
+
Dt(w, l.o, l, l.f, l.u, l.c.length);
|
|
437
|
+
var v = 30 + l.f.length + gt(l.extra);
|
|
438
|
+
w.set(l.c, l.o + v), Dt(w, r, l, l.f, l.u, l.c.length, l.o, l.m), r += 16 + v + (l.m ? l.m.length : 0);
|
|
439
|
+
}
|
|
440
|
+
return Re(w, r, s.length, P, $), w;
|
|
441
|
+
}
|
|
442
|
+
class we {
|
|
443
|
+
async parse(t, i = {}) {
|
|
444
|
+
i = Object.assign({
|
|
445
|
+
ar: {
|
|
446
|
+
anchoring: { type: "plane" },
|
|
447
|
+
planeAnchoring: { alignment: "horizontal" }
|
|
448
|
+
},
|
|
449
|
+
quickLookCompatible: !1,
|
|
450
|
+
maxTextureSize: 1024
|
|
451
|
+
}, i);
|
|
452
|
+
const s = {}, r = "model.usda";
|
|
453
|
+
s[r] = null;
|
|
454
|
+
let n = Gt();
|
|
455
|
+
n += xe(i);
|
|
456
|
+
const o = {}, h = {};
|
|
457
|
+
t.traverseVisible((u) => {
|
|
458
|
+
if (u.isMesh) {
|
|
459
|
+
const a = u.geometry, l = u.material;
|
|
460
|
+
if (l.isMeshStandardMaterial) {
|
|
461
|
+
const d = "geometries/Geometry_" + a.id + ".usda";
|
|
462
|
+
if (!(d in s)) {
|
|
463
|
+
const f = Ee(a);
|
|
464
|
+
s[d] = be(f);
|
|
465
|
+
}
|
|
466
|
+
l.uuid in o || (o[l.uuid] = l), n += Te(u, a, l);
|
|
467
|
+
} else
|
|
468
|
+
console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)", u);
|
|
469
|
+
} else u.isCamera && (n += Xe(u));
|
|
470
|
+
}), n += Me(), n += Ie(o, h, i.quickLookCompatible), s[r] = ot(n), n = null;
|
|
471
|
+
for (const u in h) {
|
|
472
|
+
let a = h[u];
|
|
473
|
+
a.isCompressedTexture === !0 && (a = re(a));
|
|
474
|
+
const l = ye(a.image, a.flipY, i.maxTextureSize), d = await new Promise((f) => l.toBlob(f, "image/png", 1));
|
|
475
|
+
s[`textures/Texture_${u}.png`] = new Uint8Array(await d.arrayBuffer());
|
|
476
|
+
}
|
|
477
|
+
let c = 0;
|
|
478
|
+
for (const u in s) {
|
|
479
|
+
const a = s[u], l = 34 + u.length;
|
|
480
|
+
c += l;
|
|
481
|
+
const d = c & 63;
|
|
482
|
+
if (d !== 4) {
|
|
483
|
+
const f = 64 - d, p = new Uint8Array(f);
|
|
484
|
+
s[u] = [a, { extra: { 12345: p } }];
|
|
485
|
+
}
|
|
486
|
+
c = a.length;
|
|
487
|
+
}
|
|
488
|
+
return Se(s, { level: 0 });
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function ye(e, t, i) {
|
|
492
|
+
if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas || typeof ImageBitmap < "u" && e instanceof ImageBitmap) {
|
|
493
|
+
const s = i / Math.max(e.width, e.height), r = document.createElement("canvas");
|
|
494
|
+
r.width = e.width * Math.min(1, s), r.height = e.height * Math.min(1, s);
|
|
495
|
+
const n = r.getContext("2d");
|
|
496
|
+
return t === !0 && (n.translate(0, r.height), n.scale(1, -1)), n.drawImage(e, 0, 0, r.width, r.height), r;
|
|
497
|
+
} else
|
|
498
|
+
throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.");
|
|
499
|
+
}
|
|
500
|
+
const b = 7;
|
|
501
|
+
function Gt() {
|
|
502
|
+
return `#usda 1.0
|
|
503
|
+
(
|
|
504
|
+
customLayerData = {
|
|
505
|
+
string creator = "Three.js USDZExporter"
|
|
506
|
+
}
|
|
507
|
+
defaultPrim = "Root"
|
|
508
|
+
metersPerUnit = 1
|
|
509
|
+
upAxis = "Y"
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
`;
|
|
513
|
+
}
|
|
514
|
+
function xe(e) {
|
|
515
|
+
return `def Xform "Root"
|
|
516
|
+
{
|
|
517
|
+
def Scope "Scenes" (
|
|
518
|
+
kind = "sceneLibrary"
|
|
519
|
+
)
|
|
520
|
+
{
|
|
521
|
+
def Xform "Scene" (
|
|
522
|
+
customData = {
|
|
523
|
+
bool preliminary_collidesWithEnvironment = 0
|
|
524
|
+
string sceneName = "Scene"
|
|
525
|
+
}
|
|
526
|
+
sceneName = "Scene"
|
|
527
|
+
)
|
|
528
|
+
{
|
|
529
|
+
token preliminary:anchoring:type = "${e.ar.anchoring.type}"
|
|
530
|
+
token preliminary:planeAnchoring:alignment = "${e.ar.planeAnchoring.alignment}"
|
|
531
|
+
|
|
532
|
+
`;
|
|
533
|
+
}
|
|
534
|
+
function Me() {
|
|
535
|
+
return `
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
`;
|
|
541
|
+
}
|
|
542
|
+
function be(e) {
|
|
543
|
+
let t = Gt();
|
|
544
|
+
return t += e, ot(t);
|
|
545
|
+
}
|
|
546
|
+
function Te(e, t, i) {
|
|
547
|
+
const s = "Object_" + e.id, r = Qt(e.matrixWorld);
|
|
548
|
+
return e.matrixWorld.determinant() < 0 && console.warn("THREE.USDZExporter: USDZ does not support negative scales", e), `def Xform "${s}" (
|
|
549
|
+
prepend references = @./geometries/Geometry_${t.id}.usda@</Geometry>
|
|
550
|
+
prepend apiSchemas = ["MaterialBindingAPI"]
|
|
551
|
+
)
|
|
552
|
+
{
|
|
553
|
+
matrix4d xformOp:transform = ${r}
|
|
554
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
555
|
+
|
|
556
|
+
rel material:binding = </Materials/Material_${i.id}>
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
`;
|
|
560
|
+
}
|
|
561
|
+
function Qt(e) {
|
|
562
|
+
const t = e.elements;
|
|
563
|
+
return `( ${rt(t, 0)}, ${rt(t, 4)}, ${rt(t, 8)}, ${rt(t, 12)} )`;
|
|
564
|
+
}
|
|
565
|
+
function rt(e, t) {
|
|
566
|
+
return `(${e[t + 0]}, ${e[t + 1]}, ${e[t + 2]}, ${e[t + 3]})`;
|
|
567
|
+
}
|
|
568
|
+
function Ee(e) {
|
|
569
|
+
return `
|
|
570
|
+
def "Geometry"
|
|
571
|
+
{
|
|
572
|
+
${$e(e)}
|
|
573
|
+
}
|
|
574
|
+
`;
|
|
575
|
+
}
|
|
576
|
+
function $e(e) {
|
|
577
|
+
const t = "Geometry", i = e.attributes, s = i.position.count;
|
|
578
|
+
return `
|
|
579
|
+
def Mesh "${t}"
|
|
580
|
+
{
|
|
581
|
+
int[] faceVertexCounts = [${Ce(e)}]
|
|
582
|
+
int[] faceVertexIndices = [${Pe(e)}]
|
|
583
|
+
normal3f[] normals = [${mt(i.normal, s)}] (
|
|
584
|
+
interpolation = "vertex"
|
|
585
|
+
)
|
|
586
|
+
point3f[] points = [${mt(i.position, s)}]
|
|
587
|
+
${Ae(i)}
|
|
588
|
+
uniform token subdivisionScheme = "none"
|
|
589
|
+
}
|
|
590
|
+
`;
|
|
591
|
+
}
|
|
592
|
+
function Ce(e) {
|
|
593
|
+
const t = e.index !== null ? e.index.count : e.attributes.position.count;
|
|
594
|
+
return Array(t / 3).fill(3).join(", ");
|
|
595
|
+
}
|
|
596
|
+
function Pe(e) {
|
|
597
|
+
const t = e.index, i = [];
|
|
598
|
+
if (t !== null)
|
|
599
|
+
for (let s = 0; s < t.count; s++)
|
|
600
|
+
i.push(t.getX(s));
|
|
601
|
+
else {
|
|
602
|
+
const s = e.attributes.position.count;
|
|
603
|
+
for (let r = 0; r < s; r++)
|
|
604
|
+
i.push(r);
|
|
605
|
+
}
|
|
606
|
+
return i.join(", ");
|
|
607
|
+
}
|
|
608
|
+
function mt(e, t) {
|
|
609
|
+
if (e === void 0)
|
|
610
|
+
return console.warn("USDZExporter: Normals missing."), Array(t).fill("(0, 0, 0)").join(", ");
|
|
611
|
+
const i = [];
|
|
612
|
+
for (let s = 0; s < e.count; s++) {
|
|
613
|
+
const r = e.getX(s), n = e.getY(s), o = e.getZ(s);
|
|
614
|
+
i.push(`(${r.toPrecision(b)}, ${n.toPrecision(b)}, ${o.toPrecision(b)})`);
|
|
615
|
+
}
|
|
616
|
+
return i.join(", ");
|
|
617
|
+
}
|
|
618
|
+
function He(e) {
|
|
619
|
+
const t = [];
|
|
620
|
+
for (let i = 0; i < e.count; i++) {
|
|
621
|
+
const s = e.getX(i), r = e.getY(i);
|
|
622
|
+
t.push(`(${s.toPrecision(b)}, ${1 - r.toPrecision(b)})`);
|
|
623
|
+
}
|
|
624
|
+
return t.join(", ");
|
|
625
|
+
}
|
|
626
|
+
function Ae(e) {
|
|
627
|
+
let t = "";
|
|
628
|
+
for (let s = 0; s < 4; s++) {
|
|
629
|
+
const r = s > 0 ? s : "", n = e["uv" + r];
|
|
630
|
+
n !== void 0 && (t += `
|
|
631
|
+
texCoord2f[] primvars:st${r} = [${He(n)}] (
|
|
632
|
+
interpolation = "vertex"
|
|
633
|
+
)`);
|
|
634
|
+
}
|
|
635
|
+
const i = e.color;
|
|
636
|
+
if (i !== void 0) {
|
|
637
|
+
const s = i.count;
|
|
638
|
+
t += `
|
|
639
|
+
color3f[] primvars:displayColor = [${mt(i, s)}] (
|
|
640
|
+
interpolation = "vertex"
|
|
641
|
+
)`;
|
|
642
|
+
}
|
|
643
|
+
return t;
|
|
644
|
+
}
|
|
645
|
+
function Ie(e, t, i = !1) {
|
|
646
|
+
const s = [];
|
|
647
|
+
for (const r in e) {
|
|
648
|
+
const n = e[r];
|
|
649
|
+
s.push(Oe(n, t, i));
|
|
650
|
+
}
|
|
651
|
+
return `def "Materials"
|
|
652
|
+
{
|
|
653
|
+
${s.join("")}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
`;
|
|
657
|
+
}
|
|
658
|
+
function Oe(e, t, i = !1) {
|
|
659
|
+
const s = " ", r = [], n = [];
|
|
660
|
+
function o(h, c, u) {
|
|
661
|
+
const a = h.source.id + "_" + h.flipY;
|
|
662
|
+
t[a] = h;
|
|
663
|
+
const l = h.channel > 0 ? "st" + h.channel : "st", d = {
|
|
664
|
+
1e3: "repeat",
|
|
665
|
+
// RepeatWrapping
|
|
666
|
+
1001: "clamp",
|
|
667
|
+
// ClampToEdgeWrapping
|
|
668
|
+
1002: "mirror"
|
|
669
|
+
// MirroredRepeatWrapping
|
|
670
|
+
}, f = h.repeat.clone(), p = h.offset.clone(), g = h.rotation, S = Math.sin(g), C = Math.cos(g);
|
|
671
|
+
return p.y = 1 - p.y - f.y, i ? (p.x = p.x / f.x, p.y = p.y / f.y, p.x += S / f.x, p.y += C - 1) : (p.x += S * f.x, p.y += (1 - C) * f.y), `
|
|
672
|
+
def Shader "PrimvarReader_${c}"
|
|
673
|
+
{
|
|
674
|
+
uniform token info:id = "UsdPrimvarReader_float2"
|
|
675
|
+
float2 inputs:fallback = (0.0, 0.0)
|
|
676
|
+
token inputs:varname = "${l}"
|
|
677
|
+
float2 outputs:result
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
def Shader "Transform2d_${c}"
|
|
681
|
+
{
|
|
682
|
+
uniform token info:id = "UsdTransform2d"
|
|
683
|
+
token inputs:in.connect = </Materials/Material_${e.id}/PrimvarReader_${c}.outputs:result>
|
|
684
|
+
float inputs:rotation = ${(g * (180 / Math.PI)).toFixed(b)}
|
|
685
|
+
float2 inputs:scale = ${Ut(f)}
|
|
686
|
+
float2 inputs:translation = ${Ut(p)}
|
|
687
|
+
float2 outputs:result
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
def Shader "Texture_${h.id}_${c}"
|
|
691
|
+
{
|
|
692
|
+
uniform token info:id = "UsdUVTexture"
|
|
693
|
+
asset inputs:file = @textures/Texture_${a}.png@
|
|
694
|
+
float2 inputs:st.connect = </Materials/Material_${e.id}/Transform2d_${c}.outputs:result>
|
|
695
|
+
${u !== void 0 ? "float4 inputs:scale = " + De(u) : ""}
|
|
696
|
+
token inputs:sourceColorSpace = "${h.colorSpace === Kt ? "raw" : "sRGB"}"
|
|
697
|
+
token inputs:wrapS = "${d[h.wrapS]}"
|
|
698
|
+
token inputs:wrapT = "${d[h.wrapT]}"
|
|
699
|
+
float outputs:r
|
|
700
|
+
float outputs:g
|
|
701
|
+
float outputs:b
|
|
702
|
+
float3 outputs:rgb
|
|
703
|
+
${e.transparent || e.alphaTest > 0 ? "float outputs:a" : ""}
|
|
704
|
+
}`;
|
|
705
|
+
}
|
|
706
|
+
return e.side === Jt && console.warn("THREE.USDZExporter: USDZ does not support double sided materials", e), e.map !== null ? (r.push(`${s}color3f inputs:diffuseColor.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:rgb>`), e.transparent ? r.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`) : e.alphaTest > 0 && (r.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`), r.push(`${s}float inputs:opacityThreshold = ${e.alphaTest}`)), n.push(o(e.map, "diffuse", e.color))) : r.push(`${s}color3f inputs:diffuseColor = ${Xt(e.color)}`), e.emissiveMap !== null ? (r.push(`${s}color3f inputs:emissiveColor.connect = </Materials/Material_${e.id}/Texture_${e.emissiveMap.id}_emissive.outputs:rgb>`), n.push(o(e.emissiveMap, "emissive"))) : e.emissive.getHex() > 0 && r.push(`${s}color3f inputs:emissiveColor = ${Xt(e.emissive)}`), e.normalMap !== null && (r.push(`${s}normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`), n.push(o(e.normalMap, "normal"))), e.aoMap !== null && (r.push(`${s}float inputs:occlusion.connect = </Materials/Material_${e.id}/Texture_${e.aoMap.id}_occlusion.outputs:r>`), n.push(o(e.aoMap, "occlusion"))), e.roughnessMap !== null && e.roughness === 1 ? (r.push(`${s}float inputs:roughness.connect = </Materials/Material_${e.id}/Texture_${e.roughnessMap.id}_roughness.outputs:g>`), n.push(o(e.roughnessMap, "roughness"))) : r.push(`${s}float inputs:roughness = ${e.roughness}`), e.metalnessMap !== null && e.metalness === 1 ? (r.push(`${s}float inputs:metallic.connect = </Materials/Material_${e.id}/Texture_${e.metalnessMap.id}_metallic.outputs:b>`), n.push(o(e.metalnessMap, "metallic"))) : r.push(`${s}float inputs:metallic = ${e.metalness}`), e.alphaMap !== null ? (r.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`), r.push(`${s}float inputs:opacityThreshold = 0.0001`), n.push(o(e.alphaMap, "opacity"))) : r.push(`${s}float inputs:opacity = ${e.opacity}`), e.isMeshPhysicalMaterial && (r.push(`${s}float inputs:clearcoat = ${e.clearcoat}`), r.push(`${s}float inputs:clearcoatRoughness = ${e.clearcoatRoughness}`), r.push(`${s}float inputs:ior = ${e.ior}`)), `
|
|
707
|
+
def Material "Material_${e.id}"
|
|
708
|
+
{
|
|
709
|
+
def Shader "PreviewSurface"
|
|
710
|
+
{
|
|
711
|
+
uniform token info:id = "UsdPreviewSurface"
|
|
712
|
+
${r.join(`
|
|
713
|
+
`)}
|
|
714
|
+
int inputs:useSpecularWorkflow = 0
|
|
715
|
+
token outputs:surface
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
token outputs:surface.connect = </Materials/Material_${e.id}/PreviewSurface.outputs:surface>
|
|
719
|
+
|
|
720
|
+
${n.join(`
|
|
721
|
+
`)}
|
|
722
|
+
|
|
723
|
+
}
|
|
724
|
+
`;
|
|
725
|
+
}
|
|
726
|
+
function Xt(e) {
|
|
727
|
+
return `(${e.r}, ${e.g}, ${e.b})`;
|
|
728
|
+
}
|
|
729
|
+
function De(e) {
|
|
730
|
+
return `(${e.r}, ${e.g}, ${e.b}, 1.0)`;
|
|
731
|
+
}
|
|
732
|
+
function Ut(e) {
|
|
733
|
+
return `(${e.x}, ${e.y})`;
|
|
734
|
+
}
|
|
735
|
+
function Xe(e) {
|
|
736
|
+
const t = e.name ? e.name : "Camera_" + e.id, i = Qt(e.matrixWorld);
|
|
737
|
+
return e.matrixWorld.determinant() < 0 && console.warn("THREE.USDZExporter: USDZ does not support negative scales", e), e.isOrthographicCamera ? `def Camera "${t}"
|
|
738
|
+
{
|
|
739
|
+
matrix4d xformOp:transform = ${i}
|
|
740
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
741
|
+
|
|
742
|
+
float2 clippingRange = (${e.near.toPrecision(b)}, ${e.far.toPrecision(b)})
|
|
743
|
+
float horizontalAperture = ${((Math.abs(e.left) + Math.abs(e.right)) * 10).toPrecision(b)}
|
|
744
|
+
float verticalAperture = ${((Math.abs(e.top) + Math.abs(e.bottom)) * 10).toPrecision(b)}
|
|
745
|
+
token projection = "orthographic"
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
` : `def Camera "${t}"
|
|
749
|
+
{
|
|
750
|
+
matrix4d xformOp:transform = ${i}
|
|
751
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
752
|
+
|
|
753
|
+
float2 clippingRange = (${e.near.toPrecision(b)}, ${e.far.toPrecision(b)})
|
|
754
|
+
float focalLength = ${e.getFocalLength().toPrecision(b)}
|
|
755
|
+
float focusDistance = ${e.focus.toPrecision(b)}
|
|
756
|
+
float horizontalAperture = ${e.getFilmWidth().toPrecision(b)}
|
|
757
|
+
token projection = "perspective"
|
|
758
|
+
float verticalAperture = ${e.getFilmHeight().toPrecision(b)}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
`;
|
|
762
|
+
}
|
|
763
|
+
class Ue extends we {
|
|
764
|
+
parse(t, i) {
|
|
765
|
+
return super.parse(t, i);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
const bt = class bt {
|
|
769
|
+
static Launch(t, i) {
|
|
770
|
+
const s = new wt(), r = t.Root.clone(!0);
|
|
771
|
+
return s.add(...r.children), this.launchARFromNode(s, i);
|
|
772
|
+
}
|
|
773
|
+
static extractModels(t) {
|
|
774
|
+
return t.Root.children;
|
|
775
|
+
}
|
|
776
|
+
static launchARFromNode(t, i) {
|
|
777
|
+
return this._usdzExporter.parse(t, {
|
|
778
|
+
quickLookCompatible: !0,
|
|
779
|
+
ar: {
|
|
780
|
+
anchoring: { type: "plane" },
|
|
781
|
+
planeAnchoring: {
|
|
782
|
+
alignment: (i == null ? void 0 : i.arPlacement) === "vertical" ? "vertical" : "horizontal"
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}).then((s) => {
|
|
786
|
+
const r = new Blob([s], { type: "model/vnd.usdz+zip" });
|
|
787
|
+
let n = URL.createObjectURL(r);
|
|
788
|
+
(i == null ? void 0 : i.arScale) === "fixed" && (n = n.concat("#allowsContentScaling=0"));
|
|
789
|
+
const o = document.createElement("a");
|
|
790
|
+
o.innerHTML = "<picture></picture>", o.rel = "ar", o.href = n, o.download = "scene.usdz", o.click();
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
bt._usdzExporter = new Ue();
|
|
795
|
+
let Rt = bt;
|
|
796
|
+
class ke {
|
|
797
|
+
get Element() {
|
|
798
|
+
return this._element;
|
|
799
|
+
}
|
|
800
|
+
get CloseButton() {
|
|
801
|
+
return this._closeButton;
|
|
802
|
+
}
|
|
803
|
+
constructor() {
|
|
804
|
+
this._element = document.createElement("div"), this._closeButton = this.createCloseButton(), this._element.appendChild(this._closeButton), document.body.appendChild(this._element);
|
|
805
|
+
}
|
|
806
|
+
createCloseButton() {
|
|
807
|
+
const t = document.createElementNS(
|
|
808
|
+
"http://www.w3.org/2000/svg",
|
|
809
|
+
"path"
|
|
810
|
+
);
|
|
811
|
+
t.setAttribute("d", "M 12,12 L 28,28 M 28,12 12,28"), t.setAttribute("stroke", "#fff"), t.setAttribute("stroke-width", "2");
|
|
812
|
+
const i = document.createElementNS(
|
|
813
|
+
"http://www.w3.org/2000/svg",
|
|
814
|
+
"svg"
|
|
815
|
+
);
|
|
816
|
+
return i.setAttribute("width", "38"), i.setAttribute("height", "38"), i.style.position = "absolute", i.style.right = "20px", i.style.top = "20px", i.appendChild(t), i;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
class Le extends wt {
|
|
820
|
+
set mesh(t) {
|
|
821
|
+
this.clear(), t && this.add(t);
|
|
822
|
+
}
|
|
823
|
+
constructor(t) {
|
|
824
|
+
return super(), t ? this.mesh = t : this.UseDefaultMesh(), this.matrixAutoUpdate = !1, this;
|
|
825
|
+
}
|
|
826
|
+
UseDefaultMesh() {
|
|
827
|
+
const t = new te(0.08, 0.1, 32).rotateX(-Math.PI / 2), i = new ee();
|
|
828
|
+
this.mesh = new kt(t, i);
|
|
829
|
+
}
|
|
830
|
+
UpdateFromPose(t) {
|
|
831
|
+
this.matrix.fromArray(t.transform.matrix);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
class ze {
|
|
835
|
+
constructor(t, i) {
|
|
836
|
+
this._referenceSpaceBuffer = null, this._requesting = !1, this._initialized = !1, this._session = t, this._renderer = i, this._hitMatrixBuffer = new dt();
|
|
837
|
+
}
|
|
838
|
+
Dispose() {
|
|
839
|
+
var t;
|
|
840
|
+
(t = this._transientHitTestSource) == null || t.cancel(), this._transientHitTestSource = void 0, this._initialized = !1;
|
|
841
|
+
}
|
|
842
|
+
async Init() {
|
|
843
|
+
return this._session ? this._requesting ? (console.error(
|
|
844
|
+
"DIVEWebXRRaycaster: Currently initializing! Aborting initialization..."
|
|
845
|
+
), Promise.reject()) : this._initialized ? (console.error(
|
|
846
|
+
"DIVEWebXRRaycaster: Already initialized! Aborting initialization..."
|
|
847
|
+
), Promise.reject()) : (this._requesting = !0, this._transientHitTestSource = await this._session.requestHitTestSourceForTransientInput({
|
|
848
|
+
profile: "generic-touchscreen"
|
|
849
|
+
}), this._referenceSpaceBuffer = this._renderer.xr.getReferenceSpace(), this._requesting = !1, this._transientHitTestSource ? (this._initialized = !0, console.log("DIVEWebXRRaycasterAR: Initialized"), Promise.resolve(this)) : Promise.reject()) : (console.error(
|
|
850
|
+
"DIVEWebXRRaycaster: No session set in Init()! Aborting initialization..."
|
|
851
|
+
), Promise.reject());
|
|
852
|
+
}
|
|
853
|
+
GetIntersections(t) {
|
|
854
|
+
if (!this._transientHitTestSource) return [];
|
|
855
|
+
const i = t.getHitTestResultsForTransientInput(
|
|
856
|
+
this._transientHitTestSource
|
|
857
|
+
);
|
|
858
|
+
return i.length === 0 ? [] : i.map((r) => {
|
|
859
|
+
if (!this._referenceSpaceBuffer || !r.results[0] || !r.results[0].getPose) return;
|
|
860
|
+
const n = r.results[0].getPose(this._referenceSpaceBuffer);
|
|
861
|
+
return n ? (this._hitMatrixBuffer.fromArray(n.transform.matrix), {
|
|
862
|
+
point: new k().setFromMatrixPosition(
|
|
863
|
+
this._hitMatrixBuffer
|
|
864
|
+
),
|
|
865
|
+
matrix: this._hitMatrixBuffer,
|
|
866
|
+
object: void 0
|
|
867
|
+
}) : void 0;
|
|
868
|
+
}).filter((r) => r !== void 0);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
class Be {
|
|
872
|
+
constructor(t, i) {
|
|
873
|
+
this._raycaster = new ie(), this._renderer = t, this._scene = i, this._controller = this._renderer.xr.getController(0);
|
|
874
|
+
}
|
|
875
|
+
async Init() {
|
|
876
|
+
return console.log("DIVEWebXRRaycasterTHREE: Initialized"), Promise.resolve(this);
|
|
877
|
+
}
|
|
878
|
+
GetIntersections() {
|
|
879
|
+
this._controller.updateMatrixWorld(), this._raycaster.setFromXRController(this._controller);
|
|
880
|
+
const t = this._raycaster.intersectObjects(
|
|
881
|
+
this._scene.XRRoot.XRModelRoot.children
|
|
882
|
+
);
|
|
883
|
+
return t.length === 0 ? [] : t.map((i) => ({
|
|
884
|
+
point: i.point,
|
|
885
|
+
matrix: i.object.matrixWorld,
|
|
886
|
+
object: i.object
|
|
887
|
+
}));
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
class Yt {
|
|
891
|
+
constructor() {
|
|
892
|
+
this._listeners = /* @__PURE__ */ new Map();
|
|
893
|
+
}
|
|
894
|
+
Subscribe(t, i) {
|
|
895
|
+
return this._listeners.get(t) || this._listeners.set(t, []), this._listeners.get(t).push(i), () => {
|
|
896
|
+
const s = this._listeners.get(t);
|
|
897
|
+
if (!s) return !1;
|
|
898
|
+
const r = s.findIndex(
|
|
899
|
+
(n) => n === i
|
|
900
|
+
);
|
|
901
|
+
return r === -1 ? !1 : (s.splice(r, 1), !0);
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
dispatch(t, i) {
|
|
905
|
+
const s = this._listeners.get(t);
|
|
906
|
+
s && s.forEach((r) => r(i));
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
class Ve extends Yt {
|
|
910
|
+
constructor(t, i, s) {
|
|
911
|
+
super(), this._initialized = !1, this._arHitResultBuffer = [], this._sceneHitResultBuffer = [], this._hasHit = !1, this._session = t, this._threeRaycaster = new Be(i, s), this._arRaycaster = new ze(t, i);
|
|
912
|
+
}
|
|
913
|
+
Dispose() {
|
|
914
|
+
this._initialized = !1;
|
|
915
|
+
}
|
|
916
|
+
async Init() {
|
|
917
|
+
return this._session ? this._initialized ? (console.error(
|
|
918
|
+
"DIVEWebXRRaycaster: Already initialized! Aborting initialization..."
|
|
919
|
+
), Promise.reject()) : (await this._threeRaycaster.Init(), await this._arRaycaster.Init(), console.log("DIVEWebXRRaycaster: Initialized"), this._initialized = !0, Promise.resolve(this)) : (console.error(
|
|
920
|
+
"DIVEWebXRRaycaster: No session set in Init()! Aborting initialization..."
|
|
921
|
+
), Promise.reject());
|
|
922
|
+
}
|
|
923
|
+
GetARIntersections(t) {
|
|
924
|
+
return this._arHitResultBuffer = this._arRaycaster.GetIntersections(t), this._arHitResultBuffer.length > 0 ? this.onARHitFound(this._arHitResultBuffer[0]) : this.onARHitLost(), this._arHitResultBuffer;
|
|
925
|
+
}
|
|
926
|
+
GetSceneIntersections() {
|
|
927
|
+
return this._sceneHitResultBuffer = this._threeRaycaster.GetIntersections(), this._sceneHitResultBuffer.length > 0 ? this.onSceneHitFound(this._sceneHitResultBuffer[0]) : this.onSceneHitLost(), this._sceneHitResultBuffer;
|
|
928
|
+
}
|
|
929
|
+
onARHitFound(t) {
|
|
930
|
+
this._hasHit = !0, this.dispatch("AR_HIT_FOUND", { hit: t });
|
|
931
|
+
}
|
|
932
|
+
onARHitLost() {
|
|
933
|
+
this._hasHit && (this._hasHit = !1, this.dispatch("AR_HIT_LOST"));
|
|
934
|
+
}
|
|
935
|
+
onSceneHitFound(t) {
|
|
936
|
+
this._hasHit = !0, this.dispatch("SCENE_HIT_FOUND", { hit: t });
|
|
937
|
+
}
|
|
938
|
+
onSceneHitLost() {
|
|
939
|
+
this._hasHit && (this._hasHit = !1, this.dispatch("SCENE_HIT_LOST"));
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
class Ne {
|
|
943
|
+
constructor(t, i, s) {
|
|
944
|
+
this._raycastHitCounter = 0, this._originSetResolve = () => {
|
|
945
|
+
}, this._renderer = i, this._session = t, this._originSet = new Promise((r) => {
|
|
946
|
+
this._originSetResolve = r;
|
|
947
|
+
}), this._requesting = !1, this._initialized = !1, this._referenceSpaceBuffer = null, this._hitTestSource = null, this._entityTypes = s || ["plane"], this._hitTestResultBuffer = [], this._matrix = new dt(), this._position = new k(), this._quaternion = new et(), this._scale = new k(), this._originSet.then(() => {
|
|
948
|
+
this._matrix.decompose(
|
|
949
|
+
this._position,
|
|
950
|
+
this._quaternion,
|
|
951
|
+
this._scale
|
|
952
|
+
);
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
get originSet() {
|
|
956
|
+
return this._originSet;
|
|
957
|
+
}
|
|
958
|
+
get matrix() {
|
|
959
|
+
return this._matrix;
|
|
960
|
+
}
|
|
961
|
+
set matrix(t) {
|
|
962
|
+
this._matrix = t, this._matrix.decompose(this._position, this._quaternion, this._scale);
|
|
963
|
+
}
|
|
964
|
+
get position() {
|
|
965
|
+
return this._position;
|
|
966
|
+
}
|
|
967
|
+
get quaternion() {
|
|
968
|
+
return this._quaternion;
|
|
969
|
+
}
|
|
970
|
+
get scale() {
|
|
971
|
+
return this._scale;
|
|
972
|
+
}
|
|
973
|
+
async Init() {
|
|
974
|
+
if (this._initialized)
|
|
975
|
+
return Promise.resolve(this);
|
|
976
|
+
if (!this._session)
|
|
977
|
+
return console.error(
|
|
978
|
+
"DIVEWebXROrigin: No session set in Init()! Aborting initialization..."
|
|
979
|
+
), Promise.reject();
|
|
980
|
+
if (this._requesting)
|
|
981
|
+
return console.error(
|
|
982
|
+
"DIVEWebXROrigin: Currently initializing! Aborting initialization..."
|
|
983
|
+
), Promise.reject();
|
|
984
|
+
this._requesting = !0;
|
|
985
|
+
const t = await this._session.requestReferenceSpace("viewer");
|
|
986
|
+
return this._hitTestSource = await this._session.requestHitTestSource({
|
|
987
|
+
space: t,
|
|
988
|
+
entityTypes: this._entityTypes
|
|
989
|
+
}) || null, this._requesting = !1, this._hitTestSource ? (this._initialized = !0, Promise.resolve(this)) : Promise.reject();
|
|
990
|
+
}
|
|
991
|
+
Dispose() {
|
|
992
|
+
var t;
|
|
993
|
+
this._initialized = !1, this._requesting = !1, (t = this._hitTestSource) == null || t.cancel(), this._hitTestSource = null, this._hitTestResultBuffer = [], this._matrix = new dt(), this._position = new k(), this._quaternion = new et(), this._scale = new k();
|
|
994
|
+
}
|
|
995
|
+
Update(t) {
|
|
996
|
+
if (this._initialized) {
|
|
997
|
+
if (!this._hitTestSource)
|
|
998
|
+
throw new Error(
|
|
999
|
+
"DIVEWebXRRaycaster: Critical Error: HitTestSource not available but WebXROrigin is initialized!"
|
|
1000
|
+
);
|
|
1001
|
+
if (this._hitTestResultBuffer = t.getHitTestResults(
|
|
1002
|
+
this._hitTestSource
|
|
1003
|
+
), this._hitTestResultBuffer.length > 0) {
|
|
1004
|
+
if (this._referenceSpaceBuffer = this._renderer.xr.getReferenceSpace(), !this._referenceSpaceBuffer) {
|
|
1005
|
+
this.onHitLost();
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
const i = this._hitTestResultBuffer[0].getPose(
|
|
1009
|
+
this._referenceSpaceBuffer
|
|
1010
|
+
);
|
|
1011
|
+
if (!i) {
|
|
1012
|
+
this.onHitLost();
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
this.onHitFound(i);
|
|
1016
|
+
} else
|
|
1017
|
+
this.onHitLost();
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
onHitFound(t) {
|
|
1021
|
+
this._raycastHitCounter++, this.matrix.fromArray(t.transform.matrix), this._raycastHitCounter > 50 && this._originSetResolve();
|
|
1022
|
+
}
|
|
1023
|
+
onHitLost() {
|
|
1024
|
+
this._raycastHitCounter = 0;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
class je extends Yt {
|
|
1028
|
+
constructor(t) {
|
|
1029
|
+
super(), this._touchCount = 0, this._touches = [], this._handleRotateStarted = !1, this._handleRotateMoved = !1, this._handleRotateEnded = !1, this._startAngle = 0, this._lastAngle = 0, this._angleDelta = 0, this._handlePinchStarted = !1, this._handlePinchMoved = !1, this._handlePinchEnded = !1, this._scaleDistanceStart = 0, this._currentDistance = 1, this._deltaDistance = 0, this._session = t, this._touches = [
|
|
1030
|
+
{
|
|
1031
|
+
start: new Z(),
|
|
1032
|
+
current: new Z(),
|
|
1033
|
+
delta: new Z()
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
start: new Z(),
|
|
1037
|
+
current: new Z(),
|
|
1038
|
+
delta: new Z()
|
|
1039
|
+
}
|
|
1040
|
+
], this._handleRotateStarted = !1, window.addEventListener(
|
|
1041
|
+
"touchstart",
|
|
1042
|
+
(i) => this.onTouchStart(i)
|
|
1043
|
+
), window.addEventListener(
|
|
1044
|
+
"touchmove",
|
|
1045
|
+
(i) => this.onTouchMove(i)
|
|
1046
|
+
), window.addEventListener(
|
|
1047
|
+
"touchend",
|
|
1048
|
+
(i) => this.onTouchEnd(i)
|
|
1049
|
+
), this._session.addEventListener(
|
|
1050
|
+
"selectstart",
|
|
1051
|
+
() => this.onSessionSelectStart()
|
|
1052
|
+
), this._session.addEventListener(
|
|
1053
|
+
"selectend",
|
|
1054
|
+
() => this.onSessionSelectEnd()
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
Dispose() {
|
|
1058
|
+
window.removeEventListener(
|
|
1059
|
+
"touchstart",
|
|
1060
|
+
(t) => this.onTouchStart(t)
|
|
1061
|
+
), window.removeEventListener(
|
|
1062
|
+
"touchmove",
|
|
1063
|
+
(t) => this.onTouchMove(t)
|
|
1064
|
+
), window.removeEventListener(
|
|
1065
|
+
"touchend",
|
|
1066
|
+
(t) => this.onTouchEnd(t)
|
|
1067
|
+
), this._session.removeEventListener(
|
|
1068
|
+
"selectstart",
|
|
1069
|
+
() => this.onSessionSelectStart()
|
|
1070
|
+
), this._session.removeEventListener(
|
|
1071
|
+
"selectend",
|
|
1072
|
+
() => this.onSessionSelectEnd()
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
onTouchStart(t) {
|
|
1076
|
+
this._touchCount = t.touches.length, this._touches[0].start.set(
|
|
1077
|
+
t.touches[0].clientX,
|
|
1078
|
+
t.touches[0].clientY
|
|
1079
|
+
), this._touches[0].current.set(
|
|
1080
|
+
t.touches[0].clientX,
|
|
1081
|
+
t.touches[0].clientY
|
|
1082
|
+
), this._touches[0].delta.set(0, 0), this._touchCount > 1 && (this._touches[1].start.set(
|
|
1083
|
+
t.touches[1].clientX,
|
|
1084
|
+
t.touches[1].clientY
|
|
1085
|
+
), this._touches[1].current.set(
|
|
1086
|
+
t.touches[1].clientX,
|
|
1087
|
+
t.touches[1].clientY
|
|
1088
|
+
), this._touches[1].delta.set(0, 0)), this._touchCount === 2 && (this.handleRotateStart(), this.handlePinchStart()), this._handleRotateStarted && (this.dispatch("ROTATE_START", {
|
|
1089
|
+
current: 0
|
|
1090
|
+
}), this._handleRotateStarted = !1), this._handlePinchStarted && (this.dispatch("PINCH_START", {
|
|
1091
|
+
current: 0
|
|
1092
|
+
}), this._handlePinchStarted = !1);
|
|
1093
|
+
}
|
|
1094
|
+
onTouchMove(t) {
|
|
1095
|
+
this._touchCount = t.touches.length, this._touches[0].start.set(
|
|
1096
|
+
t.touches[0].clientX,
|
|
1097
|
+
t.touches[0].clientY
|
|
1098
|
+
), this._touches[0].current.set(
|
|
1099
|
+
t.touches[0].clientX,
|
|
1100
|
+
t.touches[0].clientY
|
|
1101
|
+
), this._touches[0].delta.copy(
|
|
1102
|
+
this._touches[0].current.clone().sub(this._touches[0].start)
|
|
1103
|
+
), this._touchCount > 1 && (this._touches[1].start.set(
|
|
1104
|
+
t.touches[1].clientX,
|
|
1105
|
+
t.touches[1].clientY
|
|
1106
|
+
), this._touches[1].current.set(
|
|
1107
|
+
t.touches[1].clientX,
|
|
1108
|
+
t.touches[1].clientY
|
|
1109
|
+
), this._touches[1].delta.copy(
|
|
1110
|
+
this._touches[1].current.clone().sub(this._touches[1].start)
|
|
1111
|
+
)), this._touchCount === 2 && (this.handleRotateMoved(), this.handlePinchMoved()), this._touchCount === 1 && this.dispatch("TOUCH_MOVE", {
|
|
1112
|
+
touches: [
|
|
1113
|
+
{
|
|
1114
|
+
current: this._touches[0].current.clone(),
|
|
1115
|
+
delta: this._touches[0].delta.clone()
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
current: this._touches[1].current.clone(),
|
|
1119
|
+
delta: this._touches[1].delta.clone()
|
|
1120
|
+
}
|
|
1121
|
+
],
|
|
1122
|
+
touchCount: this._touchCount
|
|
1123
|
+
}), this._touchCount === 2 && (this._handleRotateMoved && (this.dispatch("ROTATE_MOVE", {
|
|
1124
|
+
current: this._lastAngle,
|
|
1125
|
+
delta: this._angleDelta
|
|
1126
|
+
}), this._handleRotateMoved = !1), this._handlePinchMoved && (this.dispatch("PINCH_MOVE", {
|
|
1127
|
+
current: this._currentDistance,
|
|
1128
|
+
delta: this._deltaDistance
|
|
1129
|
+
}), this._handlePinchMoved = !1));
|
|
1130
|
+
}
|
|
1131
|
+
onTouchEnd(t) {
|
|
1132
|
+
this._touchCount = t.touches.length, this._touchCount === 0 && (this._touches[0].start.set(0, 0), this._touches[0].current.set(0, 0), this._touches[0].delta.set(0, 0)), this._touchCount === 1 && (this.handleRotateEnded(), this.handlePinchEnded(), this._touches[1].start.set(0, 0), this._touches[1].current.set(0, 0), this._touches[1].delta.set(0, 0)), this._handleRotateEnded && (this.dispatch("ROTATE_END", {
|
|
1133
|
+
current: this._lastAngle
|
|
1134
|
+
}), this._handleRotateEnded = !1), this._handlePinchEnded && (this.dispatch("PINCH_END", {
|
|
1135
|
+
current: this._currentDistance
|
|
1136
|
+
}), this._handlePinchEnded = !1);
|
|
1137
|
+
}
|
|
1138
|
+
onSessionSelectStart() {
|
|
1139
|
+
this.dispatch("TOUCH_START", {
|
|
1140
|
+
touches: [
|
|
1141
|
+
{
|
|
1142
|
+
current: this._touches[0].current.clone()
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
current: this._touches[1].current.clone()
|
|
1146
|
+
}
|
|
1147
|
+
],
|
|
1148
|
+
touchCount: this._touchCount
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
onSessionSelectEnd() {
|
|
1152
|
+
this.dispatch("TOUCH_END", {
|
|
1153
|
+
touches: [
|
|
1154
|
+
{
|
|
1155
|
+
current: this._touches[0].current.clone()
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
current: this._touches[1].current.clone()
|
|
1159
|
+
}
|
|
1160
|
+
],
|
|
1161
|
+
touchCount: this._touchCount
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
// rotation handler
|
|
1165
|
+
handleRotateStart() {
|
|
1166
|
+
this._handleRotateStarted = !0, this._startAngle = this._touches[1].start.clone().sub(this._touches[0].current).angle();
|
|
1167
|
+
}
|
|
1168
|
+
handleRotateMoved() {
|
|
1169
|
+
this._handleRotateMoved = !0;
|
|
1170
|
+
const t = this._touches[1].current.clone().sub(this._touches[0].current).angle();
|
|
1171
|
+
this._angleDelta = t - this._startAngle, this._lastAngle = this._angleDelta * -1;
|
|
1172
|
+
}
|
|
1173
|
+
handleRotateEnded() {
|
|
1174
|
+
this._handleRotateEnded = !0;
|
|
1175
|
+
}
|
|
1176
|
+
// pinch handler
|
|
1177
|
+
handlePinchStart() {
|
|
1178
|
+
this._handlePinchStarted = !0, this._scaleDistanceStart = this._touches[1].start.distanceTo(
|
|
1179
|
+
this._touches[0].current
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
handlePinchMoved() {
|
|
1183
|
+
this._handlePinchMoved = !0;
|
|
1184
|
+
const t = this._currentDistance, i = this._touches[1].current.distanceTo(
|
|
1185
|
+
this._touches[0].current
|
|
1186
|
+
);
|
|
1187
|
+
this._currentDistance = i / this._scaleDistanceStart, this._deltaDistance = this._currentDistance - t;
|
|
1188
|
+
}
|
|
1189
|
+
handlePinchEnded() {
|
|
1190
|
+
this._handlePinchEnded = !0;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
class We extends wt {
|
|
1194
|
+
constructor(t, i, s) {
|
|
1195
|
+
super(), this._frameBuffer = null, this._handNodeInitialPosition = new k(), this._placed = !1, this._grabbedObject = null, this._arHitPosition = new k(), this._arHitQuaternion = new et(), this._arHitScale = new k(1, 1, 1), this._initialObjectPosition = null, this._initialRaycastHit = null, this._deltaRaycastHit = new k(), this._touchQuaterion = new et(), this._touchScale = 1, this._scaleThreshold = 0.1, this._startTouchQuaternion = new et(), this._startTouchScale = 1, this._renderer = i, this._scene = s, this._session = t, this._xrRaycaster = new Ve(t, i, s), this._origin = new Ne(this._session, this._renderer, [
|
|
1196
|
+
"plane"
|
|
1197
|
+
]), this._crosshair = new Le(), this._crosshair.visible = !1, this._xrCamera = this._renderer.xr.getCamera(), this._scene.XRRoot.XRHandNode.position.set(0, -0.05, -0.25), this._handNodeInitialPosition = this._scene.XRRoot.XRHandNode.position.clone(), this._touchscreenControls = new je(
|
|
1198
|
+
this._session
|
|
1199
|
+
), this._touchscreenControls.Subscribe(
|
|
1200
|
+
"TOUCH_START",
|
|
1201
|
+
() => this.onTouchStart()
|
|
1202
|
+
), this._touchscreenControls.Subscribe(
|
|
1203
|
+
"TOUCH_MOVE",
|
|
1204
|
+
() => this.onTouchMove()
|
|
1205
|
+
), this._touchscreenControls.Subscribe(
|
|
1206
|
+
"TOUCH_END",
|
|
1207
|
+
(r) => this.onTouchEnd(r)
|
|
1208
|
+
), this._touchscreenControls.Subscribe(
|
|
1209
|
+
"ROTATE_START",
|
|
1210
|
+
() => this.onRotateStart()
|
|
1211
|
+
), this._touchscreenControls.Subscribe(
|
|
1212
|
+
"ROTATE_MOVE",
|
|
1213
|
+
(r) => this.onRotateMove(r)
|
|
1214
|
+
), this._touchscreenControls.Subscribe(
|
|
1215
|
+
"PINCH_START",
|
|
1216
|
+
() => this.onPinchStart()
|
|
1217
|
+
), this._touchscreenControls.Subscribe(
|
|
1218
|
+
"PINCH_MOVE",
|
|
1219
|
+
(r) => this.onPinchMove(r)
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
async Init() {
|
|
1223
|
+
return this.prepareScene(), await this.initOrigin(), await this.initRaycaster(), Promise.resolve(this);
|
|
1224
|
+
}
|
|
1225
|
+
Dispose() {
|
|
1226
|
+
this.restoreScene(), this._origin.Dispose(), this._xrRaycaster.Dispose(), this._placed = !1;
|
|
1227
|
+
}
|
|
1228
|
+
Update(t) {
|
|
1229
|
+
this._frameBuffer = t, this._placed || (this.updateHandNode(), this._origin && this._origin.Update(t));
|
|
1230
|
+
}
|
|
1231
|
+
updateHandNode() {
|
|
1232
|
+
this._xrCamera.updateMatrixWorld(), this._scene.XRRoot.XRHandNode.position.copy(
|
|
1233
|
+
this._handNodeInitialPosition.clone().applyMatrix4(this._xrCamera.matrixWorld)
|
|
1234
|
+
), this._scene.XRRoot.XRHandNode.quaternion.setFromRotationMatrix(
|
|
1235
|
+
this._xrCamera.matrixWorld
|
|
1236
|
+
);
|
|
1237
|
+
}
|
|
1238
|
+
// placement
|
|
1239
|
+
async initOrigin() {
|
|
1240
|
+
this._origin = await this._origin.Init(), this._origin.originSet.then(() => {
|
|
1241
|
+
this.placeObjects(this._origin.matrix);
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
placeObjects(t) {
|
|
1245
|
+
this._scene.XRRoot.XRModelRoot.matrix.copy(t), [...this._scene.XRRoot.XRHandNode.children].forEach((i) => {
|
|
1246
|
+
this._scene.XRRoot.XRModelRoot.add(i);
|
|
1247
|
+
}), this._placed = !0;
|
|
1248
|
+
}
|
|
1249
|
+
// grabbing
|
|
1250
|
+
updateObject() {
|
|
1251
|
+
this._grabbedObject && (this._grabbedObject.position.copy(this._arHitPosition), this._grabbedObject.quaternion.copy(
|
|
1252
|
+
this._arHitQuaternion.clone().multiply(this._touchQuaterion)
|
|
1253
|
+
), this._grabbedObject.scale.copy(
|
|
1254
|
+
new k(
|
|
1255
|
+
this._touchScale,
|
|
1256
|
+
this._touchScale,
|
|
1257
|
+
this._touchScale
|
|
1258
|
+
).multiply(this._arHitScale)
|
|
1259
|
+
));
|
|
1260
|
+
}
|
|
1261
|
+
onTouchStart() {
|
|
1262
|
+
const t = this._xrRaycaster.GetSceneIntersections();
|
|
1263
|
+
if (console.log("sceneHits", t), t.length === 0 || !t[0].object) return;
|
|
1264
|
+
const i = Lt(
|
|
1265
|
+
t[0].object,
|
|
1266
|
+
"isMovable"
|
|
1267
|
+
);
|
|
1268
|
+
i && (this._grabbedObject = i);
|
|
1269
|
+
}
|
|
1270
|
+
onTouchMove() {
|
|
1271
|
+
if (!this._frameBuffer || !this._grabbedObject) return;
|
|
1272
|
+
const t = this._xrRaycaster.GetARIntersections(
|
|
1273
|
+
this._frameBuffer
|
|
1274
|
+
);
|
|
1275
|
+
if (t.length === 0) {
|
|
1276
|
+
this._crosshair.visible = !1;
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
const i = t[0];
|
|
1280
|
+
this._crosshair.visible = !0, this._crosshair.matrix.copy(i.matrix), this._grabbedObject && ((!this._initialObjectPosition || !this._initialRaycastHit) && (this._initialObjectPosition = this._grabbedObject.position.clone(), this._initialRaycastHit = i.point.clone()), i.matrix.decompose(
|
|
1281
|
+
this._arHitPosition,
|
|
1282
|
+
this._arHitQuaternion,
|
|
1283
|
+
this._arHitScale
|
|
1284
|
+
), this._deltaRaycastHit.copy(
|
|
1285
|
+
i.point.clone().sub(this._initialRaycastHit)
|
|
1286
|
+
), this._arHitPosition.copy(
|
|
1287
|
+
this._initialObjectPosition.clone().add(this._deltaRaycastHit)
|
|
1288
|
+
), console.log("arHitPosition", this._arHitPosition), this.updateObject());
|
|
1289
|
+
}
|
|
1290
|
+
onTouchEnd(t) {
|
|
1291
|
+
t.touchCount === 0 && (this._crosshair.visible = !1, this._initialObjectPosition = null, this._initialRaycastHit = null, this._grabbedObject = null);
|
|
1292
|
+
}
|
|
1293
|
+
onRotateStart() {
|
|
1294
|
+
this._startTouchQuaternion = this._touchQuaterion.clone();
|
|
1295
|
+
}
|
|
1296
|
+
onRotateMove(t) {
|
|
1297
|
+
this._touchQuaterion.setFromAxisAngle(
|
|
1298
|
+
new k(0, -1, 0),
|
|
1299
|
+
t.delta * 3
|
|
1300
|
+
), this._touchQuaterion.multiply(this._startTouchQuaternion), this.updateObject();
|
|
1301
|
+
}
|
|
1302
|
+
onPinchStart() {
|
|
1303
|
+
this._startTouchScale = this._touchScale;
|
|
1304
|
+
}
|
|
1305
|
+
onPinchMove(t) {
|
|
1306
|
+
this._touchScale = this._startTouchScale * t.current, this.updateObject();
|
|
1307
|
+
}
|
|
1308
|
+
// prepare & cleanup scene
|
|
1309
|
+
prepareScene() {
|
|
1310
|
+
this._scene.XRRoot.XRModelRoot.matrixAutoUpdate = !1, this._scene.add(this._crosshair);
|
|
1311
|
+
const t = [];
|
|
1312
|
+
this._scene.Root.children.forEach((i) => {
|
|
1313
|
+
const s = i.clone();
|
|
1314
|
+
s.layers.enableAll(), s.traverse((r) => {
|
|
1315
|
+
r.layers.enableAll(), r instanceof kt && r.scale.set(0.1, 0.1, 0.1);
|
|
1316
|
+
}), s.position.set(0, 0, 0), t.push(s);
|
|
1317
|
+
}), this._scene.XRRoot.XRHandNode.add(...t);
|
|
1318
|
+
}
|
|
1319
|
+
restoreScene() {
|
|
1320
|
+
this._scene.remove(this._crosshair), this._scene.XRRoot.XRHandNode.clear(), this._scene.XRRoot.XRModelRoot.clear(), this._scene.XRRoot.XRModelRoot.matrixAutoUpdate = !0;
|
|
1321
|
+
}
|
|
1322
|
+
// raycast
|
|
1323
|
+
async initRaycaster() {
|
|
1324
|
+
if (await this._xrRaycaster.Init(), !this._xrRaycaster)
|
|
1325
|
+
return console.error(
|
|
1326
|
+
"Raycaster not initialized successfully. Aborting WebXR..."
|
|
1327
|
+
), this.Dispose(), Promise.reject();
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
const E = class E {
|
|
1331
|
+
static async Launch(t, i, s) {
|
|
1332
|
+
if (this._renderer = t, this._scene = i, this._controller = s, this._cameraPosition = this._controller.object.position.clone(), this._cameraTarget = this._controller.target.clone(), !navigator.xr)
|
|
1333
|
+
return console.error("WebXR not supported"), Promise.reject();
|
|
1334
|
+
if (this._renderer.xr.enabled = !0, this._scene.InitXR(t), !E._overlay) {
|
|
1335
|
+
const n = new ke();
|
|
1336
|
+
E._overlay = n;
|
|
1337
|
+
}
|
|
1338
|
+
E._options.domOverlay = { root: E._overlay.Element };
|
|
1339
|
+
const r = await navigator.xr.requestSession(
|
|
1340
|
+
"immersive-ar",
|
|
1341
|
+
this._options
|
|
1342
|
+
);
|
|
1343
|
+
return r.addEventListener("end", () => {
|
|
1344
|
+
this._onSessionEnded();
|
|
1345
|
+
}), t.xr.setReferenceSpaceType(this._referenceSpaceType), await t.xr.setSession(r), E._overlay.Element.style.display = "", this._session = r, E._overlay.CloseButton.addEventListener(
|
|
1346
|
+
"click",
|
|
1347
|
+
() => this.End()
|
|
1348
|
+
), await this._onSessionStarted(), Promise.resolve();
|
|
1349
|
+
}
|
|
1350
|
+
static Update(t, i) {
|
|
1351
|
+
this._session && this._xrController && this._xrController.Update(i);
|
|
1352
|
+
}
|
|
1353
|
+
static End() {
|
|
1354
|
+
this._session && this._session.end();
|
|
1355
|
+
}
|
|
1356
|
+
static async _onSessionStarted() {
|
|
1357
|
+
if (this._session)
|
|
1358
|
+
return this._renderCallbackId = this._renderer.AddPreRenderCallback(
|
|
1359
|
+
(t, i) => {
|
|
1360
|
+
this.Update(t, i);
|
|
1361
|
+
}
|
|
1362
|
+
), this._xrController = new We(
|
|
1363
|
+
this._session,
|
|
1364
|
+
this._renderer,
|
|
1365
|
+
this._scene
|
|
1366
|
+
), await this._xrController.Init().catch(() => {
|
|
1367
|
+
this.End();
|
|
1368
|
+
}), Promise.resolve();
|
|
1369
|
+
}
|
|
1370
|
+
static _onSessionEnded() {
|
|
1371
|
+
if (!this._session) return;
|
|
1372
|
+
this._xrController && this._xrController.Dispose(), this._renderCallbackId && (this._renderer.RemovePreRenderCallback(this._renderCallbackId), this._renderCallbackId = null), this._renderer.xr.enabled = !1;
|
|
1373
|
+
const t = this._renderer.domElement.parentElement;
|
|
1374
|
+
if (t) {
|
|
1375
|
+
const { clientWidth: i, clientHeight: s } = t;
|
|
1376
|
+
this._renderer.OnResize(i, s), this._controller.object.OnResize(i, s);
|
|
1377
|
+
}
|
|
1378
|
+
this._controller.object.position.copy(this._cameraPosition), this._controller.target.copy(this._cameraTarget), this._cameraPosition.set(0, 0, 0), this._cameraTarget.set(0, 0, 0), this._scene.DisposeXR(), this._session.removeEventListener("end", this._onSessionEnded), E._overlay.Element.style.display = "none", this._session = null;
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
E._renderCallbackId = null, E._session = null, E._referenceSpaceType = "local", E._overlay = null, E._options = {
|
|
1382
|
+
requiredFeatures: [
|
|
1383
|
+
"local",
|
|
1384
|
+
"hit-test"
|
|
1385
|
+
],
|
|
1386
|
+
optionalFeatures: [
|
|
1387
|
+
"light-estimation",
|
|
1388
|
+
"local-floor",
|
|
1389
|
+
"dom-overlay",
|
|
1390
|
+
"depth-sensing"
|
|
1391
|
+
],
|
|
1392
|
+
depthSensing: {
|
|
1393
|
+
usagePreference: ["gpu-optimized"],
|
|
1394
|
+
dataFormatPreference: []
|
|
1395
|
+
},
|
|
1396
|
+
domOverlay: { root: {} }
|
|
1397
|
+
}, E._xrController = null;
|
|
1398
|
+
let St = E;
|
|
1399
|
+
class Fe {
|
|
1400
|
+
static Launch(t, i) {
|
|
1401
|
+
const s = this.findSceneViewerSrc(t);
|
|
1402
|
+
this.launchSceneViewer(s, i);
|
|
1403
|
+
}
|
|
1404
|
+
static launchSceneViewer(t, i) {
|
|
1405
|
+
const s = document.createElement("a"), r = "#model-viewer-no-ar-fallback", n = self.location.toString(), o = new URL(n), h = new URL(t, n), c = new URLSearchParams(h.search);
|
|
1406
|
+
o.hash = r, c.set("mode", "ar_only"), (i == null ? void 0 : i.arScale) === "fixed" && c.set("resizable", "false"), (i == null ? void 0 : i.arPlacement) === "vertical" && c.set("enable_vertical_placement", "true");
|
|
1407
|
+
const u = `intent://arvr.google.com/scene-viewer/1.2?${c.toString() + "&file=" + h.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(
|
|
1408
|
+
o.toString()
|
|
1409
|
+
)};end;`;
|
|
1410
|
+
s.setAttribute("href", u), s.click();
|
|
1411
|
+
}
|
|
1412
|
+
static findSceneViewerSrc(t) {
|
|
1413
|
+
let i = null;
|
|
1414
|
+
if (t.traverse((s) => {
|
|
1415
|
+
i || s.userData.uri && (i = s.userData.uri);
|
|
1416
|
+
}), !i)
|
|
1417
|
+
throw new Error("No model found in scene");
|
|
1418
|
+
return i;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
class Qe {
|
|
1422
|
+
constructor(t, i, s) {
|
|
1423
|
+
this._renderer = t, this._scene = i, this._controller = s;
|
|
1424
|
+
}
|
|
1425
|
+
async Launch(t) {
|
|
1426
|
+
const i = st.GetSystem();
|
|
1427
|
+
if (i === "iOS")
|
|
1428
|
+
return this.tryARQuickLook();
|
|
1429
|
+
if (i === "Android")
|
|
1430
|
+
return t != null && t.useWebXR ? (console.warn("DIVE: WebXR is experimental on Android."), this.tryWebXR()) : this.trySceneViewer();
|
|
1431
|
+
console.log(
|
|
1432
|
+
"DIVE: AR not supported. Not a mobile system. (System is " + i + ")"
|
|
1433
|
+
);
|
|
1434
|
+
}
|
|
1435
|
+
async tryARQuickLook(t) {
|
|
1436
|
+
return st.GetSupportsARQuickLook() ? (console.log("DIVE: Launching AR with ARQuickLook ..."), await Rt.Launch(this._scene, t), Promise.resolve()) : (console.log("ARQuickLook not supported"), Promise.reject());
|
|
1437
|
+
}
|
|
1438
|
+
async tryWebXR() {
|
|
1439
|
+
return await st.GetSupportsWebXR() ? (console.log("DIVE: Launching AR with WebXR ..."), await St.Launch(this._renderer, this._scene, this._controller), Promise.resolve()) : (console.log(
|
|
1440
|
+
"WebXR not supported. Reason: " + se[st.GetWebXRUnsupportedReason()]
|
|
1441
|
+
), Promise.reject());
|
|
1442
|
+
}
|
|
1443
|
+
async trySceneViewer(t) {
|
|
1444
|
+
return console.log("DIVE: Launching AR with SceneViewer ..."), Fe.Launch(this._scene, t), Promise.resolve();
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
export {
|
|
1448
|
+
Qe as DIVEAR
|
|
1449
|
+
};
|
|
1450
|
+
//# sourceMappingURL=AR-B-g0updz.js.map
|