@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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var S = (t, s, e) => s in t ? y(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
|
|
3
|
+
var f = (t, s, e) => S(t, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
+
import { useCallback as B } from "react";
|
|
5
|
+
import { p as M, u as v } from "./getFaceInfo-BkZfaQs-.js";
|
|
6
|
+
const F = ({
|
|
7
|
+
node: t,
|
|
8
|
+
enabled: s,
|
|
9
|
+
selectedSource: e,
|
|
10
|
+
throttleMs: i = 16,
|
|
11
|
+
holdMs: r = 250,
|
|
12
|
+
onFrame: l
|
|
13
|
+
}) => {
|
|
14
|
+
const c = B(
|
|
15
|
+
(a) => M(a.faceLandmarks ?? []),
|
|
16
|
+
[e]
|
|
17
|
+
);
|
|
18
|
+
return v({ enabled: s, holdMs: r, node: t, onFrame: l, prepare: c, throttleMs: i });
|
|
19
|
+
}, u = (t) => Number.isFinite(t) ? Math.max(0, Math.min(1, t)) : 0, m = (t, s) => Math.hypot(t.x - s.x, t.y - s.y), n = {
|
|
20
|
+
wrist: 0,
|
|
21
|
+
thumbTip: 4,
|
|
22
|
+
indexBase: 5,
|
|
23
|
+
indexTip: 8,
|
|
24
|
+
middleBase: 9,
|
|
25
|
+
middleTip: 12,
|
|
26
|
+
ringBase: 13,
|
|
27
|
+
ringTip: 16,
|
|
28
|
+
pinkyBase: 17,
|
|
29
|
+
pinkyTip: 20
|
|
30
|
+
}, d = [
|
|
31
|
+
[n.indexBase, n.indexTip],
|
|
32
|
+
[n.middleBase, n.middleTip],
|
|
33
|
+
[n.ringBase, n.ringTip],
|
|
34
|
+
[n.pinkyBase, n.pinkyTip]
|
|
35
|
+
], h = (t) => t !== void 0 && t.length >= 21, g = (t) => h(t) ? m(t[n.wrist], t[n.middleBase]) : 0, O = (t) => {
|
|
36
|
+
if (!h(t)) return 0;
|
|
37
|
+
const s = g(t);
|
|
38
|
+
if (s <= 0) return 0;
|
|
39
|
+
const e = m(t[n.thumbTip], t[n.indexTip]) / s;
|
|
40
|
+
return u(1 - (e - 0.15) / 0.85);
|
|
41
|
+
}, x = (t, s, e) => {
|
|
42
|
+
const i = t[n.wrist], r = m(t[s], i);
|
|
43
|
+
if (r <= 0) return 0;
|
|
44
|
+
const l = m(t[e], i) / r;
|
|
45
|
+
return u((1.6 - l) / 0.6);
|
|
46
|
+
}, R = (t, s = [0, 0, 0, 0]) => {
|
|
47
|
+
for (let e = 0; e < d.length; e += 1) {
|
|
48
|
+
const [i, r] = d[e];
|
|
49
|
+
s[e] = 1 - x(t, i, r);
|
|
50
|
+
}
|
|
51
|
+
return s;
|
|
52
|
+
}, b = (t) => {
|
|
53
|
+
const s = g(t);
|
|
54
|
+
if (s <= 0) return 0;
|
|
55
|
+
const e = m(t[n.thumbTip], t[n.indexBase]) / s;
|
|
56
|
+
return u((e - 0.45) / 0.5);
|
|
57
|
+
}, p = (t) => {
|
|
58
|
+
const s = g(t);
|
|
59
|
+
if (s <= 0) return 0;
|
|
60
|
+
const e = (t[n.thumbTip].y - t[n.indexBase].y) / s;
|
|
61
|
+
return Math.max(-1, Math.min(1, e / 0.6));
|
|
62
|
+
}, V = (t, s) => {
|
|
63
|
+
if (!h(t)) return 0;
|
|
64
|
+
const e = R(t);
|
|
65
|
+
let i = 1;
|
|
66
|
+
for (let r = 0; r < 4; r += 1) {
|
|
67
|
+
const l = s.fingers[r];
|
|
68
|
+
l !== null && (i = Math.min(i, l ? e[r] : 1 - e[r]));
|
|
69
|
+
}
|
|
70
|
+
if (s.thumb !== void 0 && s.thumb !== null) {
|
|
71
|
+
const r = b(t);
|
|
72
|
+
i = Math.min(i, s.thumb ? r : 1 - r);
|
|
73
|
+
}
|
|
74
|
+
return i;
|
|
75
|
+
}, N = (t, s) => {
|
|
76
|
+
if (!h(t)) return 0;
|
|
77
|
+
const e = V(t, { fingers: [!1, !1, !1, !1] }), i = u(s === "up" ? p(t) : -p(t));
|
|
78
|
+
return Math.min(e, b(t), i);
|
|
79
|
+
}, k = (t) => {
|
|
80
|
+
if (!h(t)) return 0;
|
|
81
|
+
let s = 0;
|
|
82
|
+
for (const [e, i] of d) s += x(t, e, i);
|
|
83
|
+
return s / d.length;
|
|
84
|
+
}, z = (t) => h(t) ? 1 - k(t) : 0, q = (t) => h(t) ? u((t[n.wrist].y + 1) / 2) : 0, o = {
|
|
85
|
+
leftShoulder: 11,
|
|
86
|
+
rightShoulder: 12,
|
|
87
|
+
leftElbow: 13,
|
|
88
|
+
rightElbow: 14,
|
|
89
|
+
leftWrist: 15,
|
|
90
|
+
rightWrist: 16,
|
|
91
|
+
leftHip: 23,
|
|
92
|
+
rightHip: 24
|
|
93
|
+
}, T = (t) => t !== void 0 && t.length >= 33, w = (t) => m(t[o.leftShoulder], t[o.rightShoulder]), A = (t, s) => {
|
|
94
|
+
if (!T(t)) return 0;
|
|
95
|
+
const e = w(t);
|
|
96
|
+
if (e <= 0) return 0;
|
|
97
|
+
const i = t[s === "left" ? o.leftWrist : o.rightWrist], r = t[s === "left" ? o.leftShoulder : o.rightShoulder];
|
|
98
|
+
return u((i.y - r.y) / e);
|
|
99
|
+
}, C = (t) => {
|
|
100
|
+
if (!T(t)) return 0;
|
|
101
|
+
const s = w(t);
|
|
102
|
+
if (s <= 0) return 0;
|
|
103
|
+
let e = 1;
|
|
104
|
+
for (const i of ["left", "right"]) {
|
|
105
|
+
const r = t[i === "left" ? o.leftWrist : o.rightWrist], l = t[i === "left" ? o.leftShoulder : o.rightShoulder], c = u(1 - Math.abs(r.y - l.y) / (s * 0.5)), a = i === "left" ? r.x - l.x : l.x - r.x, E = u(a / s);
|
|
106
|
+
e = Math.min(e, c, E);
|
|
107
|
+
}
|
|
108
|
+
return e;
|
|
109
|
+
};
|
|
110
|
+
class D {
|
|
111
|
+
constructor(s) {
|
|
112
|
+
f(this, "reversals", []);
|
|
113
|
+
f(this, "lastExtremum", null);
|
|
114
|
+
f(this, "lastValue", null);
|
|
115
|
+
f(this, "direction", 0);
|
|
116
|
+
this.options = s;
|
|
117
|
+
}
|
|
118
|
+
reset() {
|
|
119
|
+
this.reversals = [], this.lastExtremum = null, this.lastValue = null, this.direction = 0;
|
|
120
|
+
}
|
|
121
|
+
/** Feed one sample; returns the oscillation progress 0..1. */
|
|
122
|
+
push(s, e) {
|
|
123
|
+
const { minAmplitude: i, requiredReversals: r, windowMs: l } = this.options;
|
|
124
|
+
if (this.lastExtremum === null || this.lastValue === null)
|
|
125
|
+
return this.lastExtremum = s, this.lastValue = s, this.progress(e);
|
|
126
|
+
const c = s - this.lastValue, a = c > 0 ? 1 : c < 0 ? -1 : 0;
|
|
127
|
+
for (a !== 0 && (this.direction === 0 ? Math.abs(s - this.lastExtremum) >= i && (this.direction = a) : a !== this.direction ? Math.abs(this.lastValue - this.lastExtremum) >= i && (this.reversals.push(e), this.lastExtremum = this.lastValue, this.direction = a) : this.direction > 0 && s > this.lastExtremum || this.direction < 0 && s < this.lastExtremum), this.lastValue = s; this.reversals.length > 0 && e - this.reversals[0] > l; )
|
|
128
|
+
this.reversals.shift();
|
|
129
|
+
return this.progress(e);
|
|
130
|
+
}
|
|
131
|
+
progress(s) {
|
|
132
|
+
const { requiredReversals: e, windowMs: i } = this.options;
|
|
133
|
+
for (; this.reversals.length > 0 && s - this.reversals[0] > i; )
|
|
134
|
+
this.reversals.shift();
|
|
135
|
+
return u(this.reversals.length / e);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
n as H,
|
|
140
|
+
D as O,
|
|
141
|
+
o as P,
|
|
142
|
+
A as a,
|
|
143
|
+
N as b,
|
|
144
|
+
V as c,
|
|
145
|
+
q as d,
|
|
146
|
+
z as e,
|
|
147
|
+
k as f,
|
|
148
|
+
O as g,
|
|
149
|
+
R as h,
|
|
150
|
+
b as i,
|
|
151
|
+
C as m,
|
|
152
|
+
p as t,
|
|
153
|
+
F as u
|
|
154
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=Object.defineProperty;var R=(t,e,s)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var f=(t,e,s)=>R(t,typeof e!="symbol"?e+"":e,s);const v=require("react"),b=require("./getFaceInfo-ahPxQFGu.cjs"),O=({node:t,enabled:e,selectedSource:s,throttleMs:i=16,holdMs:r=250,onFrame:l})=>{const h=v.useCallback(a=>b.prepareCalibrationFaceResults(a.faceLandmarks??[]),[s]);return b.useFaceResultReader({enabled:e,holdMs:r,node:t,onFrame:l,prepare:h,throttleMs:i})},o=t=>Number.isFinite(t)?Math.max(0,Math.min(1,t)):0,m=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),n={wrist:0,thumbTip:4,indexBase:5,indexTip:8,middleBase:9,middleTip:12,ringBase:13,ringTip:16,pinkyBase:17,pinkyTip:20},d=[[n.indexBase,n.indexTip],[n.middleBase,n.middleTip],[n.ringBase,n.ringTip],[n.pinkyBase,n.pinkyTip]],c=t=>t!==void 0&&t.length>=21,x=t=>c(t)?m(t[n.wrist],t[n.middleBase]):0,F=t=>{if(!c(t))return 0;const e=x(t);if(e<=0)return 0;const s=m(t[n.thumbTip],t[n.indexTip])/e;return o(1-(s-.15)/.85)},T=(t,e,s)=>{const i=t[n.wrist],r=m(t[e],i);if(r<=0)return 0;const l=m(t[s],i)/r;return o((1.6-l)/.6)},E=(t,e=[0,0,0,0])=>{for(let s=0;s<d.length;s+=1){const[i,r]=d[s];e[s]=1-T(t,i,r)}return e},p=t=>{const e=x(t);if(e<=0)return 0;const s=m(t[n.thumbTip],t[n.indexBase])/e;return o((s-.45)/.5)},g=t=>{const e=x(t);if(e<=0)return 0;const s=(t[n.thumbTip].y-t[n.indexBase].y)/e;return Math.max(-1,Math.min(1,s/.6))},S=(t,e)=>{if(!c(t))return 0;const s=E(t);let i=1;for(let r=0;r<4;r+=1){const l=e.fingers[r];l!==null&&(i=Math.min(i,l?s[r]:1-s[r]))}if(e.thumb!==void 0&&e.thumb!==null){const r=p(t);i=Math.min(i,e.thumb?r:1-r)}return i},H=(t,e)=>{if(!c(t))return 0;const s=S(t,{fingers:[!1,!1,!1,!1]}),i=o(e==="up"?g(t):-g(t));return Math.min(s,p(t),i)},w=t=>{if(!c(t))return 0;let e=0;for(const[s,i]of d)e+=T(t,s,i);return e/d.length},k=t=>c(t)?1-w(t):0,N=t=>c(t)?o((t[n.wrist].y+1)/2):0,u={leftShoulder:11,rightShoulder:12,leftElbow:13,rightElbow:14,leftWrist:15,rightWrist:16,leftHip:23,rightHip:24},y=t=>t!==void 0&&t.length>=33,B=t=>m(t[u.leftShoulder],t[u.rightShoulder]),V=(t,e)=>{if(!y(t))return 0;const s=B(t);if(s<=0)return 0;const i=t[e==="left"?u.leftWrist:u.rightWrist],r=t[e==="left"?u.leftShoulder:u.rightShoulder];return o((i.y-r.y)/s)},W=t=>{if(!y(t))return 0;const e=B(t);if(e<=0)return 0;let s=1;for(const i of["left","right"]){const r=t[i==="left"?u.leftWrist:u.rightWrist],l=t[i==="left"?u.leftShoulder:u.rightShoulder],h=o(1-Math.abs(r.y-l.y)/(e*.5)),a=i==="left"?r.x-l.x:l.x-r.x,M=o(a/e);s=Math.min(s,h,M)}return s};class I{constructor(e){f(this,"reversals",[]);f(this,"lastExtremum",null);f(this,"lastValue",null);f(this,"direction",0);this.options=e}reset(){this.reversals=[],this.lastExtremum=null,this.lastValue=null,this.direction=0}push(e,s){const{minAmplitude:i,requiredReversals:r,windowMs:l}=this.options;if(this.lastExtremum===null||this.lastValue===null)return this.lastExtremum=e,this.lastValue=e,this.progress(s);const h=e-this.lastValue,a=h>0?1:h<0?-1:0;for(a!==0&&(this.direction===0?Math.abs(e-this.lastExtremum)>=i&&(this.direction=a):a!==this.direction?Math.abs(this.lastValue-this.lastExtremum)>=i&&(this.reversals.push(s),this.lastExtremum=this.lastValue,this.direction=a):this.direction>0&&e>this.lastExtremum||this.direction<0&&e<this.lastExtremum),this.lastValue=e;this.reversals.length>0&&s-this.reversals[0]>l;)this.reversals.shift();return this.progress(s)}progress(e){const{requiredReversals:s,windowMs:i}=this.options;for(;this.reversals.length>0&&e-this.reversals[0]>i;)this.reversals.shift();return o(this.reversals.length/s)}}exports.HAND_JOINTS=n;exports.OscillationTracker=I;exports.POSE_JOINTS=u;exports.fingerExtensions=E;exports.measureArmRaise=V;exports.measureFingerPattern=S;exports.measureGrab=w;exports.measureHandHeight=N;exports.measureOpenPalm=k;exports.measurePinch=F;exports.measureTPose=W;exports.measureThumb=H;exports.thumbDirection=g;exports.thumbExtension=p;exports.useFaceResults=O;
|
|
@@ -1,11 +1,60 @@
|
|
|
1
1
|
import { RunModelParams } from '../../types';
|
|
2
2
|
import { PerformanceData } from '../../types/common';
|
|
3
|
+
/**
|
|
4
|
+
* Per-model health read by `useXRDiagnostics`. Every field is a current value
|
|
5
|
+
* (not an event); `null` means "not measured yet" or "not applicable".
|
|
6
|
+
*/
|
|
7
|
+
export type XRModelDiagnostics = {
|
|
8
|
+
/** Duration of the last inference in milliseconds. */
|
|
9
|
+
inferenceMs: number | null;
|
|
10
|
+
/** Inferences per second over the last ~1 s window. */
|
|
11
|
+
inferenceFps: number;
|
|
12
|
+
/** Total inferences since `run()`. */
|
|
13
|
+
inferences: number;
|
|
14
|
+
/**
|
|
15
|
+
* RAF ticks the model saw but did not analyse (throttled by `targetFps`, or
|
|
16
|
+
* skipped while busy). A high value next to a low `inferenceFps` means the
|
|
17
|
+
* cap is doing its job; a high value with no cap means the device is slow.
|
|
18
|
+
*/
|
|
19
|
+
skippedFrames: number;
|
|
20
|
+
/** Subjects detected in the last inference (faces, hands, bodies; `null` when not applicable). */
|
|
21
|
+
detections: number | null;
|
|
22
|
+
/** Detector confidence of the primary subject, 0..1 (`null` when the model reports none). */
|
|
23
|
+
confidence: number | null;
|
|
24
|
+
/** `error` when the last inference threw; models without inline status report `"ready"`. */
|
|
25
|
+
status: "ready" | "error";
|
|
26
|
+
error: Error | null;
|
|
27
|
+
paused: boolean;
|
|
28
|
+
disposed: boolean;
|
|
29
|
+
};
|
|
3
30
|
export declare class BaseXRModel {
|
|
4
31
|
protected disposed: boolean;
|
|
5
32
|
protected paused: boolean;
|
|
6
33
|
protected rafId: number | null;
|
|
34
|
+
private statInferenceMs;
|
|
35
|
+
private statInferences;
|
|
36
|
+
private statWindowStart;
|
|
37
|
+
private statWindowCount;
|
|
38
|
+
private statFps;
|
|
39
|
+
private statSkipped;
|
|
40
|
+
private statDetections;
|
|
41
|
+
private statConfidence;
|
|
42
|
+
private statStatus;
|
|
43
|
+
private statError;
|
|
44
|
+
/** Record one completed inference that started at `startMs` (`performance.now()`). */
|
|
45
|
+
protected recordInference(startMs: number, endMs?: number): number;
|
|
46
|
+
/** Record what the last inference found (subjects and the primary confidence). */
|
|
47
|
+
protected recordDetections(count: number | null, confidence?: number | null): void;
|
|
48
|
+
/** Record an inference failure (or clear it with `null`). */
|
|
49
|
+
protected recordInferenceError(error: Error | null): void;
|
|
50
|
+
/** Current health snapshot. Allocates a small object; sample it at UI rate, not per frame. */
|
|
51
|
+
getDiagnostics(): XRModelDiagnostics;
|
|
7
52
|
protected targetFrameIntervalMs: number;
|
|
8
53
|
protected lastInferenceMs: number;
|
|
54
|
+
/** Analysis-resolution multiplier (0.25..1) from the quality tier; subclasses read it where they downscale. */
|
|
55
|
+
protected analysisScale: number;
|
|
56
|
+
/** Clamp and store the analysis scale; subclasses with a downscaler forward it. */
|
|
57
|
+
protected setAnalysisScale(scale: number | undefined): void;
|
|
9
58
|
/** Set the per-frame inference cap. fps <= 0 (or undefined) → uncapped. */
|
|
10
59
|
protected setTargetFps(fps: number | undefined): void;
|
|
11
60
|
/**
|
|
@@ -16,7 +16,7 @@ export declare class BodyTrackingModel extends BaseXRModel {
|
|
|
16
16
|
dispose(): void;
|
|
17
17
|
private getLandmarks2D;
|
|
18
18
|
initialize(options?: BodyModelOptions): Promise<void>;
|
|
19
|
-
run({ sourceCanvas, targetFps }: RunModelParams): Promise<void>;
|
|
19
|
+
run({ sourceCanvas, targetFps, analysisScale }: RunModelParams): Promise<void>;
|
|
20
20
|
getModelNode(): XRModelNodeBodyTracking;
|
|
21
21
|
getPerformanceData(): Promise<PerformanceData>;
|
|
22
22
|
}
|
|
@@ -30,7 +30,7 @@ export declare class FaceTrackingModel extends BaseXRModel {
|
|
|
30
30
|
private getDetectionResults;
|
|
31
31
|
private getRawFaceTrackingData;
|
|
32
32
|
initialize(options?: FaceModelOptions): Promise<void>;
|
|
33
|
-
run({ sourceCanvas, getSource, targetFps }: RunModelParams): Promise<void>;
|
|
33
|
+
run({ sourceCanvas, getSource, targetFps, analysisScale, }: RunModelParams): Promise<void>;
|
|
34
34
|
getModelNode(): XRModelNodeFaceTracking;
|
|
35
35
|
getPerformanceData(): Promise<PerformanceData>;
|
|
36
36
|
}
|
|
@@ -15,7 +15,7 @@ export declare class GestureTrackingModel extends BaseXRModel {
|
|
|
15
15
|
resume(): void;
|
|
16
16
|
dispose(): void;
|
|
17
17
|
initialize(): Promise<void>;
|
|
18
|
-
run({ sourceCanvas, targetFps }: RunModelParams): Promise<void>;
|
|
18
|
+
run({ sourceCanvas, targetFps, analysisScale }: RunModelParams): Promise<void>;
|
|
19
19
|
getModelNode(): XRModelNodeGestureTracking;
|
|
20
20
|
getPerformanceData(): Promise<PerformanceData>;
|
|
21
21
|
}
|
|
@@ -17,7 +17,7 @@ export declare class HandTrackingModel extends BaseXRModel {
|
|
|
17
17
|
resume(): void;
|
|
18
18
|
dispose(): void;
|
|
19
19
|
initialize(): Promise<void>;
|
|
20
|
-
run({ sourceCanvas, targetFps }: RunModelParams): Promise<void>;
|
|
20
|
+
run({ sourceCanvas, targetFps, analysisScale }: RunModelParams): Promise<void>;
|
|
21
21
|
getModelNode(): XRModelNodeHandTracking;
|
|
22
22
|
getPerformanceData(): Promise<PerformanceData>;
|
|
23
23
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RunModelParams } from '../../types';
|
|
2
|
+
import { PerformanceData } from '../../types/common';
|
|
3
|
+
import { HolisticModelOptions } from '../../types/holistic';
|
|
4
|
+
import { XRModelNodeHolisticTracking } from '../../types/nodes';
|
|
5
|
+
import { BaseXRModel } from '../Base';
|
|
6
|
+
export declare class HolisticTrackingModel extends BaseXRModel {
|
|
7
|
+
private landmarker;
|
|
8
|
+
private status;
|
|
9
|
+
private error;
|
|
10
|
+
private processingTime;
|
|
11
|
+
private sourceCanvas;
|
|
12
|
+
private getSource;
|
|
13
|
+
private downscaler;
|
|
14
|
+
private raw;
|
|
15
|
+
private delegatePolicy;
|
|
16
|
+
private delegate;
|
|
17
|
+
/** Kept so the graph can be rebuilt on another delegate without refetching. */
|
|
18
|
+
private vision;
|
|
19
|
+
private modelBuffer;
|
|
20
|
+
private graphOptions;
|
|
21
|
+
private rebuilding;
|
|
22
|
+
private fallbackAttempted;
|
|
23
|
+
private readonly result;
|
|
24
|
+
private readonly builder;
|
|
25
|
+
private readonly node;
|
|
26
|
+
constructor();
|
|
27
|
+
private setRuntimeOptions;
|
|
28
|
+
initialize(options?: HolisticModelOptions): Promise<void>;
|
|
29
|
+
private createLandmarker;
|
|
30
|
+
/**
|
|
31
|
+
* The GPU graph can fail on its first run (the face-blendshape stage has no
|
|
32
|
+
* WebGL kernel for one of its ops). Rebuild on the CPU once, keep the RAF
|
|
33
|
+
* loop alive meanwhile, and run one detection right away so static sources
|
|
34
|
+
* (which pulse models once) still get a result.
|
|
35
|
+
*/
|
|
36
|
+
private fallbackToCpu;
|
|
37
|
+
/** One detect + publish outside the loop (used after a delegate rebuild). */
|
|
38
|
+
private detectOnce;
|
|
39
|
+
private detect;
|
|
40
|
+
/** The session mirrors only the webcam feed (an unknown kind is treated as webcam). */
|
|
41
|
+
private isMirrored;
|
|
42
|
+
run({ sourceCanvas, getSource, targetFps, analysisScale, }: RunModelParams): Promise<void>;
|
|
43
|
+
private process;
|
|
44
|
+
resume(): void;
|
|
45
|
+
dispose(): void;
|
|
46
|
+
getModelNode(): XRModelNodeHolisticTracking;
|
|
47
|
+
getPerformanceData(): Promise<PerformanceData>;
|
|
48
|
+
}
|
|
49
|
+
export { DEFAULT_HOLISTIC_ANALYSIS_MAX_DIMENSION, DEFAULT_HOLISTIC_HOLD_MS, DEFAULT_HOLISTIC_MODEL_URL, DEFAULT_HOLISTIC_PREDICT_MS, HolisticResultBuilder, createHolisticResult, resolveHolisticRuntimeOptions, } from './result';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { HolisticLandmarkerResult } from '@mediapipe/tasks-vision';
|
|
2
|
+
import { TrackerPoint } from '../../types/common';
|
|
3
|
+
import { HolisticResult, HolisticRuntimeOptions } from '../../types/holistic';
|
|
4
|
+
/** MediaPipe's published holistic landmarker; the SDK CDN copy is not published yet. */
|
|
5
|
+
export declare const DEFAULT_HOLISTIC_MODEL_URL = "https://storage.googleapis.com/mediapipe-models/holistic_landmarker/holistic_landmarker/float16/latest/holistic_landmarker.task";
|
|
6
|
+
export declare const DEFAULT_HOLISTIC_HOLD_MS = 250;
|
|
7
|
+
export declare const DEFAULT_HOLISTIC_PREDICT_MS = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Pose needs a full-body subject at distance resolved well enough to detect,
|
|
10
|
+
* so the cap matches `BodyTrackingModel` (768) rather than Hand/Face (512).
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_HOLISTIC_ANALYSIS_MAX_DIMENSION = 768;
|
|
13
|
+
export declare const resolveHolisticRuntimeOptions: (options?: HolisticRuntimeOptions) => Required<HolisticRuntimeOptions>;
|
|
14
|
+
export declare const createHolisticResult: () => HolisticResult;
|
|
15
|
+
type Point3 = {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
z: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* MediaPipe Pose index with left and right swapped: 0 (nose) stays, then the
|
|
22
|
+
* 16 left/right pairs (eyes 1–3/4–6, ears 7/8, mouth 9/10, shoulders 11/12,
|
|
23
|
+
* elbows 13/14, wrists 15/16, pinkies 17/18, indexes 19/20, thumbs 21/22,
|
|
24
|
+
* hips 23/24, knees 25/26, ankles 27/28, heels 29/30, foot indexes 31/32).
|
|
25
|
+
*/
|
|
26
|
+
export declare const MIRRORED_POSE_INDEX: readonly number[];
|
|
27
|
+
/**
|
|
28
|
+
* Converts raw MediaPipe holistic results into the SDK's unified
|
|
29
|
+
* `HolisticResult`, bridging dropouts per stream with `FaceTrackMemory` (the
|
|
30
|
+
* SDK's single hold/predict mechanism). Output arrays and objects are reused
|
|
31
|
+
* frame-over-frame; the published result is mutated in place.
|
|
32
|
+
*/
|
|
33
|
+
export declare class HolisticResultBuilder {
|
|
34
|
+
private options;
|
|
35
|
+
private readonly faceMemory;
|
|
36
|
+
private readonly leftHandMemory;
|
|
37
|
+
private readonly rightHandMemory;
|
|
38
|
+
private readonly poseMemory;
|
|
39
|
+
private readonly face;
|
|
40
|
+
private readonly leftHand;
|
|
41
|
+
private readonly rightHand;
|
|
42
|
+
private readonly poseScratch;
|
|
43
|
+
private readonly poseWorldScratch;
|
|
44
|
+
private readonly pose;
|
|
45
|
+
constructor(options?: HolisticRuntimeOptions);
|
|
46
|
+
getOptions(): Required<HolisticRuntimeOptions>;
|
|
47
|
+
setOptions(options?: HolisticRuntimeOptions): void;
|
|
48
|
+
reset(): void;
|
|
49
|
+
private memories;
|
|
50
|
+
/**
|
|
51
|
+
* Publish `raw` (or a miss when `undefined`) into `result` at `nowMs`.
|
|
52
|
+
*
|
|
53
|
+
* `mirrored` says the analysed frame is a mirror of the person (the
|
|
54
|
+
* session's webcam feed). Pose left/right follow the image, and holistic
|
|
55
|
+
* assigns hands from the pose, so on a mirrored frame MediaPipe's "left"
|
|
56
|
+
* is the person's right. Swap both the hands and the pose's left/right
|
|
57
|
+
* landmarks so the whole result is anatomical and self-consistent
|
|
58
|
+
* (`leftHand` and pose wrist 15 are the same physical hand), matching the
|
|
59
|
+
* convention `HandTracker` reports on that feed.
|
|
60
|
+
*/
|
|
61
|
+
update(raw: HolisticLandmarkerResult | undefined, nowMs: number, result: HolisticResult, mirrored?: boolean): HolisticResult;
|
|
62
|
+
private updateFace;
|
|
63
|
+
private updateHand;
|
|
64
|
+
private updatePose;
|
|
65
|
+
}
|
|
66
|
+
/** Convenience for tests and custom consumers: a single-stream TrackerPoint copy. */
|
|
67
|
+
export declare const toTrackerPoints: (landmarks: ReadonlyArray<Point3>) => TrackerPoint[];
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PerformanceData, RunModelParams } from '../../types';
|
|
2
|
+
import { XRModelNodeSemanticSegmentation } from '../../types/nodes';
|
|
3
|
+
import { SemanticSegmentationModelOptions } from '../../types/segmentation';
|
|
4
|
+
import { BaseXRModel } from '../Base';
|
|
5
|
+
/**
|
|
6
|
+
* Generic MediaPipe category segmenter publishing a `SemanticMask` in feed
|
|
7
|
+
* space. The first acquirer picks the preset (hair or multiclass) and the
|
|
8
|
+
* model asset; the mask object is stable and mutated in place, with `version`
|
|
9
|
+
* bumped on every inference.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SemanticSegmentationModel extends BaseXRModel {
|
|
12
|
+
private segmenter;
|
|
13
|
+
private preset;
|
|
14
|
+
private quality;
|
|
15
|
+
private status;
|
|
16
|
+
private error;
|
|
17
|
+
private processingTime;
|
|
18
|
+
private sourceCanvas;
|
|
19
|
+
private processCanvas;
|
|
20
|
+
private isProcessing;
|
|
21
|
+
private readonly mask;
|
|
22
|
+
private readonly node;
|
|
23
|
+
constructor();
|
|
24
|
+
initialize(options?: SemanticSegmentationModelOptions): Promise<void>;
|
|
25
|
+
run({ sourceCanvas, targetFps }: RunModelParams): Promise<void>;
|
|
26
|
+
private process;
|
|
27
|
+
resume(): void;
|
|
28
|
+
getModelNode(): XRModelNodeSemanticSegmentation;
|
|
29
|
+
getPerformanceData(): Promise<PerformanceData>;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SemanticSegmentationPreset } from '../../types/segmentation';
|
|
2
|
+
export type SemanticSegmentationPresetSpec = {
|
|
3
|
+
/** Class labels in model index order; index 0 is `bg`. */
|
|
4
|
+
labels: readonly string[];
|
|
5
|
+
/**
|
|
6
|
+
* Model asset path on the SDK CDN. Its hash is already pinned in the
|
|
7
|
+
* integrity manifest; once the file is uploaded there, point `defaultUrl`
|
|
8
|
+
* at it.
|
|
9
|
+
*/
|
|
10
|
+
assetPath: string;
|
|
11
|
+
/**
|
|
12
|
+
* Where the model loads from by default: MediaPipe's published file, whose
|
|
13
|
+
* bytes are pinned in the integrity manifest, so the default is verified
|
|
14
|
+
* (a republished file fails loudly with an SRI mismatch rather than
|
|
15
|
+
* silently changing behaviour).
|
|
16
|
+
*/
|
|
17
|
+
defaultUrl: string;
|
|
18
|
+
/**
|
|
19
|
+
* How a category-mask byte maps to a class index. The hair and multiclass
|
|
20
|
+
* segmenters emit the class index itself (measured: hair reads 0 / 1). The
|
|
21
|
+
* SDK's portrait selfie segmenter is the odd one out and emits 255 for
|
|
22
|
+
* background / 0 for person; `usePersonMask` handles that separately.
|
|
23
|
+
*/
|
|
24
|
+
decode: (value: number) => number;
|
|
25
|
+
};
|
|
26
|
+
export declare const SEMANTIC_SEGMENTATION_PRESET_SPECS: Record<SemanticSegmentationPreset, SemanticSegmentationPresetSpec>;
|
|
27
|
+
/** Decode a MediaPipe category mask into class indices, resizing `out` when needed. */
|
|
28
|
+
export declare const decodeCategoryMask: (raw: Uint8Array, decode: (value: number) => number, out: Uint8Array) => Uint8Array;
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { BodyTrackingModel } from './Body';
|
|
2
2
|
export { FaceTrackingModel } from './Face';
|
|
3
3
|
export { GestureTrackingModel } from './Hand/GestureTracking';
|
|
4
|
+
export { HolisticTrackingModel } from './Holistic';
|
|
4
5
|
export { HandTrackingModel } from './Hand/HandTracking';
|
|
5
6
|
export { BackgroundSegmentationModel } from './Segmentation';
|
|
7
|
+
export { SemanticSegmentationModel } from './SemanticSegmentation';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { DimensionLine, ProductDimensions as Dimensions } from './details';
|
|
3
|
+
export type ProductDimensionsProps = {
|
|
4
|
+
dimensions: Dimensions | null;
|
|
5
|
+
unit?: "metric" | "imperial";
|
|
6
|
+
/** Which axes to label. Default all three. */
|
|
7
|
+
axes?: Array<DimensionLine["axis"]>;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
export declare const DIMENSION_SLOT_PREFIX = "hotspot-__dim-";
|
|
11
|
+
/**
|
|
12
|
+
* True-size labels on the model's bounding box (width / height / depth),
|
|
13
|
+
* anchored as hotspots so they track the model. Child of `<ProductViewer>`.
|
|
14
|
+
* Pair with `scale="fixed"` so AR shows the same size.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ProductDimensions: ({ dimensions, unit, axes, style, }: ProductDimensionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { ProductHotspotData } from './details';
|
|
3
|
+
export type ProductHotspotProps = {
|
|
4
|
+
hotspot: ProductHotspotData;
|
|
5
|
+
/** Custom content; default a dot with the label. */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
onClick?: (hotspot: ProductHotspotData) => void;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A surface-anchored callout. Must be a child of `<ProductViewer>`: model-viewer
|
|
13
|
+
* slots it as `hotspot-{id}` and keeps it over `position` as the camera
|
|
14
|
+
* orbits, fading it when the surface faces away.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ProductHotspot: ({ hotspot, children, onClick, style, className, }: ProductHotspotProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProductViewerElement, ProductViewerProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Surface-placement product viewer: a typed React wrapper over Google's
|
|
4
|
+
* `<model-viewer>`, loaded lazily. Renders the GLB with camera controls and
|
|
5
|
+
* hands off to WebXR, Scene Viewer or Quick Look from a user gesture. This
|
|
6
|
+
* is not the SDK's camera session; see `useProductAr` for the camera
|
|
7
|
+
* handoff when both exist on one page.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ProductViewer: import('react').ForwardRefExoticComponent<ProductViewerProps & import('react').RefAttributes<ProductViewerElement | null>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for product details: variants, hotspots and dimensions.
|
|
3
|
+
* model-viewer expresses positions as "x y z" strings in model metres; the
|
|
4
|
+
* SDK keeps them as numeric tuples so they are serializable and testable.
|
|
5
|
+
*/
|
|
6
|
+
export type Vec3 = [number, number, number];
|
|
7
|
+
/** A surface-anchored annotation, serializable authoring data. */
|
|
8
|
+
export type ProductHotspotData = {
|
|
9
|
+
/** Unique within the product; becomes `slot="hotspot-{id}"`. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Model-space position in metres. */
|
|
12
|
+
position: Vec3;
|
|
13
|
+
/** Surface normal at the position (unit vector). */
|
|
14
|
+
normal: Vec3;
|
|
15
|
+
/** Short label shown in the callout. */
|
|
16
|
+
label?: string;
|
|
17
|
+
/** Longer text, free-form. */
|
|
18
|
+
description?: string;
|
|
19
|
+
};
|
|
20
|
+
export type ProductDimensions = {
|
|
21
|
+
/** Size along x / y / z in metres. */
|
|
22
|
+
size: Vec3;
|
|
23
|
+
center: Vec3;
|
|
24
|
+
};
|
|
25
|
+
export declare const formatVec3: (v: Vec3, digits?: number) => string;
|
|
26
|
+
export declare const parseVec3: (text: string) => Vec3 | null;
|
|
27
|
+
/** `data-position` / `data-normal` attribute pair for a hotspot. */
|
|
28
|
+
export declare const hotspotAttributes: (hotspot: ProductHotspotData) => {
|
|
29
|
+
slot: string;
|
|
30
|
+
"data-position": string;
|
|
31
|
+
"data-normal": string;
|
|
32
|
+
};
|
|
33
|
+
/** A stable id from a label (or a counter when the label is empty / taken). */
|
|
34
|
+
export declare const nextHotspotId: (existing: ReadonlyArray<ProductHotspotData>, label?: string) => string;
|
|
35
|
+
/** Validate a hotspot list from storage / import; invalid entries are dropped. */
|
|
36
|
+
export declare const parseHotspots: (raw: unknown) => ProductHotspotData[];
|
|
37
|
+
export declare const serializeHotspots: (hotspots: ReadonlyArray<ProductHotspotData>) => string;
|
|
38
|
+
/** Human size string: metres under 1 m become centimetres. */
|
|
39
|
+
export declare const formatLength: (metres: number, unit?: "metric" | "imperial") => string;
|
|
40
|
+
export type DimensionLine = {
|
|
41
|
+
axis: "x" | "y" | "z";
|
|
42
|
+
/** Hotspot anchors at both ends and the label midpoint (model metres). */
|
|
43
|
+
start: Vec3;
|
|
44
|
+
end: Vec3;
|
|
45
|
+
mid: Vec3;
|
|
46
|
+
length: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Three edge lines of the bounding box (width along x at the front-bottom
|
|
50
|
+
* edge, height along y at the front-left edge, depth along z at the
|
|
51
|
+
* bottom-left edge), each anchored as hotspots so they track the model.
|
|
52
|
+
*/
|
|
53
|
+
export declare const dimensionLines: ({ size, center }: ProductDimensions) => DimensionLine[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { ProductViewer } from './ProductViewer';
|
|
2
|
+
export { useProductAr, releaseSessionForAr, supportedProductArModes } from './useProductAr';
|
|
3
|
+
export type { UseProductArOptions, UseProductArResult } from './useProductAr';
|
|
4
|
+
export { isModelViewerDefined, loadModelViewer } from './loadModelViewer';
|
|
5
|
+
export { DEFAULT_PRODUCT_AR_MODES } from './types';
|
|
6
|
+
export { dimensionLines, formatLength, formatVec3, hotspotAttributes, nextHotspotId, parseHotspots, parseVec3, serializeHotspots, } from './details';
|
|
7
|
+
export type { DimensionLine, ProductDimensions as ProductDimensionsData, ProductHotspotData, Vec3, } from './details';
|
|
8
|
+
export { useDimensionLines, useProductDimensions, useProductHotspots, useProductVariants, } from './useProductDetails';
|
|
9
|
+
export type { ProductDetailsElement, UseProductHotspotsOptions, UseProductHotspotsResult, } from './useProductDetails';
|
|
10
|
+
export { ProductHotspot } from './ProductHotspot';
|
|
11
|
+
export type { ProductHotspotProps } from './ProductHotspot';
|
|
12
|
+
export { ProductDimensions } from './ProductDimensions';
|
|
13
|
+
export type { ProductDimensionsProps } from './ProductDimensions';
|
|
14
|
+
export type { ProductArMode, ProductArState, ProductArStatus, ProductViewerElement, ProductViewerPlacement, ProductViewerProps, ProductViewerScale, } from './types';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { XRFallbackReason } from '../capabilities/types';
|
|
2
|
+
/** The native path a device takes for surface placement. */
|
|
3
|
+
export type ProductArMode = "webxr" | "scene-viewer" | "quick-look";
|
|
4
|
+
/** Preference order shared by `<ProductViewer arModes>` and `useProductAr({ modes })`. */
|
|
5
|
+
export declare const DEFAULT_PRODUCT_AR_MODES: readonly ProductArMode[];
|
|
6
|
+
/**
|
|
7
|
+
* model-viewer's `ar-status` values, plus the SDK's `unavailable` when no
|
|
8
|
+
* mode is supported on the device.
|
|
9
|
+
*/
|
|
10
|
+
export type ProductArStatus = "unavailable" | "not-presenting" | "session-started" | "object-placed" | "failed";
|
|
11
|
+
export type ProductViewerPlacement = "floor" | "wall";
|
|
12
|
+
export type ProductViewerScale = "auto" | "fixed";
|
|
13
|
+
export type ProductViewerProps = {
|
|
14
|
+
/** glTF / GLB URL (the model every platform renders). */
|
|
15
|
+
src: string;
|
|
16
|
+
/** USDZ URL for iOS Quick Look. Without it iOS falls back to model-viewer's own USDZ export (slower, lower fidelity). */
|
|
17
|
+
iosSrc?: string;
|
|
18
|
+
/** Accessible description. */
|
|
19
|
+
alt?: string;
|
|
20
|
+
/** Poster image shown until the model loads. */
|
|
21
|
+
poster?: string;
|
|
22
|
+
/** Native paths to offer, in preference order. Default `["webxr", "scene-viewer", "quick-look"]`. */
|
|
23
|
+
arModes?: ProductArMode[];
|
|
24
|
+
/** Enable the AR button / `activateAR()`. Default `true`. */
|
|
25
|
+
ar?: boolean;
|
|
26
|
+
/** Where the object lands. Default `floor`. */
|
|
27
|
+
placement?: ProductViewerPlacement;
|
|
28
|
+
/** `fixed` keeps real-world size (no pinch-to-resize). Default `auto`. */
|
|
29
|
+
scale?: ProductViewerScale;
|
|
30
|
+
cameraControls?: boolean;
|
|
31
|
+
autoRotate?: boolean;
|
|
32
|
+
/** `auto` | `eager` | `lazy`; default `auto`. */
|
|
33
|
+
loading?: "auto" | "eager" | "lazy";
|
|
34
|
+
/** Environment image URL or `neutral`. */
|
|
35
|
+
environmentImage?: string;
|
|
36
|
+
shadowIntensity?: number;
|
|
37
|
+
exposure?: number;
|
|
38
|
+
/** Extra attributes passed straight to `<model-viewer>` (anything not wrapped). */
|
|
39
|
+
attributes?: Record<string, string | number | boolean>;
|
|
40
|
+
className?: string;
|
|
41
|
+
style?: React.CSSProperties;
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
onLoad?: () => void;
|
|
44
|
+
onError?: (error: Error) => void;
|
|
45
|
+
/** Fires on every `ar-status` change. */
|
|
46
|
+
onArStatus?: (status: ProductArStatus) => void;
|
|
47
|
+
/** The custom element, once model-viewer is loaded and mounted. */
|
|
48
|
+
onReady?: (element: ProductViewerElement) => void;
|
|
49
|
+
};
|
|
50
|
+
/** The subset of `ModelViewerElement` the SDK relies on (typed loosely so the peer stays optional). */
|
|
51
|
+
export type ProductViewerElement = HTMLElement & {
|
|
52
|
+
src: string;
|
|
53
|
+
canActivateAR: boolean;
|
|
54
|
+
activateAR: () => Promise<void>;
|
|
55
|
+
loaded: boolean;
|
|
56
|
+
modelIsVisible: boolean;
|
|
57
|
+
addEventListener: HTMLElement["addEventListener"];
|
|
58
|
+
removeEventListener: HTMLElement["removeEventListener"];
|
|
59
|
+
};
|
|
60
|
+
export type ProductArState = {
|
|
61
|
+
status: ProductArStatus;
|
|
62
|
+
/** Modes the device supports (from the capability check), in the viewer's preference order. */
|
|
63
|
+
supportedModes: ProductArMode[];
|
|
64
|
+
/** `canActivateAR` from the element once it is ready. */
|
|
65
|
+
canActivate: boolean;
|
|
66
|
+
/** Why AR is unavailable, when it is. */
|
|
67
|
+
reason: XRFallbackReason | null;
|
|
68
|
+
/** True while the viewer library is still loading. */
|
|
69
|
+
loading: boolean;
|
|
70
|
+
error: Error | null;
|
|
71
|
+
};
|