@vincentt-xr/sdk 2.0.0-alpha.10 → 2.0.0-alpha.12
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/GROUNDING.md +95 -8
- package/dist/{CanonicalHeadFrame-D_0OzdB9.cjs → CanonicalHeadFrame-CZFvPzN_.cjs} +1 -1
- package/dist/{CanonicalHeadFrame-DdUqF6Fv.js → CanonicalHeadFrame-vn-jM9fG.js} +3 -3
- package/dist/{DebuggerUI-D-rcPa54.js → DebuggerUI-DDpU-nBF.js} +1 -1
- package/dist/{DebuggerUI-CVuV-VJ5.cjs → DebuggerUI-Db-1VtQJ.cjs} +1 -1
- package/dist/{FaceRetouch-C1AxBNex.js → FaceRetouch-D2xH5OpW.js} +4 -4
- package/dist/{FaceRetouch-D7kryDE6.cjs → FaceRetouch-DHhn1nSV.cjs} +1 -1
- package/dist/{TextLabel-c9BCucOI.js → TextLabel-C6F5xoaz.js} +182 -180
- package/dist/TextLabel-ChZCoB3P.cjs +2 -0
- package/dist/{bodyMaskMaterial-Cs2awskk.js → bodyMaskMaterial-C3aXItLo.js} +1 -1
- package/dist/{bodyMaskMaterial-CBWub5t_.cjs → bodyMaskMaterial-Q6rYywwW.cjs} +1 -1
- package/dist/{cache-2x3CUJuY.js → cache-C85JjyZA.js} +2 -2
- package/dist/{cache-DL1Dbz6k.cjs → cache-DFqZYsHC.cjs} +1 -1
- package/dist/components/ScreenImage/ScreenImage.d.ts +4 -1
- package/dist/components/ScreenShape/index.d.ts +4 -1
- package/dist/components/ScreenText/index.d.ts +4 -1
- package/dist/components/SegmentationOverlay/settings.d.ts +2 -2
- package/dist/components/TextLabel/TextLabel.d.ts +1 -1
- package/dist/{contexts-Y_FhdnIv.js → contexts-B5GODwuV.js} +2 -2
- package/dist/{contexts-DQc7zyqT.cjs → contexts-CSz9stBV.cjs} +1 -1
- package/dist/coordinates/index.d.ts +1 -1
- package/dist/coordinates/viewport.d.ts +10 -0
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +1 -1
- package/dist/debug-ui.cjs +1 -1
- package/dist/debug-ui.js +11 -11
- package/dist/{drawNormalizedCrop-DG3gtJxf.js → drawNormalizedCrop-BLfB484W.js} +5 -5
- package/dist/{drawNormalizedCrop-C4KFaRne.cjs → drawNormalizedCrop-DaGT5mZ5.cjs} +1 -1
- package/dist/entries/core.d.ts +1 -1
- package/dist/face-effects.cjs +1 -1
- package/dist/face-effects.js +17 -17
- package/dist/footage-input/index.d.ts +46 -0
- package/dist/{getFaceInfo-BzlwHMjX.cjs → getFaceInfo-BbcKq8PJ.cjs} +1 -1
- package/dist/{getFaceInfo-BafgGT27.js → getFaceInfo-D_tCSQC7.js} +1 -1
- package/dist/{index-DiIoHK_4.js → index-B9DdHE4u.js} +1 -1
- package/dist/{index-Cyk_VIZE.js → index-BaNlidsb.js} +279 -273
- package/dist/index-BzGLgXJm.cjs +46 -0
- package/dist/{index-iIQ9jBDb.js → index-CNt8esFO.js} +1 -1
- package/dist/{index-CKRN-xJp.js → index-CTqQJj5p.js} +1249 -1175
- package/dist/{index-ItufYyHH.cjs → index-CelqbDSR.cjs} +1 -1
- package/dist/index-Cm3v6Dlg.cjs +21 -0
- package/dist/{index-vr2ichWQ.js → index-D10O6vqR.js} +2 -2
- package/dist/{index-S3gqudT6.cjs → index-DIYaENN3.cjs} +1 -1
- package/dist/{index-CUldCMRl.js → index-DlP4xxaT.js} +1 -1
- package/dist/{index-D-4w34GO.cjs → index-DzdKBXGE.cjs} +1 -1
- package/dist/index-J3Qy6hi3.cjs +1 -0
- package/dist/{index-By_LCo2V.cjs → index-LC2Xs08E.cjs} +1 -1
- package/dist/{index-BZoBxyLn.js → index-bL819L-K.js} +387 -375
- package/dist/instructions.cjs +1 -1
- package/dist/instructions.js +8 -8
- package/dist/{internal-Bb9ZXbpr.cjs → internal-DS8Pdlsm.cjs} +1 -1
- package/dist/{internal-Gt1wn6Z3.js → internal-TD4QhIry.js} +3 -3
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/{landmarks-BEjJXcnE.cjs → landmarks-BP6RbRHN.cjs} +1 -1
- package/dist/{landmarks-DtCAFV_m.js → landmarks-vLy5QKt6.js} +1 -1
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +40 -40
- package/dist/main.cjs +1 -1
- package/dist/main.js +234 -230
- package/dist/particles.cjs +1 -1
- package/dist/particles.js +5 -5
- package/dist/product.cjs +1 -1
- package/dist/product.js +2 -2
- package/dist/{providers-CEZQgz2s.cjs → providers-BRSbw214.cjs} +1 -1
- package/dist/{providers-CRuaD8bi.js → providers-DmJlgrDD.js} +3 -3
- package/dist/{renderGroups-BADrepA1.cjs → renderGroups-B0N58SIA.cjs} +1 -1
- package/dist/{renderGroups-CNB99dZ2.js → renderGroups-BcQYy_J2.js} +1 -1
- package/dist/{renderPasses-DgxUKn9b.cjs → renderPasses-Bt8k0dkm.cjs} +1 -1
- package/dist/{renderPasses-DuapJA6V.js → renderPasses-DIPTIU_x.js} +4 -4
- package/dist/scene-object.cjs +1 -1
- package/dist/scene-object.js +2 -2
- package/dist/screen2d/coordinates.d.ts +37 -0
- package/dist/{segmentation-BOZJdWFC.js → segmentation-CZs5aVvY.js} +1 -1
- package/dist/{segmentation-J8GoNBvP.cjs → segmentation-Cz7oeNcS.cjs} +1 -1
- package/dist/{selectors-QB2qsaxy.cjs → selectors-Bq6tSgOY.cjs} +1 -1
- package/dist/{selectors-BvJepq6H.js → selectors-K5JKCWxw.js} +1 -1
- package/dist/{session-BVX859as.cjs → session-3aCMNb8W.cjs} +1 -1
- package/dist/{session-Cz8aie4K.js → session-DHBNTyJJ.js} +1 -1
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +75 -75
- package/dist/{trigger-D9L4GPmQ.js → trigger-BwZ81ENx.js} +7 -7
- package/dist/{trigger-DZ9vU7jo.cjs → trigger-UjeJY5uh.cjs} +1 -1
- package/dist/{useBodies-BYzJpQ4L.js → useBodies-BMKHXAOL.js} +2 -2
- package/dist/{useBodies-Cxpmx6Bb.cjs → useBodies-CXomEo0i.cjs} +1 -1
- package/dist/useEditOverrides-BTkPGVjN.js +38 -0
- package/dist/useEditOverrides-C3ZVXuIH.cjs +1 -0
- package/dist/{useFaceInfo-DlLRAVNw.cjs → useFaceInfo-BEMMiZxw.cjs} +1 -1
- package/dist/{useFaceInfo-BzEUj2OI.js → useFaceInfo-BNVdnprN.js} +4 -4
- package/dist/{useFaceResultReader-Cc4Qrutf.js → useFaceResultReader-B15wn6RB.js} +1 -1
- package/dist/{useFaceResultReader-D3jOQNKz.cjs → useFaceResultReader-D9qibKmm.cjs} +1 -1
- package/dist/{useIrisTracking-Bz4uLDa7.js → useIrisTracking-CYm-KDIZ.js} +10 -10
- package/dist/{useIrisTracking-DRGWgoNy.cjs → useIrisTracking-DExhnhlt.cjs} +1 -1
- package/dist/{useXRCapabilities-B1KLckqw.js → useXRCapabilities-ClWlG5_Y.js} +1 -1
- package/dist/{useXRCapabilities-CZlPUBjF.cjs → useXRCapabilities-D-EhcDzM.cjs} +1 -1
- package/dist/utils/useEditOverrides.d.ts +33 -0
- package/docs/api/face-info.mdx +1 -1
- package/docs/api/screen-space-coordinates.mdx +17 -9
- package/docs/api/session-lifecycle.mdx +29 -0
- package/package.json +1 -1
- package/settings.json +64 -13
- package/dist/TextLabel-XE0rQSDn.cjs +0 -2
- package/dist/index-C-Mryx_u.cjs +0 -21
- package/dist/index-Dv3WnY9n.cjs +0 -46
- package/dist/index-Sho4F4it.cjs +0 -1
|
@@ -1,12 +1,70 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsxs as
|
|
5
|
-
import { useRef as
|
|
6
|
-
import { FilesetResolver as $, PoseLandmarker as
|
|
7
|
-
import * as
|
|
8
|
-
import { Vector2 as
|
|
9
|
-
|
|
1
|
+
var Ps = Object.defineProperty;
|
|
2
|
+
var _s = (e, s, t) => s in e ? Ps(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
|
|
3
|
+
var m = (e, s, t) => _s(e, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { jsxs as Ds, jsx as xt } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as ue, useMemo as xe, useEffect as de, useContext as et, useCallback as St, createElement as Os, createContext as Lt, useState as Ls } from "react";
|
|
6
|
+
import { FilesetResolver as $, PoseLandmarker as Ns, FaceLandmarker as Bs, GestureRecognizer as Hs, HolisticLandmarker as Us, HandLandmarker as zs, ImageSegmenter as Nt, DrawingUtils as Ws } from "@mediapipe/tasks-vision";
|
|
7
|
+
import * as W from "three";
|
|
8
|
+
import { Vector2 as qs, Raycaster as Vs, Ray as Ks, Vector3 as Gs, RGBAFormat as Bt, LinearFilter as Ie, CanvasTexture as Ht, SRGBColorSpace as Xs } from "three";
|
|
9
|
+
var I = /* @__PURE__ */ ((e) => (e.WEBCAM = "webcam", e.STREAM = "stream", e.CANVAS = "canvas", e))(I || {}), P = /* @__PURE__ */ ((e) => (e.HAND_TRACKER = "vincentt.xr.hand-tracker", e.GESTURE_TRACKER = "vincentt.xr.gesture-tracker", e.FACE_TRACKER = "vincentt.xr.face-tracker", e.BODY_TRACKER = "vincentt.xr.body-tracker", e.HOLISTIC_TRACKER = "vincentt.xr.holistic-tracker", e.BACKGROUND_SEGMENTATION = "vincentt.xr.background-segmentation", e.SEMANTIC_SEGMENTATION = "vincentt.xr.semantic-segmentation", e))(P || {});
|
|
10
|
+
class O extends Error {
|
|
11
|
+
constructor(s) {
|
|
12
|
+
super(s), this.name = "VincenttXRError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const Ce = Symbol.for("vincentt.xr.footage-input"), js = (e) => {
|
|
16
|
+
if (!e) return !1;
|
|
17
|
+
try {
|
|
18
|
+
return e.self !== e.top;
|
|
19
|
+
} catch {
|
|
20
|
+
return !1;
|
|
21
|
+
}
|
|
22
|
+
}, Ys = "FootageSupersededError", ze = () => {
|
|
23
|
+
const e = new Error("superseded");
|
|
24
|
+
return e.name = Ys, e;
|
|
25
|
+
}, Qs = (e) => {
|
|
26
|
+
let s = null, t = !1, n = !1;
|
|
27
|
+
const i = () => {
|
|
28
|
+
if (n || t || !s || e.store.getSnapshot().lifecycle !== "running") return;
|
|
29
|
+
const h = s;
|
|
30
|
+
s = null, t = !0;
|
|
31
|
+
let u;
|
|
32
|
+
try {
|
|
33
|
+
u = e.setMediaSource(h.params);
|
|
34
|
+
} catch (p) {
|
|
35
|
+
u = Promise.reject(p);
|
|
36
|
+
}
|
|
37
|
+
u.then(h.resolve, h.reject).finally(() => {
|
|
38
|
+
t = !1, i();
|
|
39
|
+
});
|
|
40
|
+
}, r = e.store.subscribe(i), a = (h) => n ? Promise.reject(ze()) : new Promise((u, p) => {
|
|
41
|
+
s == null || s.reject(ze()), s = { params: h, resolve: u, reject: p }, i();
|
|
42
|
+
}), o = (h, u) => {
|
|
43
|
+
let p;
|
|
44
|
+
if (u === "video") p = "video";
|
|
45
|
+
else if (u === "image") p = "image";
|
|
46
|
+
else return Promise.reject(new O(`Invalid footage kind: ${String(u)}`));
|
|
47
|
+
return typeof h != "object" || h === null || typeof h.getTracks != "function" ? Promise.reject(new O("Footage stream must be a MediaStream")) : a({ source: I.STREAM, stream: h, sourceKind: p });
|
|
48
|
+
}, d = () => a({ source: I.WEBCAM }), l = () => {
|
|
49
|
+
n || (n = !0, r(), s == null || s.reject(ze()), s = null);
|
|
50
|
+
};
|
|
51
|
+
return { handle: Object.freeze({ v: 1, setStream: o, useCamera: d }), dispose: l };
|
|
52
|
+
}, Js = (e, s = typeof window > "u" ? void 0 : window) => {
|
|
53
|
+
if (!s || !js(s)) return () => {
|
|
54
|
+
};
|
|
55
|
+
const t = s;
|
|
56
|
+
if (t[Ce] !== void 0) return () => {
|
|
57
|
+
};
|
|
58
|
+
const n = Qs(e);
|
|
59
|
+
return Object.defineProperty(s, Ce, {
|
|
60
|
+
value: n.handle,
|
|
61
|
+
configurable: !0,
|
|
62
|
+
enumerable: !1,
|
|
63
|
+
writable: !1
|
|
64
|
+
}), () => {
|
|
65
|
+
n.dispose(), t[Ce] === n.handle && delete t[Ce];
|
|
66
|
+
};
|
|
67
|
+
}, q = {
|
|
10
68
|
// Pinned to the CDN, NOT build-env-driven: a stale VITE_ASSET_STORAGE_ENDPOINT
|
|
11
69
|
// baked a now-deleted CloudFront domain into every published bundle, breaking
|
|
12
70
|
// WASM/model loads at runtime. The host must never come from a mutable env value.
|
|
@@ -19,12 +77,10 @@ const W = {
|
|
|
19
77
|
debugMediaBaseUrl: "https://cdn.vincentt.studio/assets/sdk/debug-ui/v1",
|
|
20
78
|
loggerPrefix: "[vincentt-xr]:",
|
|
21
79
|
sessionCheckInterval: 3e4
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const He = (e) => Array.from({ length: e }, () => ({ x: 0, y: 0, z: 0 }));
|
|
25
|
-
class Ks {
|
|
80
|
+
}, We = (e) => Array.from({ length: e }, () => ({ x: 0, y: 0, z: 0 }));
|
|
81
|
+
class Zs {
|
|
26
82
|
constructor(s) {
|
|
27
|
-
|
|
83
|
+
m(this, "slots", []);
|
|
28
84
|
this.options = s;
|
|
29
85
|
}
|
|
30
86
|
setOptions(s) {
|
|
@@ -32,54 +88,54 @@ class Ks {
|
|
|
32
88
|
}
|
|
33
89
|
/** Landmark sets to draw this frame: live faces, plus held/predicted ones. */
|
|
34
90
|
update(s, t) {
|
|
35
|
-
const { holdMs: n, predictMs: i, maxVelocityGapMs: r = 250 } = this.options,
|
|
36
|
-
for (let d = 0; d <
|
|
91
|
+
const { holdMs: n, predictMs: i, maxVelocityGapMs: r = 250 } = this.options, a = [], o = Math.max(s.length, this.slots.length);
|
|
92
|
+
for (let d = 0; d < o; d += 1) {
|
|
37
93
|
const l = s[d], h = this.slots[d] ?? null;
|
|
38
94
|
if (l && l.length > 0) {
|
|
39
95
|
const M = h && h.points.length === l.length ? h : null, x = M ?? {
|
|
40
|
-
points:
|
|
41
|
-
velocity:
|
|
96
|
+
points: We(l.length),
|
|
97
|
+
velocity: We(l.length),
|
|
42
98
|
lastSeen: t,
|
|
43
|
-
output:
|
|
99
|
+
output: We(l.length)
|
|
44
100
|
}, b = (t - x.lastSeen) / 1e3, T = M !== null && b > 0 && b * 1e3 <= r;
|
|
45
101
|
for (let R = 0; R < l.length; R += 1) {
|
|
46
|
-
const
|
|
47
|
-
T ? (
|
|
102
|
+
const w = l[R], g = x.points[R], y = x.velocity[R], v = w.z ?? 0;
|
|
103
|
+
T ? (y.x = 0.5 * y.x + 0.5 * ((w.x - g.x) / b), y.y = 0.5 * y.y + 0.5 * ((w.y - g.y) / b), y.z = 0.5 * y.z + 0.5 * ((v - g.z) / b)) : (y.x = 0, y.y = 0, y.z = 0), g.x = w.x, g.y = w.y, g.z = v;
|
|
48
104
|
}
|
|
49
|
-
x.lastSeen = t, this.slots[d] = x,
|
|
105
|
+
x.lastSeen = t, this.slots[d] = x, a.push(l);
|
|
50
106
|
continue;
|
|
51
107
|
}
|
|
52
108
|
if (!h) continue;
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
109
|
+
const u = t - h.lastSeen;
|
|
110
|
+
if (u > n) {
|
|
55
111
|
this.slots[d] = null;
|
|
56
112
|
continue;
|
|
57
113
|
}
|
|
58
|
-
const
|
|
114
|
+
const p = Math.max(0, Math.min(u, i)) / 1e3;
|
|
59
115
|
for (let M = 0; M < h.points.length; M += 1)
|
|
60
|
-
h.output[M].x = h.points[M].x + h.velocity[M].x *
|
|
61
|
-
|
|
116
|
+
h.output[M].x = h.points[M].x + h.velocity[M].x * p, h.output[M].y = h.points[M].y + h.velocity[M].y * p, h.output[M].z = h.points[M].z + h.velocity[M].z * p;
|
|
117
|
+
a.push(h.output);
|
|
62
118
|
}
|
|
63
119
|
for (; this.slots.length > 0 && this.slots[this.slots.length - 1] === null; ) this.slots.pop();
|
|
64
|
-
return
|
|
120
|
+
return a;
|
|
65
121
|
}
|
|
66
122
|
reset() {
|
|
67
123
|
this.slots = [];
|
|
68
124
|
}
|
|
69
125
|
}
|
|
70
|
-
const
|
|
126
|
+
const me = (e, s = { x: 0, y: 0, z: 0 }) => (s.x = e.x * 2 - 1, s.y = 1 - e.y * 2, s.z = -e.z, s), $s = (e, s = { x: 0, y: 0, z: 0 }) => (s.x = (e.x + 1) / 2, s.y = (1 - e.y) / 2, s.z = -e.z, s), Ut = "https://storage.googleapis.com/mediapipe-models/holistic_landmarker/holistic_landmarker/float16/latest/holistic_landmarker.task", en = 250, tn = 0, sn = 768, Ze = (e) => ({
|
|
71
127
|
hands: (e == null ? void 0 : e.hands) ?? "both",
|
|
72
|
-
analysisMaxDimension: (e == null ? void 0 : e.analysisMaxDimension) ??
|
|
73
|
-
holdMs: (e == null ? void 0 : e.holdMs) ??
|
|
74
|
-
predictMs: (e == null ? void 0 : e.predictMs) ??
|
|
75
|
-
}),
|
|
128
|
+
analysisMaxDimension: (e == null ? void 0 : e.analysisMaxDimension) ?? sn,
|
|
129
|
+
holdMs: (e == null ? void 0 : e.holdMs) ?? en,
|
|
130
|
+
predictMs: (e == null ? void 0 : e.predictMs) ?? tn
|
|
131
|
+
}), nn = () => ({
|
|
76
132
|
version: 0,
|
|
77
133
|
timestampMs: 0,
|
|
78
134
|
face: null,
|
|
79
135
|
leftHand: null,
|
|
80
136
|
rightHand: null,
|
|
81
137
|
pose: null
|
|
82
|
-
}),
|
|
138
|
+
}), Mt = [
|
|
83
139
|
0,
|
|
84
140
|
4,
|
|
85
141
|
5,
|
|
@@ -113,19 +169,19 @@ const ue = (e, s = { x: 0, y: 0, z: 0 }) => (s.x = e.x * 2 - 1, s.y = 1 - e.y *
|
|
|
113
169
|
29,
|
|
114
170
|
32,
|
|
115
171
|
31
|
|
116
|
-
],
|
|
117
|
-
if (e.length !==
|
|
172
|
+
], bt = (e, s) => {
|
|
173
|
+
if (e.length !== Mt.length) return e;
|
|
118
174
|
s.length = e.length;
|
|
119
|
-
for (let t = 0; t < e.length; t += 1) s[t] = e[
|
|
175
|
+
for (let t = 0; t < e.length; t += 1) s[t] = e[Mt[t]];
|
|
120
176
|
return s;
|
|
121
177
|
};
|
|
122
|
-
class
|
|
178
|
+
class Te {
|
|
123
179
|
constructor(s, t) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.holdMs = s, this.memory = new
|
|
180
|
+
m(this, "memory");
|
|
181
|
+
m(this, "holdMs");
|
|
182
|
+
m(this, "lastLiveMs", -1 / 0);
|
|
183
|
+
m(this, "lastConfidence", 0);
|
|
184
|
+
this.holdMs = s, this.memory = new Zs({ holdMs: s, predictMs: t });
|
|
129
185
|
}
|
|
130
186
|
setOptions(s, t) {
|
|
131
187
|
this.holdMs = s, this.memory.setOptions({ holdMs: s, predictMs: t });
|
|
@@ -144,51 +200,51 @@ class ke {
|
|
|
144
200
|
if (!r) return;
|
|
145
201
|
if (i)
|
|
146
202
|
return this.lastLiveMs = n, this.lastConfidence = t, { points: r, held: !1, confidence: t };
|
|
147
|
-
const
|
|
148
|
-
return { points: r, held: !0, confidence: this.lastConfidence *
|
|
203
|
+
const a = n - this.lastLiveMs, o = this.holdMs > 0 ? Math.max(0, 1 - a / this.holdMs) : 0;
|
|
204
|
+
return { points: r, held: !0, confidence: this.lastConfidence * o };
|
|
149
205
|
}
|
|
150
206
|
}
|
|
151
207
|
const ce = (e, s, t) => {
|
|
152
208
|
for (e.length > s && (e.length = s); e.length < s; ) e.push(t());
|
|
153
209
|
return e;
|
|
154
|
-
},
|
|
210
|
+
}, qe = (e, s) => {
|
|
155
211
|
e.x = s.x, e.y = s.y, e.z = s.z;
|
|
156
|
-
},
|
|
212
|
+
}, rn = (e) => {
|
|
157
213
|
if (e.length === 0) return 0;
|
|
158
214
|
let s = 0;
|
|
159
215
|
for (let t = 0; t < e.length; t += 1) s += e[t].visibility ?? 0;
|
|
160
216
|
return s / e.length;
|
|
161
217
|
};
|
|
162
|
-
class
|
|
218
|
+
class an {
|
|
163
219
|
constructor(s) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
220
|
+
m(this, "options", Ze());
|
|
221
|
+
m(this, "faceMemory", new Te(this.options.holdMs, this.options.predictMs));
|
|
222
|
+
m(this, "leftHandMemory", new Te(this.options.holdMs, this.options.predictMs));
|
|
223
|
+
m(this, "rightHandMemory", new Te(this.options.holdMs, this.options.predictMs));
|
|
224
|
+
m(this, "poseMemory", new Te(this.options.holdMs, this.options.predictMs));
|
|
225
|
+
m(this, "face", {
|
|
170
226
|
landmarks: [],
|
|
171
227
|
blendshapes: {},
|
|
172
228
|
confidence: 0,
|
|
173
229
|
held: !1
|
|
174
230
|
});
|
|
175
|
-
|
|
231
|
+
m(this, "leftHand", {
|
|
176
232
|
handedness: "left",
|
|
177
233
|
landmarks: [],
|
|
178
234
|
worldLandmarks: [],
|
|
179
235
|
confidence: 0,
|
|
180
236
|
held: !1
|
|
181
237
|
});
|
|
182
|
-
|
|
238
|
+
m(this, "rightHand", {
|
|
183
239
|
handedness: "right",
|
|
184
240
|
landmarks: [],
|
|
185
241
|
worldLandmarks: [],
|
|
186
242
|
confidence: 0,
|
|
187
243
|
held: !1
|
|
188
244
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
245
|
+
m(this, "poseScratch", []);
|
|
246
|
+
m(this, "poseWorldScratch", []);
|
|
247
|
+
m(this, "pose", {
|
|
192
248
|
landmarks: [],
|
|
193
249
|
worldLandmarks: [],
|
|
194
250
|
visibility: [],
|
|
@@ -201,7 +257,7 @@ class Zs {
|
|
|
201
257
|
return this.options;
|
|
202
258
|
}
|
|
203
259
|
setOptions(s) {
|
|
204
|
-
this.options =
|
|
260
|
+
this.options = Ze({ ...this.options, ...s });
|
|
205
261
|
const { holdMs: t, predictMs: n } = this.options;
|
|
206
262
|
for (const i of this.memories()) i.setOptions(t, n);
|
|
207
263
|
}
|
|
@@ -223,72 +279,72 @@ class Zs {
|
|
|
223
279
|
* convention `HandTracker` reports on that feed.
|
|
224
280
|
*/
|
|
225
281
|
update(s, t, n, i = !1) {
|
|
226
|
-
var l, h,
|
|
282
|
+
var l, h, u, p;
|
|
227
283
|
n.face = this.updateFace(s, t);
|
|
228
284
|
const r = {
|
|
229
285
|
landmarks: (l = s == null ? void 0 : s.leftHandLandmarks) == null ? void 0 : l[0],
|
|
230
286
|
world: (h = s == null ? void 0 : s.leftHandWorldLandmarks) == null ? void 0 : h[0]
|
|
231
|
-
},
|
|
232
|
-
landmarks: (
|
|
233
|
-
world: (
|
|
234
|
-
},
|
|
235
|
-
return n.leftHand = this.updateHand("left",
|
|
287
|
+
}, a = {
|
|
288
|
+
landmarks: (u = s == null ? void 0 : s.rightHandLandmarks) == null ? void 0 : u[0],
|
|
289
|
+
world: (p = s == null ? void 0 : s.rightHandWorldLandmarks) == null ? void 0 : p[0]
|
|
290
|
+
}, o = i ? a : r, d = i ? r : a;
|
|
291
|
+
return n.leftHand = this.updateHand("left", o.landmarks, o.world, t), n.rightHand = this.updateHand("right", d.landmarks, d.world, t), n.pose = this.updatePose(s, t, i), n.timestampMs = t, n.version += 1, n;
|
|
236
292
|
}
|
|
237
293
|
updateFace(s, t) {
|
|
238
|
-
var
|
|
239
|
-
const n = (
|
|
294
|
+
var o, d, l, h;
|
|
295
|
+
const n = (o = s == null ? void 0 : s.faceLandmarks) == null ? void 0 : o[0], i = this.faceMemory.bridge(n, 1, t);
|
|
240
296
|
if (!i) return null;
|
|
241
|
-
const { face: r } = this,
|
|
297
|
+
const { face: r } = this, a = !i.held && n;
|
|
242
298
|
ce(r.landmarks, i.points.length, () => ({
|
|
243
299
|
x: 0,
|
|
244
300
|
y: 0,
|
|
245
301
|
z: 0,
|
|
246
302
|
visibility: 0
|
|
247
303
|
}));
|
|
248
|
-
for (let
|
|
249
|
-
const
|
|
250
|
-
|
|
304
|
+
for (let u = 0; u < i.points.length; u += 1) {
|
|
305
|
+
const p = r.landmarks[u];
|
|
306
|
+
qe(p, i.points[u]), p.visibility = a ? ((d = n[u]) == null ? void 0 : d.visibility) ?? 0 : 0;
|
|
251
307
|
}
|
|
252
|
-
if (
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
255
|
-
for (const
|
|
308
|
+
if (a) {
|
|
309
|
+
const u = (h = (l = s == null ? void 0 : s.faceBlendshapes) == null ? void 0 : l[0]) == null ? void 0 : h.categories;
|
|
310
|
+
if (u)
|
|
311
|
+
for (const p of u) r.blendshapes[p.categoryName] = p.score;
|
|
256
312
|
}
|
|
257
313
|
return r.confidence = i.confidence, r.held = i.held, r;
|
|
258
314
|
}
|
|
259
315
|
updateHand(s, t, n, i) {
|
|
260
|
-
const r = s === "left" ? this.leftHandMemory : this.rightHandMemory, { hands:
|
|
261
|
-
if (
|
|
316
|
+
const r = s === "left" ? this.leftHandMemory : this.rightHandMemory, { hands: a } = this.options;
|
|
317
|
+
if (a === "none" || a !== "both" && a !== s)
|
|
262
318
|
return r.reset(), null;
|
|
263
|
-
const
|
|
264
|
-
if (!
|
|
319
|
+
const o = r.bridge(t, 1, i);
|
|
320
|
+
if (!o) return null;
|
|
265
321
|
const d = s === "left" ? this.leftHand : this.rightHand;
|
|
266
|
-
ce(d.landmarks,
|
|
267
|
-
for (let l = 0; l <
|
|
268
|
-
|
|
269
|
-
if (!
|
|
322
|
+
ce(d.landmarks, o.points.length, () => ({ x: 0, y: 0, z: 0 }));
|
|
323
|
+
for (let l = 0; l < o.points.length; l += 1)
|
|
324
|
+
me(o.points[l], d.landmarks[l]);
|
|
325
|
+
if (!o.held && n) {
|
|
270
326
|
ce(d.worldLandmarks, n.length, () => ({ x: 0, y: 0, z: 0 }));
|
|
271
|
-
for (let l = 0; l < n.length; l += 1)
|
|
327
|
+
for (let l = 0; l < n.length; l += 1) qe(d.worldLandmarks[l], n[l]);
|
|
272
328
|
}
|
|
273
|
-
return d.confidence =
|
|
329
|
+
return d.confidence = o.confidence, d.held = o.held, d;
|
|
274
330
|
}
|
|
275
331
|
updatePose(s, t, n) {
|
|
276
|
-
var
|
|
277
|
-
const i = (
|
|
278
|
-
if (!
|
|
279
|
-
const { pose:
|
|
280
|
-
ce(
|
|
281
|
-
for (let x = 0; x <
|
|
282
|
-
|
|
283
|
-
const l = (M = s == null ? void 0 : s.poseWorldLandmarks) == null ? void 0 : M[0], h = l && n ?
|
|
332
|
+
var u, p, M;
|
|
333
|
+
const i = (u = s == null ? void 0 : s.poseLandmarks) == null ? void 0 : u[0], r = i && n ? bt(i, this.poseScratch) : i, a = this.poseMemory.bridge(r, r ? rn(r) : 0, t);
|
|
334
|
+
if (!a) return null;
|
|
335
|
+
const { pose: o } = this, d = !a.held && r;
|
|
336
|
+
ce(o.landmarks, a.points.length, () => ({ x: 0, y: 0, z: 0 })), ce(o.visibility, a.points.length, () => 0);
|
|
337
|
+
for (let x = 0; x < a.points.length; x += 1)
|
|
338
|
+
me(a.points[x], o.landmarks[x]), d && (o.visibility[x] = ((p = r[x]) == null ? void 0 : p.visibility) ?? 0);
|
|
339
|
+
const l = (M = s == null ? void 0 : s.poseWorldLandmarks) == null ? void 0 : M[0], h = l && n ? bt(l, this.poseWorldScratch) : l;
|
|
284
340
|
if (d && h) {
|
|
285
|
-
ce(
|
|
286
|
-
for (let x = 0; x < h.length; x += 1)
|
|
341
|
+
ce(o.worldLandmarks, h.length, () => ({ x: 0, y: 0, z: 0 }));
|
|
342
|
+
for (let x = 0; x < h.length; x += 1) qe(o.worldLandmarks[x], h[x]);
|
|
287
343
|
}
|
|
288
|
-
return
|
|
344
|
+
return o.confidence = a.confidence, o.held = a.held, o;
|
|
289
345
|
}
|
|
290
346
|
}
|
|
291
|
-
const
|
|
347
|
+
const zt = {
|
|
292
348
|
"camera-permission-denied": "Camera access was blocked. Allow camera permissions in your browser, then refresh.",
|
|
293
349
|
"camera-in-use": "Camera is already in use by another app or browser tab. Close it and refresh.",
|
|
294
350
|
"no-camera": "No camera was found on this device.",
|
|
@@ -303,7 +359,7 @@ const Bt = {
|
|
|
303
359
|
"model-init-failed": "The tracker failed to initialize on this device.",
|
|
304
360
|
"placement-unsupported": "This device cannot place 3D objects in the room (no WebXR, Scene Viewer or Quick Look).",
|
|
305
361
|
unknown: "Tracking is unavailable for an unknown reason."
|
|
306
|
-
},
|
|
362
|
+
}, on = {
|
|
307
363
|
"camera-permission-denied": !0,
|
|
308
364
|
"camera-in-use": !0,
|
|
309
365
|
"no-camera": !1,
|
|
@@ -318,18 +374,18 @@ const Bt = {
|
|
|
318
374
|
"model-init-failed": !1,
|
|
319
375
|
"placement-unsupported": !1,
|
|
320
376
|
unknown: !0
|
|
321
|
-
}, _ = (e, s =
|
|
322
|
-
[
|
|
323
|
-
[
|
|
324
|
-
[
|
|
325
|
-
[
|
|
326
|
-
[
|
|
327
|
-
[
|
|
328
|
-
[
|
|
329
|
-
},
|
|
330
|
-
const s =
|
|
331
|
-
return s ? /^https?:/.test(s) ? s : new URL(s,
|
|
332
|
-
},
|
|
377
|
+
}, _ = (e, s = zt[e]) => ({ code: e, message: s, recoverable: on[e] }), cn = {
|
|
378
|
+
[P.FACE_TRACKER]: "/assets/xr/models/face_tracking.task",
|
|
379
|
+
[P.HAND_TRACKER]: "/assets/xr/models/hand_tracking.task",
|
|
380
|
+
[P.GESTURE_TRACKER]: "/assets/xr/models/gesture_tracking.task",
|
|
381
|
+
[P.BODY_TRACKER]: "/assets/xr/models/body_tracking.task",
|
|
382
|
+
[P.BACKGROUND_SEGMENTATION]: "/assets/xr/models/segmentation.tflite",
|
|
383
|
+
[P.SEMANTIC_SEGMENTATION]: "/assets/xr/models/selfie_multiclass_256x256.tflite",
|
|
384
|
+
[P.HOLISTIC_TRACKER]: Ut
|
|
385
|
+
}, Wt = (e) => {
|
|
386
|
+
const s = cn[e];
|
|
387
|
+
return s ? /^https?:/.test(s) ? s : new URL(s, q.assetStorageEndpoint).toString() : null;
|
|
388
|
+
}, ln = Object.values(P), dn = () => {
|
|
333
389
|
var t, n, i;
|
|
334
390
|
const e = typeof window < "u", s = typeof document < "u";
|
|
335
391
|
return {
|
|
@@ -344,7 +400,7 @@ const Bt = {
|
|
|
344
400
|
relSupportsAr: s ? ((i = (n = document.createElement("a").relList) == null ? void 0 : n.supports) == null ? void 0 : i.call(n, "ar")) === !0 : void 0,
|
|
345
401
|
userAgent: typeof navigator < "u" ? navigator.userAgent : void 0
|
|
346
402
|
};
|
|
347
|
-
},
|
|
403
|
+
}, hn = (e) => !!e && /Android/.test(e) && /(Chrome|SamsungBrowser)\//.test(e) && !/Firefox|OPR\//.test(e), un = async (e) => {
|
|
348
404
|
let s = !1;
|
|
349
405
|
if (e.xrSessionSupported)
|
|
350
406
|
try {
|
|
@@ -352,7 +408,7 @@ const Bt = {
|
|
|
352
408
|
} catch {
|
|
353
409
|
s = !1;
|
|
354
410
|
}
|
|
355
|
-
const t =
|
|
411
|
+
const t = hn(e.userAgent), n = e.relSupportsAr === !0, i = s || t || n;
|
|
356
412
|
return {
|
|
357
413
|
webxr: s,
|
|
358
414
|
sceneViewer: t,
|
|
@@ -360,7 +416,7 @@ const Bt = {
|
|
|
360
416
|
any: i,
|
|
361
417
|
reason: i ? null : _("placement-unsupported")
|
|
362
418
|
};
|
|
363
|
-
},
|
|
419
|
+
}, mn = (e) => {
|
|
364
420
|
switch (e) {
|
|
365
421
|
case "granted":
|
|
366
422
|
return "supported";
|
|
@@ -371,9 +427,9 @@ const Bt = {
|
|
|
371
427
|
default:
|
|
372
428
|
return "unknown";
|
|
373
429
|
}
|
|
374
|
-
},
|
|
375
|
-
var
|
|
376
|
-
const t = e.isSecureContext ?? !0, n = (
|
|
430
|
+
}, fn = async (e, s) => {
|
|
431
|
+
var o, d, l;
|
|
432
|
+
const t = e.isSecureContext ?? !0, n = (o = e.navigator) == null ? void 0 : o.mediaDevices;
|
|
377
433
|
if (!t)
|
|
378
434
|
return {
|
|
379
435
|
status: "unsupported",
|
|
@@ -392,15 +448,15 @@ const Bt = {
|
|
|
392
448
|
if (s && ((l = (d = e.navigator) == null ? void 0 : d.permissions) != null && l.query))
|
|
393
449
|
try {
|
|
394
450
|
const h = await e.navigator.permissions.query({ name: "camera" });
|
|
395
|
-
i =
|
|
451
|
+
i = mn(h.state);
|
|
396
452
|
} catch {
|
|
397
453
|
i = "unknown";
|
|
398
454
|
}
|
|
399
|
-
let r = null,
|
|
455
|
+
let r = null, a = !1;
|
|
400
456
|
if (typeof n.enumerateDevices == "function")
|
|
401
457
|
try {
|
|
402
458
|
const h = await n.enumerateDevices();
|
|
403
|
-
r = h.filter((
|
|
459
|
+
r = h.filter((u) => u.kind === "videoinput").length, a = h.some((u) => !!u.label);
|
|
404
460
|
} catch {
|
|
405
461
|
r = null;
|
|
406
462
|
}
|
|
@@ -409,13 +465,13 @@ const Bt = {
|
|
|
409
465
|
reason: _("camera-permission-denied"),
|
|
410
466
|
deviceCount: r,
|
|
411
467
|
secureContext: t
|
|
412
|
-
} : r === 0 && (i === "supported" ||
|
|
468
|
+
} : r === 0 && (i === "supported" || a) ? {
|
|
413
469
|
status: "unsupported",
|
|
414
470
|
reason: _("no-camera"),
|
|
415
471
|
deviceCount: r,
|
|
416
472
|
secureContext: t
|
|
417
473
|
} : { status: i, reason: null, deviceCount: r, secureContext: t };
|
|
418
|
-
},
|
|
474
|
+
}, gn = (e) => {
|
|
419
475
|
var t;
|
|
420
476
|
const s = (t = e.createCanvas) == null ? void 0 : t.call(e);
|
|
421
477
|
if (!s) return 0;
|
|
@@ -426,9 +482,9 @@ const Bt = {
|
|
|
426
482
|
return 0;
|
|
427
483
|
}
|
|
428
484
|
return 0;
|
|
429
|
-
},
|
|
430
|
-
var
|
|
431
|
-
const s =
|
|
485
|
+
}, pn = (e) => {
|
|
486
|
+
var a;
|
|
487
|
+
const s = gn(e), t = e.offscreenCanvas ?? !1, n = e.wasm ?? !1, i = !!((a = e.navigator) != null && a.gpu);
|
|
432
488
|
let r = null;
|
|
433
489
|
return s === 0 ? r = _("webgl-unavailable") : t ? n || (r = _("wasm-unavailable")) : r = _("offscreen-canvas-unavailable"), {
|
|
434
490
|
status: r ? "unsupported" : "supported",
|
|
@@ -438,9 +494,9 @@ const Bt = {
|
|
|
438
494
|
offscreenCanvas: t,
|
|
439
495
|
wasm: n
|
|
440
496
|
};
|
|
441
|
-
},
|
|
442
|
-
var
|
|
443
|
-
const n =
|
|
497
|
+
}, yn = async (e, s, t) => {
|
|
498
|
+
var a, o;
|
|
499
|
+
const n = Wt(e);
|
|
444
500
|
if (!n || !s.fetch)
|
|
445
501
|
return { model: e, status: "unknown", reason: null, url: n, bytes: null };
|
|
446
502
|
const i = typeof AbortController < "u" ? new AbortController() : void 0, r = setTimeout(() => i == null ? void 0 : i.abort(), t);
|
|
@@ -452,12 +508,12 @@ const Bt = {
|
|
|
452
508
|
status: "unsupported",
|
|
453
509
|
reason: _(
|
|
454
510
|
"model-unreachable",
|
|
455
|
-
`${
|
|
511
|
+
`${zt["model-unreachable"]} (${d.status})`
|
|
456
512
|
),
|
|
457
513
|
url: n,
|
|
458
514
|
bytes: null
|
|
459
515
|
};
|
|
460
|
-
const l = Number(((
|
|
516
|
+
const l = Number(((o = (a = d.headers) == null ? void 0 : a.get) == null ? void 0 : o.call(a, "content-length")) ?? NaN);
|
|
461
517
|
return {
|
|
462
518
|
model: e,
|
|
463
519
|
status: "supported",
|
|
@@ -476,31 +532,31 @@ const Bt = {
|
|
|
476
532
|
} finally {
|
|
477
533
|
clearTimeout(r);
|
|
478
534
|
}
|
|
479
|
-
},
|
|
480
|
-
const t = e.timeoutMs ?? 4e3, n = new Set(e.models ?? []), [i, r,
|
|
481
|
-
|
|
535
|
+
}, dr = async (e = {}, s = dn()) => {
|
|
536
|
+
const t = e.timeoutMs ?? 4e3, n = new Set(e.models ?? []), [i, r, a] = await Promise.all([
|
|
537
|
+
fn(s, e.queryPermission ?? !0),
|
|
482
538
|
Promise.all(
|
|
483
|
-
|
|
484
|
-
async (l) => n.has(l) ?
|
|
539
|
+
ln.map(
|
|
540
|
+
async (l) => n.has(l) ? yn(l, s, t) : {
|
|
485
541
|
model: l,
|
|
486
542
|
status: "unknown",
|
|
487
543
|
reason: null,
|
|
488
|
-
url:
|
|
544
|
+
url: Wt(l),
|
|
489
545
|
bytes: null
|
|
490
546
|
}
|
|
491
547
|
)
|
|
492
548
|
),
|
|
493
|
-
|
|
494
|
-
]),
|
|
549
|
+
un(s)
|
|
550
|
+
]), o = pn(s), d = Object.fromEntries(r.map((l) => [l.model, l]));
|
|
495
551
|
return {
|
|
496
552
|
camera: i,
|
|
497
|
-
rendering:
|
|
498
|
-
placement:
|
|
553
|
+
rendering: o,
|
|
554
|
+
placement: a,
|
|
499
555
|
models: d,
|
|
500
|
-
canRunTracking:
|
|
556
|
+
canRunTracking: o.status === "supported" && i.status !== "unsupported",
|
|
501
557
|
checkedAt: s.now ? s.now() : Date.now()
|
|
502
558
|
};
|
|
503
|
-
},
|
|
559
|
+
}, qt = (e) => {
|
|
504
560
|
switch (e) {
|
|
505
561
|
case "permission-denied":
|
|
506
562
|
return _("camera-permission-denied");
|
|
@@ -515,13 +571,13 @@ const Bt = {
|
|
|
515
571
|
default:
|
|
516
572
|
return _("unknown");
|
|
517
573
|
}
|
|
518
|
-
},
|
|
574
|
+
}, hr = (e, s) => {
|
|
519
575
|
const { camera: t, rendering: n } = e, i = e.models[s], r = t.status === "permission-prompt" || t.status === "unknown";
|
|
520
576
|
return n.reason ? { supported: !1, reason: n.reason, needsPermission: r } : t.reason ? { supported: !1, reason: t.reason, needsPermission: r } : i != null && i.reason ? { supported: !1, reason: i.reason, needsPermission: r } : { supported: !0, reason: null, needsPermission: r };
|
|
521
|
-
},
|
|
577
|
+
}, ur = (e) => {
|
|
522
578
|
const s = e instanceof Error ? e.message : String(e ?? ""), t = s.toLowerCase();
|
|
523
579
|
return t.includes("integrity") || t.includes("sha-384") || t.includes("sha384") ? _("model-integrity", s) : t.includes("failed to fetch") || t.includes("networkerror") || t.includes("load failed") || /\b(404|403|5\d\d)\b/.test(t) || t.includes("fetch") ? _("model-unreachable", s) : t.includes("webgl") || t.includes("gpu") ? _("webgl-unavailable", s) : s ? _("model-init-failed", s) : _("unknown");
|
|
524
|
-
},
|
|
580
|
+
}, Vt = (e) => {
|
|
525
581
|
switch (e instanceof DOMException ? e.name : "") {
|
|
526
582
|
case "NotAllowedError":
|
|
527
583
|
case "PermissionDeniedError":
|
|
@@ -539,18 +595,18 @@ const Bt = {
|
|
|
539
595
|
default:
|
|
540
596
|
return e instanceof TypeError ? "unsupported" : "unknown";
|
|
541
597
|
}
|
|
542
|
-
},
|
|
598
|
+
}, kt = {
|
|
543
599
|
"permission-denied": "Camera access was blocked. Allow camera permissions in your browser, then refresh.",
|
|
544
600
|
"camera-in-use": "Camera is already in use by another app or browser tab. Close it and refresh.",
|
|
545
601
|
"no-camera": "No camera was found on this device.",
|
|
546
602
|
"camera-lost": "The camera stopped sending frames. Reconnect it or re-allow access, then start again.",
|
|
547
603
|
unsupported: "Unable to access camera. Allow camera permissions in your browser, then refresh.",
|
|
548
604
|
unknown: "Unable to access camera. Allow camera permissions in your browser, then refresh."
|
|
549
|
-
},
|
|
605
|
+
}, tt = () => ({
|
|
550
606
|
mediaDevices: typeof navigator < "u" ? navigator.mediaDevices : void 0,
|
|
551
607
|
permissions: typeof navigator < "u" ? navigator.permissions : void 0,
|
|
552
608
|
isSecureContext: typeof window < "u" ? window.isSecureContext : void 0
|
|
553
|
-
}),
|
|
609
|
+
}), Kt = async (e = tt()) => {
|
|
554
610
|
var s;
|
|
555
611
|
if (!((s = e.permissions) != null && s.query)) return { state: "unknown", prompt: !1 };
|
|
556
612
|
try {
|
|
@@ -559,10 +615,10 @@ const Bt = {
|
|
|
559
615
|
} catch {
|
|
560
616
|
return { state: "unknown", prompt: !1 };
|
|
561
617
|
}
|
|
562
|
-
},
|
|
618
|
+
}, Gt = (e, s) => e === "permission-denied" ? {
|
|
563
619
|
state: s === "blocked" ? "blocked" : "denied",
|
|
564
620
|
reason: _("camera-permission-denied")
|
|
565
|
-
} : { state: "unavailable", reason:
|
|
621
|
+
} : { state: "unavailable", reason: qt(e) }, mr = async (e = {}, s = tt()) => {
|
|
566
622
|
var n;
|
|
567
623
|
if (s.isSecureContext === !1)
|
|
568
624
|
return {
|
|
@@ -584,10 +640,10 @@ const Bt = {
|
|
|
584
640
|
);
|
|
585
641
|
return e.keepStream ? { state: "granted", reason: null, stream: i } : (i.getTracks().forEach((r) => r.stop()), { state: "granted", reason: null, stream: null });
|
|
586
642
|
} catch (i) {
|
|
587
|
-
const r =
|
|
588
|
-
return { ...
|
|
643
|
+
const r = Vt(i), a = await Kt(s);
|
|
644
|
+
return { ...Gt(r, a.state), stream: null };
|
|
589
645
|
}
|
|
590
|
-
},
|
|
646
|
+
}, fr = async (e, s = tt()) => {
|
|
591
647
|
var t, n;
|
|
592
648
|
if (!((t = s.permissions) != null && t.query)) return () => {
|
|
593
649
|
};
|
|
@@ -596,24 +652,24 @@ const Bt = {
|
|
|
596
652
|
i.state === "granted" ? e({ state: "granted", prompt: !1 }) : i.state === "denied" ? e({ state: "blocked", prompt: !1 }) : e({ state: "unknown", prompt: i.state === "prompt" });
|
|
597
653
|
};
|
|
598
654
|
return (n = i.addEventListener) == null || n.call(i, "change", r), () => {
|
|
599
|
-
var
|
|
600
|
-
return (
|
|
655
|
+
var a;
|
|
656
|
+
return (a = i.removeEventListener) == null ? void 0 : a.call(i, "change", r);
|
|
601
657
|
};
|
|
602
658
|
} catch {
|
|
603
659
|
return () => {
|
|
604
660
|
};
|
|
605
661
|
}
|
|
606
|
-
},
|
|
662
|
+
}, gr = (e) => e === "unknown" || e === "denied" || e === "granted", pr = {
|
|
607
663
|
unknown: "This experience uses your camera. Nothing is recorded or uploaded.",
|
|
608
664
|
requesting: "Waiting for you to allow the camera…",
|
|
609
665
|
granted: "Camera access granted.",
|
|
610
666
|
denied: "Camera access was not allowed. You can try again.",
|
|
611
667
|
blocked: "Camera access is blocked for this site. Allow it in your browser's site settings, then reload.",
|
|
612
668
|
unavailable: "The camera is unavailable on this device right now."
|
|
613
|
-
},
|
|
669
|
+
}, wn = (e, s, t = "cover", n = 1) => {
|
|
614
670
|
if (e.width <= 0 || e.height <= 0 || s.width <= 0 || s.height <= 0)
|
|
615
671
|
return null;
|
|
616
|
-
const i = Number.isFinite(n) && n > 0 ? n : 1, r = s.width / e.width,
|
|
672
|
+
const i = Number.isFinite(n) && n > 0 ? n : 1, r = s.width / e.width, a = s.height / e.height, o = t === "contain" ? a <= r : a >= r, d = (o ? a : r) * i, l = o ? e.width * a * i : s.width * i, h = o ? s.height * i : e.height * r * i;
|
|
617
673
|
return {
|
|
618
674
|
scale: d,
|
|
619
675
|
drawWidth: l,
|
|
@@ -621,24 +677,24 @@ const Bt = {
|
|
|
621
677
|
offsetX: (s.width - l) / 2,
|
|
622
678
|
offsetY: (s.height - h) / 2
|
|
623
679
|
};
|
|
624
|
-
}, Se = (e) => e === "webcam" || e === void 0,
|
|
680
|
+
}, Se = (e) => e === "webcam" || e === void 0, vn = ({
|
|
625
681
|
source: e,
|
|
626
682
|
feed: s,
|
|
627
683
|
zoom: t = 1,
|
|
628
684
|
mirrored: n = !1
|
|
629
685
|
}) => {
|
|
630
|
-
const i =
|
|
686
|
+
const i = wn(e, s, "cover", t);
|
|
631
687
|
return i ? { ...i, source: e, feed: s, zoom: Number.isFinite(t) && t > 0 ? t : 1, mirrored: n } : null;
|
|
632
|
-
},
|
|
688
|
+
}, yr = (e, s, t = { x: 0, y: 0 }) => {
|
|
633
689
|
const n = s.mirrored ? s.source.width - e.x : e.x;
|
|
634
690
|
return t.x = (s.offsetX + n * s.scale) / s.feed.width, t.y = (s.offsetY + e.y * s.scale) / s.feed.height, t;
|
|
635
|
-
},
|
|
691
|
+
}, xn = (e, s, t = { x: 0, y: 0 }) => {
|
|
636
692
|
const n = (e.x * s.feed.width - s.offsetX) / s.scale;
|
|
637
693
|
return t.x = s.mirrored ? s.source.width - n : n, t.y = (e.y * s.feed.height - s.offsetY) / s.scale, t;
|
|
638
|
-
},
|
|
639
|
-
const t =
|
|
694
|
+
}, wr = (e, s) => {
|
|
695
|
+
const t = xn(e, s);
|
|
640
696
|
return t.x >= 0 && t.x <= s.source.width && t.y >= 0 && t.y <= s.source.height;
|
|
641
|
-
},
|
|
697
|
+
}, vr = (e, s = { x: 0, y: 0 }) => (s.x = 1 - e.x, s.y = e.y, e.z !== void 0 && (s.z = e.z), s), xr = (e, s, t, n = { x: 0, y: 0 }) => {
|
|
642
698
|
switch (t) {
|
|
643
699
|
case 90:
|
|
644
700
|
return n.x = s.height - e.y, n.y = e.x, n;
|
|
@@ -649,18 +705,13 @@ const Bt = {
|
|
|
649
705
|
default:
|
|
650
706
|
return n.x = e.x, n.y = e.y, n;
|
|
651
707
|
}
|
|
652
|
-
},
|
|
653
|
-
class
|
|
708
|
+
}, Sr = (e, s) => s === 90 || s === 270 ? { width: e.height, height: e.width } : { width: e.width, height: e.height };
|
|
709
|
+
class Sn {
|
|
654
710
|
constructor(s) {
|
|
655
|
-
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
class fn {
|
|
659
|
-
constructor(s) {
|
|
660
|
-
u(this, "options");
|
|
711
|
+
m(this, "options");
|
|
661
712
|
const t = {
|
|
662
713
|
verbose: !1,
|
|
663
|
-
prefix:
|
|
714
|
+
prefix: q.loggerPrefix
|
|
664
715
|
};
|
|
665
716
|
this.options = { ...t, ...s };
|
|
666
717
|
}
|
|
@@ -673,7 +724,7 @@ class fn {
|
|
|
673
724
|
t && console.error(n, ...s);
|
|
674
725
|
}
|
|
675
726
|
}
|
|
676
|
-
const
|
|
727
|
+
const Xt = [
|
|
677
728
|
"nose",
|
|
678
729
|
"leftEyeInner",
|
|
679
730
|
"leftEye",
|
|
@@ -707,83 +758,83 @@ const Vt = [
|
|
|
707
758
|
"rightHeel",
|
|
708
759
|
"leftFootIndex",
|
|
709
760
|
"rightFootIndex"
|
|
710
|
-
],
|
|
711
|
-
|
|
712
|
-
),
|
|
713
|
-
|
|
714
|
-
),
|
|
761
|
+
], ye = Object.fromEntries(
|
|
762
|
+
Xt.map((e, s) => [e, s])
|
|
763
|
+
), Mn = (e) => e === "mouthLeft" ? "mouthRight" : e === "mouthRight" ? "mouthLeft" : e.startsWith("left") ? `right${e.slice(4)}` : e.startsWith("right") ? `left${e.slice(5)}` : e, bn = Object.freeze(
|
|
764
|
+
Xt.map((e) => ye[Mn(e)])
|
|
765
|
+
), kn = (e, s = { x: 0, y: 0, z: 0 }) => (s.x = e.x * 100, s.y = -e.y * 100, s.z = -e.z * 100, s), Cn = (e, s, t) => {
|
|
715
766
|
if (!s) return { ...e, timestampMs: t };
|
|
716
|
-
const n = (i) => i.map((r,
|
|
767
|
+
const n = (i) => i.map((r, a) => i[bn[a] ?? a] ?? i[a]);
|
|
717
768
|
return {
|
|
718
769
|
world: n(e.world),
|
|
719
770
|
image: n(e.image),
|
|
720
771
|
visibility: n(e.visibility),
|
|
721
772
|
timestampMs: t
|
|
722
773
|
};
|
|
723
|
-
},
|
|
774
|
+
}, Tn = Object.freeze({
|
|
724
775
|
holdMs: 250,
|
|
725
776
|
maxJump: 1,
|
|
726
777
|
duplicate: 0.1,
|
|
727
778
|
confirm: 3,
|
|
728
779
|
confirmMs: 100
|
|
729
|
-
}),
|
|
730
|
-
const t =
|
|
731
|
-
if (t.some((
|
|
732
|
-
const n = (
|
|
780
|
+
}), En = 1, Rn = 1.2, An = 200, Ve = [ye.leftShoulder, ye.rightShoulder, ye.leftHip, ye.rightHip], In = (e, s) => {
|
|
781
|
+
const t = Ve.map((p) => e.image[p]);
|
|
782
|
+
if (t.some((p) => !p)) return null;
|
|
783
|
+
const n = (p) => ({ x: p.x * s, y: p.y }), [i, r, a, o] = t.map(n), d = { x: (i.x + r.x) / 2, y: (i.y + r.y) / 2 }, l = { x: (a.x + o.x) / 2, y: (a.y + o.y) / 2 }, h = Math.max(
|
|
733
784
|
Math.hypot(d.x - l.x, d.y - l.y),
|
|
734
785
|
Math.hypot(i.x - r.x, i.y - r.y)
|
|
735
786
|
);
|
|
736
787
|
if (!(h > 1e-6)) return null;
|
|
737
|
-
const
|
|
788
|
+
const u = Ve.reduce((p, M) => p + (e.visibility[M] ?? 0), 0) / Ve.length;
|
|
738
789
|
return {
|
|
739
790
|
pose: e,
|
|
740
791
|
center: { x: (d.x + l.x) / 2, y: (d.y + l.y) / 2 },
|
|
741
792
|
size: h,
|
|
742
|
-
visibility:
|
|
793
|
+
visibility: u
|
|
743
794
|
};
|
|
744
795
|
};
|
|
745
|
-
class
|
|
796
|
+
class Fn {
|
|
746
797
|
constructor(s = {}) {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
this.settings = { ...
|
|
798
|
+
m(this, "settings");
|
|
799
|
+
m(this, "tracks", []);
|
|
800
|
+
m(this, "nextId", 1);
|
|
801
|
+
this.settings = { ...Tn, ...s };
|
|
751
802
|
}
|
|
752
803
|
/**
|
|
753
804
|
* One detection's bodies (any order) at `nowMs`; `aspect` is the analysed
|
|
754
805
|
* frame's width / height. Returns every tracked body, by id.
|
|
755
806
|
*/
|
|
756
807
|
update(s, t, n = 1) {
|
|
757
|
-
const { holdMs: i, maxJump: r, duplicate:
|
|
758
|
-
s.map((g) =>
|
|
759
|
-
|
|
808
|
+
const { holdMs: i, maxJump: r, duplicate: a, confirm: o, confirmMs: d } = this.settings, l = this.dedupe(
|
|
809
|
+
s.map((g) => In(g, n)).filter((g) => !!g),
|
|
810
|
+
a
|
|
760
811
|
), h = l.map(
|
|
761
|
-
(g) => this.tracks.map((
|
|
762
|
-
const v = Math.min(Math.max(t -
|
|
763
|
-
return K > r ? 1 / 0 : K +
|
|
812
|
+
(g) => this.tracks.map((y) => {
|
|
813
|
+
const v = Math.min(Math.max(t - y.lastSeenMs, 0), An), A = y.center.x + y.velocity.x * v, E = y.center.y + y.velocity.y * v, B = Math.max(y.size, g.size), K = Math.hypot(g.center.x - A, g.center.y - E) / B;
|
|
814
|
+
return K > r ? 1 / 0 : K + En * Math.abs(Math.log(g.size / y.size));
|
|
764
815
|
})
|
|
765
816
|
);
|
|
766
|
-
let
|
|
767
|
-
const M = [], x = /* @__PURE__ */ new Set(), b = (g,
|
|
768
|
-
if (!(
|
|
817
|
+
let u = l.map(() => -1), p = 1 / 0;
|
|
818
|
+
const M = [], x = /* @__PURE__ */ new Set(), b = (g, y) => {
|
|
819
|
+
if (!(y >= p)) {
|
|
769
820
|
if (g === l.length) {
|
|
770
|
-
|
|
821
|
+
u = [...M], p = y;
|
|
771
822
|
return;
|
|
772
823
|
}
|
|
773
824
|
for (let v = 0; v < this.tracks.length; v += 1) {
|
|
774
825
|
const A = h[g][v];
|
|
775
|
-
x.has(v) || A === 1 / 0 || (x.add(v), M[g] = v, b(g + 1,
|
|
826
|
+
x.has(v) || A === 1 / 0 || (x.add(v), M[g] = v, b(g + 1, y + A), x.delete(v));
|
|
776
827
|
}
|
|
777
|
-
M[g] = -1, b(g + 1,
|
|
828
|
+
M[g] = -1, b(g + 1, y + Rn);
|
|
778
829
|
}
|
|
779
830
|
};
|
|
780
831
|
b(0, 0);
|
|
781
|
-
const T = /* @__PURE__ */ new Set(),
|
|
782
|
-
(g,
|
|
832
|
+
const T = /* @__PURE__ */ new Set(), w = !this.tracks.some((g) => g.id !== null) ? l.reduce(
|
|
833
|
+
(g, y, v) => u[v] < 0 && (!g || y.visibility > g.visibility) ? y : g,
|
|
783
834
|
null
|
|
784
835
|
) : null;
|
|
785
|
-
l.forEach((g,
|
|
786
|
-
const v =
|
|
836
|
+
l.forEach((g, y) => {
|
|
837
|
+
const v = u[y] >= 0 ? this.tracks[u[y]] : null;
|
|
787
838
|
if (!v) {
|
|
788
839
|
const E = {
|
|
789
840
|
id: null,
|
|
@@ -795,10 +846,10 @@ class kn {
|
|
|
795
846
|
velocity: { x: 0, y: 0 },
|
|
796
847
|
lastSeenMs: t
|
|
797
848
|
};
|
|
798
|
-
(g ===
|
|
849
|
+
(g === w || o <= 1 && d <= 0) && this.confirm(E), this.tracks.push(E), T.add(E);
|
|
799
850
|
return;
|
|
800
851
|
}
|
|
801
|
-
v.hits += 1, v.id === null && v.hits >=
|
|
852
|
+
v.hits += 1, v.id === null && v.hits >= o && t - v.firstSeenMs >= d && this.confirm(v);
|
|
802
853
|
const A = t - v.lastSeenMs;
|
|
803
854
|
A > 0 && (v.velocity = {
|
|
804
855
|
x: (v.velocity.x + (g.center.x - v.center.x) / A) / 2,
|
|
@@ -808,7 +859,7 @@ class kn {
|
|
|
808
859
|
(g) => T.has(g) || g.id !== null && t - g.lastSeenMs <= i
|
|
809
860
|
);
|
|
810
861
|
for (const g of this.tracks) T.has(g) || (g.hits = 0);
|
|
811
|
-
return this.tracks.filter((g) => g.id !== null).map((g) => ({ id: g.id, pose: g.pose, held: !T.has(g) })).sort((g,
|
|
862
|
+
return this.tracks.filter((g) => g.id !== null).map((g) => ({ id: g.id, pose: g.pose, held: !T.has(g) })).sort((g, y) => g.id - y.id);
|
|
812
863
|
}
|
|
813
864
|
confirm(s) {
|
|
814
865
|
s.id = this.nextId, this.nextId += 1;
|
|
@@ -819,22 +870,22 @@ class kn {
|
|
|
819
870
|
}
|
|
820
871
|
/** One person detected twice (overlapping tracking regions): keep the more visible. */
|
|
821
872
|
dedupe(s, t) {
|
|
822
|
-
const n = [], i = [...s].sort((r,
|
|
873
|
+
const n = [], i = [...s].sort((r, a) => a.visibility - r.visibility);
|
|
823
874
|
for (const r of i)
|
|
824
875
|
n.some(
|
|
825
|
-
(
|
|
876
|
+
(o) => Math.hypot(o.center.x - r.center.x, o.center.y - r.center.y) / Math.max(o.size, r.size) < t && Math.abs(Math.log(o.size / r.size)) < 0.1
|
|
826
877
|
) || n.push(r);
|
|
827
878
|
return s.filter((r) => n.includes(r));
|
|
828
879
|
}
|
|
829
880
|
}
|
|
830
|
-
const
|
|
881
|
+
const Ct = (e, s) => {
|
|
831
882
|
let t = 1;
|
|
832
883
|
for (const n of e) Number.isFinite(n) && (t = Math.max(t, Math.round(n)));
|
|
833
884
|
return Math.min(t, s);
|
|
834
|
-
},
|
|
885
|
+
}, z = {
|
|
835
886
|
width: 720,
|
|
836
887
|
height: 1280
|
|
837
|
-
}, J = 32,
|
|
888
|
+
}, J = 32, Pn = 0.5, Ee = {
|
|
838
889
|
enabled: !0,
|
|
839
890
|
position: { x: 0, y: 0 },
|
|
840
891
|
size: { width: 680, height: 1230 },
|
|
@@ -846,104 +897,123 @@ const Mt = (e, s) => {
|
|
|
846
897
|
overlay: !0,
|
|
847
898
|
visible: !0,
|
|
848
899
|
showTransformGuides: !1
|
|
849
|
-
},
|
|
900
|
+
}, _n = Math.PI / 180, Tt = (e, s) => s <= 0 ? e : Math.round(e / s) * s, Mr = ({
|
|
850
901
|
transform: e,
|
|
851
902
|
parentSize: s,
|
|
852
|
-
root: t =
|
|
853
|
-
snapIncrement: n =
|
|
903
|
+
root: t = z,
|
|
904
|
+
snapIncrement: n = Pn
|
|
854
905
|
}) => {
|
|
855
|
-
const r = Math.min(s.width / t.width, s.height / t.height) * (J / e.referencePixelsPerUnit),
|
|
906
|
+
const r = Math.min(s.width / t.width, s.height / t.height) * (J / e.referencePixelsPerUnit), a = e.size.width * e.scale2D.x * r, o = e.size.height * e.scale2D.y * r, d = Tt(e.position.x, n) * r, l = Tt(e.position.y, n) * r, h = (e.pivot[0] - 0.5) * a, u = (e.pivot[1] - 0.5) * o;
|
|
856
907
|
return {
|
|
857
|
-
center: [d - h, l -
|
|
858
|
-
size: [
|
|
859
|
-
rotation: [0, 0, e.rotation *
|
|
860
|
-
pivotOffset: [h / Math.max(
|
|
861
|
-
aspect:
|
|
908
|
+
center: [d - h, l - u, 0],
|
|
909
|
+
size: [a, o, 1],
|
|
910
|
+
rotation: [0, 0, e.rotation * _n],
|
|
911
|
+
pivotOffset: [h / Math.max(a, 1e-6), u / Math.max(o, 1e-6), 0],
|
|
912
|
+
aspect: a > 0 && o > 0 ? Math.abs(a / o) : 1
|
|
862
913
|
};
|
|
863
|
-
},
|
|
864
|
-
...
|
|
914
|
+
}, br = (e) => ({
|
|
915
|
+
...Ee,
|
|
865
916
|
...e,
|
|
866
|
-
position: { ...
|
|
867
|
-
size: { ...
|
|
868
|
-
scale2D: { ...
|
|
917
|
+
position: { ...Ee.position, ...e == null ? void 0 : e.position },
|
|
918
|
+
size: { ...Ee.size, ...e == null ? void 0 : e.size },
|
|
919
|
+
scale2D: { ...Ee.scale2D, ...e == null ? void 0 : e.scale2D }
|
|
869
920
|
}), U = (e, s) => {
|
|
870
921
|
if (!Number.isFinite(e) || e <= 0) throw new RangeError(`${s} must be positive`);
|
|
871
922
|
return e;
|
|
872
|
-
},
|
|
923
|
+
}, Me = (e, s) => {
|
|
873
924
|
const t = U(s.width, "root.width"), n = U(s.height, "root.height");
|
|
874
925
|
return !Number.isFinite(e.width) || !Number.isFinite(e.height) || e.width <= 0 || e.height <= 0 ? 0 : Math.min(e.width / t, e.height / n);
|
|
875
|
-
},
|
|
926
|
+
}, st = (e, s, t, n) => s.width <= 0 || s.height <= 0 ? Object.assign(n, { x: 0, y: 0 }) : (U(t.width, "root.width"), U(t.height, "root.height"), n.x = (e.x / s.width - 0.5) * t.width, n.y = (0.5 - e.y / s.height) * t.height, n), nt = (e, s, t, n) => s.width <= 0 || s.height <= 0 ? Object.assign(n, { x: 0, y: 0 }) : (U(t.width, "root.width"), U(t.height, "root.height"), n.x = (e.x / t.width + 0.5) * s.width, n.y = (0.5 - e.y / t.height) * s.height, n), jt = ({
|
|
876
927
|
parentSize: e,
|
|
877
928
|
referencePixelsPerUnit: s = J,
|
|
878
|
-
root: t =
|
|
879
|
-
}) =>
|
|
880
|
-
const t =
|
|
929
|
+
root: t = z
|
|
930
|
+
}) => Me(e, t) * (J / U(s, "referencePixelsPerUnit")), kr = (e, s) => e * jt(s), Cr = (e, s) => {
|
|
931
|
+
const t = jt(s);
|
|
881
932
|
return t === 0 ? 0 : e / t;
|
|
882
|
-
},
|
|
933
|
+
}, Tr = ({
|
|
883
934
|
point: e,
|
|
884
935
|
parentSize: s,
|
|
885
936
|
referencePixelsPerUnit: t = J,
|
|
886
|
-
root: n =
|
|
937
|
+
root: n = z,
|
|
887
938
|
target: i = { x: 0, y: 0 }
|
|
888
939
|
}) => {
|
|
889
940
|
if (s.width <= 0 || s.height <= 0) return Object.assign(i, { x: 0, y: 0 });
|
|
890
941
|
const r = J / U(t, "referencePixelsPerUnit");
|
|
891
942
|
return i.x = e.x * (s.width / U(n.width, "root.width")) * r, i.y = e.y * (s.height / U(n.height, "root.height")) * r, i;
|
|
892
|
-
},
|
|
943
|
+
}, Er = ({
|
|
893
944
|
point: e,
|
|
894
945
|
parentSize: s,
|
|
895
946
|
referencePixelsPerUnit: t = J,
|
|
896
|
-
root: n =
|
|
947
|
+
root: n = z,
|
|
897
948
|
target: i = { x: 0, y: 0 }
|
|
898
949
|
}) => {
|
|
899
950
|
if (s.width <= 0 || s.height <= 0) return Object.assign(i, { x: 0, y: 0 });
|
|
900
951
|
const r = J / U(t, "referencePixelsPerUnit");
|
|
901
952
|
return i.x = e.x / (s.width / U(n.width, "root.width") * r), i.y = e.y / (s.height / U(n.height, "root.height") * r), i;
|
|
902
|
-
},
|
|
953
|
+
}, Rr = ({
|
|
903
954
|
point: e,
|
|
904
955
|
rect: s,
|
|
905
|
-
root: t =
|
|
956
|
+
root: t = z,
|
|
906
957
|
target: n = { x: 0, y: 0 }
|
|
907
|
-
}) =>
|
|
958
|
+
}) => st({ x: e.x - s.left, y: e.y - s.top }, s, t, n), Ar = ({
|
|
908
959
|
point: e,
|
|
909
960
|
rect: s,
|
|
910
|
-
root: t =
|
|
961
|
+
root: t = z,
|
|
911
962
|
target: n = { x: 0, y: 0 }
|
|
912
|
-
}) => (
|
|
963
|
+
}) => (nt(e, s, t, n), n.x += s.left, n.y += s.top, n), Yt = ({
|
|
913
964
|
point: e,
|
|
914
|
-
root: s =
|
|
965
|
+
root: s = z,
|
|
915
966
|
target: t = { x: 0, y: 0 },
|
|
916
967
|
viewportSize: n
|
|
917
|
-
}) =>
|
|
968
|
+
}) => st(
|
|
918
969
|
{ x: e.x * n.width, y: e.y * n.height },
|
|
919
970
|
n,
|
|
920
971
|
s,
|
|
921
972
|
t
|
|
922
|
-
),
|
|
973
|
+
), Ir = (e, s = z) => Me(e, s), Fr = ({
|
|
923
974
|
point: e,
|
|
924
|
-
root: s =
|
|
975
|
+
root: s = z,
|
|
925
976
|
target: t = { x: 0, y: 0 },
|
|
926
977
|
viewportSize: n
|
|
927
|
-
}) =>
|
|
978
|
+
}) => {
|
|
979
|
+
const i = Me(n, s);
|
|
980
|
+
return i <= 0 ? Object.assign(t, { x: 0, y: 0 }) : (t.x = (e.x - 0.5) * n.width / i, t.y = (0.5 - e.y) * n.height / i, t);
|
|
981
|
+
}, Pr = ({
|
|
982
|
+
point: e,
|
|
983
|
+
root: s = z,
|
|
984
|
+
target: t = { x: 0, y: 0 },
|
|
985
|
+
viewportSize: n
|
|
986
|
+
}) => {
|
|
987
|
+
const i = Me(n, s);
|
|
988
|
+
return i <= 0 || n.width <= 0 || n.height <= 0 ? Object.assign(t, { x: 0, y: 0 }) : (t.x = e.x * i / n.width + 0.5, t.y = 0.5 - e.y * i / n.height, t);
|
|
989
|
+
}, _r = (e, s, t = z, n = { width: 0, height: 0 }) => {
|
|
990
|
+
const i = Me(s, t);
|
|
991
|
+
return i <= 0 ? Object.assign(n, { width: 0, height: 0 }) : (n.width = e.width / i, n.height = e.height / i, n);
|
|
992
|
+
}, Dn = ({
|
|
928
993
|
point: e,
|
|
929
|
-
root: s =
|
|
994
|
+
root: s = z,
|
|
930
995
|
target: t = { x: 0, y: 0 },
|
|
931
996
|
viewportSize: n
|
|
932
|
-
}) =>
|
|
997
|
+
}) => n.width <= 0 || n.height <= 0 ? Object.assign(t, { x: 0, y: 0 }) : (nt(e, n, s, t), t.x /= n.width, t.y /= n.height, t), Dr = ({
|
|
998
|
+
point: e,
|
|
999
|
+
root: s = z,
|
|
1000
|
+
target: t = { x: 0, y: 0 },
|
|
1001
|
+
viewportSize: n
|
|
1002
|
+
}) => Yt({
|
|
933
1003
|
point: { x: (e.x + 1) / 2, y: (1 - e.y) / 2 },
|
|
934
1004
|
viewportSize: n,
|
|
935
1005
|
root: s,
|
|
936
1006
|
target: t
|
|
937
|
-
}),
|
|
1007
|
+
}), Or = ({
|
|
938
1008
|
layout: e,
|
|
939
1009
|
mirrored: s = !1,
|
|
940
1010
|
point: t,
|
|
941
|
-
root: n =
|
|
1011
|
+
root: n = z,
|
|
942
1012
|
target: i = { x: 0, y: 0 }
|
|
943
1013
|
}) => {
|
|
944
1014
|
if (e.scale <= 0) return Object.assign(i, { x: 0, y: 0 });
|
|
945
1015
|
const r = e.offsetX + t.x * e.scale;
|
|
946
|
-
return
|
|
1016
|
+
return st(
|
|
947
1017
|
{
|
|
948
1018
|
x: s ? e.destination.width - r : r,
|
|
949
1019
|
y: e.offsetY + t.y * e.scale
|
|
@@ -952,58 +1022,58 @@ const Mt = (e, s) => {
|
|
|
952
1022
|
n,
|
|
953
1023
|
i
|
|
954
1024
|
);
|
|
955
|
-
},
|
|
1025
|
+
}, Lr = ({
|
|
956
1026
|
layout: e,
|
|
957
1027
|
mirrored: s = !1,
|
|
958
1028
|
point: t,
|
|
959
|
-
root: n =
|
|
1029
|
+
root: n = z,
|
|
960
1030
|
target: i = { x: 0, y: 0 }
|
|
961
1031
|
}) => {
|
|
962
1032
|
if (e.scale <= 0) return Object.assign(i, { x: 0, y: 0 });
|
|
963
|
-
|
|
1033
|
+
nt(t, e.destination, n, i);
|
|
964
1034
|
const r = s ? e.destination.width - i.x : i.x;
|
|
965
1035
|
return i.x = (r - e.offsetX) / e.scale, i.y = (i.y - e.offsetY) / e.scale, i;
|
|
966
|
-
},
|
|
1036
|
+
}, Re = new Gs(), Et = new qs(), Rt = new Vs(), Nr = ({
|
|
967
1037
|
camera: e,
|
|
968
1038
|
point: s,
|
|
969
|
-
root: t =
|
|
1039
|
+
root: t = z,
|
|
970
1040
|
target: n = { x: 0, y: 0, depth: 0 },
|
|
971
1041
|
viewportSize: i
|
|
972
|
-
}) => (U(t.width, "root.width"), U(t.height, "root.height"),
|
|
1042
|
+
}) => (U(t.width, "root.width"), U(t.height, "root.height"), Re.set(s.x, s.y, s.z).project(e), n.x = Re.x * t.width / 2, n.y = Re.y * t.height / 2, n.depth = Re.z, n), Br = ({
|
|
973
1043
|
camera: e,
|
|
974
1044
|
point: s,
|
|
975
|
-
root: t =
|
|
976
|
-
target: n = new
|
|
1045
|
+
root: t = z,
|
|
1046
|
+
target: n = new Ks(),
|
|
977
1047
|
viewportSize: i
|
|
978
|
-
}) => (U(t.width, "root.width"), U(t.height, "root.height"),
|
|
979
|
-
const t =
|
|
1048
|
+
}) => (U(t.width, "root.width"), U(t.height, "root.height"), Et.set(s.x * 2 / t.width, s.y * 2 / t.height), Rt.setFromCamera(Et, e), n.copy(Rt.ray)), Hr = (e, s) => me({ x: e.x, y: e.y, z: e.z ?? 0 }, s), On = (e, s = { x: 0, y: 0 }) => {
|
|
1049
|
+
const t = $s(e);
|
|
980
1050
|
return s.x = t.x, s.y = t.y, s.z = t.z, s;
|
|
981
|
-
},
|
|
1051
|
+
}, Ur = (e, s, t = { x: 0, y: 0 }) => (t.x = e.x * s.width, t.y = e.y * s.height, t), zr = (e, s, t = { x: 0, y: 0 }) => s.width <= 0 || s.height <= 0 ? Object.assign(t, { x: 0, y: 0 }) : (t.x = e.x / s.width, t.y = e.y / s.height, t), Wr = (e, s, t = {}) => Yt({
|
|
982
1052
|
point: e,
|
|
983
1053
|
viewportSize: s,
|
|
984
1054
|
root: t.root,
|
|
985
1055
|
target: t.target
|
|
986
|
-
}),
|
|
1056
|
+
}), qr = (e, s, t = {}) => {
|
|
987
1057
|
const n = t.target ?? { x: 0, y: 0 };
|
|
988
|
-
return
|
|
989
|
-
},
|
|
1058
|
+
return Dn({ point: e, viewportSize: s, root: t.root, target: n }), n;
|
|
1059
|
+
}, Ln = { selection: "index", index: 0 }, At = Object.freeze({
|
|
990
1060
|
face: { max: 10, default: 1, option: "numFaces" },
|
|
991
1061
|
hand: { max: 2, default: 2, option: null },
|
|
992
1062
|
gesture: { max: 1, default: 1, option: null },
|
|
993
1063
|
body: { max: 2, default: 1, option: "numBodies" },
|
|
994
1064
|
holistic: { max: 1, default: 1, option: null }
|
|
995
|
-
}),
|
|
1065
|
+
}), Nn = { center: null }, he = (e, s) => Math.hypot(e.x - s.x, e.y - s.y), Ae = (e) => ({
|
|
996
1066
|
center: { ...e.center },
|
|
997
1067
|
...e.label === void 0 ? {} : { label: e.label },
|
|
998
1068
|
...e.id === void 0 ? {} : { id: e.id }
|
|
999
|
-
}),
|
|
1069
|
+
}), It = (e, s, t) => {
|
|
1000
1070
|
if (!e.length) return null;
|
|
1001
1071
|
switch (s) {
|
|
1002
1072
|
case "largest":
|
|
1003
1073
|
return e.reduce((n, i) => i.size > n.size ? i : n);
|
|
1004
1074
|
case "nearest-center":
|
|
1005
1075
|
return e.reduce(
|
|
1006
|
-
(n, i) =>
|
|
1076
|
+
(n, i) => he(i.center, { x: 0.5, y: 0.5 }) < he(n.center, { x: 0.5, y: 0.5 }) ? i : n
|
|
1007
1077
|
);
|
|
1008
1078
|
case "leftmost":
|
|
1009
1079
|
return e.reduce((n, i) => i.center.x < n.center.x ? i : n);
|
|
@@ -1012,75 +1082,75 @@ const Mt = (e, s) => {
|
|
|
1012
1082
|
default:
|
|
1013
1083
|
return e.find((n) => n.index === t) ?? null;
|
|
1014
1084
|
}
|
|
1015
|
-
},
|
|
1085
|
+
}, Vr = (e, s = Ln, t = Nn) => {
|
|
1016
1086
|
const n = s.index ?? 0;
|
|
1017
1087
|
if (s.selection !== "sticky") {
|
|
1018
|
-
const
|
|
1088
|
+
const o = It(e, s.selection, n);
|
|
1019
1089
|
return {
|
|
1020
|
-
index: (
|
|
1021
|
-
reason:
|
|
1022
|
-
memory:
|
|
1090
|
+
index: (o == null ? void 0 : o.index) ?? null,
|
|
1091
|
+
reason: o ? s.selection : "none",
|
|
1092
|
+
memory: o ? Ae(o) : t
|
|
1023
1093
|
};
|
|
1024
1094
|
}
|
|
1025
|
-
const i = t.id === void 0 ? void 0 : e.find((
|
|
1026
|
-
if (i) return { index: i.index, reason: "sticky", memory:
|
|
1095
|
+
const i = t.id === void 0 ? void 0 : e.find((o) => o.id === t.id);
|
|
1096
|
+
if (i) return { index: i.index, reason: "sticky", memory: Ae(i) };
|
|
1027
1097
|
const r = s.stickyRadius ?? 0.2;
|
|
1028
1098
|
if (t.center) {
|
|
1029
|
-
const
|
|
1099
|
+
const o = t.center, d = e.filter((u) => he(u.center, o) <= r).sort((u, p) => he(u.center, o) - he(p.center, o)), h = (t.label ? d.find((u) => u.label === t.label) : void 0) ?? d[0];
|
|
1030
1100
|
if (h)
|
|
1031
|
-
return { index: h.index, reason: "sticky", memory:
|
|
1101
|
+
return { index: h.index, reason: "sticky", memory: Ae(h) };
|
|
1032
1102
|
}
|
|
1033
|
-
const
|
|
1103
|
+
const a = It(e, s.fallback ?? "largest", n);
|
|
1034
1104
|
return {
|
|
1035
|
-
index: (
|
|
1036
|
-
reason:
|
|
1105
|
+
index: (a == null ? void 0 : a.index) ?? null,
|
|
1106
|
+
reason: a ? "sticky-fallback" : "none",
|
|
1037
1107
|
// Keep the old memory on a miss so a brief dropout does not forget the subject.
|
|
1038
|
-
memory:
|
|
1108
|
+
memory: a ? Ae(a) : t
|
|
1039
1109
|
};
|
|
1040
|
-
},
|
|
1041
|
-
let n = 1 / 0, i = -1 / 0, r = 1 / 0,
|
|
1110
|
+
}, Kr = (e) => e.map((s, t) => {
|
|
1111
|
+
let n = 1 / 0, i = -1 / 0, r = 1 / 0, a = -1 / 0;
|
|
1042
1112
|
for (const d of s)
|
|
1043
|
-
d.x < n && (n = d.x), d.x > i && (i = d.x), d.y < r && (r = d.y), d.y >
|
|
1044
|
-
const
|
|
1113
|
+
d.x < n && (n = d.x), d.x > i && (i = d.x), d.y < r && (r = d.y), d.y > a && (a = d.y);
|
|
1114
|
+
const o = s.length > 0 && Number.isFinite(n);
|
|
1045
1115
|
return {
|
|
1046
1116
|
index: t,
|
|
1047
|
-
center:
|
|
1048
|
-
size:
|
|
1117
|
+
center: o ? { x: (n + i) / 2, y: (r + a) / 2 } : { x: 0.5, y: 0.5 },
|
|
1118
|
+
size: o ? i - n : 0
|
|
1049
1119
|
};
|
|
1050
|
-
}),
|
|
1051
|
-
const n = (s.coordinates ?? []).map((l) =>
|
|
1052
|
-
let i = 1 / 0, r = -1 / 0,
|
|
1120
|
+
}), Bn = (e) => e.map((s, t) => {
|
|
1121
|
+
const n = (s.coordinates ?? []).map((l) => On(l));
|
|
1122
|
+
let i = 1 / 0, r = -1 / 0, a = 1 / 0, o = -1 / 0;
|
|
1053
1123
|
for (const l of n)
|
|
1054
|
-
l.x < i && (i = l.x), l.x > r && (r = l.x), l.y <
|
|
1124
|
+
l.x < i && (i = l.x), l.x > r && (r = l.x), l.y < a && (a = l.y), l.y > o && (o = l.y);
|
|
1055
1125
|
const d = n.length > 0;
|
|
1056
1126
|
return {
|
|
1057
1127
|
index: t,
|
|
1058
|
-
center: d ? { x: (i + r) / 2, y: (
|
|
1059
|
-
size: d ? Math.max(r - i,
|
|
1128
|
+
center: d ? { x: (i + r) / 2, y: (a + o) / 2 } : { x: 0.5, y: 0.5 },
|
|
1129
|
+
size: d ? Math.max(r - i, o - a) : 0,
|
|
1060
1130
|
...s.label ? { label: s.label } : {}
|
|
1061
1131
|
};
|
|
1062
|
-
}),
|
|
1132
|
+
}), Gr = (e) => Bn(e.map((s) => ({ coordinates: s.pose.image }))).map((s, t) => ({
|
|
1063
1133
|
...s,
|
|
1064
1134
|
id: e[t].id
|
|
1065
|
-
})),
|
|
1135
|
+
})), Xr = (e, s, t = 0.35) => {
|
|
1066
1136
|
const n = [];
|
|
1067
|
-
for (const
|
|
1068
|
-
for (const
|
|
1069
|
-
const d =
|
|
1070
|
-
d <= t && n.push({ primaryIndex:
|
|
1137
|
+
for (const a of e)
|
|
1138
|
+
for (const o of s) {
|
|
1139
|
+
const d = he(a.center, o.center);
|
|
1140
|
+
d <= t && n.push({ primaryIndex: a.index, secondaryIndex: o.index, distance: d });
|
|
1071
1141
|
}
|
|
1072
|
-
n.sort((
|
|
1142
|
+
n.sort((a, o) => a.distance - o.distance);
|
|
1073
1143
|
const i = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1074
|
-
return n.filter((
|
|
1075
|
-
},
|
|
1076
|
-
|
|
1077
|
-
const r = (n - t.position.z) /
|
|
1078
|
-
return i.copy(t.position).addScaledVector(
|
|
1079
|
-
},
|
|
1144
|
+
return n.filter((a) => i.has(a.primaryIndex) || r.has(a.secondaryIndex) ? !1 : (i.add(a.primaryIndex), r.add(a.secondaryIndex), !0));
|
|
1145
|
+
}, Ft = new W.Vector3(), Ke = new W.Vector3(), Qt = (e, s, t, n, i) => {
|
|
1146
|
+
Ft.set(e, s, 0).unproject(t), Ke.copy(Ft).sub(t.position).normalize();
|
|
1147
|
+
const r = (n - t.position.z) / Ke.z;
|
|
1148
|
+
return i.copy(t.position).addScaledVector(Ke, r);
|
|
1149
|
+
}, Hn = (e, s, t = new W.Vector3(), n = 0) => Qt((e.x - 0.5) * 2, (0.5 - e.y) * 2, s, n, t), jr = (e, s, t = new W.Vector3(), n = 0) => Qt(e.x, e.y, s, n, t), Y = new W.Vector3(), Yr = (e, s, t = { x: 0, y: 0, z: 0 }) => (Y.set(e.x, e.y, e.z).project(s), t.x = Y.x / 2 + 0.5, t.y = 0.5 - Y.y / 2, t.z = Y.z, t), Qr = (e, s, t = { x: 0, y: 0, z: 0 }) => (Y.set(e.x, e.y, e.z).project(s), t.x = Y.x, t.y = Y.y, t.z = Y.z, t), Ge = (e, s, t) => Hn(e, s, t, 0), Un = (e, s, t = 0.2) => t * s + (1 - t) * e;
|
|
1080
1150
|
class we {
|
|
1081
1151
|
constructor(s) {
|
|
1082
|
-
|
|
1083
|
-
|
|
1152
|
+
m(this, "canvas");
|
|
1153
|
+
m(this, "scale", 1);
|
|
1084
1154
|
this.maxDimension = s;
|
|
1085
1155
|
}
|
|
1086
1156
|
/** Multiply the cap (0.25..1); the adaptive-quality tier sets it. */
|
|
@@ -1098,16 +1168,16 @@ class we {
|
|
|
1098
1168
|
this.maxDimension * this.scale / Math.max(t, n)
|
|
1099
1169
|
);
|
|
1100
1170
|
if (i >= 1) return s;
|
|
1101
|
-
const r = Math.max(1, Math.round(t * i)),
|
|
1102
|
-
(!this.canvas || this.canvas.width !== r || this.canvas.height !==
|
|
1103
|
-
const
|
|
1104
|
-
return
|
|
1171
|
+
const r = Math.max(1, Math.round(t * i)), a = Math.max(1, Math.round(n * i));
|
|
1172
|
+
(!this.canvas || this.canvas.width !== r || this.canvas.height !== a) && (this.canvas = new OffscreenCanvas(r, a));
|
|
1173
|
+
const o = this.canvas.getContext("2d");
|
|
1174
|
+
return o ? (o.setTransform(1, 0, 0, 1, 0, 0), o.clearRect(0, 0, r, a), o.drawImage(s, 0, 0, r, a), this.canvas) : s;
|
|
1105
1175
|
}
|
|
1106
1176
|
dispose() {
|
|
1107
1177
|
this.canvas = void 0;
|
|
1108
1178
|
}
|
|
1109
1179
|
}
|
|
1110
|
-
const
|
|
1180
|
+
const zn = {
|
|
1111
1181
|
"/assets/xr/models/face_tracking.task": "sha384-tYQh+yJE8llY+zO4RviZmWaSKs5W9tsB0ix5rjQVpF5/CLTqmwtP7bYtkUi2w65P",
|
|
1112
1182
|
"/assets/xr/models/hand_tracking.task": "sha384-uWvruVKd887ov8k43S+DBHCsi7UXXS+CKvvdM1PX00rjPzx/B0QrAPfJ1U9yKcze",
|
|
1113
1183
|
"/assets/xr/models/gesture_tracking.task": "sha384-2zuseP9JKKWAYlWQGKA2N+ooabB8V/yIxu23Mv8mtY7SowcySB+xKiOmqBhVvlUC",
|
|
@@ -1144,36 +1214,36 @@ const On = {
|
|
|
1144
1214
|
"/assets/sdk/face/v1/canonical_face_model.obj": "sha384-xP8YM/72TXKvbMptXB9a8JUlUf3MZQ8uLurExrsZc05v6/P5RrsaNGMUYS/BZx8A",
|
|
1145
1215
|
"/opencv/facial_expression_recognition/resolve/main/facial_expression_recognition_mobilefacenet_2022july_int8.onnx": "sha384-g8mtFubiIc/yhqi591RsxD76AJLw2CfYgKhKbVkIiFlwBmIyG7ZAIVyGPXafrDGB"
|
|
1146
1216
|
};
|
|
1147
|
-
async function
|
|
1217
|
+
async function Wn(e, s) {
|
|
1148
1218
|
const t = await fetch(e, s != null && s.signal ? { signal: s.signal } : void 0);
|
|
1149
1219
|
if (!t.ok)
|
|
1150
1220
|
throw new Error(`fetchAndVerify: ${t.status} ${e}`);
|
|
1151
|
-
const n = await t.arrayBuffer(), i =
|
|
1221
|
+
const n = await t.arrayBuffer(), i = Kn(e);
|
|
1152
1222
|
if (!i) {
|
|
1153
|
-
if (
|
|
1223
|
+
if (qn(e))
|
|
1154
1224
|
throw new Error(`[xr-sdk integrity] no SRI hash for SDK asset ${e}`);
|
|
1155
1225
|
return console.warn(`[xr-sdk integrity] no SRI hash for ${e} — passing through`), n;
|
|
1156
1226
|
}
|
|
1157
|
-
const r = await
|
|
1227
|
+
const r = await Gn(n);
|
|
1158
1228
|
if (r !== i)
|
|
1159
1229
|
throw new Error(
|
|
1160
1230
|
`[xr-sdk integrity] SRI mismatch for ${e}: expected ${i}, got ${r}`
|
|
1161
1231
|
);
|
|
1162
1232
|
return n;
|
|
1163
1233
|
}
|
|
1164
|
-
function
|
|
1234
|
+
function qn(e) {
|
|
1165
1235
|
try {
|
|
1166
|
-
return new URL(e).origin === new URL(
|
|
1236
|
+
return new URL(e).origin === new URL(q.assetStorageEndpoint).origin;
|
|
1167
1237
|
} catch {
|
|
1168
1238
|
return !1;
|
|
1169
1239
|
}
|
|
1170
1240
|
}
|
|
1171
1241
|
async function ee(e) {
|
|
1172
|
-
const s = await
|
|
1242
|
+
const s = await Wn(e);
|
|
1173
1243
|
return new Uint8Array(s);
|
|
1174
1244
|
}
|
|
1175
1245
|
const le = /* @__PURE__ */ new Map();
|
|
1176
|
-
function
|
|
1246
|
+
function Vn(e) {
|
|
1177
1247
|
let s = le.get(e);
|
|
1178
1248
|
if (!s) {
|
|
1179
1249
|
const i = { bytes: ee(e), holders: 0 };
|
|
@@ -1191,30 +1261,30 @@ function Bn(e) {
|
|
|
1191
1261
|
}
|
|
1192
1262
|
};
|
|
1193
1263
|
}
|
|
1194
|
-
function
|
|
1264
|
+
function Kn(e) {
|
|
1195
1265
|
try {
|
|
1196
1266
|
const s = new URL(e);
|
|
1197
|
-
return
|
|
1267
|
+
return zn[s.pathname];
|
|
1198
1268
|
} catch {
|
|
1199
1269
|
return;
|
|
1200
1270
|
}
|
|
1201
1271
|
}
|
|
1202
|
-
async function
|
|
1272
|
+
async function Gn(e) {
|
|
1203
1273
|
const s = await crypto.subtle.digest("SHA-384", e), t = new Uint8Array(s);
|
|
1204
1274
|
let n = "";
|
|
1205
1275
|
for (let i = 0; i < t.byteLength; i++)
|
|
1206
1276
|
n += String.fromCharCode(t[i]);
|
|
1207
1277
|
return `sha384-${btoa(n)}`;
|
|
1208
1278
|
}
|
|
1209
|
-
const
|
|
1279
|
+
const Xe = /* @__PURE__ */ new Map();
|
|
1210
1280
|
function te(e) {
|
|
1211
1281
|
const s = e.wasmBinaryPath;
|
|
1212
|
-
let t =
|
|
1213
|
-
return t || (t =
|
|
1214
|
-
|
|
1215
|
-
}),
|
|
1282
|
+
let t = Xe.get(s);
|
|
1283
|
+
return t || (t = Xn(s).catch(() => {
|
|
1284
|
+
Xe.delete(s);
|
|
1285
|
+
}), Xe.set(s, t)), t;
|
|
1216
1286
|
}
|
|
1217
|
-
async function
|
|
1287
|
+
async function Xn(e) {
|
|
1218
1288
|
const s = await fetch(e, { credentials: "same-origin" });
|
|
1219
1289
|
if (!s.ok || !s.body)
|
|
1220
1290
|
throw new Error(`warmVisionWasm: ${s.status} ${e}`);
|
|
@@ -1226,31 +1296,31 @@ async function zn(e) {
|
|
|
1226
1296
|
}
|
|
1227
1297
|
class se {
|
|
1228
1298
|
constructor() {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1299
|
+
m(this, "disposed", !1);
|
|
1300
|
+
m(this, "paused", !1);
|
|
1301
|
+
m(this, "rafId", null);
|
|
1232
1302
|
// Inference bookkeeping behind `getDiagnostics()`. Subclasses call
|
|
1233
1303
|
// `recordInference(startMs)` right after their detect call and
|
|
1234
1304
|
// `recordDetections(count, confidence)` after reading the result.
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1305
|
+
m(this, "statInferenceMs", null);
|
|
1306
|
+
m(this, "statInferences", 0);
|
|
1307
|
+
m(this, "statWindowStart", 0);
|
|
1308
|
+
m(this, "statWindowCount", 0);
|
|
1309
|
+
m(this, "statFps", 0);
|
|
1310
|
+
m(this, "statSkipped", 0);
|
|
1311
|
+
m(this, "statDetections", null);
|
|
1312
|
+
m(this, "statConfidence", null);
|
|
1313
|
+
m(this, "statStatus", "ready");
|
|
1314
|
+
m(this, "statError", null);
|
|
1245
1315
|
// Inference-rate throttle. `targetFrameIntervalMs` is 0 when uncapped
|
|
1246
1316
|
// (detect every frame); a positive value skips detection until that many ms
|
|
1247
1317
|
// have elapsed since the last inference. `run()` sets this from
|
|
1248
1318
|
// `params.targetFps`; subclasses call `shouldRunInference()` in their RAF
|
|
1249
1319
|
// loop to gate the expensive MediaPipe call.
|
|
1250
|
-
|
|
1251
|
-
|
|
1320
|
+
m(this, "targetFrameIntervalMs", 0);
|
|
1321
|
+
m(this, "lastInferenceMs", 0);
|
|
1252
1322
|
/** Analysis-resolution multiplier (0.25..1) from the quality tier; subclasses read it where they downscale. */
|
|
1253
|
-
|
|
1323
|
+
m(this, "analysisScale", 1);
|
|
1254
1324
|
}
|
|
1255
1325
|
/** Record one completed inference that started at `startMs` (`performance.now()`). */
|
|
1256
1326
|
recordInference(s, t = performance.now()) {
|
|
@@ -1336,52 +1406,52 @@ class se {
|
|
|
1336
1406
|
this.disposed = !0, this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
1337
1407
|
}
|
|
1338
1408
|
}
|
|
1339
|
-
const
|
|
1340
|
-
class
|
|
1409
|
+
const jn = 768, je = (e) => e > 1 ? "IMAGE" : "VIDEO";
|
|
1410
|
+
class Yn extends se {
|
|
1341
1411
|
constructor() {
|
|
1342
1412
|
super();
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1413
|
+
m(this, "landmarker", null);
|
|
1414
|
+
m(this, "processingTime", null);
|
|
1415
|
+
m(this, "coordinates");
|
|
1416
|
+
m(this, "visibility");
|
|
1347
1417
|
/** Per body, sided as the person's own left / right (see `anatomicalBodyPose`). */
|
|
1348
|
-
|
|
1418
|
+
m(this, "poses", []);
|
|
1349
1419
|
/** The same bodies with a stable id each (`BodyIdentity`), by id. */
|
|
1350
|
-
|
|
1351
|
-
|
|
1420
|
+
m(this, "bodies", []);
|
|
1421
|
+
m(this, "identity", new Fn());
|
|
1352
1422
|
/** How many bodies the landmarker looks for now, and what each consumer asked for. */
|
|
1353
|
-
|
|
1354
|
-
|
|
1423
|
+
m(this, "numPoses", 1);
|
|
1424
|
+
m(this, "bodyRequests", /* @__PURE__ */ new Map());
|
|
1355
1425
|
/** While `setOptions` rebuilds the landmarker, inference waits. */
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1426
|
+
m(this, "reconfiguring", !1);
|
|
1427
|
+
m(this, "getSource");
|
|
1428
|
+
m(this, "sourceCanvas");
|
|
1429
|
+
m(this, "downscaler", new we(jn));
|
|
1360
1430
|
}
|
|
1361
1431
|
async getBodyData() {
|
|
1362
|
-
var
|
|
1432
|
+
var p;
|
|
1363
1433
|
if (!this.landmarker || !this.sourceCanvas)
|
|
1364
1434
|
return;
|
|
1365
|
-
const t = this.downscaler.draw(this.sourceCanvas), n = performance.now(), i =
|
|
1435
|
+
const t = this.downscaler.draw(this.sourceCanvas), n = performance.now(), i = je(this.numPoses) === "IMAGE" ? this.landmarker.detect(t) : this.landmarker.detectForVideo(t, n), r = performance.now();
|
|
1366
1436
|
this.processingTime = r - n, this.recordInference(n, r);
|
|
1367
|
-
const
|
|
1437
|
+
const a = i.landmarks, o = a == null ? void 0 : a[0];
|
|
1368
1438
|
this.recordDetections(
|
|
1369
|
-
(
|
|
1370
|
-
|
|
1439
|
+
(a == null ? void 0 : a.length) ?? 0,
|
|
1440
|
+
o && o.length ? o.reduce((M, x) => M + (x.visibility ?? 0), 0) / o.length : null
|
|
1371
1441
|
);
|
|
1372
|
-
const d = [], l = [], h = [],
|
|
1373
|
-
if (
|
|
1374
|
-
return
|
|
1442
|
+
const d = [], l = [], h = [], u = Se((p = this.getSource) == null ? void 0 : p.call(this));
|
|
1443
|
+
if (a)
|
|
1444
|
+
return a.forEach((M, x) => {
|
|
1375
1445
|
var T;
|
|
1376
1446
|
d[x] || (d[x] = [], l[x] = []), M.forEach((R) => {
|
|
1377
|
-
d[x].push(
|
|
1447
|
+
d[x].push(me(R)), l[x].push(R.visibility ?? 1);
|
|
1378
1448
|
});
|
|
1379
1449
|
const b = (((T = i.worldLandmarks) == null ? void 0 : T[x]) ?? []).map(
|
|
1380
|
-
(R) =>
|
|
1450
|
+
(R) => kn(R)
|
|
1381
1451
|
);
|
|
1382
|
-
b.length === M.length && (h[x] =
|
|
1452
|
+
b.length === M.length && (h[x] = Cn(
|
|
1383
1453
|
{ world: b, image: d[x], visibility: l[x] },
|
|
1384
|
-
|
|
1454
|
+
u,
|
|
1385
1455
|
n
|
|
1386
1456
|
));
|
|
1387
1457
|
}), {
|
|
@@ -1443,11 +1513,11 @@ class qn extends se {
|
|
|
1443
1513
|
};
|
|
1444
1514
|
}
|
|
1445
1515
|
async applyNumBodies() {
|
|
1446
|
-
const t =
|
|
1516
|
+
const t = Ct(this.bodyRequests.values(), At.body.max);
|
|
1447
1517
|
if (!(t === this.numPoses || this.disposed || this.reconfiguring || !this.landmarker)) {
|
|
1448
1518
|
this.reconfiguring = !0;
|
|
1449
1519
|
try {
|
|
1450
|
-
await this.landmarker.setOptions({ numPoses: t, runningMode:
|
|
1520
|
+
await this.landmarker.setOptions({ numPoses: t, runningMode: je(t) }), this.numPoses = t;
|
|
1451
1521
|
} catch (n) {
|
|
1452
1522
|
console.warn("[BodyTrackingModel] numPoses change failed", n);
|
|
1453
1523
|
return;
|
|
@@ -1459,21 +1529,21 @@ class qn extends se {
|
|
|
1459
1529
|
}
|
|
1460
1530
|
async initialize(t) {
|
|
1461
1531
|
const n = await $.forVisionTasks(
|
|
1462
|
-
new URL("/assets/xr/wasm",
|
|
1532
|
+
new URL("/assets/xr/wasm", q.assetStorageEndpoint).toString()
|
|
1463
1533
|
), [i] = await Promise.all([
|
|
1464
1534
|
ee(
|
|
1465
|
-
new URL("/assets/xr/models/body_tracking.task",
|
|
1535
|
+
new URL("/assets/xr/models/body_tracking.task", q.assetStorageEndpoint).toString()
|
|
1466
1536
|
),
|
|
1467
1537
|
te(n)
|
|
1468
1538
|
]);
|
|
1469
1539
|
t != null && t.numPoses && this.bodyRequests.set("options", t.numPoses);
|
|
1470
|
-
const r =
|
|
1471
|
-
this.landmarker = await
|
|
1540
|
+
const r = Ct(this.bodyRequests.values(), At.body.max);
|
|
1541
|
+
this.landmarker = await Ns.createFromOptions(n, {
|
|
1472
1542
|
baseOptions: {
|
|
1473
1543
|
modelAssetBuffer: i,
|
|
1474
1544
|
delegate: "GPU"
|
|
1475
1545
|
},
|
|
1476
|
-
runningMode:
|
|
1546
|
+
runningMode: je(r),
|
|
1477
1547
|
numPoses: r
|
|
1478
1548
|
}), this.numPoses = r, this.applyNumBodies();
|
|
1479
1549
|
}
|
|
@@ -1506,33 +1576,33 @@ class qn extends se {
|
|
|
1506
1576
|
};
|
|
1507
1577
|
}
|
|
1508
1578
|
}
|
|
1509
|
-
const
|
|
1510
|
-
class
|
|
1579
|
+
const Jt = Symbol("xr.modelNodeSource"), Jr = (e) => e[Jt] ?? e, Qn = 0.11, Jn = 4e-3, Zn = "/assets/xr/models/face_tracking.task", $n = "/assets/xr/wasm", ei = (e, s, t = !0) => t ? s.set(e.x, -e.y, e.z) : s.set(e.x, e.y, -e.z), ti = (e, s) => s.setFromRotationMatrix(e).normalize();
|
|
1580
|
+
class si extends se {
|
|
1511
1581
|
constructor() {
|
|
1512
1582
|
super();
|
|
1513
|
-
|
|
1583
|
+
m(this, "landmarker", null);
|
|
1514
1584
|
/** The face model bytes, held while this model is alive (shared with the still-image detector). */
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1585
|
+
m(this, "modelBytes", null);
|
|
1586
|
+
m(this, "processingTime", null);
|
|
1587
|
+
m(this, "sourceCanvas");
|
|
1588
|
+
m(this, "analysisCanvas");
|
|
1589
|
+
m(this, "getSource");
|
|
1590
|
+
m(this, "detectionResults");
|
|
1591
|
+
m(this, "numFaces", 1);
|
|
1592
|
+
m(this, "cameras", []);
|
|
1523
1593
|
// camera object to unproject each face's translation
|
|
1524
|
-
|
|
1594
|
+
m(this, "faces", []);
|
|
1525
1595
|
// Reused per-face work vectors. Allocated once per face index and mutated
|
|
1526
1596
|
// in place each frame, so the published Face[] doesn't churn the GC at
|
|
1527
1597
|
// 30+ fps. Per-face indexing means two faces don't alias each other's
|
|
1528
1598
|
// transforms; consumers see "current value" each frame.
|
|
1529
|
-
|
|
1530
|
-
|
|
1599
|
+
m(this, "leftCheekScratch", []);
|
|
1600
|
+
m(this, "rightCheekScratch", []);
|
|
1531
1601
|
// Reused per-frame rotation scratch (matrix -> quaternion -> mirror -> euler),
|
|
1532
1602
|
// allocated once to avoid per-frame churn at 30+ fps.
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1603
|
+
m(this, "rotMatrixScratch", new W.Matrix4());
|
|
1604
|
+
m(this, "rotQuatScratch", new W.Quaternion());
|
|
1605
|
+
m(this, "rotEulerScratch", new W.Euler());
|
|
1536
1606
|
}
|
|
1537
1607
|
extractAndUpdateFaceData(t) {
|
|
1538
1608
|
var r;
|
|
@@ -1546,34 +1616,34 @@ class Qn extends se {
|
|
|
1546
1616
|
for (; this.faces.length < n; )
|
|
1547
1617
|
this.faces.push({
|
|
1548
1618
|
transform: {
|
|
1549
|
-
position: new
|
|
1550
|
-
rotation: new
|
|
1551
|
-
quaternion: new
|
|
1552
|
-
scale: new
|
|
1619
|
+
position: new W.Vector3(),
|
|
1620
|
+
rotation: new W.Vector3(),
|
|
1621
|
+
quaternion: new W.Quaternion(),
|
|
1622
|
+
scale: new W.Vector3()
|
|
1553
1623
|
},
|
|
1554
1624
|
gestures: {},
|
|
1555
1625
|
mirrored: i
|
|
1556
|
-
}), this.leftCheekScratch.push(new
|
|
1557
|
-
for (let
|
|
1558
|
-
this.faces[
|
|
1559
|
-
for (let
|
|
1560
|
-
if (!this.cameras[
|
|
1626
|
+
}), this.leftCheekScratch.push(new W.Vector3()), this.rightCheekScratch.push(new W.Vector3());
|
|
1627
|
+
for (let a = 0; a < n; a += 1)
|
|
1628
|
+
this.faces[a].mirrored = i;
|
|
1629
|
+
for (let a = 0; a < n; a += 1) {
|
|
1630
|
+
if (!this.cameras[a])
|
|
1561
1631
|
continue;
|
|
1562
|
-
const
|
|
1563
|
-
this.rotMatrixScratch.fromArray(l.data),
|
|
1632
|
+
const o = this.faces[a], d = t.faceLandmarks[a], l = t.facialTransformationMatrixes[a];
|
|
1633
|
+
this.rotMatrixScratch.fromArray(l.data), ti(this.rotMatrixScratch, o.transform.quaternion), this.rotQuatScratch.copy(o.transform.quaternion), this.rotQuatScratch.set(
|
|
1564
1634
|
-this.rotQuatScratch.x,
|
|
1565
1635
|
this.rotQuatScratch.y,
|
|
1566
1636
|
this.rotQuatScratch.z,
|
|
1567
1637
|
this.rotQuatScratch.w
|
|
1568
|
-
), this.rotEulerScratch.setFromQuaternion(this.rotQuatScratch, "XYZ"),
|
|
1569
|
-
const
|
|
1638
|
+
), this.rotEulerScratch.setFromQuaternion(this.rotQuatScratch, "XYZ"), ei(this.rotEulerScratch, o.transform.rotation, i), Ge(d[4], this.cameras[a], o.transform.position), Ge(d[50], this.cameras[a], this.leftCheekScratch[a]), Ge(d[280], this.cameras[a], this.rightCheekScratch[a]);
|
|
1639
|
+
const u = this.leftCheekScratch[a].distanceTo(this.rightCheekScratch[a]) * Qn, p = Math.abs(W.MathUtils.radToDeg(this.rotEulerScratch.y)), M = u + p * Jn, x = o.transform.scale.x, b = Un(
|
|
1570
1640
|
isNaN(x) ? 0 : x,
|
|
1571
1641
|
M
|
|
1572
1642
|
);
|
|
1573
|
-
|
|
1574
|
-
const T =
|
|
1575
|
-
for (const
|
|
1576
|
-
T[
|
|
1643
|
+
o.transform.scale.set(b, b, b);
|
|
1644
|
+
const T = o.gestures, R = t.faceBlendshapes[a].categories;
|
|
1645
|
+
for (const w of R)
|
|
1646
|
+
T[w.categoryName] = w.score;
|
|
1577
1647
|
}
|
|
1578
1648
|
}
|
|
1579
1649
|
async processFaceTracking() {
|
|
@@ -1583,16 +1653,16 @@ class Qn extends se {
|
|
|
1583
1653
|
this.rafId = requestAnimationFrame(this.processFaceTracking.bind(this));
|
|
1584
1654
|
return;
|
|
1585
1655
|
}
|
|
1586
|
-
const t =
|
|
1587
|
-
(!this.analysisCanvas || this.analysisCanvas.width !==
|
|
1656
|
+
const t = ni(this.numFaces) * this.analysisScale, n = this.sourceCanvas.width, i = this.sourceCanvas.height, r = Math.min(1, t / Math.max(n, i)), a = Math.max(1, Math.round(n * r)), o = Math.max(1, Math.round(i * r));
|
|
1657
|
+
(!this.analysisCanvas || this.analysisCanvas.width !== a || this.analysisCanvas.height !== o) && (this.analysisCanvas = new OffscreenCanvas(a, o));
|
|
1588
1658
|
const d = this.analysisCanvas.getContext("2d");
|
|
1589
1659
|
if (!d) {
|
|
1590
1660
|
this.rafId = requestAnimationFrame(this.processFaceTracking.bind(this));
|
|
1591
1661
|
return;
|
|
1592
1662
|
}
|
|
1593
|
-
d.setTransform(1, 0, 0, 1, 0, 0), d.clearRect(0, 0,
|
|
1594
|
-
const l = performance.now(), h = this.landmarker.detectForVideo(this.analysisCanvas, l),
|
|
1595
|
-
this.processingTime =
|
|
1663
|
+
d.setTransform(1, 0, 0, 1, 0, 0), d.clearRect(0, 0, a, o), d.drawImage(this.sourceCanvas, 0, 0, a, o);
|
|
1664
|
+
const l = performance.now(), h = this.landmarker.detectForVideo(this.analysisCanvas, l), u = performance.now();
|
|
1665
|
+
this.processingTime = u - l, this.recordInference(l, u), this.recordDetections(h.faceLandmarks.length, null), this.detectionResults = h, this.extractAndUpdateFaceData(h), !(this.disposed || this.paused) && (this.rafId = requestAnimationFrame(this.processFaceTracking.bind(this)));
|
|
1596
1666
|
}
|
|
1597
1667
|
resume() {
|
|
1598
1668
|
this.paused && (super.resume(), this.processFaceTracking());
|
|
@@ -1614,31 +1684,31 @@ class Qn extends se {
|
|
|
1614
1684
|
return this.detectionResults;
|
|
1615
1685
|
}
|
|
1616
1686
|
getRawFaceTrackingData(t = 0) {
|
|
1617
|
-
var n, i, r,
|
|
1687
|
+
var n, i, r, a;
|
|
1618
1688
|
if (this.detectionResults)
|
|
1619
1689
|
return {
|
|
1620
1690
|
landmarks: (n = this.detectionResults.faceLandmarks) == null ? void 0 : n[t],
|
|
1621
1691
|
blendshapes: (r = (i = this.detectionResults.faceBlendshapes) == null ? void 0 : i[t]) == null ? void 0 : r.categories,
|
|
1622
|
-
transformationMatrix: (
|
|
1692
|
+
transformationMatrix: (a = this.detectionResults.facialTransformationMatrixes) == null ? void 0 : a[t]
|
|
1623
1693
|
};
|
|
1624
1694
|
}
|
|
1625
1695
|
async initialize(t) {
|
|
1626
|
-
var
|
|
1696
|
+
var a;
|
|
1627
1697
|
this.numFaces = (t == null ? void 0 : t.numFaces) || 1;
|
|
1628
1698
|
const n = await $.forVisionTasks(
|
|
1629
|
-
new URL(
|
|
1699
|
+
new URL($n, q.assetStorageEndpoint).toString()
|
|
1630
1700
|
);
|
|
1631
|
-
(
|
|
1632
|
-
const i =
|
|
1633
|
-
new URL(
|
|
1701
|
+
(a = this.modelBytes) == null || a.release();
|
|
1702
|
+
const i = Vn(
|
|
1703
|
+
new URL(Zn, q.assetStorageEndpoint).toString()
|
|
1634
1704
|
);
|
|
1635
1705
|
this.modelBytes = i;
|
|
1636
1706
|
let r;
|
|
1637
1707
|
try {
|
|
1638
|
-
const [
|
|
1639
|
-
r = await
|
|
1708
|
+
const [o] = await Promise.all([i.bytes, te(n)]);
|
|
1709
|
+
r = await Bs.createFromOptions(n, {
|
|
1640
1710
|
baseOptions: {
|
|
1641
|
-
modelAssetBuffer:
|
|
1711
|
+
modelAssetBuffer: o,
|
|
1642
1712
|
delegate: "GPU"
|
|
1643
1713
|
},
|
|
1644
1714
|
// Keep detection permissive for calibration workflows with dark webcam input.
|
|
@@ -1650,8 +1720,8 @@ class Qn extends se {
|
|
|
1650
1720
|
runningMode: "VIDEO",
|
|
1651
1721
|
numFaces: this.numFaces
|
|
1652
1722
|
});
|
|
1653
|
-
} catch (
|
|
1654
|
-
throw this.releaseModelBytes(i),
|
|
1723
|
+
} catch (o) {
|
|
1724
|
+
throw this.releaseModelBytes(i), o;
|
|
1655
1725
|
}
|
|
1656
1726
|
if (this.disposed) {
|
|
1657
1727
|
r.close(), this.releaseModelBytes(i);
|
|
@@ -1685,7 +1755,7 @@ class Qn extends se {
|
|
|
1685
1755
|
this.cameras[r] = i;
|
|
1686
1756
|
}
|
|
1687
1757
|
};
|
|
1688
|
-
return Object.defineProperty(n,
|
|
1758
|
+
return Object.defineProperty(n, Jt, { value: t }), n;
|
|
1689
1759
|
}
|
|
1690
1760
|
async getPerformanceData() {
|
|
1691
1761
|
return {
|
|
@@ -1694,27 +1764,27 @@ class Qn extends se {
|
|
|
1694
1764
|
};
|
|
1695
1765
|
}
|
|
1696
1766
|
}
|
|
1697
|
-
const
|
|
1698
|
-
var
|
|
1699
|
-
const
|
|
1700
|
-
Closed_Fist:
|
|
1701
|
-
Open_Palm:
|
|
1702
|
-
Pointing_Up:
|
|
1703
|
-
Thumb_Down:
|
|
1704
|
-
Thumb_Up:
|
|
1705
|
-
Victory:
|
|
1706
|
-
ILoveYou:
|
|
1707
|
-
None:
|
|
1708
|
-
},
|
|
1709
|
-
class
|
|
1767
|
+
const ni = (e) => e > 1 ? 1024 : 512;
|
|
1768
|
+
var j = /* @__PURE__ */ ((e) => (e.ClosedFist = "closed_fist", e.OpenPalm = "open_palm", e.PointingUp = "pointing_up", e.ThumbDown = "thumb_down", e.ThumbUp = "thumb_up", e.Victory = "victory", e.ILoveYou = "i_love_you", e.None = "none", e))(j || {});
|
|
1769
|
+
const ii = 512, ri = {
|
|
1770
|
+
Closed_Fist: j.ClosedFist,
|
|
1771
|
+
Open_Palm: j.OpenPalm,
|
|
1772
|
+
Pointing_Up: j.PointingUp,
|
|
1773
|
+
Thumb_Down: j.ThumbDown,
|
|
1774
|
+
Thumb_Up: j.ThumbUp,
|
|
1775
|
+
Victory: j.Victory,
|
|
1776
|
+
ILoveYou: j.ILoveYou,
|
|
1777
|
+
None: j.None
|
|
1778
|
+
}, ai = 15;
|
|
1779
|
+
class oi extends se {
|
|
1710
1780
|
constructor() {
|
|
1711
1781
|
super();
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1782
|
+
m(this, "landmarker", null);
|
|
1783
|
+
m(this, "processingTime", null);
|
|
1784
|
+
m(this, "coordinates");
|
|
1785
|
+
m(this, "gesture");
|
|
1786
|
+
m(this, "sourceCanvas");
|
|
1787
|
+
m(this, "downscaler", new we(ii));
|
|
1718
1788
|
}
|
|
1719
1789
|
async getGestureData() {
|
|
1720
1790
|
var d, l;
|
|
@@ -1722,14 +1792,14 @@ class ti extends se {
|
|
|
1722
1792
|
return;
|
|
1723
1793
|
const t = this.downscaler.draw(this.sourceCanvas), n = performance.now(), i = this.landmarker.recognizeForVideo(t, n), r = performance.now();
|
|
1724
1794
|
this.processingTime = r - n, this.recordInference(n, r), this.recordDetections(i.landmarks.length, ((l = (d = i.gestures[0]) == null ? void 0 : d[0]) == null ? void 0 : l.score) ?? null);
|
|
1725
|
-
const
|
|
1726
|
-
if (
|
|
1795
|
+
const a = i.landmarks[0], o = [];
|
|
1796
|
+
if (a) {
|
|
1727
1797
|
const h = i.gestures[0][0].categoryName;
|
|
1728
|
-
return
|
|
1729
|
-
|
|
1798
|
+
return a.forEach((u) => {
|
|
1799
|
+
o.push(me(u));
|
|
1730
1800
|
}), {
|
|
1731
|
-
coordinates:
|
|
1732
|
-
gesture:
|
|
1801
|
+
coordinates: o,
|
|
1802
|
+
gesture: ri[h]
|
|
1733
1803
|
};
|
|
1734
1804
|
}
|
|
1735
1805
|
return { coordinates: void 0, gesture: void 0 };
|
|
@@ -1758,16 +1828,16 @@ class ti extends se {
|
|
|
1758
1828
|
}
|
|
1759
1829
|
async initialize() {
|
|
1760
1830
|
const t = await $.forVisionTasks(
|
|
1761
|
-
new URL("/assets/xr/wasm",
|
|
1831
|
+
new URL("/assets/xr/wasm", q.assetStorageEndpoint).toString()
|
|
1762
1832
|
), [n] = await Promise.all([
|
|
1763
1833
|
ee(
|
|
1764
1834
|
new URL(
|
|
1765
1835
|
"/assets/xr/models/gesture_tracking.task",
|
|
1766
|
-
|
|
1836
|
+
q.assetStorageEndpoint
|
|
1767
1837
|
).toString()
|
|
1768
1838
|
),
|
|
1769
1839
|
te(t)
|
|
1770
|
-
]), i = await
|
|
1840
|
+
]), i = await Hs.createFromOptions(t, {
|
|
1771
1841
|
baseOptions: {
|
|
1772
1842
|
modelAssetBuffer: n,
|
|
1773
1843
|
delegate: "GPU"
|
|
@@ -1778,7 +1848,7 @@ class ti extends se {
|
|
|
1778
1848
|
this.landmarker = i;
|
|
1779
1849
|
}
|
|
1780
1850
|
async run({ sourceCanvas: t, targetFps: n, analysisScale: i }) {
|
|
1781
|
-
this.setAnalysisScale(i), this.downscaler.setScale(this.analysisScale), this.sourceCanvas = t, this.setTargetFps(n ??
|
|
1851
|
+
this.setAnalysisScale(i), this.downscaler.setScale(this.analysisScale), this.sourceCanvas = t, this.setTargetFps(n ?? ai), this.rafId === null && await this.processGestureTracking();
|
|
1782
1852
|
}
|
|
1783
1853
|
getModelNode() {
|
|
1784
1854
|
const t = this;
|
|
@@ -1798,28 +1868,28 @@ class ti extends se {
|
|
|
1798
1868
|
};
|
|
1799
1869
|
}
|
|
1800
1870
|
}
|
|
1801
|
-
class
|
|
1871
|
+
class ci extends se {
|
|
1802
1872
|
constructor() {
|
|
1803
1873
|
super();
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1874
|
+
m(this, "landmarker", null);
|
|
1875
|
+
m(this, "status", "loading");
|
|
1876
|
+
m(this, "error", null);
|
|
1877
|
+
m(this, "processingTime", null);
|
|
1878
|
+
m(this, "sourceCanvas");
|
|
1879
|
+
m(this, "getSource");
|
|
1880
|
+
m(this, "downscaler", new we(Ze().analysisMaxDimension));
|
|
1881
|
+
m(this, "raw");
|
|
1882
|
+
m(this, "delegatePolicy", "auto");
|
|
1883
|
+
m(this, "delegate", "GPU");
|
|
1814
1884
|
/** Kept so the graph can be rebuilt on another delegate without refetching. */
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1885
|
+
m(this, "vision", null);
|
|
1886
|
+
m(this, "modelBuffer", null);
|
|
1887
|
+
m(this, "graphOptions", {});
|
|
1888
|
+
m(this, "rebuilding", !1);
|
|
1889
|
+
m(this, "fallbackAttempted", !1);
|
|
1890
|
+
m(this, "result", nn());
|
|
1891
|
+
m(this, "builder", new an());
|
|
1892
|
+
m(this, "node");
|
|
1823
1893
|
this.node = {
|
|
1824
1894
|
getResult: () => this.result,
|
|
1825
1895
|
getRawResult: () => this.raw,
|
|
@@ -1839,9 +1909,9 @@ class si extends se {
|
|
|
1839
1909
|
this.status = "loading", this.error = null, this.setRuntimeOptions(t ?? {});
|
|
1840
1910
|
try {
|
|
1841
1911
|
const n = await $.forVisionTasks(
|
|
1842
|
-
new URL("/assets/xr/wasm",
|
|
1912
|
+
new URL("/assets/xr/wasm", q.assetStorageEndpoint).toString()
|
|
1843
1913
|
), [i] = await Promise.all([
|
|
1844
|
-
ee((t == null ? void 0 : t.modelUrl) ??
|
|
1914
|
+
ee((t == null ? void 0 : t.modelUrl) ?? Ut),
|
|
1845
1915
|
te(n)
|
|
1846
1916
|
]);
|
|
1847
1917
|
this.vision = n, this.modelBuffer = i, this.graphOptions = {
|
|
@@ -1866,7 +1936,7 @@ class si extends se {
|
|
|
1866
1936
|
createLandmarker(t) {
|
|
1867
1937
|
if (!this.vision || !this.modelBuffer)
|
|
1868
1938
|
throw new Error("HolisticTrackingModel: initialize() has not loaded the model");
|
|
1869
|
-
return
|
|
1939
|
+
return Us.createFromOptions(this.vision, {
|
|
1870
1940
|
baseOptions: { modelAssetBuffer: this.modelBuffer, delegate: t },
|
|
1871
1941
|
...this.graphOptions
|
|
1872
1942
|
});
|
|
@@ -1904,15 +1974,15 @@ class si extends se {
|
|
|
1904
1974
|
this.disposed || !this.landmarker || !this.sourceCanvas || (this.detect(), this.builder.update(this.raw, performance.now(), this.result, this.isMirrored()));
|
|
1905
1975
|
}
|
|
1906
1976
|
detect() {
|
|
1907
|
-
var i, r,
|
|
1977
|
+
var i, r, a, o, d;
|
|
1908
1978
|
if (!this.landmarker || !this.sourceCanvas) return;
|
|
1909
1979
|
const t = this.downscaler.draw(this.sourceCanvas), n = performance.now();
|
|
1910
1980
|
try {
|
|
1911
1981
|
this.raw = this.landmarker.detectForVideo(t, n), this.status === "error" && (this.status = "ready", this.error = null), this.recordInferenceError(null);
|
|
1912
|
-
const l = this.raw, h = ((i = l.faceLandmarks) != null && i.length ? 1 : 0) + ((r = l.leftHandLandmarks) != null && r.length ? 1 : 0) + ((
|
|
1982
|
+
const l = this.raw, h = ((i = l.faceLandmarks) != null && i.length ? 1 : 0) + ((r = l.leftHandLandmarks) != null && r.length ? 1 : 0) + ((a = l.rightHandLandmarks) != null && a.length ? 1 : 0) + ((o = l.poseLandmarks) != null && o.length ? 1 : 0), u = (d = l.poseLandmarks) == null ? void 0 : d[0];
|
|
1913
1983
|
this.recordDetections(
|
|
1914
1984
|
h,
|
|
1915
|
-
|
|
1985
|
+
u && u.length ? u.reduce((p, M) => p + (M.visibility ?? 0), 0) / u.length : null
|
|
1916
1986
|
);
|
|
1917
1987
|
} catch (l) {
|
|
1918
1988
|
const h = l instanceof Error ? l : new Error(String(l));
|
|
@@ -1956,12 +2026,12 @@ class si extends se {
|
|
|
1956
2026
|
return { name: this.constructor.name, processingTime: this.processingTime };
|
|
1957
2027
|
}
|
|
1958
2028
|
}
|
|
1959
|
-
const
|
|
2029
|
+
const li = (e) => e === "left" ? "right" : "left", di = (e, s) => s ? li(e) : e, hi = /left|right|Left|Right/, ui = {
|
|
1960
2030
|
left: "right",
|
|
1961
2031
|
right: "left",
|
|
1962
2032
|
Left: "Right",
|
|
1963
2033
|
Right: "Left"
|
|
1964
|
-
},
|
|
2034
|
+
}, mi = (e) => e.replace(hi, (s) => ui[s]), Zr = (e, s) => s ? mi(e) : e, $r = (e) => e ? -1 : 1, fi = [
|
|
1965
2035
|
"wrist",
|
|
1966
2036
|
"thumbCmc",
|
|
1967
2037
|
"thumbMcp",
|
|
@@ -1983,107 +2053,107 @@ const ni = (e) => e === "left" ? "right" : "left", ii = (e, s) => s ? ni(e) : e,
|
|
|
1983
2053
|
"pinkyPip",
|
|
1984
2054
|
"pinkyDip",
|
|
1985
2055
|
"pinkyTip"
|
|
1986
|
-
],
|
|
1987
|
-
|
|
1988
|
-
),
|
|
2056
|
+
], ea = Object.fromEntries(
|
|
2057
|
+
fi.map((e, s) => [e, s])
|
|
2058
|
+
), gi = 200, ge = (e, s) => Math.hypot(e.x - s.x, e.y - s.y), pe = (e) => e === "left" ? "right" : "left", Ye = (e, s, t) => ({
|
|
1989
2059
|
handedness: s,
|
|
1990
2060
|
score: e.score,
|
|
1991
2061
|
world: e.world,
|
|
1992
2062
|
image: e.image,
|
|
1993
2063
|
timestampMs: t,
|
|
1994
2064
|
held: !1
|
|
1995
|
-
}),
|
|
1996
|
-
holdMs: n =
|
|
2065
|
+
}), pi = (e, s, t, {
|
|
2066
|
+
holdMs: n = gi,
|
|
1997
2067
|
confidentScore: i = 0.8,
|
|
1998
2068
|
continuityMs: r = 500
|
|
1999
2069
|
} = {}) => {
|
|
2000
|
-
const
|
|
2070
|
+
const a = (l) => !!l && t - l.timestampMs <= r && l.image.length > 0, o = { left: null, right: null }, d = e.filter((l) => l.image.length > 0).slice(0, 2);
|
|
2001
2071
|
if (d.length === 2) {
|
|
2002
|
-
const [l, h] = d,
|
|
2072
|
+
const [l, h] = d, u = l.handedness !== void 0 && h.handedness !== void 0 && l.handedness !== h.handedness, p = l.score >= i && h.score >= i;
|
|
2003
2073
|
let M;
|
|
2004
|
-
if (
|
|
2074
|
+
if (u && p)
|
|
2005
2075
|
M = l.handedness;
|
|
2006
|
-
else if (
|
|
2007
|
-
const x =
|
|
2076
|
+
else if (a(s.left) && a(s.right)) {
|
|
2077
|
+
const x = ge(l.image[0], s.left.image[0]) + ge(h.image[0], s.right.image[0]), b = ge(l.image[0], s.right.image[0]) + ge(h.image[0], s.left.image[0]);
|
|
2008
2078
|
M = x <= b ? "left" : "right";
|
|
2009
|
-
} else if (
|
|
2079
|
+
} else if (u)
|
|
2010
2080
|
M = l.handedness;
|
|
2011
2081
|
else {
|
|
2012
2082
|
const x = l.score >= h.score ? l : h, b = x.handedness ?? "right";
|
|
2013
|
-
M = x === l ? b :
|
|
2083
|
+
M = x === l ? b : pe(b);
|
|
2014
2084
|
}
|
|
2015
|
-
|
|
2085
|
+
o[M] = Ye(l, M, t), o[pe(M)] = Ye(h, pe(M), t);
|
|
2016
2086
|
} else if (d.length === 1) {
|
|
2017
2087
|
const [l] = d;
|
|
2018
2088
|
let h = l.handedness ?? "right";
|
|
2019
2089
|
if (l.score < i || l.handedness === void 0) {
|
|
2020
|
-
const
|
|
2021
|
-
|
|
2090
|
+
const u = (x) => a(x) ? ge(l.image[0], x.image[0]) : 1 / 0, p = u(s[h]);
|
|
2091
|
+
u(s[pe(h)]) < p && (h = pe(h));
|
|
2022
2092
|
}
|
|
2023
|
-
|
|
2093
|
+
o[h] = Ye(l, h, t);
|
|
2024
2094
|
}
|
|
2025
2095
|
for (const l of ["left", "right"]) {
|
|
2026
2096
|
const h = s[l];
|
|
2027
|
-
|
|
2097
|
+
o[l] || !h || t - h.timestampMs <= n && (o[l] = { ...h, held: !0 });
|
|
2028
2098
|
}
|
|
2029
|
-
return
|
|
2030
|
-
},
|
|
2099
|
+
return o;
|
|
2100
|
+
}, yi = (e, s) => {
|
|
2031
2101
|
const t = e == null ? void 0 : e.toLowerCase();
|
|
2032
2102
|
if (!(t !== "left" && t !== "right"))
|
|
2033
|
-
return
|
|
2034
|
-
},
|
|
2103
|
+
return di(t, s);
|
|
2104
|
+
}, wi = (e, s = { x: 0, y: 0, z: 0 }) => (s.x = e.x * 100, s.y = -e.y * 100, s.z = -e.z * 100, s), vi = 512, xi = Object.freeze({
|
|
2035
2105
|
minHandDetectionConfidence: 0.5,
|
|
2036
2106
|
minHandPresenceConfidence: 0.65,
|
|
2037
2107
|
minTrackingConfidence: 0.5
|
|
2038
2108
|
});
|
|
2039
|
-
class
|
|
2109
|
+
class Si extends se {
|
|
2040
2110
|
constructor() {
|
|
2041
2111
|
super();
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2112
|
+
m(this, "landmarker", null);
|
|
2113
|
+
m(this, "processingTime", null);
|
|
2114
|
+
m(this, "hands");
|
|
2115
|
+
m(this, "coordinates");
|
|
2116
|
+
m(this, "gesture");
|
|
2117
|
+
m(this, "handedness");
|
|
2118
|
+
m(this, "poses", { left: null, right: null });
|
|
2119
|
+
m(this, "sourceCanvas");
|
|
2120
|
+
m(this, "getSource");
|
|
2121
|
+
m(this, "downscaler", new we(vi));
|
|
2052
2122
|
}
|
|
2053
2123
|
async getHandData() {
|
|
2054
|
-
var
|
|
2124
|
+
var u, p, M;
|
|
2055
2125
|
if (!this.landmarker || !this.sourceCanvas)
|
|
2056
2126
|
return;
|
|
2057
2127
|
const t = this.downscaler.draw(this.sourceCanvas), n = performance.now(), i = this.landmarker.detectForVideo(t, n), r = performance.now();
|
|
2058
2128
|
this.processingTime = r - n, this.recordInference(n, r);
|
|
2059
|
-
const
|
|
2060
|
-
this.recordDetections(i.landmarks.length, ((
|
|
2129
|
+
const a = [], o = [], d = i.handedness ?? i.handednesses ?? [];
|
|
2130
|
+
this.recordDetections(i.landmarks.length, ((p = (u = d[0]) == null ? void 0 : u[0]) == null ? void 0 : p.score) ?? null);
|
|
2061
2131
|
const l = Se((M = this.getSource) == null ? void 0 : M.call(this));
|
|
2062
2132
|
if (i.landmarks.forEach((x, b) => {
|
|
2063
2133
|
var A, E;
|
|
2064
2134
|
if (!x || x.length === 0)
|
|
2065
2135
|
return;
|
|
2066
2136
|
const T = x.map(
|
|
2067
|
-
(B) =>
|
|
2137
|
+
(B) => me(B)
|
|
2068
2138
|
), R = (((A = i.worldLandmarks) == null ? void 0 : A[b]) ?? []).map(
|
|
2069
|
-
(B) =>
|
|
2070
|
-
),
|
|
2071
|
-
|
|
2139
|
+
(B) => wi(B)
|
|
2140
|
+
), w = (E = d[b]) == null ? void 0 : E[0], g = yi(w == null ? void 0 : w.categoryName, l), y = (w == null ? void 0 : w.score) ?? 0, v = x[0].z < 0 ? "closed_fist" : "open_palm";
|
|
2141
|
+
a.push({ coordinates: T, worldCoordinates: R, gesture: v, handedness: g, handednessScore: y }), o.push({
|
|
2072
2142
|
handedness: g,
|
|
2073
|
-
score:
|
|
2143
|
+
score: y,
|
|
2074
2144
|
world: R,
|
|
2075
2145
|
image: T
|
|
2076
2146
|
});
|
|
2077
|
-
}), this.poses =
|
|
2147
|
+
}), this.poses = pi(o, this.poses, n), !a.length)
|
|
2078
2148
|
return {
|
|
2079
2149
|
hands: void 0,
|
|
2080
2150
|
coordinates: void 0,
|
|
2081
2151
|
gesture: void 0,
|
|
2082
2152
|
handedness: void 0
|
|
2083
2153
|
};
|
|
2084
|
-
const h =
|
|
2154
|
+
const h = a[0];
|
|
2085
2155
|
return {
|
|
2086
|
-
hands:
|
|
2156
|
+
hands: a,
|
|
2087
2157
|
coordinates: h.coordinates,
|
|
2088
2158
|
gesture: h.gesture,
|
|
2089
2159
|
handedness: h.handedness
|
|
@@ -2113,20 +2183,20 @@ class gi extends se {
|
|
|
2113
2183
|
}
|
|
2114
2184
|
async initialize() {
|
|
2115
2185
|
const t = await $.forVisionTasks(
|
|
2116
|
-
new URL("/assets/xr/wasm",
|
|
2186
|
+
new URL("/assets/xr/wasm", q.assetStorageEndpoint).toString()
|
|
2117
2187
|
), [n] = await Promise.all([
|
|
2118
2188
|
ee(
|
|
2119
|
-
new URL("/assets/xr/models/hand_tracking.task",
|
|
2189
|
+
new URL("/assets/xr/models/hand_tracking.task", q.assetStorageEndpoint).toString()
|
|
2120
2190
|
),
|
|
2121
2191
|
te(t)
|
|
2122
|
-
]), i = await
|
|
2192
|
+
]), i = await zs.createFromOptions(t, {
|
|
2123
2193
|
baseOptions: {
|
|
2124
2194
|
modelAssetBuffer: n,
|
|
2125
2195
|
delegate: "GPU"
|
|
2126
2196
|
},
|
|
2127
2197
|
runningMode: "VIDEO",
|
|
2128
2198
|
numHands: 2,
|
|
2129
|
-
...
|
|
2199
|
+
...xi
|
|
2130
2200
|
});
|
|
2131
2201
|
this.landmarker = i;
|
|
2132
2202
|
}
|
|
@@ -2166,22 +2236,22 @@ class gi extends se {
|
|
|
2166
2236
|
};
|
|
2167
2237
|
}
|
|
2168
2238
|
}
|
|
2169
|
-
const
|
|
2239
|
+
const Mi = 24, bi = 720, ki = [
|
|
2170
2240
|
[255, 255, 255, 255],
|
|
2171
2241
|
// 0: the person → white
|
|
2172
2242
|
[0, 0, 0, 0]
|
|
2173
2243
|
// 1
|
|
2174
2244
|
];
|
|
2175
|
-
class
|
|
2245
|
+
class Ci extends se {
|
|
2176
2246
|
constructor() {
|
|
2177
2247
|
super();
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2248
|
+
m(this, "segmenter", null);
|
|
2249
|
+
m(this, "processingTime", null);
|
|
2250
|
+
m(this, "sourceCanvas");
|
|
2181
2251
|
// input source canvas
|
|
2182
|
-
|
|
2252
|
+
m(this, "processCanvas");
|
|
2183
2253
|
// downscaled canvas of sourceCanvas for processing
|
|
2184
|
-
|
|
2254
|
+
m(this, "filterCanvas");
|
|
2185
2255
|
// post-processing (blur) canvas
|
|
2186
2256
|
// Optional high-resolution input override. The shared session feed canvas is
|
|
2187
2257
|
// sized to the on-screen display layout (often a small, display-fit crop),
|
|
@@ -2189,36 +2259,36 @@ class vi extends se {
|
|
|
2189
2259
|
// body. When a consumer supplies a native-resolution source here (e.g. the raw
|
|
2190
2260
|
// <video>/<img>), the segmenter runs on THAT instead — letterboxed into the
|
|
2191
2261
|
// process canvas so nothing is cropped. Falls back to `sourceCanvas` when unset.
|
|
2192
|
-
|
|
2193
|
-
|
|
2262
|
+
m(this, "inputSource");
|
|
2263
|
+
m(this, "inputSourceSize");
|
|
2194
2264
|
// The segmenter's own WebGL2 context. DrawingUtils renders the inverted mask
|
|
2195
2265
|
// into this context on the GPU; we then blit that GL canvas straight into the
|
|
2196
2266
|
// mask canvas with a single `drawImage` — a GPU→GPU transfer, no CPU readback
|
|
2197
2267
|
// and no per-pixel JS loop. (A spike proved `drawImage(glCanvas)` reads the
|
|
2198
2268
|
// full DrawingUtils output correctly; the earlier "reads empty" wall that once
|
|
2199
2269
|
// forced a readPixels path was a false alarm.)
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2270
|
+
m(this, "glCanvas");
|
|
2271
|
+
m(this, "drawingUtils");
|
|
2272
|
+
m(this, "useGpuMaskPath", !1);
|
|
2203
2273
|
// CPU-fallback reused ImageData, allocated on size change only. Used ONLY when
|
|
2204
2274
|
// WebGL2 is unavailable and we must read the single-channel mask back by hand.
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2275
|
+
m(this, "maskImageData");
|
|
2276
|
+
m(this, "maskCanvas", null);
|
|
2277
|
+
m(this, "segmentationMaskTexture");
|
|
2278
|
+
m(this, "isMaskSetup", !1);
|
|
2279
|
+
m(this, "isProcessing", !1);
|
|
2210
2280
|
// Live clone of the most recent category mask, kept so getRawSegmentationData()
|
|
2211
2281
|
// can read the single-channel Uint8Array lazily — that readback is paid ONLY
|
|
2212
2282
|
// when a consumer actually asks for raw data. Cloned because the mask returned
|
|
2213
2283
|
// by segmentForVideo is invalidated on the next inference call.
|
|
2214
|
-
|
|
2284
|
+
m(this, "latestMask", null);
|
|
2215
2285
|
// Per-frame cache of the read-back array, so repeated getRawSegmentationData()
|
|
2216
2286
|
// calls within one frame don't re-run the GPU→CPU transfer.
|
|
2217
|
-
|
|
2287
|
+
m(this, "rawCache", null);
|
|
2218
2288
|
/** When the frame behind `latestMask` was segmented (`performance.now()`). */
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2289
|
+
m(this, "latestMaskTimeMs", 0);
|
|
2290
|
+
m(this, "quality", "medium");
|
|
2291
|
+
m(this, "stagingCanvas");
|
|
2222
2292
|
}
|
|
2223
2293
|
getQualityScaleFactor() {
|
|
2224
2294
|
switch (this.quality) {
|
|
@@ -2260,7 +2330,7 @@ class vi extends se {
|
|
|
2260
2330
|
const t = this.readIntrinsicSize(this.inputSource);
|
|
2261
2331
|
if (!t) return;
|
|
2262
2332
|
this.inputSourceSize = t;
|
|
2263
|
-
const n = Math.min(1,
|
|
2333
|
+
const n = Math.min(1, bi / Math.max(t.width, t.height)), i = Math.max(1, Math.round(t.width * n)), r = Math.max(1, Math.round(t.height * n));
|
|
2264
2334
|
this.processCanvas.width === i && this.processCanvas.height === r || (this.processCanvas.width = i, this.processCanvas.height = r, this.glCanvas && (this.glCanvas.width = i, this.glCanvas.height = r), this.maskImageData = void 0);
|
|
2265
2335
|
}
|
|
2266
2336
|
async processSegmentation() {
|
|
@@ -2283,25 +2353,25 @@ class vi extends se {
|
|
|
2283
2353
|
if (i) {
|
|
2284
2354
|
const d = this.processCanvas.width, l = this.processCanvas.height;
|
|
2285
2355
|
if (i.clearRect(0, 0, d, l), this.inputSource && this.inputSourceSize) {
|
|
2286
|
-
const { width: h, height:
|
|
2356
|
+
const { width: h, height: u } = this.inputSourceSize, p = Math.min(d / h, l / u), M = h * p, x = u * p;
|
|
2287
2357
|
i.drawImage(this.inputSource, (d - M) / 2, (l - x) / 2, M, x);
|
|
2288
2358
|
} else
|
|
2289
2359
|
i.drawImage(t, 0, 0, d, l);
|
|
2290
2360
|
}
|
|
2291
|
-
const r = performance.now(),
|
|
2292
|
-
if (!
|
|
2361
|
+
const r = performance.now(), o = this.segmenter.segmentForVideo(this.processCanvas, r).categoryMask;
|
|
2362
|
+
if (!o) {
|
|
2293
2363
|
if (this.disposed || this.paused) return;
|
|
2294
2364
|
this.rafId = requestAnimationFrame(this.processSegmentation.bind(this));
|
|
2295
2365
|
return;
|
|
2296
2366
|
}
|
|
2297
2367
|
if (this.rawCache = null, this.latestMaskTimeMs = r, this.latestMask && (this.latestMask.close(), this.latestMask = null), this.useGpuMaskPath && this.drawingUtils && this.glCanvas)
|
|
2298
|
-
this.drawingUtils.drawCategoryMask(
|
|
2368
|
+
this.drawingUtils.drawCategoryMask(o, ki), this.latestMask = o.clone(), o.close(), this.blitGlToMask();
|
|
2299
2369
|
else {
|
|
2300
|
-
this.latestMask =
|
|
2301
|
-
const d = this.readMaskToImageData(
|
|
2302
|
-
|
|
2370
|
+
this.latestMask = o.clone();
|
|
2371
|
+
const d = this.readMaskToImageData(o);
|
|
2372
|
+
o.close(), d && this.blitImageDataToMask(d);
|
|
2303
2373
|
}
|
|
2304
|
-
this.segmentationMaskTexture && (this.isMaskSetup || (this.segmentationMaskTexture.format =
|
|
2374
|
+
this.segmentationMaskTexture && (this.isMaskSetup || (this.segmentationMaskTexture.format = Bt, this.segmentationMaskTexture.minFilter = Ie, this.segmentationMaskTexture.magFilter = Ie, this.segmentationMaskTexture.generateMipmaps = !1, this.isMaskSetup = !0), this.segmentationMaskTexture.needsUpdate = !0), this.processingTime = performance.now() - n, this.recordInference(n), this.recordDetections(1, null), !(this.disposed || this.paused) && (this.rafId = requestAnimationFrame(this.processSegmentation.bind(this)));
|
|
2305
2375
|
}
|
|
2306
2376
|
/**
|
|
2307
2377
|
* Blit the GPU-rendered mask (already RGBA-inverted by drawCategoryMask)
|
|
@@ -2325,10 +2395,10 @@ class vi extends se {
|
|
|
2325
2395
|
const n = t.getAsUint8Array(), { width: i, height: r } = t;
|
|
2326
2396
|
if (!n || i <= 0 || r <= 0) return null;
|
|
2327
2397
|
(!this.maskImageData || this.maskImageData.width !== i || this.maskImageData.height !== r) && (this.maskImageData = new ImageData(i, r));
|
|
2328
|
-
const
|
|
2329
|
-
for (let
|
|
2330
|
-
const d = n[
|
|
2331
|
-
o
|
|
2398
|
+
const a = this.maskImageData.data;
|
|
2399
|
+
for (let o = 0; o < n.length; o += 1) {
|
|
2400
|
+
const d = n[o] === 255 ? 0 : 255;
|
|
2401
|
+
a[o * 4] = 255, a[o * 4 + 1] = d, a[o * 4 + 2] = 255, a[o * 4 + 3] = d;
|
|
2332
2402
|
}
|
|
2333
2403
|
return this.maskImageData;
|
|
2334
2404
|
}
|
|
@@ -2341,8 +2411,8 @@ class vi extends se {
|
|
|
2341
2411
|
if (!this.maskCanvas || !this.filterCanvas) return;
|
|
2342
2412
|
const n = this.maskCanvas.getContext("2d"), i = this.filterCanvas.getContext("2d");
|
|
2343
2413
|
if (!n || !i) return;
|
|
2344
|
-
const r = this.getStagingCanvas(t.width, t.height),
|
|
2345
|
-
|
|
2414
|
+
const r = this.getStagingCanvas(t.width, t.height), a = r.getContext("2d");
|
|
2415
|
+
a && (a.putImageData(t, 0, 0), i.filter = "blur(0.5px)", i.clearRect(0, 0, this.filterCanvas.width, this.filterCanvas.height), i.drawImage(r, 0, 0, this.filterCanvas.width, this.filterCanvas.height), n.clearRect(0, 0, this.maskCanvas.width, this.maskCanvas.height), n.drawImage(this.filterCanvas, 0, 0, this.maskCanvas.width, this.maskCanvas.height));
|
|
2346
2416
|
}
|
|
2347
2417
|
getStagingCanvas(t, n) {
|
|
2348
2418
|
return this.stagingCanvas || (this.stagingCanvas = document.createElement("canvas")), this.stagingCanvas.width !== t && (this.stagingCanvas.width = t), this.stagingCanvas.height !== n && (this.stagingCanvas.height = n), this.stagingCanvas;
|
|
@@ -2370,10 +2440,10 @@ class vi extends se {
|
|
|
2370
2440
|
async initialize(t) {
|
|
2371
2441
|
this.quality = (t == null ? void 0 : t.quality) ?? "low";
|
|
2372
2442
|
const n = await $.forVisionTasks(
|
|
2373
|
-
new URL("/assets/xr/wasm",
|
|
2443
|
+
new URL("/assets/xr/wasm", q.assetStorageEndpoint).toString()
|
|
2374
2444
|
), [i] = await Promise.all([
|
|
2375
2445
|
ee(
|
|
2376
|
-
new URL("/assets/xr/models/segmentation.tflite",
|
|
2446
|
+
new URL("/assets/xr/models/segmentation.tflite", q.assetStorageEndpoint).toString()
|
|
2377
2447
|
),
|
|
2378
2448
|
te(n)
|
|
2379
2449
|
]);
|
|
@@ -2381,7 +2451,7 @@ class vi extends se {
|
|
|
2381
2451
|
const r = this.glCanvas.getContext("webgl2", {
|
|
2382
2452
|
preserveDrawingBuffer: !0
|
|
2383
2453
|
});
|
|
2384
|
-
this.segmenter = await
|
|
2454
|
+
this.segmenter = await Nt.createFromOptions(n, {
|
|
2385
2455
|
baseOptions: {
|
|
2386
2456
|
modelAssetBuffer: i,
|
|
2387
2457
|
delegate: "GPU"
|
|
@@ -2390,7 +2460,7 @@ class vi extends se {
|
|
|
2390
2460
|
outputCategoryMask: !0,
|
|
2391
2461
|
outputConfidenceMasks: !1,
|
|
2392
2462
|
runningMode: "VIDEO"
|
|
2393
|
-
}), r ? (this.drawingUtils = new
|
|
2463
|
+
}), r ? (this.drawingUtils = new Ws(r), this.useGpuMaskPath = !0) : this.useGpuMaskPath = !1;
|
|
2394
2464
|
}
|
|
2395
2465
|
async run({
|
|
2396
2466
|
sourceCanvas: t,
|
|
@@ -2398,12 +2468,12 @@ class vi extends se {
|
|
|
2398
2468
|
renderHeight: i,
|
|
2399
2469
|
targetFps: r
|
|
2400
2470
|
}) {
|
|
2401
|
-
var
|
|
2471
|
+
var o;
|
|
2402
2472
|
if (!t)
|
|
2403
2473
|
return;
|
|
2404
|
-
this.setTargetFps(r ??
|
|
2405
|
-
const
|
|
2406
|
-
this.sourceCanvas = t, this.processCanvas = document.createElement("canvas"), this.processCanvas.width = t.width *
|
|
2474
|
+
this.setTargetFps(r ?? Mi), this.isProcessing = !1, this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
2475
|
+
const a = this.getQualityScaleFactor();
|
|
2476
|
+
this.sourceCanvas = t, this.processCanvas = document.createElement("canvas"), this.processCanvas.width = t.width * a, this.processCanvas.height = t.height * a, this.glCanvas && (this.glCanvas.width = this.processCanvas.width, this.glCanvas.height = this.processCanvas.height), this.maskImageData = void 0, this.maskCanvas = document.createElement("canvas"), this.maskCanvas.width = n, this.maskCanvas.height = i, this.filterCanvas = document.createElement("canvas"), this.filterCanvas.width = n, this.filterCanvas.height = i, (o = this.segmentationMaskTexture) == null || o.dispose(), this.segmentationMaskTexture = new Ht(this.maskCanvas), this.isMaskSetup = !1, this.rawCache = null, this.isProcessing = !0, this.lastInferenceMs = 0, this.rafId = requestAnimationFrame(this.processSegmentation.bind(this));
|
|
2407
2477
|
}
|
|
2408
2478
|
/**
|
|
2409
2479
|
* Lazily read the single-channel mask back to a Uint8Array. Only invoked when
|
|
@@ -2440,60 +2510,60 @@ class vi extends se {
|
|
|
2440
2510
|
};
|
|
2441
2511
|
}
|
|
2442
2512
|
}
|
|
2443
|
-
const
|
|
2513
|
+
const Ti = (e, s, t, n = "feed") => ({
|
|
2444
2514
|
width: Math.max(1, Math.round(e)),
|
|
2445
2515
|
height: Math.max(1, Math.round(s)),
|
|
2446
2516
|
indices: new Uint8Array(Math.max(1, Math.round(e)) * Math.max(1, Math.round(s))),
|
|
2447
2517
|
labels: t,
|
|
2448
2518
|
space: n,
|
|
2449
2519
|
version: 0
|
|
2450
|
-
}),
|
|
2520
|
+
}), ta = (e) => {
|
|
2451
2521
|
e.indices.fill(0);
|
|
2452
|
-
},
|
|
2453
|
-
const { width: n, height: i, indices: r } = e,
|
|
2454
|
-
if (
|
|
2455
|
-
let
|
|
2456
|
-
for (let
|
|
2457
|
-
const M = s[
|
|
2458
|
-
M <
|
|
2459
|
-
}
|
|
2460
|
-
const l = Math.max(0, Math.floor(
|
|
2461
|
-
for (let
|
|
2462
|
-
const M =
|
|
2463
|
-
|
|
2464
|
-
for (let b = 0; b <
|
|
2465
|
-
const T = s[b], R = s[(b + 1) %
|
|
2466
|
-
if (M <
|
|
2467
|
-
const
|
|
2468
|
-
|
|
2469
|
-
}
|
|
2470
|
-
|
|
2471
|
-
const x =
|
|
2472
|
-
for (let b = 0; b + 1 <
|
|
2473
|
-
const T = Math.max(0, Math.round(
|
|
2474
|
-
for (let
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
},
|
|
2522
|
+
}, sa = (e, s) => e.labels.indexOf(s), Ei = (e, s, t) => {
|
|
2523
|
+
const { width: n, height: i, indices: r } = e, a = s.length;
|
|
2524
|
+
if (a < 3) return;
|
|
2525
|
+
let o = 1 / 0, d = -1 / 0;
|
|
2526
|
+
for (let p = 0; p < a; p += 1) {
|
|
2527
|
+
const M = s[p].y * i;
|
|
2528
|
+
M < o && (o = M), M > d && (d = M);
|
|
2529
|
+
}
|
|
2530
|
+
const l = Math.max(0, Math.floor(o)), h = Math.min(i - 1, Math.ceil(d)), u = [];
|
|
2531
|
+
for (let p = l; p <= h; p += 1) {
|
|
2532
|
+
const M = p + 0.5;
|
|
2533
|
+
u.length = 0;
|
|
2534
|
+
for (let b = 0; b < a; b += 1) {
|
|
2535
|
+
const T = s[b], R = s[(b + 1) % a], w = T.y * i, g = R.y * i;
|
|
2536
|
+
if (M < w == M < g) continue;
|
|
2537
|
+
const y = (M - w) / (g - w);
|
|
2538
|
+
u.push((T.x + y * (R.x - T.x)) * n);
|
|
2539
|
+
}
|
|
2540
|
+
u.sort((b, T) => b - T);
|
|
2541
|
+
const x = p * n;
|
|
2542
|
+
for (let b = 0; b + 1 < u.length; b += 2) {
|
|
2543
|
+
const T = Math.max(0, Math.round(u[b])), R = Math.min(n, Math.round(u[b + 1]));
|
|
2544
|
+
for (let w = T; w < R; w += 1) r[x + w] = t;
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
}, na = (e, s, t, n, i = []) => {
|
|
2478
2548
|
i.length = 0;
|
|
2479
2549
|
for (let r = 0; r < t.length; r += 1) {
|
|
2480
|
-
const
|
|
2481
|
-
if (!
|
|
2482
|
-
i.push(
|
|
2550
|
+
const a = s[t[r]];
|
|
2551
|
+
if (!a) return;
|
|
2552
|
+
i.push(a);
|
|
2483
2553
|
}
|
|
2484
|
-
|
|
2485
|
-
},
|
|
2554
|
+
Ei(e, i, n);
|
|
2555
|
+
}, Qe = (e) => e, Pt = {
|
|
2486
2556
|
hair: {
|
|
2487
2557
|
labels: ["bg", "hair"],
|
|
2488
2558
|
assetPath: "/assets/xr/models/hair_segmenter.tflite",
|
|
2489
2559
|
defaultUrl: "https://storage.googleapis.com/mediapipe-models/image_segmenter/hair_segmenter/float32/latest/hair_segmenter.tflite",
|
|
2490
|
-
decode:
|
|
2560
|
+
decode: Qe
|
|
2491
2561
|
},
|
|
2492
2562
|
multiclass: {
|
|
2493
2563
|
labels: ["bg", "hair", "body_skin", "face_skin", "clothes", "others"],
|
|
2494
2564
|
assetPath: "/assets/xr/models/selfie_multiclass_256x256.tflite",
|
|
2495
2565
|
defaultUrl: "https://storage.googleapis.com/mediapipe-models/image_segmenter/selfie_multiclass_256x256/float32/latest/selfie_multiclass_256x256.tflite",
|
|
2496
|
-
decode:
|
|
2566
|
+
decode: Qe
|
|
2497
2567
|
},
|
|
2498
2568
|
// Fingernails: the MIT-licensed tiny U-Net from nngeek195/nail-segmentation-v1
|
|
2499
2569
|
// (Hugging Face), re-exported to TFLite float16 with the input normalisation
|
|
@@ -2504,27 +2574,27 @@ const xi = (e, s, t, n = "feed") => ({
|
|
|
2504
2574
|
labels: ["bg", "nail"],
|
|
2505
2575
|
assetPath: "/assets/xr/models/nail_segmenter_v1.tflite",
|
|
2506
2576
|
defaultUrl: "https://cdn.vincentt.studio/assets/xr/models/nail_segmenter_v1.tflite",
|
|
2507
|
-
decode:
|
|
2577
|
+
decode: Qe
|
|
2508
2578
|
}
|
|
2509
|
-
},
|
|
2579
|
+
}, Ri = (e, s, t) => {
|
|
2510
2580
|
const n = t.length === e.length ? t : new Uint8Array(e.length);
|
|
2511
2581
|
for (let i = 0; i < e.length; i += 1) n[i] = s(e[i]);
|
|
2512
2582
|
return n;
|
|
2513
|
-
},
|
|
2514
|
-
class
|
|
2583
|
+
}, Ai = 15, Ii = { low: 0.5, medium: 0.75, high: 1 };
|
|
2584
|
+
class Fi extends se {
|
|
2515
2585
|
constructor() {
|
|
2516
2586
|
super();
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2587
|
+
m(this, "segmenter", null);
|
|
2588
|
+
m(this, "preset", "hair");
|
|
2589
|
+
m(this, "quality", "medium");
|
|
2590
|
+
m(this, "status", "loading");
|
|
2591
|
+
m(this, "error", null);
|
|
2592
|
+
m(this, "processingTime", null);
|
|
2593
|
+
m(this, "sourceCanvas");
|
|
2594
|
+
m(this, "processCanvas");
|
|
2595
|
+
m(this, "isProcessing", !1);
|
|
2596
|
+
m(this, "mask", Ti(1, 1, ["bg"]));
|
|
2597
|
+
m(this, "node");
|
|
2528
2598
|
this.node = {
|
|
2529
2599
|
getMask: () => this.mask,
|
|
2530
2600
|
getStatus: () => this.status,
|
|
@@ -2533,17 +2603,17 @@ class Ci extends se {
|
|
|
2533
2603
|
}
|
|
2534
2604
|
async initialize(t) {
|
|
2535
2605
|
this.preset = (t == null ? void 0 : t.preset) ?? "hair", this.quality = (t == null ? void 0 : t.quality) ?? "medium";
|
|
2536
|
-
const n =
|
|
2606
|
+
const n = Pt[this.preset];
|
|
2537
2607
|
this.mask.labels = n.labels, this.status = "loading", this.error = null;
|
|
2538
2608
|
try {
|
|
2539
2609
|
const i = await $.forVisionTasks(
|
|
2540
|
-
new URL("/assets/xr/wasm",
|
|
2541
|
-
), r = (t == null ? void 0 : t.modelUrl) ?? n.defaultUrl, [
|
|
2610
|
+
new URL("/assets/xr/wasm", q.assetStorageEndpoint).toString()
|
|
2611
|
+
), r = (t == null ? void 0 : t.modelUrl) ?? n.defaultUrl, [a] = await Promise.all([
|
|
2542
2612
|
ee(r),
|
|
2543
2613
|
te(i)
|
|
2544
2614
|
]);
|
|
2545
|
-
this.segmenter = await
|
|
2546
|
-
baseOptions: { modelAssetBuffer:
|
|
2615
|
+
this.segmenter = await Nt.createFromOptions(i, {
|
|
2616
|
+
baseOptions: { modelAssetBuffer: a, delegate: "GPU" },
|
|
2547
2617
|
outputCategoryMask: !0,
|
|
2548
2618
|
outputConfidenceMasks: !1,
|
|
2549
2619
|
runningMode: "VIDEO"
|
|
@@ -2553,7 +2623,7 @@ class Ci extends se {
|
|
|
2553
2623
|
}
|
|
2554
2624
|
}
|
|
2555
2625
|
async run({ sourceCanvas: t, targetFps: n }) {
|
|
2556
|
-
t && (this.setTargetFps(n ??
|
|
2626
|
+
t && (this.setTargetFps(n ?? Ai), this.isProcessing = !1, this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.sourceCanvas = t, this.processCanvas = document.createElement("canvas"), this.isProcessing = !0, this.lastInferenceMs = 0, this.rafId = requestAnimationFrame(this.process.bind(this)));
|
|
2557
2627
|
}
|
|
2558
2628
|
process() {
|
|
2559
2629
|
if (this.disposed || this.paused || !this.isProcessing) return;
|
|
@@ -2562,21 +2632,21 @@ class Ci extends se {
|
|
|
2562
2632
|
this.rafId = requestAnimationFrame(this.process.bind(this));
|
|
2563
2633
|
return;
|
|
2564
2634
|
}
|
|
2565
|
-
const r = performance.now(),
|
|
2566
|
-
(i.width !==
|
|
2635
|
+
const r = performance.now(), a = Ii[this.quality], o = Math.max(1, Math.round(n.width * a)), d = Math.max(1, Math.round(n.height * a));
|
|
2636
|
+
(i.width !== o || i.height !== d) && (i.width = o, i.height = d);
|
|
2567
2637
|
const l = i.getContext("2d");
|
|
2568
|
-
l && l.drawImage(n, 0, 0,
|
|
2638
|
+
l && l.drawImage(n, 0, 0, o, d);
|
|
2569
2639
|
try {
|
|
2570
|
-
const
|
|
2571
|
-
if (
|
|
2572
|
-
const
|
|
2573
|
-
(this.mask.width !==
|
|
2574
|
-
|
|
2575
|
-
|
|
2640
|
+
const u = t.segmentForVideo(i, performance.now()).categoryMask;
|
|
2641
|
+
if (u) {
|
|
2642
|
+
const p = u.getAsUint8Array();
|
|
2643
|
+
(this.mask.width !== u.width || this.mask.height !== u.height) && (this.mask.width = u.width, this.mask.height = u.height), this.mask.indices = Ri(
|
|
2644
|
+
p,
|
|
2645
|
+
Pt[this.preset].decode,
|
|
2576
2646
|
this.mask.indices
|
|
2577
|
-
), this.mask.version += 1, this.mask.timestampMs = r,
|
|
2647
|
+
), this.mask.version += 1, this.mask.timestampMs = r, u.close();
|
|
2578
2648
|
}
|
|
2579
|
-
this.status === "error" && (this.status = "ready", this.error = null), this.recordInferenceError(null), this.recordDetections(
|
|
2649
|
+
this.status === "error" && (this.status = "ready", this.error = null), this.recordInferenceError(null), this.recordDetections(u ? 1 : 0, null);
|
|
2580
2650
|
} catch (h) {
|
|
2581
2651
|
this.status = "error", this.error = h instanceof Error ? h : new Error(String(h)), this.recordInferenceError(this.error);
|
|
2582
2652
|
}
|
|
@@ -2601,15 +2671,15 @@ class Ci extends se {
|
|
|
2601
2671
|
this.segmenter = null, this.sourceCanvas = void 0, this.processCanvas = void 0;
|
|
2602
2672
|
}
|
|
2603
2673
|
}
|
|
2604
|
-
const
|
|
2605
|
-
[
|
|
2606
|
-
[
|
|
2607
|
-
[
|
|
2608
|
-
[
|
|
2609
|
-
[
|
|
2610
|
-
[
|
|
2611
|
-
[
|
|
2612
|
-
},
|
|
2674
|
+
const _t = {
|
|
2675
|
+
[P.BACKGROUND_SEGMENTATION]: Ci,
|
|
2676
|
+
[P.SEMANTIC_SEGMENTATION]: Fi,
|
|
2677
|
+
[P.HAND_TRACKER]: Si,
|
|
2678
|
+
[P.GESTURE_TRACKER]: oi,
|
|
2679
|
+
[P.FACE_TRACKER]: si,
|
|
2680
|
+
[P.BODY_TRACKER]: Yn,
|
|
2681
|
+
[P.HOLISTIC_TRACKER]: ci
|
|
2682
|
+
}, Pi = async (e) => {
|
|
2613
2683
|
const s = document.createElement("video");
|
|
2614
2684
|
s.srcObject = e, s.muted = !0, s.playsInline = !0, s.autoplay = !0, await new Promise((n) => {
|
|
2615
2685
|
s.onloadedmetadata = () => {
|
|
@@ -2623,20 +2693,20 @@ const It = {
|
|
|
2623
2693
|
};
|
|
2624
2694
|
typeof t.requestVideoFrameCallback == "function" ? t.requestVideoFrameCallback(r) : requestAnimationFrame(() => requestAnimationFrame(() => r()));
|
|
2625
2695
|
}), s;
|
|
2626
|
-
},
|
|
2627
|
-
const s = new
|
|
2628
|
-
return s.colorSpace =
|
|
2629
|
-
},
|
|
2696
|
+
}, _i = (e) => {
|
|
2697
|
+
const s = new Ht(e);
|
|
2698
|
+
return s.colorSpace = Xs, s.format = Bt, s.minFilter = Ie, s.magFilter = Ie, s.generateMipmaps = !1, s.needsUpdate = !0, s;
|
|
2699
|
+
}, Di = (e, s) => {
|
|
2630
2700
|
const t = e.videoWidth, n = e.videoHeight;
|
|
2631
2701
|
t > 0 && n > 0 && (s.width !== t && (s.width = t), s.height !== n && (s.height = n));
|
|
2632
2702
|
const i = s.getContext("2d", {
|
|
2633
2703
|
colorSpace: "srgb"
|
|
2634
2704
|
});
|
|
2635
2705
|
i.save(), i.scale(-1, 1), i.drawImage(e, -s.width, 0, s.width, s.height), i.restore();
|
|
2636
|
-
},
|
|
2706
|
+
}, Oi = (e, s, t = 1) => {
|
|
2637
2707
|
const n = s.getContext("2d", {
|
|
2638
2708
|
colorSpace: "srgb"
|
|
2639
|
-
}), i =
|
|
2709
|
+
}), i = vn({
|
|
2640
2710
|
source: { width: e.width, height: e.height },
|
|
2641
2711
|
feed: { width: s.width, height: s.height },
|
|
2642
2712
|
zoom: t
|
|
@@ -2652,95 +2722,95 @@ const It = {
|
|
|
2652
2722
|
i.drawWidth,
|
|
2653
2723
|
i.drawHeight
|
|
2654
2724
|
));
|
|
2655
|
-
},
|
|
2725
|
+
}, Li = (e, s, t) => {
|
|
2656
2726
|
const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakSet();
|
|
2657
2727
|
let r = !1;
|
|
2658
|
-
const
|
|
2659
|
-
const
|
|
2660
|
-
if (g === null && !
|
|
2661
|
-
const v = new Map(
|
|
2662
|
-
g === null ? v.delete(
|
|
2663
|
-
},
|
|
2664
|
-
var
|
|
2728
|
+
const a = (w, g) => {
|
|
2729
|
+
const y = e.getSnapshot().modelErrors;
|
|
2730
|
+
if (g === null && !y.has(w)) return;
|
|
2731
|
+
const v = new Map(y);
|
|
2732
|
+
g === null ? v.delete(w) : v.set(w, { model: w, error: g, at: performance.now() }), e.set({ modelErrors: v });
|
|
2733
|
+
}, o = (w, g) => {
|
|
2734
|
+
var y;
|
|
2665
2735
|
try {
|
|
2666
|
-
(
|
|
2736
|
+
(y = g.dispose) == null || y.call(g);
|
|
2667
2737
|
} catch (v) {
|
|
2668
|
-
console.warn(`[xr-sdk registry] dispose threw for ${
|
|
2738
|
+
console.warn(`[xr-sdk registry] dispose threw for ${w}`, v);
|
|
2669
2739
|
}
|
|
2670
2740
|
};
|
|
2671
2741
|
return {
|
|
2672
|
-
acquire: async (
|
|
2673
|
-
let v = n.get(
|
|
2742
|
+
acquire: async (w, g, y) => {
|
|
2743
|
+
let v = n.get(w);
|
|
2674
2744
|
if (v)
|
|
2675
2745
|
return v.refs.add(g), v.activeRefs.add(g), v.initPromise;
|
|
2676
|
-
const A = s[
|
|
2746
|
+
const A = s[w];
|
|
2677
2747
|
if (!A)
|
|
2678
|
-
throw new Error(`Invalid model: ${
|
|
2748
|
+
throw new Error(`Invalid model: ${w}`);
|
|
2679
2749
|
const E = new A(), B = /* @__PURE__ */ new Set([g]), K = /* @__PURE__ */ new Set([g]);
|
|
2680
|
-
|
|
2681
|
-
const
|
|
2682
|
-
await E.initialize(
|
|
2683
|
-
const
|
|
2684
|
-
if (!
|
|
2685
|
-
return
|
|
2686
|
-
t && await t(
|
|
2687
|
-
const G = n.get(
|
|
2688
|
-
return G && G.refs.size > 0 && (i.add(E), e.setPipeline((X) => X.set(
|
|
2750
|
+
a(w, null);
|
|
2751
|
+
const L = (async () => {
|
|
2752
|
+
await E.initialize(y);
|
|
2753
|
+
const F = n.get(w);
|
|
2754
|
+
if (!F || F.model !== E || F.refs.size === 0)
|
|
2755
|
+
return o(w, E), E;
|
|
2756
|
+
t && await t(w, E);
|
|
2757
|
+
const G = n.get(w);
|
|
2758
|
+
return G && G.refs.size > 0 && (i.add(E), e.setPipeline((X) => X.set(w, E))), E;
|
|
2689
2759
|
})();
|
|
2690
|
-
return v = { model: E, refs: B, activeRefs: K, initPromise:
|
|
2691
|
-
n.get(
|
|
2692
|
-
}),
|
|
2760
|
+
return v = { model: E, refs: B, activeRefs: K, initPromise: L, options: y }, n.set(w, v), L.catch((F) => {
|
|
2761
|
+
n.get(w) === v && (n.delete(w), e.setPipeline((X) => X.delete(w)), a(w, F instanceof Error ? F : new Error(String(F)))), o(w, E);
|
|
2762
|
+
}), L;
|
|
2693
2763
|
},
|
|
2694
|
-
release: (
|
|
2695
|
-
const
|
|
2696
|
-
|
|
2764
|
+
release: (w, g) => {
|
|
2765
|
+
const y = n.get(w);
|
|
2766
|
+
y && (y.refs.delete(g), y.activeRefs.delete(g) && y.refs.size > 0 && y.activeRefs.size === 0 && y.model.pause(), !(y.refs.size > 0) && (n.delete(w), o(w, y.model), e.setPipeline((v) => v.delete(w))));
|
|
2697
2767
|
},
|
|
2698
|
-
setActive: (
|
|
2699
|
-
const v = n.get(
|
|
2768
|
+
setActive: (w, g, y) => {
|
|
2769
|
+
const v = n.get(w);
|
|
2700
2770
|
if (!v || !v.refs.has(g)) return;
|
|
2701
2771
|
const A = v.activeRefs.size > 0;
|
|
2702
|
-
|
|
2772
|
+
y ? v.activeRefs.add(g) : v.activeRefs.delete(g);
|
|
2703
2773
|
const E = v.activeRefs.size > 0;
|
|
2704
2774
|
A !== E && (E && !r ? v.model.resume() : v.model.pause());
|
|
2705
2775
|
},
|
|
2706
2776
|
suspendAll: () => {
|
|
2707
2777
|
r = !0;
|
|
2708
|
-
for (const
|
|
2709
|
-
|
|
2778
|
+
for (const w of n.values())
|
|
2779
|
+
w.model.pause();
|
|
2710
2780
|
},
|
|
2711
2781
|
resumeActive: () => {
|
|
2712
2782
|
r = !1;
|
|
2713
|
-
for (const
|
|
2714
|
-
|
|
2783
|
+
for (const w of n.values())
|
|
2784
|
+
w.activeRefs.size > 0 && w.model.resume();
|
|
2715
2785
|
},
|
|
2716
|
-
get: (
|
|
2786
|
+
get: (w) => {
|
|
2717
2787
|
var g;
|
|
2718
|
-
return (g = n.get(
|
|
2788
|
+
return (g = n.get(w)) == null ? void 0 : g.model;
|
|
2719
2789
|
},
|
|
2720
|
-
getOptions: (
|
|
2790
|
+
getOptions: (w) => {
|
|
2721
2791
|
var g;
|
|
2722
|
-
return (g = n.get(
|
|
2792
|
+
return (g = n.get(w)) == null ? void 0 : g.options;
|
|
2723
2793
|
},
|
|
2724
2794
|
releaseAll: () => {
|
|
2725
|
-
for (const
|
|
2726
|
-
const g = n.get(
|
|
2727
|
-
g && (g.refs.clear(), n.delete(
|
|
2795
|
+
for (const w of Array.from(n.keys())) {
|
|
2796
|
+
const g = n.get(w);
|
|
2797
|
+
g && (g.refs.clear(), n.delete(w), o(w, g.model));
|
|
2728
2798
|
}
|
|
2729
|
-
e.setPipeline((
|
|
2799
|
+
e.setPipeline((w) => w.clear());
|
|
2730
2800
|
},
|
|
2731
|
-
getState: (
|
|
2732
|
-
const g = n.get(
|
|
2733
|
-
return g ? i.has(g.model) ? "ready" : "initializing" : e.getSnapshot().modelErrors.has(
|
|
2801
|
+
getState: (w) => {
|
|
2802
|
+
const g = n.get(w);
|
|
2803
|
+
return g ? i.has(g.model) ? "ready" : "initializing" : e.getSnapshot().modelErrors.has(w) ? "error" : "idle";
|
|
2734
2804
|
},
|
|
2735
|
-
getOwners: (
|
|
2736
|
-
const g = n.get(
|
|
2805
|
+
getOwners: (w) => {
|
|
2806
|
+
const g = n.get(w);
|
|
2737
2807
|
return {
|
|
2738
2808
|
refs: g ? Array.from(g.refs) : [],
|
|
2739
2809
|
active: g ? Array.from(g.activeRefs) : []
|
|
2740
2810
|
};
|
|
2741
2811
|
}
|
|
2742
2812
|
};
|
|
2743
|
-
},
|
|
2813
|
+
}, Ni = {
|
|
2744
2814
|
lifecycle: "idle",
|
|
2745
2815
|
ready: !1,
|
|
2746
2816
|
error: void 0,
|
|
@@ -2762,8 +2832,8 @@ const It = {
|
|
|
2762
2832
|
cameraPermission: "unknown",
|
|
2763
2833
|
cameraPermissionReason: null,
|
|
2764
2834
|
feedFrames: 0
|
|
2765
|
-
},
|
|
2766
|
-
let e = { ...
|
|
2835
|
+
}, Bi = () => {
|
|
2836
|
+
let e = { ...Ni, pipeline: /* @__PURE__ */ new Map(), modelErrors: /* @__PURE__ */ new Map() };
|
|
2767
2837
|
const s = /* @__PURE__ */ new Set(), t = () => {
|
|
2768
2838
|
s.forEach((n) => n());
|
|
2769
2839
|
};
|
|
@@ -2786,7 +2856,7 @@ const It = {
|
|
|
2786
2856
|
s.delete(n);
|
|
2787
2857
|
})
|
|
2788
2858
|
};
|
|
2789
|
-
},
|
|
2859
|
+
}, Dt = (e, s) => s ?? e === "user", Hi = ({
|
|
2790
2860
|
renderHeight: e,
|
|
2791
2861
|
renderWidth: s,
|
|
2792
2862
|
videoHeight: t,
|
|
@@ -2794,48 +2864,48 @@ const It = {
|
|
|
2794
2864
|
}) => ({
|
|
2795
2865
|
height: e || t,
|
|
2796
2866
|
width: s || n
|
|
2797
|
-
}),
|
|
2798
|
-
const t = new
|
|
2867
|
+
}), Ui = (e, s) => {
|
|
2868
|
+
const t = new Sn({ verbose: !0 }), n = Bi();
|
|
2799
2869
|
n.set({ cameraZoom: (e == null ? void 0 : e.cameraZoom) ?? 1.2 });
|
|
2800
2870
|
let i = s, r = e;
|
|
2801
|
-
const
|
|
2871
|
+
const a = (c) => {
|
|
2802
2872
|
var S;
|
|
2803
|
-
const f = (S =
|
|
2873
|
+
const f = (S = V.getOptions(c)) == null ? void 0 : S.targetFps;
|
|
2804
2874
|
return typeof f == "number" ? f : r == null ? void 0 : r.targetFps;
|
|
2805
2875
|
};
|
|
2806
|
-
let
|
|
2807
|
-
const X = /* @__PURE__ */ new Set(),
|
|
2876
|
+
let o, d, l, h, u, p, M, x, b, T, R, w, g = !1, y = !1, v = !1, A = 0, E, B, K, L = !1, F = 0, G = /* @__PURE__ */ new WeakSet();
|
|
2877
|
+
const X = /* @__PURE__ */ new Set(), be = (c) => {
|
|
2808
2878
|
const f = n.getSnapshot().cameraTexture;
|
|
2809
2879
|
f && f.dispose();
|
|
2810
|
-
const S =
|
|
2880
|
+
const S = _i(c);
|
|
2811
2881
|
return n.set({ cameraTexture: S }), S;
|
|
2812
|
-
},
|
|
2813
|
-
if (G.has(f) || n.getSnapshot().lifecycle !== "running" || !
|
|
2882
|
+
}, Pe = async (c, f) => {
|
|
2883
|
+
if (G.has(f) || n.getSnapshot().lifecycle !== "running" || !u) return;
|
|
2814
2884
|
G.add(f);
|
|
2815
|
-
const S =
|
|
2885
|
+
const S = F;
|
|
2816
2886
|
try {
|
|
2817
2887
|
await f.run({
|
|
2818
|
-
sourceCanvas:
|
|
2888
|
+
sourceCanvas: u,
|
|
2819
2889
|
renderWidth: n.getSnapshot().renderWidth,
|
|
2820
2890
|
renderHeight: n.getSnapshot().renderHeight,
|
|
2821
2891
|
getSource: () => n.getSnapshot().sourceKind,
|
|
2822
|
-
targetFps:
|
|
2892
|
+
targetFps: a(c),
|
|
2823
2893
|
analysisScale: r == null ? void 0 : r.analysisScale
|
|
2824
|
-
}),
|
|
2894
|
+
}), L && (await new Promise((k) => requestAnimationFrame(() => k())), await new Promise((k) => requestAnimationFrame(() => k())), L && F === S && V.suspendAll());
|
|
2825
2895
|
} catch (k) {
|
|
2826
2896
|
throw G.delete(f), k;
|
|
2827
2897
|
}
|
|
2828
|
-
},
|
|
2898
|
+
}, V = Li(n, _t, (c, f) => Pe(c, f));
|
|
2829
2899
|
n.subscribe(() => {
|
|
2830
2900
|
if (n.getSnapshot().lifecycle !== "running") return;
|
|
2831
2901
|
const c = n.getSnapshot().pipeline;
|
|
2832
2902
|
for (const [f, S] of c.entries())
|
|
2833
|
-
G.has(S) ||
|
|
2903
|
+
G.has(S) || Pe(f, S);
|
|
2834
2904
|
});
|
|
2835
|
-
const
|
|
2836
|
-
|
|
2905
|
+
const rt = () => {
|
|
2906
|
+
w !== void 0 && (cancelAnimationFrame(w), w = void 0);
|
|
2837
2907
|
}, ne = () => {
|
|
2838
|
-
if (
|
|
2908
|
+
if (rt(), E == null || E(), E = void 0, d) {
|
|
2839
2909
|
try {
|
|
2840
2910
|
d.pause();
|
|
2841
2911
|
} catch {
|
|
@@ -2853,34 +2923,34 @@ const It = {
|
|
|
2853
2923
|
}
|
|
2854
2924
|
l = void 0;
|
|
2855
2925
|
}
|
|
2856
|
-
},
|
|
2857
|
-
if (g || !d || !h || !
|
|
2926
|
+
}, _e = () => {
|
|
2927
|
+
if (g || !d || !h || !u) return;
|
|
2858
2928
|
const c = typeof window < "u" ? window.__xr_debugger_metrics : void 0;
|
|
2859
2929
|
if (c != null && c.trackCameraFrame && c.trackCameraFrame(), Se(n.getSnapshot().sourceKind))
|
|
2860
|
-
|
|
2930
|
+
Di(d, h);
|
|
2861
2931
|
else {
|
|
2862
2932
|
const C = h.getContext("2d");
|
|
2863
2933
|
if (!C) return;
|
|
2864
|
-
const D = d.videoWidth,
|
|
2865
|
-
h.width !== D && (h.width = D), h.height !==
|
|
2934
|
+
const D = d.videoWidth, N = d.videoHeight;
|
|
2935
|
+
h.width !== D && (h.width = D), h.height !== N && (h.height = N), C.setTransform(1, 0, 0, 1, 0, 0), C.clearRect(0, 0, D, N), C.drawImage(d, 0, 0, D, N);
|
|
2866
2936
|
}
|
|
2867
|
-
|
|
2937
|
+
Oi(h, u, (r == null ? void 0 : r.cameraZoom) ?? 1.2);
|
|
2868
2938
|
const S = n.getSnapshot();
|
|
2869
2939
|
(S.sourceWidth !== d.videoWidth || S.sourceHeight !== d.videoHeight) && n.set({ sourceWidth: d.videoWidth, sourceHeight: d.videoHeight }), A += 1, A % 10 === 0 && n.set({ feedFrames: A });
|
|
2870
2940
|
const k = n.getSnapshot().cameraTexture;
|
|
2871
2941
|
k && (k.needsUpdate = !0);
|
|
2872
|
-
},
|
|
2873
|
-
if (!d || !h || !
|
|
2874
|
-
if (
|
|
2875
|
-
|
|
2942
|
+
}, De = () => {
|
|
2943
|
+
if (!d || !h || !u) return;
|
|
2944
|
+
if (L) {
|
|
2945
|
+
_e();
|
|
2876
2946
|
return;
|
|
2877
2947
|
}
|
|
2878
2948
|
const c = () => {
|
|
2879
|
-
|
|
2949
|
+
w = requestAnimationFrame(c), _e();
|
|
2880
2950
|
};
|
|
2881
|
-
|
|
2882
|
-
},
|
|
2883
|
-
if (c.source ===
|
|
2951
|
+
w = requestAnimationFrame(c);
|
|
2952
|
+
}, is = async (c, f) => {
|
|
2953
|
+
if (c.source === I.WEBCAM)
|
|
2884
2954
|
try {
|
|
2885
2955
|
const S = r != null && r.camRes && r.camRes > 0 ? r.camRes : 960;
|
|
2886
2956
|
n.set({ cameraPermission: "requesting", cameraPermissionReason: null });
|
|
@@ -2892,36 +2962,36 @@ const It = {
|
|
|
2892
2962
|
let D;
|
|
2893
2963
|
try {
|
|
2894
2964
|
D = await navigator.mediaDevices.getUserMedia({ video: C });
|
|
2895
|
-
} catch (
|
|
2896
|
-
if (!(
|
|
2965
|
+
} catch (N) {
|
|
2966
|
+
if (!(N instanceof DOMException && N.name === "OverconstrainedError")) throw N;
|
|
2897
2967
|
D = await navigator.mediaDevices.getUserMedia({
|
|
2898
2968
|
video: { frameRate: { ideal: 30 }, width: { ideal: S }, ...k }
|
|
2899
2969
|
});
|
|
2900
2970
|
}
|
|
2901
|
-
return f ===
|
|
2971
|
+
return f === F && n.set({ cameraPermission: "granted", cameraPermissionReason: null }), D;
|
|
2902
2972
|
} catch (S) {
|
|
2903
|
-
const k =
|
|
2904
|
-
throw f ===
|
|
2973
|
+
const k = Vt(S), C = kt[k], D = await Kt(), N = Gt(k, D.state);
|
|
2974
|
+
throw f === F && n.set({
|
|
2905
2975
|
error: { error: "PermissionError", message: C, reason: k },
|
|
2906
|
-
cameraPermission:
|
|
2907
|
-
cameraPermissionReason:
|
|
2908
|
-
}), new
|
|
2976
|
+
cameraPermission: N.state,
|
|
2977
|
+
cameraPermissionReason: N.reason
|
|
2978
|
+
}), new O(S instanceof Error ? S.message : "getUserMedia failed");
|
|
2909
2979
|
}
|
|
2910
2980
|
return c.stream;
|
|
2911
|
-
},
|
|
2981
|
+
}, at = (c) => {
|
|
2912
2982
|
const { lifecycle: f } = n.getSnapshot();
|
|
2913
|
-
f === "idle" || f === "stopped" || g || (ne(),
|
|
2983
|
+
f === "idle" || f === "stopped" || g || (ne(), V.suspendAll(), F += 1, o = void 0, n.set({
|
|
2914
2984
|
lifecycle: "stopped",
|
|
2915
2985
|
ready: !1,
|
|
2916
|
-
error: { error: "PermissionError", message:
|
|
2986
|
+
error: { error: "PermissionError", message: kt[c], reason: c },
|
|
2917
2987
|
cameraPermission: c === "permission-denied" ? "blocked" : "unavailable",
|
|
2918
|
-
cameraPermissionReason:
|
|
2988
|
+
cameraPermissionReason: qt(c)
|
|
2919
2989
|
}), t.log("XR session stopped: camera lost.", c));
|
|
2920
|
-
},
|
|
2990
|
+
}, rs = (c) => {
|
|
2921
2991
|
var k;
|
|
2922
2992
|
E == null || E();
|
|
2923
2993
|
const f = ((k = c.getVideoTracks) == null ? void 0 : k.call(c)) ?? [], S = () => {
|
|
2924
|
-
l === c &&
|
|
2994
|
+
l === c && at("camera-lost");
|
|
2925
2995
|
};
|
|
2926
2996
|
f.forEach((C) => {
|
|
2927
2997
|
var D;
|
|
@@ -2932,122 +3002,122 @@ const It = {
|
|
|
2932
3002
|
return (D = C.removeEventListener) == null ? void 0 : D.call(C, "ended", S);
|
|
2933
3003
|
});
|
|
2934
3004
|
};
|
|
2935
|
-
},
|
|
3005
|
+
}, as = async () => {
|
|
2936
3006
|
if (B || typeof navigator > "u") return;
|
|
2937
3007
|
const c = navigator.permissions;
|
|
2938
3008
|
if (c != null && c.query)
|
|
2939
3009
|
try {
|
|
2940
3010
|
const f = await c.query({ name: "camera" });
|
|
2941
|
-
if (
|
|
3011
|
+
if (y) return;
|
|
2942
3012
|
B = f, K = () => {
|
|
2943
|
-
f.state === "denied" && (
|
|
3013
|
+
f.state === "denied" && (o == null ? void 0 : o.source) === I.WEBCAM && at("permission-denied");
|
|
2944
3014
|
}, f.addEventListener("change", K);
|
|
2945
3015
|
} catch {
|
|
2946
3016
|
}
|
|
2947
|
-
},
|
|
3017
|
+
}, os = () => {
|
|
2948
3018
|
var c;
|
|
2949
3019
|
B && K && ((c = B.removeEventListener) == null || c.call(B, "change", K)), B = void 0, K = void 0;
|
|
2950
|
-
},
|
|
2951
|
-
var
|
|
2952
|
-
const f =
|
|
2953
|
-
if (f !==
|
|
2954
|
-
throw S.getTracks().forEach((oe) => oe.stop()), new
|
|
2955
|
-
l = S,
|
|
2956
|
-
const k = await
|
|
2957
|
-
if (f !==
|
|
2958
|
-
throw S.getTracks().forEach((oe) => oe.stop()), new
|
|
3020
|
+
}, Oe = async (c) => {
|
|
3021
|
+
var yt, ke, wt;
|
|
3022
|
+
const f = F, S = await is(c, f);
|
|
3023
|
+
if (f !== F)
|
|
3024
|
+
throw S.getTracks().forEach((oe) => oe.stop()), new O("Media source superseded by a newer bind");
|
|
3025
|
+
l = S, rs(S);
|
|
3026
|
+
const k = await Pi(S);
|
|
3027
|
+
if (f !== F || y)
|
|
3028
|
+
throw S.getTracks().forEach((oe) => oe.stop()), new O("Media source superseded by a newer bind");
|
|
2959
3029
|
d = k, h = new OffscreenCanvas(k.videoWidth, k.videoHeight);
|
|
2960
|
-
const { renderWidth: C, renderHeight: D } = n.getSnapshot(),
|
|
3030
|
+
const { renderWidth: C, renderHeight: D } = n.getSnapshot(), N = Hi({
|
|
2961
3031
|
renderWidth: C,
|
|
2962
3032
|
renderHeight: D,
|
|
2963
3033
|
videoWidth: k.videoWidth,
|
|
2964
3034
|
videoHeight: k.videoHeight
|
|
2965
3035
|
});
|
|
2966
|
-
|
|
2967
|
-
const
|
|
2968
|
-
|
|
2969
|
-
const ae = (
|
|
2970
|
-
if (c.source ===
|
|
2971
|
-
const oe =
|
|
2972
|
-
|
|
2973
|
-
source:
|
|
2974
|
-
sourceKind:
|
|
3036
|
+
u ? (u.width !== N.width || u.height !== N.height) && (u.width = N.width, u.height = N.height, be(u)) : (u = new OffscreenCanvas(N.width, N.height), be(u));
|
|
3037
|
+
const pt = c.source === I.STREAM ? c.static === !0 : !1;
|
|
3038
|
+
L = pt;
|
|
3039
|
+
const ae = (wt = (ke = (yt = S.getVideoTracks) == null ? void 0 : yt.call(S)[0]) == null ? void 0 : ke.getSettings) == null ? void 0 : wt.call(ke), Ue = ae == null ? void 0 : ae.facingMode, Fs = Ue === "user" || Ue === "environment" ? Ue : null;
|
|
3040
|
+
if (c.source === I.WEBCAM) {
|
|
3041
|
+
const oe = Fs ?? c.facingMode ?? "user", vt = Dt(oe, c.mirrored);
|
|
3042
|
+
o = {
|
|
3043
|
+
source: I.WEBCAM,
|
|
3044
|
+
sourceKind: vt ? "webcam" : "rear-camera",
|
|
2975
3045
|
facingMode: oe,
|
|
2976
3046
|
deviceId: c.deviceId,
|
|
2977
|
-
mirrored:
|
|
3047
|
+
mirrored: vt
|
|
2978
3048
|
};
|
|
2979
3049
|
} else
|
|
2980
|
-
|
|
2981
|
-
source:
|
|
3050
|
+
o = {
|
|
3051
|
+
source: I.STREAM,
|
|
2982
3052
|
stream: c.stream,
|
|
2983
|
-
static:
|
|
3053
|
+
static: pt,
|
|
2984
3054
|
sourceKind: c.sourceKind ?? "webcam"
|
|
2985
3055
|
};
|
|
2986
3056
|
n.set({
|
|
2987
3057
|
source: c.source,
|
|
2988
|
-
sourceKind:
|
|
2989
|
-
cameraFacing:
|
|
2990
|
-
cameraDeviceId:
|
|
3058
|
+
sourceKind: o.sourceKind,
|
|
3059
|
+
cameraFacing: o.source === I.WEBCAM ? o.facingMode : null,
|
|
3060
|
+
cameraDeviceId: o.source === I.WEBCAM ? (ae == null ? void 0 : ae.deviceId) ?? o.deviceId ?? null : null,
|
|
2991
3061
|
sourceWidth: k.videoWidth,
|
|
2992
3062
|
sourceHeight: k.videoHeight,
|
|
2993
3063
|
error: void 0
|
|
2994
|
-
}), c.source ===
|
|
2995
|
-
},
|
|
3064
|
+
}), c.source === I.WEBCAM && as();
|
|
3065
|
+
}, Le = async (c) => {
|
|
2996
3066
|
const f = c.sourceKind ?? "webcam";
|
|
2997
|
-
|
|
2998
|
-
const S =
|
|
3067
|
+
u = c.canvas;
|
|
3068
|
+
const S = be(u);
|
|
2999
3069
|
n.set({
|
|
3000
3070
|
cameraTexture: S,
|
|
3001
|
-
source:
|
|
3071
|
+
source: I.CANVAS,
|
|
3002
3072
|
sourceKind: f,
|
|
3003
3073
|
cameraFacing: null,
|
|
3004
3074
|
cameraDeviceId: null,
|
|
3005
|
-
renderWidth:
|
|
3006
|
-
renderHeight:
|
|
3075
|
+
renderWidth: u.width,
|
|
3076
|
+
renderHeight: u.height,
|
|
3007
3077
|
error: void 0
|
|
3008
|
-
}),
|
|
3009
|
-
source:
|
|
3078
|
+
}), o = {
|
|
3079
|
+
source: I.CANVAS,
|
|
3010
3080
|
canvas: c.canvas,
|
|
3011
3081
|
sourceKind: f
|
|
3012
3082
|
};
|
|
3013
|
-
},
|
|
3083
|
+
}, cs = (c, f) => {
|
|
3014
3084
|
if (!f || c.source !== f.source) return !1;
|
|
3015
|
-
if (c.source ===
|
|
3085
|
+
if (c.source === I.STREAM && f.source === I.STREAM)
|
|
3016
3086
|
return c.stream === f.stream && (c.sourceKind ?? "webcam") === f.sourceKind;
|
|
3017
|
-
if (c.source ===
|
|
3087
|
+
if (c.source === I.WEBCAM && f.source === I.WEBCAM) {
|
|
3018
3088
|
const S = c.facingMode ?? "user";
|
|
3019
|
-
return S === f.facingMode && c.deviceId === f.deviceId &&
|
|
3089
|
+
return S === f.facingMode && c.deviceId === f.deviceId && Dt(S, c.mirrored) === f.mirrored;
|
|
3020
3090
|
}
|
|
3021
3091
|
return !1;
|
|
3022
|
-
},
|
|
3023
|
-
if (!
|
|
3024
|
-
const c =
|
|
3092
|
+
}, ot = async () => {
|
|
3093
|
+
if (!u) return;
|
|
3094
|
+
const c = F, f = n.getSnapshot().pipeline;
|
|
3025
3095
|
for (const [, S] of f.entries())
|
|
3026
3096
|
S.resume();
|
|
3027
|
-
await new Promise((S) => requestAnimationFrame(() => S())), await new Promise((S) => requestAnimationFrame(() => S())),
|
|
3028
|
-
},
|
|
3097
|
+
await new Promise((S) => requestAnimationFrame(() => S())), await new Promise((S) => requestAnimationFrame(() => S())), L && F === c && V.suspendAll();
|
|
3098
|
+
}, ls = (c, f) => !f || f.source !== I.CANVAS ? !1 : c.canvas === f.canvas && (c.sourceKind ?? "webcam") === f.sourceKind, Ne = async (c) => {
|
|
3029
3099
|
const f = c.source;
|
|
3030
|
-
if (f !==
|
|
3031
|
-
throw new
|
|
3032
|
-
if (
|
|
3033
|
-
if (
|
|
3100
|
+
if (f !== I.WEBCAM && f !== I.STREAM)
|
|
3101
|
+
throw new O(`Invalid media source: ${String(f)}`);
|
|
3102
|
+
if (y) throw new O("session.setMediaSource() called after the provider unmounted");
|
|
3103
|
+
if (cs(c, o)) {
|
|
3034
3104
|
t.log("Media source unchanged, skipping rebind.");
|
|
3035
3105
|
return;
|
|
3036
3106
|
}
|
|
3037
|
-
|
|
3107
|
+
F += 1;
|
|
3038
3108
|
const { lifecycle: S } = n.getSnapshot();
|
|
3039
3109
|
if (S === "idle" || S === "stopped") {
|
|
3040
|
-
await
|
|
3110
|
+
await Oe(c), n.set({ lifecycle: "media-bound" }), t.log("Media source set to:", c.source);
|
|
3041
3111
|
return;
|
|
3042
3112
|
}
|
|
3043
3113
|
if (S === "media-bound") {
|
|
3044
|
-
ne(), await
|
|
3114
|
+
ne(), await Oe(c), t.log("Media source rebound to:", c.source);
|
|
3045
3115
|
return;
|
|
3046
3116
|
}
|
|
3047
3117
|
const k = S === "paused";
|
|
3048
3118
|
g = !0, await new Promise((C) => requestAnimationFrame(() => C())), ne();
|
|
3049
3119
|
try {
|
|
3050
|
-
await
|
|
3120
|
+
await Oe(c);
|
|
3051
3121
|
} finally {
|
|
3052
3122
|
g = !1;
|
|
3053
3123
|
}
|
|
@@ -3055,76 +3125,76 @@ const It = {
|
|
|
3055
3125
|
d == null || d.pause(), t.log("Media source swapped (paused) to:", c.source);
|
|
3056
3126
|
return;
|
|
3057
3127
|
}
|
|
3058
|
-
|
|
3059
|
-
},
|
|
3060
|
-
if (
|
|
3061
|
-
if (
|
|
3128
|
+
De(), L ? await ot() : V.resumeActive(), t.log("Media source swapped to:", c.source);
|
|
3129
|
+
}, ds = async (c) => {
|
|
3130
|
+
if (y) throw new O("session.setFrameSource() called after the provider unmounted");
|
|
3131
|
+
if (ls(c, o)) {
|
|
3062
3132
|
t.log("Frame source unchanged, skipping rebind.");
|
|
3063
3133
|
return;
|
|
3064
3134
|
}
|
|
3065
|
-
|
|
3135
|
+
F += 1;
|
|
3066
3136
|
const { lifecycle: f } = n.getSnapshot();
|
|
3067
3137
|
if (f === "idle" || f === "stopped") {
|
|
3068
|
-
await
|
|
3138
|
+
await Le(c), n.set({ lifecycle: "media-bound" }), t.log("Frame source set to canvas.");
|
|
3069
3139
|
return;
|
|
3070
3140
|
}
|
|
3071
3141
|
if (f === "media-bound") {
|
|
3072
|
-
ne(), await
|
|
3142
|
+
ne(), await Le(c), t.log("Frame source rebound to canvas.");
|
|
3073
3143
|
return;
|
|
3074
3144
|
}
|
|
3075
3145
|
g = !0, await new Promise((S) => requestAnimationFrame(() => S())), ne();
|
|
3076
3146
|
try {
|
|
3077
|
-
await
|
|
3147
|
+
await Le(c);
|
|
3078
3148
|
} finally {
|
|
3079
3149
|
g = !1;
|
|
3080
3150
|
}
|
|
3081
3151
|
t.log("Frame source swapped to canvas.");
|
|
3082
|
-
},
|
|
3083
|
-
if (
|
|
3152
|
+
}, ct = async () => {
|
|
3153
|
+
if (y) throw new O("session.start() called after the provider unmounted");
|
|
3084
3154
|
const { lifecycle: c } = n.getSnapshot();
|
|
3085
3155
|
if (c === "running") return;
|
|
3086
3156
|
if (c === "paused") {
|
|
3087
|
-
await
|
|
3157
|
+
await Be();
|
|
3088
3158
|
return;
|
|
3089
3159
|
}
|
|
3090
3160
|
if (c === "idle")
|
|
3091
|
-
throw new
|
|
3092
|
-
if (!
|
|
3093
|
-
throw new
|
|
3094
|
-
const f = (
|
|
3161
|
+
throw new O("session.start() called before setMediaSource — call setMediaSource first");
|
|
3162
|
+
if (!u)
|
|
3163
|
+
throw new O("session.start(): media source not bound");
|
|
3164
|
+
const f = (o == null ? void 0 : o.source) === I.CANVAS;
|
|
3095
3165
|
if (!f && (!d || !h))
|
|
3096
|
-
throw c === "stopped" ? new
|
|
3166
|
+
throw c === "stopped" ? new O(
|
|
3097
3167
|
"session.start() called from stopped state without a media source — call setMediaSource first"
|
|
3098
|
-
) : new
|
|
3099
|
-
f ||
|
|
3168
|
+
) : new O("session.start(): media source not bound");
|
|
3169
|
+
f || De(), V.resumeActive(), n.set({ lifecycle: "running" }), await new Promise((k) => requestAnimationFrame(() => k()));
|
|
3100
3170
|
const S = n.getSnapshot().pipeline;
|
|
3101
3171
|
for (const [k, C] of S.entries())
|
|
3102
|
-
await
|
|
3172
|
+
await Pe(k, C);
|
|
3103
3173
|
n.set({ ready: !0 }), t.log("XR session started.");
|
|
3104
|
-
},
|
|
3174
|
+
}, lt = () => {
|
|
3105
3175
|
if (n.getSnapshot().lifecycle === "running") {
|
|
3106
|
-
|
|
3176
|
+
rt(), V.suspendAll();
|
|
3107
3177
|
try {
|
|
3108
3178
|
d == null || d.pause();
|
|
3109
3179
|
} catch {
|
|
3110
3180
|
}
|
|
3111
3181
|
n.set({ lifecycle: "paused" }), t.log("XR session paused.");
|
|
3112
3182
|
}
|
|
3113
|
-
},
|
|
3114
|
-
if (
|
|
3183
|
+
}, Be = async () => {
|
|
3184
|
+
if (y) throw new O("session.resume() called after the provider unmounted");
|
|
3115
3185
|
n.getSnapshot().lifecycle === "paused" && (v = !1, d && d.play().catch(() => {
|
|
3116
|
-
}), (
|
|
3117
|
-
},
|
|
3118
|
-
await
|
|
3186
|
+
}), (o == null ? void 0 : o.source) !== I.CANVAS && De(), n.set({ lifecycle: "running" }), L ? await ot() : V.resumeActive(), t.log("XR session resumed."));
|
|
3187
|
+
}, hs = async (c = {}) => {
|
|
3188
|
+
await Ne({ source: I.WEBCAM, ...c });
|
|
3119
3189
|
const { lifecycle: f } = n.getSnapshot();
|
|
3120
|
-
return (f === "media-bound" || f === "stopped") && await
|
|
3121
|
-
},
|
|
3190
|
+
return (f === "media-bound" || f === "stopped") && await ct(), n.getSnapshot().cameraFacing ?? c.facingMode ?? "user";
|
|
3191
|
+
}, dt = async () => {
|
|
3122
3192
|
const { lifecycle: c } = n.getSnapshot();
|
|
3123
|
-
c === "stopped" || c === "idle" || (v = !1, ne(),
|
|
3124
|
-
},
|
|
3125
|
-
await
|
|
3193
|
+
c === "stopped" || c === "idle" || (v = !1, ne(), V.suspendAll(), o = void 0, n.set({ lifecycle: "stopped", ready: !1 }), t.log("XR session stopped."));
|
|
3194
|
+
}, ht = async () => {
|
|
3195
|
+
await dt(), V.releaseAll(), X.clear();
|
|
3126
3196
|
const c = n.getSnapshot().cameraTexture;
|
|
3127
|
-
c && c.dispose(), G = /* @__PURE__ */ new WeakSet(),
|
|
3197
|
+
c && c.dispose(), G = /* @__PURE__ */ new WeakSet(), o = void 0, F += 1, u = void 0, h = void 0, M = void 0, L = !1, os(), n.set({
|
|
3128
3198
|
lifecycle: "idle",
|
|
3129
3199
|
cameraTexture: void 0,
|
|
3130
3200
|
source: void 0,
|
|
@@ -3136,112 +3206,112 @@ const It = {
|
|
|
3136
3206
|
cameraPermission: "unknown",
|
|
3137
3207
|
cameraPermissionReason: null
|
|
3138
3208
|
}), t.log("XR session reset.");
|
|
3139
|
-
},
|
|
3140
|
-
|
|
3141
|
-
},
|
|
3142
|
-
|
|
3143
|
-
},
|
|
3209
|
+
}, us = async () => {
|
|
3210
|
+
y || (y = !0, re == null || re(), re = void 0, ie == null || ie(), ie = void 0, await ht(), t.log("XR session disposed."));
|
|
3211
|
+
}, ms = () => {
|
|
3212
|
+
y && (y = !1, gt(), ft(), t.log("XR session re-armed."));
|
|
3213
|
+
}, fs = () => y, gs = async (c) => {
|
|
3144
3214
|
const f = "legacy:registerXRPipeline", S = [];
|
|
3145
3215
|
await Promise.all(
|
|
3146
3216
|
c.map(async (k) => {
|
|
3147
3217
|
const { model: C } = k;
|
|
3148
|
-
if (!
|
|
3149
|
-
throw new
|
|
3218
|
+
if (!_t[C])
|
|
3219
|
+
throw new O(`Invalid model: ${C}`);
|
|
3150
3220
|
X.has(C) || S.push(C);
|
|
3151
3221
|
const D = "options" in k ? k.options : void 0;
|
|
3152
|
-
await
|
|
3222
|
+
await V.acquire(C, f, D);
|
|
3153
3223
|
})
|
|
3154
3224
|
), S.length > 0 && (S.forEach((k) => X.add(k)), t.log("XR pipeline registered."));
|
|
3155
|
-
},
|
|
3156
|
-
const f =
|
|
3225
|
+
}, ps = (c) => {
|
|
3226
|
+
const f = V.get(c);
|
|
3157
3227
|
if (!f)
|
|
3158
|
-
throw new
|
|
3228
|
+
throw new O(`Model ${c} is not registered in the pipeline`);
|
|
3159
3229
|
return f.getModelNode();
|
|
3160
|
-
},
|
|
3161
|
-
c <= 0 || f <= 0 || (n.set({ renderWidth: c, renderHeight: f }),
|
|
3162
|
-
},
|
|
3230
|
+
}, ut = async (c, f) => {
|
|
3231
|
+
c <= 0 || f <= 0 || (n.set({ renderWidth: c, renderHeight: f }), u && (u.width !== c || u.height !== f) && (u.width = c, u.height = f, be(u), L && _e()), t.log(`Source canvas set. Render size: ${c}x${f}`));
|
|
3232
|
+
}, ys = async (c) => {
|
|
3163
3233
|
var C;
|
|
3164
|
-
|
|
3234
|
+
p = c;
|
|
3165
3235
|
const f = (C = c.getBoundingClientRect) == null ? void 0 : C.call(c), S = f && f.width > 0 ? Math.round(f.width) : c.clientWidth, k = f && f.height > 0 ? Math.round(f.height) : c.clientHeight;
|
|
3166
|
-
await
|
|
3167
|
-
},
|
|
3236
|
+
await ut(S, k);
|
|
3237
|
+
}, ws = (c) => {
|
|
3168
3238
|
M = c;
|
|
3169
|
-
},
|
|
3239
|
+
}, He = () => p && x && b && T ? p : M, vs = (c) => {
|
|
3170
3240
|
x = c.renderer, b = c.scene, T = c.camera, R = c.renderFrame;
|
|
3171
|
-
},
|
|
3241
|
+
}, mt = () => {
|
|
3172
3242
|
if (!x || !b || !T)
|
|
3173
|
-
throw new
|
|
3243
|
+
throw new O(
|
|
3174
3244
|
"XR frame render requested before the R3F state was bound — make sure <XRScene> is mounted"
|
|
3175
3245
|
);
|
|
3176
3246
|
R ? R() : x.render(b, T);
|
|
3177
|
-
},
|
|
3178
|
-
const c =
|
|
3179
|
-
if (c &&
|
|
3180
|
-
return
|
|
3181
|
-
const f =
|
|
3247
|
+
}, xs = () => {
|
|
3248
|
+
const c = p;
|
|
3249
|
+
if (c && He() === c)
|
|
3250
|
+
return mt(), c.toDataURL("image/png");
|
|
3251
|
+
const f = He();
|
|
3182
3252
|
if (f) return f.toDataURL("image/png");
|
|
3183
|
-
throw new
|
|
3253
|
+
throw new O(
|
|
3184
3254
|
"session.captureFrame() called before an XRScene or XRMediaSurface capture target was bound"
|
|
3185
3255
|
);
|
|
3186
|
-
},
|
|
3187
|
-
const f =
|
|
3256
|
+
}, Ss = (c = 30) => {
|
|
3257
|
+
const f = He();
|
|
3188
3258
|
if (!(f != null && f.captureStream))
|
|
3189
|
-
throw new
|
|
3259
|
+
throw new O(
|
|
3190
3260
|
"session.captureStream() called before an XRScene or XRMediaSurface capture target was bound"
|
|
3191
3261
|
);
|
|
3192
3262
|
return f.captureStream(c);
|
|
3193
|
-
},
|
|
3194
|
-
if (r = c, n.set({ cameraZoom: (c == null ? void 0 : c.cameraZoom) ?? 1.2 }), n.getSnapshot().lifecycle !== "running" || !
|
|
3263
|
+
}, Ms = () => d, bs = () => u ?? null, ks = (c) => {
|
|
3264
|
+
if (r = c, n.set({ cameraZoom: (c == null ? void 0 : c.cameraZoom) ?? 1.2 }), n.getSnapshot().lifecycle !== "running" || !u) return;
|
|
3195
3265
|
const f = n.getSnapshot().pipeline;
|
|
3196
3266
|
for (const [S, k] of f.entries())
|
|
3197
3267
|
k.run({
|
|
3198
|
-
sourceCanvas:
|
|
3268
|
+
sourceCanvas: u,
|
|
3199
3269
|
renderWidth: n.getSnapshot().renderWidth,
|
|
3200
3270
|
renderHeight: n.getSnapshot().renderHeight,
|
|
3201
3271
|
getSource: () => n.getSnapshot().sourceKind,
|
|
3202
|
-
targetFps:
|
|
3272
|
+
targetFps: a(S),
|
|
3203
3273
|
analysisScale: r == null ? void 0 : r.analysisScale
|
|
3204
3274
|
});
|
|
3205
|
-
},
|
|
3206
|
-
if (!
|
|
3207
|
-
const { facingMode: c, deviceId: f, mirrored: S } =
|
|
3208
|
-
|
|
3209
|
-
},
|
|
3275
|
+
}, Cs = () => r, Ts = async () => {
|
|
3276
|
+
if (!o || o.source !== I.WEBCAM) return;
|
|
3277
|
+
const { facingMode: c, deviceId: f, mirrored: S } = o;
|
|
3278
|
+
o = void 0, await Ne({ source: I.WEBCAM, facingMode: c, deviceId: f, mirrored: S });
|
|
3279
|
+
}, Es = (c) => {
|
|
3210
3280
|
n.set({ quality: c });
|
|
3211
|
-
},
|
|
3281
|
+
}, Rs = (c) => {
|
|
3212
3282
|
n.set({ qualityConfig: c });
|
|
3213
|
-
},
|
|
3283
|
+
}, As = (c) => {
|
|
3214
3284
|
i = c;
|
|
3215
|
-
},
|
|
3285
|
+
}, Is = () => {
|
|
3216
3286
|
var C;
|
|
3217
3287
|
if (typeof window > "u") return { type: "portrait", angle: 0 };
|
|
3218
3288
|
const c = (C = window.screen) == null ? void 0 : C.orientation, f = (c == null ? void 0 : c.angle) ?? 0, S = f === 90 || f === 180 || f === 270 ? f : 0;
|
|
3219
3289
|
return { type: c != null && c.type ? c.type.startsWith("landscape") ? "landscape" : "portrait" : window.innerWidth > window.innerHeight ? "landscape" : "portrait", angle: S };
|
|
3220
|
-
},
|
|
3221
|
-
const c =
|
|
3290
|
+
}, fe = () => {
|
|
3291
|
+
const c = Is(), f = n.getSnapshot().orientation, S = f.type !== c.type || f.angle !== c.angle ? { orientation: c } : {};
|
|
3222
3292
|
d && d.videoWidth > 0 && (S.sourceWidth = d.videoWidth, S.sourceHeight = d.videoHeight), Object.keys(S).length && n.set(S);
|
|
3223
3293
|
};
|
|
3224
3294
|
let ie;
|
|
3225
|
-
const
|
|
3295
|
+
const ft = () => {
|
|
3226
3296
|
var f, S, k;
|
|
3227
3297
|
if (ie || typeof window > "u") return;
|
|
3228
3298
|
const c = (f = window.screen) == null ? void 0 : f.orientation;
|
|
3229
|
-
(S = c == null ? void 0 : c.addEventListener) == null || S.call(c, "change",
|
|
3299
|
+
(S = c == null ? void 0 : c.addEventListener) == null || S.call(c, "change", fe), (k = window.addEventListener) == null || k.call(window, "resize", fe), ie = () => {
|
|
3230
3300
|
var C, D;
|
|
3231
|
-
(C = c == null ? void 0 : c.removeEventListener) == null || C.call(c, "change",
|
|
3232
|
-
},
|
|
3301
|
+
(C = c == null ? void 0 : c.removeEventListener) == null || C.call(c, "change", fe), (D = window.removeEventListener) == null || D.call(window, "resize", fe);
|
|
3302
|
+
}, fe();
|
|
3233
3303
|
};
|
|
3234
3304
|
let re;
|
|
3235
|
-
const
|
|
3305
|
+
const gt = () => {
|
|
3236
3306
|
if (re || typeof document > "u" || typeof document.addEventListener != "function") return;
|
|
3237
3307
|
const c = () => {
|
|
3238
|
-
if (!
|
|
3308
|
+
if (!y) {
|
|
3239
3309
|
if (document.hidden) {
|
|
3240
|
-
i != null && i.pauseWhenHidden && n.getSnapshot().lifecycle === "running" && (
|
|
3310
|
+
i != null && i.pauseWhenHidden && n.getSnapshot().lifecycle === "running" && (lt(), v = !0);
|
|
3241
3311
|
return;
|
|
3242
3312
|
}
|
|
3243
3313
|
if (v && n.getSnapshot().lifecycle === "paused") {
|
|
3244
|
-
|
|
3314
|
+
Be();
|
|
3245
3315
|
return;
|
|
3246
3316
|
}
|
|
3247
3317
|
n.getSnapshot().lifecycle === "running" && (d != null && d.paused) && d.play().catch(() => {
|
|
@@ -3250,81 +3320,81 @@ const It = {
|
|
|
3250
3320
|
};
|
|
3251
3321
|
document.addEventListener("visibilitychange", c), re = () => document.removeEventListener("visibilitychange", c);
|
|
3252
3322
|
};
|
|
3253
|
-
return
|
|
3323
|
+
return gt(), ft(), {
|
|
3254
3324
|
store: n,
|
|
3255
|
-
registry:
|
|
3256
|
-
setMediaSource:
|
|
3257
|
-
start:
|
|
3258
|
-
stop:
|
|
3259
|
-
reset:
|
|
3260
|
-
pause:
|
|
3261
|
-
resume:
|
|
3262
|
-
switchCamera:
|
|
3263
|
-
dispose:
|
|
3264
|
-
rearm:
|
|
3265
|
-
isDisposed:
|
|
3266
|
-
setFrameSource:
|
|
3267
|
-
registerXRPipeline:
|
|
3268
|
-
getModelNode:
|
|
3269
|
-
captureFrame:
|
|
3270
|
-
captureStream:
|
|
3271
|
-
getInputFrame:
|
|
3272
|
-
_setRenderTarget:
|
|
3273
|
-
_setCaptureTarget:
|
|
3274
|
-
_setRenderSize:
|
|
3275
|
-
_setR3FState:
|
|
3276
|
-
_renderFrame:
|
|
3277
|
-
_getVideoElement:
|
|
3278
|
-
_setPerf:
|
|
3279
|
-
_setLifecycle:
|
|
3280
|
-
_rebindMedia:
|
|
3281
|
-
_setQuality:
|
|
3282
|
-
_setQualityConfig:
|
|
3283
|
-
_getPerf:
|
|
3325
|
+
registry: V,
|
|
3326
|
+
setMediaSource: Ne,
|
|
3327
|
+
start: ct,
|
|
3328
|
+
stop: dt,
|
|
3329
|
+
reset: ht,
|
|
3330
|
+
pause: lt,
|
|
3331
|
+
resume: Be,
|
|
3332
|
+
switchCamera: hs,
|
|
3333
|
+
dispose: us,
|
|
3334
|
+
rearm: ms,
|
|
3335
|
+
isDisposed: fs,
|
|
3336
|
+
setFrameSource: ds,
|
|
3337
|
+
registerXRPipeline: gs,
|
|
3338
|
+
getModelNode: ps,
|
|
3339
|
+
captureFrame: xs,
|
|
3340
|
+
captureStream: Ss,
|
|
3341
|
+
getInputFrame: bs,
|
|
3342
|
+
_setRenderTarget: ys,
|
|
3343
|
+
_setCaptureTarget: ws,
|
|
3344
|
+
_setRenderSize: ut,
|
|
3345
|
+
_setR3FState: vs,
|
|
3346
|
+
_renderFrame: mt,
|
|
3347
|
+
_getVideoElement: Ms,
|
|
3348
|
+
_setPerf: ks,
|
|
3349
|
+
_setLifecycle: As,
|
|
3350
|
+
_rebindMedia: Ts,
|
|
3351
|
+
_setQuality: Es,
|
|
3352
|
+
_setQualityConfig: Rs,
|
|
3353
|
+
_getPerf: Cs
|
|
3284
3354
|
};
|
|
3285
|
-
},
|
|
3286
|
-
const t =
|
|
3287
|
-
() =>
|
|
3355
|
+
}, zi = (e, s) => {
|
|
3356
|
+
const t = ue(e), n = ue(s), i = xe(
|
|
3357
|
+
() => Ui(t.current, n.current),
|
|
3288
3358
|
[]
|
|
3289
3359
|
), r = JSON.stringify(s ?? {});
|
|
3290
|
-
|
|
3360
|
+
de(() => {
|
|
3291
3361
|
i._setLifecycle(s);
|
|
3292
|
-
}, [i, r]),
|
|
3293
|
-
const
|
|
3294
|
-
return
|
|
3362
|
+
}, [i, r]), de(() => (i.rearm(), () => void i.dispose()), [i]);
|
|
3363
|
+
const a = JSON.stringify(e ?? {});
|
|
3364
|
+
return de(() => {
|
|
3295
3365
|
i._setPerf(e);
|
|
3296
|
-
}, [i,
|
|
3297
|
-
},
|
|
3366
|
+
}, [i, a]), i;
|
|
3367
|
+
}, Je = /* @__PURE__ */ new Map(), Wi = () => ({
|
|
3298
3368
|
register: (e, s) => {
|
|
3299
|
-
s ?
|
|
3369
|
+
s ? Je.set(e, s) : Je.delete(e);
|
|
3300
3370
|
},
|
|
3301
|
-
resolve: (e) => e ?
|
|
3302
|
-
}),
|
|
3303
|
-
const s =
|
|
3304
|
-
|
|
3305
|
-
}, []), n =
|
|
3371
|
+
resolve: (e) => e ? Je.get(e) ?? null : null
|
|
3372
|
+
}), Zt = Wi(), $t = Lt(null), qi = ({ children: e }) => {
|
|
3373
|
+
const s = ue(/* @__PURE__ */ new Map()), t = St((r, a) => {
|
|
3374
|
+
a ? s.current.set(r, a) : s.current.delete(r);
|
|
3375
|
+
}, []), n = St(
|
|
3306
3376
|
(r) => r ? s.current.get(r) ?? null : null,
|
|
3307
3377
|
[]
|
|
3308
3378
|
), i = xe(() => ({ register: t, resolve: n }), [t, n]);
|
|
3309
|
-
return
|
|
3310
|
-
},
|
|
3311
|
-
|
|
3312
|
-
const
|
|
3313
|
-
[
|
|
3314
|
-
[
|
|
3315
|
-
[
|
|
3316
|
-
[
|
|
3317
|
-
[
|
|
3318
|
-
[
|
|
3319
|
-
[
|
|
3320
|
-
},
|
|
3379
|
+
return Os($t.Provider, { value: i }, e);
|
|
3380
|
+
}, es = () => et($t) ?? Zt, ia = () => es().register, ra = () => es().resolve;
|
|
3381
|
+
Zt.register;
|
|
3382
|
+
const Vi = {
|
|
3383
|
+
[P.FACE_TRACKER]: "face",
|
|
3384
|
+
[P.HAND_TRACKER]: "hand",
|
|
3385
|
+
[P.GESTURE_TRACKER]: "gesture",
|
|
3386
|
+
[P.BODY_TRACKER]: "body",
|
|
3387
|
+
[P.HOLISTIC_TRACKER]: "holistic",
|
|
3388
|
+
[P.BACKGROUND_SEGMENTATION]: "segmentation",
|
|
3389
|
+
[P.SEMANTIC_SEGMENTATION]: "semantic-seg"
|
|
3390
|
+
}, Ot = Object.values(P), Ki = (e, s) => {
|
|
3321
3391
|
var n;
|
|
3322
3392
|
const t = (n = e.registry.getOptions(s)) == null ? void 0 : n.targetFps;
|
|
3323
3393
|
return typeof t == "number" ? t : null;
|
|
3324
|
-
},
|
|
3325
|
-
const i = e.store.getSnapshot(), r = t ? n - t.sampledAt : 0,
|
|
3394
|
+
}, $e = (e, s, t, n = performance.now()) => {
|
|
3395
|
+
const i = e.store.getSnapshot(), r = t ? n - t.sampledAt : 0, a = t && r > 0 ? Math.max(0, (i.feedFrames - t.feedFrames) * 1e3 / r) : 0, o = i.lifecycle === "running", d = s.map((h) => {
|
|
3326
3396
|
var T;
|
|
3327
|
-
const
|
|
3397
|
+
const u = e.registry.getState(h), p = e.store.getSnapshot().pipeline.get(h), M = ((T = i.modelErrors.get(h)) == null ? void 0 : T.error) ?? null, x = (p == null ? void 0 : p.getDiagnostics()) ?? {
|
|
3328
3398
|
inferenceMs: null,
|
|
3329
3399
|
inferenceFps: 0,
|
|
3330
3400
|
inferences: 0,
|
|
@@ -3337,13 +3407,13 @@ const Bi = {
|
|
|
3337
3407
|
disposed: !1
|
|
3338
3408
|
};
|
|
3339
3409
|
let b;
|
|
3340
|
-
return
|
|
3410
|
+
return u === "error" || x.status === "error" ? b = "error" : u === "idle" ? b = "unavailable" : u === "initializing" ? b = "loading" : x.paused || !o ? b = "paused" : b = "ready", {
|
|
3341
3411
|
...x,
|
|
3342
3412
|
error: x.error ?? M,
|
|
3343
3413
|
model: h,
|
|
3344
|
-
label:
|
|
3414
|
+
label: Vi[h] ?? h,
|
|
3345
3415
|
state: b,
|
|
3346
|
-
targetFps:
|
|
3416
|
+
targetFps: Ki(e, h),
|
|
3347
3417
|
owners: e.registry.getOwners(h)
|
|
3348
3418
|
};
|
|
3349
3419
|
}), l = i.quality;
|
|
@@ -3364,36 +3434,36 @@ const Bi = {
|
|
|
3364
3434
|
sourceHeight: i.sourceHeight,
|
|
3365
3435
|
renderWidth: i.renderWidth,
|
|
3366
3436
|
renderHeight: i.renderHeight,
|
|
3367
|
-
feedFps:
|
|
3437
|
+
feedFps: a,
|
|
3368
3438
|
feedFrames: i.feedFrames
|
|
3369
3439
|
},
|
|
3370
3440
|
models: d,
|
|
3371
3441
|
inferenceMsTotal: d.reduce(
|
|
3372
|
-
(h,
|
|
3442
|
+
(h, u) => h + (u.state === "ready" ? u.inferenceMs ?? 0 : 0),
|
|
3373
3443
|
0
|
|
3374
3444
|
),
|
|
3375
3445
|
sampledAt: n
|
|
3376
3446
|
};
|
|
3377
|
-
},
|
|
3378
|
-
const { intervalMs: s = 250, enabled: t = !0 } = e, { session: n } =
|
|
3379
|
-
() => e.models && e.models.length ? e.models :
|
|
3447
|
+
}, aa = (e = {}) => {
|
|
3448
|
+
const { intervalMs: s = 250, enabled: t = !0 } = e, { session: n } = ns(), i = (e.models ?? Ot).join("|"), r = xe(
|
|
3449
|
+
() => e.models && e.models.length ? e.models : Ot,
|
|
3380
3450
|
// modelsKey captures the list by value.
|
|
3381
3451
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3382
3452
|
[i]
|
|
3383
|
-
),
|
|
3384
|
-
() =>
|
|
3453
|
+
), a = ue(null), [o, d] = Ls(
|
|
3454
|
+
() => $e(n, r, null)
|
|
3385
3455
|
);
|
|
3386
|
-
return
|
|
3456
|
+
return de(() => {
|
|
3387
3457
|
if (!t) return;
|
|
3388
3458
|
const l = () => {
|
|
3389
|
-
const
|
|
3390
|
-
|
|
3459
|
+
const u = $e(n, r, a.current);
|
|
3460
|
+
a.current = { feedFrames: u.session.feedFrames, sampledAt: u.sampledAt }, d(u);
|
|
3391
3461
|
};
|
|
3392
3462
|
l();
|
|
3393
3463
|
const h = window.setInterval(l, Math.max(50, s));
|
|
3394
3464
|
return () => window.clearInterval(h);
|
|
3395
|
-
}, [n, r, s, t]),
|
|
3396
|
-
},
|
|
3465
|
+
}, [n, r, s, t]), o;
|
|
3466
|
+
}, Gi = [
|
|
3397
3467
|
{ name: "high", targetFps: 30, renderScale: 1, analysisScale: 1, camRes: 960 },
|
|
3398
3468
|
{ name: "medium", targetFps: 24, renderScale: 0.8, analysisScale: 0.85, camRes: 720 },
|
|
3399
3469
|
{ name: "low", targetFps: 15, renderScale: 0.6, analysisScale: 0.7, camRes: 640 }
|
|
@@ -3406,7 +3476,7 @@ const Bi = {
|
|
|
3406
3476
|
upgradeAfter: 6,
|
|
3407
3477
|
upgradeHeadroom: 0.75,
|
|
3408
3478
|
cooldownMs: 4e3
|
|
3409
|
-
},
|
|
3479
|
+
}, ts = {
|
|
3410
3480
|
frameMs: null,
|
|
3411
3481
|
fps: null,
|
|
3412
3482
|
inferenceMs: null,
|
|
@@ -3415,14 +3485,14 @@ const Bi = {
|
|
|
3415
3485
|
deviceMemoryGb: null,
|
|
3416
3486
|
hardwareConcurrency: null,
|
|
3417
3487
|
thermal: "unknown"
|
|
3418
|
-
}, ve = (e, s, t) => Math.min(t, Math.max(s, e)), H = (e, s) => typeof e == "number" && Number.isFinite(e) ? e : s,
|
|
3488
|
+
}, ve = (e, s, t) => Math.min(t, Math.max(s, e)), H = (e, s) => typeof e == "number" && Number.isFinite(e) ? e : s, Xi = (e, s) => ({
|
|
3419
3489
|
name: typeof e.name == "string" && e.name ? e.name : `tier-${s}`,
|
|
3420
3490
|
...H(e.targetFps, NaN) > 0 ? { targetFps: H(e.targetFps, 0) } : {},
|
|
3421
3491
|
...H(e.renderScale, NaN) > 0 ? { renderScale: ve(H(e.renderScale, 1), 0.25, 1) } : {},
|
|
3422
3492
|
...H(e.analysisScale, NaN) > 0 ? { analysisScale: ve(H(e.analysisScale, 1), 0.25, 1) } : {},
|
|
3423
3493
|
...H(e.camRes, NaN) > 0 ? { camRes: Math.round(H(e.camRes, 0)) } : {},
|
|
3424
3494
|
...e.rebindCamera ? { rebindCamera: !0 } : {}
|
|
3425
|
-
}),
|
|
3495
|
+
}), ji = (e = {}) => ({
|
|
3426
3496
|
maxFrameMs: Math.max(1, H(e.maxFrameMs, Z.maxFrameMs)),
|
|
3427
3497
|
maxInferenceMs: Math.max(
|
|
3428
3498
|
0,
|
|
@@ -3452,25 +3522,25 @@ const Bi = {
|
|
|
3452
3522
|
if (n >= 0) return n;
|
|
3453
3523
|
}
|
|
3454
3524
|
return t;
|
|
3455
|
-
},
|
|
3456
|
-
const s = e.tiers && e.tiers.length ? e.tiers.map((i, r) =>
|
|
3525
|
+
}, Yi = (e = {}) => {
|
|
3526
|
+
const s = e.tiers && e.tiers.length ? e.tiers.map((i, r) => Xi(i, r)) : Gi, t = Q(s, e.maxTier, 0), n = Math.max(t, Q(s, e.minTier, s.length - 1));
|
|
3457
3527
|
return {
|
|
3458
3528
|
tiers: s,
|
|
3459
|
-
budget:
|
|
3529
|
+
budget: ji(e.budget),
|
|
3460
3530
|
...e.initialTier !== void 0 ? { initialTier: e.initialTier } : {},
|
|
3461
3531
|
minTier: n,
|
|
3462
3532
|
maxTier: t,
|
|
3463
3533
|
adaptive: e.adaptive !== !1,
|
|
3464
3534
|
historySize: Math.max(1, Math.round(H(e.historySize, 20)))
|
|
3465
3535
|
};
|
|
3466
|
-
},
|
|
3536
|
+
}, Qi = (e, s) => {
|
|
3467
3537
|
const t = Q(e.tiers, e.maxTier, 0), n = Q(e.tiers, e.minTier, e.tiers.length - 1);
|
|
3468
3538
|
if (e.initialTier !== void 0)
|
|
3469
3539
|
return ve(Q(e.tiers, e.initialTier, t), t, n);
|
|
3470
3540
|
const i = s.deviceMemoryGb !== null && s.deviceMemoryGb <= 4 || s.hardwareConcurrency !== null && s.hardwareConcurrency <= 4;
|
|
3471
3541
|
return ve(i ? t + 1 : t, t, n);
|
|
3472
|
-
},
|
|
3473
|
-
const n =
|
|
3542
|
+
}, ss = (e, s = ts, t = 0) => {
|
|
3543
|
+
const n = Qi(e, s), i = { index: n, tier: e.tiers[n], reason: "init", at: t };
|
|
3474
3544
|
return {
|
|
3475
3545
|
index: n,
|
|
3476
3546
|
locked: !1,
|
|
@@ -3481,58 +3551,58 @@ const Bi = {
|
|
|
3481
3551
|
history: [i],
|
|
3482
3552
|
signals: s
|
|
3483
3553
|
};
|
|
3484
|
-
},
|
|
3485
|
-
const
|
|
3554
|
+
}, Fe = (e, s, t, n, i, r = e.signals) => {
|
|
3555
|
+
const a = { index: t, tier: s.tiers[t], reason: n, at: i };
|
|
3486
3556
|
return {
|
|
3487
3557
|
...e,
|
|
3488
3558
|
index: t,
|
|
3489
3559
|
badStreak: 0,
|
|
3490
3560
|
goodStreak: 0,
|
|
3491
3561
|
lastChangeAt: i,
|
|
3492
|
-
decision:
|
|
3493
|
-
history: [
|
|
3562
|
+
decision: a,
|
|
3563
|
+
history: [a, ...e.history].slice(0, s.historySize),
|
|
3494
3564
|
signals: r
|
|
3495
3565
|
};
|
|
3496
|
-
},
|
|
3497
|
-
const { budget: i } = t, r = Q(t.tiers, t.maxTier, 0),
|
|
3566
|
+
}, Ji = (e, s) => e.thermal === "critical" ? "thermal" : s.maxMemoryMb !== null && e.memoryMb !== null && e.memoryMb > s.maxMemoryMb ? "memory" : e.inferenceMs !== null && e.inferenceMs > s.maxInferenceMs ? "inference" : e.frameMs !== null && e.frameMs > s.maxFrameMs ? "frame-time" : null, Zi = (e, s, t, n) => {
|
|
3567
|
+
const { budget: i } = t, r = Q(t.tiers, t.maxTier, 0), a = Q(t.tiers, t.minTier, t.tiers.length - 1);
|
|
3498
3568
|
if (e.locked || !t.adaptive) return { ...e, signals: s };
|
|
3499
|
-
const
|
|
3500
|
-
if (
|
|
3501
|
-
if (e.index <
|
|
3502
|
-
return
|
|
3503
|
-
const
|
|
3504
|
-
return { ...e, badStreak: l, goodStreak: h, signals: { ...s, thermal:
|
|
3505
|
-
}
|
|
3506
|
-
return d && h >= i.upgradeAfter &&
|
|
3507
|
-
},
|
|
3569
|
+
const o = Ji(s, i), d = o === null && s.frameMs !== null && s.frameMs <= i.maxFrameMs * i.upgradeHeadroom && (s.inferenceMs === null || s.inferenceMs <= i.maxInferenceMs * i.upgradeHeadroom), l = o ? e.badStreak + 1 : 0, h = d ? e.goodStreak + 1 : 0, u = n - e.lastChangeAt >= i.cooldownMs;
|
|
3570
|
+
if (o && l >= i.downgradeAfter && u) {
|
|
3571
|
+
if (e.index < a)
|
|
3572
|
+
return Fe(e, t, e.index + 1, o, n, s);
|
|
3573
|
+
const p = o === "frame-time" ? "suspected" : s.thermal;
|
|
3574
|
+
return { ...e, badStreak: l, goodStreak: h, signals: { ...s, thermal: p } };
|
|
3575
|
+
}
|
|
3576
|
+
return d && h >= i.upgradeAfter && u && e.index > r ? Fe(e, t, e.index - 1, "recovered", n, s) : { ...e, badStreak: l, goodStreak: h, signals: s };
|
|
3577
|
+
}, oa = (e, s, t, n) => {
|
|
3508
3578
|
const i = Q(s.tiers, t, e.index);
|
|
3509
|
-
return i === e.index ? e :
|
|
3510
|
-
},
|
|
3511
|
-
const n =
|
|
3579
|
+
return i === e.index ? e : Fe(e, s, i, "manual", n);
|
|
3580
|
+
}, ca = (e, s, t, n) => t === e.locked ? e : { ...Fe(e, s, e.index, t ? "locked" : "manual", n), locked: t }, $i = (e, s) => e.decision.tier === s ? null : e.decision.tier, la = (e, s, t) => {
|
|
3581
|
+
const n = ss(e, s, t);
|
|
3512
3582
|
return {
|
|
3513
3583
|
...n,
|
|
3514
3584
|
decision: { ...n.decision, reason: "reset" },
|
|
3515
3585
|
history: [{ ...n.decision, reason: "reset" }]
|
|
3516
3586
|
};
|
|
3517
|
-
},
|
|
3587
|
+
}, er = Object.values(P), tr = () => {
|
|
3518
3588
|
if (typeof navigator > "u") return { deviceMemoryGb: null, hardwareConcurrency: null };
|
|
3519
3589
|
const e = navigator;
|
|
3520
3590
|
return {
|
|
3521
3591
|
deviceMemoryGb: typeof e.deviceMemory == "number" ? e.deviceMemory : null,
|
|
3522
3592
|
hardwareConcurrency: typeof e.hardwareConcurrency == "number" ? e.hardwareConcurrency : null
|
|
3523
3593
|
};
|
|
3524
|
-
},
|
|
3594
|
+
}, sr = () => {
|
|
3525
3595
|
const e = performance.memory;
|
|
3526
3596
|
return e ? e.usedJSHeapSize / 1048576 : null;
|
|
3527
|
-
},
|
|
3528
|
-
const { session: n } =
|
|
3529
|
-
|
|
3530
|
-
const
|
|
3531
|
-
return
|
|
3532
|
-
const d =
|
|
3533
|
-
let l =
|
|
3597
|
+
}, nr = ({ config: e, thermal: s, onDecision: t }) => {
|
|
3598
|
+
const { session: n } = ns(), i = JSON.stringify(e ?? {}), r = xe(() => Yi(e), [i]), a = ue(s ?? "unknown");
|
|
3599
|
+
a.current = s ?? "unknown";
|
|
3600
|
+
const o = ue(t);
|
|
3601
|
+
return o.current = t, de(() => {
|
|
3602
|
+
const d = tr();
|
|
3603
|
+
let l = ss(
|
|
3534
3604
|
r,
|
|
3535
|
-
{ ...
|
|
3605
|
+
{ ...ts, ...d },
|
|
3536
3606
|
performance.now()
|
|
3537
3607
|
);
|
|
3538
3608
|
const h = n.store.getSnapshot().quality;
|
|
@@ -3540,201 +3610,205 @@ const Bi = {
|
|
|
3540
3610
|
...h,
|
|
3541
3611
|
decision: { ...h.decision, tier: r.tiers[h.index] }
|
|
3542
3612
|
}), n._setQualityConfig(r), n._setQuality(l);
|
|
3543
|
-
let
|
|
3544
|
-
const M = async (
|
|
3613
|
+
let u = n._getPerf(), p = null;
|
|
3614
|
+
const M = async (y, v) => {
|
|
3545
3615
|
const A = {
|
|
3546
|
-
...
|
|
3547
|
-
...
|
|
3548
|
-
...
|
|
3549
|
-
...
|
|
3616
|
+
...u,
|
|
3617
|
+
...y.targetFps !== void 0 ? { targetFps: y.targetFps } : {},
|
|
3618
|
+
...y.analysisScale !== void 0 ? { analysisScale: y.analysisScale } : {},
|
|
3619
|
+
...y.camRes !== void 0 && y.rebindCamera ? { camRes: y.camRes } : {}
|
|
3550
3620
|
};
|
|
3551
|
-
n._setPerf(A),
|
|
3621
|
+
n._setPerf(A), y.rebindCamera && y.camRes !== void 0 && y.camRes !== (v == null ? void 0 : v.camRes) && await n._rebindMedia().catch(() => {
|
|
3552
3622
|
});
|
|
3553
3623
|
};
|
|
3554
|
-
|
|
3624
|
+
p = l.decision.tier, M(l.decision.tier, null);
|
|
3555
3625
|
let x = 0, b = performance.now(), T = 0;
|
|
3556
3626
|
const R = () => {
|
|
3557
3627
|
x += 1, T = requestAnimationFrame(R);
|
|
3558
3628
|
};
|
|
3559
3629
|
T = requestAnimationFrame(R);
|
|
3560
|
-
let
|
|
3630
|
+
let w = null;
|
|
3561
3631
|
const g = window.setInterval(() => {
|
|
3562
3632
|
var G;
|
|
3563
3633
|
if (typeof document < "u" && document.hidden) {
|
|
3564
3634
|
x = 0, b = performance.now();
|
|
3565
3635
|
return;
|
|
3566
3636
|
}
|
|
3567
|
-
const
|
|
3568
|
-
|
|
3637
|
+
const y = performance.now(), v = y - b, A = $e(n, er, w, y);
|
|
3638
|
+
w = { feedFrames: A.session.feedFrames, sampledAt: y };
|
|
3569
3639
|
const E = n.store.getSnapshot().lifecycle === "running", B = {
|
|
3570
3640
|
frameMs: x > 0 && v > 0 && E ? v / x : null,
|
|
3571
3641
|
fps: x > 0 && v > 0 ? x * 1e3 / v : null,
|
|
3572
3642
|
inferenceMs: E ? A.inferenceMsTotal : null,
|
|
3573
3643
|
feedFps: A.session.feedFps,
|
|
3574
|
-
memoryMb:
|
|
3644
|
+
memoryMb: sr(),
|
|
3575
3645
|
...d,
|
|
3576
|
-
thermal:
|
|
3646
|
+
thermal: a.current
|
|
3577
3647
|
};
|
|
3578
|
-
x = 0, b =
|
|
3579
|
-
const K = n.store.getSnapshot().quality ?? l,
|
|
3580
|
-
l =
|
|
3581
|
-
const
|
|
3582
|
-
if (
|
|
3583
|
-
const X =
|
|
3584
|
-
|
|
3648
|
+
x = 0, b = y;
|
|
3649
|
+
const K = n.store.getSnapshot().quality ?? l, L = Zi(K, B, r, y);
|
|
3650
|
+
l = L, n._setQuality(L);
|
|
3651
|
+
const F = $i(L, p);
|
|
3652
|
+
if (F) {
|
|
3653
|
+
const X = p;
|
|
3654
|
+
p = F, M(F, X), (G = o.current) == null || G.call(o, L);
|
|
3585
3655
|
}
|
|
3586
3656
|
}, r.budget.sampleMs);
|
|
3587
3657
|
return () => {
|
|
3588
3658
|
cancelAnimationFrame(T), window.clearInterval(g);
|
|
3589
|
-
const
|
|
3590
|
-
n._setPerf(
|
|
3591
|
-
}),
|
|
3659
|
+
const y = (p == null ? void 0 : p.rebindCamera) && p.camRes !== void 0;
|
|
3660
|
+
n._setPerf(u), y && (u == null ? void 0 : u.camRes) !== (p == null ? void 0 : p.camRes) && n._rebindMedia().catch(() => {
|
|
3661
|
+
}), u = void 0, n._setQualityConfig(null);
|
|
3592
3662
|
};
|
|
3593
3663
|
}, [n, r]), null;
|
|
3594
|
-
},
|
|
3595
|
-
const e =
|
|
3664
|
+
}, it = Lt(void 0), ns = () => {
|
|
3665
|
+
const e = et(it);
|
|
3596
3666
|
if (!e)
|
|
3597
|
-
throw new
|
|
3667
|
+
throw new O(
|
|
3598
3668
|
"XR context can only be used inside XRProvider, did you forget to wrap your app in <XRProvider>?"
|
|
3599
3669
|
);
|
|
3600
3670
|
return e;
|
|
3601
|
-
},
|
|
3602
|
-
const i =
|
|
3603
|
-
return /* @__PURE__ */
|
|
3604
|
-
n !== !1 && /* @__PURE__ */
|
|
3605
|
-
/* @__PURE__ */
|
|
3671
|
+
}, da = () => et(it) ?? null, ha = ({ children: e, perf: s, lifecycle: t, quality: n }) => {
|
|
3672
|
+
const i = zi(s, t), r = xe(() => ({ session: i }), [i]);
|
|
3673
|
+
return de(() => Js(i), [i]), /* @__PURE__ */ Ds(it.Provider, { value: r, children: [
|
|
3674
|
+
n !== !1 && /* @__PURE__ */ xt(nr, { config: n || void 0 }),
|
|
3675
|
+
/* @__PURE__ */ xt(qi, { children: e })
|
|
3606
3676
|
] });
|
|
3607
3677
|
};
|
|
3608
3678
|
export {
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3679
|
+
Or as $,
|
|
3680
|
+
di as A,
|
|
3681
|
+
ye as B,
|
|
3682
|
+
me as C,
|
|
3683
|
+
ta as D,
|
|
3684
|
+
ts as E,
|
|
3685
|
+
na as F,
|
|
3686
|
+
Ti as G,
|
|
3687
|
+
fi as H,
|
|
3688
|
+
Zs as I,
|
|
3689
|
+
q as J,
|
|
3690
|
+
Mr as K,
|
|
3691
|
+
z as L,
|
|
3622
3692
|
J as M,
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3693
|
+
ra as N,
|
|
3694
|
+
br as O,
|
|
3695
|
+
Ee as P,
|
|
3696
|
+
tt as Q,
|
|
3697
|
+
Kt as R,
|
|
3698
|
+
Pt as S,
|
|
3699
|
+
mr as T,
|
|
3700
|
+
fr as U,
|
|
3701
|
+
gr as V,
|
|
3702
|
+
pr as W,
|
|
3703
|
+
At as X,
|
|
3704
|
+
ha as Y,
|
|
3705
|
+
Pn as Z,
|
|
3706
|
+
Rr as _,
|
|
3707
|
+
oa as a,
|
|
3708
|
+
$i as a$,
|
|
3709
|
+
Yt as a0,
|
|
3710
|
+
Fr as a1,
|
|
3711
|
+
Ir as a2,
|
|
3712
|
+
Pr as a3,
|
|
3713
|
+
_r as a4,
|
|
3714
|
+
kr as a5,
|
|
3715
|
+
Ar as a6,
|
|
3716
|
+
Lr as a7,
|
|
3717
|
+
Dn as a8,
|
|
3718
|
+
Tr as a9,
|
|
3719
|
+
Gi as aA,
|
|
3720
|
+
nr as aB,
|
|
3721
|
+
Ze as aC,
|
|
3722
|
+
gi as aD,
|
|
3723
|
+
Xt as aE,
|
|
3724
|
+
Ut as aF,
|
|
3725
|
+
en as aG,
|
|
3726
|
+
tn as aH,
|
|
3727
|
+
sn as aI,
|
|
3728
|
+
Ln as aJ,
|
|
3729
|
+
Xr as aK,
|
|
3730
|
+
Kr as aL,
|
|
3731
|
+
Bn as aM,
|
|
3732
|
+
$s as aN,
|
|
3733
|
+
$e as aO,
|
|
3734
|
+
Vt as aP,
|
|
3735
|
+
Gt as aQ,
|
|
3736
|
+
aa as aR,
|
|
3737
|
+
Vi as aS,
|
|
3738
|
+
mn as aT,
|
|
3739
|
+
ss as aU,
|
|
3740
|
+
Ji as aV,
|
|
3741
|
+
tr as aW,
|
|
3742
|
+
Qi as aX,
|
|
3743
|
+
ji as aY,
|
|
3744
|
+
Xi as aZ,
|
|
3745
|
+
Zi as a_,
|
|
3746
|
+
Br as aa,
|
|
3747
|
+
Er as ab,
|
|
3748
|
+
Cr as ac,
|
|
3749
|
+
Dr as ad,
|
|
3750
|
+
Nr as ae,
|
|
3751
|
+
Wr as af,
|
|
3752
|
+
xn as ag,
|
|
3753
|
+
Hr as ah,
|
|
3754
|
+
Ur as ai,
|
|
3755
|
+
wr as aj,
|
|
3756
|
+
vr as ak,
|
|
3757
|
+
xr as al,
|
|
3758
|
+
Sr as am,
|
|
3759
|
+
qr as an,
|
|
3760
|
+
yr as ao,
|
|
3761
|
+
On as ap,
|
|
3762
|
+
zr as aq,
|
|
3763
|
+
Yr as ar,
|
|
3764
|
+
Qr as as,
|
|
3765
|
+
li as at,
|
|
3766
|
+
mi as au,
|
|
3767
|
+
zt as av,
|
|
3768
|
+
cn as aw,
|
|
3769
|
+
Wt as ax,
|
|
3770
|
+
hr as ay,
|
|
3771
|
+
Z as az,
|
|
3772
|
+
la as b,
|
|
3773
|
+
Ei as b0,
|
|
3774
|
+
sa as b1,
|
|
3775
|
+
Tn as b2,
|
|
3776
|
+
Fn as b3,
|
|
3777
|
+
Ct as b4,
|
|
3778
|
+
yi as b5,
|
|
3779
|
+
pi as b6,
|
|
3780
|
+
wi as b7,
|
|
3781
|
+
bn as b8,
|
|
3782
|
+
Cn as b9,
|
|
3783
|
+
kn as ba,
|
|
3784
|
+
ia as bb,
|
|
3785
|
+
Jr as bc,
|
|
3786
|
+
Vn as bd,
|
|
3787
|
+
Zn as be,
|
|
3788
|
+
$n as bf,
|
|
3789
|
+
te as bg,
|
|
3790
|
+
vn as c,
|
|
3791
|
+
dr as d,
|
|
3792
|
+
ea as e,
|
|
3793
|
+
Nn as f,
|
|
3794
|
+
Vr as g,
|
|
3795
|
+
Gr as h,
|
|
3722
3796
|
Se as i,
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3797
|
+
P as j,
|
|
3798
|
+
Zr as k,
|
|
3799
|
+
ca as l,
|
|
3800
|
+
ur as m,
|
|
3801
|
+
Hn as n,
|
|
3802
|
+
Ge as o,
|
|
3803
|
+
$r as p,
|
|
3804
|
+
Wn as q,
|
|
3805
|
+
Yi as r,
|
|
3806
|
+
qt as s,
|
|
3807
|
+
jr as t,
|
|
3808
|
+
ns as u,
|
|
3809
|
+
qn as v,
|
|
3810
|
+
I as w,
|
|
3811
|
+
da as x,
|
|
3738
3812
|
_ as y,
|
|
3739
|
-
|
|
3813
|
+
wn as z
|
|
3740
3814
|
};
|