@vincentt-xr/sdk 2.0.0-alpha.7 → 2.0.0-alpha.9
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 +5651 -82
- package/README.md +1 -0
- package/dist/CanonicalHeadFrame-BHcWyaiK.js +1506 -0
- package/dist/CanonicalHeadFrame-D-_T1OMU.cjs +1 -0
- package/dist/DebuggerUI-7ngnJsBe.js +275 -0
- package/dist/DebuggerUI-CoglgKdO.cjs +1 -0
- package/dist/FaceRetouch-CLoTfrcs.js +1071 -0
- package/dist/FaceRetouch-J1lC1WbS.cjs +134 -0
- package/dist/FaceSurface-CHAMEeG1.cjs +1 -0
- package/dist/FaceSurface-DmP9AEeC.js +27 -0
- package/dist/SegmentationOverlay-D_FWkcyP.cjs +35 -0
- package/dist/SegmentationOverlay-vn5x_knv.js +6237 -0
- package/dist/SkeletonUtils-C2r90MtN.js +21 -0
- package/dist/SkeletonUtils-CddIup1F.cjs +1 -0
- package/dist/TextLabel-XE0rQSDn.cjs +2 -0
- package/dist/TextLabel-c9BCucOI.js +961 -0
- package/dist/assets/cache.d.ts +99 -0
- package/dist/assets/estimate.d.ts +11 -0
- package/dist/assets/gltfLoader.d.ts +16 -0
- package/dist/assets/index.d.ts +7 -0
- package/dist/assets/loaders.d.ts +43 -0
- package/dist/assets/react.d.ts +33 -0
- package/dist/body-pose/index.d.ts +521 -0
- package/dist/body-trigger/__fixtures__/syntheticBody.d.ts +83 -0
- package/dist/body-trigger/frame.d.ts +88 -0
- package/dist/body-trigger/index.d.ts +6 -0
- package/dist/body-trigger/moves.d.ts +235 -0
- package/dist/body-trigger/trigger.d.ts +75 -0
- package/dist/calibration/calibration.d.ts +75 -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/canonicalFace-BHwyCx1c.js +9 -0
- package/dist/canonicalFace-C83I225R.cjs +1 -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/BodyInstruction/BodyPoseHint.d.ts +63 -0
- package/dist/components/BodyInstruction/index.d.ts +69 -0
- package/dist/components/BodyInstruction/useBodyPose.d.ts +23 -0
- package/dist/components/BodyTracker/index.d.ts +17 -0
- package/dist/components/BodyTrigger/index.d.ts +49 -0
- package/dist/components/Debugger/DebuggerProvider.d.ts +14 -1
- package/dist/components/Debugger/DebuggerUI.d.ts +3 -1
- package/dist/components/FaceAtlas/FaceAtlasLayer.d.ts +114 -0
- package/dist/components/FaceAtlas/MadeUpCamera.d.ts +80 -0
- package/dist/components/FaceAtlas/constants.d.ts +8 -0
- package/dist/components/FaceAtlas/index.d.ts +7 -0
- package/dist/components/FaceAtlas/useFaceAtlasSurface.d.ts +84 -0
- package/dist/components/FaceAtlas/useFaceSkin.d.ts +84 -0
- package/dist/components/FaceCharacter/ExternalFaceMesh.d.ts +109 -0
- package/dist/components/FaceCharacter/FaceExpressionController.d.ts +53 -0
- package/dist/components/FaceCharacter/FaceMorph.d.ts +71 -0
- package/dist/components/FaceCharacter/FacePiercing.d.ts +65 -0
- package/dist/components/FaceCharacter/FaceReprojection.d.ts +85 -0
- package/dist/components/FaceCharacter/FaceRig.d.ts +38 -0
- package/dist/components/FaceCharacter/FaceSurface.d.ts +49 -0
- package/dist/components/FaceCharacter/FaceSurfaceOccluder.d.ts +39 -0
- package/dist/components/FaceCharacter/PinToFaceMesh.d.ts +68 -0
- package/dist/components/FaceCharacter/index.d.ts +18 -0
- package/dist/components/FaceCharacter/useFaceReprojector.d.ts +10 -0
- package/dist/components/FaceInset/FaceInset.d.ts +68 -0
- package/dist/components/FaceInset/frame.d.ts +94 -0
- package/dist/components/FaceInset/index.d.ts +6 -0
- package/dist/components/FaceInset/material.d.ts +40 -0
- package/dist/components/FaceInset/useFaceInsetTexture.d.ts +37 -0
- package/dist/components/FaceInstruction/FaceExpressionHint.d.ts +43 -0
- package/dist/components/FaceInstruction/index.d.ts +56 -0
- package/dist/components/FaceInstruction/useFaceExpression.d.ts +20 -0
- package/dist/components/FaceLiquify/FaceLiquify.d.ts +49 -0
- package/dist/components/FaceLiquify/debug.d.ts +37 -0
- package/dist/components/FaceLiquify/frame.d.ts +55 -0
- package/dist/components/FaceLiquify/index.d.ts +10 -0
- package/dist/components/FaceLiquify/material.d.ts +39 -0
- package/dist/components/FaceLiquify/pass.d.ts +49 -0
- package/dist/components/FaceLiquify/presence.d.ts +25 -0
- package/dist/components/FaceLiquify/presets.d.ts +82 -0
- package/dist/components/FaceLiquify/selfTest.d.ts +66 -0
- package/dist/components/FaceLiquify/target.d.ts +85 -0
- package/dist/components/FaceLiquify/warp.d.ts +72 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +37 -5
- package/dist/components/FaceMesh/canonical/geometryGroups.d.ts +21 -0
- package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +21 -0
- package/dist/components/FaceMesh/canonical/shaders.d.ts +1 -1
- package/dist/components/FaceMesh/index.d.ts +2 -2
- package/dist/components/FaceRetouch/Background.d.ts +3 -1
- package/dist/components/FaceRetouch/FaceRetouch.d.ts +5 -0
- package/dist/components/FaceRetouch/renderState.d.ts +19 -0
- package/dist/components/FaceSwap/FaceMirror.d.ts +46 -0
- package/dist/components/FaceSwap/FaceSwap.d.ts +58 -0
- package/dist/components/FaceSwap/FaceTextureLayer.d.ts +72 -0
- package/dist/components/FaceSwap/faceSwapPlan.d.ts +91 -0
- package/dist/components/FaceSwap/index.d.ts +13 -0
- package/dist/components/FaceSwap/settings.d.ts +300 -0
- package/dist/components/FaceSwap/useFaceTexture.d.ts +35 -0
- package/dist/components/FaceSwap/useLiveFace.d.ts +38 -0
- package/dist/components/FaceSwap/useLiveFaceTexture.d.ts +31 -0
- package/dist/components/FaceWarp3D/FaceWarp3D.d.ts +50 -0
- package/dist/components/FaceWarp3D/index.d.ts +2 -3
- package/dist/components/Faceless/Faceless.d.ts +51 -0
- package/dist/components/Faceless/index.d.ts +2 -0
- package/dist/components/GestureListener/index.d.ts +11 -0
- package/dist/components/HairLock/HairLock.d.ts +39 -0
- package/dist/components/HairLock/index.d.ts +2 -0
- package/dist/components/HairLock/lockGeometry.d.ts +15 -0
- package/dist/components/HandCutout/index.d.ts +35 -0
- package/dist/components/HandInstruction/HandGestureHint.d.ts +70 -0
- package/dist/components/HandInstruction/index.d.ts +74 -0
- package/dist/components/HandInstruction/useHandGesture.d.ts +22 -0
- package/dist/components/HandRig/ForearmOccluder.d.ts +29 -0
- package/dist/components/HandRig/HandAttachment.d.ts +34 -0
- package/dist/components/HandRig/HandOccluder.d.ts +55 -0
- package/dist/components/HandRig/HandTattoo.d.ts +61 -0
- package/dist/components/HandRig/WristAttachment.d.ts +34 -0
- package/dist/components/HandRig/index.d.ts +101 -0
- package/dist/components/HandRig/useArmMask.d.ts +29 -0
- package/dist/components/HandRig/wristSolve.d.ts +69 -0
- package/dist/components/HandTouch/HandTouch.d.ts +62 -0
- package/dist/components/HandTouch/Touchable.d.ts +36 -0
- package/dist/components/HandTouch/index.d.ts +2 -0
- package/dist/components/HandTracker/index.d.ts +10 -0
- package/dist/components/HeadBinding/index.d.ts +14 -0
- package/dist/components/HeadOccluder/CanonicalHeadFrame.d.ts +22 -0
- package/dist/components/HeadOccluder/Earrings.d.ts +55 -0
- package/dist/components/HeadOccluder/HeadAttachment.d.ts +38 -0
- package/dist/components/HeadOccluder/NeckOccluder.d.ts +64 -0
- package/dist/components/HeadOccluder/earringPlacement.d.ts +31 -0
- package/dist/components/HeadOccluder/headAttachmentPoints.d.ts +69 -0
- package/dist/components/HeadOccluder/index.d.ts +57 -3
- package/dist/components/HeadOccluder/useCanonicalHeadFit.d.ts +36 -0
- package/dist/components/HeadOccluder/useLandmarkPoseFit.d.ts +80 -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/Instruction/HintStage.d.ts +29 -0
- package/dist/components/Instruction/InstructionCue.d.ts +126 -0
- package/dist/components/Instruction/gestureHold.d.ts +20 -0
- package/dist/components/Instruction/ghost.d.ts +129 -0
- package/dist/components/Instruction/hintBlend.d.ts +19 -0
- package/dist/components/Instruction/hintLook.d.ts +81 -0
- package/dist/components/Instruction/hintLoop.d.ts +36 -0
- package/dist/components/Instruction/index.d.ts +41 -0
- package/dist/components/Instruction/useGhostModel.d.ts +33 -0
- package/dist/components/Instruction/useInstructionHold.d.ts +72 -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 +27 -1
- package/dist/components/LipEffect/LipEffectMaterial.d.ts +95 -7
- package/dist/components/LipEffect/LipEffects.d.ts +12 -0
- package/dist/components/LipEffect/defaults.d.ts +46 -4
- package/dist/components/LipEffect/index.d.ts +11 -3
- package/dist/components/LipEffect/lipShading.d.ts +73 -0
- package/dist/components/LipEffect/settings.d.ts +375 -0
- package/dist/components/LipEffect/shader.d.ts +39 -0
- package/dist/components/LipEffect/types.d.ts +128 -9
- package/dist/components/LipEffect/useLipDesignTextures.d.ts +17 -0
- package/dist/components/LipEffect/uvGuide.d.ts +74 -0
- package/dist/components/Makeup/Blush.d.ts +18 -0
- package/dist/components/Makeup/Brows.d.ts +20 -0
- package/dist/components/Makeup/Contour.d.ts +17 -0
- package/dist/components/Makeup/Eyeliner.d.ts +20 -0
- package/dist/components/Makeup/Eyeshadow.d.ts +20 -0
- package/dist/components/Makeup/Highlighter.d.ts +18 -0
- package/dist/components/Makeup/MakeupDesign.d.ts +37 -0
- package/dist/components/Makeup/MakeupRegion.d.ts +132 -0
- package/dist/components/Makeup/constants.d.ts +44 -0
- package/dist/components/Makeup/design.d.ts +106 -0
- package/dist/components/Makeup/designSamples.d.ts +42 -0
- package/dist/components/Makeup/eyes.d.ts +114 -0
- package/dist/components/Makeup/fields.d.ts +10 -0
- package/dist/components/Makeup/geometry.d.ts +106 -0
- package/dist/components/Makeup/index.d.ts +26 -0
- package/dist/components/Makeup/looks.d.ts +28 -0
- package/dist/components/Makeup/material.d.ts +239 -0
- package/dist/components/Makeup/settings.d.ts +54 -0
- package/dist/components/Makeup/shades.d.ts +143 -0
- package/dist/components/Makeup/shapes.d.ts +27 -0
- package/dist/components/Makeup/skinTone.d.ts +135 -0
- package/dist/components/Makeup/types.d.ts +110 -0
- package/dist/components/Makeup/useMakeupSkinTone.d.ts +40 -0
- package/dist/components/Necklace/Necklace.d.ts +44 -0
- package/dist/components/Necklace/index.d.ts +1 -0
- package/dist/components/ParticleEmitter/ParticleEmitter.d.ts +69 -0
- package/dist/components/ParticleEmitter/index.d.ts +1 -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/ShoulderOccluder/index.d.ts +43 -0
- package/dist/components/ShoulderOccluder/useCanonicalTorsoFit.d.ts +24 -0
- package/dist/components/SpringSwing/SpringSwing.d.ts +22 -0
- package/dist/components/SpringSwing/index.d.ts +1 -0
- package/dist/components/XRProvider/index.d.ts +16 -2
- package/dist/components/XRScene/renderOutputTarget.d.ts +12 -0
- 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 +11 -0
- package/dist/config/index.d.ts +0 -1
- package/dist/constants/index.d.ts +4 -1
- package/dist/context-DTxSQvp4.js +13 -0
- package/dist/context-hA0Rb2Xa.cjs +1 -0
- package/dist/contexts-BH7PdKFS.cjs +1 -0
- package/dist/contexts-jak8-tND.js +667 -0
- package/dist/coordinates/feed.d.ts +52 -0
- package/dist/coordinates/index.d.ts +7 -0
- package/dist/coordinates/side.d.ts +40 -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/default-setting.cjs +2 -2
- package/dist/debug-ui/face-swap-settings/index.d.ts +22 -0
- package/dist/debug-ui/gesture-settings/index.d.ts +14 -0
- package/dist/debug-ui/hierarchy-panel/index.d.ts +3 -2
- package/dist/debug-ui/holistic-tracker-settings/index.d.ts +16 -0
- package/dist/debug-ui/index.d.ts +18 -3
- 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/index.d.ts +1 -1
- package/dist/debug-ui/media-source/session.d.ts +30 -2
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +1 -1
- package/dist/debug-ui/object-inspector-panel/index.d.ts +3 -2
- package/dist/debug-ui/product-hotspots/index.d.ts +25 -0
- package/dist/debug-ui/scene-editor/hierarchy-panel.d.ts +3 -1
- package/dist/debug-ui/scene-editor/inspector-panel.d.ts +3 -1
- package/dist/debug-ui/screen-image-settings/index.d.ts +3 -1
- package/dist/debug-ui/screen-text-settings/ScreenTextSettingsPanel.d.ts +1 -1
- package/dist/debug-ui/screen-text-settings/types.d.ts +2 -0
- package/dist/debug-ui/segmentation-overlay-settings/index.d.ts +12 -0
- package/dist/debug-ui/settings-panel/index.d.ts +6 -1
- package/dist/debug-ui/shared/debugWindow.d.ts +51 -0
- package/dist/debug-ui/xr-diagnostics/index.d.ts +26 -0
- package/dist/debug-ui.cjs +3 -3
- package/dist/debug-ui.js +2695 -2547
- package/dist/detector-K8aej4MB.js +59 -0
- package/dist/detector-ijypGtse.cjs +1 -0
- package/dist/entries/all.d.ts +3 -1
- package/dist/entries/core.d.ts +20 -2
- package/dist/entries/face-effects.d.ts +123 -9
- package/dist/entries/instructions.d.ts +48 -0
- package/dist/entries/internal.d.ts +2 -1
- package/dist/entries/low-level.d.ts +49 -3
- package/dist/entries/particles.d.ts +11 -0
- package/dist/entries/product.d.ts +11 -0
- package/dist/entries/tracking.d.ts +60 -2
- package/dist/face-atlas/attributes.d.ts +30 -0
- package/dist/face-atlas/eyes.d.ts +272 -0
- package/dist/face-atlas/faceAtlas.generated.d.ts +46 -0
- package/dist/face-atlas/glsl/atlasVertex.d.ts +46 -0
- package/dist/face-atlas/glsl/common.d.ts +55 -0
- package/dist/face-atlas/glsl/design.d.ts +49 -0
- package/dist/face-atlas/glsl/eyes.d.ts +73 -0
- package/dist/face-atlas/glsl/finish.d.ts +24 -0
- package/dist/face-atlas/glsl/format.d.ts +4 -0
- package/dist/face-atlas/glsl/index.d.ts +59 -0
- package/dist/face-atlas/glsl/shading.d.ts +15 -0
- package/dist/face-atlas/glsl/shapes.d.ts +66 -0
- package/dist/face-atlas/glsl/sparkle.d.ts +19 -0
- package/dist/face-atlas/glsl/uniforms.d.ts +106 -0
- package/dist/face-atlas/guide.d.ts +51 -0
- package/dist/face-atlas/index.d.ts +25 -0
- package/dist/face-atlas/lead.d.ts +117 -0
- package/dist/face-atlas/madeUpCamera.d.ts +125 -0
- package/dist/face-atlas/masks.d.ts +53 -0
- package/dist/face-atlas/obj.d.ts +69 -0
- package/dist/face-atlas/polylines.d.ts +63 -0
- package/dist/face-atlas/probe/FaceSkinProbe.d.ts +208 -0
- package/dist/face-atlas/probe/__fixtures__/emulate.d.ts +9 -0
- package/dist/face-atlas/probe/__fixtures__/face.d.ts +24 -0
- package/dist/face-atlas/probe/constants.d.ts +137 -0
- package/dist/face-atlas/probe/glsl.d.ts +43 -0
- package/dist/face-atlas/probe/lightFit.d.ts +108 -0
- package/dist/face-atlas/probe/schedule.d.ts +44 -0
- package/dist/face-atlas/probe/selfTest.d.ts +87 -0
- package/dist/face-atlas/probe/stats.d.ts +143 -0
- package/dist/face-atlas/probe/targets.d.ts +70 -0
- package/dist/face-atlas/probe/unwrap.d.ts +76 -0
- package/dist/face-atlas/quality.d.ts +28 -0
- package/dist/face-atlas/regions.d.ts +31 -0
- package/dist/face-atlas/registry.d.ts +252 -0
- package/dist/face-atlas/renderState.d.ts +86 -0
- package/dist/face-atlas/selfOcclusion.d.ts +62 -0
- package/dist/face-atlas/shading.d.ts +406 -0
- package/dist/face-atlas/shapes.d.ts +86 -0
- package/dist/face-atlas/sides.d.ts +41 -0
- package/dist/face-atlas/skinMask.d.ts +35 -0
- package/dist/face-atlas/surface.d.ts +155 -0
- package/dist/face-atlas/topology.d.ts +44 -0
- package/dist/face-character/__fixtures__/faceImageDetections.d.ts +25 -0
- package/dist/face-character/__fixtures__/faceNode.d.ts +22 -0
- package/dist/face-character/bindFaceModel.d.ts +106 -0
- package/dist/face-character/canonicalFace.d.ts +17 -0
- package/dist/face-character/canonicalFaceGeometry.d.ts +11 -0
- package/dist/face-character/canonicalFacePositions.d.ts +7 -0
- package/dist/face-character/driveFaceModel.d.ts +57 -0
- package/dist/face-character/expressionOutputs.d.ts +45 -0
- package/dist/face-character/faceExpressions.d.ts +104 -0
- package/dist/face-character/faceImageLandmarker.d.ts +93 -0
- package/dist/face-character/faceMeshBinding.d.ts +62 -0
- package/dist/face-character/faceMorph.d.ts +77 -0
- package/dist/face-character/faceMorphs.d.ts +46 -0
- package/dist/face-character/facePhoto.d.ts +138 -0
- package/dist/face-character/facePiercings.d.ts +116 -0
- package/dist/face-character/facePin.d.ts +131 -0
- package/dist/face-character/faceReprojection.d.ts +273 -0
- package/dist/face-character/faceReprojector.d.ts +171 -0
- package/dist/face-character/faceRig.d.ts +176 -0
- package/dist/face-character/faceSwapPresence.d.ts +85 -0
- package/dist/face-character/faceTexture.d.ts +169 -0
- package/dist/face-character/faceTextureBaker.d.ts +86 -0
- package/dist/face-character/faceTextureGuide.d.ts +106 -0
- package/dist/face-character/faceTextureStats.d.ts +298 -0
- package/dist/face-character/faceTransfer.d.ts +396 -0
- package/dist/face-character/faceTransferGeometry.d.ts +109 -0
- package/dist/face-character/faceTransferSelfTest.d.ts +94 -0
- package/dist/face-character/faceWarp3D.d.ts +101 -0
- package/dist/face-character/faceless.d.ts +79 -0
- package/dist/face-character/featureWarp.d.ts +28 -0
- package/dist/face-character/liveFaceRegistry.d.ts +370 -0
- package/dist/face-character/liveValue.d.ts +12 -0
- package/dist/face-character/memo.d.ts +15 -0
- package/dist/face-effects.cjs +2324 -1
- package/dist/face-effects.js +14208 -2268
- package/dist/face-expression/index.d.ts +182 -0
- package/dist/face-info/landmarks.d.ts +17 -3
- package/dist/face-info/types.d.ts +20 -3
- package/dist/gestures/definitions.d.ts +98 -0
- package/dist/gestures/detector.d.ts +87 -0
- package/dist/gestures/index.d.ts +8 -0
- package/dist/gestures/measures.d.ts +114 -0
- package/dist/gestures/settings.d.ts +49 -0
- package/dist/getFaceInfo-B1otSDMX.cjs +1 -0
- package/dist/getFaceInfo-Cu4xDWiL.js +62 -0
- package/dist/hand/armFit.d.ts +46 -0
- package/dist/hand/armMask.d.ts +178 -0
- package/dist/hand/handCutout.d.ts +23 -0
- package/dist/hand/handCutoutRegistry.d.ts +7 -0
- package/dist/hand/handGestures.d.ts +524 -0
- package/dist/hand/handPose.d.ts +98 -0
- package/dist/hand/handRigSolver.d.ts +159 -0
- package/dist/hand/handTattoo.d.ts +81 -0
- package/dist/hand/handTouch.d.ts +240 -0
- package/dist/hand/wrist.d.ts +44 -0
- package/dist/hand/wristFilter.d.ts +44 -0
- package/dist/hooks/selectors.d.ts +76 -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/useFaceModelAcquisition.d.ts +38 -0
- package/dist/hooks/useGesture.d.ts +32 -0
- package/dist/hooks/useIrisTracking.d.ts +45 -0
- package/dist/hooks/useTrackerContext.d.ts +6 -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-B1_TzJaI.js +1104 -0
- package/dist/index-BavF06C6.js +190 -0
- package/dist/index-BfFmpddl.cjs +21 -0
- package/dist/index-BuBzneeW.cjs +46 -0
- package/dist/index-CGsQWodV.cjs +1 -0
- package/dist/index-CIe7eCMH.js +3200 -0
- package/dist/index-CfSF8LXa.cjs +1 -0
- package/dist/index-D5GTzOzD.cjs +1 -0
- package/dist/index-DBhQzvVa.js +314 -0
- package/dist/index-DE17y0ZI.cjs +1 -0
- package/dist/index-JII7huPk.js +442 -0
- package/dist/index-tpCr9CLj.cjs +1 -0
- package/dist/index-w1S7fI2B.js +1432 -0
- package/dist/index-zGaqrz_K.js +188 -0
- package/dist/instructions.cjs +30 -0
- package/dist/instructions.js +1507 -0
- package/dist/{internal-Dmk1cTXq.js → internal-B90P-clC.js} +138 -119
- package/dist/internal-Cjinca64.cjs +1 -0
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +15 -10
- package/dist/iris/compute.d.ts +27 -0
- package/dist/iris/index.d.ts +4 -0
- package/dist/iris/lead.d.ts +19 -0
- package/dist/iris/types.d.ts +89 -0
- package/dist/landmarkMask-BFDyBnKM.js +224 -0
- package/dist/landmarkMask-u7es2k4X.cjs +1 -0
- package/dist/landmarks-BlUqf5MZ.cjs +1 -0
- package/dist/landmarks-bftdwq6Z.js +76 -0
- package/dist/loaders-BGAUACsd.js +363 -0
- package/dist/loaders-BJ1_QCHt.cjs +1 -0
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +1190 -675
- package/dist/main.cjs +1 -1
- package/dist/main.js +1190 -452
- package/dist/models/Base/index.d.ts +49 -0
- package/dist/models/Body/index.d.ts +3 -1
- package/dist/models/Face/constants.d.ts +8 -0
- package/dist/models/Face/index.d.ts +4 -12
- package/dist/models/Face/rotation.d.ts +18 -3
- package/dist/models/Hand/GestureTracking.d.ts +1 -1
- package/dist/models/Hand/HandTracking.d.ts +17 -1
- package/dist/models/Holistic/index.d.ts +49 -0
- package/dist/models/Holistic/result.d.ts +68 -0
- package/dist/models/Segmentation/index.d.ts +2 -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/models/nodeSource.d.ts +9 -0
- package/dist/particles/emission.d.ts +24 -0
- package/dist/particles/eyes.d.ts +24 -0
- package/dist/particles/glsl.d.ts +14 -0
- package/dist/particles/index.d.ts +10 -0
- package/dist/particles/motion.d.ts +42 -0
- package/dist/particles/presets.d.ts +12 -0
- package/dist/particles/ring.d.ts +58 -0
- package/dist/particles/selfTest.d.ts +53 -0
- package/dist/particles/settings.d.ts +127 -0
- package/dist/particles/shapes.d.ts +29 -0
- package/dist/particles/spawner.d.ts +60 -0
- package/dist/particles/system.d.ts +64 -0
- package/dist/particles.cjs +122 -0
- package/dist/particles.js +774 -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-C8rE26Uf.js +366 -0
- package/dist/providers-DHsrhDI2.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/render/renderPasses.d.ts +8 -0
- package/dist/render/sceneBeforeRender.d.ts +12 -0
- package/dist/{renderGroups-KZk6eRiY.js → renderGroups-B38pUaX2.js} +1 -1
- package/dist/{renderGroups-80H3DpTl.cjs → renderGroups-Cb_4Ar1Q.cjs} +1 -1
- package/dist/renderPasses-B6l8IpJv.js +1290 -0
- package/dist/renderPasses-dqmkft4P.cjs +158 -0
- package/dist/renderState-CJNmj5jz.js +39 -0
- package/dist/renderState-apSfg4eR.cjs +1 -0
- package/dist/scene-object.cjs +1 -1
- package/dist/scene-object.js +2 -2
- package/dist/segmentation-Cb3ouK6Z.js +1758 -0
- package/dist/segmentation-D9pYO6aR.cjs +1 -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 +52 -0
- package/dist/select-Ck5LGz-J.cjs +1 -0
- package/dist/select-pYRo_win.js +233 -0
- package/dist/selectors-C4X71aoD.cjs +1 -0
- package/dist/selectors-DmNaKIwE.js +196 -0
- package/dist/session-BrH8G7iJ.cjs +31 -0
- package/dist/session-DgA_z6O1.js +418 -0
- package/dist/settings-BJ7FMBsO.js +111 -0
- package/dist/settings-C63FMBlF.cjs +1 -0
- package/dist/similarityFit-BFqHND2e.cjs +1 -0
- package/dist/similarityFit-Bbz-R8AY.js +91 -0
- package/dist/spring/index.d.ts +2 -0
- package/dist/spring/spring.d.ts +69 -0
- package/dist/spring/swing.d.ts +54 -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 +10 -1
- package/dist/tracking.js +1326 -506
- package/dist/trigger-D0Pm9noT.cjs +49 -0
- package/dist/trigger-IQeys0oS.js +2128 -0
- package/dist/types/compositor.d.ts +21 -0
- package/dist/types/face.d.ts +20 -1
- package/dist/types/hand-tracking.d.ts +9 -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 +47 -3
- package/dist/types/segmentation.d.ts +24 -0
- package/dist/types/session.d.ts +41 -3
- package/dist/updateThrottle-BseecYag.js +4 -0
- package/dist/updateThrottle-Of5Y4SVa.cjs +1 -0
- package/dist/useFaceInfo-BHDNCvsJ.cjs +1 -0
- package/dist/useFaceInfo-J4x7LsqL.js +76 -0
- package/dist/useFaceResultReader-BvEo5REG.js +61 -0
- package/dist/useFaceResultReader-DuaL1KJG.cjs +1 -0
- package/dist/useInstructionHold-DOu-RpCM.js +53 -0
- package/dist/useInstructionHold-DwJY1Alr.cjs +1 -0
- package/dist/useLandmarkPoseFit-Bg-h9BPb.cjs +1 -0
- package/dist/useLandmarkPoseFit-Bmb3h6Mw.js +87 -0
- package/dist/useXRCapabilities-Cr3RzuAW.cjs +1 -0
- package/dist/useXRCapabilities-Cxmlmpbd.js +30 -0
- package/dist/utils/canonicalRigidLandmarks.d.ts +8 -0
- package/dist/utils/fns.d.ts +6 -3
- package/dist/utils/headOccluderFit.d.ts +42 -0
- package/dist/utils/integrity.d.ts +21 -1
- package/dist/utils/resolveNumFaces.d.ts +13 -0
- package/dist/utils/shoulderOccluderFit.d.ts +38 -0
- package/dist/utils/similarityFit.d.ts +23 -0
- package/dist/utils/updateThrottle.d.ts +2 -0
- package/dist/utils/useStableUniforms.d.ts +18 -0
- package/dist/uv-BMFt19bg.cjs +1 -0
- package/dist/{index-ByoNj0QP.js → uv-DJU_XfmN.js} +15 -247
- package/docs/SDK_DOCUMENTATION.md +1 -2
- package/docs/api/adaptive-quality.mdx +104 -0
- package/docs/api/asset-lifecycle.mdx +78 -0
- package/docs/api/body-instructions.mdx +285 -0
- package/docs/api/body-triggers.mdx +234 -0
- package/docs/api/camera-permission.mdx +142 -0
- package/docs/api/coordinate-spaces.mdx +168 -0
- package/docs/api/cross-camera.mdx +89 -0
- package/docs/api/debug-ui-scene-editor.mdx +23 -2
- package/docs/api/diagnostics-calibration.mdx +97 -0
- package/docs/api/external-face-mesh.mdx +231 -0
- package/docs/api/face-actions.mdx +20 -16
- package/docs/api/face-attribute-expression.mdx +1 -1
- package/docs/api/face-binding-anchors.mdx +4 -2
- package/docs/api/face-character.mdx +157 -0
- package/docs/api/face-effects.mdx +9 -0
- package/docs/api/face-expression-controller.mdx +153 -0
- package/docs/api/face-info.mdx +17 -11
- package/docs/api/face-inset.mdx +204 -0
- package/docs/api/face-instructions.mdx +183 -0
- package/docs/api/face-liquify.mdx +196 -0
- package/docs/api/face-mesh.mdx +8 -9
- package/docs/api/face-morph.mdx +117 -0
- package/docs/api/face-painting.mdx +7 -0
- package/docs/api/face-reprojection.mdx +154 -0
- package/docs/api/face-retouching.mdx +18 -10
- package/docs/api/face-swap.mdx +350 -0
- package/docs/api/face-warp-3d.mdx +166 -0
- package/docs/api/faceless.mdx +143 -0
- package/docs/api/gestures.mdx +209 -0
- package/docs/api/hair.mdx +97 -0
- package/docs/api/hand-instructions.mdx +222 -0
- package/docs/api/hand-rig.mdx +535 -0
- package/docs/api/hand-touch.mdx +162 -0
- package/docs/api/head-occluder.mdx +563 -0
- package/docs/api/holistic-tracker.mdx +164 -0
- package/docs/api/instructions.mdx +323 -0
- package/docs/api/iris-tracking.mdx +247 -0
- package/docs/api/made-up-camera.mdx +131 -0
- package/docs/api/makeup-skin-tone.mdx +135 -0
- package/docs/api/makeup.mdx +353 -0
- package/docs/api/multi-subject.mdx +98 -0
- package/docs/api/particles.mdx +155 -0
- package/docs/api/person-cutout.mdx +136 -0
- package/docs/api/pin-to-face-mesh.mdx +274 -0
- package/docs/api/product-ar.mdx +114 -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 +51 -1
- package/docs/examples/lip-shaders.mdx +273 -0
- package/docs/guides/face-atlas-template.svg +1 -0
- package/docs/guides/face-atlas-textures.mdx +186 -0
- package/docs/guides/face-texture-template.svg +1 -0
- package/docs/guides/harness-debug-ui.mdx +4 -4
- package/docs/guides/lip-effect-textures.mdx +368 -0
- package/docs/guides/lip-uv-template.png +0 -0
- package/docs/guides/lip-uv-template.svg +1 -0
- package/docs/guides/makeup-design-textures.mdx +109 -0
- package/docs/introduction.mdx +1 -2
- package/package.json +23 -1
- package/dist/DebuggerUI-B6bP6P9r.cjs +0 -1
- package/dist/DebuggerUI-BjOMr8q_.js +0 -269
- 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/components/FaceWarp3D/FaceWarp3DHead.d.ts +0 -15
- package/dist/components/FaceWarp3D/defaults.d.ts +0 -37
- package/dist/components/FaceWarp3D/warp.d.ts +0 -13
- package/dist/contexts-ByhzppYl.js +0 -663
- package/dist/contexts-Dr62It_K.cjs +0 -1
- package/dist/debug-ui/face-warp-3d/index.d.ts +0 -6
- package/dist/getFaceInfo-C4QpCQIY.js +0 -118
- package/dist/getFaceInfo-fA1bFBub.cjs +0 -1
- package/dist/index-9dlAQAhy.js +0 -1462
- package/dist/index-BjmTe9eM.cjs +0 -1
- package/dist/index-BpEf2BBb.cjs +0 -1
- package/dist/index-CyUUurQT.cjs +0 -1
- package/dist/index-DCiMbxC3.cjs +0 -1
- package/dist/index-DXT3WccE.js +0 -2089
- package/dist/index-DpI-qo5X.cjs +0 -17
- package/dist/index-DyVF4vEW.js +0 -111
- package/dist/index-VJ0SJwmG.js +0 -214
- 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/session-CpkiK5YA.cjs +0 -31
- package/dist/session-DLFN_VII.js +0 -363
- package/dist/useFaceInfo-BJ8-_MOs.cjs +0 -1
- package/dist/useFaceInfo-Dk426LTu.js +0 -62
- package/dist/useFaceResults-CtetsO9M.js +0 -19
- package/dist/useFaceResults-wBJF3zyp.cjs +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";var gn=Object.defineProperty;var yn=(e,t,n)=>t in e?gn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var v=(e,t,n)=>yn(e,typeof t!="symbol"?t+"":t,n);const y=require("react"),le=require("./useFaceResultReader-DuaL1KJG.cjs"),J=require("react/jsx-runtime"),Mn=require("three"),it=require("@react-three/fiber"),W=require("./index-CfSF8LXa.cjs"),wt=require("./useLandmarkPoseFit-Bg-h9BPb.cjs"),wn=require("./SkeletonUtils-CddIup1F.cjs"),F=require("./index-CGsQWodV.cjs"),jt=require("./selectors-C4X71aoD.cjs"),At=require("./landmarks-BlUqf5MZ.cjs"),at=require("./detector-ijypGtse.cjs");function xn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const u=xn(Mn),vn=({node:e,enabled:t,selectedSource:n,throttleMs:s=16,holdMs:i=250,onFrame:o})=>{const r=y.useCallback(c=>le.prepareCalibrationFaceResults(c.faceLandmarks??[]),[n]);return le.useFaceResultReader({enabled:t,holdMs:i,node:e,onFrame:o,prepare:r,throttleMs:s})},Sn=7,Me=Object.freeze({along:Object.freeze([2,4,6,8]),widthAt:1.5,maxWidth:11,minWidth:2.5,maxTurn:95}),we=(e,t)=>{const{image:n,world:s}=e;if(n.length<21||s.length<21)return null;const i=I=>(n[I].x+1)/2*t,o=I=>(1-n[I].y)/2;let r=0,c=0,l=0,h=0;const a=21;for(let I=0;I<a;I+=1)r+=i(I),c+=o(I),l+=s[I].x,h-=s[I].y;r/=a,c/=a,l/=a,h/=a;let f=0,d=0,g=0;for(let I=0;I<a;I+=1){const P=s[I].x-l,B=-s[I].y-h,z=i(I)-r,Y=o(I)-c;f+=P*z+B*Y,d+=P*Y-B*z,g+=P*P+B*B}const x=Math.hypot(f,d)/Math.max(g,1e-12),E=W.HAND_JOINT_INDEX.wrist,m=W.HAND_JOINT_INDEX.middleMcp,T=i(E)-i(m),N=o(E)-o(m),k=Math.hypot(T,N),Q=Math.hypot(s[E].x-s[m].x,s[E].y-s[m].y,s[E].z-s[m].z);return!(x>0)||k<.3*Q*x?null:{wrist:{x:i(E),y:o(E)},toElbow:{x:T/k,y:N/k},unitsPerCm:x,aspect:t}},st=(e,t,n)=>({x:e.x+t.x*n,y:e.y+t.y*n}),xe=(e,t,n={})=>{const s={...Me,...n},{wrist:i,toElbow:o,unitsPerCm:r,aspect:c}=t,{width:l,height:h}=e;if(l<=0||h<=0||!(r>0))return null;const a=Math.min(1/h,c/l),f=s.maxWidth*r,d=s.minWidth*r,g=O=>{const w=O.x/c,b=O.y;return w<0||b<0||w>=1||b>=1?null:e.inside(Math.floor(b*h)*l+Math.floor(w*l))},x=(O,w)=>{if(g(O)===null)return null;const b={x:-w.y,y:w.x};let V=null;for(let D=0;D*a<=f/2;D+=1){if(g(st(O,b,D*a))){V=D*a;break}if(D>0&&g(st(O,b,-D*a))){V=-D*a;break}}if(V===null)return null;let R=!1;const A=D=>{let Z=V;for(;;){const dt=g(st(O,b,Z+D*a));if(dt===null)return R=!0,Z;if(!dt)return Z;if(Z+=D*a,Math.abs(Z-V)>f)return R=!0,Z}},U=A(-1),H=A(1),_=H-U+a;return{mid:st(O,b,(U+H)/2),width:_,a:st(O,b,U),b:st(O,b,H),ok:!R&&_>=d&&_<=f}},E=O=>s.along.map(w=>x(st(i,O,w*r),O)),m=O=>{const w=[i,...O.filter(M=>!!(M!=null&&M.ok)).map(M=>M.mid)];if(w.length<3)return null;const b=w.reduce((M,D)=>M+D.x,0)/w.length,V=w.reduce((M,D)=>M+D.y,0)/w.length;let R=0,A=0,U=0;for(const M of w)R+=(M.x-b)**2,A+=(M.x-b)*(M.y-V),U+=(M.y-V)**2;const H=.5*Math.atan2(2*A,R-U),_={x:Math.cos(H),y:Math.sin(H)};return _.x*o.x+_.y*o.y<0?{x:-_.x,y:-_.y}:_},T=s.maxTurn*Math.PI/180,N=O=>Math.atan2(o.x*O.y-o.y*O.x,o.x*O.x+o.y*O.y),k=O=>({x:o.x*Math.cos(O)-o.y*Math.sin(O),y:o.x*Math.sin(O)+o.y*Math.cos(O)}),I=E((()=>{const O=T+40*Math.PI/180,w=Sn*r,b=Math.min(1*Math.PI/180,a/w),V=Math.ceil(O/b),R=[];let A=null;for(let M=-V;M<=V+1;M+=1){const D=M*b,Z=M<=V&&g(st(i,k(D),w))===!0;Z&&A===null&&(A=D),!Z&&A!==null&&(A>-V*b&&D<=V*b&&R.push([A,D-b]),A=null)}const U=([M,D])=>(D-M)*w,H=R.filter(M=>U(M)>=d&&U(M)<=f*1.5);if(!H.length)return null;const _=H.reduce((M,D)=>Math.abs((D[0]+D[1])/2)<Math.abs((M[0]+M[1])/2)?D:M);return k((_[0]+_[1])/2)})()??o);let P=m(I);if(!P||Math.abs(N(P))>T)return null;const B=E(P),z=m(B);z&&Math.abs(N(z))<=T&&(P=z);const Y=z?B:I,et=Y.filter(O=>!!(O!=null&&O.ok)),L=x(st(i,P,s.widthAt*r),P),nt=Math.min(...et.map(O=>O.width),L!=null&&L.ok?L.width:1/0),ht=L!=null&&L.ok?L.mid:st(i,P,s.widthAt*r),C=Y.filter(O=>!!O).map(({a:O,b:w,ok:b})=>({a:O,b:w,ok:b}));return L&&C.push({a:L.a,b:L.b,ok:L.ok}),{direction:P,bend:N(P),width:nt/r,center:ht,confidence:et.length/Math.max(1,s.along.length),sections:C}},Kt=Object.freeze({smoothing:.4,holdMs:400,fadeMs:300,maxSkewMs:70,maxShift:2}),bn=24,On=.5,Tn=Math.cos(3*Math.PI/180);class ve{constructor(t={}){v(this,"bend",0);v(this,"width",null);v(this,"shift",0);v(this,"weight",0);v(this,"confidence",0);v(this,"last",null);v(this,"settings");v(this,"history",[]);v(this,"found",!1);v(this,"lostAtMs",null);this.settings={...Kt,...t}}pushHand(t,n){const s=this.history[this.history.length-1];s&&s.timeMs===t||(this.history.push({timeMs:t,query:n}),this.history.length>bn&&this.history.shift())}get query(){var t;return((t=this.history[this.history.length-1])==null?void 0:t.query)??null}still(){const t=this.query;if(!t||this.history.length<2)return!1;const n=On*t.unitsPerCm;return this.history.every(({query:s})=>!!s&&Math.hypot(s.wrist.x-t.wrist.x,s.wrist.y-t.wrist.y)<=n&&s.toElbow.x*t.toElbow.x+s.toElbow.y*t.toElbow.y>=Tn)}measure(t,n,s={}){const i=this.history.filter(g=>g.query!==null),o=i[i.length-1];let r=n===void 0?o:i.reduce((g,x)=>!g||Math.abs(x.timeMs-n)<Math.abs(g.timeMs-n)?x:g,void 0);if(!r)return null;if(n!==void 0&&Math.abs(r.timeMs-n)>this.settings.maxSkewMs){const g=this.history[0];if(!g||g.timeMs>n||!this.still())return null;r=o}const c=xe(t,r.query,s);if(this.last=c,!c)return this.found&&this.lostAtMs===null&&(this.lostAtMs=n??r.timeMs),null;const{wrist:l,unitsPerCm:h}=r.query,a=((c.center.x-l.x)*-c.direction.y+(c.center.y-l.y)*c.direction.x)/h,f=Math.max(-this.settings.maxShift,Math.min(this.settings.maxShift,a)),d=this.found?Math.min(1,Math.max(.01,this.settings.smoothing)):1;return this.bend+=(c.bend-this.bend)*d,this.confidence+=(c.confidence-this.confidence)*d,this.width=this.width===null?c.width:this.width+(c.width-this.width)*d,this.shift+=(f-this.shift)*d,this.found=!0,this.lostAtMs=null,c}step(t){if(!this.found){this.weight=0;return}const n=this.lostAtMs===null?-1/0:t-this.lostAtMs-this.settings.holdMs;this.weight=n<=0?1:Math.max(0,1-n/Math.max(1,this.settings.fadeMs)),this.weight===0&&this.clear()}clear(){this.found=!1,this.lostAtMs=null,this.confidence=0,this.bend=0,this.shift=0,this.width=null,this.weight=0}reset(){this.history.length=0,this.clear(),this.last=null}}const _n=15,Se=e=>{At.useXRModel(W.XRModel.BACKGROUND_SEGMENTATION,{type:"portrait"},e==="portrait"),At.useXRModel(W.XRModel.SEMANTIC_SEGMENTATION,{preset:"multiclass"},e==="skin");const t=jt.useXRModelNode(W.XRModel.BACKGROUND_SEGMENTATION),n=jt.useXRModelNode(W.XRModel.SEMANTIC_SEGMENTATION);return y.useMemo(()=>{if(!e)return null;let s=0,i=0,o=0,r,c=-1/0,l=null,h=null,a=null,f=-1,d=-1;return{kind:e,get width(){return s},get height(){return i},get version(){return o},get timestampMs(){return r},inside:e==="portrait"?g=>l!==null&&l[g]<=127:g=>a!==null&&a[g]===f,refresh:g=>{var E;if(e==="portrait"){if(!t||g-c<1e3/_n)return!1;const m=(E=t.getRawSegmentationData)==null?void 0:E.call(t);return!(m!=null&&m.maskData)||m===h||m.width<=0?!1:(c=g,h=m,l=m.maskData,s=m.width,i=m.height,r=m.timestampMs,o+=1,!0)}const x=n==null?void 0:n.getMask();return!x||x.version===0||x.version===d?!1:(d=x.version,f=x.labels.indexOf("body_skin"),a=x.indices,s=x.width,i=x.height,r=x.timestampMs,o+=1,f>=0)}}},[e,t,n])},p={c:new u.Vector3,y:new u.Vector3,p:new u.Vector3,ndc:new u.Vector3,axis:new u.Vector3,q:new u.Quaternion,m:new u.Matrix4,t:new u.Matrix4,turned:new u.Matrix4,a:{x:0,y:0},b:{x:0,y:0}},mt=(e,t,n,s={x:0,y:0})=>(p.ndc.copy(e).project(t),s.x=(p.ndc.x+1)/2*n,s.y=(1-p.ndc.y)/2,s),be=(e,t)=>Math.atan2(e.x*t.y-e.y*t.x,e.x*t.x+e.y*t.y),Gt=(e,t,n,s={x:0,y:0})=>{p.c.setFromMatrixPosition(e),p.y.setFromMatrixColumn(e,1).normalize(),mt(p.c,t,n,p.a);const i=Math.max(1e-4,p.c.distanceTo(t.position)*.001);mt(p.p.copy(p.c).addScaledVector(p.y,-i),t,n,p.b);const o=p.b.x-p.a.x,r=p.b.y-p.a.y,c=Math.hypot(o,r)||1;return s.x=o/c,s.y=r/c,s},En=(e,t,n)=>{p.c.setFromMatrixPosition(e);const s=Math.max(1e-4,p.c.distanceTo(t.position)*.001);mt(p.c,t,n,p.a);const i=h=>(p.y.setFromMatrixColumn(e,h).normalize(),mt(p.p.copy(p.c).addScaledVector(p.y,s),t,n,p.b),Math.hypot(p.b.x-p.a.x,p.b.y-p.a.y)),o=i(1),r=Math.max(i(0),i(2),1e-12),c=o/r,l=Math.min(1,Math.max(0,(c-ae)/(An-ae)));return l*l*(3-2*l)},ae=.25,An=.45,Oe=(e,t,n,s,i,o)=>{const r=-s.y,c=s.x;let l=1/0,h=-1/0;for(let a=0;a<24;a+=1){const f=a/24*Math.PI*2;p.p.set(t*Math.cos(f),0,n*Math.sin(f)).applyMatrix4(e),mt(p.p,i,o,p.a);const d=p.a.x*r+p.a.y*c;l=Math.min(l,d),h=Math.max(h,d)}return h-l},Te=(e,t,n,s,i,o)=>{const r=Math.min(1,Math.max(0,i));if(r===0)return o.copy(e),1;const c=Gt(e,t,n,{x:0,y:0}),l=be(c,s.up)*r*En(e,t,n);if(p.c.setFromMatrixPosition(e),p.axis.copy(p.c).sub(t.getWorldPosition(p.p)).normalize(),t.isOrthographicCamera&&t.getWorldDirection(p.axis),p.q.setFromAxisAngle(p.axis,l),p.m.makeRotationFromQuaternion(p.q),p.t.makeTranslation(p.c.x,p.c.y,p.c.z),p.turned.copy(p.t).multiply(p.m),p.t.makeTranslation(-p.c.x,-p.c.y,-p.c.z),p.turned.multiply(p.t).multiply(e),s.shift!==0){p.ndc.copy(p.c).project(t);const a=-s.up.y*s.shift*r,f=s.up.x*s.shift*r;p.p.set(p.ndc.x+a*2/n,p.ndc.y-f*2,p.ndc.z).unproject(t).sub(p.c),p.t.makeTranslation(p.p.x,p.p.y,p.p.z),p.turned.premultiply(p.t)}o.copy(p.turned);let h=1;if(s.width!==null&&s.width>0){const a=Oe(p.turned,s.halfWidth,s.halfDepth,s.up,t,n);if(a>1e-9){const[f,d]=s.scaleRange??[.85,1.2];h=1+(Math.min(d,Math.max(f,s.width/a))-1)*r}}return h},_e=.9,Ee=.7,Jt=e=>{const t=e.restPositions,n=t[W.HAND_JOINT_INDEX.indexMcp].distanceTo(t[W.HAND_JOINT_INDEX.pinkyMcp]),s=t[W.HAND_JOINT_INDEX.wrist].distanceTo(t[W.HAND_JOINT_INDEX.middleMcp]),i=n*_e;return{width:i,depth:i*Ee,palmWidth:n,palmLength:s}},K={inv:new u.Quaternion,x:new u.Vector3,y:new u.Vector3,z:new u.Vector3,basis:new u.Matrix4},Ae=(e,t={position:new u.Vector3,quaternion:new u.Quaternion})=>{const n=e.restQuaternions.wrist;if(!n)throw new Error('WristAttachment: the rig has no "wrist" node');K.inv.copy(n).invert();const s=e.restPositions;return K.y.subVectors(s[W.HAND_JOINT_INDEX.middleMcp],s[W.HAND_JOINT_INDEX.wrist]).applyQuaternion(K.inv).normalize(),K.z.copy(e.restPalmNormal).applyQuaternion(K.inv),K.z.addScaledVector(K.y,-K.z.dot(K.y)).normalize(),K.x.crossVectors(K.y,K.z),K.basis.makeBasis(K.x,K.y,K.z),t.position.set(0,0,0),t.quaternion.setFromRotationMatrix(K.basis),t},Re=2.5,ke=1.25,De=.15,Ie=Object.freeze({jump:35,confirmMs:200,confirmSamples:4,smoothing:.6});class Ne{constructor(t={}){v(this,"settings");v(this,"q",new u.Quaternion);v(this,"has",!1);v(this,"pending",null);this.settings={...Ie,...t}}apply(t,n,s,i){const o=u.MathUtils.degToRad(this.settings.jump);if(!this.has)return this.q.copy(t),this.has=!0,this.pending=null,s.copy(this.q);if(this.q.angleTo(t)>o){const{pending:r}=this;return r&&r.q.angleTo(t)<o/2?((i===void 0||i!==r.lastSample)&&(r.samples+=1,r.lastSample=i),n-r.sinceMs>=this.settings.confirmMs&&r.samples>=this.settings.confirmSamples&&(this.q.copy(t),this.pending=null)):this.pending={q:t.clone(),sinceMs:n,samples:1,lastSample:i},s.copy(this.q)}return this.pending=null,this.q.slerp(t,u.MathUtils.clamp(this.settings.smoothing,.01,1)),s.copy(this.q)}reset(){this.has=!1,this.pending=null}}const Ct="forearm",Rn=new u.Vector3(1,1,1),kn=.2,Dn=.45;class He{constructor(t,n){v(this,"filter",new Ne);v(this,"arm",null);v(this,"world",new u.Matrix4);v(this,"crossScale",1);v(this,"size");v(this,"forearmFrame",new u.Matrix4);v(this,"wristFrame",new u.Matrix4);v(this,"toForearm",new u.Matrix4);v(this,"frame",0);v(this,"solved",-1);v(this,"sample");v(this,"last",{up:{x:0,y:0},units:0});v(this,"w",{raw:new u.Matrix4,steady:new u.Matrix4,local:new u.Matrix4,p:new u.Vector3,q:new u.Quaternion,s:new u.Vector3,up:{x:0,y:0}});this.binding=t,this.forearm=n;const{position:s,quaternion:i}=Ae(t);this.wristFrame.compose(s,i,Rn),this.size=Jt(t);const o=new u.Matrix4().compose(n.position,n.quaternion,n.scale);this.forearmFrame.copy(o).invert().multiply(this.wristFrame),this.toForearm.copy(this.wristFrame).invert().multiply(o)}tick(t){this.frame+=1,this.sample=t}reset(){this.filter.reset()}solve(t,n,s=performance.now()){const i=this.binding.bones.wrist;if(!i)return null;if(this.solved===this.frame)return this.world;this.solved=this.frame;const{w:o}=this;o.raw.multiplyMatrices(i.matrixWorld,this.wristFrame),o.raw.decompose(o.p,o.q,o.s),this.filter.apply(o.q,s,o.q,this.sample),o.steady.compose(o.p,o.q,o.s);const r=this.arm,c=r==null?void 0:r.tracker,l=c==null?void 0:c.query;this.crossScale=1;const h=!l&&this.last.units>0;if(!r||!c||c.weight<=0||!l&&!h)this.world.copy(o.steady),this.last.units=0;else{const a=l?l.unitsPerCm:this.last.units;if(!r.turn)Gt(o.steady,t,n,o.up);else if(l){const{x:d,y:g}=l.toElbow;o.up.x=d*Math.cos(c.bend)-g*Math.sin(c.bend),o.up.y=d*Math.sin(c.bend)+g*Math.cos(c.bend)}else o.up.x=this.last.up.x,o.up.y=this.last.up.y;this.last.up.x=o.up.x,this.last.up.y=o.up.y,this.last.units=a;const f=u.MathUtils.smoothstep(c.confidence,kn,Dn);this.crossScale=Te(o.steady,t,n,{up:o.up,shift:r.fitWidth?c.shift*a:0,width:r.fitWidth&&c.width!==null?c.width*a:null,halfWidth:this.size.width/2,halfDepth:this.size.depth/2},c.weight*f,this.world)}return o.local.copy(i.matrixWorld).invert().multiply(this.world).multiply(this.toForearm).decompose(this.forearm.position,this.forearm.quaternion,this.forearm.scale),this.forearm.updateMatrixWorld(!0),this.world}}const Fe=e=>{const t=e.bones.wrist;if(!t)return null;const n=t.getObjectByName(Ct);if(n)return n;const s=new u.Bone;return s.name=Ct,t.add(s),s},Yt=y.createContext(null),It="vincenttHandRigModelMesh",Nt=y.createContext(null),In=new u.Matrix4,Bt=new u.Matrix4,Ve=({hand:e,model:t,modelHand:n="right",smoothing:s=wt.LANDMARK_POSE_FIT_DEFAULT_SMOOTHING,fingerLengths:i="tracked",showHeld:o=!0,onTrackingChange:r,material:c,onModel:l,active:h=!0,armMask:a,children:f})=>{const{node:d}=At.useXRModel(W.XRModel.HAND_TRACKER,void 0,h),g=jt.useXRMirrored(),{camera:x,size:E}=it.useThree(),m=a?typeof a=="string"?{kind:a}:a:null,T=m?m.kind??"skin":!1,N=Se(T),k=y.useMemo(()=>T?{tracker:new ve,turn:!0,fitWidth:!0,mask:null}:null,[T]);k&&m&&(k.mask=N,k.turn=m.turn??!0,k.fitWidth=m.fitWidth??!0,k.tracker.settings={...Kt,...ue(m,Nn)});const Q=y.useRef({});Q.current=m?ue(m,Hn):{};const I=y.useRef(null),P=y.useMemo(()=>{const R=wn.clone(t);return R.traverse(A=>{A.frustumCulled=!1,A instanceof u.Mesh&&(A.userData[It]=!0)}),R},[t]),B=y.useMemo(()=>F.bindHandRig(P,n),[P,n]),z=y.useMemo(()=>new He(B,Fe(B)),[B]);z.arm=k;const Y=y.useRef(1);Y.current=E.width/Math.max(1,E.height);const et=it.useThree(R=>R.scene);y.useEffect(()=>wt.addSceneBeforeRender(et,(R,A,U)=>z.solve(U,Y.current)),[et,z]);const L=y.useMemo(()=>F.handRigSnapDistance(B),[B]),nt=y.useRef(l);nt.current=l,y.useEffect(()=>{var R;return(R=nt.current)==null?void 0:R.call(nt,P)},[P]);const ht=y.useMemo(()=>{const R=new Map;return P.traverse(A=>{A instanceof u.Mesh&&R.set(A,A.material)}),R},[P]);y.useEffect(()=>{for(const[R,A]of ht)R.material=c??A},[c,ht]);const C=y.useRef(void 0),O=y.useRef({tracked:!1,quaternion:new u.Quaternion,position:new u.Vector3,scale:1,mirrored:!1}),w=y.useRef({}),b=y.useRef({}),V=y.useRef({});return it.useFrame(()=>{var ie,oe,re;const R=I.current;if(!R)return;const A=((ie=d==null?void 0:d.getHandPose)==null?void 0:ie.call(d,e))??((oe=d==null?void 0:d.poses)==null?void 0:oe[e])??null,U=A&&A.world.length>=21&&A.image.length>=21&&(o||!A.held),H=O.current;if(z.tick(A==null?void 0:A.timestampMs),!U){R.visible=!1,z.reset(),k==null||k.tracker.reset(),wt.stepLandmarkPoseSmoothing(H,null,s,L)&&(r==null||r(!1));return}if(k){const G=performance.now();k.tracker.pushHand(A.timestampMs,we(A,E.width/Math.max(1,E.height))),N!=null&&N.refresh(G)&&k.tracker.measure(N,N.timestampMs,Q.current),k.tracker.step(G)}const _=F.solveHandRig(B,A,x,g,C.current);C.current=_,H.tracked&&H.mirrored!==_.mirrored&&(H.tracked=!1);const M=wt.stepLandmarkPoseSmoothing(H,_.fit,s,L);H.mirrored=_.mirrored,M&&(r==null||r(!0));const D=u.MathUtils.clamp(s,.01,1),Z=Math.min(D,.1),dt=b.current;for(const{name:G}of F.HAND_RIG_BONES){const pt=_.local[G],lt=B.bones[G];if(!pt||!lt)continue;const ft=(re=w.current)[G]??(re[G]=pt.clone());M||D>=1?ft.copy(pt):ft.slerp(pt,D),lt.quaternion.copy(ft);const ce=i==="tracked"?_.lengths[G]??1:1,Vt=dt[G];dt[G]=M||Vt===void 0?ce:Vt+(ce-Vt)*Z}const Ot=V.current;for(const{name:G,parent:pt}of F.HAND_RIG_BONES){if(pt!=="wrist")continue;const lt=_.knuckles[G];if(!lt)continue;const ft=Ot[G]??(Ot[G]=lt.clone());M?ft.copy(lt):ft.lerp(lt,Z)}F.applyHandRigLengths(B,dt,i==="tracked"?Ot:null),F.handRigRootMatrix({scale:H.scale,quaternion:H.quaternion,translation:H.position},H.mirrored,Bt),R.parent&&(R.parent.updateMatrixWorld(),Bt.premultiply(In.copy(R.parent.matrixWorld).invert())),R.matrix.copy(Bt),R.matrixWorldNeedsUpdate=!0,R.visible=!0}),J.jsx(Nt.Provider,{value:B,children:J.jsxs(Yt.Provider,{value:z,children:[J.jsx("group",{ref:I,matrixAutoUpdate:!1,visible:!1,children:J.jsx("primitive",{object:P})}),f]})})},Nn=["smoothing","holdMs","fadeMs","maxSkewMs","maxShift"],Hn=["along","widthAt","maxWidth","minWidth","maxTurn"],ue=(e,t)=>Object.fromEntries(t.filter(n=>e[n]!==void 0).map(n=>[n,e[n]])),Be=({along:e=1,offset:t,children:n})=>{const s=y.useContext(Nt),i=y.useContext(Yt),o=it.useThree(g=>g.scene),r=it.useThree(g=>g.size),c=y.useRef(null),l=y.useMemo(()=>s?Jt(s):null,[s]),h=y.useRef(1);h.current=r.width/Math.max(1,r.height),y.useEffect(()=>{if(!i)return;const g=new u.Matrix4;return wt.addSceneBeforeRender(o,(x,E,m)=>{const T=c.current;if(!T)return;i.solve(m,h.current);const N=i.crossScale;T.matrix.multiplyMatrices(i.forearmFrame,g.makeScale(N,1,N)),T.matrixWorldNeedsUpdate=!0,T.updateMatrixWorld(!0)})},[i,o]);const a=!s;if(y.useEffect(()=>{a&&console.warn(`${W.libConfig.loggerPrefix} WristAttachment must be inside a HandRig or HandOccluder`)},[a]),!s||!l||!i)return null;const f=i.forearm,d=(t==null?void 0:t.position)??[0,0,0];return it.createPortal(J.jsx("group",{ref:c,matrixAutoUpdate:!1,children:J.jsx("group",{position:[d[0],d[1]-e,d[2]],rotation:(t==null?void 0:t.rotation)??[0,0,0],scale:(t==null?void 0:t.scale)??1,children:typeof n=="function"?n(l):n})}),f)},Fn=-1,We=(e,{length:t=Re,scale:n=1}={})=>{const s=e.palmLength*t,i=e.palmLength*De,o=e.width/2*n,r=new u.CylinderGeometry(o,o*ke,s+i,24,1,!1);return r.translate(0,(i-s)/2,0),r.scale(1,1,e.depth/e.width),r},Pe=({length:e,scale:t,showDebugMaterial:n=!1,opacity:s=.5})=>{const i=y.useMemo(()=>new u.MeshBasicMaterial({color:13948120,colorWrite:!1,depthWrite:!0,side:u.DoubleSide}),[]);return y.useEffect(()=>()=>i.dispose(),[i]),y.useEffect(()=>{i.colorWrite=n,i.transparent=n,i.opacity=n?s:1,i.needsUpdate=!0},[i,n,s]),J.jsx(Be,{along:0,children:o=>J.jsx(Vn,{wrist:o,length:e,scale:t,material:i})})},Vn=({wrist:e,length:t,scale:n,material:s})=>{const i=y.useMemo(()=>We(e,{length:t,scale:n}),[e,t,n]);return y.useEffect(()=>()=>i.dispose(),[i]),J.jsx("mesh",{name:"ForearmOccluder",geometry:i,material:s,renderOrder:Fn,frustumCulled:!1})},je=-1,Wt="void main() {",Ut="#include <skinning_vertex>",Bn=[Ut,"#ifdef USE_SKINNING"," transformed += normalize( objectNormal ) * inflate;","#endif"].join(`
|
|
2
|
+
`),Ce=e=>!e.includes(Wt)||!e.includes(Ut)?e:e.replace(Wt,`uniform float inflate;
|
|
3
|
+
${Wt}`).replace(Ut,Bn),Ue=()=>{const e=new u.MeshBasicMaterial({color:13948120,colorWrite:!1,depthWrite:!0,side:u.FrontSide}),t={value:0};return e.userData.inflate=t,e.onBeforeCompile=n=>{n.uniforms.inflate=t,n.vertexShader=Ce(n.vertexShader)},e.customProgramCacheKey=()=>"vincentt-hand-occluder",e},Wn=({inflate:e=0,showDebugMaterial:t=!1,opacity:n=.5,onModel:s,forearm:i=!1,children:o,...r})=>{const c=y.useMemo(()=>Ue(),[]);y.useEffect(()=>()=>c.dispose(),[c]),y.useEffect(()=>{c.colorWrite=t,c.transparent=t,c.opacity=t?n:1,c.needsUpdate=!0},[c,t,n]),y.useEffect(()=>{c.userData.inflate.value=e},[c,e]);const l=y.useCallback(h=>{h.traverse(a=>{a instanceof u.Mesh&&a.userData[It]&&(a.renderOrder=je)}),s==null||s(h)},[s]);return J.jsxs(Ve,{...r,material:c,onModel:l,children:[i&&J.jsx(Pe,{...i===!0?{}:i,showDebugMaterial:t,opacity:n}),o]})},qe=.55,Le=1,ze=[.1,.4],he=["indexMcp","middleMcp","ringMcp","pinkyMcp"],Ke=(e,t)=>{const n=h=>e.restPositions[W.HAND_JOINT_INDEX[h]],s=new u.Vector3;for(const h of he)s.add(n(h));s.multiplyScalar(1/he.length);const i=new u.Vector3().addVectors(n("wrist"),s).multiplyScalar(.5),o=e.restPalmNormal.clone().normalize();t==="back"&&o.negate();const r=s.clone().sub(n("wrist"));r.addScaledVector(o,-r.dot(o)).normalize();const c=new u.Vector3().crossVectors(r,o).normalize(),l=Math.sign(n("thumbCmc").clone().sub(i).dot(c))||1;return{origin:i,normal:o,up:r,right:c,thumb:c.clone().multiplyScalar(l),palm:n("middleMcp").distanceTo(n("wrist"))}},Pn={basis:new u.Matrix4,shift:new u.Matrix4,centre:new u.Vector3},Ge=(e,t,{size:n,offset:s},i=new u.Matrix4)=>{const{basis:o,shift:r,centre:c}=Pn;c.copy(e.origin).addScaledVector(e.thumb,(s==null?void 0:s[0])??0).addScaledVector(e.up,(s==null?void 0:s[1])??0),o.makeBasis(e.right,e.up,e.normal).transpose(),r.makeTranslation(-c.x,-c.y,-c.z);const l=1/Math.max(n,1e-9);return i.makeScale(l,l,l).multiply(o).multiply(r).multiply(t)},jn=new u.Matrix4,de=(e,t,n)=>{n.identity();for(let s=e;s&&s!==t;s=s.parent)s.updateMatrix(),n.premultiply(s.matrix);return n},Je=(e,t,n=new u.Matrix4)=>{const s=t,i=e.bones.wrist,o=s.isSkinnedMesh&&i?s.skeleton.bones.indexOf(i):-1;return o<0?de(t,e.root,n):(de(i,e.root,n),n.multiply(jn.copy(s.skeleton.boneInverses[o])).multiply(s.bindMatrix))},Cn=(e,{rotation:t=0,aspect:n=1,mirrored:s=!1}={},i=new u.Vector2)=>{if(e.z<0)return null;const o=s?-e.x:e.x,r=Math.cos(t),c=Math.sin(t),l=r*o+c*e.y+.5,h=(-c*o+r*e.y)*n+.5;return l<0||l>1||h<0||h>1?null:i.set(l,h)},Un=`
|
|
4
|
+
#include <common>
|
|
5
|
+
#include <skinning_pars_vertex>
|
|
6
|
+
#include <logdepthbuf_pars_vertex>
|
|
7
|
+
uniform mat4 decalMatrix;
|
|
8
|
+
varying vec3 vDecal;
|
|
9
|
+
varying float vFacing;
|
|
10
|
+
varying float vMirror;
|
|
11
|
+
void main() {
|
|
12
|
+
// Decal space from the REST surface (before skinning): the art deforms with the skin.
|
|
13
|
+
vDecal = ( decalMatrix * vec4( position, 1.0 ) ).xyz;
|
|
14
|
+
vFacing = normalize( mat3( decalMatrix ) * normal ).z;
|
|
15
|
+
// A mirrored hand (the model's other chirality): the art is flipped back.
|
|
16
|
+
vMirror = determinant( mat3( modelMatrix ) ) < 0.0 ? 1.0 : 0.0;
|
|
17
|
+
#include <begin_vertex>
|
|
18
|
+
#include <skinbase_vertex>
|
|
19
|
+
#include <skinning_vertex>
|
|
20
|
+
#include <project_vertex>
|
|
21
|
+
#include <logdepthbuf_vertex>
|
|
22
|
+
}
|
|
23
|
+
`,qn=`
|
|
24
|
+
#include <common>
|
|
25
|
+
#include <logdepthbuf_pars_fragment>
|
|
26
|
+
uniform sampler2D map;
|
|
27
|
+
uniform float opacity;
|
|
28
|
+
uniform vec2 turn;
|
|
29
|
+
uniform float aspect;
|
|
30
|
+
uniform vec2 fade;
|
|
31
|
+
varying vec3 vDecal;
|
|
32
|
+
varying float vFacing;
|
|
33
|
+
varying float vMirror;
|
|
34
|
+
void main() {
|
|
35
|
+
#include <logdepthbuf_fragment>
|
|
36
|
+
if ( vDecal.z < 0.0 ) discard;
|
|
37
|
+
vec2 p = vDecal.xy;
|
|
38
|
+
if ( vMirror > 0.5 ) p.x = -p.x;
|
|
39
|
+
vec2 uv = vec2( turn.x * p.x + turn.y * p.y, ( -turn.y * p.x + turn.x * p.y ) * aspect ) + 0.5;
|
|
40
|
+
if ( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 ) discard;
|
|
41
|
+
vec4 art = texture2D( map, uv );
|
|
42
|
+
float a = art.a * opacity * smoothstep( fade.x, fade.y, vFacing );
|
|
43
|
+
if ( a < 0.002 ) discard;
|
|
44
|
+
gl_FragColor = vec4( art.rgb, 1.0 );
|
|
45
|
+
#include <colorspace_fragment>
|
|
46
|
+
// Premultiplied: the blend factors (setHandTattooBlend) mix by alpha.
|
|
47
|
+
gl_FragColor = vec4( gl_FragColor.rgb * a, a );
|
|
48
|
+
}
|
|
49
|
+
`,Xt=(e,t)=>{e.blending=u.CustomBlending,e.blendEquation=u.AddEquation,e.blendEquationAlpha=u.AddEquation,t==="multiply"?(e.blendSrc=u.DstColorFactor,e.blendDst=u.OneMinusSrcAlphaFactor,e.blendSrcAlpha=u.ZeroFactor,e.blendDstAlpha=u.OneFactor):(e.blendSrc=u.OneFactor,e.blendDst=u.OneMinusSrcAlphaFactor,e.blendSrcAlpha=u.OneFactor,e.blendDstAlpha=u.OneMinusSrcAlphaFactor)},Ye=(e="multiply")=>{const t=new u.ShaderMaterial({uniforms:{map:{value:null},decalMatrix:{value:new u.Matrix4},opacity:{value:1},turn:{value:new u.Vector2(1,0)},aspect:{value:1},fade:{value:new u.Vector2(...ze)}},vertexShader:Un,fragmentShader:qn,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1,toneMapped:!1});return Xt(t,e),t},Ln=e=>{const[t,n]=y.useState(null),s=typeof e=="string"?e:null;return y.useEffect(()=>{if(!s)return;let i=!0,o=null;return new u.TextureLoader().load(s,r=>{if(o=r,!i){r.dispose();return}r.colorSpace=u.SRGBColorSpace,n({url:s,texture:r})},void 0,()=>console.warn(`${W.libConfig.loggerPrefix} HandTattoo could not load ${s}`)),()=>{i=!1,o==null||o.dispose()}},[s]),typeof e!="string"?e:(t==null?void 0:t.url)===e?t.texture:null},zn=e=>{const t=e.image;return t!=null&&t.width&&(t!=null&&t.height)?t.width/t.height:1},Kn=({src:e,placement:t="back",size:n,offset:s,rotation:i=0,opacity:o=.9,blend:r="multiply",renderOrder:c=Le})=>{const l=y.useContext(Nt),h=Ln(e),a=y.useMemo(()=>{if(!l)return[];const E=[];return l.root.traverse(m=>{m instanceof u.Mesh&&m.userData[It]&&E.push(m)}),E.map(m=>{const T=Ye(),N=m;let k;if(N.isSkinnedMesh){const Q=new u.SkinnedMesh(m.geometry,T);Q.bindMode=N.bindMode,Q.bind(N.skeleton,N.bindMatrix),k=Q}else k=new u.Mesh(m.geometry,T);return k.name=`${m.name}_tattoo`,k.frustumCulled=!1,k.position.copy(m.position),k.quaternion.copy(m.quaternion),k.scale.copy(m.scale),{mesh:k,source:m,material:T,geometryToRoot:Je(l,m)}})},[l]);y.useEffect(()=>{var E;for(const{mesh:m,source:T}of a)(E=T.parent)==null||E.add(m);return()=>{for(const{mesh:m,material:T}of a)m.removeFromParent(),T.dispose()}},[a]);const f=y.useMemo(()=>l?Ke(l,t):null,[l,t]),d=(s==null?void 0:s[0])??0,g=(s==null?void 0:s[1])??0;y.useEffect(()=>{if(!f)return;const E=n??qe*f.palm;for(const{mesh:m,material:T,geometryToRoot:N}of a){const k=T.uniforms;Ge(f,N,{size:E,offset:[d,g]},k.decalMatrix.value),k.map.value=h,k.opacity.value=u.MathUtils.clamp(o,0,1),k.turn.value.set(Math.cos(i),Math.sin(i)),k.aspect.value=h?zn(h):1,Xt(T,r),m.renderOrder=c,m.visible=!!h}},[a,f,h,n,d,g,i,o,r,c]);const x=!l;return y.useEffect(()=>{x&&console.warn(`${W.libConfig.loggerPrefix} HandTattoo must be inside a HandRig or HandOccluder`)},[x]),null},Mt=["thumbTip","indexTip","middleTip","ringTip","pinkyTip"],$t=Object.freeze({palmRadius:.5,tipRadius:.12,pinchStart:.3,pinchEnd:.45,pinchReady:.6,smoothing:.6}),Gn=100,Jn=8,Yn=.05,pe=()=>({center:new u.Vector3,velocity:new u.Vector3,radius:0}),Et=e=>({hand:e,tracked:!1,palmLength:0,palm:pe(),tips:Object.fromEntries(Mt.map(t=>[t,pe()])),pinchDistance:1/0,pinching:!1,pinch:new u.Vector3,pinchVelocity:new u.Vector3,timeMs:null,history:[]}),rt={palm:new u.Vector3,knuckles:new u.Vector3,previous:new u.Vector3,raw:new u.Vector3},Rt=(e,t,n,s,i,o)=>{if(e.radius=n,s||o<=0){e.center.copy(t),e.velocity.set(0,0,0);return}rt.previous.copy(e.center),e.center.lerp(t,i),rt.raw.subVectors(e.center,rt.previous).divideScalar(o),e.velocity.lerp(rt.raw,1-Math.exp(-o/Yn))},Xe=(e,t)=>{const{history:n}=e;for(n.length>=Jn&&n.shift(),n.push({timeMs:t,point:e.pinch.clone()});n.length>2&&t-n[1].timeMs>=Gn;)n.shift();const s=n[0],i=(t-s.timeMs)/1e3;i>0?e.pinchVelocity.subVectors(e.pinch,s.point).divideScalar(i):e.pinchVelocity.set(0,0,0)},$e=e=>(e.tracked=!1,e.pinching=!1,e.pinchDistance=1/0,e.timeMs=null,e.history.length=0,e.pinchVelocity.set(0,0,0),e),qt=(e,t,n,s={})=>{const i={...$t,...s};if(!t||t.length<21)return $e(e);if(e.tracked&&e.timeMs===n)return e;const o=!e.tracked||e.timeMs===null,r=o?0:Math.max(0,(n-e.timeMs)/1e3),c=u.MathUtils.clamp(i.smoothing,.01,1),l=d=>t[W.HAND_JOINT_INDEX[d]],h=l("wrist").distanceTo(l("middleMcp"));e.palmLength=o?h:e.palmLength+(h-e.palmLength)*c,rt.knuckles.copy(l("indexMcp")).add(l("middleMcp")).add(l("ringMcp")).add(l("pinkyMcp")).multiplyScalar(.25),rt.palm.copy(l("wrist")).add(rt.knuckles).multiplyScalar(.5),Rt(e.palm,rt.palm,e.palmLength*i.palmRadius,o,c,r);for(const d of Mt)Rt(e.tips[d],l(d),e.palmLength*i.tipRadius,o,c,r);const a=e.tips.thumbTip.center,f=e.tips.indexTip.center;return e.pinchDistance=a.distanceTo(f)/Math.max(e.palmLength,1e-9),e.pinching?e.pinching=e.pinchDistance<=i.pinchEnd:e.pinching=e.pinchDistance<i.pinchStart,e.pinch.addVectors(a,f).multiplyScalar(.5),Xe(e,n),e.tracked=!0,e.timeMs=n,e},Qe=(e,t,n,s,i)=>{if(!t)return $e(e);const o=!e.tracked||e.timeMs===null,r=o?0:Math.max(0,(s-e.timeMs)/1e3);if(!o&&r===0)return e;e.palmLength=i,Rt(e.palm,t,i,o,1,r);for(const c of Mt)Rt(e.tips[c],t,0,o,1,r);return e.pinchDistance=n?0:1/0,e.pinching=n,e.pinch.copy(t),Xe(e,s),e.tracked=!0,e.timeMs=s,e},Qt=Object.freeze({gravity:9,damping:.4,bounce:.5,friction:4,grabReach:.35,hoverReach:.5,tapMs:350,tapSpeed:1,throwScale:1,maxSpeed:14,flat:!0}),Xn=1/120,$n=1/20,Qn=.35,Zn=.5,ts=1.08,es=1.2,Tt=new u.Vector3(0,1,0),fe=[new u.Vector3(1,0,0),new u.Vector3(0,1,0),new u.Vector3(0,0,1)],ns=["x","y","z"],S={d:new u.Vector3,n:new u.Vector3,v:new u.Vector3,t:new u.Vector3,q:new u.Quaternion,q2:new u.Quaternion,axis:new u.Vector3},ss=e=>[["palm",e.palm],...Mt.map(t=>[t,e.tips[t]])];class Ze{constructor(t={},n={}){v(this,"bodies",[]);v(this,"bounds",new u.Box3(new u.Vector3(-2,-2,-1),new u.Vector3(2,2,1)));v(this,"settings");v(this,"timeMs",0);v(this,"nextId",1);v(this,"pinched",new Map);v(this,"press",null);v(this,"handSettings");this.settings={...Qt,...t},this.handSettings=n}setHandSettings(t){this.handSettings=t}add(t={}){const n=Math.max(1e-4,t.size??.4),s={id:this.nextId,shape:t.shape??"sphere",size:n,radius:n/2,mass:Math.max(1e-6,t.mass??n**3),bounce:t.bounce,grabbable:t.grabbable??!0,pushable:t.pushable??!0,gravity:t.gravity??!0,position:new u.Vector3(...t.position??[0,0,0]),velocity:new u.Vector3(...t.velocity??[0,0,0]),quaternion:new u.Quaternion,spin:new u.Vector3,grabbedBy:null,hoveredBy:null,resting:!1,userData:{},grabOffset:new u.Vector3,contacts:new Set,tapStart:{}};return this.nextId+=1,this.bodies.push(s),s}remove(t){const n=this.bodies.indexOf(t);n>=0&&this.bodies.splice(n,1)}pick(t,n,s=!1){let i=null,o=1/0;for(const r of this.bodies){if(!r.grabbable&&!s)continue;const c=this.distance(r.position,t)-r.radius;c<=n&&c<o&&(i=r,o=c)}return i}step(t,n){const s=[],i=u.MathUtils.clamp(t,0,$n);this.timeMs+=i*1e3;const o=new Map;for(const l of n)l.tracked&&o.set(l.hand,l);this.grabAndRelease(n,o,s);const r=new Map,c=Math.max(1,Math.ceil(i/Xn-1e-9));for(let l=0;l<c;l+=1)this.substep(i/c,o,r);for(const l of this.bodies){const h=r.get(l);for(const[a,f]of h??[]){if(l.contacts.has(a))continue;const[d,g]=a.split(":");s.push({type:"touch",body:l,hand:d,part:g,speed:f})}l.contacts=new Set((h==null?void 0:h.keys())??[])}return this.hoverAndTap(o,s),s}reach(t,n){return t.hand==="pointer"?t.palm.radius:t.palmLength*n}distance(t,n){return this.settings.flat?Math.hypot(t.x-n.x,t.y-n.y):t.distanceTo(n)}release(t,n,s){const i=t.grabbedBy;t.grabbedBy=null,n&&t.velocity.copy(n.pinchVelocity).multiplyScalar(this.settings.throwScale),t.velocity.clampLength(0,this.settings.maxSpeed),s.push({type:"release",body:t,hand:i,speed:t.velocity.length()})}grabAndRelease(t,n,s){for(const i of this.bodies)if(i.grabbedBy&&!n.has(i.grabbedBy)){const o=t.find(r=>r.hand===i.grabbedBy);this.release(i,o,s)}for(const i of t){const o=i.tracked&&i.pinching,r=this.pinched.get(i.hand)??!1,c=this.bodies.find(l=>l.grabbedBy===i.hand);if(o&&!r&&!c){const l=this.pick(i.pinch,this.reach(i,this.settings.grabReach));l&&(l.grabbedBy&&s.push({type:"release",body:l,hand:l.grabbedBy,speed:0}),l.grabbedBy=i.hand,l.grabOffset.subVectors(l.position,i.pinch).clampLength(0,l.radius),s.push({type:"grab",body:l,hand:i.hand}))}else!o&&c&&this.release(c,i,s);i.hand==="pointer"&&this.clickTap(i,o,r,s),this.pinched.set(i.hand,o)}}substep(t,n,s){const i=this.settings;for(const o of this.bodies){const r=o.grabbedBy?n.get(o.grabbedBy):void 0;r?(S.t.addVectors(r.pinch,o.grabOffset),o.position.lerp(S.t,1-Math.exp(-30*t)),o.velocity.copy(r.pinchVelocity),o.spin.multiplyScalar(Math.exp(-4*t))):(o.gravity&&(o.velocity.y-=i.gravity*t),o.velocity.multiplyScalar(Math.exp(-i.damping*t)),o.velocity.clampLength(0,i.maxSpeed),o.spin.multiplyScalar(Math.exp(-i.damping*t)),o.position.addScaledVector(o.velocity,t)),this.turn(o,t),this.walls(o,t,!!r)}this.collideBodies(n),this.collideHands(n,s)}turn(t,n){const s=t.spin.length()*n;s<1e-9||(S.axis.copy(t.spin).normalize(),S.q.setFromAxisAngle(S.axis,s),t.quaternion.premultiply(S.q).normalize())}walls(t,n,s){const i=this.settings,{min:o,max:r}=this.bounds,c=t.bounce??i.bounce;let l=!1;for(const a of ns){const f=o[a]+t.radius,d=Math.max(f,r[a]-t.radius);t.position[a]<f?(t.position[a]=f,t.velocity[a]<0&&(t.velocity[a]=s?0:-t.velocity[a]*c),a==="y"&&(l=!0)):t.position[a]>d&&(t.position[a]=d,t.velocity[a]>0&&(t.velocity[a]=s?0:-t.velocity[a]*c))}if(s){t.resting=!1;return}if(!l&&t.position.y-(o.y+t.radius)<1e-4&&t.velocity.y<=0&&(l=!0),!l){t.resting=!1;return}Math.abs(t.velocity.y)<Qn&&(t.velocity.y=0);const h=Math.exp(-i.friction*n);t.velocity.x*=h,t.velocity.z*=h,t.shape==="sphere"?t.spin.crossVectors(Tt,t.velocity).divideScalar(t.radius):(t.spin.multiplyScalar(Math.exp(-10*n)),this.settleFlat(t,n)),t.resting=t.velocity.lengthSq()<.05*.05}settleFlat(t,n){let s=0,i=0;fe.forEach((o,r)=>{const c=S.v.copy(o).applyQuaternion(t.quaternion).y;Math.abs(c)>Math.abs(i)&&(s=r,i=c)}),S.v.copy(fe[s]).applyQuaternion(t.quaternion).multiplyScalar(Math.sign(i)||1),S.q2.setFromUnitVectors(S.v,Tt).multiply(t.quaternion),t.quaternion.slerp(S.q2,1-Math.exp(-10*n))}collideBodies(t){const{bodies:n}=this;for(let s=0;s<n.length;s+=1)for(let i=s+1;i<n.length;i+=1){const o=n[s],r=n[i];S.d.subVectors(r.position,o.position);const c=S.d.length(),l=o.radius+r.radius;if(c>=l)continue;const h=o.grabbedBy&&t.has(o.grabbedBy)?0:1/o.mass,a=r.grabbedBy&&t.has(r.grabbedBy)?0:1/r.mass;if(h+a===0)continue;c>1e-9?S.n.copy(S.d).divideScalar(c):S.n.copy(Tt);const f=(l-c)/(h+a);o.position.addScaledVector(S.n,-f*h),r.position.addScaledVector(S.n,f*a);const d=S.v.subVectors(r.velocity,o.velocity).dot(S.n);if(d>=0)continue;const x=-(1+Math.min(o.bounce??this.settings.bounce,r.bounce??this.settings.bounce))*d/(h+a);o.velocity.addScaledVector(S.n,-x*h),r.velocity.addScaledVector(S.n,x*a)}}collideHands(t,n){const s=this.settings,i=this.handSettings.pinchReady??$t.pinchReady;for(const o of t.values()){if(o.hand==="pointer"&&!o.pinching)continue;const r=o.pinchDistance<i;for(const[c,l]of ss(o))if(!(l.radius<=0||r&&(c==="thumbTip"||c==="indexTip")))for(const h of this.bodies){if(!h.pushable||h.grabbedBy)continue;S.d.subVectors(h.position,l.center),s.flat&&(S.d.z=0);const a=S.d.length(),f=h.radius+l.radius;if(a>=f)continue;a>1e-9?S.n.copy(S.d).divideScalar(a):S.n.copy(Tt),h.position.addScaledVector(S.n,f-a),S.v.subVectors(h.velocity,l.velocity);const d=S.v.dot(S.n);d<0&&(h.velocity.addScaledVector(S.n,-(1+(h.bounce??s.bounce))*d),h.velocity.clampLength(0,s.maxSpeed)),S.t.copy(S.v).addScaledVector(S.n,-S.v.dot(S.n)).negate(),S.axis.crossVectors(S.n,S.t).divideScalar(-h.radius),h.spin.lerp(S.axis,Zn);const g=`${o.hand}:${c}`,x=n.get(h)??new Map;x.set(g,Math.max(x.get(g)??0,Math.max(0,-d))),n.set(h,x)}}}clickTap(t,n,s,i){const o=this.reach(t,this.settings.grabReach);if(n&&!s){const r=this.pick(t.pinch,o,!0);this.press=r?{body:r,timeMs:this.timeMs}:null}else if(!n&&s&&this.press){const{body:r,timeMs:c}=this.press;this.press=null,this.distance(r.position,t.pinch)-r.radius<=o&&this.timeMs-c<=this.settings.tapMs&&this.bodies.includes(r)&&i.push({type:"tap",body:r,hand:t.hand})}}hoverAndTap(t,n){const s=this.settings;for(const i of this.bodies){let o=null;for(const r of t.values()){const c=r.tips.indexTip,l=this.distance(i.position,c.center)-i.radius;if(l<=this.reach(r,s.hoverReach)&&!i.grabbedBy&&(o===null||i.hoveredBy===r.hand)&&(o=r.hand),r.hand==="pointer")continue;const a=(i.radius+c.radius)*ts,f=(i.radius+c.radius)*es,d=l+i.radius,g=i.tapStart[r.hand];if(g===void 0&&d<a&&!i.grabbedBy){S.d.subVectors(i.position,c.center),s.flat&&(S.d.z=0);const x=c.velocity.dot(S.d.normalize());i.tapStart[r.hand]=x>=s.tapSpeed*r.palmLength?this.timeMs:NaN}else g!==void 0&&(d>f||i.grabbedBy)&&(delete i.tapStart[r.hand],!i.grabbedBy&&this.timeMs-g<=s.tapMs&&n.push({type:"tap",body:i,hand:r.hand}))}for(const r of Object.keys(i.tapStart))t.has(r)||delete i.tapStart[r];o!==i.hoveredBy&&(i.hoveredBy&&n.push({type:"hoverend",body:i,hand:i.hoveredBy}),o&&n.push({type:"hoverstart",body:i,hand:o}),i.hoveredBy=o)}}}const tn=.15,en=.6,Zt=y.createContext(null),is=()=>y.useContext(Zt),os=["left","right"],rs=new u.Vector3(1,1,1),cs=({hands:e="both",pointer:t=!1,depth:n=en,floor:s=0,bounds:i,showColliders:o=!1,onEvent:r,paused:c=!1,active:l=!0,children:h,palmRadius:a,tipRadius:f,pinchStart:d,pinchEnd:g,pinchReady:x,smoothing:E,...m})=>{const{node:T}=At.useXRModel(W.XRModel.HAND_TRACKER,void 0,l),N=it.useThree(w=>w.camera),k=it.useThree(w=>w.gl),Q=Object.fromEntries(Object.entries({palmRadius:a,tipRadius:f,pinchStart:d,pinchEnd:g,pinchReady:x,smoothing:E}).filter(([,w])=>w!==void 0)),I=y.useMemo(()=>new Ze,[]);I.settings={...Qt,...ls(m)},I.setHandSettings(Q);const P=y.useRef(Q);P.current=Q;const B=y.useMemo(()=>({left:Et("left"),right:Et("right"),pointer:Et("pointer")}),[]),z=y.useMemo(()=>({left:W.HAND_JOINT_NAMES.map(()=>new u.Vector3),right:W.HAND_JOINT_NAMES.map(()=>new u.Vector3)}),[]),Y=y.useMemo(()=>new Map,[]),et=y.useRef(r);et.current=r;const L=y.useRef({ndc:null,pressed:!1,clicked:!1,lifted:!1}),nt=!!t,ht=(typeof t=="object"?t.radius:void 0)??tn;y.useEffect(()=>{if(!nt)return;const w=k.domElement,b=L.current,V=w.style.touchAction;w.style.touchAction="none";const R=_=>{const M=w.getBoundingClientRect();b.ndc??(b.ndc=new u.Vector2),b.ndc.set((_.clientX-M.left)/M.width*2-1,1-(_.clientY-M.top)/M.height*2)},A=_=>{R(_),b.pressed=!0,b.clicked=!0,b.lifted=!1},U=()=>{b.pressed=!1},H=_=>{b.pressed=!1,_.type==="pointerup"?_.pointerType!=="mouse"&&(b.lifted=!0):b.ndc=null};return w.addEventListener("pointermove",R),w.addEventListener("pointerdown",A),window.addEventListener("pointerup",U),w.addEventListener("pointerup",H),w.addEventListener("pointerleave",H),w.addEventListener("pointercancel",H),()=>{w.style.touchAction=V,w.removeEventListener("pointermove",R),w.removeEventListener("pointerdown",A),window.removeEventListener("pointerup",U),w.removeEventListener("pointerup",H),w.removeEventListener("pointerleave",H),w.removeEventListener("pointercancel",H),b.ndc=null,b.pressed=!1,b.clicked=!1,b.lifted=!1}},[k,nt]);const C=y.useMemo(()=>({lo:new u.Vector3,hi:new u.Vector3,point:new u.Vector3,matrix:new u.Matrix4,inverse:new u.Matrix4}),[]);it.useFrame((w,b)=>{var R,A,U,H;i?(I.bounds.min.set(...i.min),I.bounds.max.set(...i.max)):(W.trackerToWorld({x:-1,y:-1},N,C.lo),W.trackerToWorld({x:1,y:1},N,C.hi),I.bounds.min.set(Math.min(C.lo.x,C.hi.x),Math.min(C.lo.y,C.hi.y)+s,-n),I.bounds.max.set(Math.max(C.lo.x,C.hi.x),Math.max(C.lo.y,C.hi.y),n));for(const _ of os){const D=e==="both"||e===_?((R=T==null?void 0:T.getHandPose)==null?void 0:R.call(T,_))??((A=T==null?void 0:T.poses)==null?void 0:A[_])??null:null;D&&D.world.length>=21&&D.image.length>=21?(F.handPoseToScene(D,N,z[_]),qt(B[_],z[_],D.timestampMs,P.current)):qt(B[_],null,0)}const V=L.current;if(Qe(B.pointer,nt&&V.ndc?W.trackerToWorld({x:V.ndc.x,y:V.ndc.y},N,C.point):null,V.pressed||V.clicked,performance.now(),ht),V.lifted&&!V.clicked&&(V.ndc=null,V.lifted=!1),V.clicked=!1,!c){const _=I.step(b,[B.left,B.right,B.pointer]);for(const M of _)(U=Y.get(M.body))==null||U.onEvent.current(M),(H=et.current)==null||H.call(et,M)}for(const[_,{object:M}]of Y)C.matrix.compose(_.position,_.quaternion,rs),M.parent&&C.matrix.premultiply(C.inverse.copy(M.parent.matrixWorld).invert()),C.matrix.decompose(M.position,M.quaternion,C.point)});const O=y.useMemo(()=>({world:I,hands:[B.left,B.right,B.pointer],register:(w,b)=>(Y.set(w,b),()=>{Y.delete(w)})}),[I,B,Y]);return J.jsxs(Zt.Provider,{value:O,children:[h,o&&J.jsx(as,{hands:O.hands})]})},ls=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),as=({hands:e})=>{const t=y.useMemo(()=>e.flatMap(o=>[{hand:o,sphere:o.palm},...Mt.map(r=>({hand:o,sphere:o.tips[r]}))]),[e]),n=y.useMemo(()=>new u.SphereGeometry(1,20,12),[]),s=y.useMemo(()=>({open:new u.MeshBasicMaterial({color:8246268,transparent:!0,opacity:.35,depthWrite:!1}),pinch:new u.MeshBasicMaterial({color:16020150,transparent:!0,opacity:.5,depthWrite:!1})}),[]);y.useEffect(()=>()=>{n.dispose(),s.open.dispose(),s.pinch.dispose()},[n,s]);const i=y.useRef([]);return it.useFrame(()=>{t.forEach(({hand:o,sphere:r},c)=>{const l=i.current[c];l&&(l.visible=o.tracked&&r.radius>0,l.position.copy(r.center),l.scale.setScalar(Math.max(r.radius,1e-6)),l.material=o.pinching?s.pinch:s.open)})}),J.jsx("group",{name:"HandTouchColliders",children:t.map((o,r)=>J.jsx("mesh",{ref:c=>{i.current[r]=c},geometry:n,material:s.open,renderOrder:10,frustumCulled:!1,visible:!1},r))})},ot=e=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):0,gt=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),q={wrist:0,thumbTip:4,indexBase:5,indexTip:8,middleBase:9,middleTip:12,ringBase:13,ringTip:16,pinkyBase:17,pinkyTip:20},kt=[[q.indexBase,q.indexTip],[q.middleBase,q.middleTip],[q.ringBase,q.ringTip],[q.pinkyBase,q.pinkyTip]],ut=e=>e!==void 0&&e.length>=21,te=e=>ut(e)?gt(e[q.wrist],e[q.middleBase]):0,us=e=>{if(!ut(e))return 0;const t=te(e);if(t<=0)return 0;const n=gt(e[q.thumbTip],e[q.indexTip])/t;return ot(1-(n-.15)/.85)},nn=(e,t,n)=>{const s=e[q.wrist],i=gt(e[t],s);if(i<=0)return 0;const o=gt(e[n],s)/i;return ot((1.6-o)/.6)},sn=(e,t=[0,0,0,0])=>{for(let n=0;n<kt.length;n+=1){const[s,i]=kt[n];t[n]=1-nn(e,s,i)}return t},ee=e=>{const t=te(e);if(t<=0)return 0;const n=gt(e[q.thumbTip],e[q.indexBase])/t;return ot((n-.45)/.5)},Lt=e=>{const t=te(e);if(t<=0)return 0;const n=(e[q.thumbTip].y-e[q.indexBase].y)/t;return Math.max(-1,Math.min(1,n/.6))},on=(e,t)=>{if(!ut(e))return 0;const n=sn(e);let s=1;for(let i=0;i<4;i+=1){const o=t.fingers[i];o!==null&&(s=Math.min(s,o?n[i]:1-n[i]))}if(t.thumb!==void 0&&t.thumb!==null){const i=ee(e);s=Math.min(s,t.thumb?i:1-i)}return s},hs=(e,t)=>{if(!ut(e))return 0;const n=on(e,{fingers:[!1,!1,!1,!1]}),s=ot(t==="up"?Lt(e):-Lt(e));return Math.min(n,ee(e),s)},rn=e=>{if(!ut(e))return 0;let t=0;for(const[n,s]of kt)t+=nn(e,n,s);return t/kt.length},ds=e=>ut(e)?1-rn(e):0,ps=e=>ut(e)?ot((e[q.wrist].y+1)/2):0,tt={leftShoulder:11,rightShoulder:12,leftElbow:13,rightElbow:14,leftWrist:15,rightWrist:16,leftHip:23,rightHip:24},cn=e=>e!==void 0&&e.length>=33,ln=e=>gt(e[tt.leftShoulder],e[tt.rightShoulder]),fs=(e,t,n=!1)=>{if(!cn(e))return 0;const s=ln(e);if(s<=0)return 0;const i=W.personSide(t,n),o=e[i==="left"?tt.leftWrist:tt.rightWrist],r=e[i==="left"?tt.leftShoulder:tt.rightShoulder];return ot((o.y-r.y)/s)},ms=e=>{if(!cn(e))return 0;const t=ln(e);if(t<=0)return 0;let n=1;for(const s of["left","right"]){const i=e[s==="left"?tt.leftWrist:tt.rightWrist],o=e[s==="left"?tt.leftShoulder:tt.rightShoulder],r=ot(1-Math.abs(i.y-o.y)/(t*.5)),c=s==="left"?i.x-o.x:o.x-i.x,l=ot(c/t);n=Math.min(n,r,l)}return n};class an{constructor(t){v(this,"reversals",[]);v(this,"extreme",null);v(this,"low",0);v(this,"high",0);v(this,"direction",0);this.options=t}reset(){this.reversals=[],this.extreme=null,this.direction=0}push(t,n){const{minAmplitude:s}=this.options;return this.extreme===null?(this.extreme=t,this.low=t,this.high=t,this.direction=0,this.progress(n)):(this.direction===0?t-this.low>=s?(this.direction=1,this.extreme=t):this.high-t>=s?(this.direction=-1,this.extreme=t):(this.low=Math.min(this.low,t),this.high=Math.max(this.high,t)):(this.direction>0?t>this.extreme:t<this.extreme)?this.extreme=t:Math.abs(this.extreme-t)>=s&&(this.reversals.push(n),this.direction=-this.direction,this.extreme=t),this.progress(n))}progress(t){const{requiredReversals:n,windowMs:s}=this.options;for(;this.reversals.length>0&&t-this.reversals[0]>s;)this.reversals.shift();return ot(this.reversals.length/n)}}const un={nose:F.BODY_POSE_JOINTS.nose,leftShoulder:F.BODY_POSE_JOINTS.leftShoulder,rightShoulder:F.BODY_POSE_JOINTS.rightShoulder,leftElbow:F.BODY_POSE_JOINTS.leftElbow,rightElbow:F.BODY_POSE_JOINTS.rightElbow,leftWrist:F.BODY_POSE_JOINTS.leftWrist,rightWrist:F.BODY_POSE_JOINTS.rightWrist,leftIndex:F.BODY_POSE_JOINTS.leftIndex,rightIndex:F.BODY_POSE_JOINTS.rightIndex,leftHip:F.BODY_POSE_JOINTS.leftHip,rightHip:F.BODY_POSE_JOINTS.rightHip,leftKnee:F.BODY_POSE_JOINTS.leftKnee,rightKnee:F.BODY_POSE_JOINTS.rightKnee,leftAnkle:F.BODY_POSE_JOINTS.leftAnkle,rightAnkle:F.BODY_POSE_JOINTS.rightAnkle},gs=Object.keys(un),ys=["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist"],Ms=["leftShoulder","rightShoulder","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],zt=Object.freeze({visible:.2,edge:.12}),ws=(e,{mirrored:t=!1,visibility:n,limits:s,aspect:i=1,view:o}={})=>{if(e.length<F.BODY_LANDMARK_COUNT)throw new Error(`createBodyMoveFrame needs MediaPipe's ${F.BODY_LANDMARK_COUNT} pose landmarks (got ${e.length})`);const r=F.squareLandmarks(e,i),c=F.analyzeBodyShape(r,{mirrored:t,visibility:n,limits:s}),l=(o==null?void 0:o.visible)??zt.visible,h=1+((o==null?void 0:o.edge)??zt.edge),a={},f={},d={};for(const m of gs){const T=un[W.feedSidedName(m,t)],N=e[T];a[m]=r[T],f[m]=(n==null?void 0:n[T])??1,d[m]=f[m]>=l&&Math.abs(N.x)<=h&&Math.abs(N.y)<=h}const g=(a.leftShoulder.y+a.rightShoulder.y)/2,x=(a.leftHip.y+a.rightHip.y)/2,E=a.leftShoulder.x-a.rightShoulder.x;return{shape:c,landmarks:e,joints:a,visibility:f,seen:d,shoulderWidth:c.shoulderWidth,torso:Math.max(0,g-x),leftward:Math.abs(E)>1e-6?E>0?1:-1:t?-1:1,upperInView:ys.every(m=>d[m]),fullInView:Ms.every(m=>d[m]),mirrored:t,aspect:i}},xs=Object.fromEntries(["left","right"].map(e=>[e,Object.fromEntries(["Shoulder","Elbow","Wrist","Index","Hip","Knee","Ankle"].map(t=>[t,`${e}${t}`]))])),j=(e,t)=>xs[e][t],yt=(e,t)=>e.seen[j(t,"Shoulder")]&&e.seen[j(t,"Elbow")]&&e.seen[j(t,"Wrist")],Dt=Object.freeze({jumpRise:.12,jumpLand:.06,jumpMaxAirMs:900,jumpLevelMs:300,squatDown:.6,squatUp:.85,waveForearmUp:.25,waveAmplitude:.3,waveReversals:3,waveWindowMs:1500,clapApart:.6,clapTogether:.3,clapWithinMs:250,clapRelease:.45,punchBent:.75,punchStraight:.93,punchWithinMs:200,punchBand:.9,flapStroke:.7,flapWithinMs:500,flapTop:-.4,flapOut:.3,kickLift:.35,kickKnee:.15,kickShin:.6,kickWithinMs:600,stepShift:.5,stepWithinMs:700,marchLift:.2,marchDrop:.08,marchWithinMs:1200}),vs=e=>{if(typeof e.measure!="function"||typeof e.createMemory!="function")throw new Error("defineBodyMove needs createMemory and measure functions");return e};class vt{constructor(t=64){v(this,"times");v(this,"values");v(this,"start",0);v(this,"count",0);this.capacity=t,this.times=new Float64Array(t),this.values=new Float64Array(t)}clear(){this.start=0,this.count=0}push(t,n){const s=(this.start+this.count)%this.capacity;this.times[s]=t,this.values[s]=n,this.count<this.capacity?this.count+=1:this.start=(this.start+1)%this.capacity}max(t){let n=-1/0;for(let s=0;s<this.count;s+=1){const i=(this.start+s)%this.capacity;this.times[i]>=t&&this.values[i]>n&&(n=this.values[i])}return n}min(t){let n=1/0;for(let s=0;s<this.count;s+=1){const i=(this.start+s)%this.capacity;this.times[i]>=t&&this.values[i]<n&&(n=this.values[i])}return n}}const Ht=["left","right"],xt=e=>e==="left"?"right":"left",St=(e,t)=>t==="either"||t===e,X={value:0,side:null},Ss={left:{value:1,side:"left"},right:{value:1,side:"right"},none:{value:1,side:null}},$=e=>Ss[e??"none"],ct={enterThreshold:.5,exitThreshold:.5,holdMs:0,lostGraceMs:250},hn=e=>e.seen.leftShoulder&&e.seen.rightShoulder&&yt(e,"left")&&yt(e,"right"),dn=(e,{side:t})=>e.seen.leftShoulder&&e.seen.rightShoulder&&(St("left",t)&&yt(e,"left")||St("right",t)&&yt(e,"right")),bt=e=>e.fullInView&&e.torso>.001,bs={name:"jump",label:"Jump",description:"Shoulders, hips and both feet rise together above the standing level (a fast rise), then land.",view:"full",limitKeys:["jumpRise","jumpLand","jumpMaxAirMs","jumpLevelMs"],defaults:{...ct,cooldownMs:150},createMemory:()=>({level:null,lastMs:0,airborne:!1,airSinceMs:0}),inView:bt,measure:(e,t,n,{limits:s})=>{const{joints:i,torso:o}=e,r=(i.leftShoulder.y+i.rightShoulder.y)/2,c=(i.leftHip.y+i.rightHip.y)/2,l=i.leftAnkle.y,h=i.rightAnkle.y,a=t.level;if(!a)return t.level={shoulders:r,hips:c,left:l,right:h},t.lastMs=n,X;const f=Math.max(0,n-t.lastMs);t.lastMs=n;const d=(x,E)=>(x-E)/o;if(t.airborne){const x=d(l,a.left)<=s.jumpLand&&d(h,a.right)<=s.jumpLand,E=n-t.airSinceMs>s.jumpMaxAirMs;return!x&&!E?$(null):(t.airborne=!1,E&&Object.assign(a,{shoulders:r,hips:c,left:l,right:h}),X)}if(d(r,a.shoulders)>=s.jumpRise&&d(c,a.hips)>=s.jumpRise&&d(l,a.left)>=s.jumpRise&&d(h,a.right)>=s.jumpRise)return t.airborne=!0,t.airSinceMs=n,$(null);const g=1-Math.exp(-f/Math.max(1,s.jumpLevelMs));return a.shoulders+=(r-a.shoulders)*g,a.hips+=(c-a.hips)*g,a.left+=(l-a.left)*g,a.right+=(h-a.right)*g,X}},me=(e,t)=>{const n=e.joints[j(t,"Hip")],s=e.joints[j(t,"Knee")],i=e.joints[j(t,"Ankle")],o=s.y-i.y;return o>1e-4?(n.y-s.y)/o:null},Os={name:"squat",label:"Squat",description:"From standing, both thighs drop toward level (the hips sink to the knees), then the body stands back up.",view:"full",limitKeys:["squatDown","squatUp"],defaults:{...ct,cooldownMs:200},createMemory:()=>({ready:!1,down:!1}),inView:bt,measure:(e,t,n,{limits:s})=>{const i=me(e,"left"),o=me(e,"right");if(i===null||o===null)return t.down?$(null):X;const r=Math.max(i,o),c=Math.abs(e.joints.leftAnkle.y-e.joints.rightAnkle.y)/e.torso<=.25;return t.down?r<s.squatUp?$(null):(t.down=!1,t.ready=!0,X):(r>=s.squatUp&&(t.ready=!0),t.ready&&c&&r<=s.squatDown?(t.ready=!1,t.down=!0,$(null)):X)}},ge=e=>{const t=()=>new an({minAmplitude:e.waveAmplitude,requiredReversals:Math.max(1,Math.round(e.waveReversals)),windowMs:e.waveWindowMs});return{built:{amplitude:e.waveAmplitude,reversals:e.waveReversals,windowMs:e.waveWindowMs},left:t(),right:t(),sample:{value:0,side:null}}},Ts={name:"wave",label:"Wave",description:"A forearm held up swings side to side about the elbow: three turning points of 0.3 shoulder widths within 1.5 s.",view:"upper",sided:!0,limitKeys:["waveForearmUp","waveAmplitude","waveReversals","waveWindowMs"],defaults:{enterThreshold:.99,exitThreshold:.3,cooldownMs:600,lostGraceMs:250},createMemory:()=>ge(Dt),inView:dn,measure:(e,t,n,{side:s,limits:i})=>{const{built:o}=t;(o.amplitude!==i.waveAmplitude||o.reversals!==i.waveReversals||o.windowMs!==i.waveWindowMs)&&Object.assign(t,ge(i));const r=e.shoulderWidth;let c=0,l=null;for(const h of Ht){if(!St(h,s))continue;const a=t[h],f=e.joints[j(h,"Elbow")],d=e.joints[j(h,"Wrist")];if(!yt(e,h)||(d.y-f.y)/r<i.waveForearmUp){a.reset();continue}const g=a.push((d.x-f.x)/r,n);g>c&&(c=g,l=h)}return c<=0?X:(t.sample.value=c,t.sample.side=l,t.sample)}},_t=(e,t,n)=>{const s=e.joints[j(t,"Wrist")][n];return e.seen[j(t,"Index")]?(s+e.joints[j(t,"Index")][n])/2:s},_s={name:"clap",label:"Clap",description:"The hands come together fast (apart to touching within 0.25 s); ends when they part. Each clap counts.",view:"upper",limitKeys:["clapApart","clapTogether","clapWithinMs","clapRelease"],defaults:{...ct,cooldownMs:100},createMemory:()=>({apartAtMs:-1/0,clapped:!1}),inView:hn,measure:(e,t,n,{limits:s})=>{const i=Math.hypot(_t(e,"left","x")-_t(e,"right","x"),_t(e,"left","y")-_t(e,"right","y"))/e.shoulderWidth;if(t.clapped){if(i<s.clapRelease)return $(null);t.clapped=!1}return i>=s.clapApart&&(t.apartAtMs=n),i<=s.clapTogether&&n-t.apartAtMs<=s.clapWithinMs?(t.clapped=!0,t.apartAtMs=-1/0,$(null)):X}},Es=(e,t)=>{const n=e.joints[j(t,"Shoulder")],s=e.joints[j(t,"Elbow")],i=e.joints[j(t,"Wrist")],o=(c,l)=>Math.hypot(c.x-l.x,c.y-l.y,2*(c.z-l.z)),r=o(n,s)+o(s,i);return r<.1*e.shoulderWidth?null:o(n,i)/r},As={name:"punch",label:"Punch",description:"An arm snaps from bent to straight (within 0.2 s) at shoulder height, toward the camera or to the side; ends when it bends back.",view:"upper",sided:!0,limitKeys:["punchBent","punchStraight","punchWithinMs","punchBand"],defaults:{...ct,cooldownMs:150},createMemory:()=>({left:{bentAtMs:-1/0,punching:!1},right:{bentAtMs:-1/0,punching:!1}}),inView:dn,measure:(e,t,n,{side:s,limits:i})=>{let o=null;for(const r of Ht){const c=t[r];if(!St(r,s)||!yt(e,r)){c.punching=!1,c.bentAtMs=-1/0;continue}const l=Es(e,r);if(l===null){c.punching&&(o??(o=r));continue}const h=e.joints[j(r,"Shoulder")],a=e.joints[j(r,"Wrist")],f=Math.abs(a.y-h.y)/e.shoulderWidth<=i.punchBand;if(c.punching){if(l>=i.punchStraight-.1&&f){o??(o=r);continue}c.punching=!1}l<=i.punchBent?c.bentAtMs=n:l>=i.punchStraight&&f&&n-c.bentAtMs<=i.punchWithinMs&&(c.punching=!0,c.bentAtMs=-1/0,o??(o=r))}return o?$(o):X}},Rs={name:"armFlap",label:"Flap your arms",description:"Both arms, held out to the sides, beat down together (a wing stroke of 0.7 shoulder widths within 0.5 s). Each downstroke counts.",view:"upper",limitKeys:["flapStroke","flapWithinMs","flapTop","flapOut"],defaults:{...ct,cooldownMs:100},createMemory:()=>({left:new vt,right:new vt,flapping:!1}),inView:hn,measure:(e,t,n,{limits:s})=>{const{left:i,right:o}=e.shape.arms;t.left.push(n,i.up),t.right.push(n,o.up);const r=n-s.flapWithinMs,c=t.left.max(r),l=t.right.max(r),h=Math.min(c-i.up,l-o.up);return t.flapping?h>=s.flapStroke*.5?$(null):(t.flapping=!1,X):h>=s.flapStroke&&Math.min(c,l)>=s.flapTop&&i.out>=s.flapOut&&o.out>=s.flapOut?(t.flapping=!0,$(null)):X}},ks={name:"kick",label:"Kick",description:"One foot swings up fast (forward or to the side) with the knee lifted and the lower leg raised, not hanging; ends when the foot is down.",view:"full",sided:!0,limitKeys:["kickLift","kickKnee","kickShin","kickWithinMs"],defaults:{...ct,cooldownMs:300},createMemory:()=>({left:{downAtMs:-1/0,kicking:!1},right:{downAtMs:-1/0,kicking:!1}}),inView:bt,measure:(e,t,n,{side:s,limits:i})=>{const{joints:o,torso:r}=e;let c=null;for(const l of Ht){const h=t[l],a=o[j(l,"Knee")],f=o[j(l,"Ankle")],d=o[j(xt(l),"Knee")],g=o[j(xt(l),"Ankle")],x=(f.y-g.y)/r;if(h.kicking){if(x>i.kickLift*.4){c??(c=l);continue}h.kicking=!1}if(x<=i.kickLift*.3&&(h.downAtMs=n),!St(l,s))continue;const E=d.y-g.y;if(E<=1e-4)continue;const m=(a.y-d.y)/r,T=(a.y-f.y)/E;x>=i.kickLift&&m>=i.kickKnee&&T<=i.kickShin&&n-h.downAtMs<=i.kickWithinMs&&(h.kicking=!0,c??(c=l))}return c?$(c):X}},Ds=150,ye=e=>({name:e==="left"?"stepLeft":"stepRight",label:e==="left"?"Step to your left":"Step to your right",description:`Hips and both feet move to the person's own ${e} by half a shoulder width within 0.7 s; ends when the body settles.`,view:"full",limitKeys:["stepShift","stepWithinMs"],defaults:{...ct,cooldownMs:300},createMemory:()=>({hips:new vt,feet:new vt,stepping:!1,peak:0,peakAtMs:0}),inView:bt,measure:(t,n,s,{limits:i})=>{const{joints:o}=t,r=(e==="left"?1:-1)*t.leftward,c=r*(o.leftHip.x+o.rightHip.x)/2,l=r*(o.leftAnkle.x+o.rightAnkle.x)/2,h=t.shoulderWidth;if(n.stepping){if(c>n.peak&&(n.peak=c,n.peakAtMs=s),!(s-n.peakAtMs>=Ds||(n.peak-c)/h>.15))return $(e);n.stepping=!1,n.hips.clear(),n.feet.clear()}n.hips.push(s,c),n.feet.push(s,l);const a=s-i.stepWithinMs,f=(c-n.hips.min(a))/h,d=(l-n.feet.min(a))/h;return f>=i.stepShift&&d>=i.stepShift*.8?(n.stepping=!0,n.peak=c,n.peakAtMs=s,$(e)):X}}),Is={name:"march",label:"March in place",description:"Knees (or feet) lift in turn, marching or running in place. Each alternating lift counts as one step; the first lift only starts the count.",view:"full",limitKeys:["marchLift","marchDrop","marchWithinMs"],defaults:{...ct,cooldownMs:0},createMemory:()=>({up:{left:!1,right:!1},liftedAtMs:{left:-1/0,right:-1/0},stepping:null}),inView:bt,measure:(e,t,n,{limits:s})=>{const{joints:i,torso:o}=e;for(const r of Ht){const c=i[j(r,"Knee")],l=i[j(r,"Ankle")],h=i[j(xt(r),"Knee")],a=i[j(xt(r),"Ankle")],f=Math.max(c.y-h.y,l.y-a.y)/o;t.up[r]?f<=s.marchDrop&&(t.up[r]=!1):f>=s.marchLift&&(t.up[r]=!0,n-t.liftedAtMs[xt(r)]<=s.marchWithinMs&&(t.stepping=r),t.liftedAtMs[r]=n)}return t.stepping&&!t.up[t.stepping]&&(t.stepping=null),t.stepping?$(t.stepping):X}},ne={jump:bs,squat:Os,wave:Ts,clap:_s,punch:As,armFlap:Rs,kick:ks,stepLeft:ye("left"),stepRight:ye("right"),march:Is},Ns=Object.keys(ne),Ft=e=>typeof e=="string"?ne[e]:e,pn=e=>e?{...Dt,...e}:Dt,fn=Object.freeze({enterThreshold:.6,exitThreshold:.25,holdMs:150,lostGraceMs:250}),Hs=80,Fs=e=>{if(typeof e=="function")return"upper";const t=F.resolveBodyPose(e);if(t)return t.view==="full"?"full":"upper";const n=s=>s.legs!==void 0||s.squat!==void 0||s.wideStance!==void 0||s.lean!==void 0&&s.lean!=="none"||(s.anyOf??[]).some(n);return n(e)?"full":"upper"},Vs=e=>{var n;if(e.move!==void 0)return Ft(e.move).name;const t=e.pose;return typeof t=="string"?t:((n=F.resolveBodyPose(t))==null?void 0:n.label)??"pose"},se=(e,t={})=>at.resolveGestureDetectorOptions(t,at.resolveGestureDetectorOptions(e.move!==void 0?Ft(e.move).defaults:fn)),mn=({side:e="either",limits:t,...n})=>({engine:n,context:{side:e,limits:pn(t)}}),Bs=(e,t={})=>{const n=Vs(e),s=e.move!==void 0?Ft(e.move):null,i=e.move!==void 0?null:e.pose,{engine:o,context:r}=mn(t),c=at.createGestureDetectorState(n);return{...at.snapshotGestureState(c),kind:s?"move":"pose",view:s?s.view:Fs(i),inView:!1,side:null,pose:i,move:s,memory:s?s.createMemory():null,memoryUsed:!1,detector:c,options:se(e,o),context:r,sample:null,sampleSide:null,lastSampleMs:null}},Ws=(e,t,n={})=>{const{engine:s,context:i}=mn(n);e.options=se(t,s),e.context=i},Pt=e=>{e.move&&e.memoryUsed&&(e.memory=e.move.createMemory(),e.memoryUsed=!1),e.lastSampleMs=null},Ps=(e,t,n)=>{if(e.sampleSide=null,!t){e.inView=!1,e.sample=null,Pt(e);return}const s=e.sample??{value:0,confidence:0};if(e.sample=s,e.pose!==null){const c=t.shape.upperBodyVisible;if(e.inView=c&&(e.view!=="full"||t.shape.lowerBodyVisible),!c){Pt(e),s.value=0,s.confidence=0;return}const l=F.matchBodyPose(t.shape,e.pose)?1:0;s.value=e.lastSampleMs===null?l:s.value+(l-s.value)*(1-Math.exp(-(n-e.lastSampleMs)/Hs)),s.confidence=1,e.lastSampleMs=n;return}const i=e.move,o=e.context;if(e.inView=i.inView?i.inView(t,o):i.view==="full"?t.fullInView&&t.torso>0:t.upperInView,!e.inView){Pt(e),s.value=0,s.confidence=0;return}const r=i.measure(t,e.memory,n,o);e.memoryUsed=!0,e.lastSampleMs=n,s.value=Number.isFinite(r.value)?r.value:0,s.confidence=1,e.sampleSide=r.side??null},js=(e,t,n,s=!0)=>{(s||!t)&&Ps(e,t,n);const i=at.stepGestureDetector(e.detector,e.sample,n,e.options);return i.justBegan&&(e.side=e.sampleSide),at.snapshotGestureState(i,e),e},Cs=(e,t)=>{const n=t??{};return n.name=e.name,n.active=e.active,n.value=e.value,n.confidence=e.confidence,n.tracked=e.tracked,n.phase=e.phase,n.justBegan=e.justBegan,n.justEnded=e.justEnded,n.endReason=e.endReason,n.startedAtMs=e.startedAtMs,n.durationMs=e.durationMs,n.count=e.count,n.kind=e.kind,n.view=e.view,n.inView=e.inView,n.side=e.side,n},Us=(e,t)=>at.gestureStatesEqual(e,t)&&e.kind===t.kind&&e.view===t.view&&e.inView===t.inView&&e.side===t.side;exports.ARM_FIT_DEFAULTS=Kt;exports.ARM_MASK_DEFAULTS=Me;exports.ArmTracker=ve;exports.BODY_MOVES=ne;exports.BODY_MOVE_LIMITS=Dt;exports.BODY_MOVE_NAMES=Ns;exports.BODY_MOVE_VIEW_LIMITS=zt;exports.BODY_POSE_TRIGGER_DEFAULTS=fn;exports.FOREARM_OCCLUDER_FLARE=ke;exports.FOREARM_OCCLUDER_LENGTH=Re;exports.FOREARM_OCCLUDER_OVERLAP=De;exports.ForearmOccluder=Pe;exports.HAND_JOINTS=q;exports.HAND_OCCLUDER_RENDER_ORDER=je;exports.HAND_RIG_FOREARM=Ct;exports.HAND_RIG_MODEL_MESH=It;exports.HAND_TATTOO_DEFAULT_SIZE=qe;exports.HAND_TATTOO_FACING_FADE=ze;exports.HAND_TATTOO_RENDER_ORDER=Le;exports.HAND_TOUCH_DEFAULTS=$t;exports.HAND_TOUCH_DEPTH=en;exports.HAND_TOUCH_POINTER_RADIUS=tn;exports.HAND_TOUCH_TIPS=Mt;exports.HandOccluder=Wn;exports.HandRig=Ve;exports.HandRigContext=Nt;exports.HandRigWrist=He;exports.HandRigWristContext=Yt;exports.HandTattoo=Kn;exports.HandTouch=cs;exports.HandTouchContext=Zt;exports.OscillationTracker=an;exports.POSE_JOINTS=tt;exports.TOUCH_WORLD_DEFAULTS=Qt;exports.TimedSeries=vt;exports.TouchWorld=Ze;exports.WRIST_DEPTH_OF_WIDTH=Ee;exports.WRIST_FILTER_DEFAULTS=Ie;exports.WRIST_WIDTH_OF_PALM=_e;exports.WristAttachment=Be;exports.WristRotationFilter=Ne;exports.armQueryOf=we;exports.bodyTriggerStatesEqual=Us;exports.createBodyMoveFrame=ws;exports.createBodyTrigger=Bs;exports.createForearmGeometry=We;exports.createHandOccluderMaterial=Ue;exports.createHandTattooMaterial=Ye;exports.createTouchHand=Et;exports.defineBodyMove=vs;exports.ellipseWidthOnScreen=Oe;exports.ensureForearmBone=Fe;exports.fingerExtensions=sn;exports.fitWristFrame=Te;exports.frameUpOnScreen=Gt;exports.handGeometryToRoot=Je;exports.handTattooFrame=Ke;exports.handTattooMatrix=Ge;exports.handTattooUv=Cn;exports.measureArm=xe;exports.measureArmRaise=fs;exports.measureFingerPattern=on;exports.measureGrab=rn;exports.measureHandHeight=ps;exports.measureOpenPalm=ds;exports.measurePinch=us;exports.measureTPose=ms;exports.measureThumb=hs;exports.patchHandOccluderInflate=Ce;exports.resolveBodyMove=Ft;exports.resolveBodyMoveLimits=pn;exports.resolveBodyTriggerOptions=se;exports.screenAngle=be;exports.setBodyTriggerOptions=Ws;exports.setHandTattooBlend=Xt;exports.sideJoint=j;exports.snapshotBodyTriggerState=Cs;exports.stepBodyTrigger=js;exports.thumbDirection=Lt;exports.thumbExtension=ee;exports.updatePointerHand=Qe;exports.updateTouchHand=qt;exports.useArmMask=Se;exports.useFaceResults=vn;exports.useHandTouch=is;exports.worldToFeedUnits=mt;exports.wristFrameLocal=Ae;exports.wristSizeOf=Jt;
|