@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/main.js
CHANGED
|
@@ -1,165 +1,170 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { X as
|
|
5
|
-
import { c as
|
|
6
|
-
import { S as
|
|
7
|
-
import { X as
|
|
8
|
-
import { c as
|
|
9
|
-
import { L as
|
|
10
|
-
import { jsxs as
|
|
11
|
-
import { useRef as
|
|
12
|
-
import * as
|
|
13
|
-
import { MathUtils as
|
|
14
|
-
import {
|
|
15
|
-
import { useThree as
|
|
16
|
-
import { R as
|
|
17
|
-
import { u as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
var Ke = Object.defineProperty;
|
|
2
|
+
var We = (s, e, t) => e in s ? Ke(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var T = (s, e, t) => We(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { X as C, u as xe, Y as He, Z as Ve, _ as je, $ as Ye, a0 as Qe, a1 as Ze, a2 as Ee, R as Je, L as et, N as tt, I as st, a3 as rt, p as at } from "./index-CnGox6Xr.js";
|
|
5
|
+
import { ag as dr, ah as mr, g as fr, a4 as hr, ai as pr, ad as gr, ae as yr, c as Sr, a as Mr, j as Er, d as br, a5 as Tr, o as Ar, a6 as Rr, i as vr, a7 as wr, a8 as Fr, a9 as Cr, af as kr, A as _r, aa as xr, r as Ur, ab as Pr, ac as Nr } from "./index-CnGox6Xr.js";
|
|
6
|
+
import { S as nt } from "./contexts-FzlnnMYD.js";
|
|
7
|
+
import { X as Ir } from "./contexts-FzlnnMYD.js";
|
|
8
|
+
import { S as it, c as ot } from "./index-s9pF4zkG.js";
|
|
9
|
+
import { L as Or, e as Gr, R as qr, b as Br, f as $r, a as zr, d as Xr, g as Kr, T as Wr } from "./index-s9pF4zkG.js";
|
|
10
|
+
import { jsxs as L, jsx as M, Fragment as ae } from "react/jsx-runtime";
|
|
11
|
+
import { useRef as w, useMemo as K, useEffect as x, useState as k, Suspense as ct, useCallback as E, forwardRef as lt, useImperativeHandle as ut, useContext as dt, createContext as mt, useId as ft, useSyncExternalStore as ht } from "react";
|
|
12
|
+
import * as $ from "three";
|
|
13
|
+
import { MathUtils as pt, Vector2 as gt, Vector3 as yt, DoubleSide as se, RepeatWrapping as be, LinearFilter as Te } from "three";
|
|
14
|
+
import { D as Vr, K as jr, J as Yr, F as Qr, N as Zr, O as Jr, H as ea, M as ta, P as sa, S as ra, E as aa, B as na, L as ia, Q as oa, R as ca, G as la, C as ua, I as da } from "./renderPasses-NnKZVfBy.js";
|
|
15
|
+
import { useThree as St, useFrame as Ue } from "@react-three/fiber";
|
|
16
|
+
import { u as Pe, a as Ne, R as Mt, d as Et, e as bt } from "./selectors-C5G1PMYL.js";
|
|
17
|
+
import { u as Tt } from "./index-CsUdQ-pn.js";
|
|
18
|
+
import { M as fa } from "./index-CsUdQ-pn.js";
|
|
19
|
+
import { useTexture as At } from "@react-three/drei";
|
|
20
|
+
import { a as Rt } from "./index-CHVbH0hz.js";
|
|
21
|
+
import { D as pa, d as ga, M as ya, n as Sa } from "./index-CHVbH0hz.js";
|
|
22
|
+
import { G as Ea, A as ba, E as Ta, M as Aa, S as Ra, T as va, H as wa, B as Fa } from "./FaceMeshRenderer-UuH5sTXG.js";
|
|
23
|
+
import { d as ka, r as _a } from "./drawNormalizedCrop-CRdIDyl1.js";
|
|
24
|
+
import { c as Ua, a as Pa, b as Na, D as Da, m as Ia, r as La } from "./screenTransform-BenfCtZt.js";
|
|
25
|
+
import { d as Ga, q as qa, r as Ba, v as $a, m as za, n as Xa, g as Ka, x as Wa, h as Ha, i as Va, k as ja, e as Ya, l as Qa, o as Za, p as Ja, t as en, y as tn, z as sn, w as rn } from "./useFaceInfo-Blf7FCu3.js";
|
|
26
|
+
import { u as nn } from "./useXRCapabilities-C68v__wB.js";
|
|
27
|
+
import { G as vt } from "./GLTFLoader-C5q63sKO.js";
|
|
28
|
+
import { S as wt } from "./segmentation-CeOTKemr.js";
|
|
29
|
+
const Q = (s, e, t, r) => pt.damp(s, e, Math.max(0, t), Math.max(0, r)), ks = (s, e, t, r, n = new gt()) => n.set(
|
|
30
|
+
Q(s.x, e.x, t, r),
|
|
31
|
+
Q(s.y, e.y, t, r)
|
|
32
|
+
), _s = (s, e, t, r, n = new yt()) => n.set(
|
|
33
|
+
Q(s.x, e.x, t, r),
|
|
34
|
+
Q(s.y, e.y, t, r),
|
|
35
|
+
Q(s.z, e.z, t, r)
|
|
36
|
+
), Ft = "rgba(20,40,110,0.88)", Ct = 24, kt = 512;
|
|
37
|
+
function xs({
|
|
38
|
+
color: s = Ft,
|
|
34
39
|
borderColor: e,
|
|
35
|
-
borderWidth:
|
|
36
|
-
borderRadius: r =
|
|
37
|
-
resolution:
|
|
38
|
-
aspect:
|
|
39
|
-
opacity:
|
|
40
|
-
name:
|
|
41
|
-
overlay:
|
|
42
|
-
position:
|
|
43
|
-
rotation:
|
|
44
|
-
scale:
|
|
40
|
+
borderWidth: t = 0,
|
|
41
|
+
borderRadius: r = Ct,
|
|
42
|
+
resolution: n = kt,
|
|
43
|
+
aspect: a = 1,
|
|
44
|
+
opacity: i = 1,
|
|
45
|
+
name: o,
|
|
46
|
+
overlay: c = !0,
|
|
47
|
+
position: l,
|
|
48
|
+
rotation: p,
|
|
49
|
+
scale: u,
|
|
45
50
|
visible: m
|
|
46
51
|
}) {
|
|
47
|
-
const
|
|
48
|
-
width: Math.round(
|
|
49
|
-
height: Math.round(
|
|
50
|
-
color:
|
|
52
|
+
const d = w(null), f = w(null), y = K(() => _t({
|
|
53
|
+
width: Math.round(n * Math.max(a, 0.05)),
|
|
54
|
+
height: Math.round(n),
|
|
55
|
+
color: s,
|
|
51
56
|
borderColor: e,
|
|
52
|
-
borderWidth:
|
|
57
|
+
borderWidth: t,
|
|
53
58
|
borderRadius: r
|
|
54
|
-
}), [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}, [
|
|
58
|
-
const
|
|
59
|
-
return
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
return
|
|
63
|
-
|
|
59
|
+
}), [s, e, t, r, n, a]);
|
|
60
|
+
x(() => () => {
|
|
61
|
+
y.dispose();
|
|
62
|
+
}, [y]);
|
|
63
|
+
const A = w(null), h = w(i);
|
|
64
|
+
return h.current !== i && (h.current = i, A.current = null, f.current && (f.current.opacity = i)), x(() => {
|
|
65
|
+
const g = d.current;
|
|
66
|
+
if (g)
|
|
67
|
+
return g.userData.setOpacity = (R) => {
|
|
68
|
+
A.current = R, f.current && (f.current.opacity = R);
|
|
64
69
|
}, () => {
|
|
65
|
-
delete
|
|
70
|
+
delete g.userData.setOpacity;
|
|
66
71
|
};
|
|
67
|
-
}, []), /* @__PURE__ */
|
|
72
|
+
}, []), /* @__PURE__ */ L(
|
|
68
73
|
"mesh",
|
|
69
74
|
{
|
|
70
|
-
ref:
|
|
71
|
-
name:
|
|
72
|
-
position:
|
|
73
|
-
rotation:
|
|
74
|
-
scale:
|
|
75
|
+
ref: d,
|
|
76
|
+
name: o,
|
|
77
|
+
position: l,
|
|
78
|
+
rotation: p,
|
|
79
|
+
scale: u,
|
|
75
80
|
visible: m,
|
|
76
81
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ M("planeGeometry", { args: [1, 1] }),
|
|
83
|
+
/* @__PURE__ */ M(
|
|
79
84
|
"meshBasicMaterial",
|
|
80
85
|
{
|
|
81
|
-
ref:
|
|
82
|
-
map:
|
|
86
|
+
ref: f,
|
|
87
|
+
map: y,
|
|
83
88
|
transparent: !0,
|
|
84
|
-
opacity:
|
|
85
|
-
depthTest: !
|
|
86
|
-
depthWrite: !
|
|
89
|
+
opacity: i,
|
|
90
|
+
depthTest: !c,
|
|
91
|
+
depthWrite: !c
|
|
87
92
|
}
|
|
88
93
|
)
|
|
89
94
|
]
|
|
90
95
|
}
|
|
91
96
|
);
|
|
92
97
|
}
|
|
93
|
-
function
|
|
94
|
-
const { width: e, height:
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
})(),
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
return
|
|
98
|
+
function _t(s) {
|
|
99
|
+
const { width: e, height: t, color: r, borderColor: n, borderWidth: a, borderRadius: i } = s, o = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(e, t) : (() => {
|
|
100
|
+
const u = document.createElement("canvas");
|
|
101
|
+
return u.width = e, u.height = t, u;
|
|
102
|
+
})(), c = o.getContext("2d");
|
|
103
|
+
c.clearRect(0, 0, e, t);
|
|
104
|
+
const l = Math.min(i, Math.min(e, t) / 2);
|
|
105
|
+
c.beginPath(), c.moveTo(l, 0), c.lineTo(e - l, 0), c.quadraticCurveTo(e, 0, e, l), c.lineTo(e, t - l), c.quadraticCurveTo(e, t, e - l, t), c.lineTo(l, t), c.quadraticCurveTo(0, t, 0, t - l), c.lineTo(0, l), c.quadraticCurveTo(0, 0, l, 0), c.closePath(), c.fillStyle = r, c.fill(), n && a > 0 && (c.lineWidth = a, c.strokeStyle = n, c.stroke());
|
|
106
|
+
const p = new $.CanvasTexture(o);
|
|
107
|
+
return p.needsUpdate = !0, p;
|
|
103
108
|
}
|
|
104
|
-
const
|
|
105
|
-
segmentationMask:
|
|
109
|
+
const Us = ({
|
|
110
|
+
segmentationMask: s,
|
|
106
111
|
segmentation: e,
|
|
107
|
-
invert:
|
|
112
|
+
invert: t = !1,
|
|
108
113
|
customBackground: r,
|
|
109
|
-
renderOrder:
|
|
114
|
+
renderOrder: n = Mt.BACKGROUND
|
|
110
115
|
}) => {
|
|
111
|
-
const { camera:
|
|
112
|
-
|
|
116
|
+
const { camera: a, size: i } = St(), o = Pe(), c = Ne(C.BACKGROUND_SEGMENTATION), l = e ? c == null ? void 0 : c.backgroundSegmentationMask : void 0, p = w(!1);
|
|
117
|
+
x(() => {
|
|
113
118
|
if (!e) {
|
|
114
|
-
|
|
119
|
+
p.current = !1;
|
|
115
120
|
return;
|
|
116
121
|
}
|
|
117
|
-
|
|
122
|
+
c === null && !p.current && (console.warn(
|
|
118
123
|
`[VideoBackground] segmentation="${e}" set but no matching <Segmentation> component is mounted; rendering unmasked.`
|
|
119
|
-
),
|
|
120
|
-
}, [e,
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
124
|
+
), p.current = !0);
|
|
125
|
+
}, [e, c]);
|
|
126
|
+
const u = e ? l : s, m = K(() => {
|
|
127
|
+
if (!a.isPerspectiveCamera)
|
|
123
128
|
return [10, 10];
|
|
124
|
-
const
|
|
125
|
-
return [
|
|
126
|
-
}, [
|
|
127
|
-
return
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */
|
|
129
|
+
const d = a, A = (d.position.z || 5) - -1, h = d.fov * Math.PI / 180, g = 2 * Math.tan(h / 2) * A;
|
|
130
|
+
return [g * (i.width / i.height), g];
|
|
131
|
+
}, [a, i]);
|
|
132
|
+
return o ? /* @__PURE__ */ M("group", { position: [0, 0, -1], children: t ? /* @__PURE__ */ L(ae, { children: [
|
|
133
|
+
/* @__PURE__ */ L("mesh", { position: [0, 0, -0.01], renderOrder: n - 1, children: [
|
|
134
|
+
/* @__PURE__ */ M("planeGeometry", { args: m }),
|
|
135
|
+
/* @__PURE__ */ M(
|
|
131
136
|
"meshBasicMaterial",
|
|
132
137
|
{
|
|
133
|
-
map:
|
|
138
|
+
map: o,
|
|
134
139
|
depthTest: !1,
|
|
135
140
|
depthWrite: !1,
|
|
136
141
|
toneMapped: !1,
|
|
137
|
-
side:
|
|
142
|
+
side: se
|
|
138
143
|
}
|
|
139
144
|
)
|
|
140
145
|
] }),
|
|
141
|
-
r &&
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
/* @__PURE__ */
|
|
146
|
+
r && u && /* @__PURE__ */ L("mesh", { position: [0, 0, 0], renderOrder: n, children: [
|
|
147
|
+
/* @__PURE__ */ M("planeGeometry", { args: m }),
|
|
148
|
+
/* @__PURE__ */ M(
|
|
144
149
|
"meshBasicMaterial",
|
|
145
150
|
{
|
|
146
151
|
map: typeof r == "string" ? void 0 : r,
|
|
147
152
|
color: typeof r == "string" ? r : void 0,
|
|
148
|
-
alphaMap:
|
|
153
|
+
alphaMap: u,
|
|
149
154
|
transparent: !1,
|
|
150
155
|
alphaTest: 0.5,
|
|
151
156
|
depthTest: !1,
|
|
152
157
|
depthWrite: !1,
|
|
153
158
|
toneMapped: !1,
|
|
154
|
-
side:
|
|
159
|
+
side: se
|
|
155
160
|
},
|
|
156
161
|
"inverted-mask"
|
|
157
162
|
)
|
|
158
163
|
] })
|
|
159
|
-
] }) : /* @__PURE__ */
|
|
160
|
-
r &&
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
/* @__PURE__ */
|
|
164
|
+
] }) : /* @__PURE__ */ L(ae, { children: [
|
|
165
|
+
r && u && /* @__PURE__ */ L("mesh", { position: [0, 0, -0.01], renderOrder: n - 1, children: [
|
|
166
|
+
/* @__PURE__ */ M("planeGeometry", { args: m }),
|
|
167
|
+
/* @__PURE__ */ M(
|
|
163
168
|
"meshBasicMaterial",
|
|
164
169
|
{
|
|
165
170
|
map: typeof r == "string" ? void 0 : r,
|
|
@@ -167,38 +172,90 @@ const tt = ({
|
|
|
167
172
|
depthTest: !1,
|
|
168
173
|
depthWrite: !1,
|
|
169
174
|
toneMapped: !1,
|
|
170
|
-
side:
|
|
175
|
+
side: se
|
|
171
176
|
}
|
|
172
177
|
)
|
|
173
178
|
] }),
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__PURE__ */ L("mesh", { position: [0, 0, 0], renderOrder: n, children: [
|
|
180
|
+
/* @__PURE__ */ M("planeGeometry", { args: m }),
|
|
181
|
+
/* @__PURE__ */ M(
|
|
177
182
|
"meshBasicMaterial",
|
|
178
183
|
{
|
|
179
|
-
map:
|
|
180
|
-
alphaMap:
|
|
184
|
+
map: o,
|
|
185
|
+
alphaMap: u,
|
|
181
186
|
transparent: !1,
|
|
182
|
-
alphaTest:
|
|
187
|
+
alphaTest: u ? 0.5 : void 0,
|
|
183
188
|
depthTest: !1,
|
|
184
189
|
depthWrite: !1,
|
|
185
190
|
toneMapped: !1,
|
|
186
|
-
side:
|
|
191
|
+
side: se
|
|
187
192
|
},
|
|
188
|
-
|
|
193
|
+
u ? "with-mask" : "no-mask"
|
|
189
194
|
)
|
|
190
195
|
] })
|
|
191
196
|
] }) }) : null;
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
|
|
197
|
+
}, xt = { left: -1, right: 1, top: 1, bottom: -1 }, Ut = ({
|
|
198
|
+
ready: s,
|
|
199
|
+
error: e,
|
|
200
|
+
hasMask: t
|
|
201
|
+
}) => e ? "error" : s && t ? "ready" : "loading", Pt = (s, e) => s === "ready" || e === "camera", Nt = (s = !0) => {
|
|
202
|
+
const { ready: e, error: t } = Tt(
|
|
203
|
+
C.BACKGROUND_SEGMENTATION,
|
|
204
|
+
{ type: "portrait" },
|
|
205
|
+
s
|
|
206
|
+
), r = Ne(C.BACKGROUND_SEGMENTATION), [n, a] = k(null);
|
|
207
|
+
return Ue(() => {
|
|
208
|
+
const i = (r == null ? void 0 : r.backgroundSegmentationMask) ?? null;
|
|
209
|
+
i !== n && a(i);
|
|
210
|
+
}), {
|
|
211
|
+
texture: n,
|
|
212
|
+
status: Ut({ ready: e, error: t, hasMask: !!n }),
|
|
213
|
+
error: t
|
|
214
|
+
};
|
|
215
|
+
}, Ps = ({
|
|
216
|
+
invert: s = !1,
|
|
217
|
+
fallback: e = "camera",
|
|
218
|
+
active: t = !0,
|
|
219
|
+
onStatusChange: r,
|
|
220
|
+
fit: n = "cover",
|
|
221
|
+
anchors: a = xt,
|
|
222
|
+
renderOrder: i = 100,
|
|
223
|
+
visible: o = !0,
|
|
224
|
+
maskFeather: c = 4,
|
|
225
|
+
maskErode: l = 0.7,
|
|
226
|
+
...p
|
|
227
|
+
}) => {
|
|
228
|
+
const u = Pe(), { texture: m, status: d, error: f } = Nt(t);
|
|
229
|
+
if (x(() => {
|
|
230
|
+
r == null || r(d, f);
|
|
231
|
+
}, [d, f, r]), !u) return null;
|
|
232
|
+
const y = d === "ready" && m;
|
|
233
|
+
return !y && !Pt(d, e) ? null : /* @__PURE__ */ M(
|
|
234
|
+
it,
|
|
235
|
+
{
|
|
236
|
+
...p,
|
|
237
|
+
source: { kind: "texture", texture: u },
|
|
238
|
+
fit: n,
|
|
239
|
+
anchors: a,
|
|
240
|
+
renderOrder: i,
|
|
241
|
+
visible: o,
|
|
242
|
+
maskTexture: y ? m : null,
|
|
243
|
+
maskChannel: "green",
|
|
244
|
+
maskInvert: s,
|
|
245
|
+
maskFeather: c,
|
|
246
|
+
maskErode: l
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
}, oe = 9, ce = 16, Ns = ({ children: s }) => {
|
|
250
|
+
const [e, t] = k({ width: 0, height: 0 });
|
|
251
|
+
return x(() => {
|
|
195
252
|
const r = () => {
|
|
196
|
-
const
|
|
197
|
-
let
|
|
198
|
-
|
|
253
|
+
const n = document.documentElement.clientWidth, a = document.documentElement.clientHeight, i = n / a, o = oe / ce;
|
|
254
|
+
let c, l;
|
|
255
|
+
i > o ? (l = a, c = l * oe / ce) : (c = n, l = c * ce / oe), t({ width: c, height: l });
|
|
199
256
|
};
|
|
200
257
|
return r(), window.addEventListener("resize", r), () => window.removeEventListener("resize", r);
|
|
201
|
-
}, []), /* @__PURE__ */
|
|
258
|
+
}, []), /* @__PURE__ */ M(
|
|
202
259
|
"div",
|
|
203
260
|
{
|
|
204
261
|
style: {
|
|
@@ -209,38 +266,38 @@ const tt = ({
|
|
|
209
266
|
justifyContent: "center",
|
|
210
267
|
backgroundColor: "#0d0d0d"
|
|
211
268
|
},
|
|
212
|
-
children: /* @__PURE__ */
|
|
269
|
+
children: /* @__PURE__ */ M("div", { style: { width: e.width, height: e.height, position: "relative" }, children: s })
|
|
213
270
|
}
|
|
214
271
|
);
|
|
215
|
-
},
|
|
216
|
-
const r =
|
|
217
|
-
return { x: r / e, y: (
|
|
218
|
-
},
|
|
219
|
-
sheet:
|
|
272
|
+
}, Ds = ({ size: s = 0.25, ...e }) => /* @__PURE__ */ M("axesHelper", { args: [s], ...e }), Dt = { left: -1, right: 1, top: 1, bottom: -1 }, It = (s, e, t) => {
|
|
273
|
+
const r = s % e, n = Math.floor(s / e);
|
|
274
|
+
return { x: r / e, y: (t - 1 - n) / t };
|
|
275
|
+
}, Lt = ({
|
|
276
|
+
sheet: s,
|
|
220
277
|
contentAspect: e,
|
|
221
|
-
renderOrder:
|
|
278
|
+
renderOrder: t,
|
|
222
279
|
name: r
|
|
223
280
|
}) => {
|
|
224
|
-
const
|
|
225
|
-
return
|
|
226
|
-
|
|
227
|
-
const m = Math.floor(
|
|
228
|
-
if (m ===
|
|
229
|
-
|
|
230
|
-
const { x:
|
|
231
|
-
|
|
232
|
-
}), /* @__PURE__ */
|
|
233
|
-
/* @__PURE__ */
|
|
234
|
-
/* @__PURE__ */
|
|
281
|
+
const n = At(s.url), a = w(0), i = w(-1), o = Rt(), [c, l] = e != null ? ot(o, e) : [1, 1];
|
|
282
|
+
return Ue((p, u) => {
|
|
283
|
+
n.wrapS = be, n.wrapT = be, n.magFilter = Te, n.minFilter = Te, n.generateMipmaps = !1, n.repeat.set(1 / s.cols, 1 / s.rows), a.current += u;
|
|
284
|
+
const m = Math.floor(a.current * s.fps) % s.frames;
|
|
285
|
+
if (m === i.current) return;
|
|
286
|
+
i.current = m;
|
|
287
|
+
const { x: d, y: f } = It(m, s.cols, s.rows);
|
|
288
|
+
n.offset.set(d, f);
|
|
289
|
+
}), /* @__PURE__ */ L("mesh", { name: r, renderOrder: t, scale: [c, l, 1], children: [
|
|
290
|
+
/* @__PURE__ */ M("planeGeometry", { args: [1, 1] }),
|
|
291
|
+
/* @__PURE__ */ M("meshBasicMaterial", { map: n, transparent: !0, toneMapped: !1, depthWrite: !1 })
|
|
235
292
|
] });
|
|
236
|
-
},
|
|
237
|
-
sheet:
|
|
238
|
-
anchors: e =
|
|
239
|
-
contentAspect:
|
|
293
|
+
}, Is = ({
|
|
294
|
+
sheet: s,
|
|
295
|
+
anchors: e = Dt,
|
|
296
|
+
contentAspect: t,
|
|
240
297
|
renderOrder: r = 10,
|
|
241
|
-
name:
|
|
242
|
-
}) => /* @__PURE__ */
|
|
243
|
-
switch (
|
|
298
|
+
name: n = "spriteAnimation"
|
|
299
|
+
}) => /* @__PURE__ */ M(ct, { fallback: null, children: /* @__PURE__ */ M(nt, { anchors: e, children: /* @__PURE__ */ M(Lt, { sheet: s, contentAspect: t, renderOrder: r, name: n }) }) }), q = (s) => {
|
|
300
|
+
switch (s) {
|
|
244
301
|
case "start":
|
|
245
302
|
return "starting";
|
|
246
303
|
case "started":
|
|
@@ -257,227 +314,227 @@ const tt = ({
|
|
|
257
314
|
case "clear":
|
|
258
315
|
return "idle";
|
|
259
316
|
}
|
|
260
|
-
},
|
|
317
|
+
}, Ot = [
|
|
261
318
|
"video/mp4",
|
|
262
319
|
"video/webm;codecs=vp9",
|
|
263
320
|
"video/webm;codecs=vp8",
|
|
264
321
|
"video/webm"
|
|
265
322
|
];
|
|
266
|
-
function
|
|
323
|
+
function Ls(s = {}) {
|
|
267
324
|
const {
|
|
268
325
|
audio: e = !1,
|
|
269
|
-
mimeType:
|
|
326
|
+
mimeType: t,
|
|
270
327
|
bitsPerSecond: r,
|
|
271
|
-
onData:
|
|
272
|
-
onStop:
|
|
273
|
-
onRecordingStart:
|
|
274
|
-
onRecordingPause:
|
|
275
|
-
onRecordingResume:
|
|
276
|
-
onRecordingStop:
|
|
277
|
-
onRecordingComplete:
|
|
278
|
-
onError:
|
|
328
|
+
onData: n,
|
|
329
|
+
onStop: a,
|
|
330
|
+
onRecordingStart: i,
|
|
331
|
+
onRecordingPause: o,
|
|
332
|
+
onRecordingResume: c,
|
|
333
|
+
onRecordingStop: l,
|
|
334
|
+
onRecordingComplete: p,
|
|
335
|
+
onError: u,
|
|
279
336
|
passThroughStream: m
|
|
280
|
-
} =
|
|
281
|
-
var
|
|
282
|
-
const
|
|
283
|
-
for (const
|
|
284
|
-
if ((
|
|
285
|
-
}, [
|
|
286
|
-
async (
|
|
287
|
-
const
|
|
288
|
-
if (
|
|
289
|
-
let
|
|
337
|
+
} = s, d = w(null), f = w(null), y = w([]), [A, h] = k("idle"), [g, R] = k(null), [W, v] = k(null), U = E(() => {
|
|
338
|
+
var F;
|
|
339
|
+
const S = [t, ...Ot].filter(Boolean);
|
|
340
|
+
for (const b of S)
|
|
341
|
+
if ((F = MediaRecorder.isTypeSupported) != null && F.call(MediaRecorder, b)) return b;
|
|
342
|
+
}, [t]), G = E(
|
|
343
|
+
async (S) => {
|
|
344
|
+
const F = new MediaStream();
|
|
345
|
+
if (S.getTracks().forEach((b) => F.addTrack(b)), e) {
|
|
346
|
+
let b;
|
|
290
347
|
if (e instanceof MediaStream)
|
|
291
|
-
|
|
348
|
+
b = e;
|
|
292
349
|
else {
|
|
293
|
-
const
|
|
294
|
-
|
|
350
|
+
const _ = typeof e == "object" ? { audio: e } : { audio: !0, video: !1 };
|
|
351
|
+
b = await navigator.mediaDevices.getUserMedia(_);
|
|
295
352
|
}
|
|
296
|
-
|
|
353
|
+
b.getAudioTracks().forEach((_) => F.addTrack(_));
|
|
297
354
|
}
|
|
298
|
-
if (!
|
|
355
|
+
if (!F.getTracks().length)
|
|
299
356
|
throw new Error("No tracks available in combined stream.");
|
|
300
|
-
return
|
|
357
|
+
return f.current = F, F;
|
|
301
358
|
},
|
|
302
359
|
[e]
|
|
303
|
-
),
|
|
304
|
-
async (
|
|
305
|
-
|
|
360
|
+
), Z = E(
|
|
361
|
+
async (S, F) => {
|
|
362
|
+
h(q("start")), v(null), R(null);
|
|
306
363
|
try {
|
|
307
|
-
let
|
|
364
|
+
let b;
|
|
308
365
|
if (m)
|
|
309
|
-
|
|
366
|
+
b = m, f.current = b;
|
|
310
367
|
else {
|
|
311
|
-
if (!
|
|
312
|
-
|
|
368
|
+
if (!S) throw new Error("start(stream) requires a MediaStream.");
|
|
369
|
+
b = await G(S);
|
|
313
370
|
}
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
|
|
371
|
+
const _ = U(), H = {};
|
|
372
|
+
_ && (H.mimeType = _), r && (H.bitsPerSecond = r);
|
|
373
|
+
const X = new MediaRecorder(b, H);
|
|
374
|
+
X.ondataavailable = (D) => {
|
|
318
375
|
var j;
|
|
319
|
-
((j =
|
|
320
|
-
},
|
|
321
|
-
const
|
|
322
|
-
type:
|
|
376
|
+
((j = D.data) == null ? void 0 : j.size) > 0 && (y.current.push(D.data), n == null || n(D.data));
|
|
377
|
+
}, X.onstop = () => {
|
|
378
|
+
const D = new Blob(y.current, {
|
|
379
|
+
type: _ ?? "video/webm"
|
|
323
380
|
});
|
|
324
|
-
|
|
325
|
-
},
|
|
326
|
-
} catch (
|
|
327
|
-
const
|
|
328
|
-
console.error("start(stream) failed",
|
|
381
|
+
R(D), a == null || a(D), p == null || p(D), y.current = [], h(q("complete"));
|
|
382
|
+
}, d.current = X, X.start(F), h(q("started")), i == null || i();
|
|
383
|
+
} catch (b) {
|
|
384
|
+
const _ = b instanceof Error ? b : new Error(String(b));
|
|
385
|
+
console.error("start(stream) failed", _), v(_), h(q("fail")), u == null || u(_);
|
|
329
386
|
}
|
|
330
387
|
},
|
|
331
388
|
[
|
|
332
|
-
|
|
333
|
-
|
|
389
|
+
G,
|
|
390
|
+
U,
|
|
334
391
|
r,
|
|
392
|
+
n,
|
|
335
393
|
a,
|
|
394
|
+
p,
|
|
336
395
|
i,
|
|
337
|
-
|
|
338
|
-
o,
|
|
339
|
-
d,
|
|
396
|
+
u,
|
|
340
397
|
m
|
|
341
398
|
]
|
|
342
|
-
),
|
|
343
|
-
const
|
|
344
|
-
!
|
|
345
|
-
}, [
|
|
346
|
-
const
|
|
347
|
-
(
|
|
348
|
-
}, [
|
|
349
|
-
const
|
|
350
|
-
(
|
|
351
|
-
}, [
|
|
352
|
-
var
|
|
399
|
+
), J = E(() => {
|
|
400
|
+
const S = d.current;
|
|
401
|
+
!S || S.state === "inactive" || (h(q("stop")), S.stop(), l == null || l());
|
|
402
|
+
}, [l]), ee = E(() => {
|
|
403
|
+
const S = d.current;
|
|
404
|
+
(S == null ? void 0 : S.state) === "recording" && (S.pause(), h(q("pause")), o == null || o());
|
|
405
|
+
}, [o]), te = E(() => {
|
|
406
|
+
const S = d.current;
|
|
407
|
+
(S == null ? void 0 : S.state) === "paused" && (S.resume(), h(q("resume")), c == null || c());
|
|
408
|
+
}, [c]), V = E(() => {
|
|
409
|
+
var S;
|
|
353
410
|
try {
|
|
354
|
-
|
|
355
|
-
} catch (
|
|
356
|
-
console.error("clear failed",
|
|
411
|
+
d.current && (d.current.onstop = null, d.current.state !== "inactive" && d.current.stop()), d.current = null, (S = f.current) == null || S.getTracks().forEach((F) => F.stop()), f.current = null, R(null), h(q("clear")), y.current = [], v(null);
|
|
412
|
+
} catch (F) {
|
|
413
|
+
console.error("clear failed", F);
|
|
357
414
|
}
|
|
358
415
|
}, []);
|
|
359
|
-
return
|
|
360
|
-
status:
|
|
361
|
-
start:
|
|
362
|
-
stop:
|
|
363
|
-
pause:
|
|
364
|
-
resume:
|
|
365
|
-
clear:
|
|
366
|
-
isRecording:
|
|
367
|
-
isPaused:
|
|
368
|
-
recordedBlob:
|
|
416
|
+
return x(() => () => V(), []), {
|
|
417
|
+
status: A,
|
|
418
|
+
start: Z,
|
|
419
|
+
stop: J,
|
|
420
|
+
pause: ee,
|
|
421
|
+
resume: te,
|
|
422
|
+
clear: V,
|
|
423
|
+
isRecording: A === "recording" || A === "paused",
|
|
424
|
+
isPaused: A === "paused",
|
|
425
|
+
recordedBlob: g,
|
|
369
426
|
error: W,
|
|
370
|
-
getActiveStream: () =>
|
|
427
|
+
getActiveStream: () => f.current
|
|
371
428
|
};
|
|
372
429
|
}
|
|
373
|
-
const
|
|
374
|
-
var
|
|
375
|
-
(
|
|
430
|
+
const Gt = async (s, e = {}) => {
|
|
431
|
+
var t, r, n;
|
|
432
|
+
(t = e.onCaptureStart) == null || t.call(e), await Promise.resolve();
|
|
376
433
|
try {
|
|
377
|
-
const
|
|
378
|
-
return (r = e.onCaptureComplete) == null || r.call(e,
|
|
379
|
-
} catch (
|
|
380
|
-
const
|
|
381
|
-
throw (
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
const { session: e } =
|
|
385
|
-
captureFrame:
|
|
434
|
+
const a = s();
|
|
435
|
+
return (r = e.onCaptureComplete) == null || r.call(e, a), a;
|
|
436
|
+
} catch (a) {
|
|
437
|
+
const i = a instanceof Error ? a : new Error(String(a));
|
|
438
|
+
throw (n = e.onError) == null || n.call(e, i), i;
|
|
439
|
+
}
|
|
440
|
+
}, Os = (s = {}) => {
|
|
441
|
+
const { session: e } = xe(), {
|
|
442
|
+
captureFrame: t = e.captureFrame,
|
|
386
443
|
onCaptureStart: r,
|
|
387
|
-
onCaptureComplete:
|
|
388
|
-
onError:
|
|
389
|
-
} =
|
|
390
|
-
|
|
444
|
+
onCaptureComplete: n,
|
|
445
|
+
onError: a
|
|
446
|
+
} = s, [i, o] = k("idle"), [c, l] = k(null), [p, u] = k(null), m = E(async () => {
|
|
447
|
+
o("capturing"), l(null), u(null);
|
|
391
448
|
try {
|
|
392
|
-
const
|
|
449
|
+
const f = await Gt(t, {
|
|
393
450
|
onCaptureStart: r,
|
|
394
|
-
onCaptureComplete:
|
|
395
|
-
onError:
|
|
451
|
+
onCaptureComplete: n,
|
|
452
|
+
onError: a
|
|
396
453
|
});
|
|
397
|
-
return
|
|
398
|
-
} catch (
|
|
399
|
-
const
|
|
400
|
-
return
|
|
454
|
+
return l(f), o("completed"), f;
|
|
455
|
+
} catch (f) {
|
|
456
|
+
const y = f instanceof Error ? f : new Error(String(f));
|
|
457
|
+
return u(y), o("error"), null;
|
|
401
458
|
}
|
|
402
|
-
}, [
|
|
403
|
-
|
|
459
|
+
}, [t, r, n, a]), d = E(() => {
|
|
460
|
+
o("idle"), l(null), u(null);
|
|
404
461
|
}, []);
|
|
405
|
-
return { status:
|
|
406
|
-
},
|
|
407
|
-
const
|
|
408
|
-
let
|
|
409
|
-
const
|
|
410
|
-
for (;
|
|
411
|
-
|
|
412
|
-
return new File([
|
|
413
|
-
},
|
|
414
|
-
if (
|
|
462
|
+
return { status: i, capturePhoto: m, clear: d, dataUrl: c, error: p };
|
|
463
|
+
}, Gs = (s, e) => {
|
|
464
|
+
const t = s.split(","), r = t[0].match(/:(.*?);/), n = r ? r[1] : "application/octet-stream", a = atob(t[t.length - 1]);
|
|
465
|
+
let i = a.length;
|
|
466
|
+
const o = new Uint8Array(i);
|
|
467
|
+
for (; i--; )
|
|
468
|
+
o[i] = a.charCodeAt(i);
|
|
469
|
+
return new File([o], e, { type: n });
|
|
470
|
+
}, qt = 4, Bt = 50, $t = 5e3, re = (s) => Math.min(1, Math.max(0, s)), Ae = (s) => new Promise((e) => {
|
|
471
|
+
if (s.readyState >= 4) {
|
|
415
472
|
e();
|
|
416
473
|
return;
|
|
417
474
|
}
|
|
418
|
-
let
|
|
475
|
+
let t = !1;
|
|
419
476
|
const r = () => {
|
|
420
|
-
|
|
477
|
+
t || (t = !0, e());
|
|
421
478
|
};
|
|
422
|
-
|
|
423
|
-
}),
|
|
424
|
-
const
|
|
425
|
-
return
|
|
426
|
-
},
|
|
427
|
-
|
|
428
|
-
|
|
479
|
+
s.addEventListener("canplaythrough", r, { once: !0 }), s.addEventListener("error", r, { once: !0 }), setTimeout(r, $t);
|
|
480
|
+
}), Re = (s, e) => {
|
|
481
|
+
const t = document.createElement("audio");
|
|
482
|
+
return t.src = s, t.loop = e, t.preload = "auto", t.setAttribute("playsinline", ""), t.setAttribute("webkit-playsinline", ""), t.load(), t;
|
|
483
|
+
}, zt = (s) => {
|
|
484
|
+
s.muted = !0, s.play().then(() => {
|
|
485
|
+
s.pause(), s.currentTime = 0, s.muted = !1;
|
|
429
486
|
}).catch(() => {
|
|
430
|
-
|
|
487
|
+
s.muted = !1;
|
|
431
488
|
});
|
|
432
489
|
};
|
|
433
|
-
class
|
|
490
|
+
class Xt {
|
|
434
491
|
constructor(e = {}) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
492
|
+
T(this, "sfxPoolSize");
|
|
493
|
+
T(this, "coalesceMs");
|
|
494
|
+
T(this, "muted", !0);
|
|
495
|
+
T(this, "listeners", /* @__PURE__ */ new Set());
|
|
496
|
+
T(this, "music", null);
|
|
497
|
+
T(this, "musicUrl", null);
|
|
498
|
+
T(this, "musicReady", null);
|
|
499
|
+
T(this, "musicWanted", null);
|
|
500
|
+
T(this, "pools", /* @__PURE__ */ new Map());
|
|
444
501
|
/** Last play time per SFX URL, for the coalesce window. */
|
|
445
|
-
|
|
502
|
+
T(this, "lastPlayed", /* @__PURE__ */ new Map());
|
|
446
503
|
/** Readiness promises so a loading gate can await decode/buffer. */
|
|
447
|
-
|
|
448
|
-
this.sfxPoolSize = e.sfxPoolSize ??
|
|
504
|
+
T(this, "ready", /* @__PURE__ */ new Map());
|
|
505
|
+
this.sfxPoolSize = e.sfxPoolSize ?? qt, this.coalesceMs = e.coalesceMs ?? Bt;
|
|
449
506
|
}
|
|
450
507
|
/**
|
|
451
508
|
* Create + buffer the looping music element. Await in the loading gate so the
|
|
452
509
|
* unmute tap is instant. Idempotent per URL (re-requesting the same track is
|
|
453
510
|
* a no-op that returns the in-flight promise).
|
|
454
511
|
*/
|
|
455
|
-
prefetchMusic(e,
|
|
456
|
-
const r =
|
|
512
|
+
prefetchMusic(e, t = 0.4) {
|
|
513
|
+
const r = re(t);
|
|
457
514
|
if (this.musicWanted = { url: e, volume: r }, this.musicUrl === e && this.musicReady)
|
|
458
515
|
return this.music && (this.music.volume = r), this.musicReady;
|
|
459
|
-
this.music && (this.music.pause(), this.music.currentTime = 0, this.music.removeAttribute("src"), this.music.load()), this.music =
|
|
460
|
-
const
|
|
461
|
-
return this.musicReady =
|
|
516
|
+
this.music && (this.music.pause(), this.music.currentTime = 0, this.music.removeAttribute("src"), this.music.load()), this.music = Re(e, !0), this.musicUrl = e, this.music.volume = r;
|
|
517
|
+
const n = Ae(this.music);
|
|
518
|
+
return this.musicReady = n, n;
|
|
462
519
|
}
|
|
463
520
|
/**
|
|
464
521
|
* Create + buffer an SFX voice pool (round-robin so overlapping plays don't
|
|
465
522
|
* cut each other off). Returns a promise that resolves when the first element
|
|
466
523
|
* buffers. Idempotent per URL.
|
|
467
524
|
*/
|
|
468
|
-
registerSound(e,
|
|
525
|
+
registerSound(e, t = 1) {
|
|
469
526
|
const r = this.ready.get(e);
|
|
470
527
|
if (r) return r;
|
|
471
|
-
const
|
|
472
|
-
for (let
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}),
|
|
528
|
+
const n = re(t), a = [];
|
|
529
|
+
for (let o = 0; o < this.sfxPoolSize; o += 1) {
|
|
530
|
+
const c = Re(e, !1);
|
|
531
|
+
c.volume = n, c.addEventListener("ended", () => {
|
|
532
|
+
c.currentTime = 0;
|
|
533
|
+
}), a.push(c);
|
|
477
534
|
}
|
|
478
|
-
this.pools.set(e, { els:
|
|
479
|
-
const
|
|
480
|
-
return this.ready.set(e,
|
|
535
|
+
this.pools.set(e, { els: a, next: 0, volume: n });
|
|
536
|
+
const i = Ae(a[0]);
|
|
537
|
+
return this.ready.set(e, i), i;
|
|
481
538
|
}
|
|
482
539
|
/** Subscribe to mute-state changes (for a toggle UI). Fires immediately with
|
|
483
540
|
* the current state. Returns an unsubscribe. */
|
|
@@ -494,7 +551,7 @@ class Oe {
|
|
|
494
551
|
* then start the music. All elements are already buffered, so this is instant.
|
|
495
552
|
*/
|
|
496
553
|
setMuted(e) {
|
|
497
|
-
e !== this.muted && (this.muted = e, this.muted || this.pools.forEach((
|
|
554
|
+
e !== this.muted && (this.muted = e, this.muted || this.pools.forEach((t) => t.els.forEach(zt)), this.applyMusic(), this.listeners.forEach((t) => t(this.muted)));
|
|
498
555
|
}
|
|
499
556
|
toggleMuted() {
|
|
500
557
|
this.setMuted(!this.muted);
|
|
@@ -505,29 +562,29 @@ class Oe {
|
|
|
505
562
|
* same sound into one play, and does NO synchronous `currentTime` seek on a
|
|
506
563
|
* ready element (the pool rewinds on `ended`, off the hot path).
|
|
507
564
|
*/
|
|
508
|
-
playOneShot(e,
|
|
565
|
+
playOneShot(e, t) {
|
|
509
566
|
if (this.muted) return;
|
|
510
567
|
const r = this.pools.get(e);
|
|
511
568
|
if (!r) return;
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
514
|
-
this.lastPlayed.set(e,
|
|
515
|
-
const
|
|
516
|
-
let
|
|
517
|
-
for (let
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
|
|
569
|
+
const n = performance.now();
|
|
570
|
+
if (n - (this.lastPlayed.get(e) ?? -1 / 0) < this.coalesceMs) return;
|
|
571
|
+
this.lastPlayed.set(e, n);
|
|
572
|
+
const a = r.els.length;
|
|
573
|
+
let i;
|
|
574
|
+
for (let o = 0; o < a; o += 1) {
|
|
575
|
+
const c = r.els[(r.next + o) % a];
|
|
576
|
+
if (c.paused) {
|
|
577
|
+
i = c, r.next = (r.next + o + 1) % a;
|
|
521
578
|
break;
|
|
522
579
|
}
|
|
523
580
|
}
|
|
524
|
-
|
|
581
|
+
i || (i = r.els[r.next], r.next = (r.next + 1) % a), i.muted = !1, i.volume = re(t ?? r.volume), i.currentTime !== 0 && (i.currentTime = 0), i.play().catch(() => {
|
|
525
582
|
});
|
|
526
583
|
}
|
|
527
584
|
/** Request the looping background track (buffer it with prefetchMusic, which
|
|
528
585
|
* a loading gate awaits). Remembered while muted; starts on unmute. */
|
|
529
|
-
startMusic(e,
|
|
530
|
-
const r =
|
|
586
|
+
startMusic(e, t = 0.4) {
|
|
587
|
+
const r = re(t);
|
|
531
588
|
this.musicUrl !== e && this.prefetchMusic(e, r), this.musicWanted = { url: e, volume: r }, this.applyMusic();
|
|
532
589
|
}
|
|
533
590
|
stopMusic() {
|
|
@@ -538,179 +595,1176 @@ class Oe {
|
|
|
538
595
|
}), this.muted && !this.music.paused && this.music.pause());
|
|
539
596
|
}
|
|
540
597
|
}
|
|
541
|
-
const
|
|
598
|
+
const Kt = (s, e, t) => s === "infinite" || s === "loop" && e < Math.max(1, Math.floor(t)) ? "replay" : "ended", Wt = (s, e, t) => s && e !== t, Ht = (s) => Math.min(100, Math.max(0, s)) / 100, qs = lt(function({
|
|
542
599
|
src: e,
|
|
543
|
-
playMode:
|
|
600
|
+
playMode: t = "once",
|
|
544
601
|
loopCount: r = 1,
|
|
545
|
-
autoplay:
|
|
546
|
-
muted:
|
|
547
|
-
volume:
|
|
548
|
-
preload:
|
|
549
|
-
onReady:
|
|
550
|
-
onPlay:
|
|
551
|
-
onPause:
|
|
552
|
-
onEnded:
|
|
602
|
+
autoplay: n = !1,
|
|
603
|
+
muted: a = !1,
|
|
604
|
+
volume: i = 100,
|
|
605
|
+
preload: o = "auto",
|
|
606
|
+
onReady: c,
|
|
607
|
+
onPlay: l,
|
|
608
|
+
onPause: p,
|
|
609
|
+
onEnded: u,
|
|
553
610
|
onError: m
|
|
554
|
-
},
|
|
555
|
-
const
|
|
556
|
-
const
|
|
557
|
-
if (
|
|
611
|
+
}, d) {
|
|
612
|
+
const f = w(null), y = w(0), A = w(null), h = E(async () => {
|
|
613
|
+
const v = f.current;
|
|
614
|
+
if (v)
|
|
558
615
|
try {
|
|
559
|
-
await
|
|
560
|
-
} catch (
|
|
561
|
-
const
|
|
562
|
-
throw m == null || m(
|
|
616
|
+
await v.play();
|
|
617
|
+
} catch (U) {
|
|
618
|
+
const G = U instanceof Error ? U : new Error(String(U));
|
|
619
|
+
throw m == null || m(G), G;
|
|
563
620
|
}
|
|
564
|
-
}, [m]),
|
|
565
|
-
var
|
|
566
|
-
return (
|
|
567
|
-
}, []),
|
|
568
|
-
const
|
|
569
|
-
|
|
621
|
+
}, [m]), g = E(() => {
|
|
622
|
+
var v;
|
|
623
|
+
return (v = f.current) == null ? void 0 : v.pause();
|
|
624
|
+
}, []), R = E(() => {
|
|
625
|
+
const v = f.current;
|
|
626
|
+
v && (v.pause(), v.currentTime = 0, y.current = 0);
|
|
570
627
|
}, []);
|
|
571
|
-
|
|
572
|
-
|
|
628
|
+
ut(
|
|
629
|
+
d,
|
|
573
630
|
() => ({
|
|
574
|
-
play:
|
|
575
|
-
pause:
|
|
576
|
-
stop:
|
|
631
|
+
play: h,
|
|
632
|
+
pause: g,
|
|
633
|
+
stop: R,
|
|
577
634
|
get current() {
|
|
578
|
-
return
|
|
635
|
+
return f.current;
|
|
579
636
|
}
|
|
580
637
|
}),
|
|
581
|
-
[
|
|
582
|
-
),
|
|
583
|
-
|
|
584
|
-
}, [e]),
|
|
585
|
-
|
|
586
|
-
}, [
|
|
587
|
-
|
|
638
|
+
[g, h, R]
|
|
639
|
+
), x(() => {
|
|
640
|
+
y.current = 0, A.current = null;
|
|
641
|
+
}, [e]), x(() => {
|
|
642
|
+
f.current && (f.current.volume = Ht(i));
|
|
643
|
+
}, [i]), x(() => {
|
|
644
|
+
Wt(n, A.current, e) && (A.current = e, h().catch(() => {
|
|
588
645
|
}));
|
|
589
|
-
}, [
|
|
590
|
-
const W =
|
|
591
|
-
|
|
592
|
-
const
|
|
593
|
-
if (
|
|
594
|
-
const
|
|
595
|
-
|
|
646
|
+
}, [n, e]);
|
|
647
|
+
const W = E(() => {
|
|
648
|
+
y.current += 1;
|
|
649
|
+
const v = Math.max(1, Math.floor(r));
|
|
650
|
+
if (Kt(t, y.current, v) === "replay") {
|
|
651
|
+
const U = f.current;
|
|
652
|
+
U && (U.currentTime = 0, h().catch(() => {
|
|
596
653
|
}));
|
|
597
654
|
return;
|
|
598
655
|
}
|
|
599
|
-
|
|
600
|
-
}, [r,
|
|
601
|
-
return /* @__PURE__ */
|
|
656
|
+
y.current = 0, u == null || u();
|
|
657
|
+
}, [r, u, h, t]);
|
|
658
|
+
return /* @__PURE__ */ M(
|
|
602
659
|
"audio",
|
|
603
660
|
{
|
|
604
|
-
ref:
|
|
661
|
+
ref: f,
|
|
605
662
|
src: e,
|
|
606
|
-
preload:
|
|
663
|
+
preload: o,
|
|
607
664
|
autoPlay: !1,
|
|
608
|
-
muted:
|
|
665
|
+
muted: a,
|
|
609
666
|
loop: !1,
|
|
610
667
|
playsInline: !0,
|
|
611
668
|
style: { display: "none" },
|
|
612
|
-
onCanPlayThrough:
|
|
613
|
-
onPlay:
|
|
614
|
-
onPause:
|
|
669
|
+
onCanPlayThrough: c,
|
|
670
|
+
onPlay: l,
|
|
671
|
+
onPause: p,
|
|
615
672
|
onEnded: W,
|
|
616
673
|
onError: () => m == null ? void 0 : m(new Error(`Unable to load audio: ${e}`))
|
|
617
674
|
}
|
|
618
675
|
);
|
|
619
|
-
}),
|
|
620
|
-
const [
|
|
621
|
-
return
|
|
676
|
+
}), N = new Xt(), Bs = (s, e) => N.prefetchMusic(s, e), $s = (s, e) => N.registerSound(s, e), zs = (s, e) => N.startMusic(s, e), Xs = () => N.stopMusic(), Ks = (s, e) => N.playOneShot(s, e), Ws = (s) => N.setMuted(s), Hs = () => N.toggleMuted(), Vs = () => N.isMuted(), js = (s) => N.onMuteChange(s), Ys = () => {
|
|
677
|
+
const [s, e] = k(N.isMuted());
|
|
678
|
+
return x(() => N.onMuteChange(e), []), s;
|
|
679
|
+
}, Vt = (s = {}) => {
|
|
680
|
+
const { auto: e = !1 } = s, t = w(s.env ?? He()), r = w(s.constraints);
|
|
681
|
+
r.current = s.constraints;
|
|
682
|
+
const [n, a] = k("unknown"), [i, o] = k(null), c = w(0), l = E(async () => {
|
|
683
|
+
const u = ++c.current, m = await Ve(t.current);
|
|
684
|
+
if (u !== c.current) return n;
|
|
685
|
+
const d = m.state === "unknown" ? "unknown" : m.state;
|
|
686
|
+
return a((f) => f === "requesting" ? f : d), d !== "blocked" && o(null), d;
|
|
687
|
+
}, []), p = E(
|
|
688
|
+
async (u) => {
|
|
689
|
+
const m = ++c.current;
|
|
690
|
+
a("requesting"), o(null);
|
|
691
|
+
const d = await je(
|
|
692
|
+
{ constraints: (u == null ? void 0 : u.constraints) ?? r.current, keepStream: !1 },
|
|
693
|
+
t.current
|
|
694
|
+
);
|
|
695
|
+
return m !== c.current || (a(d.state), o(d.reason)), d.state;
|
|
696
|
+
},
|
|
697
|
+
[]
|
|
698
|
+
);
|
|
699
|
+
return x(() => {
|
|
700
|
+
let u = () => {
|
|
701
|
+
}, m = !0;
|
|
702
|
+
return e ? p() : l(), Ye((d) => {
|
|
703
|
+
m && (a((f) => f === "requesting" ? f : d.state === "unknown" ? "unknown" : d.state), d.state !== "blocked" && o(null));
|
|
704
|
+
}, t.current).then((d) => {
|
|
705
|
+
m ? u = d : d();
|
|
706
|
+
}), () => {
|
|
707
|
+
m = !1, c.current += 1, u();
|
|
708
|
+
};
|
|
709
|
+
}, [e, l, p]), K(
|
|
710
|
+
() => ({
|
|
711
|
+
state: n,
|
|
712
|
+
reason: i,
|
|
713
|
+
canPrompt: Qe(n),
|
|
714
|
+
usable: n === "granted",
|
|
715
|
+
request: p,
|
|
716
|
+
refresh: l
|
|
717
|
+
}),
|
|
718
|
+
[n, i, p, l]
|
|
719
|
+
);
|
|
720
|
+
}, jt = {
|
|
721
|
+
display: "flex",
|
|
722
|
+
flexDirection: "column",
|
|
723
|
+
alignItems: "center",
|
|
724
|
+
justifyContent: "center",
|
|
725
|
+
gap: 12,
|
|
726
|
+
height: "100%",
|
|
727
|
+
minHeight: 160,
|
|
728
|
+
padding: 24,
|
|
729
|
+
textAlign: "center",
|
|
730
|
+
background: "#111827",
|
|
731
|
+
color: "#f9fafb",
|
|
732
|
+
fontFamily: "system-ui, sans-serif"
|
|
733
|
+
}, Yt = {
|
|
734
|
+
font: "inherit",
|
|
735
|
+
padding: "10px 18px",
|
|
736
|
+
borderRadius: 8,
|
|
737
|
+
border: "1px solid rgba(255,255,255,0.3)",
|
|
738
|
+
background: "#2563eb",
|
|
739
|
+
color: "#fff",
|
|
740
|
+
cursor: "pointer"
|
|
741
|
+
}, Qs = ({
|
|
742
|
+
children: s,
|
|
743
|
+
fallback: e,
|
|
744
|
+
auto: t = !1,
|
|
745
|
+
constraints: r,
|
|
746
|
+
requestLabel: n = "Allow camera"
|
|
747
|
+
}) => {
|
|
748
|
+
const a = Vt({ auto: t, constraints: r });
|
|
749
|
+
if (a.usable) return /* @__PURE__ */ M(ae, { children: s });
|
|
750
|
+
if (e) return /* @__PURE__ */ M(ae, { children: e(a) });
|
|
751
|
+
const { state: i, reason: o, canPrompt: c, request: l } = a;
|
|
752
|
+
return /* @__PURE__ */ L("div", { style: jt, role: "region", "aria-label": "Camera access", children: [
|
|
753
|
+
/* @__PURE__ */ M("p", { "aria-live": "polite", style: { margin: 0 }, children: (o == null ? void 0 : o.message) ?? Ze[i] }),
|
|
754
|
+
/* @__PURE__ */ M(
|
|
755
|
+
"button",
|
|
756
|
+
{
|
|
757
|
+
type: "button",
|
|
758
|
+
onClick: () => void l(),
|
|
759
|
+
disabled: !c || i === "requesting",
|
|
760
|
+
"aria-disabled": !c || i === "requesting",
|
|
761
|
+
style: { ...Yt, opacity: c && i !== "requesting" ? 1 : 0.5 },
|
|
762
|
+
children: i === "requesting" ? "Waiting…" : i === "denied" ? "Try again" : n
|
|
763
|
+
}
|
|
764
|
+
)
|
|
765
|
+
] });
|
|
766
|
+
}, Qt = () => {
|
|
767
|
+
var s;
|
|
768
|
+
return {
|
|
769
|
+
enumerateDevices: typeof navigator < "u" && ((s = navigator.mediaDevices) != null && s.enumerateDevices) ? () => navigator.mediaDevices.enumerateDevices() : void 0
|
|
770
|
+
};
|
|
771
|
+
}, Zt = /\b(back|rear|environment|world)\b/i, Jt = /\b(front|user|facetime|selfie)\b/i, es = (s) => Zt.test(s) ? "environment" : Jt.test(s) ? "user" : null, Zs = async (s = Qt()) => {
|
|
772
|
+
if (!s.enumerateDevices) return [];
|
|
773
|
+
try {
|
|
774
|
+
return (await s.enumerateDevices()).filter((t) => t.kind === "videoinput").map((t) => ({
|
|
775
|
+
deviceId: t.deviceId,
|
|
776
|
+
label: t.label,
|
|
777
|
+
facing: es(t.label)
|
|
778
|
+
}));
|
|
779
|
+
} catch {
|
|
780
|
+
return [];
|
|
781
|
+
}
|
|
782
|
+
}, Js = (s, e) => s.find((t) => t.facing === e) ?? null, er = (s) => {
|
|
783
|
+
const { session: e } = xe(), t = Et(), r = bt(), n = JSON.stringify(s ?? null), a = K(
|
|
784
|
+
() => s ? Ee(s) : r ?? Ee(),
|
|
785
|
+
[n, r]
|
|
786
|
+
// eslint-disable-line react-hooks/exhaustive-deps
|
|
787
|
+
), i = a.tiers, o = E(
|
|
788
|
+
(p) => {
|
|
789
|
+
const u = e.store.getSnapshot().quality;
|
|
790
|
+
u && e._setQuality(Je(u, a, p, performance.now()));
|
|
791
|
+
},
|
|
792
|
+
[e, a]
|
|
793
|
+
), c = E(
|
|
794
|
+
(p) => {
|
|
795
|
+
const u = e.store.getSnapshot().quality;
|
|
796
|
+
u && e._setQuality(et(u, a, p, performance.now()));
|
|
797
|
+
},
|
|
798
|
+
[e, a]
|
|
799
|
+
), l = E(() => {
|
|
800
|
+
const p = e.store.getSnapshot().quality;
|
|
801
|
+
e._setQuality(
|
|
802
|
+
tt(a, (p == null ? void 0 : p.signals) ?? st, performance.now())
|
|
803
|
+
);
|
|
804
|
+
}, [e, a]);
|
|
805
|
+
return K(
|
|
806
|
+
() => ({
|
|
807
|
+
tier: (t == null ? void 0 : t.decision.tier) ?? null,
|
|
808
|
+
index: (t == null ? void 0 : t.index) ?? -1,
|
|
809
|
+
tiers: i,
|
|
810
|
+
decision: (t == null ? void 0 : t.decision) ?? null,
|
|
811
|
+
history: (t == null ? void 0 : t.history) ?? [],
|
|
812
|
+
signals: (t == null ? void 0 : t.signals) ?? null,
|
|
813
|
+
locked: (t == null ? void 0 : t.locked) ?? !1,
|
|
814
|
+
setTier: o,
|
|
815
|
+
lock: () => c(!0),
|
|
816
|
+
unlock: () => c(!1),
|
|
817
|
+
reset: l,
|
|
818
|
+
state: t
|
|
819
|
+
}),
|
|
820
|
+
[t, i, o, c, l]
|
|
821
|
+
);
|
|
822
|
+
}, ts = 256 * 1024 * 1024;
|
|
823
|
+
class ss {
|
|
824
|
+
constructor(e = {}) {
|
|
825
|
+
T(this, "entries", /* @__PURE__ */ new Map());
|
|
826
|
+
T(this, "listeners", /* @__PURE__ */ new Set());
|
|
827
|
+
T(this, "budget");
|
|
828
|
+
T(this, "now");
|
|
829
|
+
T(this, "evictions", 0);
|
|
830
|
+
T(this, "hits", 0);
|
|
831
|
+
T(this, "misses", 0);
|
|
832
|
+
/** Memoised `getStats()` result; cleared on every change so `useSyncExternalStore` sees a stable snapshot. */
|
|
833
|
+
T(this, "statsSnapshot", null);
|
|
834
|
+
this.budget = e.budgetBytes ?? ts, this.now = e.now ?? (() => typeof performance < "u" ? performance.now() : Date.now());
|
|
835
|
+
}
|
|
836
|
+
/** Acquire `asset` on behalf of `ownerId`; shares an in-flight or loaded value. */
|
|
837
|
+
acquire(e, t) {
|
|
838
|
+
let r = this.entries.get(e.key);
|
|
839
|
+
if (r && r.status === "error" && (this.entries.delete(e.key), r = void 0), !r) {
|
|
840
|
+
this.misses += 1;
|
|
841
|
+
const n = typeof AbortController < "u" ? new AbortController() : null, a = {
|
|
842
|
+
definition: e,
|
|
843
|
+
status: "loading",
|
|
844
|
+
value: void 0,
|
|
845
|
+
bytes: 0,
|
|
846
|
+
owners: /* @__PURE__ */ new Set([t]),
|
|
847
|
+
promise: null,
|
|
848
|
+
controller: n,
|
|
849
|
+
error: null,
|
|
850
|
+
lastUsed: this.now(),
|
|
851
|
+
disposed: !1
|
|
852
|
+
};
|
|
853
|
+
return a.promise = e.load((n == null ? void 0 : n.signal) ?? new AbortController().signal).then((i) => {
|
|
854
|
+
var o, c;
|
|
855
|
+
if (a.disposed || this.entries.get(e.key) !== a)
|
|
856
|
+
throw (o = e.dispose) == null || o.call(e, i), new Error(`Asset "${e.key}" was released before it loaded`);
|
|
857
|
+
return a.value = i, a.bytes = Math.max(0, Math.round(((c = e.bytes) == null ? void 0 : c.call(e, i)) ?? 0)), a.status = "ready", a.promise = null, this.notify(), this.enforceBudget(), i;
|
|
858
|
+
}).catch((i) => {
|
|
859
|
+
const o = i instanceof Error ? i : new Error(String(i));
|
|
860
|
+
throw this.entries.get(e.key) === a && !a.disposed && (a.status = "error", a.error = o, a.promise = null, this.notify()), o;
|
|
861
|
+
}), this.entries.set(e.key, a), this.notify(), a.promise;
|
|
862
|
+
}
|
|
863
|
+
return this.hits += 1, r.owners.add(t), r.lastUsed = this.now(), this.notify(), r.status === "ready" ? Promise.resolve(r.value) : r.promise;
|
|
864
|
+
}
|
|
865
|
+
/** Start loading without holding a reference (warm the cache). */
|
|
866
|
+
preload(e) {
|
|
867
|
+
const t = "__preload__";
|
|
868
|
+
return this.acquire(e, t).finally(() => this.release(e.key, t));
|
|
869
|
+
}
|
|
870
|
+
/** Drop `ownerId`'s reference. The value stays cached until evicted or disposed. */
|
|
871
|
+
release(e, t) {
|
|
872
|
+
var n;
|
|
873
|
+
const r = this.entries.get(e);
|
|
874
|
+
!r || !r.owners.delete(t) || (r.lastUsed = this.now(), r.owners.size === 0 && r.status === "loading" && ((n = r.controller) == null || n.abort(), r.disposed = !0, this.entries.delete(e)), this.notify(), this.enforceBudget());
|
|
875
|
+
}
|
|
876
|
+
/** Synchronous read of a loaded value (or `undefined`). Does not take a reference. */
|
|
877
|
+
get(e) {
|
|
878
|
+
const t = this.entries.get(e);
|
|
879
|
+
return (t == null ? void 0 : t.status) === "ready" ? t.value : void 0;
|
|
880
|
+
}
|
|
881
|
+
has(e) {
|
|
882
|
+
return this.entries.has(e);
|
|
883
|
+
}
|
|
884
|
+
entry(e) {
|
|
885
|
+
const t = this.entries.get(e);
|
|
886
|
+
return t ? ve(e, t) : void 0;
|
|
887
|
+
}
|
|
888
|
+
list() {
|
|
889
|
+
return Array.from(this.entries, ([e, t]) => ve(e, t));
|
|
890
|
+
}
|
|
891
|
+
setBudget(e) {
|
|
892
|
+
this.budget = e, this.enforceBudget(), this.notify();
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Dispose unreferenced values, least recently used first, until usage is
|
|
896
|
+
* within the budget (or `bytesToFree` is reclaimed). Referenced values are
|
|
897
|
+
* never touched. Returns the bytes reclaimed.
|
|
898
|
+
*/
|
|
899
|
+
evict(e) {
|
|
900
|
+
const t = e ?? Math.max(0, this.usage() - (Number.isFinite(this.budget) ? this.budget : 1 / 0));
|
|
901
|
+
if (t <= 0) return 0;
|
|
902
|
+
const r = Array.from(this.entries).filter(([, a]) => a.owners.size === 0 && a.status === "ready").sort((a, i) => a[1].lastUsed - i[1].lastUsed);
|
|
903
|
+
let n = 0;
|
|
904
|
+
for (const [a, i] of r) {
|
|
905
|
+
if (n >= t) break;
|
|
906
|
+
n += i.bytes, this.disposeEntry(a, i), this.evictions += 1;
|
|
907
|
+
}
|
|
908
|
+
return n > 0 && this.notify(), n;
|
|
909
|
+
}
|
|
910
|
+
/** Dispose every unreferenced value (route change, scene teardown). Returns the bytes freed. */
|
|
911
|
+
disposeUnreferenced() {
|
|
912
|
+
let e = 0;
|
|
913
|
+
for (const [t, r] of Array.from(this.entries))
|
|
914
|
+
r.owners.size === 0 && (e += r.bytes, this.disposeEntry(t, r));
|
|
915
|
+
return e > 0 && this.notify(), e;
|
|
916
|
+
}
|
|
917
|
+
/** Dispose everything, referenced or not (app / session shutdown). Owners are forgotten. */
|
|
918
|
+
disposeAll() {
|
|
919
|
+
for (const [e, t] of Array.from(this.entries)) this.disposeEntry(e, t);
|
|
920
|
+
this.notify();
|
|
921
|
+
}
|
|
922
|
+
/** Current statistics. The object is reused until the cache changes, so it is safe as a store snapshot. */
|
|
923
|
+
getStats() {
|
|
924
|
+
if (this.statsSnapshot) return this.statsSnapshot;
|
|
925
|
+
let e = 0, t = 0, r = 0, n = 0, a = 0;
|
|
926
|
+
for (const i of this.entries.values())
|
|
927
|
+
i.owners.size > 0 && (e += 1), i.status === "loading" && (t += 1), i.status === "error" && (r += 1), i.status === "ready" && (n += i.bytes, i.owners.size === 0 && (a += i.bytes));
|
|
928
|
+
return this.statsSnapshot = {
|
|
929
|
+
assets: this.entries.size,
|
|
930
|
+
referencedAssets: e,
|
|
931
|
+
loadingAssets: t,
|
|
932
|
+
erroredAssets: r,
|
|
933
|
+
usageBytes: n,
|
|
934
|
+
reclaimableBytes: a,
|
|
935
|
+
budgetBytes: this.budget,
|
|
936
|
+
overBudget: n > this.budget,
|
|
937
|
+
evictions: this.evictions,
|
|
938
|
+
hits: this.hits,
|
|
939
|
+
misses: this.misses
|
|
940
|
+
}, this.statsSnapshot;
|
|
941
|
+
}
|
|
942
|
+
subscribe(e) {
|
|
943
|
+
return this.listeners.add(e), () => {
|
|
944
|
+
this.listeners.delete(e);
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
usage() {
|
|
948
|
+
let e = 0;
|
|
949
|
+
for (const t of this.entries.values()) t.status === "ready" && (e += t.bytes);
|
|
950
|
+
return e;
|
|
951
|
+
}
|
|
952
|
+
enforceBudget() {
|
|
953
|
+
Number.isFinite(this.budget) && this.usage() > this.budget && this.evict();
|
|
954
|
+
}
|
|
955
|
+
disposeEntry(e, t) {
|
|
956
|
+
var r, n, a;
|
|
957
|
+
if (!t.disposed) {
|
|
958
|
+
if (t.disposed = !0, (r = t.controller) == null || r.abort(), t.status === "ready" && t.value !== void 0)
|
|
959
|
+
try {
|
|
960
|
+
(a = (n = t.definition).dispose) == null || a.call(n, t.value);
|
|
961
|
+
} catch (i) {
|
|
962
|
+
console.warn(`[xr-sdk assets] dispose threw for ${e}`, i);
|
|
963
|
+
}
|
|
964
|
+
this.entries.delete(e);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
notify() {
|
|
968
|
+
this.statsSnapshot = null, this.listeners.forEach((e) => e());
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
const ve = (s, e) => ({
|
|
972
|
+
key: s,
|
|
973
|
+
status: e.status,
|
|
974
|
+
bytes: e.bytes,
|
|
975
|
+
owners: e.owners.size,
|
|
976
|
+
lastUsed: e.lastUsed,
|
|
977
|
+
error: e.error
|
|
978
|
+
}), rs = (s) => new ss(s);
|
|
979
|
+
let le;
|
|
980
|
+
const De = () => (le || (le = rs()), le), ue = (s) => {
|
|
981
|
+
if (!s) return 0;
|
|
982
|
+
const e = s.image;
|
|
983
|
+
if (!e) return 0;
|
|
984
|
+
const t = e.videoWidth || e.width || 0, r = e.videoHeight || e.height || 0;
|
|
985
|
+
if (!t || !r) return 0;
|
|
986
|
+
const n = s.isCompressedTexture, a = n ? 0.5 : s.type === $.FloatType ? 16 : 4, i = t * r * a;
|
|
987
|
+
return Math.round(s.generateMipmaps && !n ? i * 1.3334 : i);
|
|
988
|
+
}, as = (s) => {
|
|
989
|
+
if (!s) return 0;
|
|
990
|
+
let e = 0;
|
|
991
|
+
for (const t of Object.values(s.attributes)) {
|
|
992
|
+
const r = t.array;
|
|
993
|
+
r && (e += r.byteLength);
|
|
994
|
+
}
|
|
995
|
+
return s.index && (e += s.index.array.byteLength), e;
|
|
996
|
+
}, ns = [
|
|
997
|
+
"map",
|
|
998
|
+
"alphaMap",
|
|
999
|
+
"aoMap",
|
|
1000
|
+
"bumpMap",
|
|
1001
|
+
"displacementMap",
|
|
1002
|
+
"emissiveMap",
|
|
1003
|
+
"envMap",
|
|
1004
|
+
"lightMap",
|
|
1005
|
+
"metalnessMap",
|
|
1006
|
+
"normalMap",
|
|
1007
|
+
"roughnessMap",
|
|
1008
|
+
"specularMap"
|
|
1009
|
+
], Ie = (s) => {
|
|
1010
|
+
const e = [], t = s;
|
|
1011
|
+
for (const n of ns) {
|
|
1012
|
+
const a = t[n];
|
|
1013
|
+
a && a.isTexture && e.push(a);
|
|
1014
|
+
}
|
|
1015
|
+
const r = s.uniforms;
|
|
1016
|
+
if (r)
|
|
1017
|
+
for (const n of Object.values(r)) {
|
|
1018
|
+
const a = n == null ? void 0 : n.value;
|
|
1019
|
+
a && a.isTexture && e.push(a);
|
|
1020
|
+
}
|
|
1021
|
+
return e;
|
|
1022
|
+
}, is = (s) => {
|
|
1023
|
+
if (!s) return 0;
|
|
1024
|
+
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
|
|
1025
|
+
s.traverse((n) => {
|
|
1026
|
+
const a = n;
|
|
1027
|
+
a.geometry && e.add(a.geometry);
|
|
1028
|
+
const i = Array.isArray(a.material) ? a.material : a.material ? [a.material] : [];
|
|
1029
|
+
for (const o of i) Ie(o).forEach((c) => t.add(c));
|
|
1030
|
+
});
|
|
1031
|
+
let r = 0;
|
|
1032
|
+
return e.forEach((n) => {
|
|
1033
|
+
r += as(n);
|
|
1034
|
+
}), t.forEach((n) => {
|
|
1035
|
+
r += ue(n);
|
|
1036
|
+
}), r;
|
|
1037
|
+
}, we = (s) => {
|
|
1038
|
+
if (!s) return;
|
|
1039
|
+
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1040
|
+
s.traverse((n) => {
|
|
1041
|
+
const a = n;
|
|
1042
|
+
a.geometry && e.add(a.geometry);
|
|
1043
|
+
const i = Array.isArray(a.material) ? a.material : a.material ? [a.material] : [];
|
|
1044
|
+
for (const o of i)
|
|
1045
|
+
t.add(o), Ie(o).forEach((c) => r.add(c));
|
|
1046
|
+
}), r.forEach((n) => n.dispose()), t.forEach((n) => n.dispose()), e.forEach((n) => n.dispose()), s.removeFromParent();
|
|
1047
|
+
}, Le = async (s, e) => {
|
|
1048
|
+
if (rt(s)) return at(s, { signal: e });
|
|
1049
|
+
const t = await fetch(s, { signal: e });
|
|
1050
|
+
if (!t.ok) throw new Error(`Asset fetch failed (${t.status}): ${s}`);
|
|
1051
|
+
return t.arrayBuffer();
|
|
1052
|
+
}, Oe = (s) => new Promise((e, t) => {
|
|
1053
|
+
const r = () => t(new DOMException("Asset load aborted", "AbortError"));
|
|
1054
|
+
s.aborted ? r() : s.addEventListener("abort", r, { once: !0 });
|
|
1055
|
+
}), tr = (s, e = {}) => ({
|
|
1056
|
+
key: `texture:${s}${e.variant ? `#${e.variant}` : ""}`,
|
|
1057
|
+
load: async (t) => {
|
|
1058
|
+
const r = await Le(s, t), n = new Blob([r]), a = createImageBitmap(n, {
|
|
1059
|
+
imageOrientation: e.flipY === !1 ? "none" : "flipY"
|
|
1060
|
+
}), i = await Promise.race([a, Oe(t)]).catch((c) => {
|
|
1061
|
+
throw a.then((l) => l.close()).catch(() => {
|
|
1062
|
+
}), c;
|
|
1063
|
+
}), o = new $.Texture(i);
|
|
1064
|
+
return o.flipY = !1, o.colorSpace = e.colorSpace ?? $.SRGBColorSpace, o.generateMipmaps = e.generateMipmaps ?? !0, o.minFilter = o.generateMipmaps ? $.LinearMipmapLinearFilter : $.LinearFilter, o.needsUpdate = !0, o;
|
|
1065
|
+
},
|
|
1066
|
+
dispose: (t) => {
|
|
1067
|
+
var n;
|
|
1068
|
+
const r = t.image;
|
|
1069
|
+
t.dispose(), (n = r == null ? void 0 : r.close) == null || n.call(r);
|
|
1070
|
+
},
|
|
1071
|
+
bytes: ue
|
|
1072
|
+
}), sr = (s) => ({
|
|
1073
|
+
key: `gltf:${s}`,
|
|
1074
|
+
load: async (e) => {
|
|
1075
|
+
const t = await Le(s, e), r = new vt(), n = s.slice(0, s.lastIndexOf("/") + 1), a = r.parseAsync(t, n);
|
|
1076
|
+
return Promise.race([a, Oe(e)]).catch((i) => {
|
|
1077
|
+
throw a.then((o) => we(o.scene)).catch(() => {
|
|
1078
|
+
}), i;
|
|
1079
|
+
});
|
|
1080
|
+
},
|
|
1081
|
+
dispose: (e) => we(e.scene),
|
|
1082
|
+
bytes: (e) => is(e.scene)
|
|
1083
|
+
}), rr = (s, e = {}) => ({
|
|
1084
|
+
key: `video:${s}`,
|
|
1085
|
+
load: (t) => new Promise((r, n) => {
|
|
1086
|
+
const a = document.createElement("video");
|
|
1087
|
+
a.src = s, a.loop = e.loop ?? !0, a.muted = e.muted ?? !0, a.playsInline = !0, a.crossOrigin = e.crossOrigin ?? "anonymous", a.preload = "auto";
|
|
1088
|
+
const i = (o) => {
|
|
1089
|
+
a.removeAttribute("src"), a.load(), n(o instanceof Error ? o : new Error(`Video failed to load: ${s}`));
|
|
1090
|
+
};
|
|
1091
|
+
t.addEventListener(
|
|
1092
|
+
"abort",
|
|
1093
|
+
() => i(new DOMException("Asset load aborted", "AbortError")),
|
|
1094
|
+
{
|
|
1095
|
+
once: !0
|
|
1096
|
+
}
|
|
1097
|
+
), a.onerror = () => i(a.error), a.onloadeddata = () => {
|
|
1098
|
+
const o = new $.VideoTexture(a);
|
|
1099
|
+
o.colorSpace = $.SRGBColorSpace, r({ video: a, texture: o });
|
|
1100
|
+
}, a.load();
|
|
1101
|
+
}),
|
|
1102
|
+
dispose: ({ video: t, texture: r }) => {
|
|
1103
|
+
r.dispose(), t.pause(), t.removeAttribute("src"), t.load();
|
|
1104
|
+
},
|
|
1105
|
+
bytes: ({ texture: t }) => ue(t)
|
|
1106
|
+
}), Ge = mt(null), ar = ({
|
|
1107
|
+
cache: s,
|
|
1108
|
+
disposeUnreferencedOnUnmount: e = !0,
|
|
1109
|
+
children: t
|
|
1110
|
+
}) => {
|
|
1111
|
+
const r = s ?? De();
|
|
1112
|
+
return x(() => () => {
|
|
1113
|
+
e && r.disposeUnreferenced();
|
|
1114
|
+
}, [r, e]), /* @__PURE__ */ M(Ge.Provider, { value: r, children: t });
|
|
1115
|
+
}, qe = () => dt(Ge) ?? De(), nr = (s, e = {}) => {
|
|
1116
|
+
const { enabled: t = !0 } = e, r = qe(), n = ft(), a = (s == null ? void 0 : s.key) ?? null, [i, o] = k({
|
|
1117
|
+
value: null,
|
|
1118
|
+
status: "idle",
|
|
1119
|
+
error: null
|
|
1120
|
+
});
|
|
1121
|
+
return x(() => {
|
|
1122
|
+
if (!s || !t) {
|
|
1123
|
+
o({ value: null, status: "idle", error: null });
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
let c = !0;
|
|
1127
|
+
const l = r.get(s.key);
|
|
1128
|
+
return o({ value: l ?? null, status: l ? "ready" : "loading", error: null }), r.acquire(s, n).then((p) => {
|
|
1129
|
+
c && o({ value: p, status: "ready", error: null });
|
|
1130
|
+
}).catch((p) => {
|
|
1131
|
+
c && o({ value: null, status: "error", error: p });
|
|
1132
|
+
}), () => {
|
|
1133
|
+
c = !1, r.release(s.key, n);
|
|
1134
|
+
};
|
|
1135
|
+
}, [r, a, t, n]), i;
|
|
1136
|
+
}, ir = (s) => {
|
|
1137
|
+
const e = qe(), t = s ?? e;
|
|
1138
|
+
return ht(
|
|
1139
|
+
(r) => t.subscribe(r),
|
|
1140
|
+
() => t.getStats(),
|
|
1141
|
+
() => t.getStats()
|
|
1142
|
+
);
|
|
1143
|
+
}, ne = 1, Be = Object.freeze({
|
|
1144
|
+
version: ne,
|
|
1145
|
+
trackers: {
|
|
1146
|
+
face: { enabled: !0, numFaces: 1, targetFps: null, holdMs: 250, predictMs: 0, smoothing: 0 },
|
|
1147
|
+
hand: { enabled: !1, targetFps: null },
|
|
1148
|
+
gesture: { enabled: !1, targetFps: null },
|
|
1149
|
+
body: { enabled: !1, targetFps: null },
|
|
1150
|
+
holistic: {
|
|
1151
|
+
enabled: !1,
|
|
1152
|
+
targetFps: null,
|
|
1153
|
+
hands: "both",
|
|
1154
|
+
holdMs: 250,
|
|
1155
|
+
predictMs: 0,
|
|
1156
|
+
analysisMaxDimension: 768,
|
|
1157
|
+
outputFaceBlendshapes: !0,
|
|
1158
|
+
confidence: 0.5,
|
|
1159
|
+
delegate: "auto"
|
|
1160
|
+
},
|
|
1161
|
+
segmentation: { enabled: !1, quality: "low" },
|
|
1162
|
+
semanticSegmentation: { enabled: !1, preset: "multiclass", quality: "medium" }
|
|
1163
|
+
},
|
|
1164
|
+
perf: { targetFps: 24, camRes: 720, cameraZoom: 1.2, analysisScale: 1 },
|
|
1165
|
+
lifecycle: { pauseWhenHidden: !1 },
|
|
1166
|
+
quality: {},
|
|
1167
|
+
camera: { facingMode: "user", deviceId: null, mirrored: "auto" },
|
|
1168
|
+
fallbacks: { onUnsupported: "degrade", delegate: "auto" },
|
|
1169
|
+
assets: { holisticModelUrl: null, semanticSegmentationModelUrl: null },
|
|
1170
|
+
updatedAt: 0
|
|
1171
|
+
}), P = (s, e, t, r, n, a) => {
|
|
1172
|
+
if (s === void 0) return e;
|
|
1173
|
+
if (typeof s != "number" || !Number.isFinite(s))
|
|
1174
|
+
return a(`${n}: not a number, kept ${e}`), e;
|
|
1175
|
+
const i = Math.min(r, Math.max(t, s));
|
|
1176
|
+
return i !== s && a(`${n}: ${s} clamped to ${i}`), i;
|
|
1177
|
+
}, Y = (s, e, t, r) => s === void 0 ? e : s === null ? null : typeof s != "number" || !Number.isFinite(s) || s <= 0 ? (r(`${t}: invalid fps, kept ${e}`), e) : (s > 120 && r(`${t}: ${s} clamped to 120`), Math.min(120, s)), os = [
|
|
1178
|
+
"tiers",
|
|
1179
|
+
"budget",
|
|
1180
|
+
"initialTier",
|
|
1181
|
+
"minTier",
|
|
1182
|
+
"maxTier",
|
|
1183
|
+
"adaptive",
|
|
1184
|
+
"historySize"
|
|
1185
|
+
], Fe = (s) => {
|
|
1186
|
+
const e = {};
|
|
1187
|
+
for (const t of os) s[t] !== void 0 && (e[t] = s[t]);
|
|
1188
|
+
return e;
|
|
1189
|
+
}, I = (s, e, t, r) => s === void 0 ? e : typeof s != "boolean" ? (r(`${t}: not a boolean, kept ${e}`), e) : s, B = (s, e, t, r, n) => s === void 0 ? t : e.includes(s) ? s : (n(`${r}: "${String(s)}" is not one of ${e.join(" | ")}, kept ${t}`), t), Ce = (s, e, t, r) => s === void 0 ? e : s === null ? null : typeof s != "string" || !/^https?:\/\//.test(s) ? (r(`${t}: not an http(s) URL, kept ${e === null ? "the SDK default" : e}`), e) : s, z = (s = {}, e = Be, t = []) => {
|
|
1190
|
+
var o, c, l, p, u, m, d, f, y, A, h, g, R, W, v, U, G, Z, J, ee, te, V, S, F, b, _, H, X, D, j, me, fe, he, pe, ge, ye, Se, Me;
|
|
1191
|
+
const r = (Xe) => t.push(Xe), n = s.trackers ?? {}, a = e.trackers, i = s.quality === void 0 ? e.quality === !1 ? !1 : Fe(e.quality) : s.quality === !1 ? !1 : typeof s.quality == "object" && s.quality !== null ? Fe(s.quality) : (r("quality: must be an object or false, kept base"), e.quality);
|
|
1192
|
+
return {
|
|
1193
|
+
version: ne,
|
|
1194
|
+
trackers: {
|
|
1195
|
+
face: {
|
|
1196
|
+
enabled: I((o = n.face) == null ? void 0 : o.enabled, a.face.enabled, "trackers.face.enabled", r),
|
|
1197
|
+
numFaces: Math.round(
|
|
1198
|
+
P((c = n.face) == null ? void 0 : c.numFaces, a.face.numFaces, 1, 10, "trackers.face.numFaces", r)
|
|
1199
|
+
),
|
|
1200
|
+
targetFps: Y((l = n.face) == null ? void 0 : l.targetFps, a.face.targetFps, "trackers.face.targetFps", r),
|
|
1201
|
+
holdMs: P((p = n.face) == null ? void 0 : p.holdMs, a.face.holdMs, 0, 5e3, "trackers.face.holdMs", r),
|
|
1202
|
+
predictMs: P(
|
|
1203
|
+
(u = n.face) == null ? void 0 : u.predictMs,
|
|
1204
|
+
a.face.predictMs,
|
|
1205
|
+
0,
|
|
1206
|
+
1e3,
|
|
1207
|
+
"trackers.face.predictMs",
|
|
1208
|
+
r
|
|
1209
|
+
),
|
|
1210
|
+
smoothing: P(
|
|
1211
|
+
(m = n.face) == null ? void 0 : m.smoothing,
|
|
1212
|
+
a.face.smoothing,
|
|
1213
|
+
0,
|
|
1214
|
+
100,
|
|
1215
|
+
"trackers.face.smoothing",
|
|
1216
|
+
r
|
|
1217
|
+
)
|
|
1218
|
+
},
|
|
1219
|
+
hand: {
|
|
1220
|
+
enabled: I((d = n.hand) == null ? void 0 : d.enabled, a.hand.enabled, "trackers.hand.enabled", r),
|
|
1221
|
+
targetFps: Y((f = n.hand) == null ? void 0 : f.targetFps, a.hand.targetFps, "trackers.hand.targetFps", r)
|
|
1222
|
+
},
|
|
1223
|
+
gesture: {
|
|
1224
|
+
enabled: I((y = n.gesture) == null ? void 0 : y.enabled, a.gesture.enabled, "trackers.gesture.enabled", r),
|
|
1225
|
+
targetFps: Y(
|
|
1226
|
+
(A = n.gesture) == null ? void 0 : A.targetFps,
|
|
1227
|
+
a.gesture.targetFps,
|
|
1228
|
+
"trackers.gesture.targetFps",
|
|
1229
|
+
r
|
|
1230
|
+
)
|
|
1231
|
+
},
|
|
1232
|
+
body: {
|
|
1233
|
+
enabled: I((h = n.body) == null ? void 0 : h.enabled, a.body.enabled, "trackers.body.enabled", r),
|
|
1234
|
+
targetFps: Y((g = n.body) == null ? void 0 : g.targetFps, a.body.targetFps, "trackers.body.targetFps", r)
|
|
1235
|
+
},
|
|
1236
|
+
holistic: {
|
|
1237
|
+
enabled: I((R = n.holistic) == null ? void 0 : R.enabled, a.holistic.enabled, "trackers.holistic.enabled", r),
|
|
1238
|
+
targetFps: Y(
|
|
1239
|
+
(W = n.holistic) == null ? void 0 : W.targetFps,
|
|
1240
|
+
a.holistic.targetFps,
|
|
1241
|
+
"trackers.holistic.targetFps",
|
|
1242
|
+
r
|
|
1243
|
+
),
|
|
1244
|
+
hands: B(
|
|
1245
|
+
(v = n.holistic) == null ? void 0 : v.hands,
|
|
1246
|
+
["both", "left", "right", "none"],
|
|
1247
|
+
a.holistic.hands,
|
|
1248
|
+
"trackers.holistic.hands",
|
|
1249
|
+
r
|
|
1250
|
+
),
|
|
1251
|
+
holdMs: P(
|
|
1252
|
+
(U = n.holistic) == null ? void 0 : U.holdMs,
|
|
1253
|
+
a.holistic.holdMs,
|
|
1254
|
+
0,
|
|
1255
|
+
5e3,
|
|
1256
|
+
"trackers.holistic.holdMs",
|
|
1257
|
+
r
|
|
1258
|
+
),
|
|
1259
|
+
predictMs: P(
|
|
1260
|
+
(G = n.holistic) == null ? void 0 : G.predictMs,
|
|
1261
|
+
a.holistic.predictMs,
|
|
1262
|
+
0,
|
|
1263
|
+
1e3,
|
|
1264
|
+
"trackers.holistic.predictMs",
|
|
1265
|
+
r
|
|
1266
|
+
),
|
|
1267
|
+
analysisMaxDimension: Math.round(
|
|
1268
|
+
P(
|
|
1269
|
+
(Z = n.holistic) == null ? void 0 : Z.analysisMaxDimension,
|
|
1270
|
+
a.holistic.analysisMaxDimension,
|
|
1271
|
+
128,
|
|
1272
|
+
2048,
|
|
1273
|
+
"trackers.holistic.analysisMaxDimension",
|
|
1274
|
+
r
|
|
1275
|
+
)
|
|
1276
|
+
),
|
|
1277
|
+
outputFaceBlendshapes: I(
|
|
1278
|
+
(J = n.holistic) == null ? void 0 : J.outputFaceBlendshapes,
|
|
1279
|
+
a.holistic.outputFaceBlendshapes,
|
|
1280
|
+
"trackers.holistic.outputFaceBlendshapes",
|
|
1281
|
+
r
|
|
1282
|
+
),
|
|
1283
|
+
confidence: P(
|
|
1284
|
+
(ee = n.holistic) == null ? void 0 : ee.confidence,
|
|
1285
|
+
a.holistic.confidence,
|
|
1286
|
+
0,
|
|
1287
|
+
1,
|
|
1288
|
+
"trackers.holistic.confidence",
|
|
1289
|
+
r
|
|
1290
|
+
),
|
|
1291
|
+
delegate: B(
|
|
1292
|
+
(te = n.holistic) == null ? void 0 : te.delegate,
|
|
1293
|
+
["auto", "GPU", "CPU"],
|
|
1294
|
+
a.holistic.delegate,
|
|
1295
|
+
"trackers.holistic.delegate",
|
|
1296
|
+
r
|
|
1297
|
+
)
|
|
1298
|
+
},
|
|
1299
|
+
segmentation: {
|
|
1300
|
+
enabled: I(
|
|
1301
|
+
(V = n.segmentation) == null ? void 0 : V.enabled,
|
|
1302
|
+
a.segmentation.enabled,
|
|
1303
|
+
"trackers.segmentation.enabled",
|
|
1304
|
+
r
|
|
1305
|
+
),
|
|
1306
|
+
quality: B(
|
|
1307
|
+
(S = n.segmentation) == null ? void 0 : S.quality,
|
|
1308
|
+
["low", "medium", "high"],
|
|
1309
|
+
a.segmentation.quality,
|
|
1310
|
+
"trackers.segmentation.quality",
|
|
1311
|
+
r
|
|
1312
|
+
)
|
|
1313
|
+
},
|
|
1314
|
+
semanticSegmentation: {
|
|
1315
|
+
enabled: I(
|
|
1316
|
+
(F = n.semanticSegmentation) == null ? void 0 : F.enabled,
|
|
1317
|
+
a.semanticSegmentation.enabled,
|
|
1318
|
+
"trackers.semanticSegmentation.enabled",
|
|
1319
|
+
r
|
|
1320
|
+
),
|
|
1321
|
+
preset: B(
|
|
1322
|
+
(b = n.semanticSegmentation) == null ? void 0 : b.preset,
|
|
1323
|
+
wt,
|
|
1324
|
+
a.semanticSegmentation.preset,
|
|
1325
|
+
"trackers.semanticSegmentation.preset",
|
|
1326
|
+
r
|
|
1327
|
+
),
|
|
1328
|
+
quality: B(
|
|
1329
|
+
(_ = n.semanticSegmentation) == null ? void 0 : _.quality,
|
|
1330
|
+
["low", "medium", "high"],
|
|
1331
|
+
a.semanticSegmentation.quality,
|
|
1332
|
+
"trackers.semanticSegmentation.quality",
|
|
1333
|
+
r
|
|
1334
|
+
)
|
|
1335
|
+
}
|
|
1336
|
+
},
|
|
1337
|
+
perf: {
|
|
1338
|
+
targetFps: P((H = s.perf) == null ? void 0 : H.targetFps, e.perf.targetFps, 0, 120, "perf.targetFps", r),
|
|
1339
|
+
camRes: Math.round(P((X = s.perf) == null ? void 0 : X.camRes, e.perf.camRes, 160, 3840, "perf.camRes", r)),
|
|
1340
|
+
cameraZoom: P((D = s.perf) == null ? void 0 : D.cameraZoom, e.perf.cameraZoom, 1, 3, "perf.cameraZoom", r),
|
|
1341
|
+
analysisScale: P(
|
|
1342
|
+
(j = s.perf) == null ? void 0 : j.analysisScale,
|
|
1343
|
+
e.perf.analysisScale,
|
|
1344
|
+
0.25,
|
|
1345
|
+
1,
|
|
1346
|
+
"perf.analysisScale",
|
|
1347
|
+
r
|
|
1348
|
+
)
|
|
1349
|
+
},
|
|
1350
|
+
lifecycle: {
|
|
1351
|
+
pauseWhenHidden: I(
|
|
1352
|
+
(me = s.lifecycle) == null ? void 0 : me.pauseWhenHidden,
|
|
1353
|
+
e.lifecycle.pauseWhenHidden,
|
|
1354
|
+
"lifecycle.pauseWhenHidden",
|
|
1355
|
+
r
|
|
1356
|
+
)
|
|
1357
|
+
},
|
|
1358
|
+
quality: i,
|
|
1359
|
+
camera: {
|
|
1360
|
+
facingMode: B(
|
|
1361
|
+
(fe = s.camera) == null ? void 0 : fe.facingMode,
|
|
1362
|
+
["user", "environment"],
|
|
1363
|
+
e.camera.facingMode,
|
|
1364
|
+
"camera.facingMode",
|
|
1365
|
+
r
|
|
1366
|
+
),
|
|
1367
|
+
deviceId: ((he = s.camera) == null ? void 0 : he.deviceId) === void 0 ? e.camera.deviceId : typeof s.camera.deviceId == "string" || s.camera.deviceId === null ? s.camera.deviceId : (r("camera.deviceId: not a string, kept base"), e.camera.deviceId),
|
|
1368
|
+
mirrored: ((pe = s.camera) == null ? void 0 : pe.mirrored) === void 0 ? e.camera.mirrored : s.camera.mirrored === "auto" || typeof s.camera.mirrored == "boolean" ? s.camera.mirrored : (r('camera.mirrored: must be boolean or "auto", kept base'), e.camera.mirrored)
|
|
1369
|
+
},
|
|
1370
|
+
fallbacks: {
|
|
1371
|
+
onUnsupported: B(
|
|
1372
|
+
(ge = s.fallbacks) == null ? void 0 : ge.onUnsupported,
|
|
1373
|
+
["block", "degrade"],
|
|
1374
|
+
e.fallbacks.onUnsupported,
|
|
1375
|
+
"fallbacks.onUnsupported",
|
|
1376
|
+
r
|
|
1377
|
+
),
|
|
1378
|
+
delegate: B(
|
|
1379
|
+
(ye = s.fallbacks) == null ? void 0 : ye.delegate,
|
|
1380
|
+
["auto", "GPU", "CPU"],
|
|
1381
|
+
e.fallbacks.delegate,
|
|
1382
|
+
"fallbacks.delegate",
|
|
1383
|
+
r
|
|
1384
|
+
)
|
|
1385
|
+
},
|
|
1386
|
+
assets: {
|
|
1387
|
+
holisticModelUrl: Ce(
|
|
1388
|
+
(Se = s.assets) == null ? void 0 : Se.holisticModelUrl,
|
|
1389
|
+
e.assets.holisticModelUrl,
|
|
1390
|
+
"assets.holisticModelUrl",
|
|
1391
|
+
r
|
|
1392
|
+
),
|
|
1393
|
+
semanticSegmentationModelUrl: Ce(
|
|
1394
|
+
(Me = s.assets) == null ? void 0 : Me.semanticSegmentationModelUrl,
|
|
1395
|
+
e.assets.semanticSegmentationModelUrl,
|
|
1396
|
+
"assets.semanticSegmentationModelUrl",
|
|
1397
|
+
r
|
|
1398
|
+
)
|
|
1399
|
+
},
|
|
1400
|
+
updatedAt: typeof s.updatedAt == "number" && Number.isFinite(s.updatedAt) ? s.updatedAt : e.updatedAt
|
|
1401
|
+
};
|
|
1402
|
+
}, ke = (s, e, t = Date.now()) => z({ ...e, updatedAt: t }, s), $e = (s) => JSON.stringify(z({}, s)), ze = (s) => {
|
|
1403
|
+
const e = [];
|
|
1404
|
+
let t = s;
|
|
1405
|
+
if (typeof s == "string")
|
|
1406
|
+
try {
|
|
1407
|
+
t = JSON.parse(s);
|
|
1408
|
+
} catch {
|
|
1409
|
+
return {
|
|
1410
|
+
config: z(),
|
|
1411
|
+
migrated: !0,
|
|
1412
|
+
warnings: ["not valid JSON; defaults used"]
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
if (!t || typeof t != "object")
|
|
1416
|
+
return {
|
|
1417
|
+
config: z(),
|
|
1418
|
+
migrated: !0,
|
|
1419
|
+
warnings: ["not an object; defaults used"]
|
|
1420
|
+
};
|
|
1421
|
+
const r = t, n = r.version !== ne;
|
|
1422
|
+
return n && e.push(
|
|
1423
|
+
`migrated from version ${String(r.version ?? "none")} to ${ne}`
|
|
1424
|
+
), { config: z(r, Be, e), migrated: n, warnings: e };
|
|
1425
|
+
}, or = [
|
|
1426
|
+
"face",
|
|
1427
|
+
"hand",
|
|
1428
|
+
"gesture",
|
|
1429
|
+
"body",
|
|
1430
|
+
"holistic",
|
|
1431
|
+
"segmentation",
|
|
1432
|
+
"semanticSegmentation"
|
|
1433
|
+
], cs = (s) => ({
|
|
1434
|
+
perf: {
|
|
1435
|
+
targetFps: s.perf.targetFps > 0 ? s.perf.targetFps : void 0,
|
|
1436
|
+
camRes: s.perf.camRes,
|
|
1437
|
+
cameraZoom: s.perf.cameraZoom,
|
|
1438
|
+
analysisScale: s.perf.analysisScale
|
|
1439
|
+
},
|
|
1440
|
+
lifecycle: { pauseWhenHidden: s.lifecycle.pauseWhenHidden },
|
|
1441
|
+
quality: s.quality
|
|
1442
|
+
}), ls = (s) => ({
|
|
1443
|
+
facingMode: s.camera.facingMode,
|
|
1444
|
+
...s.camera.deviceId ? { deviceId: s.camera.deviceId } : {},
|
|
1445
|
+
...s.camera.mirrored === "auto" ? {} : { mirrored: s.camera.mirrored }
|
|
1446
|
+
}), O = (s) => s === null ? {} : { targetFps: s }, us = (s, e) => {
|
|
1447
|
+
const t = s.trackers;
|
|
1448
|
+
return {
|
|
1449
|
+
face: {
|
|
1450
|
+
numFaces: t.face.numFaces,
|
|
1451
|
+
...O(t.face.targetFps),
|
|
1452
|
+
holdMs: t.face.holdMs,
|
|
1453
|
+
predictMs: t.face.predictMs,
|
|
1454
|
+
active: t.face.enabled
|
|
1455
|
+
},
|
|
1456
|
+
hand: { ...O(t.hand.targetFps), active: t.hand.enabled },
|
|
1457
|
+
gesture: { ...O(t.gesture.targetFps), active: t.gesture.enabled },
|
|
1458
|
+
body: { active: t.body.enabled },
|
|
1459
|
+
holistic: {
|
|
1460
|
+
...O(t.holistic.targetFps),
|
|
1461
|
+
hands: t.holistic.hands,
|
|
1462
|
+
holdMs: t.holistic.holdMs,
|
|
1463
|
+
predictMs: t.holistic.predictMs,
|
|
1464
|
+
analysisMaxDimension: t.holistic.analysisMaxDimension,
|
|
1465
|
+
outputFaceBlendshapes: t.holistic.outputFaceBlendshapes,
|
|
1466
|
+
delegate: t.holistic.delegate === "auto" ? s.fallbacks.delegate : t.holistic.delegate,
|
|
1467
|
+
...s.assets.holisticModelUrl ? { modelUrl: s.assets.holisticModelUrl } : {},
|
|
1468
|
+
active: t.holistic.enabled
|
|
1469
|
+
},
|
|
1470
|
+
segmentation: { quality: t.segmentation.quality, active: t.segmentation.enabled },
|
|
1471
|
+
semanticSegmentation: {
|
|
1472
|
+
preset: t.semanticSegmentation.preset,
|
|
1473
|
+
quality: t.semanticSegmentation.quality,
|
|
1474
|
+
...s.assets.semanticSegmentationModelUrl ? { modelUrl: s.assets.semanticSegmentationModelUrl } : {},
|
|
1475
|
+
active: t.semanticSegmentation.enabled
|
|
1476
|
+
}
|
|
1477
|
+
}[e];
|
|
1478
|
+
}, ds = (s, e) => {
|
|
1479
|
+
const t = s.trackers;
|
|
1480
|
+
switch (e) {
|
|
1481
|
+
case C.FACE_TRACKER:
|
|
1482
|
+
return { numFaces: t.face.numFaces, ...O(t.face.targetFps) };
|
|
1483
|
+
case C.HAND_TRACKER:
|
|
1484
|
+
return { ...O(t.hand.targetFps) };
|
|
1485
|
+
case C.GESTURE_TRACKER:
|
|
1486
|
+
return { ...O(t.gesture.targetFps) };
|
|
1487
|
+
case C.BODY_TRACKER:
|
|
1488
|
+
return { ...O(t.body.targetFps) };
|
|
1489
|
+
case C.HOLISTIC_TRACKER: {
|
|
1490
|
+
const r = t.holistic;
|
|
1491
|
+
return {
|
|
1492
|
+
...O(r.targetFps),
|
|
1493
|
+
hands: r.hands,
|
|
1494
|
+
holdMs: r.holdMs,
|
|
1495
|
+
predictMs: r.predictMs,
|
|
1496
|
+
analysisMaxDimension: r.analysisMaxDimension,
|
|
1497
|
+
outputFaceBlendshapes: r.outputFaceBlendshapes,
|
|
1498
|
+
minFaceDetectionConfidence: r.confidence,
|
|
1499
|
+
minFacePresenceConfidence: r.confidence,
|
|
1500
|
+
minPoseDetectionConfidence: r.confidence,
|
|
1501
|
+
minPosePresenceConfidence: r.confidence,
|
|
1502
|
+
minHandLandmarksConfidence: r.confidence,
|
|
1503
|
+
delegate: r.delegate === "auto" ? s.fallbacks.delegate : r.delegate,
|
|
1504
|
+
...s.assets.holisticModelUrl ? { modelUrl: s.assets.holisticModelUrl } : {}
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
case C.BACKGROUND_SEGMENTATION:
|
|
1508
|
+
return { quality: t.segmentation.quality };
|
|
1509
|
+
case C.SEMANTIC_SEGMENTATION:
|
|
1510
|
+
return {
|
|
1511
|
+
preset: t.semanticSegmentation.preset,
|
|
1512
|
+
quality: t.semanticSegmentation.quality,
|
|
1513
|
+
...s.assets.semanticSegmentationModelUrl ? { modelUrl: s.assets.semanticSegmentationModelUrl } : {}
|
|
1514
|
+
};
|
|
1515
|
+
default:
|
|
1516
|
+
return {};
|
|
1517
|
+
}
|
|
1518
|
+
}, ms = (s) => {
|
|
1519
|
+
const e = s.trackers, t = [];
|
|
1520
|
+
return e.face.enabled && t.push(C.FACE_TRACKER), e.hand.enabled && t.push(C.HAND_TRACKER), e.gesture.enabled && t.push(C.GESTURE_TRACKER), e.body.enabled && t.push(C.BODY_TRACKER), e.holistic.enabled && t.push(C.HOLISTIC_TRACKER), e.segmentation.enabled && t.push(C.BACKGROUND_SEGMENTATION), e.semanticSegmentation.enabled && t.push(C.SEMANTIC_SEGMENTATION), t;
|
|
1521
|
+
}, ie = "vincentt.xr.tracking-config", de = () => {
|
|
1522
|
+
try {
|
|
1523
|
+
return typeof localStorage < "u" ? localStorage : null;
|
|
1524
|
+
} catch {
|
|
1525
|
+
return null;
|
|
1526
|
+
}
|
|
1527
|
+
}, fs = (s = ie, e = de()) => {
|
|
1528
|
+
if (!e) return null;
|
|
1529
|
+
try {
|
|
1530
|
+
const t = e.getItem(s);
|
|
1531
|
+
return t ? ze(t) : null;
|
|
1532
|
+
} catch {
|
|
1533
|
+
return null;
|
|
1534
|
+
}
|
|
1535
|
+
}, _e = (s, e = ie, t = de()) => {
|
|
1536
|
+
if (!t) return !1;
|
|
1537
|
+
try {
|
|
1538
|
+
return t.setItem(e, $e(s)), !0;
|
|
1539
|
+
} catch {
|
|
1540
|
+
return !1;
|
|
1541
|
+
}
|
|
1542
|
+
}, hs = (s = ie, e = de()) => {
|
|
1543
|
+
if (e)
|
|
1544
|
+
try {
|
|
1545
|
+
e.removeItem(s);
|
|
1546
|
+
} catch {
|
|
1547
|
+
}
|
|
1548
|
+
}, cr = (s = {}) => {
|
|
1549
|
+
const { storageKey: e = ie, persist: t = !0 } = s, r = s.storage, n = w(s.initial), a = K(() => z(n.current ?? {}), []), [i, o] = k(a), [c, l] = k([]), [p, u] = k(!t), m = w(i);
|
|
1550
|
+
m.current = i, x(() => {
|
|
1551
|
+
if (!t) {
|
|
1552
|
+
u(!0);
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
const h = fs(e, r);
|
|
1556
|
+
if (h) {
|
|
1557
|
+
const g = z(h.config, a);
|
|
1558
|
+
m.current = g, o(g), l(h.warnings), h.migrated && _e(g, e, r);
|
|
1559
|
+
}
|
|
1560
|
+
u(!0);
|
|
1561
|
+
}, [t, e, r, a]);
|
|
1562
|
+
const d = E(
|
|
1563
|
+
(h, g) => (m.current = h, o(h), l(g), t && _e(h, e, r), h),
|
|
1564
|
+
[t, e, r]
|
|
1565
|
+
), f = E(
|
|
1566
|
+
(h) => {
|
|
1567
|
+
const g = [], R = z({ ...h, updatedAt: Date.now() }, m.current, g);
|
|
1568
|
+
return d(R, g);
|
|
1569
|
+
},
|
|
1570
|
+
[d]
|
|
1571
|
+
), y = E(() => {
|
|
1572
|
+
const h = ke(a, {}, 0);
|
|
1573
|
+
return m.current = h, o(h), l([]), t && hs(e, r), h;
|
|
1574
|
+
}, [a, t, e, r]), A = E(
|
|
1575
|
+
(h) => {
|
|
1576
|
+
const g = ze(h);
|
|
1577
|
+
return g.warnings.some((R) => R.startsWith("not valid JSON") || R.startsWith("not an object")) ? (l([`import: ${g.warnings[0]}; config unchanged`]), m.current) : d(ke(g.config, {}, Date.now()), g.warnings);
|
|
1578
|
+
},
|
|
1579
|
+
[d]
|
|
1580
|
+
);
|
|
1581
|
+
return K(
|
|
1582
|
+
() => ({
|
|
1583
|
+
config: i,
|
|
1584
|
+
hydrated: p,
|
|
1585
|
+
warnings: c,
|
|
1586
|
+
update: f,
|
|
1587
|
+
reset: y,
|
|
1588
|
+
importJson: A,
|
|
1589
|
+
json: $e(i),
|
|
1590
|
+
providerProps: cs(i),
|
|
1591
|
+
cameraRequest: ls(i),
|
|
1592
|
+
trackerProps: (h) => us(i, h),
|
|
1593
|
+
modelOptions: (h) => ds(i, h),
|
|
1594
|
+
enabledModels: ms(i)
|
|
1595
|
+
}),
|
|
1596
|
+
[i, p, c, f, y, A]
|
|
1597
|
+
);
|
|
622
1598
|
};
|
|
623
1599
|
export {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
1600
|
+
Ns as AspectRatioContainer,
|
|
1601
|
+
Xt as AudioEngine,
|
|
1602
|
+
qs as AudioPlayer,
|
|
1603
|
+
Ds as Axes,
|
|
1604
|
+
Ze as CAMERA_PERMISSION_MESSAGES,
|
|
1605
|
+
Qs as CameraPermissionGate,
|
|
1606
|
+
ts as DEFAULT_ASSET_BUDGET_BYTES,
|
|
1607
|
+
Ea as DEFAULT_MATERIAL_FILL,
|
|
1608
|
+
pa as DEFAULT_MESH_RENDERER,
|
|
1609
|
+
ga as DEFAULT_MESH_RENDERER_RENDER_STATE,
|
|
1610
|
+
dr as DEFAULT_PERFORMANCE_BUDGET,
|
|
1611
|
+
Ua as DEFAULT_PIXEL_SNAP_INCREMENT,
|
|
1612
|
+
mr as DEFAULT_QUALITY_TIERS,
|
|
1613
|
+
Pa as DEFAULT_REFERENCE_PIXELS_PER_UNIT,
|
|
1614
|
+
Vr as DEFAULT_SCREEN_GLASS,
|
|
1615
|
+
ba as DEFAULT_SCREEN_GRADIENT,
|
|
1616
|
+
jr as DEFAULT_SCREEN_IMAGE_SCENE_SETTINGS,
|
|
1617
|
+
Yr as DEFAULT_SCREEN_IMAGE_SETTINGS,
|
|
1618
|
+
Qr as DEFAULT_SCREEN_SHAPE_SETTINGS,
|
|
1619
|
+
Zr as DEFAULT_SCREEN_TEXT_SCENE_SETTINGS,
|
|
1620
|
+
Jr as DEFAULT_SCREEN_TEXT_SHADOW_LAYER,
|
|
1621
|
+
Na as DEFAULT_SCREEN_TRANSFORM_2D,
|
|
1622
|
+
Da as DEFAULT_SCREEN_TRANSFORM_ROOT,
|
|
1623
|
+
Be as DEFAULT_TRACKING_CONFIG,
|
|
1624
|
+
Ta as DEFAULT_TRANSFORM_3D,
|
|
1625
|
+
ea as EXTERNAL_BACKGROUND_RENDER_LAYER,
|
|
1626
|
+
xt as FULL_SCREEN_ANCHORS,
|
|
1627
|
+
Or as LightObject,
|
|
1628
|
+
Gr as LookAt,
|
|
1629
|
+
ta as MAX_RENDER_GROUP_PASSES,
|
|
1630
|
+
Aa as MaterialFill,
|
|
1631
|
+
fa as MeshMaterial,
|
|
1632
|
+
ya as MeshRenderer,
|
|
1633
|
+
xs as Panel,
|
|
1634
|
+
Ps as PersonCutout,
|
|
1635
|
+
sa as PinToMesh,
|
|
1636
|
+
qr as RenderGroupLayer,
|
|
1637
|
+
Br as SCREEN_IMAGE_MASK_CHANNELS,
|
|
1638
|
+
$r as SceneObjectRenderer,
|
|
1639
|
+
ra as ScreenGlassMaterial,
|
|
1640
|
+
Ra as ScreenGradientMaterial,
|
|
1641
|
+
it as ScreenImage,
|
|
1642
|
+
aa as ScreenShape,
|
|
1643
|
+
zr as ScreenSpaceUI,
|
|
1644
|
+
Xr as ScreenText,
|
|
1645
|
+
nt as ScreenTransform,
|
|
1646
|
+
Kr as SequentialRenderPasses,
|
|
1647
|
+
Is as SpriteAnimation,
|
|
1648
|
+
or as TRACKER_KINDS,
|
|
1649
|
+
ie as TRACKING_CONFIG_STORAGE_KEY,
|
|
1650
|
+
ne as TRACKING_CONFIG_VERSION,
|
|
1651
|
+
Wr as TextLabel,
|
|
1652
|
+
va as Transform3D,
|
|
1653
|
+
Us as VideoBackground,
|
|
1654
|
+
ss as XRAssetCache,
|
|
1655
|
+
ar as XRAssetCacheProvider,
|
|
1656
|
+
fr as XRMediaSource,
|
|
1657
|
+
C as XRModel,
|
|
1658
|
+
hr as XRProvider,
|
|
1659
|
+
pr as XRQualityController,
|
|
1660
|
+
Ir as XRScene,
|
|
1661
|
+
gr as XR_FALLBACK_MESSAGES,
|
|
1662
|
+
yr as XR_MODEL_ASSET_URLS,
|
|
1663
|
+
N as audio,
|
|
1664
|
+
Qe as canPromptForCamera,
|
|
1665
|
+
hs as clearTrackingConfig,
|
|
1666
|
+
Ga as clientToScreenPixels,
|
|
1667
|
+
ot as computeContainScale,
|
|
1668
|
+
Sr as computeFeedCrop,
|
|
1669
|
+
Mr as computeFitLayout,
|
|
1670
|
+
rs as createAssetCache,
|
|
1671
|
+
Er as createFallbackReason,
|
|
1672
|
+
wa as createTwoStopGradient,
|
|
1673
|
+
Gs as dataURLtoFile,
|
|
1674
|
+
sr as defineGltfAsset,
|
|
1675
|
+
tr as defineTextureAsset,
|
|
1676
|
+
rr as defineVideoAsset,
|
|
1677
|
+
br as detectXRCapabilities,
|
|
1678
|
+
we as disposeObject3D,
|
|
1679
|
+
ka as drawNormalizedCrop,
|
|
1680
|
+
ms as enabledModels,
|
|
1681
|
+
as as estimateGeometryBytes,
|
|
1682
|
+
is as estimateObjectBytes,
|
|
1683
|
+
ue as estimateTextureBytes,
|
|
1684
|
+
qa as feedToScreenPixels,
|
|
1685
|
+
Tr as feedToSource,
|
|
1686
|
+
Ba as feedToTracker,
|
|
1687
|
+
$a as feedToViewport,
|
|
1688
|
+
Ar as feedToWorld,
|
|
1689
|
+
Js as findCameraByFacing,
|
|
1690
|
+
De as getDefaultAssetCache,
|
|
1691
|
+
na as getRenderGroupLayer,
|
|
1692
|
+
Rr as isFeedPointInSource,
|
|
1693
|
+
vr as isMirroredSourceKind,
|
|
1694
|
+
Vs as isMuted,
|
|
1695
|
+
Zs as listCameras,
|
|
1696
|
+
fs as loadTrackingConfig,
|
|
1697
|
+
ia as mapScreenImageSettingsToProps,
|
|
1698
|
+
oa as mapScreenTextInnerShadowToProps,
|
|
1699
|
+
ca as mapScreenTextSettingsToProps,
|
|
1700
|
+
za as mediaToScreenPixels,
|
|
1701
|
+
la as mergeScreenShapeSettings,
|
|
1702
|
+
Ia as mergeScreenTransform2D,
|
|
1703
|
+
ke as mergeTrackingConfig,
|
|
1704
|
+
wr as mirrorFeedX,
|
|
1705
|
+
Sa as normalizeMeshRendererRenderState,
|
|
1706
|
+
ua as normalizeScreenGlass,
|
|
1707
|
+
Fa as normalizeScreenGradient,
|
|
1708
|
+
Xa as normalizedToScreenPixels,
|
|
1709
|
+
js as onMuteChange,
|
|
1710
|
+
Fr as orientSourcePoint,
|
|
1711
|
+
Cr as orientedSize,
|
|
1712
|
+
ze as parseTrackingConfig,
|
|
1713
|
+
Ks as playOneShot,
|
|
1714
|
+
Bs as prefetchMusic,
|
|
1715
|
+
Ve as queryCameraPermission,
|
|
1716
|
+
$s as registerSound,
|
|
1717
|
+
da as renderSequentialPasses,
|
|
1718
|
+
je as requestCameraAccess,
|
|
1719
|
+
kr as resolveModelAssetUrl,
|
|
1720
|
+
_a as resolveNormalizedCrop,
|
|
1721
|
+
Ut as resolvePersonCutoutStatus,
|
|
1722
|
+
Ee as resolveQualityConfig,
|
|
1723
|
+
La as resolveScreenTransform2D,
|
|
1724
|
+
_r as resolveTrackerSupport,
|
|
1725
|
+
z as resolveTrackingConfig,
|
|
1726
|
+
_e as saveTrackingConfig,
|
|
1727
|
+
Ka as screenPixelsToClient,
|
|
1728
|
+
Wa as screenPixelsToFeed,
|
|
1729
|
+
Ha as screenPixelsToMedia,
|
|
1730
|
+
Va as screenPixelsToNormalized,
|
|
1731
|
+
ja as screenPixelsToScreenSpace,
|
|
1732
|
+
Ya as screenPixelsToUnits,
|
|
1733
|
+
Qa as screenPointToRay,
|
|
1734
|
+
Za as screenSpaceToScreenPixels,
|
|
1735
|
+
Ja as screenUnitsToPixels,
|
|
1736
|
+
$e as serializeTrackingConfig,
|
|
1737
|
+
Ws as setMuted,
|
|
1738
|
+
Pt as shouldDrawFallback,
|
|
1739
|
+
Q as smoothNumber,
|
|
1740
|
+
ks as smoothVector2,
|
|
1741
|
+
_s as smoothVector3,
|
|
1742
|
+
xr as sourceToFeed,
|
|
1743
|
+
zs as startMusic,
|
|
1744
|
+
Xs as stopMusic,
|
|
1745
|
+
Ye as subscribeCameraPermission,
|
|
1746
|
+
ls as toCameraRequest,
|
|
1747
|
+
ds as toModelOptions,
|
|
1748
|
+
cs as toProviderProps,
|
|
1749
|
+
us as toTrackerProps,
|
|
1750
|
+
Hs as toggleMuted,
|
|
1751
|
+
en as trackerPointToScreenPixels,
|
|
1752
|
+
tn as trackerToFeed,
|
|
1753
|
+
Ur as trackerToWorld,
|
|
1754
|
+
Vt as useCameraPermission,
|
|
1755
|
+
Os as useFrameCapture,
|
|
1756
|
+
Ls as useMediaRecorder,
|
|
1757
|
+
Ys as useMuted,
|
|
1758
|
+
Nt as usePersonMaskTexture,
|
|
1759
|
+
Rt as useScreenRectAspect,
|
|
1760
|
+
nr as useXRAsset,
|
|
1761
|
+
qe as useXRAssetCache,
|
|
1762
|
+
ir as useXRAssetStats,
|
|
1763
|
+
nn as useXRCapabilities,
|
|
1764
|
+
er as useXRQuality,
|
|
1765
|
+
cr as useXRTrackingConfig,
|
|
1766
|
+
sn as viewportToFeed,
|
|
1767
|
+
Pr as worldToFeed,
|
|
1768
|
+
rn as worldToScreenPixels,
|
|
1769
|
+
Nr as worldToTracker
|
|
716
1770
|
};
|