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