@vincentt-xr/sdk 2.0.0-alpha.7 → 2.0.0-alpha.8
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 +1109 -13
- package/dist/{DebuggerUI-BjOMr8q_.js → DebuggerUI-C-ldiozL.js} +1 -1
- package/dist/{DebuggerUI-B6bP6P9r.cjs → DebuggerUI-CWX5EtQv.cjs} +1 -1
- package/dist/FaceMeshRenderer-BEEXZwS6.cjs +158 -0
- package/dist/FaceMeshRenderer-UuH5sTXG.js +1322 -0
- package/dist/FaceRetouch-C7h7x9kd.js +683 -0
- package/dist/FaceRetouch-DqftT26Y.cjs +134 -0
- package/dist/GLTFLoader-C5q63sKO.js +1633 -0
- package/dist/GLTFLoader-Cb_CRwmG.cjs +1 -0
- package/dist/SegmentationOverlay-DQuW3dsc.js +133 -0
- package/dist/SegmentationOverlay-aWVod8Kl.cjs +1 -0
- package/dist/assets/cache.d.ts +99 -0
- package/dist/assets/estimate.d.ts +11 -0
- package/dist/assets/index.d.ts +7 -0
- package/dist/assets/loaders.d.ts +28 -0
- package/dist/assets/react.d.ts +33 -0
- package/dist/calibration/calibration.d.ts +70 -0
- package/dist/calibration/index.d.ts +6 -0
- package/dist/calibration/storage.d.ts +13 -0
- package/dist/calibration/types.d.ts +53 -0
- package/dist/calibration/useXRCalibration.d.ts +46 -0
- package/dist/camera/CameraPermissionGate.d.ts +26 -0
- package/dist/camera/devices.d.ts +26 -0
- package/dist/camera/index.d.ts +8 -0
- package/dist/camera/permission.d.ts +86 -0
- package/dist/camera/useCameraPermission.d.ts +35 -0
- package/dist/capabilities/detect.d.ts +45 -0
- package/dist/capabilities/index.d.ts +5 -0
- package/dist/capabilities/types.d.ts +120 -0
- package/dist/capabilities/useXRCapabilities.d.ts +18 -0
- package/dist/compat/environment.d.ts +5 -0
- package/dist/compat/index.d.ts +4 -0
- package/dist/compat/run.d.ts +18 -0
- package/dist/compat/scenarios.d.ts +10 -0
- package/dist/compat/types.d.ts +101 -0
- package/dist/components/BodyTracker/index.d.ts +9 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +33 -3
- package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +12 -0
- package/dist/components/FaceMesh/canonical/shaders.d.ts +1 -1
- package/dist/components/FaceMesh/index.d.ts +1 -1
- package/dist/components/GestureListener/index.d.ts +11 -0
- package/dist/components/HandTracker/index.d.ts +10 -0
- package/dist/components/HolisticTracker/index.d.ts +69 -0
- package/dist/components/HolisticTracker/settings.d.ts +58 -0
- package/dist/components/HolisticTracker/signals.d.ts +49 -0
- package/dist/components/IrisEffect/IrisMaterial.d.ts +73 -0
- package/dist/components/IrisEffect/index.d.ts +51 -0
- package/dist/components/IrisEffect/settings.d.ts +117 -0
- package/dist/components/LipEffect/LipEffect.d.ts +7 -1
- package/dist/components/LipEffect/LipEffectMaterial.d.ts +43 -7
- package/dist/components/LipEffect/LipEffects.d.ts +9 -0
- package/dist/components/LipEffect/defaults.d.ts +27 -4
- package/dist/components/LipEffect/index.d.ts +11 -3
- package/dist/components/LipEffect/settings.d.ts +271 -0
- package/dist/components/LipEffect/types.d.ts +56 -9
- package/dist/components/LipEffect/useLipDesignTextures.d.ts +11 -0
- package/dist/components/LipEffect/uvGuide.d.ts +59 -0
- package/dist/components/PersonCutout/index.d.ts +50 -0
- package/dist/components/PersonCutout/personCutout.d.ts +16 -0
- package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +1 -1
- package/dist/components/ScreenImage/index.d.ts +3 -1
- package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +1 -1
- package/dist/components/ScreenImage/materials/ScreenImageMaskMaterial.d.ts +11 -0
- package/dist/components/ScreenImage/source.d.ts +6 -0
- package/dist/components/ScreenImage/types.d.ts +18 -0
- package/dist/components/SegmentationOverlay/SegmentationOverlay.d.ts +37 -0
- package/dist/components/SegmentationOverlay/SegmentationOverlayMaterial.d.ts +31 -0
- package/dist/components/SegmentationOverlay/index.d.ts +9 -0
- package/dist/components/SegmentationOverlay/maskTexture.d.ts +23 -0
- package/dist/components/SegmentationOverlay/providers.d.ts +72 -0
- package/dist/components/SegmentationOverlay/settings.d.ts +65 -0
- package/dist/components/XRProvider/index.d.ts +16 -2
- package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +1 -1
- package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +1 -1
- package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/constants/index.d.ts +4 -1
- package/dist/contexts-CO0sd4JQ.cjs +1 -0
- package/dist/{contexts-ByhzppYl.js → contexts-FzlnnMYD.js} +252 -246
- package/dist/coordinates/feed.d.ts +52 -0
- package/dist/coordinates/index.d.ts +5 -0
- package/dist/coordinates/spaces.d.ts +49 -0
- package/dist/coordinates/viewport.d.ts +22 -0
- package/dist/coordinates/world.d.ts +15 -0
- package/dist/debug-ui/gesture-settings/index.d.ts +14 -0
- package/dist/debug-ui/holistic-tracker-settings/index.d.ts +16 -0
- package/dist/debug-ui/index.d.ts +14 -0
- package/dist/debug-ui/iris-effect-settings/index.d.ts +12 -0
- package/dist/debug-ui/lip-effect-settings/index.d.ts +15 -0
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +1 -1
- package/dist/debug-ui/product-hotspots/index.d.ts +24 -0
- package/dist/debug-ui/segmentation-overlay-settings/index.d.ts +12 -0
- package/dist/debug-ui/xr-diagnostics/index.d.ts +25 -0
- package/dist/debug-ui.cjs +3 -3
- package/dist/debug-ui.js +2057 -1687
- package/dist/detector-K8aej4MB.js +59 -0
- package/dist/detector-ijypGtse.cjs +1 -0
- package/dist/entries/core.d.ts +18 -1
- package/dist/entries/face-effects.d.ts +11 -3
- package/dist/entries/low-level.d.ts +22 -3
- package/dist/entries/product.d.ts +11 -0
- package/dist/entries/tracking.d.ts +24 -1
- package/dist/face-effects.cjs +155 -1
- package/dist/face-effects.js +1134 -2197
- package/dist/gestures/definitions.d.ts +85 -0
- package/dist/gestures/detector.d.ts +87 -0
- package/dist/gestures/index.d.ts +8 -0
- package/dist/gestures/measures.d.ts +101 -0
- package/dist/gestures/settings.d.ts +49 -0
- package/dist/{getFaceInfo-C4QpCQIY.js → getFaceInfo-BkZfaQs-.js} +5 -5
- package/dist/{getFaceInfo-fA1bFBub.cjs → getFaceInfo-ahPxQFGu.cjs} +1 -1
- package/dist/hooks/selectors.d.ts +68 -1
- package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
- package/dist/hooks/useFaceInfo.d.ts +13 -1
- package/dist/hooks/useFaceInfos.d.ts +1 -1
- package/dist/hooks/useGesture.d.ts +32 -0
- package/dist/hooks/useIrisTracking.d.ts +45 -0
- package/dist/hooks/useXRDiagnostics.d.ts +81 -0
- package/dist/hooks/useXRModel.d.ts +7 -0
- package/dist/hooks/useXRSession/facade.d.ts +42 -2
- package/dist/hooks/useXRSession/index.d.ts +2 -2
- package/dist/hooks/useXRSession/reason.d.ts +3 -1
- package/dist/hooks/useXRSession/registry.d.ts +14 -0
- package/dist/hooks/useXRSession/store.d.ts +52 -3
- package/dist/index--RgGzZ6X.cjs +47 -0
- package/dist/{index-VJ0SJwmG.js → index-CHVbH0hz.js} +4 -4
- package/dist/index-CeVkgsag.cjs +1 -0
- package/dist/index-CnGox6Xr.js +3054 -0
- package/dist/{index-ByoNj0QP.js → index-CsUdQ-pn.js} +113 -111
- package/dist/{index-BjmTe9eM.cjs → index-DKBAh6hV.cjs} +1 -1
- package/dist/index-DsZwTfG0.cjs +1 -0
- package/dist/index-Dw6tj2Mi.js +144 -0
- package/dist/index-OCPjOaeP.cjs +1 -0
- package/dist/{index-DXT3WccE.js → index-s9pF4zkG.js} +1065 -1101
- package/dist/internal-BYza1h8_.cjs +1 -0
- package/dist/{internal-Dmk1cTXq.js → internal-vsfNQycj.js} +15 -16
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/iris/compute.d.ts +25 -0
- package/dist/iris/index.d.ts +4 -0
- package/dist/iris/lead.d.ts +19 -0
- package/dist/iris/types.d.ts +87 -0
- package/dist/landmarkMask-CbTFzBYG.js +224 -0
- package/dist/landmarkMask-u7es2k4X.cjs +1 -0
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +1085 -634
- package/dist/main.cjs +1 -1
- package/dist/main.js +1519 -465
- package/dist/measures-9dQPdw96.js +154 -0
- package/dist/measures-KfJzpvod.cjs +1 -0
- package/dist/models/Base/index.d.ts +49 -0
- package/dist/models/Body/index.d.ts +1 -1
- package/dist/models/Face/index.d.ts +1 -1
- package/dist/models/Hand/GestureTracking.d.ts +1 -1
- package/dist/models/Hand/HandTracking.d.ts +1 -1
- package/dist/models/Holistic/index.d.ts +49 -0
- package/dist/models/Holistic/result.d.ts +68 -0
- package/dist/models/SemanticSegmentation/index.d.ts +31 -0
- package/dist/models/SemanticSegmentation/presets.d.ts +28 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/product/ProductDimensions.d.ts +16 -0
- package/dist/product/ProductHotspot.d.ts +16 -0
- package/dist/product/ProductViewer.d.ts +9 -0
- package/dist/product/details.d.ts +53 -0
- package/dist/product/index.d.ts +14 -0
- package/dist/product/loadModelViewer.d.ts +4 -0
- package/dist/product/types.d.ts +71 -0
- package/dist/product/useProductAr.d.ts +37 -0
- package/dist/product/useProductDetails.d.ts +60 -0
- package/dist/product.cjs +1 -0
- package/dist/product.js +414 -0
- package/dist/providers-C0Dlhh9Z.js +365 -0
- package/dist/providers-YNwkmNeK.cjs +62 -0
- package/dist/quality/XRQualityController.d.ts +25 -0
- package/dist/quality/controller.d.ts +33 -0
- package/dist/quality/index.d.ts +6 -0
- package/dist/quality/types.d.ts +100 -0
- package/dist/quality/useXRQuality.d.ts +28 -0
- package/dist/{renderGroups-KZk6eRiY.js → renderGroups-CN1cGFUo.js} +1 -1
- package/dist/{renderGroups-80H3DpTl.cjs → renderGroups-O4KmaMl9.cjs} +1 -1
- package/dist/renderPasses-Cg-zqmEz.cjs +21 -0
- package/dist/renderPasses-NnKZVfBy.js +1460 -0
- package/dist/scene-object.cjs +1 -1
- package/dist/scene-object.js +2 -2
- package/dist/screenTransform-BenfCtZt.js +44 -0
- package/dist/screenTransform-BiXdpVf0.cjs +1 -0
- package/dist/segmentation-9PhSvc-R.cjs +1 -0
- package/dist/segmentation-CeOTKemr.js +5 -0
- package/dist/segmentation2d/faceMemory.d.ts +28 -0
- package/dist/segmentation2d/faceRegions.d.ts +24 -0
- package/dist/segmentation2d/index.d.ts +9 -0
- package/dist/segmentation2d/maskUv.d.ts +23 -0
- package/dist/segmentation2d/rasterize.d.ts +14 -0
- package/dist/segmentation2d/types.d.ts +46 -0
- package/dist/selectors-C5G1PMYL.js +195 -0
- package/dist/selectors-Du_PsVnW.cjs +1 -0
- package/dist/{session-CpkiK5YA.cjs → session-BBr0yN8h.cjs} +7 -7
- package/dist/{session-DLFN_VII.js → session-Cy0m7l7-.js} +76 -76
- package/dist/settings-DRR7-snV.cjs +1 -0
- package/dist/settings-aQk845NJ.js +73 -0
- package/dist/subjects/index.d.ts +2 -0
- package/dist/subjects/select.d.ts +62 -0
- package/dist/subjects/types.d.ts +55 -0
- package/dist/tracking-config/apply.d.ts +57 -0
- package/dist/tracking-config/index.d.ts +7 -0
- package/dist/tracking-config/resolve.d.ts +25 -0
- package/dist/tracking-config/storage.d.ts +8 -0
- package/dist/tracking-config/types.d.ts +106 -0
- package/dist/tracking-config/useXRTrackingConfig.d.ts +38 -0
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +1056 -383
- package/dist/types/compositor.d.ts +21 -0
- package/dist/types/holistic.d.ts +121 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/model.d.ts +22 -2
- package/dist/types/nodes.d.ts +27 -2
- package/dist/types/segmentation.d.ts +19 -0
- package/dist/types/session.d.ts +41 -3
- package/dist/useFaceInfo-Blf7FCu3.js +303 -0
- package/dist/useFaceInfo-C5mO8NQY.cjs +1 -0
- package/dist/useXRCapabilities-B1R2ghy-.cjs +1 -0
- package/dist/useXRCapabilities-C68v__wB.js +30 -0
- package/dist/utils/fns.d.ts +6 -3
- package/dist/utils/integrity.d.ts +4 -1
- package/dist/utils/updateThrottle.d.ts +2 -0
- package/dist/utils/useStableUniforms.d.ts +18 -0
- package/docs/api/adaptive-quality.mdx +104 -0
- package/docs/api/asset-lifecycle.mdx +78 -0
- package/docs/api/camera-permission.mdx +142 -0
- package/docs/api/coordinate-spaces.mdx +165 -0
- package/docs/api/cross-camera.mdx +88 -0
- package/docs/api/diagnostics-calibration.mdx +97 -0
- package/docs/api/face-effects.mdx +6 -0
- package/docs/api/face-mesh.mdx +4 -2
- package/docs/api/gestures.mdx +173 -0
- package/docs/api/holistic-tracker.mdx +159 -0
- package/docs/api/iris-tracking.mdx +242 -0
- package/docs/api/multi-subject.mdx +95 -0
- package/docs/api/person-cutout.mdx +136 -0
- package/docs/api/product-ar.mdx +111 -0
- package/docs/api/product-details.mdx +78 -0
- package/docs/api/screen-space-coordinates.mdx +4 -1
- package/docs/api/segmentation-overlay.mdx +301 -0
- package/docs/api/session-lifecycle.mdx +136 -0
- package/docs/api/trackers.mdx +5 -0
- package/docs/api/tracking-config.mdx +108 -0
- package/docs/docs.json +23 -1
- package/docs/examples/lip-shaders.mdx +224 -0
- package/docs/guides/lip-effect-textures.mdx +292 -0
- package/docs/guides/lip-uv-template.png +0 -0
- package/docs/guides/lip-uv-template.svg +1 -0
- package/package.json +13 -1
- package/dist/FaceMeshRenderer-C5l6VLdO.cjs +0 -155
- package/dist/FaceMeshRenderer-wjAHrJzP.js +0 -1270
- package/dist/FaceRetouch-BkJzoA79.cjs +0 -134
- package/dist/FaceRetouch-DwbKQJAN.js +0 -551
- package/dist/contexts-Dr62It_K.cjs +0 -1
- package/dist/index-9dlAQAhy.js +0 -1462
- package/dist/index-BpEf2BBb.cjs +0 -1
- package/dist/index-CyUUurQT.cjs +0 -1
- package/dist/index-DCiMbxC3.cjs +0 -1
- package/dist/index-DpI-qo5X.cjs +0 -17
- package/dist/index-DyVF4vEW.js +0 -111
- package/dist/internal-Cq-TEQ5Y.cjs +0 -1
- package/dist/renderLayers-lDtL0_43.cjs +0 -1
- package/dist/renderLayers-zrK2pv5O.js +0 -13
- package/dist/renderPasses-BOoBSr8z.cjs +0 -21
- package/dist/renderPasses-BcquyVtu.js +0 -1500
- package/dist/selectors-B8H97CKA.js +0 -59
- package/dist/selectors-CZLKT2Iv.cjs +0 -1
- package/dist/useFaceInfo-BJ8-_MOs.cjs +0 -1
- package/dist/useFaceInfo-Dk426LTu.js +0 -62
- package/dist/useFaceResults-CtetsO9M.js +0 -19
- package/dist/useFaceResults-wBJF3zyp.cjs +0 -1
package/dist/tracking.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { d as
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { useThree as
|
|
5
|
-
import { useRef as
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { a as
|
|
15
|
-
import { D as
|
|
16
|
-
import { d as
|
|
17
|
-
|
|
1
|
+
import { u as U, T as q, r as $e } from "./index-CsUdQ-pn.js";
|
|
2
|
+
import { d as Mr, c as Fr, b as Pr } from "./index-CsUdQ-pn.js";
|
|
3
|
+
import { jsx as b, Fragment as Ze } from "react/jsx-runtime";
|
|
4
|
+
import { useThree as Z, useFrame as D } from "@react-three/fiber";
|
|
5
|
+
import { useRef as g, useMemo as E, useCallback as O, useContext as Qe, useEffect as k, useState as B, createContext as et, useSyncExternalStore as tt } from "react";
|
|
6
|
+
import { X as I, r as L, v as rt, o as Le, i as nt, u as He, p as st } from "./index-CnGox6Xr.js";
|
|
7
|
+
import { y as Br, w as Ur, D as jr, x as Gr, b as Kr, e as zr, n as Wr, t as Xr } from "./index-CnGox6Xr.js";
|
|
8
|
+
import { R as J } from "./selectors-C5G1PMYL.js";
|
|
9
|
+
import { a as ke } from "./segmentation-CeOTKemr.js";
|
|
10
|
+
import { S as Vr } from "./segmentation-CeOTKemr.js";
|
|
11
|
+
import { B as Jr, D as $r, F as Zr, H as Qr, b as en, g as tn } from "./index-Dw6tj2Mi.js";
|
|
12
|
+
import { r as _e, c as me, s as Be, a as ot, g as it } from "./detector-K8aej4MB.js";
|
|
13
|
+
import { D as nn } from "./detector-K8aej4MB.js";
|
|
14
|
+
import { a as A, c as at, b as ct } from "./getFaceInfo-BkZfaQs-.js";
|
|
15
|
+
import { D as on, d as an, h as cn } from "./getFaceInfo-BkZfaQs-.js";
|
|
16
|
+
import { O as ut, m as lt, a as G, b as we, c as K, d as dt, e as ht, f as ft, g as mt } from "./measures-9dQPdw96.js";
|
|
17
|
+
import { u as ln } from "./measures-9dQPdw96.js";
|
|
18
|
+
import { u as pt } from "./useFaceInfo-Blf7FCu3.js";
|
|
19
|
+
import { b as hn, D as fn, E as mn, X as pn, a as gn, f as Tn, j as Sn, s as yn, c as Rn } from "./useFaceInfo-Blf7FCu3.js";
|
|
20
|
+
import { S as bn, u as An } from "./SegmentationOverlay-DQuW3dsc.js";
|
|
21
|
+
import { d as gt } from "./drawNormalizedCrop-CRdIDyl1.js";
|
|
22
|
+
import { b as vn, D as On, G as Ln, H as kn, a as _n, c as wn, p as Dn, d as In, r as Nn, t as Cn } from "./settings-aQk845NJ.js";
|
|
23
|
+
import { h as Fn, i as Pn, P as Hn, e as Bn, f as Un, g as jn } from "./providers-C0Dlhh9Z.js";
|
|
24
|
+
import { D as Kn, f as zn, r as Wn } from "./landmarkMask-CbTFzBYG.js";
|
|
25
|
+
const Ue = {
|
|
18
26
|
"hand.wrist": 0,
|
|
19
27
|
"hand.thumbTip": 4,
|
|
20
28
|
"hand.indexTip": 8,
|
|
@@ -26,9 +34,9 @@ const re = {
|
|
|
26
34
|
"hand.ringBase": 13,
|
|
27
35
|
"hand.pinkyBase": 17
|
|
28
36
|
};
|
|
29
|
-
function
|
|
30
|
-
var
|
|
31
|
-
const n = (
|
|
37
|
+
function je(e, r, t = 0) {
|
|
38
|
+
var s;
|
|
39
|
+
const n = (s = e == null ? void 0 : e.hands) != null && s.length ? e.hands : e != null && e.coordinates ? [
|
|
32
40
|
{
|
|
33
41
|
coordinates: e.coordinates,
|
|
34
42
|
gesture: e.gesture,
|
|
@@ -36,60 +44,55 @@ function oe(e, t, r = 0) {
|
|
|
36
44
|
}
|
|
37
45
|
] : [];
|
|
38
46
|
if (n.length) {
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
47
|
+
if (r) {
|
|
48
|
+
const o = n.find((a) => a.handedness === r);
|
|
49
|
+
if (o) return o;
|
|
42
50
|
}
|
|
43
|
-
return n[
|
|
51
|
+
return n[t] ?? n[0];
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
|
-
const
|
|
54
|
+
const mr = ({
|
|
47
55
|
children: e,
|
|
48
|
-
hand:
|
|
49
|
-
handIndex:
|
|
56
|
+
hand: r,
|
|
57
|
+
handIndex: t = 0,
|
|
50
58
|
targetFps: n,
|
|
51
|
-
active:
|
|
59
|
+
active: s = !0
|
|
52
60
|
}) => {
|
|
53
|
-
const
|
|
61
|
+
const o = g(null), a = E(
|
|
54
62
|
() => n === void 0 ? void 0 : { targetFps: n },
|
|
55
63
|
[n]
|
|
56
|
-
), { ready:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
), { camera:
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
if (!
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
|
|
64
|
+
), { ready: i, node: u } = U(
|
|
65
|
+
I.HAND_TRACKER,
|
|
66
|
+
a,
|
|
67
|
+
s
|
|
68
|
+
), { camera: c } = Z(), h = g(c);
|
|
69
|
+
h.current !== c && (h.current = c);
|
|
70
|
+
const d = g(null);
|
|
71
|
+
D(() => {
|
|
72
|
+
var l;
|
|
73
|
+
if (!i || !u || !o.current) return;
|
|
74
|
+
const S = je(u, r, t);
|
|
75
|
+
d.current = S ?? null;
|
|
76
|
+
const T = (l = S == null ? void 0 : S.coordinates) == null ? void 0 : l[0];
|
|
77
|
+
if (!T) {
|
|
78
|
+
o.current.visible = !1;
|
|
71
79
|
return;
|
|
72
80
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
81
|
+
const y = L(T, h.current);
|
|
82
|
+
o.current.visible = !0, o.current.position.copy(y);
|
|
75
83
|
});
|
|
76
|
-
const
|
|
77
|
-
var
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
return
|
|
82
|
-
}, []),
|
|
83
|
-
() => ({ type: "hand", resolveLandmark:
|
|
84
|
-
[
|
|
84
|
+
const m = O((S) => {
|
|
85
|
+
var l, p;
|
|
86
|
+
const T = Ue[S];
|
|
87
|
+
if (T === void 0) return null;
|
|
88
|
+
const y = (p = (l = d.current) == null ? void 0 : l.coordinates) == null ? void 0 : p[T];
|
|
89
|
+
return y ? { position: L(y, h.current) } : null;
|
|
90
|
+
}, []), f = E(
|
|
91
|
+
() => ({ type: "hand", resolveLandmark: m }),
|
|
92
|
+
[m]
|
|
85
93
|
);
|
|
86
|
-
return /* @__PURE__ */
|
|
87
|
-
},
|
|
88
|
-
const r = new U.Vector3(e.x, e.y, e.z);
|
|
89
|
-
r.unproject(t);
|
|
90
|
-
const n = r.sub(t.position).normalize(), o = -t.position.z / n.z;
|
|
91
|
-
return t.position.clone().add(n.multiplyScalar(o));
|
|
92
|
-
}, se = {
|
|
94
|
+
return /* @__PURE__ */ b(q.Provider, { value: f, children: /* @__PURE__ */ b("group", { ref: o, renderOrder: J.TRACKED, children: e }) });
|
|
95
|
+
}, Tt = {
|
|
93
96
|
"hand.wrist": 0,
|
|
94
97
|
"hand.thumbTip": 4,
|
|
95
98
|
"hand.indexTip": 8,
|
|
@@ -100,46 +103,41 @@ const Ne = ({
|
|
|
100
103
|
"hand.middleBase": 9,
|
|
101
104
|
"hand.ringBase": 13,
|
|
102
105
|
"hand.pinkyBase": 17
|
|
103
|
-
},
|
|
104
|
-
const n =
|
|
105
|
-
() =>
|
|
106
|
-
[
|
|
107
|
-
), { ready:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
), { camera:
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
var
|
|
116
|
-
if (!
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
if (!
|
|
106
|
+
}, pr = ({ children: e, targetFps: r, active: t = !0 }) => {
|
|
107
|
+
const n = g(null), s = E(
|
|
108
|
+
() => r === void 0 ? void 0 : { targetFps: r },
|
|
109
|
+
[r]
|
|
110
|
+
), { ready: o, node: a } = U(
|
|
111
|
+
I.GESTURE_TRACKER,
|
|
112
|
+
s,
|
|
113
|
+
t
|
|
114
|
+
), { camera: i } = Z(), u = g(i);
|
|
115
|
+
u.current !== i && (u.current = i);
|
|
116
|
+
const c = g(null);
|
|
117
|
+
D(() => {
|
|
118
|
+
var S;
|
|
119
|
+
if (!o || !a || !n.current) return;
|
|
120
|
+
c.current = a;
|
|
121
|
+
const m = (S = a == null ? void 0 : a.coordinates) == null ? void 0 : S[0];
|
|
122
|
+
if (!m) {
|
|
120
123
|
n.current.visible = !1;
|
|
121
124
|
return;
|
|
122
125
|
}
|
|
123
|
-
const
|
|
124
|
-
n.current.visible = !0, n.current.position.copy(
|
|
126
|
+
const f = L(m, u.current);
|
|
127
|
+
n.current.visible = !0, n.current.position.copy(f);
|
|
125
128
|
});
|
|
126
|
-
const
|
|
127
|
-
var
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
const
|
|
131
|
-
return
|
|
132
|
-
}, []),
|
|
133
|
-
() => ({ type: "hand", resolveLandmark:
|
|
134
|
-
[
|
|
129
|
+
const h = O((m) => {
|
|
130
|
+
var T, y;
|
|
131
|
+
const f = Tt[m];
|
|
132
|
+
if (f === void 0) return null;
|
|
133
|
+
const S = (y = (T = c.current) == null ? void 0 : T.coordinates) == null ? void 0 : y[f];
|
|
134
|
+
return S ? { position: L(S, u.current) } : null;
|
|
135
|
+
}, []), d = E(
|
|
136
|
+
() => ({ type: "hand", resolveLandmark: h }),
|
|
137
|
+
[h]
|
|
135
138
|
);
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
},
|
|
138
|
-
const r = new U.Vector3(e.x, e.y, e.z);
|
|
139
|
-
r.unproject(t);
|
|
140
|
-
const n = r.sub(t.position).normalize(), o = -t.position.z / n.z;
|
|
141
|
-
return t.position.clone().add(n.multiplyScalar(o));
|
|
142
|
-
}, ue = {
|
|
139
|
+
return /* @__PURE__ */ b(q.Provider, { value: d, children: /* @__PURE__ */ b("group", { ref: n, renderOrder: J.TRACKED, children: e }) });
|
|
140
|
+
}, Ge = {
|
|
143
141
|
"body.head": 0,
|
|
144
142
|
"body.leftShoulder": 11,
|
|
145
143
|
"body.rightShoulder": 12,
|
|
@@ -153,150 +151,321 @@ const Ne = ({
|
|
|
153
151
|
"body.rightKnee": 26,
|
|
154
152
|
"body.leftAnkle": 27,
|
|
155
153
|
"body.rightAnkle": 28
|
|
156
|
-
},
|
|
157
|
-
const n =
|
|
158
|
-
|
|
154
|
+
}, gr = ({ bodyIndex: e = 0, active: r = !0, children: t }) => {
|
|
155
|
+
const n = g(null), { ready: s, node: o } = U(
|
|
156
|
+
I.BODY_TRACKER,
|
|
159
157
|
void 0,
|
|
160
|
-
|
|
161
|
-
), { camera:
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
if (!
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
if (!
|
|
158
|
+
r
|
|
159
|
+
), { camera: a } = Z(), i = g(a);
|
|
160
|
+
i.current !== a && (i.current = a);
|
|
161
|
+
const u = g(null);
|
|
162
|
+
D(() => {
|
|
163
|
+
if (!s || !o || !n.current) return;
|
|
164
|
+
const d = o;
|
|
165
|
+
u.current = d;
|
|
166
|
+
const m = d.getLandmarks2D(e), f = m == null ? void 0 : m[0];
|
|
167
|
+
if (!f) {
|
|
170
168
|
n.current.visible = !1;
|
|
171
169
|
return;
|
|
172
170
|
}
|
|
173
|
-
const
|
|
174
|
-
n.current.visible = !0, n.current.position.copy(
|
|
171
|
+
const S = L(f, i.current);
|
|
172
|
+
n.current.visible = !0, n.current.position.copy(S);
|
|
175
173
|
});
|
|
176
|
-
const
|
|
177
|
-
(
|
|
178
|
-
const
|
|
174
|
+
const c = O(
|
|
175
|
+
(d) => {
|
|
176
|
+
const m = u.current;
|
|
177
|
+
if (!m) return null;
|
|
178
|
+
const f = m.getLandmarks2D(e);
|
|
179
179
|
if (!f) return null;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const p =
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
y: (p.y + m.y) / 2,
|
|
188
|
-
z: (p.z + m.z) / 2
|
|
180
|
+
if (d === "body.neck") {
|
|
181
|
+
const y = f[11], l = f[12];
|
|
182
|
+
if (!y || !l) return null;
|
|
183
|
+
const p = {
|
|
184
|
+
x: (y.x + l.x) / 2,
|
|
185
|
+
y: (y.y + l.y) / 2,
|
|
186
|
+
z: (y.z + l.z) / 2
|
|
189
187
|
};
|
|
190
|
-
return { position:
|
|
188
|
+
return { position: L(p, i.current) };
|
|
191
189
|
}
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
return
|
|
190
|
+
const S = Ge[d];
|
|
191
|
+
if (S === void 0) return null;
|
|
192
|
+
const T = f[S];
|
|
193
|
+
return T ? { position: L(T, i.current) } : null;
|
|
194
|
+
},
|
|
195
|
+
[e]
|
|
196
|
+
), h = E(
|
|
197
|
+
() => ({ type: "body", resolveLandmark: c }),
|
|
198
|
+
[c]
|
|
199
|
+
);
|
|
200
|
+
return /* @__PURE__ */ b(q.Provider, { value: h, children: /* @__PURE__ */ b("group", { ref: n, renderOrder: J.TRACKED, children: t }) });
|
|
201
|
+
}, te = { leftShoulder: 11, rightShoulder: 12, leftWrist: 15, rightWrist: 16 }, St = 0, yt = [
|
|
202
|
+
[5, 8],
|
|
203
|
+
[9, 12],
|
|
204
|
+
[13, 16],
|
|
205
|
+
[17, 20]
|
|
206
|
+
], pe = {
|
|
207
|
+
smile: 0.3,
|
|
208
|
+
mouthOpen: 0.25,
|
|
209
|
+
minVisibility: 0.5,
|
|
210
|
+
fingerExtension: 1.25
|
|
211
|
+
}, Rt = () => ({
|
|
212
|
+
facePresent: !1,
|
|
213
|
+
leftHandPresent: !1,
|
|
214
|
+
rightHandPresent: !1,
|
|
215
|
+
posePresent: !1,
|
|
216
|
+
smile: 0,
|
|
217
|
+
mouthOpen: 0,
|
|
218
|
+
smiling: !1,
|
|
219
|
+
mouthIsOpen: !1,
|
|
220
|
+
leftHandRaised: !1,
|
|
221
|
+
rightHandRaised: !1,
|
|
222
|
+
leftPalmOpen: !1,
|
|
223
|
+
rightPalmOpen: !1,
|
|
224
|
+
greeting: null
|
|
225
|
+
}), De = (e, r) => Math.hypot(e.x - r.x, e.y - r.y), Ie = (e, r = pe.fingerExtension) => {
|
|
226
|
+
if (!e || e.landmarks.length < 21) return !1;
|
|
227
|
+
const t = e.landmarks[St];
|
|
228
|
+
let n = 0;
|
|
229
|
+
for (const [s, o] of yt) {
|
|
230
|
+
const a = De(e.landmarks[s], t), i = De(e.landmarks[o], t);
|
|
231
|
+
a > 0 && i >= a * r && (n += 1);
|
|
232
|
+
}
|
|
233
|
+
return n >= 3;
|
|
234
|
+
}, Ne = (e, r, t = pe.minVisibility) => {
|
|
235
|
+
const { pose: n } = e;
|
|
236
|
+
if (!n || n.landmarks.length < 33) return !1;
|
|
237
|
+
const s = r === "left" ? te.leftWrist : te.rightWrist, o = r === "left" ? te.leftShoulder : te.rightShoulder;
|
|
238
|
+
return n.visibility[s] < t || n.visibility[o] < t ? !1 : n.landmarks[s].y > n.landmarks[o].y;
|
|
239
|
+
}, Tr = (e, r = {}, t = Rt()) => {
|
|
240
|
+
const n = { ...pe, ...r }, { face: s, leftHand: o, rightHand: a, pose: i } = e;
|
|
241
|
+
t.facePresent = s !== null, t.leftHandPresent = o !== null, t.rightHandPresent = a !== null, t.posePresent = i !== null;
|
|
242
|
+
const u = s == null ? void 0 : s.blendshapes;
|
|
243
|
+
return t.smile = u ? ((u.mouthSmileLeft ?? 0) + (u.mouthSmileRight ?? 0)) / 2 : 0, t.mouthOpen = (u == null ? void 0 : u.jawOpen) ?? 0, t.smiling = s !== null && t.smile >= n.smile, t.mouthIsOpen = s !== null && t.mouthOpen >= n.mouthOpen, t.leftHandRaised = Ne(e, "left", n.minVisibility), t.rightHandRaised = Ne(e, "right", n.minVisibility), t.leftPalmOpen = Ie(o, n.fingerExtension), t.rightPalmOpen = Ie(a, n.fingerExtension), t.smiling && t.rightHandRaised && t.rightPalmOpen ? t.greeting = "right" : t.smiling && t.leftHandRaised && t.leftPalmOpen ? t.greeting = "left" : t.greeting = null, t;
|
|
244
|
+
}, Et = {
|
|
245
|
+
node: null,
|
|
246
|
+
ready: !1,
|
|
247
|
+
status: "loading",
|
|
248
|
+
error: null
|
|
249
|
+
}, Ke = et(null), bt = () => Qe(Ke) ?? Et, Ce = (e, r) => r ? "error" : e ? e.getStatus() : "loading", At = ({
|
|
250
|
+
children: e,
|
|
251
|
+
active: r = !0,
|
|
252
|
+
onStatusChange: t,
|
|
253
|
+
modelUrl: n,
|
|
254
|
+
delegate: s,
|
|
255
|
+
minFaceDetectionConfidence: o,
|
|
256
|
+
minFacePresenceConfidence: a,
|
|
257
|
+
minPoseDetectionConfidence: i,
|
|
258
|
+
minPosePresenceConfidence: u,
|
|
259
|
+
minHandLandmarksConfidence: c,
|
|
260
|
+
outputFaceBlendshapes: h,
|
|
261
|
+
targetFps: d,
|
|
262
|
+
hands: m,
|
|
263
|
+
analysisMaxDimension: f,
|
|
264
|
+
holdMs: S,
|
|
265
|
+
predictMs: T
|
|
266
|
+
}) => {
|
|
267
|
+
const y = E(() => {
|
|
268
|
+
const R = {};
|
|
269
|
+
return n !== void 0 && (R.modelUrl = n), s !== void 0 && (R.delegate = s), o !== void 0 && (R.minFaceDetectionConfidence = o), a !== void 0 && (R.minFacePresenceConfidence = a), i !== void 0 && (R.minPoseDetectionConfidence = i), u !== void 0 && (R.minPosePresenceConfidence = u), c !== void 0 && (R.minHandLandmarksConfidence = c), h !== void 0 && (R.outputFaceBlendshapes = h), d !== void 0 && (R.targetFps = d), Object.keys(R).length > 0 ? R : void 0;
|
|
270
|
+
}, [
|
|
271
|
+
s,
|
|
272
|
+
o,
|
|
273
|
+
a,
|
|
274
|
+
c,
|
|
275
|
+
i,
|
|
276
|
+
u,
|
|
277
|
+
n,
|
|
278
|
+
h,
|
|
279
|
+
d
|
|
280
|
+
]), { ready: l, node: p, error: _ } = U(
|
|
281
|
+
I.HOLISTIC_TRACKER,
|
|
282
|
+
y,
|
|
283
|
+
r
|
|
284
|
+
);
|
|
285
|
+
k(() => {
|
|
286
|
+
p && p.setOptions(
|
|
287
|
+
rt({ hands: m, analysisMaxDimension: f, holdMs: S, predictMs: T })
|
|
288
|
+
);
|
|
289
|
+
}, [p, m, f, S, T]);
|
|
290
|
+
const [x, N] = B(() => Ce(p, _)), F = g(x), C = g(t);
|
|
291
|
+
C.current = t, D(() => {
|
|
292
|
+
var j;
|
|
293
|
+
const R = Ce(p, _);
|
|
294
|
+
R !== F.current && (F.current = R, N(R), (j = C.current) == null || j.call(C, R, _ ?? (p == null ? void 0 : p.getError()) ?? null));
|
|
295
|
+
});
|
|
296
|
+
const Q = E(
|
|
297
|
+
() => ({
|
|
298
|
+
node: p,
|
|
299
|
+
ready: l && x === "ready",
|
|
300
|
+
status: x,
|
|
301
|
+
error: _ ?? (p == null ? void 0 : p.getError()) ?? null
|
|
302
|
+
}),
|
|
303
|
+
[p, l, x, _]
|
|
304
|
+
);
|
|
305
|
+
return /* @__PURE__ */ b(Ke.Provider, { value: Q, children: e });
|
|
306
|
+
}, xt = () => {
|
|
307
|
+
const { camera: e } = Z(), r = g(e);
|
|
308
|
+
return r.current !== e && (r.current = e), r;
|
|
309
|
+
}, ge = (e, r) => {
|
|
310
|
+
const t = g(null), { node: n, ready: s } = bt(), o = xt();
|
|
311
|
+
return D(() => {
|
|
312
|
+
const a = t.current;
|
|
313
|
+
if (!a) return;
|
|
314
|
+
const i = s && n ? e(n.getResult()) : null;
|
|
315
|
+
if (!i) {
|
|
316
|
+
a.visible = !1;
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
a.visible = !0, a.position.copy(r(i, o.current));
|
|
320
|
+
}), { groupRef: t, cameraRef: o, node: n };
|
|
321
|
+
}, ze = ({ children: e }) => {
|
|
322
|
+
const r = g({ x: 0, y: 0, z: 0, visibility: 0 }), { groupRef: t, cameraRef: n, node: s } = ge(
|
|
323
|
+
(i) => {
|
|
324
|
+
var u;
|
|
325
|
+
return ((u = i.face) == null ? void 0 : u.landmarks[4]) ?? null;
|
|
326
|
+
},
|
|
327
|
+
(i, u) => Le(i, u)
|
|
328
|
+
), o = O(
|
|
329
|
+
(i, u) => {
|
|
330
|
+
var d;
|
|
331
|
+
const c = (d = s == null ? void 0 : s.getResult().face) == null ? void 0 : d.landmarks;
|
|
332
|
+
if (!c || c.length === 0) return null;
|
|
333
|
+
const h = $e(
|
|
334
|
+
i,
|
|
335
|
+
c,
|
|
336
|
+
u,
|
|
337
|
+
r.current
|
|
338
|
+
);
|
|
339
|
+
return h ? { position: Le(h, n.current) } : null;
|
|
196
340
|
},
|
|
341
|
+
[n, s]
|
|
342
|
+
), a = E(
|
|
343
|
+
() => ({ type: "face", resolveLandmark: o }),
|
|
344
|
+
[o]
|
|
345
|
+
);
|
|
346
|
+
return /* @__PURE__ */ b(q.Provider, { value: a, children: /* @__PURE__ */ b("group", { ref: t, renderOrder: J.TRACKED, visible: !1, children: e }) });
|
|
347
|
+
};
|
|
348
|
+
ze.displayName = "HolisticTracker.Face";
|
|
349
|
+
const We = ({ hand: e, children: r }) => {
|
|
350
|
+
const t = O(
|
|
351
|
+
(u) => e === "left" ? u.leftHand : u.rightHand,
|
|
197
352
|
[e]
|
|
198
|
-
),
|
|
353
|
+
), { groupRef: n, cameraRef: s, node: o } = ge(
|
|
354
|
+
(u) => {
|
|
355
|
+
var c;
|
|
356
|
+
return ((c = t(u)) == null ? void 0 : c.landmarks[0]) ?? null;
|
|
357
|
+
},
|
|
358
|
+
L
|
|
359
|
+
), a = O(
|
|
360
|
+
(u) => {
|
|
361
|
+
var d;
|
|
362
|
+
const c = Ue[u];
|
|
363
|
+
if (c === void 0 || !o) return null;
|
|
364
|
+
const h = (d = t(o.getResult())) == null ? void 0 : d.landmarks[c];
|
|
365
|
+
return h ? { position: L(h, s.current) } : null;
|
|
366
|
+
},
|
|
367
|
+
[s, o, t]
|
|
368
|
+
), i = E(
|
|
369
|
+
() => ({ type: "hand", resolveLandmark: a }),
|
|
370
|
+
[a]
|
|
371
|
+
);
|
|
372
|
+
return /* @__PURE__ */ b(q.Provider, { value: i, children: /* @__PURE__ */ b("group", { ref: n, renderOrder: J.TRACKED, visible: !1, children: r }) });
|
|
373
|
+
};
|
|
374
|
+
We.displayName = "HolisticTracker.Hand";
|
|
375
|
+
const Xe = ({ children: e }) => {
|
|
376
|
+
const { groupRef: r, cameraRef: t, node: n } = ge(
|
|
377
|
+
(a) => {
|
|
378
|
+
var i;
|
|
379
|
+
return ((i = a.pose) == null ? void 0 : i.landmarks[0]) ?? null;
|
|
380
|
+
},
|
|
381
|
+
L
|
|
382
|
+
), s = O(
|
|
383
|
+
(a) => {
|
|
384
|
+
var h;
|
|
385
|
+
const i = (h = n == null ? void 0 : n.getResult().pose) == null ? void 0 : h.landmarks;
|
|
386
|
+
if (!i) return null;
|
|
387
|
+
if (a === "body.neck") {
|
|
388
|
+
const d = i[11], m = i[12];
|
|
389
|
+
if (!d || !m) return null;
|
|
390
|
+
const f = { x: (d.x + m.x) / 2, y: (d.y + m.y) / 2, z: (d.z + m.z) / 2 };
|
|
391
|
+
return { position: L(f, t.current) };
|
|
392
|
+
}
|
|
393
|
+
const u = Ge[a];
|
|
394
|
+
if (u === void 0) return null;
|
|
395
|
+
const c = i[u];
|
|
396
|
+
return c ? { position: L(c, t.current) } : null;
|
|
397
|
+
},
|
|
398
|
+
[t, n]
|
|
399
|
+
), o = E(
|
|
199
400
|
() => ({ type: "body", resolveLandmark: s }),
|
|
200
401
|
[s]
|
|
201
402
|
);
|
|
202
|
-
return /* @__PURE__ */
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
403
|
+
return /* @__PURE__ */ b(q.Provider, { value: o, children: /* @__PURE__ */ b("group", { ref: r, renderOrder: J.TRACKED, visible: !1, children: e }) });
|
|
404
|
+
};
|
|
405
|
+
Xe.displayName = "HolisticTracker.Body";
|
|
406
|
+
const Te = At;
|
|
407
|
+
Te.Face = ze;
|
|
408
|
+
Te.Hand = We;
|
|
409
|
+
Te.Body = Xe;
|
|
410
|
+
const Sr = ({ type: e, active: r = !0, children: t }) => (U(I.BACKGROUND_SEGMENTATION, { type: e }, r), k(() => {
|
|
411
|
+
ke.includes(e) || console.warn(
|
|
412
|
+
`[Segmentation] unsupported type "${e}"; valid values: ${ke.join(", ")}`
|
|
211
413
|
);
|
|
212
|
-
}, [e]), /* @__PURE__ */
|
|
414
|
+
}, [e]), /* @__PURE__ */ b(Ze, { children: t })), vt = 800, Ot = 200, Lt = () => ({
|
|
213
415
|
armed: !1,
|
|
214
416
|
armStart: null,
|
|
215
417
|
holdStart: null,
|
|
216
418
|
fired: !1
|
|
217
|
-
}),
|
|
218
|
-
isTrigger:
|
|
219
|
-
gesture:
|
|
419
|
+
}), kt = (e, {
|
|
420
|
+
isTrigger: r,
|
|
421
|
+
gesture: t,
|
|
220
422
|
now: n,
|
|
221
|
-
mode:
|
|
222
|
-
debounceMs:
|
|
223
|
-
holdMs:
|
|
423
|
+
mode: s,
|
|
424
|
+
debounceMs: o,
|
|
425
|
+
holdMs: a
|
|
224
426
|
}) => {
|
|
225
427
|
if (e.fired) return null;
|
|
226
|
-
if (
|
|
227
|
-
if (
|
|
228
|
-
if (e.holdStart === null && (e.holdStart = n), n - e.holdStart >=
|
|
229
|
-
return e.fired = !0,
|
|
428
|
+
if (s === "hold") {
|
|
429
|
+
if (r && t) {
|
|
430
|
+
if (e.holdStart === null && (e.holdStart = n), n - e.holdStart >= a)
|
|
431
|
+
return e.fired = !0, t;
|
|
230
432
|
} else
|
|
231
433
|
e.holdStart = null;
|
|
232
434
|
return null;
|
|
233
435
|
}
|
|
234
|
-
return e.armed ?
|
|
436
|
+
return e.armed ? r && t ? (e.fired = !0, t) : null : (r ? e.armStart = null : (e.armStart === null && (e.armStart = n), n - e.armStart >= o && (e.armed = !0)), null);
|
|
235
437
|
};
|
|
236
|
-
function
|
|
438
|
+
function _t({
|
|
237
439
|
gestures: e,
|
|
238
|
-
mode:
|
|
239
|
-
debounceMs:
|
|
240
|
-
holdMs: n =
|
|
241
|
-
onTrigger:
|
|
242
|
-
enabled:
|
|
440
|
+
mode: r = "arm",
|
|
441
|
+
debounceMs: t = vt,
|
|
442
|
+
holdMs: n = Ot,
|
|
443
|
+
onTrigger: s,
|
|
444
|
+
enabled: o = !0
|
|
243
445
|
}) {
|
|
244
|
-
const { ready:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}, [
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
446
|
+
const { ready: a, node: i } = U(I.GESTURE_TRACKER), u = g(s);
|
|
447
|
+
k(() => {
|
|
448
|
+
u.current = s;
|
|
449
|
+
}, [s]);
|
|
450
|
+
const c = g(/* @__PURE__ */ new Set());
|
|
451
|
+
k(() => {
|
|
452
|
+
c.current = new Set(Array.isArray(e) ? e : [e]);
|
|
251
453
|
}, [e]);
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
if (!
|
|
255
|
-
const
|
|
256
|
-
isTrigger:
|
|
257
|
-
gesture:
|
|
454
|
+
const h = g(Lt());
|
|
455
|
+
D(() => {
|
|
456
|
+
if (!o || !a || !i) return;
|
|
457
|
+
const d = i.gesture, m = !!(d && c.current.has(d)), f = kt(h.current, {
|
|
458
|
+
isTrigger: m,
|
|
459
|
+
gesture: d,
|
|
258
460
|
now: performance.now(),
|
|
259
|
-
mode:
|
|
260
|
-
debounceMs:
|
|
461
|
+
mode: r,
|
|
462
|
+
debounceMs: t,
|
|
261
463
|
holdMs: n
|
|
262
464
|
});
|
|
263
|
-
|
|
465
|
+
f && u.current(f);
|
|
264
466
|
});
|
|
265
467
|
}
|
|
266
|
-
const
|
|
267
|
-
face: null,
|
|
268
|
-
faces: [],
|
|
269
|
-
faceCount: 0,
|
|
270
|
-
detected: !1,
|
|
271
|
-
justDetected: !1,
|
|
272
|
-
justLost: !1,
|
|
273
|
-
phase: "none"
|
|
274
|
-
}, Oe = ({
|
|
275
|
-
faceIndex: e = 0,
|
|
276
|
-
numFaces: t,
|
|
277
|
-
...r
|
|
278
|
-
} = {}) => {
|
|
279
|
-
const n = Number.isFinite(e) ? Math.max(0, Math.round(e)) : 0, o = te({
|
|
280
|
-
...r,
|
|
281
|
-
numFaces: Math.max(t ?? n + 1, n + 1)
|
|
282
|
-
}), u = R([]), i = R(n), a = R({ detected: !1, faceIndex: n }), [y, s] = I(fe), c = R(y);
|
|
283
|
-
return L(() => {
|
|
284
|
-
u.current = o, i.current = n;
|
|
285
|
-
}, [o, n]), b(() => {
|
|
286
|
-
const l = u.current, f = i.current, h = l[f] ?? null, g = !!h, d = a.current.faceIndex === f && a.current.detected, p = he(d, g);
|
|
287
|
-
a.current = { detected: g, faceIndex: f };
|
|
288
|
-
const m = {
|
|
289
|
-
face: h,
|
|
290
|
-
faces: l,
|
|
291
|
-
faceCount: l.length,
|
|
292
|
-
detected: g,
|
|
293
|
-
justDetected: p === "begin",
|
|
294
|
-
justLost: p === "end",
|
|
295
|
-
phase: p
|
|
296
|
-
}, E = c.current;
|
|
297
|
-
E.face === m.face && E.faces === m.faces && E.faceCount === m.faceCount && E.detected === m.detected && E.justDetected === m.justDetected && E.justLost === m.justLost && E.phase === m.phase || (c.current = m, s(m));
|
|
298
|
-
}), y;
|
|
299
|
-
}, Ce = [
|
|
468
|
+
const yr = (e) => (_t(e), null), Rr = [
|
|
300
469
|
"_neutral",
|
|
301
470
|
"browDownLeft",
|
|
302
471
|
"browDownRight",
|
|
@@ -349,13 +518,13 @@ const je = (e) => (de(e), null), he = (e, t) => t && !e ? "begin" : !t && e ? "e
|
|
|
349
518
|
"mouthUpperUpRight",
|
|
350
519
|
"noseSneerLeft",
|
|
351
520
|
"noseSneerRight"
|
|
352
|
-
],
|
|
521
|
+
], wt = ({
|
|
353
522
|
source: e,
|
|
354
|
-
face:
|
|
355
|
-
canvas:
|
|
523
|
+
face: r,
|
|
524
|
+
canvas: t,
|
|
356
525
|
outputSize: n,
|
|
357
|
-
padding:
|
|
358
|
-
}) =>
|
|
526
|
+
padding: s = 0.2
|
|
527
|
+
}) => gt({ source: e, bounds: r.bounds, canvas: t, outputSize: n, padding: s }), Er = [
|
|
359
528
|
"browRaise",
|
|
360
529
|
"eyeBlink",
|
|
361
530
|
"eyeBlinkLeft",
|
|
@@ -369,86 +538,86 @@ const je = (e) => (de(e), null), he = (e, t) => t && !e ? "begin" : !t && e ? "e
|
|
|
369
538
|
"mouthPout",
|
|
370
539
|
"headTiltLeft",
|
|
371
540
|
"headTiltRight"
|
|
372
|
-
],
|
|
541
|
+
], H = (e = 0.5) => ({
|
|
373
542
|
threshold: e,
|
|
374
543
|
releaseThreshold: Math.max(0, e - 0.15),
|
|
375
544
|
holdMs: 50
|
|
376
|
-
}),
|
|
545
|
+
}), z = {
|
|
377
546
|
threshold: Math.PI / 18,
|
|
378
547
|
releaseThreshold: Math.PI / 30,
|
|
379
548
|
holdMs: 80
|
|
380
|
-
},
|
|
381
|
-
browRaise:
|
|
382
|
-
eyeBlink:
|
|
383
|
-
eyeBlinkLeft:
|
|
384
|
-
eyeBlinkRight:
|
|
385
|
-
eyeBlinkEither:
|
|
386
|
-
headUp:
|
|
387
|
-
headDown:
|
|
388
|
-
headTurnLeft:
|
|
389
|
-
headTurnRight:
|
|
390
|
-
mouthOpen:
|
|
391
|
-
mouthPout:
|
|
392
|
-
headTiltLeft:
|
|
393
|
-
headTiltRight:
|
|
394
|
-
},
|
|
395
|
-
const
|
|
549
|
+
}, Dt = {
|
|
550
|
+
browRaise: H(0.45),
|
|
551
|
+
eyeBlink: H(0.55),
|
|
552
|
+
eyeBlinkLeft: H(0.55),
|
|
553
|
+
eyeBlinkRight: H(0.55),
|
|
554
|
+
eyeBlinkEither: H(0.55),
|
|
555
|
+
headUp: z,
|
|
556
|
+
headDown: z,
|
|
557
|
+
headTurnLeft: z,
|
|
558
|
+
headTurnRight: z,
|
|
559
|
+
mouthOpen: H(0.45),
|
|
560
|
+
mouthPout: H(0.5),
|
|
561
|
+
headTiltLeft: z,
|
|
562
|
+
headTiltRight: z
|
|
563
|
+
}, W = (e) => Math.max(0, e), Y = (e, r) => e !== void 0 && Number.isFinite(e) ? e : r, Ye = (e, r = {}) => {
|
|
564
|
+
const t = Dt[e], n = Math.max(0, Y(r.threshold, t.threshold));
|
|
396
565
|
return {
|
|
397
566
|
threshold: n,
|
|
398
567
|
releaseThreshold: Math.min(
|
|
399
568
|
n,
|
|
400
|
-
Math.max(0,
|
|
569
|
+
Math.max(0, Y(r.releaseThreshold, t.releaseThreshold))
|
|
401
570
|
),
|
|
402
|
-
holdMs: Math.max(0,
|
|
571
|
+
holdMs: Math.max(0, Y(r.holdMs, t.holdMs))
|
|
403
572
|
};
|
|
404
|
-
},
|
|
405
|
-
const n =
|
|
406
|
-
switch (
|
|
573
|
+
}, V = (e, r, { neutralRotation: t = { x: 0, y: 0, z: 0 } } = {}) => {
|
|
574
|
+
const n = Y(t.x, 0), s = Y(t.y, 0), o = Y(t.z, 0);
|
|
575
|
+
switch (r) {
|
|
407
576
|
case "browRaise":
|
|
408
577
|
return Math.max(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
578
|
+
A(e, "browInnerUp"),
|
|
579
|
+
A(e, "browOuterUpLeft"),
|
|
580
|
+
A(e, "browOuterUpRight")
|
|
412
581
|
);
|
|
413
582
|
case "eyeBlink":
|
|
414
583
|
return Math.min(
|
|
415
|
-
|
|
416
|
-
|
|
584
|
+
A(e, "eyeBlinkLeft"),
|
|
585
|
+
A(e, "eyeBlinkRight")
|
|
417
586
|
);
|
|
418
587
|
case "eyeBlinkLeft":
|
|
419
|
-
return
|
|
588
|
+
return A(e, "eyeBlinkRight");
|
|
420
589
|
case "eyeBlinkRight":
|
|
421
|
-
return
|
|
590
|
+
return A(e, "eyeBlinkLeft");
|
|
422
591
|
case "eyeBlinkEither":
|
|
423
592
|
return Math.max(
|
|
424
|
-
|
|
425
|
-
|
|
593
|
+
A(e, "eyeBlinkLeft"),
|
|
594
|
+
A(e, "eyeBlinkRight")
|
|
426
595
|
);
|
|
427
596
|
case "mouthOpen":
|
|
428
|
-
return
|
|
597
|
+
return A(e, "jawOpen");
|
|
429
598
|
case "mouthPout":
|
|
430
|
-
return
|
|
599
|
+
return A(e, "mouthPucker");
|
|
431
600
|
case "headUp":
|
|
432
|
-
return
|
|
601
|
+
return W(e.pose.rotation.x - n);
|
|
433
602
|
case "headDown":
|
|
434
|
-
return
|
|
603
|
+
return W(n - e.pose.rotation.x);
|
|
435
604
|
case "headTurnLeft":
|
|
436
|
-
return
|
|
605
|
+
return W(e.pose.rotation.y - s);
|
|
437
606
|
case "headTurnRight":
|
|
438
|
-
return
|
|
607
|
+
return W(s - e.pose.rotation.y);
|
|
439
608
|
case "headTiltLeft":
|
|
440
|
-
return
|
|
609
|
+
return W(e.pose.rotation.z - o);
|
|
441
610
|
case "headTiltRight":
|
|
442
|
-
return
|
|
611
|
+
return W(o - e.pose.rotation.z);
|
|
443
612
|
}
|
|
444
|
-
},
|
|
445
|
-
let n = null,
|
|
446
|
-
for (const
|
|
447
|
-
const
|
|
448
|
-
(!n ||
|
|
613
|
+
}, br = (e, r, t = {}) => V(e, r, t) >= Ye(r, t).threshold, Ar = (e, r, t = {}) => {
|
|
614
|
+
let n = null, s = 0;
|
|
615
|
+
for (const o of e) {
|
|
616
|
+
const a = V(o, r, t);
|
|
617
|
+
(!n || a > s) && (n = o, s = a);
|
|
449
618
|
}
|
|
450
|
-
return { face: n, value:
|
|
451
|
-
},
|
|
619
|
+
return { face: n, value: s };
|
|
620
|
+
}, Me = (e) => ({
|
|
452
621
|
action: e,
|
|
453
622
|
active: !1,
|
|
454
623
|
value: 0,
|
|
@@ -456,54 +625,488 @@ const je = (e) => (de(e), null), he = (e, t) => t && !e ? "begin" : !t && e ? "e
|
|
|
456
625
|
justEnded: !1,
|
|
457
626
|
phase: "none",
|
|
458
627
|
holdStartedAt: null
|
|
459
|
-
}),
|
|
460
|
-
const
|
|
461
|
-
if (e.value =
|
|
628
|
+
}), It = (e, r, t, n, s) => {
|
|
629
|
+
const o = e.phase === "begin";
|
|
630
|
+
if (e.value = r, e.justStarted = !1, e.justEnded = !1, e.phase = e.active ? "stay" : "none", !n)
|
|
462
631
|
return e.holdStartedAt = null, e.active && (e.active = !1, e.justEnded = !0, e.phase = "end"), e;
|
|
463
632
|
if (e.active) {
|
|
464
|
-
if (
|
|
465
|
-
if (
|
|
633
|
+
if (r <= s.releaseThreshold) {
|
|
634
|
+
if (o) return e;
|
|
466
635
|
e.active = !1, e.justEnded = !0, e.phase = "end";
|
|
467
636
|
}
|
|
468
637
|
return e;
|
|
469
638
|
}
|
|
470
|
-
return
|
|
471
|
-
},
|
|
639
|
+
return r < s.threshold ? (e.holdStartedAt = null, e) : (e.holdStartedAt === null && (e.holdStartedAt = t), t - e.holdStartedAt >= s.holdMs && (e.active = !0, e.justStarted = !0, e.phase = "begin", e.holdStartedAt = null), e);
|
|
640
|
+
}, se = (e) => ({ value: e, confidence: 1 }), re = (e, r, t, n) => ({
|
|
641
|
+
name: e,
|
|
642
|
+
kind: "face",
|
|
643
|
+
description: r,
|
|
644
|
+
defaults: n,
|
|
645
|
+
measure: (s) => s ? se(t(s)) : null
|
|
646
|
+
}), v = (e, r, t, n) => ({
|
|
647
|
+
name: e,
|
|
648
|
+
kind: "hand",
|
|
649
|
+
description: r,
|
|
650
|
+
defaults: n,
|
|
651
|
+
measure: (s) => s && s.length >= 21 ? se(t(s)) : null
|
|
652
|
+
}), $ = (e, r, t, n) => ({
|
|
653
|
+
name: e,
|
|
654
|
+
kind: "body",
|
|
655
|
+
description: r,
|
|
656
|
+
defaults: n,
|
|
657
|
+
measure: (s) => s && s.length >= 33 ? se(t(s)) : null
|
|
658
|
+
}), le = (e) => () => ({
|
|
659
|
+
tracker: new ut(e),
|
|
660
|
+
wasPresent: !1
|
|
661
|
+
}), de = (e, r, t) => r === null ? (e.wasPresent = !1, null) : (e.wasPresent || e.tracker.reset(), e.wasPresent = !0, se(e.tracker.push(r, t))), he = {
|
|
662
|
+
enterThreshold: 0.99,
|
|
663
|
+
exitThreshold: 0.3,
|
|
664
|
+
cooldownMs: 600
|
|
665
|
+
}, Ve = {
|
|
666
|
+
// ── Face ───────────────────────────────────────────────────────────────
|
|
667
|
+
mouthOpen: re(
|
|
668
|
+
"mouthOpen",
|
|
669
|
+
"Jaw open (blendshape jawOpen).",
|
|
670
|
+
(e) => V(e, "mouthOpen")
|
|
671
|
+
),
|
|
672
|
+
smile: re(
|
|
673
|
+
"smile",
|
|
674
|
+
"Mean of the two mouthSmile blendshapes.",
|
|
675
|
+
(e) => (A(e, "mouthSmileLeft") + A(e, "mouthSmileRight")) / 2,
|
|
676
|
+
{ enterThreshold: 0.4 }
|
|
677
|
+
),
|
|
678
|
+
blink: re(
|
|
679
|
+
"blink",
|
|
680
|
+
"Both eyes closed (min of the eyeBlink blendshapes).",
|
|
681
|
+
(e) => V(e, "eyeBlink"),
|
|
682
|
+
{ enterThreshold: 0.55, holdMs: 50 }
|
|
683
|
+
),
|
|
684
|
+
browRaise: re(
|
|
685
|
+
"browRaise",
|
|
686
|
+
"Eyebrows raised (max of the brow-up blendshapes).",
|
|
687
|
+
(e) => V(e, "browRaise"),
|
|
688
|
+
{ enterThreshold: 0.45 }
|
|
689
|
+
),
|
|
690
|
+
headNod: {
|
|
691
|
+
name: "headNod",
|
|
692
|
+
kind: "face",
|
|
693
|
+
description: "Pitch oscillation: three turning points of at least 0.12 rad within 1.5 s.",
|
|
694
|
+
defaults: he,
|
|
695
|
+
createMemory: le({ minAmplitude: 0.12, requiredReversals: 3, windowMs: 1500 }),
|
|
696
|
+
measure: (e, r, t) => de(r, e ? e.pose.rotation.x : null, t)
|
|
697
|
+
},
|
|
698
|
+
headShake: {
|
|
699
|
+
name: "headShake",
|
|
700
|
+
kind: "face",
|
|
701
|
+
description: "Yaw oscillation: three turning points of at least 0.15 rad within 1.5 s.",
|
|
702
|
+
defaults: he,
|
|
703
|
+
createMemory: le({ minAmplitude: 0.15, requiredReversals: 3, windowMs: 1500 }),
|
|
704
|
+
measure: (e, r, t) => de(r, e ? e.pose.rotation.y : null, t)
|
|
705
|
+
},
|
|
706
|
+
// ── Hand ───────────────────────────────────────────────────────────────
|
|
707
|
+
pinch: v(
|
|
708
|
+
"pinch",
|
|
709
|
+
"Thumb and index tips touching, relative to palm size.",
|
|
710
|
+
mt,
|
|
711
|
+
{
|
|
712
|
+
enterThreshold: 0.75,
|
|
713
|
+
exitThreshold: 0.5
|
|
714
|
+
}
|
|
715
|
+
),
|
|
716
|
+
grab: v("grab", "Fist: index to pinky curled toward the wrist.", ft, {
|
|
717
|
+
enterThreshold: 0.7,
|
|
718
|
+
exitThreshold: 0.45
|
|
719
|
+
}),
|
|
720
|
+
openPalm: v("openPalm", "Index to pinky extended.", ht, {
|
|
721
|
+
enterThreshold: 0.7,
|
|
722
|
+
exitThreshold: 0.45
|
|
723
|
+
}),
|
|
724
|
+
handRaised: v(
|
|
725
|
+
"handRaised",
|
|
726
|
+
"Wrist in the upper part of the frame (0 bottom edge, 1 top edge).",
|
|
727
|
+
dt,
|
|
728
|
+
{ enterThreshold: 0.7, exitThreshold: 0.6 }
|
|
729
|
+
),
|
|
730
|
+
// Finger-count signs: each required finger must agree; 1 only when all do.
|
|
731
|
+
oneFinger: v(
|
|
732
|
+
"oneFinger",
|
|
733
|
+
"Index extended, other fingers curled (pointing).",
|
|
734
|
+
(e) => K(e, { fingers: [!0, !1, !1, !1] }),
|
|
735
|
+
{ enterThreshold: 0.65, exitThreshold: 0.45 }
|
|
736
|
+
),
|
|
737
|
+
peaceSign: v(
|
|
738
|
+
"peaceSign",
|
|
739
|
+
"Index and middle extended, ring and pinky curled.",
|
|
740
|
+
(e) => K(e, { fingers: [!0, !0, !1, !1] }),
|
|
741
|
+
{ enterThreshold: 0.65, exitThreshold: 0.45 }
|
|
742
|
+
),
|
|
743
|
+
threeFingers: v(
|
|
744
|
+
"threeFingers",
|
|
745
|
+
"Index, middle and ring extended, pinky curled.",
|
|
746
|
+
(e) => K(e, { fingers: [!0, !0, !0, !1] }),
|
|
747
|
+
{ enterThreshold: 0.65, exitThreshold: 0.45 }
|
|
748
|
+
),
|
|
749
|
+
fourFingers: v(
|
|
750
|
+
"fourFingers",
|
|
751
|
+
"Index to pinky extended, thumb tucked.",
|
|
752
|
+
(e) => K(e, { fingers: [!0, !0, !0, !0], thumb: !1 }),
|
|
753
|
+
{ enterThreshold: 0.65, exitThreshold: 0.45 }
|
|
754
|
+
),
|
|
755
|
+
fist: v(
|
|
756
|
+
"fist",
|
|
757
|
+
"All four fingers curled and the thumb tucked.",
|
|
758
|
+
(e) => K(e, { fingers: [!1, !1, !1, !1], thumb: !1 }),
|
|
759
|
+
{ enterThreshold: 0.65, exitThreshold: 0.45 }
|
|
760
|
+
),
|
|
761
|
+
palm: v(
|
|
762
|
+
"palm",
|
|
763
|
+
"All four fingers extended and the thumb out.",
|
|
764
|
+
(e) => K(e, { fingers: [!0, !0, !0, !0], thumb: !0 }),
|
|
765
|
+
{ enterThreshold: 0.65, exitThreshold: 0.45 }
|
|
766
|
+
),
|
|
767
|
+
thumbUp: v(
|
|
768
|
+
"thumbUp",
|
|
769
|
+
"Thumb out and pointing up, fingers curled.",
|
|
770
|
+
(e) => we(e, "up"),
|
|
771
|
+
{ enterThreshold: 0.6, exitThreshold: 0.4 }
|
|
772
|
+
),
|
|
773
|
+
thumbDown: v(
|
|
774
|
+
"thumbDown",
|
|
775
|
+
"Thumb out and pointing down, fingers curled.",
|
|
776
|
+
(e) => we(e, "down"),
|
|
777
|
+
{ enterThreshold: 0.6, exitThreshold: 0.4 }
|
|
778
|
+
),
|
|
779
|
+
wave: {
|
|
780
|
+
name: "wave",
|
|
781
|
+
kind: "hand",
|
|
782
|
+
description: "Wrist swinging side to side: three turning points of at least 0.08 within 1.2 s.",
|
|
783
|
+
defaults: he,
|
|
784
|
+
createMemory: le({ minAmplitude: 0.08, requiredReversals: 3, windowMs: 1200 }),
|
|
785
|
+
measure: (e, r, t) => de(r, e && e.length >= 21 ? e[0].x : null, t)
|
|
786
|
+
},
|
|
787
|
+
// ── Body ───────────────────────────────────────────────────────────────
|
|
788
|
+
armRaisedLeft: $(
|
|
789
|
+
"armRaisedLeft",
|
|
790
|
+
"Person's left wrist above the left shoulder, in shoulder widths.",
|
|
791
|
+
(e) => G(e, "left"),
|
|
792
|
+
{ enterThreshold: 0.3, exitThreshold: 0.15 }
|
|
793
|
+
),
|
|
794
|
+
armRaisedRight: $(
|
|
795
|
+
"armRaisedRight",
|
|
796
|
+
"Person's right wrist above the right shoulder, in shoulder widths.",
|
|
797
|
+
(e) => G(e, "right"),
|
|
798
|
+
{ enterThreshold: 0.3, exitThreshold: 0.15 }
|
|
799
|
+
),
|
|
800
|
+
armRaised: $(
|
|
801
|
+
"armRaised",
|
|
802
|
+
"Either wrist above its shoulder.",
|
|
803
|
+
(e) => Math.max(G(e, "left"), G(e, "right")),
|
|
804
|
+
{ enterThreshold: 0.3, exitThreshold: 0.15 }
|
|
805
|
+
),
|
|
806
|
+
bothArmsRaised: $(
|
|
807
|
+
"bothArmsRaised",
|
|
808
|
+
"Both wrists above their shoulders.",
|
|
809
|
+
(e) => Math.min(G(e, "left"), G(e, "right")),
|
|
810
|
+
{ enterThreshold: 0.3, exitThreshold: 0.15 }
|
|
811
|
+
),
|
|
812
|
+
tPose: $("tPose", "Both arms level and outstretched.", lt, {
|
|
813
|
+
enterThreshold: 0.6,
|
|
814
|
+
exitThreshold: 0.4,
|
|
815
|
+
holdMs: 150
|
|
816
|
+
})
|
|
817
|
+
}, xr = Object.keys(Ve), Nt = (e) => typeof e == "string" ? Ve[e] : e, vr = (e) => e, Ct = {
|
|
818
|
+
face: I.FACE_TRACKER,
|
|
819
|
+
hand: I.HAND_TRACKER,
|
|
820
|
+
body: I.BODY_TRACKER
|
|
821
|
+
}, Fe = (e) => Be(me(e)), Mt = (e, r = {}) => {
|
|
822
|
+
var Ae;
|
|
823
|
+
const t = E(() => Nt(e), [e]), {
|
|
824
|
+
active: n = !0,
|
|
825
|
+
faceIndex: s = 0,
|
|
826
|
+
numFaces: o,
|
|
827
|
+
hand: a,
|
|
828
|
+
handIndex: i = 0,
|
|
829
|
+
bodyIndex: u = 0,
|
|
830
|
+
targetFps: c,
|
|
831
|
+
onBegin: h,
|
|
832
|
+
onEnd: d,
|
|
833
|
+
onChange: m,
|
|
834
|
+
...f
|
|
835
|
+
} = r, S = Ct[t.kind], T = Math.max(o ?? s + 1, s + 1), y = E(() => {
|
|
836
|
+
const w = {};
|
|
837
|
+
return t.kind === "face" && (w.numFaces = T), c !== void 0 && c > 0 && (w.targetFps = c), Object.keys(w).length > 0 ? w : void 0;
|
|
838
|
+
}, [t.kind, T, c]), { node: l, ready: p } = U(S, y, n), { camera: _ } = Z();
|
|
839
|
+
k(() => {
|
|
840
|
+
!l || t.kind !== "face" || l.setCamera(_, s);
|
|
841
|
+
}, [_, t.kind, s, l]);
|
|
842
|
+
const x = E(
|
|
843
|
+
() => _e(
|
|
844
|
+
f,
|
|
845
|
+
_e(t.defaults)
|
|
846
|
+
),
|
|
847
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
848
|
+
[
|
|
849
|
+
t,
|
|
850
|
+
f.enterThreshold,
|
|
851
|
+
f.exitThreshold,
|
|
852
|
+
f.holdMs,
|
|
853
|
+
f.cooldownMs,
|
|
854
|
+
f.minConfidence,
|
|
855
|
+
f.lostGraceMs
|
|
856
|
+
]
|
|
857
|
+
), N = g(me(t.name)), F = g((Ae = t.createMemory) == null ? void 0 : Ae.call(t)), C = g(at()), [Q, R] = B(() => Fe(t.name)), j = g(Q);
|
|
858
|
+
k(() => {
|
|
859
|
+
var M;
|
|
860
|
+
N.current = me(t.name), F.current = (M = t.createMemory) == null ? void 0 : M.call(t);
|
|
861
|
+
const w = Fe(t.name);
|
|
862
|
+
j.current = w, R(w);
|
|
863
|
+
}, [t]);
|
|
864
|
+
const Ee = g({ onBegin: h, onEnd: d, onChange: m });
|
|
865
|
+
Ee.current = { onBegin: h, onEnd: d, onChange: m };
|
|
866
|
+
const be = g({ faceIndex: s, hand: a, handIndex: i, bodyIndex: u, active: n });
|
|
867
|
+
return be.current = { faceIndex: s, hand: a, handIndex: i, bodyIndex: u, active: n }, D(() => {
|
|
868
|
+
var Oe;
|
|
869
|
+
const w = performance.now(), M = be.current;
|
|
870
|
+
let xe = null;
|
|
871
|
+
if (M.active && p && l) {
|
|
872
|
+
let ee;
|
|
873
|
+
t.kind === "face" ? ee = ct(l, M.faceIndex, C.current) : t.kind === "hand" ? ee = (Oe = je(
|
|
874
|
+
l,
|
|
875
|
+
M.hand,
|
|
876
|
+
M.handIndex
|
|
877
|
+
)) == null ? void 0 : Oe.coordinates : ee = l.getLandmarks2D(M.bodyIndex), xe = t.measure(ee, F.current, w);
|
|
878
|
+
}
|
|
879
|
+
const ve = ot(N.current, xe, w, x);
|
|
880
|
+
if (it(j.current, ve)) return;
|
|
881
|
+
const P = Be(ve);
|
|
882
|
+
j.current = P, R(P);
|
|
883
|
+
const { onBegin: ae, onEnd: ce, onChange: ue } = Ee.current;
|
|
884
|
+
P.justBegan && (ae == null || ae(P)), P.justEnded && (ce == null || ce(P)), ue == null || ue(P);
|
|
885
|
+
}), Q;
|
|
886
|
+
}, Or = ({ gesture: e, ...r }) => (Mt(e, r), null), Se = 1, ye = Object.freeze({
|
|
887
|
+
version: Se,
|
|
888
|
+
orientation: 0,
|
|
889
|
+
mirrored: "auto",
|
|
890
|
+
scale: 1,
|
|
891
|
+
offset: Object.freeze({ x: 0, y: 0 }),
|
|
892
|
+
face: null,
|
|
893
|
+
body: null,
|
|
894
|
+
updatedAt: 0
|
|
895
|
+
}), Ft = (e = {}) => oe(ye, e, 0), Pt = [0, 90, 180, 270], Ht = (e) => Math.min(4, Math.max(0.25, e)), oe = (e, r, t = Date.now()) => ({
|
|
896
|
+
version: Se,
|
|
897
|
+
orientation: r.orientation !== void 0 && Pt.includes(r.orientation) ? r.orientation : e.orientation,
|
|
898
|
+
mirrored: r.mirrored === !0 || r.mirrored === !1 || r.mirrored === "auto" ? r.mirrored : e.mirrored,
|
|
899
|
+
scale: r.scale !== void 0 && Number.isFinite(r.scale) && r.scale > 0 ? Ht(r.scale) : e.scale,
|
|
900
|
+
offset: r.offset && Number.isFinite(r.offset.x) && Number.isFinite(r.offset.y) ? { x: r.offset.x, y: r.offset.y } : { ...e.offset },
|
|
901
|
+
face: r.face !== void 0 ? r.face : e.face,
|
|
902
|
+
body: r.body !== void 0 ? r.body : e.body,
|
|
903
|
+
updatedAt: t
|
|
904
|
+
}), Bt = (e = Date.now()) => oe(ye, {}, e), Lr = (e) => e.orientation === 0 && e.mirrored === "auto" && e.scale === 1 && e.offset.x === 0 && e.offset.y === 0, Ut = (e, r) => e.mirrored === "auto" ? !1 : e.mirrored !== nt(r), jt = (e, r, t, n = { x: 0, y: 0 }) => {
|
|
905
|
+
let { x: s, y: o } = e;
|
|
906
|
+
switch (r.orientation) {
|
|
907
|
+
case 90:
|
|
908
|
+
[s, o] = [1 - o, s];
|
|
909
|
+
break;
|
|
910
|
+
case 180:
|
|
911
|
+
[s, o] = [1 - s, 1 - o];
|
|
912
|
+
break;
|
|
913
|
+
case 270:
|
|
914
|
+
[s, o] = [o, 1 - s];
|
|
915
|
+
break;
|
|
916
|
+
}
|
|
917
|
+
return Ut(r, t) && (s = 1 - s), s = 0.5 + (s - 0.5) * r.scale + r.offset.x, o = 0.5 + (o - 0.5) * r.scale + r.offset.y, n.x = s, n.y = o, e.z !== void 0 && (n.z = e.z), n;
|
|
918
|
+
}, ne = (e, r) => e && r ? Math.hypot(e.x - r.x, e.y - r.y) : null, Gt = Object.freeze({
|
|
919
|
+
leftTemple: 234,
|
|
920
|
+
rightTemple: 454,
|
|
921
|
+
leftEyeOuter: 33,
|
|
922
|
+
rightEyeOuter: 263
|
|
923
|
+
}), qe = (e, r = Date.now()) => {
|
|
924
|
+
if (!e || e.length < 468) return null;
|
|
925
|
+
const { leftTemple: t, rightTemple: n, leftEyeOuter: s, rightEyeOuter: o } = Gt, a = ne(e[t], e[n]), i = ne(e[s], e[o]);
|
|
926
|
+
return !a || !i ? null : { faceWidth: a, eyeDistance: i, capturedAt: r };
|
|
927
|
+
}, Kt = Object.freeze({
|
|
928
|
+
leftShoulder: 11,
|
|
929
|
+
rightShoulder: 12,
|
|
930
|
+
leftHip: 23,
|
|
931
|
+
rightHip: 24
|
|
932
|
+
}), Je = (e, r = Date.now()) => {
|
|
933
|
+
if (!e || e.length < 33) return null;
|
|
934
|
+
const { leftShoulder: t, rightShoulder: n, leftHip: s, rightHip: o } = Kt, a = ne(e[t], e[n]), i = ne(e[s], e[o]), u = e[t], c = e[n], h = e[s], d = e[o];
|
|
935
|
+
if (!a || !i || !u || !c || !h || !d) return null;
|
|
936
|
+
const m = Math.hypot(
|
|
937
|
+
(u.x + c.x) / 2 - (h.x + d.x) / 2,
|
|
938
|
+
(u.y + c.y) / 2 - (h.y + d.y) / 2
|
|
939
|
+
);
|
|
940
|
+
return { shoulderWidth: a, hipWidth: i, torsoLength: m, capturedAt: r };
|
|
941
|
+
}, zt = (e, r) => {
|
|
942
|
+
const t = r.face, n = qe(e, 0);
|
|
943
|
+
return !t || !n ? null : t.faceWidth > 0 && n.faceWidth > 0 ? n.faceWidth / t.faceWidth : t.eyeDistance > 0 && n.eyeDistance > 0 ? n.eyeDistance / t.eyeDistance : null;
|
|
944
|
+
}, Wt = (e, r) => {
|
|
945
|
+
const t = r.body, n = Je(e, 0);
|
|
946
|
+
return !t || !n || t.shoulderWidth <= 0 ? null : n.shoulderWidth / t.shoulderWidth;
|
|
947
|
+
}, ie = "vincentt.xr.calibration", Re = () => {
|
|
948
|
+
try {
|
|
949
|
+
return typeof localStorage < "u" ? localStorage : null;
|
|
950
|
+
} catch {
|
|
951
|
+
return null;
|
|
952
|
+
}
|
|
953
|
+
}, Xt = (e = ie, r = Re()) => {
|
|
954
|
+
if (!r) return null;
|
|
955
|
+
try {
|
|
956
|
+
const t = r.getItem(e);
|
|
957
|
+
if (!t) return null;
|
|
958
|
+
const n = JSON.parse(t);
|
|
959
|
+
return !n || typeof n != "object" || n.version !== Se ? null : oe(
|
|
960
|
+
ye,
|
|
961
|
+
{
|
|
962
|
+
orientation: n.orientation,
|
|
963
|
+
mirrored: n.mirrored,
|
|
964
|
+
scale: n.scale,
|
|
965
|
+
offset: n.offset,
|
|
966
|
+
face: n.face ?? null,
|
|
967
|
+
body: n.body ?? null
|
|
968
|
+
},
|
|
969
|
+
typeof n.updatedAt == "number" ? n.updatedAt : 0
|
|
970
|
+
);
|
|
971
|
+
} catch {
|
|
972
|
+
return null;
|
|
973
|
+
}
|
|
974
|
+
}, Yt = (e, r = ie, t = Re()) => {
|
|
975
|
+
if (!t) return !1;
|
|
976
|
+
try {
|
|
977
|
+
return t.setItem(r, JSON.stringify(e)), !0;
|
|
978
|
+
} catch {
|
|
979
|
+
return !1;
|
|
980
|
+
}
|
|
981
|
+
}, Vt = (e = ie, r = Re()) => {
|
|
982
|
+
if (r)
|
|
983
|
+
try {
|
|
984
|
+
r.removeItem(e);
|
|
985
|
+
} catch {
|
|
986
|
+
}
|
|
987
|
+
}, kr = (e = {}) => {
|
|
988
|
+
const { storageKey: r = ie, persist: t = !0 } = e, n = e.storage === void 0 ? void 0 : e.storage, s = g(e.initial), { session: o } = He(), a = tt(
|
|
989
|
+
(l) => o.store.subscribe(l),
|
|
990
|
+
() => o.store.getSnapshot().sourceKind,
|
|
991
|
+
() => {
|
|
992
|
+
}
|
|
993
|
+
), [i, u] = B(
|
|
994
|
+
() => Ft(s.current)
|
|
995
|
+
), [c, h] = B(!t), d = g(i);
|
|
996
|
+
d.current = i, k(() => {
|
|
997
|
+
if (!t) {
|
|
998
|
+
h(!0);
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
const l = Xt(r, n);
|
|
1002
|
+
l && (d.current = l, u(l)), h(!0);
|
|
1003
|
+
}, [t, r, n]);
|
|
1004
|
+
const m = O(
|
|
1005
|
+
(l) => (d.current = l, u(l), t && Yt(l, r, n), l),
|
|
1006
|
+
[t, r, n]
|
|
1007
|
+
), f = O(
|
|
1008
|
+
(l) => m(oe(d.current, l)),
|
|
1009
|
+
[m]
|
|
1010
|
+
), S = O(() => {
|
|
1011
|
+
const l = Bt();
|
|
1012
|
+
return d.current = l, u(l), t && Vt(r, n), l;
|
|
1013
|
+
}, [t, r, n]), T = O(
|
|
1014
|
+
(l) => {
|
|
1015
|
+
const p = qe(l);
|
|
1016
|
+
return p ? (f({ face: p }), !0) : !1;
|
|
1017
|
+
},
|
|
1018
|
+
[f]
|
|
1019
|
+
), y = O(
|
|
1020
|
+
(l) => {
|
|
1021
|
+
const p = Je(l);
|
|
1022
|
+
return p ? (f({ body: p }), !0) : !1;
|
|
1023
|
+
},
|
|
1024
|
+
[f]
|
|
1025
|
+
);
|
|
1026
|
+
return E(
|
|
1027
|
+
() => ({
|
|
1028
|
+
calibration: i,
|
|
1029
|
+
hydrated: c,
|
|
1030
|
+
update: f,
|
|
1031
|
+
reset: S,
|
|
1032
|
+
calibrateFace: T,
|
|
1033
|
+
calibrateBody: y,
|
|
1034
|
+
applyToFeedPoint: (l, p) => jt(l, i, a, p),
|
|
1035
|
+
faceDistance: (l) => zt(l, i),
|
|
1036
|
+
bodyScale: (l) => Wt(l, i),
|
|
1037
|
+
sourceKind: a
|
|
1038
|
+
}),
|
|
1039
|
+
[i, c, f, S, T, y, a]
|
|
1040
|
+
);
|
|
1041
|
+
}, qt = (e, r) => r && !e ? "begin" : !r && e ? "end" : r ? "stay" : "none", Jt = {
|
|
1042
|
+
face: null,
|
|
1043
|
+
faces: [],
|
|
1044
|
+
faceCount: 0,
|
|
1045
|
+
detected: !1,
|
|
1046
|
+
justDetected: !1,
|
|
1047
|
+
justLost: !1,
|
|
1048
|
+
phase: "none"
|
|
1049
|
+
}, _r = ({
|
|
1050
|
+
faceIndex: e = 0,
|
|
1051
|
+
numFaces: r,
|
|
1052
|
+
...t
|
|
1053
|
+
} = {}) => {
|
|
1054
|
+
const n = Number.isFinite(e) ? Math.max(0, Math.round(e)) : 0, s = pt({
|
|
1055
|
+
...t,
|
|
1056
|
+
numFaces: Math.max(r ?? n + 1, n + 1)
|
|
1057
|
+
}), o = g([]), a = g(n), i = g({ detected: !1, faceIndex: n }), [u, c] = B(Jt), h = g(u);
|
|
1058
|
+
return k(() => {
|
|
1059
|
+
o.current = s, a.current = n;
|
|
1060
|
+
}, [s, n]), D(() => {
|
|
1061
|
+
const d = o.current, m = a.current, f = d[m] ?? null, S = !!f, T = i.current.faceIndex === m && i.current.detected, y = qt(T, S);
|
|
1062
|
+
i.current = { detected: S, faceIndex: m };
|
|
1063
|
+
const l = {
|
|
1064
|
+
face: f,
|
|
1065
|
+
faces: d,
|
|
1066
|
+
faceCount: d.length,
|
|
1067
|
+
detected: S,
|
|
1068
|
+
justDetected: y === "begin",
|
|
1069
|
+
justLost: y === "end",
|
|
1070
|
+
phase: y
|
|
1071
|
+
}, p = h.current;
|
|
1072
|
+
p.face === l.face && p.faces === l.faces && p.faceCount === l.faceCount && p.detected === l.detected && p.justDetected === l.justDetected && p.justLost === l.justLost && p.phase === l.phase || (h.current = l, c(l));
|
|
1073
|
+
}), u;
|
|
1074
|
+
}, Pe = (e) => ({
|
|
472
1075
|
action: e,
|
|
473
1076
|
active: !1,
|
|
474
1077
|
value: 0,
|
|
475
1078
|
justStarted: !1,
|
|
476
1079
|
justEnded: !1,
|
|
477
1080
|
phase: "none"
|
|
478
|
-
}),
|
|
479
|
-
const n =
|
|
480
|
-
return
|
|
481
|
-
|
|
482
|
-
}, [e,
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
}, [
|
|
487
|
-
const
|
|
1081
|
+
}), wr = (e, r, t = {}) => {
|
|
1082
|
+
const n = g(Me(r)), s = g(null), o = g(r), a = g({}), [i, u] = B(() => Pe(r)), c = g(i);
|
|
1083
|
+
return k(() => {
|
|
1084
|
+
s.current = e, a.current = t;
|
|
1085
|
+
}, [e, t]), k(() => {
|
|
1086
|
+
o.current = r, n.current = Me(r);
|
|
1087
|
+
const h = Pe(r);
|
|
1088
|
+
c.current = h, u(h);
|
|
1089
|
+
}, [r]), D(({ clock: h }) => {
|
|
1090
|
+
const d = s.current, m = o.current, f = a.current, S = d ? V(d, m, f) : 0, T = It(
|
|
488
1091
|
n.current,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
!!
|
|
492
|
-
|
|
493
|
-
),
|
|
494
|
-
if (
|
|
1092
|
+
S,
|
|
1093
|
+
h.elapsedTime * 1e3,
|
|
1094
|
+
!!d,
|
|
1095
|
+
Ye(m, f)
|
|
1096
|
+
), y = c.current;
|
|
1097
|
+
if (y.action === T.action && y.active === T.active && y.value === T.value && y.justStarted === T.justStarted && y.justEnded === T.justEnded && y.phase === T.phase)
|
|
495
1098
|
return;
|
|
496
|
-
const
|
|
497
|
-
action:
|
|
498
|
-
active:
|
|
499
|
-
value:
|
|
500
|
-
justStarted:
|
|
501
|
-
justEnded:
|
|
502
|
-
phase:
|
|
1099
|
+
const l = {
|
|
1100
|
+
action: T.action,
|
|
1101
|
+
active: T.active,
|
|
1102
|
+
value: T.value,
|
|
1103
|
+
justStarted: T.justStarted,
|
|
1104
|
+
justEnded: T.justEnded,
|
|
1105
|
+
phase: T.phase
|
|
503
1106
|
};
|
|
504
|
-
|
|
505
|
-
}),
|
|
506
|
-
},
|
|
1107
|
+
c.current = l, u(l);
|
|
1108
|
+
}), i;
|
|
1109
|
+
}, Dr = [
|
|
507
1110
|
"angry",
|
|
508
1111
|
"disgust",
|
|
509
1112
|
"fear",
|
|
@@ -512,7 +1115,7 @@ const je = (e) => (de(e), null), he = (e, t) => t && !e ? "begin" : !t && e ? "e
|
|
|
512
1115
|
"sad",
|
|
513
1116
|
"surprise",
|
|
514
1117
|
"unknown"
|
|
515
|
-
],
|
|
1118
|
+
], X = [
|
|
516
1119
|
"angry",
|
|
517
1120
|
"disgust",
|
|
518
1121
|
"fear",
|
|
@@ -520,112 +1123,182 @@ const je = (e) => (de(e), null), he = (e, t) => t && !e ? "begin" : !t && e ? "e
|
|
|
520
1123
|
"neutral",
|
|
521
1124
|
"sad",
|
|
522
1125
|
"surprise"
|
|
523
|
-
],
|
|
524
|
-
let
|
|
525
|
-
for (let
|
|
526
|
-
|
|
527
|
-
const n = new Array(
|
|
528
|
-
let
|
|
529
|
-
for (let
|
|
530
|
-
const
|
|
531
|
-
n[
|
|
1126
|
+
], $t = (e, r = 0.55) => {
|
|
1127
|
+
let t = -1 / 0;
|
|
1128
|
+
for (let c = 0; c < X.length; c += 1)
|
|
1129
|
+
t = Math.max(t, Number(e[c]) || 0);
|
|
1130
|
+
const n = new Array(X.length);
|
|
1131
|
+
let s = 0;
|
|
1132
|
+
for (let c = 0; c < X.length; c += 1) {
|
|
1133
|
+
const h = Math.exp((Number(e[c]) || 0) - t);
|
|
1134
|
+
n[c] = h, s += h;
|
|
532
1135
|
}
|
|
533
|
-
const
|
|
534
|
-
let
|
|
535
|
-
for (let
|
|
536
|
-
const
|
|
537
|
-
|
|
1136
|
+
const o = Object.fromEntries(X.map((c) => [c, 0]));
|
|
1137
|
+
let a = "unknown", i = 0;
|
|
1138
|
+
for (let c = 0; c < X.length; c += 1) {
|
|
1139
|
+
const h = s ? n[c] / s : 0, d = X[c];
|
|
1140
|
+
o[d] = h, h > i && (a = d, i = h);
|
|
538
1141
|
}
|
|
539
|
-
const
|
|
540
|
-
return { expression:
|
|
541
|
-
},
|
|
542
|
-
const
|
|
543
|
-
for (let n = 0,
|
|
544
|
-
|
|
545
|
-
return
|
|
546
|
-
},
|
|
547
|
-
let
|
|
548
|
-
return
|
|
549
|
-
throw
|
|
550
|
-
}),
|
|
551
|
-
},
|
|
552
|
-
active:
|
|
553
|
-
targetFps:
|
|
1142
|
+
const u = Number.isFinite(r) ? Math.min(1, Math.max(0, r)) : 0.55;
|
|
1143
|
+
return { expression: i >= u ? a : "unknown", confidence: i, scores: o };
|
|
1144
|
+
}, Zt = (e) => {
|
|
1145
|
+
const r = e.width * e.height, t = new Float32Array(r * 3);
|
|
1146
|
+
for (let n = 0, s = 0; n < r; n += 1, s += 4)
|
|
1147
|
+
t[n] = e.data[s] / 127.5 - 1, t[r + n] = e.data[s + 1] / 127.5 - 1, t[r * 2 + n] = e.data[s + 2] / 127.5 - 1;
|
|
1148
|
+
return t;
|
|
1149
|
+
}, Qt = "https://huggingface.co/opencv/facial_expression_recognition/resolve/main/facial_expression_recognition_mobilefacenet_2022july_int8.onnx", er = (e) => `https://cdn.jsdelivr.net/npm/onnxruntime-web@${e.env.versions.web}/dist/`, fe = /* @__PURE__ */ new Map(), tr = (e) => {
|
|
1150
|
+
let r = fe.get(e);
|
|
1151
|
+
return r || (r = Promise.all([import("onnxruntime-web/wasm"), st(e)]).then(([t, n]) => (t.env.wasm.wasmPaths = er(t), t.InferenceSession.create(n, { executionProviders: ["wasm"] }))).catch((t) => {
|
|
1152
|
+
throw fe.delete(e), t;
|
|
1153
|
+
}), fe.set(e, r)), r;
|
|
1154
|
+
}, Ir = (e, {
|
|
1155
|
+
active: r = !0,
|
|
1156
|
+
targetFps: t = 5,
|
|
554
1157
|
minConfidence: n = 0.55,
|
|
555
|
-
modelUrl:
|
|
1158
|
+
modelUrl: s = Qt
|
|
556
1159
|
} = {}) => {
|
|
557
|
-
const { session:
|
|
1160
|
+
const { session: o } = He(), a = g(null), i = g(null), u = g(!1), c = g(-1 / 0), h = g(!0), [d, m] = B({
|
|
558
1161
|
status: "idle",
|
|
559
1162
|
result: null,
|
|
560
1163
|
error: null
|
|
561
1164
|
});
|
|
562
|
-
return
|
|
563
|
-
const
|
|
564
|
-
return
|
|
565
|
-
|
|
1165
|
+
return k(() => {
|
|
1166
|
+
const f = document.createElement("canvas");
|
|
1167
|
+
return a.current = f, i.current = f.getContext("2d", { willReadFrequently: !0 }), h.current = !0, () => {
|
|
1168
|
+
h.current = !1, a.current = null, i.current = null;
|
|
566
1169
|
};
|
|
567
|
-
}, []),
|
|
568
|
-
if (!
|
|
569
|
-
const
|
|
570
|
-
if (
|
|
571
|
-
const
|
|
572
|
-
if (!
|
|
573
|
-
|
|
574
|
-
const
|
|
575
|
-
Promise.all([import("onnxruntime-web/wasm"),
|
|
576
|
-
const
|
|
577
|
-
[
|
|
578
|
-
}),
|
|
579
|
-
|
|
1170
|
+
}, []), D(({ clock: f }) => {
|
|
1171
|
+
if (!r || !e || u.current || d.status === "error") return;
|
|
1172
|
+
const S = Number.isFinite(t) && t > 0 ? t : 5, T = f.elapsedTime * 1e3;
|
|
1173
|
+
if (T - c.current < 1e3 / S) return;
|
|
1174
|
+
const y = o.getInputFrame(), l = a.current, p = i.current;
|
|
1175
|
+
if (!y || !l || !p || !wt({ source: y, face: e, canvas: l, outputSize: { width: 112, height: 112 } })) return;
|
|
1176
|
+
c.current = T, u.current = !0, d.status === "idle" && m({ status: "loading", result: null, error: null });
|
|
1177
|
+
const _ = Zt(p.getImageData(0, 0, 112, 112));
|
|
1178
|
+
Promise.all([import("onnxruntime-web/wasm"), tr(s)]).then(async ([x, N]) => {
|
|
1179
|
+
const F = await N.run({
|
|
1180
|
+
[N.inputNames[0]]: new x.Tensor("float32", _, [1, 3, 112, 112])
|
|
1181
|
+
}), C = $t(
|
|
1182
|
+
F[N.outputNames[0]].data,
|
|
580
1183
|
n
|
|
581
1184
|
);
|
|
582
|
-
|
|
583
|
-
}).catch((
|
|
584
|
-
|
|
1185
|
+
h.current && m({ status: "ready", result: C, error: null });
|
|
1186
|
+
}).catch((x) => {
|
|
1187
|
+
h.current && m({
|
|
585
1188
|
status: "error",
|
|
586
1189
|
result: null,
|
|
587
|
-
error:
|
|
1190
|
+
error: x instanceof Error ? x : new Error(String(x))
|
|
588
1191
|
});
|
|
589
1192
|
}).finally(() => {
|
|
590
|
-
|
|
1193
|
+
u.current = !1;
|
|
591
1194
|
});
|
|
592
|
-
}),
|
|
1195
|
+
}), d;
|
|
593
1196
|
};
|
|
594
1197
|
export {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
1198
|
+
Kt as BODY_CALIBRATION_LANDMARKS,
|
|
1199
|
+
Jr as BODY_TARGETS,
|
|
1200
|
+
gr as BodyTracker,
|
|
1201
|
+
ie as CALIBRATION_STORAGE_KEY,
|
|
1202
|
+
Se as CALIBRATION_VERSION,
|
|
1203
|
+
ye as DEFAULT_CALIBRATION,
|
|
1204
|
+
Dt as DEFAULT_FACE_ACTION_OPTIONS,
|
|
1205
|
+
Qt as DEFAULT_FACE_ATTRIBUTE_EXPRESSION_MODEL_URL,
|
|
1206
|
+
on as DEFAULT_FACE_EXPRESSION_THRESHOLD,
|
|
1207
|
+
nn as DEFAULT_GESTURE_DETECTOR_OPTIONS,
|
|
1208
|
+
vn as DEFAULT_GESTURE_SETTINGS,
|
|
1209
|
+
Br as DEFAULT_HOLISTIC_ANALYSIS_MAX_DIMENSION,
|
|
1210
|
+
Ur as DEFAULT_HOLISTIC_HOLD_MS,
|
|
1211
|
+
jr as DEFAULT_HOLISTIC_MODEL_URL,
|
|
1212
|
+
Gr as DEFAULT_HOLISTIC_PREDICT_MS,
|
|
1213
|
+
pe as DEFAULT_HOLISTIC_SIGNAL_THRESHOLDS,
|
|
1214
|
+
On as DEFAULT_HOLISTIC_TRACKER_SETTINGS,
|
|
1215
|
+
hn as DEFAULT_POLICY_NUM_FACES,
|
|
1216
|
+
Kn as DEFAULT_SEGMENTATION_OVERLAY_SETTINGS,
|
|
1217
|
+
fn as DEFAULT_SUBJECT_POLICY,
|
|
1218
|
+
$r as DEFAULT_TRACKING_ANCHOR,
|
|
1219
|
+
mn as EMPTY_SUBJECT_MEMORY,
|
|
1220
|
+
Er as FACE_ACTION_NAMES,
|
|
1221
|
+
Dr as FACE_ATTRIBUTE_EXPRESSION_NAMES,
|
|
1222
|
+
Rr as FACE_BLENDSHAPE_NAMES,
|
|
1223
|
+
Gt as FACE_CALIBRATION_LANDMARKS,
|
|
1224
|
+
Mr as FACE_LANDMARK_INDICES,
|
|
1225
|
+
Zr as FACE_TARGETS,
|
|
1226
|
+
Fr as FaceMesh,
|
|
1227
|
+
Pr as FaceTracker,
|
|
1228
|
+
Ve as GESTURES,
|
|
1229
|
+
xr as GESTURE_NAMES,
|
|
1230
|
+
Ln as GESTURE_SETTINGS_FIELDS,
|
|
1231
|
+
Or as GestureListener,
|
|
1232
|
+
pr as GestureTracker,
|
|
1233
|
+
yr as GestureTrigger,
|
|
1234
|
+
Qr as HAND_TARGETS,
|
|
1235
|
+
kn as HOLISTIC_HANDS_OPTIONS,
|
|
1236
|
+
_n as HOLISTIC_TRACKER_SETTINGS_FIELDS,
|
|
1237
|
+
mr as HandTracker,
|
|
1238
|
+
Te as HolisticTracker,
|
|
1239
|
+
Fn as IRIS_LANDMARKS,
|
|
1240
|
+
Pn as IRIS_LANDMARK_COUNT,
|
|
1241
|
+
Hn as PERSON_MASK_LABELS,
|
|
1242
|
+
ke as SEGMENTATION_TYPES,
|
|
1243
|
+
Vr as SEMANTIC_SEGMENTATION_PRESETS,
|
|
1244
|
+
Sr as Segmentation,
|
|
1245
|
+
bn as SegmentationOverlay,
|
|
1246
|
+
en as TrackingAnchor,
|
|
1247
|
+
pn as XR_MAX_SUBJECTS,
|
|
1248
|
+
jt as applyCalibrationToFeedPoint,
|
|
1249
|
+
gn as associateSubjects,
|
|
1250
|
+
Vt as clearCalibration,
|
|
1251
|
+
Kr as clearSemanticMask,
|
|
1252
|
+
Ft as createCalibration,
|
|
1253
|
+
Rt as createHolisticSignals,
|
|
1254
|
+
zr as createSemanticMask,
|
|
1255
|
+
vr as defineGesture,
|
|
1256
|
+
wt as drawFaceCrop,
|
|
1257
|
+
Wt as estimateBodyScale,
|
|
1258
|
+
zt as estimateFaceDistance,
|
|
1259
|
+
Tn as faceCandidates,
|
|
1260
|
+
V as getFaceActionValue,
|
|
1261
|
+
A as getFaceBlendshape,
|
|
1262
|
+
an as getFaceEyeDistance,
|
|
1263
|
+
Tr as getHolisticSignals,
|
|
1264
|
+
Ar as getStrongestFaceAction,
|
|
1265
|
+
tn as getTargetNamespace,
|
|
1266
|
+
br as hasFaceAction,
|
|
1267
|
+
cn as hasFaceExpression,
|
|
1268
|
+
Ne as isHandRaised,
|
|
1269
|
+
Lr as isIdentityCalibration,
|
|
1270
|
+
Ie as isPalmOpen,
|
|
1271
|
+
Sn as jointCandidates,
|
|
1272
|
+
Xt as loadCalibration,
|
|
1273
|
+
Je as measureBodyCalibration,
|
|
1274
|
+
qe as measureFaceCalibration,
|
|
1275
|
+
Wr as normalizedTrackerPointToTrackerPoint,
|
|
1276
|
+
wn as patchGestureSettings,
|
|
1277
|
+
Dn as patchHolisticTrackerSettings,
|
|
1278
|
+
zn as patchSegmentationOverlaySettings,
|
|
1279
|
+
Bt as resetCalibration,
|
|
1280
|
+
Ut as resolveCalibrationMirror,
|
|
1281
|
+
Nt as resolveGestureDefinition,
|
|
1282
|
+
_e as resolveGestureDetectorOptions,
|
|
1283
|
+
In as resolveGestureSettings,
|
|
1284
|
+
Nn as resolveHolisticTrackerSettings,
|
|
1285
|
+
Wn as resolveSegmentationOverlaySettings,
|
|
1286
|
+
Yt as saveCalibration,
|
|
1287
|
+
yn as selectSubject,
|
|
1288
|
+
Cn as toHolisticTrackerProps,
|
|
1289
|
+
Xr as trackerPointToNormalizedTrackerPoint,
|
|
1290
|
+
oe as updateCalibration,
|
|
1291
|
+
wr as useFaceAction,
|
|
1292
|
+
Ir as useFaceAttributeExpression,
|
|
1293
|
+
_r as useFaceDetection,
|
|
1294
|
+
Rn as useFaceInfo,
|
|
1295
|
+
pt as useFaceInfos,
|
|
1296
|
+
ln as useFaceResults,
|
|
1297
|
+
Mt as useGesture,
|
|
1298
|
+
Bn as useHairMask,
|
|
1299
|
+
bt as useHolisticTracking,
|
|
1300
|
+
An as useIrisTracking,
|
|
1301
|
+
Un as usePersonMask,
|
|
1302
|
+
jn as useSemanticSegmentationMask,
|
|
1303
|
+
kr as useXRCalibration
|
|
631
1304
|
};
|