@vincentt-xr/sdk 2.0.0-alpha.1 → 2.0.0-alpha.11

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.
Files changed (885) hide show
  1. package/GROUNDING.md +8066 -120
  2. package/README.md +86 -52
  3. package/dist/CanonicalHeadFrame-CZFvPzN_.cjs +1 -0
  4. package/dist/CanonicalHeadFrame-vn-jM9fG.js +1506 -0
  5. package/dist/DebuggerUI-DDpU-nBF.js +275 -0
  6. package/dist/DebuggerUI-Db-1VtQJ.cjs +1 -0
  7. package/dist/FaceRetouch-D2xH5OpW.js +1071 -0
  8. package/dist/FaceRetouch-DHhn1nSV.cjs +134 -0
  9. package/dist/FaceSurface-CHAMEeG1.cjs +1 -0
  10. package/dist/FaceSurface-DmP9AEeC.js +27 -0
  11. package/dist/SkeletonUtils-C2r90MtN.js +21 -0
  12. package/dist/SkeletonUtils-CddIup1F.cjs +1 -0
  13. package/dist/TextLabel-Ctp-a7g9.cjs +2 -0
  14. package/dist/TextLabel-Dgt-uNN9.js +984 -0
  15. package/dist/assets/cache.d.ts +99 -0
  16. package/dist/assets/estimate.d.ts +11 -0
  17. package/dist/assets/gltfLoader.d.ts +16 -0
  18. package/dist/assets/index.d.ts +7 -0
  19. package/dist/assets/loaders.d.ts +43 -0
  20. package/dist/assets/react.d.ts +33 -0
  21. package/dist/assets/sdkModels.d.ts +22 -0
  22. package/dist/audio/AudioEngine.d.ts +3 -1
  23. package/dist/audio/AudioPlayer.d.ts +29 -0
  24. package/dist/audio/AudioPlayerLogic.d.ts +4 -0
  25. package/dist/audio/index.d.ts +2 -0
  26. package/dist/body/__fixtures__/syntheticRig.d.ts +21 -0
  27. package/dist/body/bodyFlipGuard.d.ts +39 -0
  28. package/dist/body/bodyIdentity.d.ts +72 -0
  29. package/dist/body/bodyMask.d.ts +79 -0
  30. package/dist/body/bodyMaskMaterial.d.ts +15 -0
  31. package/dist/body/bodyPose.d.ts +58 -0
  32. package/dist/body/bodyRigFit.d.ts +148 -0
  33. package/dist/body/bodyRigSolver.d.ts +114 -0
  34. package/dist/body/bodySubject.d.ts +46 -0
  35. package/dist/body-pose/index.d.ts +521 -0
  36. package/dist/body-trigger/__fixtures__/syntheticBody.d.ts +83 -0
  37. package/dist/body-trigger/frame.d.ts +88 -0
  38. package/dist/body-trigger/index.d.ts +6 -0
  39. package/dist/body-trigger/moves.d.ts +235 -0
  40. package/dist/body-trigger/trigger.d.ts +75 -0
  41. package/dist/bodyMaskMaterial-C3aXItLo.js +207 -0
  42. package/dist/bodyMaskMaterial-Q6rYywwW.cjs +68 -0
  43. package/dist/cache-C85JjyZA.js +212 -0
  44. package/dist/cache-DFqZYsHC.cjs +1 -0
  45. package/dist/calibration/calibration.d.ts +75 -0
  46. package/dist/calibration/index.d.ts +6 -0
  47. package/dist/calibration/storage.d.ts +13 -0
  48. package/dist/calibration/types.d.ts +53 -0
  49. package/dist/calibration/useXRCalibration.d.ts +46 -0
  50. package/dist/camera/CameraPermissionGate.d.ts +26 -0
  51. package/dist/camera/devices.d.ts +26 -0
  52. package/dist/camera/index.d.ts +8 -0
  53. package/dist/camera/permission.d.ts +86 -0
  54. package/dist/camera/useCameraPermission.d.ts +35 -0
  55. package/dist/canonicalFace-BHwyCx1c.js +9 -0
  56. package/dist/canonicalFace-C83I225R.cjs +1 -0
  57. package/dist/capabilities/detect.d.ts +45 -0
  58. package/dist/capabilities/index.d.ts +5 -0
  59. package/dist/capabilities/types.d.ts +120 -0
  60. package/dist/capabilities/useXRCapabilities.d.ts +18 -0
  61. package/dist/compat/environment.d.ts +5 -0
  62. package/dist/compat/index.d.ts +4 -0
  63. package/dist/compat/run.d.ts +18 -0
  64. package/dist/compat/scenarios.d.ts +10 -0
  65. package/dist/compat/types.d.ts +101 -0
  66. package/dist/components/Axes/index.d.ts +6 -0
  67. package/dist/components/BodyInstruction/BodyPoseHint.d.ts +63 -0
  68. package/dist/components/BodyInstruction/index.d.ts +76 -0
  69. package/dist/components/BodyInstruction/useBodyPose.d.ts +30 -0
  70. package/dist/components/BodyRig/BodyAttachment.d.ts +28 -0
  71. package/dist/components/BodyRig/BodyOccluder.d.ts +27 -0
  72. package/dist/components/BodyRig/bodyDepth.d.ts +57 -0
  73. package/dist/components/BodyRig/index.d.ts +129 -0
  74. package/dist/components/BodyRig/useBodyDepthTexture.d.ts +40 -0
  75. package/dist/components/BodyTracker/index.d.ts +26 -1
  76. package/dist/components/BodyTrigger/index.d.ts +56 -0
  77. package/dist/components/Debugger/DebuggerProvider.d.ts +14 -1
  78. package/dist/components/Debugger/DebuggerUI.d.ts +3 -1
  79. package/dist/components/FaceAtlas/FaceAtlasLayer.d.ts +114 -0
  80. package/dist/components/FaceAtlas/MadeUpCamera.d.ts +80 -0
  81. package/dist/components/FaceAtlas/constants.d.ts +8 -0
  82. package/dist/components/FaceAtlas/index.d.ts +7 -0
  83. package/dist/components/FaceAtlas/useFaceAtlasSurface.d.ts +84 -0
  84. package/dist/components/FaceAtlas/useFaceSkin.d.ts +84 -0
  85. package/dist/components/FaceCharacter/ExternalFaceMesh.d.ts +109 -0
  86. package/dist/components/FaceCharacter/FaceExpressionController.d.ts +53 -0
  87. package/dist/components/FaceCharacter/FaceMorph.d.ts +71 -0
  88. package/dist/components/FaceCharacter/FacePiercing.d.ts +65 -0
  89. package/dist/components/FaceCharacter/FaceReprojection.d.ts +85 -0
  90. package/dist/components/FaceCharacter/FaceRig.d.ts +38 -0
  91. package/dist/components/FaceCharacter/FaceSurface.d.ts +49 -0
  92. package/dist/components/FaceCharacter/FaceSurfaceOccluder.d.ts +39 -0
  93. package/dist/components/FaceCharacter/PinToFaceMesh.d.ts +68 -0
  94. package/dist/components/FaceCharacter/index.d.ts +18 -0
  95. package/dist/components/FaceCharacter/useFaceReprojector.d.ts +10 -0
  96. package/dist/components/FaceInset/FaceInset.d.ts +68 -0
  97. package/dist/components/FaceInset/frame.d.ts +94 -0
  98. package/dist/components/FaceInset/index.d.ts +6 -0
  99. package/dist/components/FaceInset/material.d.ts +40 -0
  100. package/dist/components/FaceInset/useFaceInsetTexture.d.ts +37 -0
  101. package/dist/components/FaceInstruction/FaceExpressionHint.d.ts +43 -0
  102. package/dist/components/FaceInstruction/index.d.ts +56 -0
  103. package/dist/components/FaceInstruction/useFaceExpression.d.ts +20 -0
  104. package/dist/components/FaceLiquify/FaceLiquify.d.ts +49 -0
  105. package/dist/components/FaceLiquify/debug.d.ts +37 -0
  106. package/dist/components/FaceLiquify/frame.d.ts +55 -0
  107. package/dist/components/FaceLiquify/index.d.ts +10 -0
  108. package/dist/components/FaceLiquify/material.d.ts +39 -0
  109. package/dist/components/FaceLiquify/pass.d.ts +49 -0
  110. package/dist/components/FaceLiquify/presence.d.ts +25 -0
  111. package/dist/components/FaceLiquify/presets.d.ts +82 -0
  112. package/dist/components/FaceLiquify/selfTest.d.ts +66 -0
  113. package/dist/components/FaceLiquify/target.d.ts +85 -0
  114. package/dist/components/FaceLiquify/warp.d.ts +72 -0
  115. package/dist/components/FaceMesh/FaceMeshRenderer.d.ts +25 -0
  116. package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +67 -3
  117. package/dist/components/FaceMesh/canonical/FaceMeshMaterial.d.ts +25 -0
  118. package/dist/components/FaceMesh/canonical/assets.d.ts +3 -0
  119. package/dist/components/FaceMesh/canonical/geometryGroups.d.ts +30 -0
  120. package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +24 -0
  121. package/dist/components/FaceMesh/canonical/shaders.d.ts +2 -0
  122. package/dist/components/FaceMesh/deform.d.ts +3 -0
  123. package/dist/components/FaceMesh/index.d.ts +6 -1
  124. package/dist/components/FaceMesh/material/defaults.d.ts +70 -0
  125. package/dist/components/FaceMesh/material/index.d.ts +1 -0
  126. package/dist/components/FaceMesh/material/options.d.ts +5 -1
  127. package/dist/components/FaceMesh/material/support.d.ts +7 -2
  128. package/dist/components/FaceMesh/material/textures.d.ts +4 -0
  129. package/dist/components/FaceMesh/material/types.d.ts +2 -2
  130. package/dist/components/FaceRetouch/Background.d.ts +7 -6
  131. package/dist/components/FaceRetouch/FaceRetouch.d.ts +52 -0
  132. package/dist/components/FaceRetouch/index.d.ts +2 -8
  133. package/dist/components/FaceRetouch/landmarkMask.d.ts +0 -5
  134. package/dist/components/FaceRetouch/renderState.d.ts +19 -0
  135. package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +3 -7
  136. package/dist/components/FaceSwap/FaceMirror.d.ts +46 -0
  137. package/dist/components/FaceSwap/FaceSwap.d.ts +58 -0
  138. package/dist/components/FaceSwap/FaceTextureLayer.d.ts +72 -0
  139. package/dist/components/FaceSwap/faceSwapPlan.d.ts +91 -0
  140. package/dist/components/FaceSwap/index.d.ts +13 -0
  141. package/dist/components/FaceSwap/settings.d.ts +300 -0
  142. package/dist/components/FaceSwap/useFaceTexture.d.ts +35 -0
  143. package/dist/components/FaceSwap/useLiveFace.d.ts +38 -0
  144. package/dist/components/FaceSwap/useLiveFaceTexture.d.ts +31 -0
  145. package/dist/components/FaceTracker/index.d.ts +5 -3
  146. package/dist/components/FaceWarp3D/FaceWarp3D.d.ts +50 -0
  147. package/dist/components/FaceWarp3D/index.d.ts +2 -3
  148. package/dist/components/Faceless/Faceless.d.ts +51 -0
  149. package/dist/components/Faceless/index.d.ts +2 -0
  150. package/dist/components/GestureListener/index.d.ts +11 -0
  151. package/dist/components/HairLock/HairLock.d.ts +39 -0
  152. package/dist/components/HairLock/index.d.ts +2 -0
  153. package/dist/components/HairLock/lockGeometry.d.ts +15 -0
  154. package/dist/components/HandCutout/index.d.ts +35 -0
  155. package/dist/components/HandEffect/index.d.ts +36 -0
  156. package/dist/components/HandInstruction/HandGestureHint.d.ts +70 -0
  157. package/dist/components/HandInstruction/index.d.ts +74 -0
  158. package/dist/components/HandInstruction/useHandGesture.d.ts +22 -0
  159. package/dist/components/HandJoints2D/index.d.ts +1 -1
  160. package/dist/components/HandRig/ForearmOccluder.d.ts +29 -0
  161. package/dist/components/HandRig/HandAttachment.d.ts +34 -0
  162. package/dist/components/HandRig/HandNails.d.ts +61 -0
  163. package/dist/components/HandRig/HandOccluder.d.ts +45 -0
  164. package/dist/components/HandRig/HandTattoo.d.ts +61 -0
  165. package/dist/components/HandRig/WristAttachment.d.ts +34 -0
  166. package/dist/components/HandRig/index.d.ts +127 -0
  167. package/dist/components/HandRig/useArmMask.d.ts +29 -0
  168. package/dist/components/HandRig/wristSolve.d.ts +96 -0
  169. package/dist/components/HandTouch/HandTouch.d.ts +62 -0
  170. package/dist/components/HandTouch/Touchable.d.ts +36 -0
  171. package/dist/components/HandTouch/index.d.ts +2 -0
  172. package/dist/components/HandTracker/index.d.ts +10 -0
  173. package/dist/components/HandTracking2D/HandVisual.d.ts +1 -1
  174. package/dist/components/HandTracking2D/index.d.ts +1 -1
  175. package/dist/components/HandTracking2DController/index.d.ts +1 -1
  176. package/dist/components/HandTracking3D/index.d.ts +1 -1
  177. package/dist/components/HeadBinding/index.d.ts +14 -0
  178. package/dist/components/HeadOccluder/CanonicalHeadFrame.d.ts +22 -0
  179. package/dist/components/HeadOccluder/Earrings.d.ts +55 -0
  180. package/dist/components/HeadOccluder/HeadAttachment.d.ts +38 -0
  181. package/dist/components/HeadOccluder/NeckOccluder.d.ts +67 -0
  182. package/dist/components/HeadOccluder/earringPlacement.d.ts +31 -0
  183. package/dist/components/HeadOccluder/headAttachmentPoints.d.ts +69 -0
  184. package/dist/components/HeadOccluder/index.d.ts +57 -3
  185. package/dist/components/HeadOccluder/useCanonicalHeadFit.d.ts +36 -0
  186. package/dist/components/HeadOccluder/useLandmarkPoseFit.d.ts +80 -0
  187. package/dist/components/HolisticTracker/index.d.ts +69 -0
  188. package/dist/components/HolisticTracker/settings.d.ts +58 -0
  189. package/dist/components/HolisticTracker/signals.d.ts +49 -0
  190. package/dist/components/Instruction/HintStage.d.ts +29 -0
  191. package/dist/components/Instruction/InstructionCue.d.ts +126 -0
  192. package/dist/components/Instruction/gestureHold.d.ts +20 -0
  193. package/dist/components/Instruction/ghost.d.ts +129 -0
  194. package/dist/components/Instruction/hintBlend.d.ts +19 -0
  195. package/dist/components/Instruction/hintLook.d.ts +81 -0
  196. package/dist/components/Instruction/hintLoop.d.ts +36 -0
  197. package/dist/components/Instruction/index.d.ts +41 -0
  198. package/dist/components/Instruction/useGhostModel.d.ts +33 -0
  199. package/dist/components/Instruction/useInstructionHold.d.ts +72 -0
  200. package/dist/components/IrisEffect/IrisMaterial.d.ts +73 -0
  201. package/dist/components/IrisEffect/index.d.ts +51 -0
  202. package/dist/components/IrisEffect/settings.d.ts +117 -0
  203. package/dist/components/LightObject/index.d.ts +20 -0
  204. package/dist/components/LipEffect/LipEffect.d.ts +28 -0
  205. package/dist/components/LipEffect/LipEffectMaterial.d.ts +98 -0
  206. package/dist/components/LipEffect/LipEffects.d.ts +12 -0
  207. package/dist/components/LipEffect/defaults.d.ts +51 -0
  208. package/dist/components/LipEffect/index.d.ts +12 -0
  209. package/dist/components/LipEffect/lipShading.d.ts +73 -0
  210. package/dist/components/LipEffect/settings.d.ts +375 -0
  211. package/dist/components/LipEffect/shader.d.ts +39 -0
  212. package/dist/components/LipEffect/types.d.ts +141 -0
  213. package/dist/components/LipEffect/useLipDesignTextures.d.ts +17 -0
  214. package/dist/components/LipEffect/uvGuide.d.ts +74 -0
  215. package/dist/components/LookAt/index.d.ts +23 -0
  216. package/dist/components/Makeup/Blush.d.ts +18 -0
  217. package/dist/components/Makeup/Brows.d.ts +20 -0
  218. package/dist/components/Makeup/Contour.d.ts +17 -0
  219. package/dist/components/Makeup/Eyeliner.d.ts +20 -0
  220. package/dist/components/Makeup/Eyeshadow.d.ts +20 -0
  221. package/dist/components/Makeup/Highlighter.d.ts +18 -0
  222. package/dist/components/Makeup/MakeupDesign.d.ts +37 -0
  223. package/dist/components/Makeup/MakeupRegion.d.ts +132 -0
  224. package/dist/components/Makeup/constants.d.ts +44 -0
  225. package/dist/components/Makeup/design.d.ts +106 -0
  226. package/dist/components/Makeup/designSamples.d.ts +42 -0
  227. package/dist/components/Makeup/eyes.d.ts +114 -0
  228. package/dist/components/Makeup/fields.d.ts +10 -0
  229. package/dist/components/Makeup/geometry.d.ts +106 -0
  230. package/dist/components/Makeup/index.d.ts +26 -0
  231. package/dist/components/Makeup/looks.d.ts +28 -0
  232. package/dist/components/Makeup/material.d.ts +239 -0
  233. package/dist/components/Makeup/settings.d.ts +54 -0
  234. package/dist/components/Makeup/shades.d.ts +143 -0
  235. package/dist/components/Makeup/shapes.d.ts +27 -0
  236. package/dist/components/Makeup/skinTone.d.ts +135 -0
  237. package/dist/components/Makeup/types.d.ts +110 -0
  238. package/dist/components/Makeup/useMakeupSkinTone.d.ts +40 -0
  239. package/dist/components/MeshRenderer/index.d.ts +59 -0
  240. package/dist/components/Necklace/Necklace.d.ts +44 -0
  241. package/dist/components/Necklace/index.d.ts +1 -0
  242. package/dist/components/ParticleEmitter/ParticleEmitter.d.ts +69 -0
  243. package/dist/components/ParticleEmitter/index.d.ts +1 -0
  244. package/dist/components/PersonCutout/index.d.ts +46 -0
  245. package/dist/components/PersonCutout/personCutout.d.ts +16 -0
  246. package/dist/components/PersonCutout/personMask.d.ts +19 -0
  247. package/dist/components/PersonCutout/useBodyMaskTexture.d.ts +35 -0
  248. package/dist/components/PerspectiveCamera/index.d.ts +2 -8
  249. package/dist/components/PinToMesh/index.d.ts +47 -0
  250. package/dist/components/RenderGroupLayer/index.d.ts +6 -0
  251. package/dist/components/SceneObjectRenderer/index.d.ts +23 -0
  252. package/dist/components/Screen2D/ScreenTransformFrame.d.ts +11 -0
  253. package/dist/components/Screen2D/ScreenTransformHelpers.d.ts +19 -0
  254. package/dist/components/Screen2D/ScreenTransformInteraction.d.ts +18 -0
  255. package/dist/components/Screen2D/index.d.ts +5 -0
  256. package/dist/components/ScreenGlass/defaults.d.ts +3 -0
  257. package/dist/components/ScreenGlass/index.d.ts +5 -0
  258. package/dist/components/ScreenGlass/shaders.d.ts +2 -0
  259. package/dist/components/ScreenGlass/types.d.ts +10 -0
  260. package/dist/components/ScreenGradient/defaults.d.ts +5 -0
  261. package/dist/components/ScreenGradient/index.d.ts +5 -0
  262. package/dist/components/ScreenGradient/shaders.d.ts +2 -0
  263. package/dist/components/ScreenGradient/types.d.ts +19 -0
  264. package/dist/components/ScreenImage/ScreenImage.d.ts +7 -0
  265. package/dist/components/ScreenImage/components/DynamicTextureSync.d.ts +9 -0
  266. package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +9 -0
  267. package/dist/components/ScreenImage/components/ScreenImageFrame.d.ts +9 -0
  268. package/dist/components/ScreenImage/components/ScreenImageTransformFrame.d.ts +9 -0
  269. package/dist/components/ScreenImage/fit.d.ts +52 -0
  270. package/dist/components/ScreenImage/index.d.ts +10 -87
  271. package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +9 -0
  272. package/dist/components/ScreenImage/materials/ScreenImageMaskMaterial.d.ts +11 -0
  273. package/dist/components/ScreenImage/materials/ScreenImageMatcap.d.ts +3 -0
  274. package/dist/components/ScreenImage/source.d.ts +25 -0
  275. package/dist/components/ScreenImage/types.d.ts +64 -0
  276. package/dist/components/ScreenImage/utils/ScreenImageConstants.d.ts +9 -0
  277. package/dist/components/ScreenImage/utils/ScreenImageHelpers.d.ts +4 -0
  278. package/dist/components/ScreenShape/geometry.d.ts +5 -0
  279. package/dist/components/ScreenShape/index.d.ts +8 -0
  280. package/dist/components/ScreenShape/types.d.ts +54 -0
  281. package/dist/components/ScreenSpaceUI/ScreenTransformGuide.d.ts +15 -0
  282. package/dist/components/ScreenSpaceUI/ScreenTransformOverlayGuide.d.ts +9 -0
  283. package/dist/components/ScreenSpaceUI/index.d.ts +3 -0
  284. package/dist/components/ScreenText/components/ScreenTextBody.d.ts +2 -0
  285. package/dist/components/ScreenText/components/ScreenTextTransformFrame.d.ts +9 -0
  286. package/dist/components/ScreenText/constants.d.ts +5 -0
  287. package/dist/components/ScreenText/index.d.ts +9 -20
  288. package/dist/components/ScreenText/types.d.ts +31 -0
  289. package/dist/components/ScreenText/utils/ScreenTextHelpers.d.ts +14 -0
  290. package/dist/components/ScreenText/utils/ScreenTextMappings.d.ts +17 -0
  291. package/dist/components/SegmentationOverlay/SegmentationOverlay.d.ts +37 -0
  292. package/dist/components/SegmentationOverlay/SegmentationOverlayMaterial.d.ts +31 -0
  293. package/dist/components/SegmentationOverlay/index.d.ts +9 -0
  294. package/dist/components/SegmentationOverlay/maskTexture.d.ts +23 -0
  295. package/dist/components/SegmentationOverlay/providers.d.ts +72 -0
  296. package/dist/components/SegmentationOverlay/settings.d.ts +65 -0
  297. package/dist/components/SequentialRenderPasses/index.d.ts +6 -0
  298. package/dist/components/ShoulderOccluder/index.d.ts +46 -0
  299. package/dist/components/ShoulderOccluder/useCanonicalTorsoFit.d.ts +27 -0
  300. package/dist/components/SpringSwing/SpringSwing.d.ts +22 -0
  301. package/dist/components/SpringSwing/index.d.ts +1 -0
  302. package/dist/components/TextLabel/TextLabel.d.ts +5 -0
  303. package/dist/components/TextLabel/alignment.d.ts +4 -0
  304. package/dist/components/TextLabel/bend.d.ts +9 -0
  305. package/dist/components/TextLabel/canvas/buildTextLabelTexture.d.ts +4 -0
  306. package/dist/components/TextLabel/canvas/canvasTypography.d.ts +13 -0
  307. package/dist/components/TextLabel/canvas/drawBackground.d.ts +21 -0
  308. package/dist/components/TextLabel/canvas/drawEffects.d.ts +34 -0
  309. package/dist/components/TextLabel/canvas/drawText.d.ts +19 -0
  310. package/dist/components/TextLabel/components/TextLabelMesh.d.ts +13 -0
  311. package/dist/components/TextLabel/constants.d.ts +2 -0
  312. package/dist/components/TextLabel/hooks/useTextLabelTexture.d.ts +7 -0
  313. package/dist/components/TextLabel/index.d.ts +2 -161
  314. package/dist/components/TextLabel/layout/measurement.d.ts +8 -0
  315. package/dist/components/TextLabel/layout/resolveTextLayout.d.ts +25 -0
  316. package/dist/components/TextLabel/layout/wrapText.d.ts +6 -0
  317. package/dist/components/TextLabel/types.d.ts +337 -0
  318. package/dist/components/TrackingAnchor/index.d.ts +18 -2
  319. package/dist/components/Transform3D/index.d.ts +30 -0
  320. package/dist/components/XRMediaSurface/index.d.ts +8 -7
  321. package/dist/components/XRProvider/index.d.ts +16 -2
  322. package/dist/components/XRScene/renderOutputTarget.d.ts +12 -0
  323. package/dist/components/XRViewport/XRViewport.d.ts +11 -0
  324. package/dist/components/XRViewport/components/HiddenMedia.d.ts +7 -0
  325. package/dist/components/XRViewport/components/MediaAssetPicker.d.ts +8 -0
  326. package/dist/components/XRViewport/components/MediaControlStack.d.ts +13 -0
  327. package/dist/components/XRViewport/components/XRViewportLayers.d.ts +30 -0
  328. package/dist/components/XRViewport/constants.d.ts +24 -0
  329. package/dist/components/XRViewport/contexts.d.ts +6 -0
  330. package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +13 -0
  331. package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +16 -0
  332. package/dist/components/XRViewport/hooks/useViewportMediaTexture.d.ts +10 -0
  333. package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +41 -0
  334. package/dist/components/XRViewport/hooks/useViewportRenderState.d.ts +47 -0
  335. package/dist/components/XRViewport/index.d.ts +3 -118
  336. package/dist/components/XRViewport/layout.d.ts +16 -0
  337. package/dist/components/XRViewport/slots.d.ts +16 -0
  338. package/dist/components/XRViewport/types.d.ts +89 -0
  339. package/dist/components/XRViewport/useViewportSize.d.ts +3 -0
  340. package/dist/components/index.d.ts +24 -0
  341. package/dist/components/occluder/skinnedOccluder.d.ts +39 -0
  342. package/dist/config/index.d.ts +1 -1
  343. package/dist/constants/index.d.ts +4 -1
  344. package/dist/context-DTxSQvp4.js +13 -0
  345. package/dist/context-hA0Rb2Xa.cjs +1 -0
  346. package/dist/contexts-B5GODwuV.js +667 -0
  347. package/dist/contexts-CSz9stBV.cjs +1 -0
  348. package/dist/coordinates/feed.d.ts +52 -0
  349. package/dist/coordinates/index.d.ts +7 -0
  350. package/dist/coordinates/side.d.ts +40 -0
  351. package/dist/coordinates/spaces.d.ts +49 -0
  352. package/dist/coordinates/viewport.d.ts +32 -0
  353. package/dist/coordinates/world.d.ts +15 -0
  354. package/dist/debug-ui/component-editor/index.d.ts +19 -0
  355. package/dist/debug-ui/default-setting.cjs +2 -2
  356. package/dist/debug-ui/face-mesh-renderer-settings/index.d.ts +8 -0
  357. package/dist/debug-ui/face-retouch/index.d.ts +11 -0
  358. package/dist/debug-ui/face-swap-settings/index.d.ts +22 -0
  359. package/dist/debug-ui/gesture-settings/index.d.ts +14 -0
  360. package/dist/debug-ui/hand-joints-2d/index.d.ts +1 -1
  361. package/dist/debug-ui/hand-tracking-2d/index.d.ts +1 -1
  362. package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +1 -1
  363. package/dist/debug-ui/hand-tracking-3d/index.d.ts +1 -1
  364. package/dist/debug-ui/hierarchy-panel/index.d.ts +30 -0
  365. package/dist/debug-ui/holistic-tracker-settings/index.d.ts +16 -0
  366. package/dist/debug-ui/index.d.ts +43 -5
  367. package/dist/debug-ui/iris-effect-settings/index.d.ts +12 -0
  368. package/dist/debug-ui/layer-panel/index.d.ts +3 -2
  369. package/dist/debug-ui/lip-effect-settings/index.d.ts +15 -0
  370. package/dist/debug-ui/media-source/index.d.ts +4 -2
  371. package/dist/debug-ui/media-source/media-preset.d.ts +12 -0
  372. package/dist/debug-ui/media-source/session.d.ts +40 -0
  373. package/dist/debug-ui/media-source.cjs +1 -1
  374. package/dist/debug-ui/media-source.js +8 -4
  375. package/dist/debug-ui/mesh-renderer-settings/index.d.ts +6 -0
  376. package/dist/debug-ui/object-inspector-panel/index.d.ts +26 -0
  377. package/dist/debug-ui/pin-to-mesh-settings/index.d.ts +10 -0
  378. package/dist/debug-ui/product-hotspots/index.d.ts +25 -0
  379. package/dist/debug-ui/scene-editor/context.d.ts +38 -0
  380. package/dist/debug-ui/scene-editor/hierarchy-panel.d.ts +11 -0
  381. package/dist/debug-ui/scene-editor/index.d.ts +11 -0
  382. package/dist/debug-ui/scene-editor/inspector-panel.d.ts +9 -0
  383. package/dist/debug-ui/scene-editor/store-utils.d.ts +2 -0
  384. package/dist/debug-ui/scene-editor/viewport-toolbar.d.ts +4 -0
  385. package/dist/debug-ui/scene-editor/viewport.d.ts +21 -0
  386. package/dist/debug-ui/screen-glass-settings/index.d.ts +6 -0
  387. package/dist/debug-ui/screen-gradient-settings/GradientStopsEditor.d.ts +5 -0
  388. package/dist/debug-ui/screen-gradient-settings/index.d.ts +6 -0
  389. package/dist/debug-ui/screen-gradient-settings/styles.d.ts +3 -0
  390. package/dist/debug-ui/screen-image-settings/index.d.ts +6 -2
  391. package/dist/debug-ui/screen-shape-settings/index.d.ts +6 -0
  392. package/dist/debug-ui/screen-text-settings/NumberField.d.ts +9 -0
  393. package/dist/debug-ui/screen-text-settings/ScreenTextSettingsPanel.d.ts +3 -0
  394. package/dist/debug-ui/screen-text-settings/controls/NestedSection.d.ts +7 -0
  395. package/dist/debug-ui/screen-text-settings/controls/Section.d.ts +8 -0
  396. package/dist/debug-ui/screen-text-settings/controls/icons.d.ts +4 -0
  397. package/dist/debug-ui/screen-text-settings/index.d.ts +2 -122
  398. package/dist/debug-ui/screen-text-settings/sections/BackgroundSection.d.ts +8 -0
  399. package/dist/debug-ui/screen-text-settings/sections/ContentSection.d.ts +5 -0
  400. package/dist/debug-ui/screen-text-settings/sections/EffectsSection.d.ts +25 -0
  401. package/dist/debug-ui/screen-text-settings/sections/StyleSection.d.ts +5 -0
  402. package/dist/debug-ui/screen-text-settings/sections/TransformSection.d.ts +5 -0
  403. package/dist/debug-ui/screen-text-settings/sections/background/BackgroundFillControls.d.ts +2 -0
  404. package/dist/debug-ui/screen-text-settings/sections/background/BackgroundSizeControls.d.ts +2 -0
  405. package/dist/debug-ui/screen-text-settings/sections/background/BackgroundStrokeControls.d.ts +2 -0
  406. package/dist/debug-ui/screen-text-settings/sections/background/types.d.ts +7 -0
  407. package/dist/debug-ui/screen-text-settings/sections/effects/BendEffectSection.d.ts +4 -0
  408. package/dist/debug-ui/screen-text-settings/sections/effects/EffectChrome.d.ts +21 -0
  409. package/dist/debug-ui/screen-text-settings/sections/effects/GlowEffectSection.d.ts +4 -0
  410. package/dist/debug-ui/screen-text-settings/sections/effects/InnerShadowEffectSection.d.ts +4 -0
  411. package/dist/debug-ui/screen-text-settings/sections/effects/OutlineEffectSection.d.ts +4 -0
  412. package/dist/debug-ui/screen-text-settings/sections/effects/ShadowEffectSection.d.ts +4 -0
  413. package/dist/debug-ui/screen-text-settings/sections/effects/types.d.ts +14 -0
  414. package/dist/debug-ui/screen-text-settings/settings.d.ts +90 -0
  415. package/dist/debug-ui/screen-text-settings/styles.d.ts +26 -0
  416. package/dist/debug-ui/screen-text-settings/transform.d.ts +6 -0
  417. package/dist/debug-ui/screen-text-settings/types.d.ts +11 -0
  418. package/dist/debug-ui/segmentation-overlay-settings/index.d.ts +12 -0
  419. package/dist/debug-ui/settings-panel/index.d.ts +6 -1
  420. package/dist/debug-ui/shared/ScreenTransformSection.d.ts +6 -3
  421. package/dist/debug-ui/shared/debugWindow.d.ts +51 -0
  422. package/dist/debug-ui/transform-3d-settings/index.d.ts +11 -0
  423. package/dist/debug-ui/xr-diagnostics/index.d.ts +26 -0
  424. package/dist/debug-ui.cjs +3 -13
  425. package/dist/debug-ui.js +8166 -5178
  426. package/dist/detector-K8aej4MB.js +59 -0
  427. package/dist/detector-ijypGtse.cjs +1 -0
  428. package/dist/drawNormalizedCrop-BLfB484W.js +135 -0
  429. package/dist/drawNormalizedCrop-DaGT5mZ5.cjs +1 -0
  430. package/dist/entries/all.d.ts +4 -1
  431. package/dist/entries/core.d.ts +74 -8
  432. package/dist/entries/face-effects.d.ts +130 -12
  433. package/dist/entries/instructions.d.ts +48 -0
  434. package/dist/entries/internal.d.ts +5 -2
  435. package/dist/entries/low-level.d.ts +101 -6
  436. package/dist/entries/particles.d.ts +15 -0
  437. package/dist/entries/product.d.ts +11 -0
  438. package/dist/entries/scene-object.d.ts +10 -0
  439. package/dist/entries/tracking.d.ts +110 -2
  440. package/dist/face-action/index.d.ts +34 -0
  441. package/dist/face-atlas/attributes.d.ts +30 -0
  442. package/dist/face-atlas/eyes.d.ts +272 -0
  443. package/dist/face-atlas/faceAtlas.generated.d.ts +46 -0
  444. package/dist/face-atlas/glsl/atlasVertex.d.ts +46 -0
  445. package/dist/face-atlas/glsl/common.d.ts +55 -0
  446. package/dist/face-atlas/glsl/design.d.ts +49 -0
  447. package/dist/face-atlas/glsl/eyes.d.ts +73 -0
  448. package/dist/face-atlas/glsl/finish.d.ts +24 -0
  449. package/dist/face-atlas/glsl/format.d.ts +4 -0
  450. package/dist/face-atlas/glsl/index.d.ts +59 -0
  451. package/dist/face-atlas/glsl/shading.d.ts +15 -0
  452. package/dist/face-atlas/glsl/shapes.d.ts +66 -0
  453. package/dist/face-atlas/glsl/sparkle.d.ts +19 -0
  454. package/dist/face-atlas/glsl/uniforms.d.ts +106 -0
  455. package/dist/face-atlas/guide.d.ts +51 -0
  456. package/dist/face-atlas/index.d.ts +25 -0
  457. package/dist/face-atlas/lead.d.ts +117 -0
  458. package/dist/face-atlas/madeUpCamera.d.ts +125 -0
  459. package/dist/face-atlas/masks.d.ts +53 -0
  460. package/dist/face-atlas/obj.d.ts +69 -0
  461. package/dist/face-atlas/polylines.d.ts +63 -0
  462. package/dist/face-atlas/probe/FaceSkinProbe.d.ts +208 -0
  463. package/dist/face-atlas/probe/__fixtures__/emulate.d.ts +9 -0
  464. package/dist/face-atlas/probe/__fixtures__/face.d.ts +24 -0
  465. package/dist/face-atlas/probe/constants.d.ts +137 -0
  466. package/dist/face-atlas/probe/glsl.d.ts +43 -0
  467. package/dist/face-atlas/probe/lightFit.d.ts +108 -0
  468. package/dist/face-atlas/probe/schedule.d.ts +44 -0
  469. package/dist/face-atlas/probe/selfTest.d.ts +87 -0
  470. package/dist/face-atlas/probe/stats.d.ts +143 -0
  471. package/dist/face-atlas/probe/targets.d.ts +70 -0
  472. package/dist/face-atlas/probe/unwrap.d.ts +76 -0
  473. package/dist/face-atlas/quality.d.ts +28 -0
  474. package/dist/face-atlas/regions.d.ts +31 -0
  475. package/dist/face-atlas/registry.d.ts +252 -0
  476. package/dist/face-atlas/renderState.d.ts +86 -0
  477. package/dist/face-atlas/selfOcclusion.d.ts +62 -0
  478. package/dist/face-atlas/shading.d.ts +406 -0
  479. package/dist/face-atlas/shapes.d.ts +86 -0
  480. package/dist/face-atlas/sides.d.ts +41 -0
  481. package/dist/face-atlas/skinMask.d.ts +35 -0
  482. package/dist/face-atlas/surface.d.ts +155 -0
  483. package/dist/face-atlas/topology.d.ts +44 -0
  484. package/dist/face-attribute-expression/index.d.ts +10 -0
  485. package/dist/face-character/__fixtures__/faceImageDetections.d.ts +25 -0
  486. package/dist/face-character/__fixtures__/faceNode.d.ts +22 -0
  487. package/dist/face-character/bindFaceModel.d.ts +106 -0
  488. package/dist/face-character/canonicalFace.d.ts +17 -0
  489. package/dist/face-character/canonicalFaceGeometry.d.ts +11 -0
  490. package/dist/face-character/canonicalFacePositions.d.ts +7 -0
  491. package/dist/face-character/driveFaceModel.d.ts +57 -0
  492. package/dist/face-character/expressionOutputs.d.ts +45 -0
  493. package/dist/face-character/faceExpressions.d.ts +104 -0
  494. package/dist/face-character/faceImageLandmarker.d.ts +93 -0
  495. package/dist/face-character/faceMeshBinding.d.ts +62 -0
  496. package/dist/face-character/faceMorph.d.ts +77 -0
  497. package/dist/face-character/faceMorphs.d.ts +46 -0
  498. package/dist/face-character/facePhoto.d.ts +138 -0
  499. package/dist/face-character/facePiercings.d.ts +116 -0
  500. package/dist/face-character/facePin.d.ts +131 -0
  501. package/dist/face-character/faceReprojection.d.ts +273 -0
  502. package/dist/face-character/faceReprojector.d.ts +171 -0
  503. package/dist/face-character/faceRig.d.ts +176 -0
  504. package/dist/face-character/faceSwapPresence.d.ts +85 -0
  505. package/dist/face-character/faceTexture.d.ts +169 -0
  506. package/dist/face-character/faceTextureBaker.d.ts +86 -0
  507. package/dist/face-character/faceTextureGuide.d.ts +106 -0
  508. package/dist/face-character/faceTextureStats.d.ts +298 -0
  509. package/dist/face-character/faceTransfer.d.ts +396 -0
  510. package/dist/face-character/faceTransferGeometry.d.ts +109 -0
  511. package/dist/face-character/faceTransferSelfTest.d.ts +94 -0
  512. package/dist/face-character/faceWarp3D.d.ts +101 -0
  513. package/dist/face-character/faceless.d.ts +79 -0
  514. package/dist/face-character/featureWarp.d.ts +28 -0
  515. package/dist/face-character/liveFaceRegistry.d.ts +370 -0
  516. package/dist/face-character/liveValue.d.ts +12 -0
  517. package/dist/face-character/memo.d.ts +15 -0
  518. package/dist/face-effects.cjs +2271 -289
  519. package/dist/face-effects.js +14240 -3562
  520. package/dist/face-expression/index.d.ts +182 -0
  521. package/dist/face-info/blendshapes.d.ts +3 -0
  522. package/dist/face-info/derive.d.ts +8 -0
  523. package/dist/face-info/drawFaceCrop.d.ts +10 -0
  524. package/dist/face-info/getFaceInfo.d.ts +8 -0
  525. package/dist/face-info/index.d.ts +8 -0
  526. package/dist/face-info/landmarks.d.ts +35 -0
  527. package/dist/face-info/types.d.ts +69 -0
  528. package/dist/footage-input/index.d.ts +46 -0
  529. package/dist/gestures/definitions.d.ts +98 -0
  530. package/dist/gestures/detector.d.ts +87 -0
  531. package/dist/gestures/index.d.ts +8 -0
  532. package/dist/gestures/measures.d.ts +114 -0
  533. package/dist/gestures/settings.d.ts +49 -0
  534. package/dist/getFaceInfo-BbcKq8PJ.cjs +1 -0
  535. package/dist/getFaceInfo-D_tCSQC7.js +62 -0
  536. package/dist/hand/armFit.d.ts +46 -0
  537. package/dist/hand/armMask.d.ts +190 -0
  538. package/dist/hand/forearm.d.ts +114 -0
  539. package/dist/hand/handCutout.d.ts +23 -0
  540. package/dist/hand/handCutoutRegistry.d.ts +7 -0
  541. package/dist/hand/handEffect.d.ts +38 -0
  542. package/dist/hand/handGestures.d.ts +524 -0
  543. package/dist/{handJoints2d.d.ts → hand/handJoints2d.d.ts} +1 -1
  544. package/dist/hand/handNail.d.ts +73 -0
  545. package/dist/hand/handPose.d.ts +98 -0
  546. package/dist/hand/handRigSolver.d.ts +159 -0
  547. package/dist/hand/handTattoo.d.ts +81 -0
  548. package/dist/hand/handTouch.d.ts +240 -0
  549. package/dist/{handTracking2d.d.ts → hand/handTracking2d.d.ts} +1 -1
  550. package/dist/{handTracking2dController.d.ts → hand/handTracking2dController.d.ts} +1 -1
  551. package/dist/{handTracking3d.d.ts → hand/handTracking3d.d.ts} +1 -1
  552. package/dist/hand/nailImageMask.d.ts +40 -0
  553. package/dist/hand/nailMaskFingers.d.ts +23 -0
  554. package/dist/hand/nailTipRefine.d.ts +37 -0
  555. package/dist/hand/wrist.d.ts +44 -0
  556. package/dist/hand/wristFilter.d.ts +44 -0
  557. package/dist/hooks/faceResults.d.ts +1 -1
  558. package/dist/hooks/selectors.d.ts +77 -4
  559. package/dist/hooks/useBodies.d.ts +39 -0
  560. package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
  561. package/dist/hooks/useFaceAction.d.ts +3 -0
  562. package/dist/hooks/useFaceAttributeExpression.d.ts +16 -0
  563. package/dist/hooks/useFaceDetection.d.ts +18 -0
  564. package/dist/hooks/useFaceInfo.d.ts +19 -0
  565. package/dist/hooks/useFaceInfos.d.ts +15 -0
  566. package/dist/hooks/useFaceModelAcquisition.d.ts +38 -0
  567. package/dist/hooks/useFaceResultReader.d.ts +10 -0
  568. package/dist/hooks/useFrameCapture.d.ts +18 -0
  569. package/dist/hooks/useGesture.d.ts +39 -0
  570. package/dist/hooks/useIrisTracking.d.ts +45 -0
  571. package/dist/hooks/useMediaRecorder.d.ts +14 -2
  572. package/dist/hooks/useOwnedTexture.d.ts +6 -0
  573. package/dist/hooks/useTrackerContext.d.ts +14 -2
  574. package/dist/hooks/useXRDiagnostics.d.ts +81 -0
  575. package/dist/hooks/useXRModel.d.ts +12 -0
  576. package/dist/hooks/useXRSession/facade.d.ts +47 -2
  577. package/dist/hooks/useXRSession/index.d.ts +2 -2
  578. package/dist/hooks/useXRSession/reason.d.ts +21 -0
  579. package/dist/hooks/useXRSession/registry.d.ts +23 -0
  580. package/dist/hooks/useXRSession/store.d.ts +64 -7
  581. package/dist/index-B9DdHE4u.js +442 -0
  582. package/dist/index-Bxb_UcfF.cjs +46 -0
  583. package/dist/index-CNt8esFO.js +240 -0
  584. package/dist/index-CTqQJj5p.js +3814 -0
  585. package/dist/index-CXaj3tOT.js +1108 -0
  586. package/dist/index-CYwAL_d7.cjs +21 -0
  587. package/dist/index-CelqbDSR.cjs +1 -0
  588. package/dist/index-D10O6vqR.js +190 -0
  589. package/dist/index-DIYaENN3.cjs +1 -0
  590. package/dist/index-DlP4xxaT.js +188 -0
  591. package/dist/index-DzdKBXGE.cjs +1 -0
  592. package/dist/index-J3Qy6hi3.cjs +1 -0
  593. package/dist/index-LC2Xs08E.cjs +1 -0
  594. package/dist/index-WkEZBuB4.js +1432 -0
  595. package/dist/instructions.cjs +30 -0
  596. package/dist/instructions.js +1528 -0
  597. package/dist/internal-DS8Pdlsm.cjs +1 -0
  598. package/dist/{internal-Cae1ps15.js → internal-TD4QhIry.js} +152 -127
  599. package/dist/internal.cjs +1 -1
  600. package/dist/internal.js +16 -9
  601. package/dist/iris/compute.d.ts +27 -0
  602. package/dist/iris/index.d.ts +4 -0
  603. package/dist/iris/lead.d.ts +19 -0
  604. package/dist/iris/types.d.ts +89 -0
  605. package/dist/landmarkMask-CvN-L5NT.cjs +1 -0
  606. package/dist/landmarkMask-DHivVjJm.js +225 -0
  607. package/dist/landmarks-BP6RbRHN.cjs +1 -0
  608. package/dist/landmarks-vLy5QKt6.js +76 -0
  609. package/dist/low-level.cjs +1 -1
  610. package/dist/low-level.js +1766 -85
  611. package/dist/main.cjs +1 -73
  612. package/dist/main.js +1299 -1713
  613. package/dist/material/MaterialFill.d.ts +20 -0
  614. package/dist/material/MeshMaterial.d.ts +14 -0
  615. package/dist/material/index.d.ts +2 -0
  616. package/dist/models/Base/index.d.ts +49 -0
  617. package/dist/models/Body/index.d.ts +30 -1
  618. package/dist/models/Face/constants.d.ts +8 -0
  619. package/dist/models/Face/index.d.ts +5 -12
  620. package/dist/models/Face/rotation.d.ts +18 -0
  621. package/dist/models/Hand/GestureTracking.d.ts +1 -1
  622. package/dist/models/Hand/HandTracking.d.ts +17 -1
  623. package/dist/models/Holistic/index.d.ts +49 -0
  624. package/dist/models/Holistic/result.d.ts +68 -0
  625. package/dist/models/Segmentation/index.d.ts +6 -3
  626. package/dist/models/SemanticSegmentation/index.d.ts +31 -0
  627. package/dist/models/SemanticSegmentation/presets.d.ts +28 -0
  628. package/dist/models/index.d.ts +2 -0
  629. package/dist/models/nodeSource.d.ts +9 -0
  630. package/dist/particles/emission.d.ts +24 -0
  631. package/dist/particles/eyes.d.ts +24 -0
  632. package/dist/particles/glsl.d.ts +14 -0
  633. package/dist/particles/index.d.ts +10 -0
  634. package/dist/particles/motion.d.ts +42 -0
  635. package/dist/particles/presets.d.ts +12 -0
  636. package/dist/particles/ring.d.ts +58 -0
  637. package/dist/particles/selfTest.d.ts +53 -0
  638. package/dist/particles/settings.d.ts +127 -0
  639. package/dist/particles/shapes.d.ts +29 -0
  640. package/dist/particles/spawner.d.ts +71 -0
  641. package/dist/particles/system.d.ts +66 -0
  642. package/dist/particles.cjs +122 -0
  643. package/dist/particles.js +999 -0
  644. package/dist/product/ProductDimensions.d.ts +16 -0
  645. package/dist/product/ProductHotspot.d.ts +16 -0
  646. package/dist/product/ProductViewer.d.ts +9 -0
  647. package/dist/product/details.d.ts +53 -0
  648. package/dist/product/index.d.ts +14 -0
  649. package/dist/product/loadModelViewer.d.ts +4 -0
  650. package/dist/product/types.d.ts +71 -0
  651. package/dist/product/useProductAr.d.ts +37 -0
  652. package/dist/product/useProductDetails.d.ts +60 -0
  653. package/dist/product.cjs +1 -0
  654. package/dist/product.js +414 -0
  655. package/dist/providers-BRSbw214.cjs +62 -0
  656. package/dist/providers-DmJlgrDD.js +424 -0
  657. package/dist/quality/XRQualityController.d.ts +25 -0
  658. package/dist/quality/controller.d.ts +33 -0
  659. package/dist/quality/index.d.ts +6 -0
  660. package/dist/quality/types.d.ts +100 -0
  661. package/dist/quality/useXRQuality.d.ts +28 -0
  662. package/dist/render/renderGroups.d.ts +47 -0
  663. package/dist/render/renderPasses.d.ts +26 -0
  664. package/dist/render/sceneBeforeRender.d.ts +12 -0
  665. package/dist/renderGroups-B0N58SIA.cjs +1 -0
  666. package/dist/renderGroups-BcQYy_J2.js +152 -0
  667. package/dist/renderPasses-Bt8k0dkm.cjs +158 -0
  668. package/dist/renderPasses-DIPTIU_x.js +1290 -0
  669. package/dist/renderState-CJNmj5jz.js +39 -0
  670. package/dist/renderState-apSfg4eR.cjs +1 -0
  671. package/dist/scene-object/index.d.ts +146 -0
  672. package/dist/scene-object/runtimeRegistry.d.ts +14 -0
  673. package/dist/scene-object.cjs +1 -0
  674. package/dist/scene-object.js +40 -0
  675. package/dist/{screenImageSettings.d.ts → screen-image/screenImageSettings.d.ts} +9 -2
  676. package/dist/{screenTextSettings.d.ts → screen-text/screenTextSettings.d.ts} +18 -2
  677. package/dist/screen2d/coordinates.d.ts +144 -0
  678. package/dist/screen2d/index.d.ts +3 -0
  679. package/dist/screen2d/screenTransform.d.ts +60 -0
  680. package/dist/screen2d/smoothing.d.ts +5 -0
  681. package/dist/segmentation-CZs5aVvY.js +1911 -0
  682. package/dist/segmentation-Cz7oeNcS.cjs +1 -0
  683. package/dist/segmentation2d/faceMemory.d.ts +28 -0
  684. package/dist/segmentation2d/faceRegions.d.ts +24 -0
  685. package/dist/segmentation2d/index.d.ts +9 -0
  686. package/dist/segmentation2d/maskUv.d.ts +23 -0
  687. package/dist/segmentation2d/rasterize.d.ts +14 -0
  688. package/dist/segmentation2d/types.d.ts +52 -0
  689. package/dist/selectors-Bq6tSgOY.cjs +1 -0
  690. package/dist/selectors-K5JKCWxw.js +196 -0
  691. package/dist/services/MetricsCollector/index.d.ts +7 -1
  692. package/dist/services/MetricsCollector/utils.d.ts +1 -1
  693. package/dist/session-3aCMNb8W.cjs +31 -0
  694. package/dist/session-DHBNTyJJ.js +493 -0
  695. package/dist/settings-BJ7FMBsO.js +111 -0
  696. package/dist/settings-C63FMBlF.cjs +1 -0
  697. package/dist/similarityFit-BFqHND2e.cjs +1 -0
  698. package/dist/similarityFit-Bbz-R8AY.js +91 -0
  699. package/dist/spring/index.d.ts +2 -0
  700. package/dist/spring/spring.d.ts +69 -0
  701. package/dist/spring/swing.d.ts +54 -0
  702. package/dist/subjects/index.d.ts +2 -0
  703. package/dist/subjects/select.d.ts +70 -0
  704. package/dist/subjects/types.d.ts +59 -0
  705. package/dist/texture/animatedTexture.d.ts +63 -0
  706. package/dist/texture/animationMath.d.ts +8 -0
  707. package/dist/texture/gifReader.d.ts +17 -0
  708. package/dist/texture/gifTextureSource.d.ts +16 -0
  709. package/dist/texture/sourceResolver.d.ts +30 -0
  710. package/dist/textures-BVwo9Z7z.js +38 -0
  711. package/dist/textures-DAfc61zz.cjs +1 -0
  712. package/dist/tracking/coordinates.d.ts +5 -0
  713. package/dist/tracking-config/apply.d.ts +57 -0
  714. package/dist/tracking-config/index.d.ts +7 -0
  715. package/dist/tracking-config/resolve.d.ts +25 -0
  716. package/dist/tracking-config/storage.d.ts +8 -0
  717. package/dist/tracking-config/types.d.ts +106 -0
  718. package/dist/tracking-config/useXRTrackingConfig.d.ts +38 -0
  719. package/dist/tracking.cjs +10 -1
  720. package/dist/tracking.js +1529 -317
  721. package/dist/trigger-BwZ81ENx.js +3726 -0
  722. package/dist/trigger-UjeJY5uh.cjs +147 -0
  723. package/dist/types/common.d.ts +11 -1
  724. package/dist/types/compositor.d.ts +21 -0
  725. package/dist/types/face.d.ts +21 -14
  726. package/dist/types/gesture-tracking.d.ts +2 -2
  727. package/dist/types/hand-tracking.d.ts +12 -3
  728. package/dist/types/holistic.d.ts +121 -0
  729. package/dist/types/index.d.ts +1 -1
  730. package/dist/types/model.d.ts +22 -2
  731. package/dist/types/nodes.d.ts +81 -6
  732. package/dist/types/segmentation.d.ts +26 -0
  733. package/dist/types/session.d.ts +50 -4
  734. package/dist/types/tracking.d.ts +8 -2
  735. package/dist/types/util-types.d.ts +1 -1
  736. package/dist/useBodies-BMKHXAOL.js +75 -0
  737. package/dist/useBodies-CXomEo0i.cjs +1 -0
  738. package/dist/useFaceInfo-BEMMiZxw.cjs +1 -0
  739. package/dist/useFaceInfo-BNVdnprN.js +75 -0
  740. package/dist/useFaceResultReader-B15wn6RB.js +61 -0
  741. package/dist/useFaceResultReader-D9qibKmm.cjs +1 -0
  742. package/dist/useInstructionHold-DOu-RpCM.js +53 -0
  743. package/dist/useInstructionHold-DwJY1Alr.cjs +1 -0
  744. package/dist/useIrisTracking-CYm-KDIZ.js +6190 -0
  745. package/dist/useIrisTracking-DExhnhlt.cjs +35 -0
  746. package/dist/useLandmarkPoseFit-Bg-h9BPb.cjs +1 -0
  747. package/dist/useLandmarkPoseFit-Bmb3h6Mw.js +87 -0
  748. package/dist/useXRCapabilities-ClWlG5_Y.js +30 -0
  749. package/dist/useXRCapabilities-D-EhcDzM.cjs +1 -0
  750. package/dist/utils/canonicalRigidLandmarks.d.ts +8 -0
  751. package/dist/utils/drawNormalizedCrop.d.ts +22 -0
  752. package/dist/utils/fns.d.ts +6 -3
  753. package/dist/utils/headOccluderFit.d.ts +42 -0
  754. package/dist/utils/integrity.d.ts +25 -26
  755. package/dist/utils/landmarkBounds.d.ts +1 -1
  756. package/dist/utils/logger.d.ts +2 -2
  757. package/dist/utils/resolveNumFaces.d.ts +13 -0
  758. package/dist/utils/shoulderOccluderFit.d.ts +38 -0
  759. package/dist/utils/similarityFit.d.ts +23 -0
  760. package/dist/utils/updateThrottle.d.ts +2 -0
  761. package/dist/utils/useEditOverrides.d.ts +26 -0
  762. package/dist/utils/useStableUniforms.d.ts +18 -0
  763. package/dist/utils/visionWasm.d.ts +18 -0
  764. package/dist/uv-BMFt19bg.cjs +1 -0
  765. package/dist/{index-BGNbrc4C.js → uv-DJU_XfmN.js} +15 -156
  766. package/docs/MIGRATION_GUIDE.md +589 -0
  767. package/docs/SDK_DOCUMENTATION.md +1157 -0
  768. package/docs/api/adaptive-quality.mdx +104 -0
  769. package/docs/api/asset-lifecycle.mdx +78 -0
  770. package/docs/api/audio.mdx +36 -0
  771. package/docs/api/behavior-components.mdx +164 -0
  772. package/docs/api/body-instructions.mdx +287 -0
  773. package/docs/api/body-rig.mdx +384 -0
  774. package/docs/api/body-triggers.mdx +235 -0
  775. package/docs/api/camera-permission.mdx +142 -0
  776. package/docs/api/capture-recording.mdx +111 -0
  777. package/docs/api/coordinate-spaces.mdx +168 -0
  778. package/docs/api/cross-camera.mdx +89 -0
  779. package/docs/api/debug-ui-scene-editor.mdx +270 -0
  780. package/docs/api/diagnostics-calibration.mdx +97 -0
  781. package/docs/api/external-face-mesh.mdx +231 -0
  782. package/docs/api/face-actions.mdx +108 -0
  783. package/docs/api/face-attribute-expression.mdx +87 -0
  784. package/docs/api/face-binding-anchors.mdx +55 -0
  785. package/docs/api/face-character.mdx +157 -0
  786. package/docs/api/face-effects.mdx +28 -0
  787. package/docs/api/face-expression-controller.mdx +153 -0
  788. package/docs/api/face-info.mdx +118 -0
  789. package/docs/api/face-inset.mdx +204 -0
  790. package/docs/api/face-instructions.mdx +183 -0
  791. package/docs/api/face-liquify.mdx +196 -0
  792. package/docs/api/face-mesh.mdx +130 -0
  793. package/docs/api/face-morph.mdx +117 -0
  794. package/docs/api/face-painting.mdx +40 -0
  795. package/docs/api/face-reprojection.mdx +154 -0
  796. package/docs/api/face-retouching.mdx +81 -0
  797. package/docs/api/face-swap.mdx +350 -0
  798. package/docs/api/face-warp-3d.mdx +166 -0
  799. package/docs/api/faceless.mdx +143 -0
  800. package/docs/api/gestures.mdx +210 -0
  801. package/docs/api/hair.mdx +97 -0
  802. package/docs/api/hand-instructions.mdx +222 -0
  803. package/docs/api/hand-rig.mdx +661 -0
  804. package/docs/api/hand-touch.mdx +162 -0
  805. package/docs/api/head-occluder.mdx +563 -0
  806. package/docs/api/holistic-tracker.mdx +164 -0
  807. package/docs/api/instructions.mdx +323 -0
  808. package/docs/api/iris-tracking.mdx +247 -0
  809. package/docs/api/made-up-camera.mdx +131 -0
  810. package/docs/api/makeup-skin-tone.mdx +135 -0
  811. package/docs/api/makeup.mdx +353 -0
  812. package/docs/api/material-render-state.mdx +132 -0
  813. package/docs/api/multi-subject.mdx +185 -0
  814. package/docs/api/particles.mdx +183 -0
  815. package/docs/api/person-cutout.mdx +171 -0
  816. package/docs/api/pin-to-face-mesh.mdx +274 -0
  817. package/docs/api/product-ar.mdx +114 -0
  818. package/docs/api/product-details.mdx +78 -0
  819. package/docs/api/runtime-3d.mdx +316 -0
  820. package/docs/api/scene-object-store.mdx +213 -0
  821. package/docs/api/screen-image.mdx +67 -0
  822. package/docs/api/screen-shape.mdx +64 -0
  823. package/docs/api/screen-space-coordinates.mdx +83 -0
  824. package/docs/api/screen-text.mdx +39 -0
  825. package/docs/api/segmentation-overlay.mdx +301 -0
  826. package/docs/api/session-lifecycle.mdx +165 -0
  827. package/docs/api/texture-sources.mdx +74 -0
  828. package/docs/api/trackers.mdx +65 -0
  829. package/docs/api/tracking-config.mdx +108 -0
  830. package/docs/docs.json +121 -0
  831. package/docs/examples/lip-shaders.mdx +273 -0
  832. package/docs/examples/scene-object-recipes.mdx +194 -0
  833. package/docs/guides/face-atlas-template.svg +1 -0
  834. package/docs/guides/face-atlas-textures.mdx +186 -0
  835. package/docs/guides/face-texture-template.svg +1 -0
  836. package/docs/guides/harness-debug-ui.mdx +139 -0
  837. package/docs/guides/lip-effect-textures.mdx +368 -0
  838. package/docs/guides/lip-uv-template.png +0 -0
  839. package/docs/guides/lip-uv-template.svg +1 -0
  840. package/docs/guides/makeup-design-textures.mdx +109 -0
  841. package/docs/inspector/hierarchy-panel.mdx +51 -0
  842. package/docs/inspector/object-inspector-panel.mdx +51 -0
  843. package/docs/introduction.mdx +120 -0
  844. package/docs/scene-objects/overview.mdx +127 -0
  845. package/docs/scene-objects/render-groups.mdx +77 -0
  846. package/docs/scene-objects/runtime-rendering.mdx +75 -0
  847. package/docs/texture-api-consumer.md +84 -0
  848. package/package.json +69 -9
  849. package/settings.json +2049 -0
  850. package/dist/DebuggerUI-CatYc-RG.cjs +0 -1
  851. package/dist/DebuggerUI-gLMKiVwJ.js +0 -269
  852. package/dist/MediaSourceSwitcher-C-xYg0nQ.js +0 -317
  853. package/dist/MediaSourceSwitcher-Cq3g4IKw.cjs +0 -31
  854. package/dist/components/FaceRetouch/defaults.d.ts +0 -13
  855. package/dist/components/FaceRetouch/retouchRegions.d.ts +0 -23
  856. package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +0 -12
  857. package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +0 -15
  858. package/dist/components/FaceWarp3D/defaults.d.ts +0 -37
  859. package/dist/components/FaceWarp3D/warp.d.ts +0 -13
  860. package/dist/debug-ui/face-warp-3d/index.d.ts +0 -6
  861. package/dist/defaults-BLpcN3pG.cjs +0 -1
  862. package/dist/defaults-LtY4M7dg.js +0 -55
  863. package/dist/index-BXyObVHF.cjs +0 -1
  864. package/dist/index-CY3bUAcW.js +0 -12
  865. package/dist/index-C_Duh13c.cjs +0 -1
  866. package/dist/index-D8fpPQkC.cjs +0 -1
  867. package/dist/index-DxshgBu0.cjs +0 -1
  868. package/dist/index-O-2crZ3M.js +0 -1102
  869. package/dist/index-safCs_af.js +0 -1341
  870. package/dist/internal-BjyhBP8i.cjs +0 -1
  871. package/dist/modules/XRClient/index.d.ts +0 -9
  872. package/dist/modules/index.d.ts +0 -1
  873. package/dist/screenImageSettings-6NRg4cx9.js +0 -39
  874. package/dist/screenImageSettings-y_B4_767.cjs +0 -1
  875. package/dist/selectors-BLl2JUWW.cjs +0 -1
  876. package/dist/selectors-CXd_x-6t.js +0 -59
  877. package/dist/services/ApiService.d.ts +0 -12
  878. package/dist/types/client.d.ts +0 -3
  879. package/dist/useFaceResults-cpsSmKKc.js +0 -81
  880. package/dist/useFaceResults-hVUJYSEY.cjs +0 -1
  881. package/dist/useXRModel-3DcUa28n.cjs +0 -1
  882. package/dist/useXRModel-BMJE1hrk.js +0 -28
  883. /package/dist/{layerStack.d.ts → render/layerStack.d.ts} +0 -0
  884. /package/dist/{screenImagePresets.d.ts → screen-image/screenImagePresets.d.ts} +0 -0
  885. /package/dist/{screenTextPresets.d.ts → screen-text/screenTextPresets.d.ts} +0 -0
@@ -0,0 +1,3726 @@
1
+ var Ls = Object.defineProperty;
2
+ var Hs = (t, e, n) => e in t ? Ls(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var B = (t, e, n) => Hs(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { useCallback as Kn, useMemo as K, createContext as oe, useRef as st, useEffect as Z, useContext as qt, useState as Vs } from "react";
5
+ import { p as Bs, u as Fs } from "./useFaceResultReader-B15wn6RB.js";
6
+ import { jsx as at, jsxs as ie, Fragment as Ws } from "react/jsx-runtime";
7
+ import { useThree as Ot, useFrame as ye, createPortal as Pe } from "@react-three/fiber";
8
+ import * as c from "three";
9
+ import { e as ut, j as Et, aE as $e, B as m, t as Jt, J as re, H as Je, A as Us, k as Ps } from "./index-CTqQJj5p.js";
10
+ import { c as Yn } from "./SkeletonUtils-C2r90MtN.js";
11
+ import { b as te, f as $n } from "./selectors-K5JKCWxw.js";
12
+ import { u as qs } from "./useBodies-BMKHXAOL.js";
13
+ import { a as de, s as Xe, L as Cs } from "./useLandmarkPoseFit-Bmb3h6Mw.js";
14
+ import { R as zs } from "./uv-DJU_XfmN.js";
15
+ import { u as ee } from "./landmarks-vLy5QKt6.js";
16
+ import { S as be } from "./providers-DmJlgrDD.js";
17
+ import { b as js, y as Gs, z as Qs, H as Ze, v as Ks, x as Ys, o as $s, B as tn, k as Js, a as Xs, e as ft, r as Jn, m as Zs } from "./index-B9DdHE4u.js";
18
+ import { g as to, r as en, c as eo, s as Xn, a as no } from "./detector-K8aej4MB.js";
19
+ const _a = ({
20
+ node: t,
21
+ enabled: e,
22
+ selectedSource: n,
23
+ throttleMs: s = 16,
24
+ holdMs: o = 250,
25
+ onFrame: i
26
+ }) => {
27
+ const r = Kn(
28
+ (a) => Bs(a.faceLandmarks ?? []),
29
+ [n]
30
+ );
31
+ return Fs({ enabled: e, holdMs: o, node: t, onFrame: i, prepare: r, throttleMs: s });
32
+ }, so = 7, nn = 1, oo = 3, io = Object.freeze({
33
+ along: Object.freeze([2, 4, 6, 8]),
34
+ widthAt: 1.5,
35
+ maxWidth: 11,
36
+ minWidth: 2.5,
37
+ maxTurn: 95
38
+ }), Zn = (t, e, n) => {
39
+ const { image: s, world: o } = t;
40
+ if (s.length < 21 || o.length < 21) return null;
41
+ const i = (E) => (s[E].x + 1) / 2 * e, r = (E) => (1 - s[E].y) / 2;
42
+ let a = 0, l = 0, h = 0, u = 0;
43
+ const f = 21;
44
+ for (let E = 0; E < f; E += 1)
45
+ a += i(E), l += r(E), h += o[E].x, u -= o[E].y;
46
+ a /= f, l /= f, h /= f, u /= f;
47
+ let d = 0, g = 0, M = 0;
48
+ for (let E = 0; E < f; E += 1) {
49
+ const R = o[E].x - h, J = -o[E].y - u, H = i(E) - a, C = r(E) - l;
50
+ d += R * H + J * C, g += R * C - J * H, M += R * R + J * J;
51
+ }
52
+ const _ = Math.hypot(d, g) / Math.max(M, 1e-12), w = ut.wrist, x = ut.middleMcp, L = i(w) - i(x), V = r(w) - r(x), N = Math.hypot(L, V), W = Math.hypot(
53
+ o[w].x - o[x].x,
54
+ o[w].y - o[x].y,
55
+ o[w].z - o[x].z
56
+ );
57
+ if (!(_ > 0)) return null;
58
+ if (N < 0.3 * W * _) {
59
+ if (!n) return null;
60
+ const E = Math.hypot(n.x, n.y) || 1;
61
+ return {
62
+ wrist: { x: i(w), y: r(w) },
63
+ toElbow: { x: n.x / E, y: n.y / E },
64
+ unitsPerCm: _,
65
+ aspect: e,
66
+ guessed: !0
67
+ };
68
+ }
69
+ return {
70
+ wrist: { x: i(w), y: r(w) },
71
+ toElbow: { x: L / N, y: V / N },
72
+ unitsPerCm: _,
73
+ aspect: e
74
+ };
75
+ }, _t = (t, e, n) => ({ x: t.x + e.x * n, y: t.y + e.y * n }), ro = (t, e, n = {}) => {
76
+ const s = { ...io, ...n }, { wrist: o, toElbow: i, unitsPerCm: r, aspect: a } = e, { width: l, height: h } = t;
77
+ if (l <= 0 || h <= 0 || !(r > 0)) return null;
78
+ const u = Math.min(1 / h, a / l), f = s.maxWidth * r, d = s.minWidth * r, g = (y) => {
79
+ const k = y.x / a, p = y.y;
80
+ return k < 0 || p < 0 || k >= 1 || p >= 1 ? null : t.inside(Math.floor(p * h) * l + Math.floor(k * l));
81
+ }, M = (y, k) => {
82
+ if (g(y) === null) return null;
83
+ const p = { x: -k.y, y: k.x };
84
+ let v = null;
85
+ for (let j = 0; j * u <= f / 2; j += 1) {
86
+ if (g(_t(y, p, j * u))) {
87
+ v = j * u;
88
+ break;
89
+ }
90
+ if (j > 0 && g(_t(y, p, -j * u))) {
91
+ v = -j * u;
92
+ break;
93
+ }
94
+ }
95
+ if (v === null) return null;
96
+ let b = !1, T = !1;
97
+ const A = (j) => {
98
+ let Q = v;
99
+ for (; ; ) {
100
+ const $ = g(_t(y, p, Q + j * u));
101
+ if ($ === null)
102
+ return b = !0, T = !0, Q;
103
+ if (!$) return Q;
104
+ if (Q += j * u, Math.abs(Q - v) > f)
105
+ return b = !0, Q;
106
+ }
107
+ }, D = A(-1), F = A(1), I = F - D + u;
108
+ return {
109
+ mid: _t(y, p, (D + F) / 2),
110
+ width: I,
111
+ a: _t(y, p, D),
112
+ b: _t(y, p, F),
113
+ ok: !b && I >= d && I <= f,
114
+ cut: T
115
+ };
116
+ }, _ = (y, k) => k.map((p) => M(_t(o, y, p * r), y)), w = (y) => {
117
+ const k = _(y, s.along), p = k.filter((I) => I == null ? void 0 : I.ok).length, v = k.some((I) => I === null || I.cut);
118
+ if (p >= 2 || !v) return k;
119
+ const b = Math.max(...s.along), T = [];
120
+ for (let I = nn; I <= b; I += nn) T.push(I);
121
+ const A = _(y, T), D = A.filter((I) => I == null ? void 0 : I.ok).length, F = T.filter((I, q) => {
122
+ var j;
123
+ return (j = A[q]) == null ? void 0 : j.ok;
124
+ }).pop() ?? 0;
125
+ return D > p && F >= oo ? A : k;
126
+ }, x = (y) => {
127
+ const k = [o, ...y.filter((I) => !!(I != null && I.ok)).map((I) => I.mid)];
128
+ if (k.length < 3) return null;
129
+ const p = k.reduce((I, q) => I + q.x, 0) / k.length, v = k.reduce((I, q) => I + q.y, 0) / k.length;
130
+ let b = 0, T = 0, A = 0;
131
+ for (const I of k)
132
+ b += (I.x - p) ** 2, T += (I.x - p) * (I.y - v), A += (I.y - v) ** 2;
133
+ const D = 0.5 * Math.atan2(2 * T, b - A), F = { x: Math.cos(D), y: Math.sin(D) };
134
+ return F.x * i.x + F.y * i.y < 0 ? { x: -F.x, y: -F.y } : F;
135
+ }, L = s.maxTurn * Math.PI / 180, V = (y) => Math.atan2(i.x * y.y - i.y * y.x, i.x * y.x + i.y * y.y), N = (y) => ({
136
+ x: i.x * Math.cos(y) - i.y * Math.sin(y),
137
+ y: i.x * Math.sin(y) + i.y * Math.cos(y)
138
+ }), E = w((() => {
139
+ const y = L + 40 * Math.PI / 180, k = so * r, p = Math.min(1 * Math.PI / 180, u / k), v = Math.ceil(y / p), b = [];
140
+ let T = null;
141
+ for (let I = -v; I <= v + 1; I += 1) {
142
+ const q = I * p, j = I <= v && g(_t(o, N(q), k)) === !0;
143
+ j && T === null && (T = q), !j && T !== null && (T > -v * p && q <= v * p && b.push([T, q - p]), T = null);
144
+ }
145
+ const A = ([I, q]) => (q - I) * k, D = b.filter((I) => A(I) >= d && A(I) <= f * 1.5);
146
+ if (!D.length) return null;
147
+ const F = D.reduce(
148
+ (I, q) => Math.abs((q[0] + q[1]) / 2) < Math.abs((I[0] + I[1]) / 2) ? q : I
149
+ );
150
+ return N((F[0] + F[1]) / 2);
151
+ })() ?? i);
152
+ let R = x(E);
153
+ if (!R || Math.abs(V(R)) > L) return null;
154
+ const J = w(R), H = x(J);
155
+ H && Math.abs(V(H)) <= L && (R = H);
156
+ const C = H ? J : E, tt = C.filter((y) => !!(y != null && y.ok)), Y = M(_t(o, R, s.widthAt * r), R), ot = tt.map((y) => y.width);
157
+ Y != null && Y.ok && ot.push(Y.width), ot.sort((y, k) => y - k);
158
+ const z = ot[ot.length >> 1], rt = Y != null && Y.ok ? Y.mid : _t(o, R, s.widthAt * r), S = C.filter((y) => !!y).map(({ a: y, b: k, ok: p }) => ({ a: y, b: k, ok: p }));
159
+ return Y && S.push({ a: Y.a, b: Y.b, ok: Y.ok }), {
160
+ direction: R,
161
+ bend: V(R),
162
+ width: z / r,
163
+ center: rt,
164
+ confidence: tt.length / Math.max(1, s.along.length),
165
+ sections: S
166
+ };
167
+ }, ts = Object.freeze({
168
+ smoothing: 0.4,
169
+ holdMs: 150,
170
+ fadeMs: 250,
171
+ maxSkewMs: 70,
172
+ maxShift: 2
173
+ }), ao = 24, lo = 0.5, co = Math.cos(3 * Math.PI / 180);
174
+ class ho {
175
+ constructor(e = {}) {
176
+ /** Radians, clockwise on screen, from the hand's axis to the arm's. */
177
+ B(this, "bend", 0);
178
+ /** The arm's width, cm (null until measured). */
179
+ B(this, "width", null);
180
+ /** How far the arm's middle is from the hand's axis, across it, cm (+ = clockwise side). */
181
+ B(this, "shift", 0);
182
+ /** 0..1, how much of the fit applies (found, held or fading). */
183
+ B(this, "weight", 0);
184
+ /** 0..1, how sure the measures are (closed cross-sections, eased): blends the fit with the hand. */
185
+ B(this, "confidence", 0);
186
+ /** The last measure, for drawing. */
187
+ B(this, "last", null);
188
+ B(this, "settings");
189
+ B(this, "history", []);
190
+ /** There is a fit (measured, not yet faded out). */
191
+ B(this, "found", !1);
192
+ /** When a mask first came without the arm since the last fit. */
193
+ B(this, "lostAtMs", null);
194
+ this.settings = { ...ts, ...e };
195
+ }
196
+ /**
197
+ * The hand's query at a detection (`HandPose.timestampMs`); `null` when the
198
+ * hand's axis can't be used (it points at the camera): `query` reads null
199
+ * then, and nothing steers by an old axis.
200
+ */
201
+ pushHand(e, n) {
202
+ const s = this.history[this.history.length - 1];
203
+ s && s.timeMs === e || (this.history.push({ timeMs: e, query: n }), this.history.length > ao && this.history.shift());
204
+ }
205
+ /** The newest hand query (the hand now), null while its axis is unusable. */
206
+ get query() {
207
+ var e;
208
+ return ((e = this.history[this.history.length - 1]) == null ? void 0 : e.query) ?? null;
209
+ }
210
+ /**
211
+ * The hand hasn't moved over the kept history (within 0.5 cm and 3°): any
212
+ * of its poses matches a mask from within that time.
213
+ */
214
+ still() {
215
+ const e = this.query;
216
+ if (!e || this.history.length < 2) return !1;
217
+ const n = lo * e.unitsPerCm;
218
+ return this.history.every(
219
+ ({ query: s }) => !!s && Math.hypot(s.wrist.x - e.wrist.x, s.wrist.y - e.wrist.y) <= n && s.toElbow.x * e.toElbow.x + s.toElbow.y * e.toElbow.y >= co
220
+ );
221
+ }
222
+ /**
223
+ * Measures a new mask (taken at `maskTimeMs`, or now when unknown) against
224
+ * the hand from the same moment (or the newest, while the hand is still).
225
+ * Returns the measure, or null when the arm wasn't found (that starts the
226
+ * hold, then the fade) or no hand pose matches the mask's time (nothing
227
+ * changes: wait for the next mask).
228
+ */
229
+ measure(e, n, s = {}) {
230
+ const o = this.history.filter((g) => g.query !== null), i = o[o.length - 1];
231
+ let r = n === void 0 ? i : o.reduce(
232
+ (g, M) => !g || Math.abs(M.timeMs - n) < Math.abs(g.timeMs - n) ? M : g,
233
+ void 0
234
+ );
235
+ if (!r) return null;
236
+ if (n !== void 0 && Math.abs(r.timeMs - n) > this.settings.maxSkewMs) {
237
+ const g = this.history[0];
238
+ if (!g || g.timeMs > n || !this.still()) return null;
239
+ r = i;
240
+ }
241
+ const a = ro(e, r.query, s);
242
+ if (this.last = a, !a)
243
+ return this.found && this.lostAtMs === null && (this.lostAtMs = n ?? r.timeMs), null;
244
+ const { wrist: l, unitsPerCm: h } = r.query, u = ((a.center.x - l.x) * -a.direction.y + (a.center.y - l.y) * a.direction.x) / h, f = Math.max(-this.settings.maxShift, Math.min(this.settings.maxShift, u)), d = this.found ? Math.min(1, Math.max(0.01, this.settings.smoothing)) : 1;
245
+ return this.bend += (a.bend - this.bend) * d, this.confidence += (a.confidence - this.confidence) * d, this.width = this.width === null ? a.width : this.width + (a.width - this.width) * d, this.shift += (f - this.shift) * d, this.found = !0, this.lostAtMs = null, a;
246
+ }
247
+ /**
248
+ * Advances the hold and fade (call every frame with `performance.now()`).
249
+ * A fit holds until a mask comes without the arm, then for `holdMs`, then
250
+ * fades over `fadeMs`; no new mask changes nothing.
251
+ */
252
+ step(e) {
253
+ if (!this.found) {
254
+ this.weight = 0;
255
+ return;
256
+ }
257
+ const n = this.lostAtMs === null ? -1 / 0 : e - this.lostAtMs - this.settings.holdMs;
258
+ this.weight = n <= 0 ? 1 : Math.max(0, 1 - n / Math.max(1, this.settings.fadeMs)), this.weight === 0 && this.clear();
259
+ }
260
+ clear() {
261
+ this.found = !1, this.lostAtMs = null, this.confidence = 0, this.bend = 0, this.shift = 0, this.width = null, this.weight = 0;
262
+ }
263
+ /** Forget everything (the hand was lost). */
264
+ reset() {
265
+ this.history.length = 0, this.clear(), this.last = null;
266
+ }
267
+ }
268
+ const uo = 15, Fe = (t) => {
269
+ ee(Et.BACKGROUND_SEGMENTATION, { type: "portrait" }, t === "portrait"), ee(Et.SEMANTIC_SEGMENTATION, { preset: "multiclass" }, t === "skin");
270
+ const e = te(Et.BACKGROUND_SEGMENTATION), n = te(Et.SEMANTIC_SEGMENTATION);
271
+ return K(() => {
272
+ if (!t) return null;
273
+ let s = 0, o = 0, i = 0, r, a = -1 / 0, l = null, h = null, u = null, f = -1, d = -1;
274
+ return {
275
+ kind: t,
276
+ get width() {
277
+ return s;
278
+ },
279
+ get height() {
280
+ return o;
281
+ },
282
+ get version() {
283
+ return i;
284
+ },
285
+ get timestampMs() {
286
+ return r;
287
+ },
288
+ // The portrait segmenter's category mask reads 0 on the person, 255 on
289
+ // the background (see `usePersonMask`).
290
+ inside: t === "portrait" ? (g) => l !== null && l[g] <= 127 : (g) => u !== null && u[g] === f,
291
+ refresh: (g) => {
292
+ var _;
293
+ if (t === "portrait") {
294
+ if (!e || g - a < 1e3 / uo) return !1;
295
+ const w = (_ = e.getRawSegmentationData) == null ? void 0 : _.call(e);
296
+ return !(w != null && w.maskData) || w === h || w.width <= 0 ? !1 : (a = g, h = w, l = w.maskData, s = w.width, o = w.height, r = w.timestampMs, i += 1, !0);
297
+ }
298
+ const M = n == null ? void 0 : n.getMask();
299
+ return !M || M.version === 0 || M.version === d ? !1 : (d = M.version, f = M.labels.indexOf("body_skin"), u = M.indices, s = M.width, o = M.height, r = M.timestampMs, i += 1, f >= 0);
300
+ }
301
+ };
302
+ }, [t, e, n]);
303
+ }, O = {
304
+ c: new c.Vector3(),
305
+ y: new c.Vector3(),
306
+ p: new c.Vector3(),
307
+ ndc: new c.Vector3(),
308
+ axis: new c.Vector3(),
309
+ q: new c.Quaternion(),
310
+ m: new c.Matrix4(),
311
+ t: new c.Matrix4(),
312
+ turned: new c.Matrix4(),
313
+ a: { x: 0, y: 0 },
314
+ b: { x: 0, y: 0 }
315
+ }, ne = (t, e, n, s = { x: 0, y: 0 }) => (O.ndc.copy(t).project(e), s.x = (O.ndc.x + 1) / 2 * n, s.y = (1 - O.ndc.y) / 2, s), po = (t, e) => Math.atan2(t.x * e.y - t.y * e.x, t.x * e.x + t.y * e.y), es = (t, e, n, s = { x: 0, y: 0 }) => {
316
+ O.c.setFromMatrixPosition(t), O.y.setFromMatrixColumn(t, 1).normalize(), ne(O.c, e, n, O.a);
317
+ const o = Math.max(1e-4, O.c.distanceTo(e.position) * 1e-3);
318
+ ne(O.p.copy(O.c).addScaledVector(O.y, -o), e, n, O.b);
319
+ const i = O.b.x - O.a.x, r = O.b.y - O.a.y, a = Math.hypot(i, r) || 1;
320
+ return s.x = i / a, s.y = r / a, s;
321
+ }, ns = (t, e, n) => {
322
+ O.c.setFromMatrixPosition(t);
323
+ const s = Math.max(1e-4, O.c.distanceTo(e.position) * 1e-3);
324
+ ne(O.c, e, n, O.a);
325
+ const o = (h) => (O.y.setFromMatrixColumn(t, h).normalize(), ne(O.p.copy(O.c).addScaledVector(O.y, s), e, n, O.b), Math.hypot(O.b.x - O.a.x, O.b.y - O.a.y)), i = o(1), r = Math.max(o(0), o(2), 1e-12), a = i / r, l = Math.min(1, Math.max(0, (a - sn) / (fo - sn)));
326
+ return l * l * (3 - 2 * l);
327
+ }, sn = 0.25, fo = 0.45, mo = (t, e, n, s, o, i) => {
328
+ const r = -s.y, a = s.x;
329
+ let l = 1 / 0, h = -1 / 0;
330
+ for (let u = 0; u < 24; u += 1) {
331
+ const f = u / 24 * Math.PI * 2;
332
+ O.p.set(e * Math.cos(f), 0, n * Math.sin(f)).applyMatrix4(t), ne(O.p, o, i, O.a);
333
+ const d = O.a.x * r + O.a.y * a;
334
+ l = Math.min(l, d), h = Math.max(h, d);
335
+ }
336
+ return h - l;
337
+ }, on = (t, e, n, s, o, i) => {
338
+ const r = Math.min(1, Math.max(0, o));
339
+ if (r === 0)
340
+ return i.copy(t), 1;
341
+ const a = es(t, e, n, { x: 0, y: 0 }), l = po(a, s.up) * r * ns(t, e, n);
342
+ if (O.c.setFromMatrixPosition(t), O.axis.copy(O.c).sub(e.getWorldPosition(O.p)).normalize(), e.isOrthographicCamera && e.getWorldDirection(O.axis), O.q.setFromAxisAngle(O.axis, l), O.m.makeRotationFromQuaternion(O.q), O.t.makeTranslation(O.c.x, O.c.y, O.c.z), O.turned.copy(O.t).multiply(O.m), O.t.makeTranslation(-O.c.x, -O.c.y, -O.c.z), O.turned.multiply(O.t).multiply(t), s.shift !== 0) {
343
+ O.ndc.copy(O.c).project(e);
344
+ const u = -s.up.y * s.shift * r, f = s.up.x * s.shift * r;
345
+ O.p.set(O.ndc.x + u * 2 / n, O.ndc.y - f * 2, O.ndc.z).unproject(e).sub(O.c), O.t.makeTranslation(O.p.x, O.p.y, O.p.z), O.turned.premultiply(O.t);
346
+ }
347
+ i.copy(O.turned);
348
+ let h = 1;
349
+ if (s.width !== null && s.width > 0) {
350
+ const u = mo(
351
+ O.turned,
352
+ s.halfWidth,
353
+ s.halfDepth,
354
+ s.up,
355
+ e,
356
+ n
357
+ );
358
+ if (u > 1e-9) {
359
+ const [f, d] = s.scaleRange ?? [0.85, 1.2];
360
+ h = 1 + (Math.min(d, Math.max(f, s.width / u)) - 1) * r;
361
+ }
362
+ }
363
+ return h;
364
+ }, go = 1.45, yo = 1.45, wo = 1.75, rn = 0.7, ss = Object.freeze({
365
+ /** Palm-ward bend (flexion). */
366
+ flexion: 70 * Math.PI / 180,
367
+ /** Back-ward bend (extension). */
368
+ extension: 70 * Math.PI / 180,
369
+ /** Toward the thumb (radial deviation). */
370
+ radial: 20 * Math.PI / 180,
371
+ /** Toward the little finger (ulnar deviation). */
372
+ ulnar: 30 * Math.PI / 180,
373
+ /** Forearm roll either way about its long axis (pronation / supination). */
374
+ roll: 80 * Math.PI / 180
375
+ }), Ea = (t, e) => ({
376
+ length: t * go,
377
+ wrist: { width: e.width, depth: e.depth },
378
+ elbow: {
379
+ width: e.width * yo,
380
+ depth: e.depth * wo
381
+ }
382
+ }), ka = (t) => {
383
+ const e = t[ut.wrist], n = t[ut.middleTip];
384
+ return Math.hypot(n.x - e.x, n.y - e.y, n.z - e.z);
385
+ }, Ra = (t, e, n = { width: 0, depth: 0 }) => {
386
+ const s = Math.min(1, Math.max(0, e)), o = s <= rn ? s / rn : 1, i = o * o * (3 - 2 * o);
387
+ return n.width = t.wrist.width + (t.elbow.width - t.wrist.width) * i, n.depth = t.wrist.depth + (t.elbow.depth - t.wrist.depth) * i, n;
388
+ }, Mo = { d: new c.Vector3() }, os = (t, e = { flexion: 0, deviation: 0 }) => {
389
+ const n = Mo.d.copy(t).normalize();
390
+ return e.flexion = Math.atan2(n.z, -n.y), e.deviation = Math.atan2(n.x, Math.hypot(n.y, n.z)), e;
391
+ }, xo = (t, e = new c.Vector3()) => {
392
+ const n = Math.cos(t.deviation);
393
+ return e.set(
394
+ Math.sin(t.deviation),
395
+ -n * Math.cos(t.flexion),
396
+ n * Math.sin(t.flexion)
397
+ );
398
+ }, vo = (t, e = ss, n = { flexion: 0, deviation: 0 }) => (n.flexion = Math.min(e.flexion, Math.max(-e.extension, t.flexion)), n.deviation = Math.min(e.radial, Math.max(-e.ulnar, t.deviation)), n), an = { bend: { flexion: 0, deviation: 0 } }, So = (t, e = ss, n = new c.Vector3()) => xo(
399
+ vo(os(t, an.bend), e, an.bend),
400
+ n
401
+ ), bo = 0.9, Ao = 0.7, is = (t) => {
402
+ const e = t.restPositions, n = e[ut.indexMcp].distanceTo(e[ut.pinkyMcp]), s = e[ut.wrist].distanceTo(e[ut.middleMcp]), o = n * bo;
403
+ return { width: o, depth: o * Ao, palmWidth: n, palmLength: s };
404
+ }, ht = {
405
+ inv: new c.Quaternion(),
406
+ x: new c.Vector3(),
407
+ y: new c.Vector3(),
408
+ z: new c.Vector3(),
409
+ basis: new c.Matrix4()
410
+ }, _o = (t, e = { position: new c.Vector3(), quaternion: new c.Quaternion() }) => {
411
+ const n = t.restQuaternions.wrist;
412
+ if (!n) throw new Error('WristAttachment: the rig has no "wrist" node');
413
+ ht.inv.copy(n).invert();
414
+ const s = t.restPositions;
415
+ return ht.y.subVectors(s[ut.middleMcp], s[ut.wrist]).applyQuaternion(ht.inv).normalize(), ht.z.copy(t.restPalmNormal).applyQuaternion(ht.inv), ht.z.addScaledVector(ht.y, -ht.z.dot(ht.y)).normalize(), ht.x.crossVectors(ht.y, ht.z), ht.basis.makeBasis(ht.x, ht.y, ht.z), e.position.set(0, 0, 0), e.quaternion.setFromRotationMatrix(ht.basis), e;
416
+ }, Eo = 2.5, ko = 1.25, Ro = 0.15, To = Object.freeze({
417
+ jump: 35,
418
+ confirmMs: 200,
419
+ confirmSamples: 4,
420
+ smoothing: 0.6
421
+ });
422
+ class Oo {
423
+ constructor(e = {}) {
424
+ B(this, "settings");
425
+ B(this, "q", new c.Quaternion());
426
+ B(this, "has", !1);
427
+ B(this, "pending", null);
428
+ this.settings = { ...To, ...e };
429
+ }
430
+ /**
431
+ * Filters this frame's wrist rotation (`target`) at `nowMs`; writes into
432
+ * `out`. `sample` names the hand detection it comes from (its timestamp);
433
+ * omitted, every call counts as one.
434
+ */
435
+ apply(e, n, s, o) {
436
+ const i = c.MathUtils.degToRad(this.settings.jump);
437
+ if (!this.has)
438
+ return this.q.copy(e), this.has = !0, this.pending = null, s.copy(this.q);
439
+ if (this.q.angleTo(e) > i) {
440
+ const { pending: r } = this;
441
+ return r && r.q.angleTo(e) < i / 2 ? ((o === void 0 || o !== r.lastSample) && (r.samples += 1, r.lastSample = o), n - r.sinceMs >= this.settings.confirmMs && r.samples >= this.settings.confirmSamples && (this.q.copy(e), this.pending = null)) : this.pending = { q: e.clone(), sinceMs: n, samples: 1, lastSample: o }, s.copy(this.q);
442
+ }
443
+ return this.pending = null, this.q.slerp(e, c.MathUtils.clamp(this.settings.smoothing, 0.01, 1)), s.copy(this.q);
444
+ }
445
+ /** Forget the wrist (the hand was lost): the next pose is taken as it is. */
446
+ reset() {
447
+ this.has = !1, this.pending = null;
448
+ }
449
+ }
450
+ const ln = "forearm", Io = new c.Vector3(1, 1, 1), Do = 0.2, No = 0.45, Lo = 0.03, Ho = [0.85, 1.15], cn = new c.Vector3(0, -1, 0), Vo = 0.45, hn = 0.999;
451
+ class Bo {
452
+ /** `forearm`: the rig's forearm bone, at rest, a child of the wrist bone. */
453
+ constructor(e, n) {
454
+ B(this, "filter", new Oo());
455
+ /** The arm fit (null without `armMask`). */
456
+ B(this, "arm", null);
457
+ /** The wrist frame this frame, world (rigid). */
458
+ B(this, "world", new c.Matrix4());
459
+ /** Across the arm (X, Z) to fit the arm's width; 1 without a fit. */
460
+ B(this, "crossScale", 1);
461
+ /** The settled width's home: give both rigs of a session the same object. */
462
+ B(this, "shared", { cm: null });
463
+ /** The wrist joint's bend this frame, after the anatomical clamp (radians). */
464
+ B(this, "joint", { flexion: 0, deviation: 0 });
465
+ /** How far the fitted direction was pulled back into the joint's range this frame, radians. */
466
+ B(this, "clamped", 0);
467
+ /**
468
+ * Up the arm on screen from a body tracker's elbow (unit, feed units), set
469
+ * by the rig each frame when a body tracker sees this hand's elbow; null
470
+ * otherwise. The best direction source: it needs neither a mask nor the
471
+ * hand's own axis, so it holds when the hand points at the camera.
472
+ */
473
+ B(this, "bodyUp", null);
474
+ B(this, "size");
475
+ /**
476
+ * The wrist frame in the forearm bone's space (+Y toward the fingers, +Z
477
+ * out of the palm, origin on the wrist joint): where wristwear is authored.
478
+ */
479
+ B(this, "forearmFrame", new c.Matrix4());
480
+ B(this, "wristFrame", new c.Matrix4());
481
+ /** inverse(wrist frame in the wrist bone) × the forearm's rest (in the wrist bone). */
482
+ B(this, "toForearm", new c.Matrix4());
483
+ B(this, "frame", 0);
484
+ B(this, "solved", -1);
485
+ /** The hand detection behind this frame (`HandPose.timestampMs`), for the filter. */
486
+ B(this, "sample");
487
+ /** The arm's way up on screen and the scale it was aimed with, last frame. */
488
+ B(this, "last", { up: { x: 0, y: 0 }, units: 0 });
489
+ B(this, "w", {
490
+ raw: new c.Matrix4(),
491
+ steady: new c.Matrix4(),
492
+ local: new c.Matrix4(),
493
+ p: new c.Vector3(),
494
+ q: new c.Quaternion(),
495
+ s: new c.Vector3(),
496
+ up: { x: 0, y: 0 },
497
+ p2: new c.Vector3(),
498
+ q2: new c.Quaternion(),
499
+ s2: new c.Vector3(),
500
+ qi: new c.Quaternion(),
501
+ dir: new c.Vector3(),
502
+ fix: new c.Quaternion(),
503
+ limited: new c.Vector3()
504
+ });
505
+ this.binding = e, this.forearm = n;
506
+ const { position: s, quaternion: o } = _o(e);
507
+ this.wristFrame.compose(s, o, Io), this.size = is(e);
508
+ const i = new c.Matrix4().compose(n.position, n.quaternion, n.scale);
509
+ this.forearmFrame.copy(i).invert().multiply(this.wristFrame), this.toForearm.copy(this.wristFrame).invert().multiply(i);
510
+ }
511
+ /**
512
+ * The person's wrist width, cm, settled from confident mask measures
513
+ * (null until one); a property of the person, so it moves slowly, and
514
+ * shared between both hands' rigs of a session (`shared`): the hand
515
+ * tracker's left / right label can flip, and both wrists are alike.
516
+ */
517
+ get widthCm() {
518
+ return this.shared.cm;
519
+ }
520
+ set widthCm(e) {
521
+ this.shared.cm = e;
522
+ }
523
+ /** A new frame (the rig moved; `sample`: its detection): the next `solve` works it out again. */
524
+ tick(e) {
525
+ this.frame += 1, this.sample = e;
526
+ }
527
+ /** The hand was lost: the next pose is taken as it is. */
528
+ reset() {
529
+ this.filter.reset();
530
+ }
531
+ /**
532
+ * Aims the forearm bone for this frame (once; later calls are free) and
533
+ * returns the wrist frame (world), or null without a wrist bone. Call
534
+ * before render, after the rig has posed the hand.
535
+ */
536
+ solve(e, n, s = performance.now()) {
537
+ const o = this.binding.bones.wrist;
538
+ if (!o) return null;
539
+ if (this.solved === this.frame) return this.world;
540
+ this.solved = this.frame;
541
+ const { w: i } = this;
542
+ i.raw.multiplyMatrices(o.matrixWorld, this.wristFrame), i.raw.decompose(i.p, i.q, i.s), this.filter.apply(i.q, s, i.q, this.sample), i.steady.compose(i.p, i.q, i.s);
543
+ const r = this.arm, a = r == null ? void 0 : r.tracker, l = a == null ? void 0 : a.query, { bodyUp: h } = this;
544
+ this.crossScale = 1;
545
+ let u = !!h;
546
+ const f = !l && this.last.units > 0, d = !!r && !!a && a.weight > 0 && (!!l || f);
547
+ if (!d && !h)
548
+ this.world.copy(i.steady), this.last.units = 0;
549
+ else if (h && (!d || !(r != null && r.turn) || !a))
550
+ i.up.x = h.x, i.up.y = h.y, this.last.up.x = i.up.x, this.last.up.y = i.up.y, this.crossScale = on(
551
+ i.steady,
552
+ e,
553
+ n,
554
+ {
555
+ up: i.up,
556
+ shift: 0,
557
+ width: null,
558
+ halfWidth: this.size.width / 2,
559
+ halfDepth: this.size.depth / 2
560
+ },
561
+ 1,
562
+ this.world
563
+ );
564
+ else if (r && a) {
565
+ const M = l ? l.unitsPerCm : this.last.units;
566
+ if (h)
567
+ i.up.x = h.x, i.up.y = h.y;
568
+ else if (!r.turn)
569
+ es(i.steady, e, n, i.up);
570
+ else if (l) {
571
+ const { x: w, y: x } = l.toElbow;
572
+ i.up.x = w * Math.cos(a.bend) - x * Math.sin(a.bend), i.up.y = w * Math.sin(a.bend) + x * Math.cos(a.bend);
573
+ } else
574
+ i.up.x = this.last.up.x, i.up.y = this.last.up.y;
575
+ this.last.up.x = i.up.x, this.last.up.y = i.up.y, this.last.units = M;
576
+ const _ = h ? 1 : c.MathUtils.smoothstep(a.confidence, Do, No);
577
+ if (_ >= hn && a.weight >= hn && r.turn && (u = !0), r.fitWidth && a.width !== null && _ >= 1) {
578
+ const [w, x] = Ho, L = Math.min(
579
+ this.size.width * x,
580
+ Math.max(this.size.width * w, a.width)
581
+ );
582
+ this.widthCm = (this.widthCm ?? this.size.width) + (L - (this.widthCm ?? this.size.width)) * Lo;
583
+ }
584
+ this.crossScale = on(
585
+ i.steady,
586
+ e,
587
+ n,
588
+ {
589
+ up: i.up,
590
+ shift: r.fitWidth ? a.shift * M : 0,
591
+ width: r.fitWidth && this.widthCm !== null ? this.widthCm * M : null,
592
+ halfWidth: this.size.width / 2,
593
+ halfDepth: this.size.depth / 2
594
+ },
595
+ h ? 1 : a.weight * _,
596
+ this.world
597
+ );
598
+ }
599
+ i.steady.decompose(i.p, i.q, i.s), this.world.decompose(i.p2, i.q2, i.s2), i.qi.copy(i.q).invert().multiply(i.q2), i.dir.copy(cn).applyQuaternion(i.qi), So(i.dir, void 0, i.limited);
600
+ const g = !u && ns(i.steady, e, n) >= Vo;
601
+ return this.clamped = g ? i.dir.angleTo(i.limited) : 0, os(g ? i.limited : i.dir, this.joint), this.clamped > 1e-4 && (i.fix.setFromUnitVectors(cn, i.limited), i.q2.copy(i.q).multiply(i.fix), this.world.compose(i.p2, i.q2, i.s2)), i.local.copy(o.matrixWorld).invert().multiply(this.world).multiply(this.toForearm).decompose(this.forearm.position, this.forearm.quaternion, this.forearm.scale), this.forearm.updateMatrixWorld(!0), this.world;
602
+ }
603
+ }
604
+ const Fo = (t) => {
605
+ const e = t.bones.wrist;
606
+ if (!e) return null;
607
+ const n = e.getObjectByName(ln);
608
+ if (n) return n;
609
+ const s = new c.Bone();
610
+ return s.name = ln, e.add(s), s;
611
+ }, rs = oe(null), we = "vincenttHandRigModelMesh", Me = oe(null), as = oe(null), Wo = new c.Matrix4(), Ae = new c.Matrix4(), Uo = ({
612
+ hand: t,
613
+ model: e,
614
+ modelHand: n = "right",
615
+ smoothing: s = Cs,
616
+ fingerLengths: o = "tracked",
617
+ showHeld: i = !0,
618
+ onTrackingChange: r,
619
+ material: a,
620
+ onModel: l,
621
+ active: h = !0,
622
+ armMask: u,
623
+ children: f
624
+ }) => {
625
+ const { node: d } = ee(Et.HAND_TRACKER, void 0, h), g = te(Et.BODY_TRACKER), M = $n(), { camera: _, size: w } = Ot(), x = u ? typeof u == "string" ? { kind: u } : u : null, L = x ? x.kind ?? "skin" : !1, V = Fe(L), N = x != null && x.fallback && x.fallback !== L ? x.fallback : !1, W = Fe(N), E = K(
626
+ () => L ? { tracker: new ho(), turn: !0, fitWidth: !0, mask: null } : null,
627
+ [L]
628
+ );
629
+ E && x && (E.mask = V, E.turn = x.turn ?? !0, E.fitWidth = x.fitWidth ?? !0, E.tracker.settings = { ...ts, ...pn(x, Po) });
630
+ const R = st({});
631
+ R.current = x ? pn(x, Go) : {};
632
+ const J = st(null), H = K(() => {
633
+ const T = Yn(e);
634
+ return T.traverse((A) => {
635
+ A.frustumCulled = !1, A instanceof c.Mesh && (A.userData[we] = !0);
636
+ }), T;
637
+ }, [e]), C = K(() => js(H, n), [H, n]), tt = K(
638
+ () => new Bo(C, Fo(C)),
639
+ [C]
640
+ );
641
+ tt.arm = E, d && (tt.shared = qo(d));
642
+ const Y = st(1);
643
+ Y.current = w.width / Math.max(1, w.height);
644
+ const ot = Ot((T) => T.scene);
645
+ Z(
646
+ () => de(
647
+ ot,
648
+ (T, A, D) => tt.solve(D, Y.current)
649
+ ),
650
+ [ot, tt]
651
+ );
652
+ const z = K(() => Gs(C), [C]), rt = st(l);
653
+ rt.current = l, Z(() => {
654
+ var T;
655
+ return (T = rt.current) == null ? void 0 : T.call(rt, H);
656
+ }, [H]);
657
+ const S = K(() => {
658
+ const T = /* @__PURE__ */ new Map();
659
+ return H.traverse((A) => {
660
+ A instanceof c.Mesh && T.set(A, A.material);
661
+ }), T;
662
+ }, [H]);
663
+ Z(() => {
664
+ for (const [T, A] of S) T.material = a ?? A;
665
+ }, [a, S]);
666
+ const y = st(void 0), k = st({
667
+ tracked: !1,
668
+ quaternion: new c.Quaternion(),
669
+ position: new c.Vector3(),
670
+ scale: 1,
671
+ mirrored: !1
672
+ }), p = st({}), v = st({}), b = st({});
673
+ return ye(() => {
674
+ var lt, wt, Mt, Rt;
675
+ const T = J.current;
676
+ if (!T) return;
677
+ const A = ((lt = d == null ? void 0 : d.getHandPose) == null ? void 0 : lt.call(d, t)) ?? ((wt = d == null ? void 0 : d.poses) == null ? void 0 : wt[t]) ?? null, D = A && A.world.length >= 21 && A.image.length >= 21 && (i || !A.held), F = k.current;
678
+ if (tt.tick(A == null ? void 0 : A.timestampMs), !D) {
679
+ T.visible = !1, tt.reset(), E == null || E.tracker.reset(), Xe(F, null, s, z) && (r == null || r(!1));
680
+ return;
681
+ }
682
+ const I = w.width / Math.max(1, w.height);
683
+ if (_e.x = (A.image[0].x + 1) / 2 * I, _e.y = (1 - A.image[0].y) / 2, tt.bodyUp = jo(g, _e, I, tt.bodyUp), E) {
684
+ const et = performance.now();
685
+ E.tracker.pushHand(
686
+ A.timestampMs,
687
+ Zn(
688
+ A,
689
+ w.width / Math.max(1, w.height),
690
+ E.tracker.weight > 0 ? ((Mt = E.tracker.last) == null ? void 0 : Mt.direction) ?? null : null
691
+ )
692
+ );
693
+ const Tt = (V == null ? void 0 : V.refresh(et)) ?? !1, xt = (W == null ? void 0 : W.refresh(et)) ?? !1;
694
+ (Tt || xt) && !(V && E.tracker.measure(V, V.timestampMs, R.current)) && W && E.tracker.measure(W, W.timestampMs, R.current), E.tracker.step(et);
695
+ }
696
+ const q = Qs(C, A, _, M, y.current);
697
+ y.current = q, F.tracked && F.mirrored !== q.mirrored && (F.tracked = !1);
698
+ const j = Xe(F, q.fit, s, z);
699
+ F.mirrored = q.mirrored, j && (r == null || r(!0));
700
+ const Q = c.MathUtils.clamp(s, 0.01, 1), $ = Math.min(Q, 0.1), it = v.current;
701
+ for (const { name: et } of Ze) {
702
+ const Tt = q.local[et], xt = C.bones[et];
703
+ if (!Tt || !xt) continue;
704
+ const At = (Rt = p.current)[et] ?? (Rt[et] = Tt.clone());
705
+ j || Q >= 1 ? At.copy(Tt) : At.slerp(Tt, Q), xt.quaternion.copy(At);
706
+ const Kt = o === "tracked" ? q.lengths[et] ?? 1 : 1, zt = it[et];
707
+ it[et] = j || zt === void 0 ? Kt : zt + (Kt - zt) * $;
708
+ }
709
+ const X = b.current;
710
+ for (const { name: et, parent: Tt } of Ze) {
711
+ if (Tt !== "wrist") continue;
712
+ const xt = q.knuckles[et];
713
+ if (!xt) continue;
714
+ const At = X[et] ?? (X[et] = xt.clone());
715
+ j ? At.copy(xt) : At.lerp(xt, $);
716
+ }
717
+ Ks(C, it, o === "tracked" ? X : null), Ys(
718
+ { scale: F.scale, quaternion: F.quaternion, translation: F.position },
719
+ F.mirrored,
720
+ Ae
721
+ ), T.parent && (T.parent.updateMatrixWorld(), Ae.premultiply(Wo.copy(T.parent.matrixWorld).invert())), T.matrix.copy(Ae), T.matrixWorldNeedsUpdate = !0, T.visible = !0;
722
+ }), /* @__PURE__ */ at(Me.Provider, { value: C, children: /* @__PURE__ */ at(as.Provider, { value: t, children: /* @__PURE__ */ ie(rs.Provider, { value: tt, children: [
723
+ /* @__PURE__ */ at("group", { ref: J, matrixAutoUpdate: !1, visible: !1, children: /* @__PURE__ */ at("primitive", { object: H }) }),
724
+ f
725
+ ] }) }) });
726
+ }, Po = ["smoothing", "holdMs", "fadeMs", "maxSkewMs", "maxShift"], _e = { x: 0, y: 0 }, un = /* @__PURE__ */ new WeakMap(), qo = (t) => {
727
+ let e = un.get(t);
728
+ return e || (e = { cm: null }, un.set(t, e)), e;
729
+ }, Co = [
730
+ { elbow: 13, wrist: 15 },
731
+ { elbow: 14, wrist: 16 }
732
+ ], dn = 0.5, zo = 0.12, jo = (t, e, n, s) => {
733
+ var M, _;
734
+ const o = (w) => (w + 1) / 2 * n, i = (w) => (1 - w) / 2;
735
+ let r = null, a = zo;
736
+ for (let w = 0; w < ((t == null ? void 0 : t.numBodies) ?? 1); w += 1) {
737
+ const x = (M = t == null ? void 0 : t.getLandmarks2D) == null ? void 0 : M.call(t, w);
738
+ if (!x) continue;
739
+ const L = (_ = t == null ? void 0 : t.getVisibility) == null ? void 0 : _.call(t, w);
740
+ for (const V of Co) {
741
+ const N = x[V.wrist], W = x[V.elbow];
742
+ if (!N || !W || L && (L[V.elbow] < dn || L[V.wrist] < dn))
743
+ continue;
744
+ const E = Math.hypot(o(N.x) - e.x, i(N.y) - e.y);
745
+ E < a && (a = E, r = { points: x, ...V });
746
+ }
747
+ }
748
+ if (!r) return null;
749
+ const l = r.points[r.elbow], h = r.points[r.wrist], u = o(l.x) - o(h.x), f = i(l.y) - i(h.y), d = Math.hypot(u, f);
750
+ if (d < 1e-6) return null;
751
+ const g = s ?? { x: 0, y: 0 };
752
+ return g.x = u / d, g.y = f / d, g;
753
+ }, Go = ["along", "widthAt", "maxWidth", "minWidth", "maxTurn"], pn = (t, e) => Object.fromEntries(e.filter((n) => t[n] !== void 0).map((n) => [n, t[n]])), Qo = Object.freeze({
754
+ jump: 35,
755
+ windowMs: 120,
756
+ confirmMs: 200,
757
+ confirmSamples: 4
758
+ });
759
+ class Ko {
760
+ constructor(e = {}) {
761
+ B(this, "settings");
762
+ /** Accepted detections, oldest first, kept for `windowMs`. */
763
+ B(this, "accepted", []);
764
+ B(this, "pending", null);
765
+ this.settings = { ...Qo, ...e };
766
+ }
767
+ /**
768
+ * Checks one detection's hips rotation at `nowMs` (its timestamp); `true` =
769
+ * hold it (keep the last accepted pose), `false` = take it.
770
+ */
771
+ hold(e, n) {
772
+ const { jump: s, windowMs: o, confirmMs: i, confirmSamples: r } = this.settings;
773
+ if (!this.accepted.length)
774
+ return this.take(e, n), !1;
775
+ if (this.accepted[0].q.angleTo(e) > c.MathUtils.degToRad(s))
776
+ return this.pending ?? (this.pending = { sinceMs: n, samples: 0 }), this.pending.samples += 1, n - this.pending.sinceMs < i || this.pending.samples < r ? !0 : (this.accepted = [], this.take(e, n), !1);
777
+ for (this.take(e, n); this.accepted.length > 1 && n - this.accepted[1].ms >= o; )
778
+ this.accepted.shift();
779
+ return !1;
780
+ }
781
+ /** Forget the body (it was lost): the next detection is taken as it is. */
782
+ reset() {
783
+ this.accepted = [], this.pending = null;
784
+ }
785
+ take(e, n) {
786
+ this.pending = null, this.accepted.push({ ms: n, q: e.clone() });
787
+ }
788
+ }
789
+ const fn = [
790
+ "leftArm",
791
+ "rightArm",
792
+ "leftLeg",
793
+ "rightLeg"
794
+ ], Yo = Object.freeze({
795
+ leftArm: ["leftArm", "leftForeArm", "leftHand"],
796
+ rightArm: ["rightArm", "rightForeArm", "rightHand"],
797
+ leftLeg: ["leftUpLeg", "leftLeg", "leftFoot"],
798
+ rightLeg: ["rightUpLeg", "rightLeg", "rightFoot"]
799
+ }), $o = Object.freeze({
800
+ leftArm: [m.leftShoulder, m.leftElbow, m.leftWrist],
801
+ rightArm: [m.rightShoulder, m.rightElbow, m.rightWrist],
802
+ leftLeg: [m.leftHip, m.leftKnee, m.leftAnkle],
803
+ rightLeg: [m.rightHip, m.rightKnee, m.rightAnkle]
804
+ }), Jo = [
805
+ m.leftShoulder,
806
+ m.rightShoulder,
807
+ m.leftHip,
808
+ m.rightHip,
809
+ m.leftElbow,
810
+ m.rightElbow,
811
+ m.leftKnee,
812
+ m.rightKnee
813
+ ], Xo = (t, e, n = {
814
+ points: $e.map(() => new c.Vector3()),
815
+ scale: 0
816
+ }) => {
817
+ const s = $e.length;
818
+ for (let d = 0; d < s; d += 1) Jt(t.image[d], e, n.points[d], 0);
819
+ let o = Jo.filter((d) => (t.visibility[d] ?? 0) > 0.5);
820
+ o.length < 3 && (o = [m.leftShoulder, m.rightShoulder, m.leftHip, m.rightHip]);
821
+ let i = 0, r = 0, a = 0, l = 0;
822
+ for (const d of o)
823
+ i += t.world[d].x, r += t.world[d].y, a += n.points[d].x, l += n.points[d].y;
824
+ i /= o.length, r /= o.length, a /= o.length, l /= o.length;
825
+ let h = 0, u = 0;
826
+ for (const d of o) {
827
+ const g = t.world[d].x - i, M = t.world[d].y - r;
828
+ h += g * (n.points[d].x - a) + M * (n.points[d].y - l), u += g * g + M * M;
829
+ }
830
+ n.scale = u > 1e-9 ? Math.max(h / u, 0) : 0;
831
+ const f = (t.world[m.leftHip].z + t.world[m.rightHip].z) / 2;
832
+ for (let d = 0; d < s; d += 1)
833
+ Jt(t.image[d], e, n.points[d], n.scale * (t.world[d].z - f));
834
+ return n;
835
+ }, Lt = {
836
+ inverse: new c.Matrix4(),
837
+ m: new c.Matrix4(),
838
+ p: new c.Vector3(),
839
+ q: new c.Quaternion(),
840
+ s: new c.Vector3()
841
+ }, Bt = (t, e, n = new c.Vector3()) => {
842
+ const s = t.bones[e];
843
+ return s ? (Lt.inverse.copy(t.root.matrixWorld).invert(), n.setFromMatrixPosition(Lt.m.multiplyMatrices(Lt.inverse, s.matrixWorld))) : n.set(0, 0, 0);
844
+ }, Ft = (t, e, n) => e === t.root ? n.identity() : (Lt.inverse.copy(t.root.matrixWorld).invert(), Lt.m.multiplyMatrices(Lt.inverse, e.matrixWorld).decompose(Lt.p, n, Lt.s), n), Xt = (t, e, n) => {
845
+ const s = Ft(t, e.parent, new c.Quaternion());
846
+ e.quaternion.copy(s.invert().multiply(n)), e.updateMatrixWorld(!0);
847
+ }, qe = {
848
+ neck: { node: "head", from: "neck", a: m.leftEar, b: m.rightEar },
849
+ leftClavicle: { node: "leftArm", from: "leftShoulder", a: m.leftShoulder, b: m.rightShoulder },
850
+ rightClavicle: { node: "rightArm", from: "rightShoulder", a: m.rightShoulder, b: m.leftShoulder },
851
+ leftUpperArm: { node: "leftForeArm", from: "leftArm", a: m.leftShoulder, b: m.leftElbow },
852
+ leftForearm: { node: "leftHand", from: "leftForeArm", a: m.leftElbow, b: m.leftWrist },
853
+ rightUpperArm: { node: "rightForeArm", from: "rightArm", a: m.rightShoulder, b: m.rightElbow },
854
+ rightForearm: { node: "rightHand", from: "rightForeArm", a: m.rightElbow, b: m.rightWrist },
855
+ leftThigh: { node: "leftLeg", from: "leftUpLeg", a: m.leftHip, b: m.leftKnee },
856
+ leftShin: { node: "leftFoot", from: "leftLeg", a: m.leftKnee, b: m.leftAnkle },
857
+ rightThigh: { node: "rightLeg", from: "rightUpLeg", a: m.rightHip, b: m.rightKnee },
858
+ rightShin: { node: "rightFoot", from: "rightLeg", a: m.rightKnee, b: m.rightAnkle }
859
+ }, ls = Object.keys(qe), mn = [0.8, 1.25], gn = [0.5, 1.5], pe = [0.5, 2], Zo = 0.9, ti = (t, e) => {
860
+ const n = t.restPositions, s = n.leftArm.clone().add(n.rightArm).multiplyScalar(0.5).distanceTo(n.leftUpLeg.clone().add(n.rightUpLeg).multiplyScalar(0.5)), o = e.points, i = o[m.leftShoulder].clone().add(o[m.rightShoulder]).multiplyScalar(0.5).distanceTo(o[m.leftHip].clone().add(o[m.rightHip]).multiplyScalar(0.5));
861
+ return s > 1e-9 ? i / s : 0;
862
+ }, cs = (t, e) => {
863
+ const n = t.restPositions, s = n.leftArm.distanceTo(n.rightArm), o = e.points[m.leftShoulder].distanceTo(e.points[m.rightShoulder]);
864
+ return s > 1e-9 ? o / s : 0;
865
+ }, ei = 1.1, yn = [0.75, 1.1], ni = (t) => {
866
+ const e = t.boundParent.leftShoulder;
867
+ return e && e === t.boundParent.rightShoulder && t.bones[e] ? e : null;
868
+ }, si = (t, e, n) => {
869
+ const s = cs(t, e);
870
+ return n <= 0 || s <= 0 ? 1 : c.MathUtils.clamp(
871
+ s / n,
872
+ yn[0],
873
+ yn[1]
874
+ );
875
+ }, oi = (t, e, n, s = {}) => {
876
+ const o = t.restPositions, i = e.points;
877
+ for (const r of ls) {
878
+ const { node: a, from: l, a: h, b: u } = qe[r];
879
+ if (!t.bones[a] || !o[a] || !o[l] || n <= 0) continue;
880
+ const f = o[a].distanceTo(o[l]);
881
+ if (f < 1e-9) continue;
882
+ let d;
883
+ if (r === "neck") {
884
+ const g = o.leftArm.clone().add(o.rightArm).multiplyScalar(0.5), M = o.head.clone().add(
885
+ (ze(t) ?? new c.Vector3()).applyQuaternion(
886
+ t.restQuaternions.head
887
+ )
888
+ ), _ = g.distanceTo(M);
889
+ d = 1 + (i[m.leftShoulder].clone().add(i[m.rightShoulder]).multiplyScalar(0.5).distanceTo(i[h].clone().add(i[u]).multiplyScalar(0.5)) / n - _) / f, s[r] = c.MathUtils.clamp(d, pe[0], pe[1]);
890
+ continue;
891
+ }
892
+ if (r === "leftClavicle" || r === "rightClavicle") {
893
+ const g = o.leftArm.distanceTo(o.rightArm) / 2, M = i[h].distanceTo(i[u]) / 2 / n;
894
+ d = (f + M - g) / f, s[r] = c.MathUtils.clamp(
895
+ d,
896
+ gn[0],
897
+ gn[1]
898
+ );
899
+ continue;
900
+ }
901
+ d = i[h].distanceTo(i[u]) / n / f, s[r] = c.MathUtils.clamp(d, mn[0], mn[1]);
902
+ }
903
+ return s;
904
+ }, wn = (t, e, n = 1) => {
905
+ const s = e ? n : 1, o = ni(t), i = ["leftShoulder", "rightShoulder"], r = (a) => {
906
+ const l = t.boundParent[a];
907
+ return !!o && (l === o || i.includes(l));
908
+ };
909
+ o && t.bones[o].scale.copy(t.restLocalScales[o]).multiplyScalar(s);
910
+ for (const a of Object.keys(t.boundParent)) {
911
+ const l = t.bones[a];
912
+ !l || !r(a) || (l.position.copy(t.restLocalPositions[a]).divideScalar(s), l.scale.copy(t.restLocalScales[a]), i.includes(a) || l.scale.divideScalar(s));
913
+ }
914
+ for (const a of ls) {
915
+ const { node: l } = qe[a], h = t.bones[l], u = t.restLocalPositions[l];
916
+ !h || !u || (h.position.copy(u).multiplyScalar((e == null ? void 0 : e[a]) ?? 1), r(l) && h.position.divideScalar(s));
917
+ }
918
+ }, ii = 1.1, Mn = [0.7, 1.3], Ee = /* @__PURE__ */ new WeakMap(), Ce = (t) => {
919
+ if (Ee.has(t)) return Ee.get(t);
920
+ const e = t.bones.head, n = t.restPositions.head, s = t.restQuaternions.head;
921
+ let o = null;
922
+ if (e && n && s) {
923
+ t.root.updateMatrixWorld(!0);
924
+ const i = new c.Matrix4().copy(t.root.matrixWorld).invert(), r = (h) => {
925
+ for (let u = h ?? null; u; u = u.parent) if (u === e) return !0;
926
+ return !1;
927
+ }, a = new c.Box3(), l = new c.Vector3();
928
+ t.root.traverse((h) => {
929
+ if (!(h instanceof c.SkinnedMesh)) return;
930
+ const u = h.geometry.getAttribute("skinIndex"), f = h.geometry.getAttribute("skinWeight"), d = h.geometry.getAttribute("position");
931
+ if (!(!u || !f || !d))
932
+ for (let g = 0; g < d.count; g += 1) {
933
+ let M = 0, _ = -1;
934
+ for (let w = 0; w < 4; w += 1) {
935
+ const x = f.getComponent(g, w);
936
+ x > M && (M = x, _ = u.getComponent(g, w));
937
+ }
938
+ _ < 0 || !r(h.skeleton.bones[_]) || a.expandByPoint(
939
+ h.getVertexPosition(g, l).applyMatrix4(h.matrixWorld).applyMatrix4(i)
940
+ );
941
+ }
942
+ }), !a.isEmpty() && a.max.x > a.min.x && (o = {
943
+ width: a.max.x - a.min.x,
944
+ center: a.getCenter(new c.Vector3()).sub(n).applyQuaternion(s.clone().invert())
945
+ });
946
+ }
947
+ return Ee.set(t, o), o;
948
+ }, ri = (t, e, n) => {
949
+ var i;
950
+ const s = (i = Ce(t)) == null ? void 0 : i.width;
951
+ if (!s || n <= 0) return null;
952
+ const o = e.points[m.leftEar].distanceTo(e.points[m.rightEar]) / n * ii;
953
+ return c.MathUtils.clamp(o / s, Mn[0], Mn[1]);
954
+ }, xn = (t, e) => {
955
+ const n = t.bones.head, s = t.restLocalScales.head;
956
+ n && s && n.scale.copy(s).multiplyScalar(e ?? 1);
957
+ }, bt = {
958
+ a: new c.Vector3(),
959
+ b: new c.Vector3(),
960
+ c: new c.Vector3(),
961
+ t: new c.Vector3(),
962
+ dir: new c.Vector3(),
963
+ side: new c.Vector3(),
964
+ nb: new c.Vector3(),
965
+ q: new c.Quaternion(),
966
+ upper: new c.Quaternion(),
967
+ lower: new c.Quaternion(),
968
+ end: new c.Quaternion()
969
+ }, ai = (t, e, n, s = 1) => {
970
+ if (s <= 0) return;
971
+ const [o, i, r] = Yo[e], a = t.bones[o], l = t.bones[i], h = t.bones[r];
972
+ if (!a || !l || !h) return;
973
+ const { a: u, b: f, c: d, t: g, dir: M, side: _, nb: w } = bt;
974
+ Bt(t, o, u), Bt(t, i, f), Bt(t, r, d), g.copy(d).lerp(n, Math.min(s, 1));
975
+ const x = u.distanceTo(f), L = f.distanceTo(d);
976
+ if (x < 1e-9 || L < 1e-9) return;
977
+ M.subVectors(g, u);
978
+ const V = c.MathUtils.clamp(
979
+ M.length(),
980
+ Math.abs(x - L) + 1e-6,
981
+ x + L - 1e-6
982
+ );
983
+ if (M.lengthSq() < 1e-12) return;
984
+ M.normalize(), _.subVectors(f, u).addScaledVector(M, -f.clone().sub(u).dot(M)), _.lengthSq() < 1e-12 && (_.subVectors(d, f).addScaledVector(M, -d.clone().sub(f).dot(M)), _.lengthSq() < 1e-12 && _.set(0, 0, 1).addScaledVector(M, -M.z)), _.normalize();
985
+ const N = c.MathUtils.clamp(
986
+ (x ** 2 + V ** 2 - L ** 2) / (2 * x * V),
987
+ -1,
988
+ 1
989
+ ), W = Math.sqrt(1 - N * N);
990
+ w.copy(u).addScaledVector(M, x * N).addScaledVector(_, x * W), Ft(t, a, bt.upper), Ft(t, l, bt.lower), Ft(t, h, bt.end), bt.q.setFromUnitVectors(f.clone().sub(u).normalize(), w.clone().sub(u).normalize()), Xt(t, a, bt.q.clone().multiply(bt.upper));
991
+ const E = d.clone().sub(u).applyQuaternion(bt.q).add(u), R = new c.Quaternion().setFromUnitVectors(
992
+ E.sub(w).normalize(),
993
+ g.clone().sub(w).normalize()
994
+ );
995
+ Xt(t, l, R.multiply(bt.q).multiply(bt.lower)), Xt(t, h, bt.end);
996
+ }, ze = (t) => {
997
+ var o;
998
+ const e = (o = Ce(t)) == null ? void 0 : o.center;
999
+ if (e) return e.clone();
1000
+ const n = t.restPositions, s = t.restQuaternions.head;
1001
+ return !n.head || !n.neck || !s ? null : n.head.clone().sub(n.neck).multiplyScalar(Zo).applyQuaternion(s.clone().invert());
1002
+ }, li = 0.2, ci = (t, e, n, s = new c.Vector3()) => {
1003
+ const o = e.distanceTo(n);
1004
+ s.copy(e).add(n).multiplyScalar(0.5);
1005
+ const i = t.bones.head, r = t.restQuaternions.head;
1006
+ if (!i || !r) return s;
1007
+ const a = Ft(t, i, new c.Quaternion()).multiply(
1008
+ r.clone().invert()
1009
+ );
1010
+ return s.addScaledVector(
1011
+ new c.Vector3(0, 1, 0).applyQuaternion(a),
1012
+ li * o
1013
+ );
1014
+ }, hi = (t, e = new c.Vector3()) => {
1015
+ const n = t.bones.head, s = ze(t);
1016
+ if (!n || !s) return null;
1017
+ const o = Ft(t, n, new c.Quaternion());
1018
+ return Bt(t, "head", e).add(s.applyQuaternion(o));
1019
+ }, ui = (t, e, n = 1) => {
1020
+ const s = t.bones.neck, o = t.bones.head, i = t.restLocalPositions.head, r = ze(t);
1021
+ if (n <= 0 || !s || !o || !i || !r) return;
1022
+ const a = hi(t);
1023
+ if (!a) return;
1024
+ const l = a.lerp(e, Math.min(n, 1)), h = Bt(t, "neck"), u = Ft(t, o, new c.Quaternion()), f = Ft(t, s, new c.Quaternion()), d = l.sub(r.clone().applyQuaternion(u)).sub(h), g = Bt(t, "head").sub(h);
1025
+ if (d.lengthSq() < 1e-12 || g.lengthSq() < 1e-12) return;
1026
+ const M = new c.Quaternion().setFromUnitVectors(
1027
+ g.clone().normalize(),
1028
+ d.clone().normalize()
1029
+ );
1030
+ Xt(t, s, M.multiply(f)), Xt(t, o, u);
1031
+ const _ = c.MathUtils.clamp(
1032
+ d.length() / Math.max(i.length(), 1e-9),
1033
+ pe[0],
1034
+ pe[1]
1035
+ );
1036
+ o.position.copy(i).multiplyScalar(_), o.updateMatrixWorld(!0);
1037
+ }, di = (t, e) => {
1038
+ const n = {};
1039
+ for (const [s, o] of Object.entries(t.bones)) {
1040
+ if (!o) continue;
1041
+ const i = e == null ? void 0 : e.tracks.find((r) => r.name === `${o.name}.quaternion`);
1042
+ n[s] = i && i.values.length >= 4 ? new c.Quaternion().fromArray(Array.from(i.values.slice(0, 4))).normalize() : t.restLocal[s].clone();
1043
+ }
1044
+ return n;
1045
+ }, Pt = [
1046
+ "hips",
1047
+ "spine",
1048
+ "spine1",
1049
+ "spine2",
1050
+ "neck",
1051
+ "head",
1052
+ "leftShoulder",
1053
+ "leftArm",
1054
+ "leftForeArm",
1055
+ "leftHand",
1056
+ "rightShoulder",
1057
+ "rightArm",
1058
+ "rightForeArm",
1059
+ "rightHand",
1060
+ "leftUpLeg",
1061
+ "leftLeg",
1062
+ "leftFoot",
1063
+ "leftToeBase",
1064
+ "rightUpLeg",
1065
+ "rightLeg",
1066
+ "rightFoot",
1067
+ "rightToeBase"
1068
+ ], vn = Object.freeze({
1069
+ hips: "Hips",
1070
+ spine: "Spine",
1071
+ spine1: "Spine1",
1072
+ spine2: "Spine2",
1073
+ neck: "Neck",
1074
+ head: "Head",
1075
+ leftShoulder: "LeftShoulder",
1076
+ leftArm: "LeftArm",
1077
+ leftForeArm: "LeftForeArm",
1078
+ leftHand: "LeftHand",
1079
+ rightShoulder: "RightShoulder",
1080
+ rightArm: "RightArm",
1081
+ rightForeArm: "RightForeArm",
1082
+ rightHand: "RightHand",
1083
+ leftUpLeg: "LeftUpLeg",
1084
+ leftLeg: "LeftLeg",
1085
+ leftFoot: "LeftFoot",
1086
+ leftToeBase: "LeftToeBase",
1087
+ rightUpLeg: "RightUpLeg",
1088
+ rightLeg: "RightLeg",
1089
+ rightFoot: "RightFoot",
1090
+ rightToeBase: "RightToeBase"
1091
+ }), pi = [
1092
+ "hips",
1093
+ "leftArm",
1094
+ "leftForeArm",
1095
+ "leftHand",
1096
+ "rightArm",
1097
+ "rightForeArm",
1098
+ "rightHand",
1099
+ "leftUpLeg",
1100
+ "leftLeg",
1101
+ "leftFoot",
1102
+ "rightUpLeg",
1103
+ "rightLeg",
1104
+ "rightFoot"
1105
+ ], hs = [
1106
+ "torso",
1107
+ "head",
1108
+ "leftArm",
1109
+ "rightArm",
1110
+ "leftLeg",
1111
+ "rightLeg"
1112
+ ], fi = Object.freeze({
1113
+ torso: [m.leftShoulder, m.rightShoulder, m.leftHip, m.rightHip],
1114
+ head: [m.nose, m.leftEar, m.rightEar],
1115
+ leftArm: [m.leftShoulder, m.leftElbow, m.leftWrist],
1116
+ rightArm: [m.rightShoulder, m.rightElbow, m.rightWrist],
1117
+ leftLeg: [m.leftHip, m.leftKnee, m.leftAnkle],
1118
+ rightLeg: [m.rightHip, m.rightKnee, m.rightAnkle]
1119
+ }), mi = Object.freeze({
1120
+ hips: "torso",
1121
+ spine: "torso",
1122
+ spine1: "torso",
1123
+ spine2: "torso",
1124
+ neck: "head",
1125
+ head: "head",
1126
+ leftShoulder: "torso",
1127
+ leftArm: "leftArm",
1128
+ leftForeArm: "leftArm",
1129
+ leftHand: "leftArm",
1130
+ rightShoulder: "torso",
1131
+ rightArm: "rightArm",
1132
+ rightForeArm: "rightArm",
1133
+ rightHand: "rightArm",
1134
+ leftUpLeg: "leftLeg",
1135
+ leftLeg: "leftLeg",
1136
+ leftFoot: "leftLeg",
1137
+ leftToeBase: "leftLeg",
1138
+ rightUpLeg: "rightLeg",
1139
+ rightLeg: "rightLeg",
1140
+ rightFoot: "rightLeg",
1141
+ rightToeBase: "rightLeg"
1142
+ }), ke = (t, e) => {
1143
+ const n = t.getObjectByName(e);
1144
+ if (n) return n;
1145
+ const s = new RegExp(`^mixamorig\\d*[:_]?${e}$`);
1146
+ let o = null;
1147
+ return t.traverse((i) => {
1148
+ !o && s.test(i.name) && (o = i);
1149
+ }), o;
1150
+ }, Nt = {
1151
+ m: new c.Matrix4(),
1152
+ inv: new c.Matrix4(),
1153
+ p: new c.Vector3(),
1154
+ q: new c.Quaternion(),
1155
+ s: new c.Vector3()
1156
+ }, ce = (t, e) => (Nt.m.multiplyMatrices(e, t.matrixWorld).decompose(Nt.p, Nt.q, Nt.s), { position: Nt.p.clone(), quaternion: Nt.q.clone() }), gi = (t, e = {}) => {
1157
+ const n = {};
1158
+ for (const l of Pt)
1159
+ n[l] = ke(t, e[l] ?? vn[l]);
1160
+ const s = pi.filter((l) => !n[l]), o = ["spine", "spine1", "spine2"].filter((l) => n[l]);
1161
+ if (o.length || s.push("spine"), !n.neck && !n.head && s.push("head"), s.length)
1162
+ throw new Error(
1163
+ `Body rig is missing bone(s): ${s.map((l) => e[l] ?? vn[l]).join(", ")}`
1164
+ );
1165
+ t.updateMatrixWorld(!0), Nt.inv.copy(t.matrixWorld).invert();
1166
+ const i = Nt.inv.clone(), r = {
1167
+ root: t,
1168
+ bones: n,
1169
+ restPositions: {},
1170
+ restQuaternions: {},
1171
+ restLocal: {},
1172
+ restLocalPositions: {},
1173
+ restLocalScales: {},
1174
+ restParentQuaternions: {},
1175
+ boundParent: {},
1176
+ spine: [...o],
1177
+ restHands: {}
1178
+ }, a = /* @__PURE__ */ new Map();
1179
+ for (const l of Pt) {
1180
+ const h = n[l];
1181
+ h && a.set(h, l);
1182
+ }
1183
+ for (const l of Pt) {
1184
+ const h = n[l];
1185
+ if (!h) continue;
1186
+ const u = ce(h, i);
1187
+ r.restPositions[l] = u.position, r.restQuaternions[l] = u.quaternion, r.restLocal[l] = h.quaternion.clone(), r.restLocalPositions[l] = h.position.clone(), r.restLocalScales[l] = h.scale.clone(), r.restParentQuaternions[l] = h.parent && h.parent !== t ? ce(h.parent, i).quaternion : new c.Quaternion();
1188
+ let f = h.parent, d = null;
1189
+ for (; f && f !== t; ) {
1190
+ const g = a.get(f);
1191
+ if (g) {
1192
+ d = g;
1193
+ break;
1194
+ }
1195
+ f = f.parent;
1196
+ }
1197
+ r.boundParent[l] = d;
1198
+ }
1199
+ for (const [l, h] of [
1200
+ ["leftHand", "LeftHand"],
1201
+ ["rightHand", "RightHand"]
1202
+ ]) {
1203
+ const u = n[l], f = u && ke(u, `${h}Index1`), d = u && ke(u, `${h}Pinky1`);
1204
+ if (!f || !d) continue;
1205
+ const g = ce(f, i).position, M = ce(d, i).position;
1206
+ r.restHands[l] = {
1207
+ forward: g.clone().add(M).multiplyScalar(0.5).sub(r.restPositions[l]),
1208
+ across: g.sub(M)
1209
+ };
1210
+ }
1211
+ return r;
1212
+ }, yi = Object.freeze({ yaw: 80, down: 65, up: 50, roll: 45 }), jt = new c.Euler(0, 0, 0, "YXZ"), wi = (t) => {
1213
+ const { yaw: e, down: n, up: s, roll: o } = yi, i = c.MathUtils.degToRad;
1214
+ return jt.setFromQuaternion(t, "YXZ"), jt.set(
1215
+ c.MathUtils.clamp(jt.x, -i(s), i(n)),
1216
+ c.MathUtils.clamp(jt.y, -i(e), i(e)),
1217
+ c.MathUtils.clamp(jt.z, -i(o), i(o)),
1218
+ "YXZ"
1219
+ ), t.setFromEuler(jt);
1220
+ }, Mi = 0.3, xi = 0.4, vi = 0.5, Sn = [0.15, 0.45], mt = () => new c.Vector3(), Yt = {
1221
+ a: mt(),
1222
+ b: mt(),
1223
+ c: mt(),
1224
+ d: mt(),
1225
+ e: mt(),
1226
+ x: mt(),
1227
+ y: mt(),
1228
+ z: mt(),
1229
+ m: new c.Matrix4(),
1230
+ q1: new c.Quaternion(),
1231
+ q2: new c.Quaternion(),
1232
+ q3: new c.Quaternion()
1233
+ }, bn = (t, e, n) => {
1234
+ const s = Yt.x.copy(t);
1235
+ if (s.lengthSq() < 1e-12) return n;
1236
+ s.normalize();
1237
+ const o = Yt.y.copy(e).addScaledVector(s, -e.dot(s));
1238
+ if (o.lengthSq() < 1e-12) return n;
1239
+ o.normalize();
1240
+ const i = Yt.z.crossVectors(s, o);
1241
+ return Yt.m.makeBasis(s, o, i), n.setFromRotationMatrix(Yt.m);
1242
+ }, $t = (t, e, n, s, o) => {
1243
+ const i = bn(t, e, new c.Quaternion()), r = bn(n, s, new c.Quaternion());
1244
+ return o.copy(r).multiply(i.invert());
1245
+ }, Ut = (t, e, n) => n.addVectors(t, e).multiplyScalar(0.5), Si = (t, e, n) => {
1246
+ const s = c.MathUtils.clamp((n - t) / (e - t), 0, 1);
1247
+ return s * s * (3 - 2 * s);
1248
+ }, bi = (t, e) => {
1249
+ const n = t.w < 0 ? -1 : 1, s = (t.x * e.x + t.y * e.y + t.z * e.z) * n;
1250
+ return 2 * Math.atan2(s, t.w * n);
1251
+ }, Ai = (t, e, n, s) => {
1252
+ const o = s ?? {
1253
+ local: {},
1254
+ mirrored: !1,
1255
+ confidence: {
1256
+ torso: 0,
1257
+ head: 0,
1258
+ leftArm: 0,
1259
+ rightArm: 0,
1260
+ leftLeg: 0,
1261
+ rightLeg: 0
1262
+ }
1263
+ };
1264
+ o.mirrored = n;
1265
+ for (const v of hs)
1266
+ o.confidence[v] = Math.min(
1267
+ ...fi[v].map((b) => e.visibility[b] ?? 0)
1268
+ );
1269
+ const i = (v) => {
1270
+ const b = e.world[v];
1271
+ return new c.Vector3(n ? -b.x : b.x, b.y, b.z);
1272
+ }, r = (v) => t.restPositions[v], a = (v) => t.restQuaternions[v], l = {}, h = (v) => v && l[v] ? l[v].clone().multiply(a(v).clone().invert()) : new c.Quaternion(), u = (v, b) => {
1273
+ l[v] = b.clone().multiply(a(v));
1274
+ }, f = (v) => {
1275
+ t.bones[v] && u(v, h(t.boundParent[v]));
1276
+ }, d = (v, b, T) => {
1277
+ const A = h(t.boundParent[v]), D = b.clone().normalize().applyQuaternion(A), F = T.clone(), I = new c.Quaternion();
1278
+ F.lengthSq() > 1e-12 && I.setFromUnitVectors(D, F.normalize()), u(v, I.multiply(A));
1279
+ }, g = i(m.leftHip), M = i(m.rightHip), _ = i(m.leftShoulder), w = i(m.rightShoulder), x = Ut(_, w, mt()).sub(Ut(g, M, mt())), L = r("leftUpLeg").clone().sub(r("rightUpLeg")), V = r("leftArm").clone().sub(r("rightArm")), N = Ut(r("leftArm"), r("rightArm"), mt()).sub(
1280
+ Ut(r("leftUpLeg"), r("rightUpLeg"), mt())
1281
+ ), W = $t(
1282
+ L,
1283
+ N,
1284
+ g.clone().sub(M),
1285
+ x,
1286
+ new c.Quaternion()
1287
+ ), E = $t(
1288
+ V,
1289
+ N,
1290
+ _.clone().sub(w),
1291
+ x,
1292
+ new c.Quaternion()
1293
+ );
1294
+ u("hips", W);
1295
+ const R = W.clone().invert().multiply(E);
1296
+ t.spine.forEach((v, b) => {
1297
+ const T = new c.Quaternion().slerp(R, (b + 1) / t.spine.length);
1298
+ u(v, W.clone().multiply(T));
1299
+ });
1300
+ const J = t.bones.neck ? "neck" : "head", H = new c.Vector3(0, 1, 0), C = i(m.leftEar).sub(i(m.rightEar)), Y = Ut(i(m.leftEye), i(m.rightEye), mt()).sub(Ut(i(m.leftEar), i(m.rightEar), mt())).clone().cross(C), ot = $t(
1301
+ V,
1302
+ H,
1303
+ C,
1304
+ Y,
1305
+ new c.Quaternion()
1306
+ ), z = t.spine[t.spine.length - 1], rt = wi(h(z).invert().multiply(ot)), S = h(z).multiply(rt);
1307
+ t.bones.neck && t.bones.head ? (u(
1308
+ "neck",
1309
+ h(z).multiply(new c.Quaternion().slerp(rt, xi))
1310
+ ), u("head", S)) : u(J, S);
1311
+ const y = new c.Vector3(0, 0, 1), k = (v, b, T, A, D, F, I) => {
1312
+ const q = h(t.boundParent[v]), j = r(b).clone().sub(r(v)), Q = j.clone().cross(I).normalize(), $ = D.clone().sub(A), it = F.clone().sub(D), X = Q.clone().applyQuaternion(q), lt = $.lengthSq() > 1e-12 && it.lengthSq() > 1e-12 ? $.clone().normalize().cross(it.clone().normalize()).length() : 0, wt = Si(Sn[0], Sn[1], lt), Mt = $.clone().cross(it);
1313
+ Mt.lengthSq() > 1e-12 && Mt.normalize();
1314
+ const Rt = $.clone().normalize();
1315
+ X.addScaledVector(Rt, -X.dot(Rt)), X.lengthSq() > 1e-12 && X.normalize();
1316
+ const et = X.clone().multiplyScalar(1 - wt).addScaledVector(Mt, wt);
1317
+ et.lengthSq() < 1e-6 && et.copy(wt > 0.5 ? Mt : X), u(v, $t(j, Q, $, et, new c.Quaternion())), d(b, r(T).clone().sub(r(b)), F.clone().sub(D));
1318
+ }, p = y.clone().negate();
1319
+ f("leftShoulder"), f("rightShoulder");
1320
+ for (const v of ["left", "right"]) {
1321
+ const b = v === "left", T = i(b ? m.leftShoulder : m.rightShoulder), A = i(b ? m.leftElbow : m.rightElbow), D = i(b ? m.leftWrist : m.rightWrist), F = b ? "leftArm" : "rightArm", I = b ? "leftForeArm" : "rightForeArm", q = b ? "leftHand" : "rightHand";
1322
+ k(F, I, q, T, A, D, y);
1323
+ const j = i(b ? m.leftIndex : m.rightIndex), Q = i(b ? m.leftPinky : m.rightPinky), $ = t.restHands[q], it = Math.min(
1324
+ ...[
1325
+ b ? m.leftWrist : m.rightWrist,
1326
+ b ? m.leftIndex : m.rightIndex,
1327
+ b ? m.leftPinky : m.rightPinky
1328
+ ].map((X) => e.visibility[X] ?? 0)
1329
+ );
1330
+ if ($ && it >= Mi) {
1331
+ const X = $t(
1332
+ $.forward,
1333
+ $.across,
1334
+ Ut(j, Q, mt()).sub(D),
1335
+ j.clone().sub(Q),
1336
+ new c.Quaternion()
1337
+ ), lt = h(I), wt = D.clone().sub(A);
1338
+ if (wt.lengthSq() > 1e-12) {
1339
+ wt.normalize();
1340
+ const Mt = X.clone().multiply(lt.clone().invert()), Rt = bi(Mt, wt) * vi;
1341
+ u(I, new c.Quaternion().setFromAxisAngle(wt, Rt).multiply(lt));
1342
+ }
1343
+ u(q, X);
1344
+ } else
1345
+ f(q);
1346
+ }
1347
+ for (const v of ["left", "right"]) {
1348
+ const b = v === "left", T = b ? "leftUpLeg" : "rightUpLeg", A = b ? "leftLeg" : "rightLeg", D = b ? "leftFoot" : "rightFoot", F = b ? "leftToeBase" : "rightToeBase", I = i(b ? m.leftHip : m.rightHip), q = i(b ? m.leftKnee : m.rightKnee), j = i(b ? m.leftAnkle : m.rightAnkle);
1349
+ k(T, A, D, I, q, j, p);
1350
+ const Q = t.bones[F] ? r(F).clone().sub(r(D)).setY(0) : null;
1351
+ Q && Q.lengthSq() > 1e-12 ? d(
1352
+ D,
1353
+ Q,
1354
+ i(b ? m.leftFootIndex : m.rightFootIndex).sub(i(b ? m.leftHeel : m.rightHeel))
1355
+ ) : f(D), f(F);
1356
+ }
1357
+ for (const v of Pt) {
1358
+ const b = l[v];
1359
+ if (!b || !t.bones[v]) continue;
1360
+ const T = h(t.boundParent[v]).multiply(
1361
+ t.restParentQuaternions[v]
1362
+ ), A = o.local[v] ?? new c.Quaternion();
1363
+ o.local[v] = A.copy(T.invert().multiply(b));
1364
+ }
1365
+ return o;
1366
+ }, Ta = (t, e) => {
1367
+ for (const n of Pt) {
1368
+ const s = t.bones[n], o = e.local[n];
1369
+ s && o && s.quaternion.copy(o);
1370
+ }
1371
+ }, Oa = (t) => {
1372
+ for (const e of Pt) {
1373
+ const n = t.bones[e], s = t.restLocal[e], o = t.restLocalPositions[e], i = t.restLocalScales[e];
1374
+ n && s && n.quaternion.copy(s), n && o && n.position.copy(o), n && i && n.scale.copy(i);
1375
+ }
1376
+ }, us = oe(null), _i = "vincenttBodyRigModel", Ei = 0.5, An = 0.1, ki = 1.5, _n = [0.04, 0.08], En = [0, 0.02], Ri = {
1377
+ torso: [],
1378
+ head: [m.leftEar, m.rightEar],
1379
+ leftArm: [m.leftWrist],
1380
+ rightArm: [m.rightWrist],
1381
+ leftLeg: [m.leftAnkle],
1382
+ rightLeg: [m.rightAnkle]
1383
+ }, Re = (t) => t ? Math.min((t.x + 1) / 2, (1 - t.x) / 2, (t.y + 1) / 2, (1 - t.y) / 2) : -1, Ti = 250, Oi = -1, kn = () => ({
1384
+ tracked: !1,
1385
+ missingSinceMs: null,
1386
+ timestampMs: -1,
1387
+ solution: void 0,
1388
+ accepted: {},
1389
+ flips: new Ko(),
1390
+ held: !1,
1391
+ scene: void 0,
1392
+ points: [],
1393
+ scale: 0,
1394
+ bones: {},
1395
+ weights: { torso: 1, head: 1, leftArm: 1, rightArm: 1, leftLeg: 1, rightLeg: 1 },
1396
+ seen: { torso: !0, head: !0, leftArm: !0, rightArm: !0, leftLeg: !0, rightLeg: !0 },
1397
+ hipsSeen: !0,
1398
+ hipsWeight: 1,
1399
+ shoulderToTorso: ei,
1400
+ lengths: {},
1401
+ chestScale: 1,
1402
+ headScale: null
1403
+ }), Ii = {
1404
+ leftArm: ["leftUpperArm", "leftForearm"],
1405
+ rightArm: ["rightUpperArm", "rightForearm"],
1406
+ leftLeg: ["leftThigh", "leftShin"],
1407
+ rightLeg: ["rightThigh", "rightShin"]
1408
+ }, G = {
1409
+ target: new c.Quaternion(),
1410
+ anchor: new c.Vector3(),
1411
+ right: new c.Vector3(),
1412
+ shoulders: new c.Vector3(),
1413
+ fromHips: new c.Vector3(),
1414
+ point: new c.Vector3(),
1415
+ matrix: new c.Matrix4(),
1416
+ inverse: new c.Matrix4(),
1417
+ scale: new c.Vector3(),
1418
+ identity: new c.Quaternion()
1419
+ }, Ia = ({
1420
+ model: t,
1421
+ idle: e,
1422
+ names: n,
1423
+ bodyIndex: s = 0,
1424
+ bodyId: o,
1425
+ subject: i,
1426
+ numBodies: r,
1427
+ smoothing: a = Ei,
1428
+ lengths: l = "tracked",
1429
+ reach: h = !0,
1430
+ visibility: u,
1431
+ fadeMs: f = 300,
1432
+ flipGuard: d = !0,
1433
+ onTrackingChange: g,
1434
+ onSeenChange: M,
1435
+ material: _,
1436
+ onModel: w,
1437
+ active: x = !0,
1438
+ children: L
1439
+ }) => {
1440
+ const { read: V } = qs({ bodyIndex: s, bodyId: o, subject: i, numBodies: r, active: x }), N = $n(), W = Ot((S) => S.camera), E = st(null), R = K(() => {
1441
+ const S = Yn(t);
1442
+ return S.traverse((y) => {
1443
+ y.frustumCulled = !1, y instanceof c.Mesh && (y.userData[_i] = !0);
1444
+ }), S;
1445
+ }, [t]), J = JSON.stringify(n ?? {}), H = K(() => {
1446
+ const S = gi(R, n);
1447
+ return Ce(S), S;
1448
+ }, [R, J]), C = K(() => di(H, e), [H, e]), tt = st(w);
1449
+ tt.current = w, Z(() => {
1450
+ var S;
1451
+ return (S = tt.current) == null ? void 0 : S.call(tt, R);
1452
+ }, [R]);
1453
+ const Y = K(() => {
1454
+ const S = /* @__PURE__ */ new Map();
1455
+ return R.traverse((y) => {
1456
+ y instanceof c.Mesh && S.set(y, y.material);
1457
+ }), S;
1458
+ }, [R]);
1459
+ Z(() => {
1460
+ for (const [S, y] of Y) S.material = _ ?? y;
1461
+ }, [_, Y]);
1462
+ const ot = st(kn());
1463
+ Z(() => {
1464
+ ot.current = kn();
1465
+ }, [H]);
1466
+ const z = st(g);
1467
+ z.current = g;
1468
+ const rt = st(M);
1469
+ return rt.current = M, ye((S, y) => {
1470
+ var xt, At, Kt, zt, Ke, Ye;
1471
+ const k = E.current;
1472
+ if (!k) return;
1473
+ const p = ot.current, v = ((xt = V()) == null ? void 0 : xt.pose) ?? null;
1474
+ if (!v) {
1475
+ const U = performance.now();
1476
+ if (p.missingSinceMs ?? (p.missingSinceMs = U), p.tracked && U - p.missingSinceMs < Ti) return;
1477
+ k.visible = !1, p.tracked && (p.tracked = !1, (At = z.current) == null || At.call(z, !1));
1478
+ return;
1479
+ }
1480
+ p.missingSinceMs = null;
1481
+ const b = !p.tracked;
1482
+ if (v.timestampMs !== p.timestampMs || b) {
1483
+ p.timestampMs = v.timestampMs, p.solution = Ai(H, v, N, p.solution), p.scene = Xo(v, W, p.scene);
1484
+ const U = p.solution.local.hips;
1485
+ if (b && p.flips.reset(), p.held = d && !!U && p.flips.hold(U, v.timestampMs), !p.held)
1486
+ for (const [dt, pt] of Object.entries(p.solution.local))
1487
+ ((Kt = p.accepted)[dt] ?? (Kt[dt] = new c.Quaternion())).copy(pt);
1488
+ }
1489
+ const T = p.solution, A = p.scene, D = b || a >= 1 ? 1 : 1 - (1 - Math.max(a, 0.01)) ** (y * 60), F = (u == null ? void 0 : u.seen) ?? 0.5, I = (u == null ? void 0 : u.lost) ?? 0.3, q = f > 0 ? y * 1e3 / f : 1;
1490
+ let j = b;
1491
+ for (const U of hs) {
1492
+ const dt = T.confidence[U], pt = Math.min(...Ri[U].map((Dt) => Re(v.image[Dt]))), vt = p.seen[U];
1493
+ U === "torso" ? p.seen.torso = !0 : dt >= F && pt >= En[1] ? p.seen[U] = !0 : (dt < I || pt < En[0]) && (p.seen[U] = !1), p.seen[U] !== vt && (j = !0);
1494
+ const St = p.seen[U] ? 1 : 0;
1495
+ p.weights[U] = b ? St : c.MathUtils.clamp(
1496
+ p.weights[U] + Math.sign(St - p.weights[U]) * q,
1497
+ 0,
1498
+ 1
1499
+ );
1500
+ }
1501
+ j && ((zt = rt.current) == null || zt.call(rt, { ...p.seen }));
1502
+ const Q = Math.min(v.visibility[m.leftHip] ?? 0, v.visibility[m.rightHip] ?? 0), $ = Math.min(
1503
+ Re(v.image[m.leftHip]),
1504
+ Re(v.image[m.rightHip])
1505
+ );
1506
+ Q >= F && $ >= _n[1] ? p.hipsSeen = !0 : (Q < I || $ < _n[0]) && (p.hipsSeen = !1), p.hipsWeight = b ? Number(p.hipsSeen) : c.MathUtils.clamp(p.hipsWeight + (p.hipsSeen ? q : -q), 0, 1);
1507
+ for (const U of Pt) {
1508
+ const dt = H.bones[U], pt = p.accepted[U];
1509
+ if (!dt || !pt) continue;
1510
+ const vt = p.weights[mi[U]];
1511
+ G.target.copy(C[U] ?? pt).slerp(pt, vt);
1512
+ const St = (Ke = p.bones)[U] ?? (Ke[U] = G.target.clone());
1513
+ D >= 1 ? St.copy(G.target) : St.slerp(G.target, D), dt.quaternion.copy(St);
1514
+ }
1515
+ const it = ti(H, A), X = cs(H, A);
1516
+ if (p.hipsSeen && p.hipsWeight >= 1 && it > 0 && X > 0) {
1517
+ const U = c.MathUtils.clamp(it / X, 0.8, 1.5);
1518
+ p.shoulderToTorso += (U - p.shoulderToTorso) * (b ? 1 : D * An);
1519
+ }
1520
+ const lt = c.MathUtils.lerp(
1521
+ X * p.shoulderToTorso,
1522
+ it,
1523
+ p.hipsWeight
1524
+ );
1525
+ if (lt <= 0) {
1526
+ k.visible = !1;
1527
+ return;
1528
+ }
1529
+ p.points.length !== A.points.length && (p.points = A.points.map((U) => U.clone())), G.shoulders.copy(A.points[m.leftShoulder]).add(A.points[m.rightShoulder]).multiplyScalar(0.5);
1530
+ const wt = p.points[m.leftShoulder].clone().add(p.points[m.rightShoulder]).multiplyScalar(0.5), Mt = b || wt.distanceTo(G.shoulders) > ki * lt * Di(H);
1531
+ for (let U = 0; U < A.points.length; U += 1)
1532
+ Mt || D >= 1 ? p.points[U].copy(A.points[U]) : p.points[U].lerp(A.points[U], D);
1533
+ if (p.scale = Mt || p.scale <= 0 ? lt : p.scale + (lt - p.scale) * D, l === "tracked") {
1534
+ const U = b ? 1 : D * An, dt = si(H, A, lt);
1535
+ p.chestScale = b ? dt : p.chestScale + (dt - p.chestScale) * U;
1536
+ const pt = oi(H, A, lt, {}), vt = (Dt) => {
1537
+ const ve = pt[Dt];
1538
+ if (ve === void 0) return;
1539
+ const Se = p.lengths[Dt];
1540
+ p.lengths[Dt] = Se === void 0 || b ? ve : Se + (ve - Se) * U;
1541
+ };
1542
+ vt("leftClavicle"), vt("rightClavicle"), p.weights.head >= 1 && vt("neck");
1543
+ for (const Dt of fn)
1544
+ p.weights[Rn(Dt)] >= 1 && Ii[Dt].forEach(vt);
1545
+ wn(H, p.lengths, p.chestScale);
1546
+ const St = p.weights.head >= 1 ? ri(H, A, lt) : null;
1547
+ St !== null && (p.headScale = p.headScale === null || b ? St : p.headScale + (St - p.headScale) * D * 0.3), xn(H, p.headScale);
1548
+ } else
1549
+ wn(H, null), xn(H, null);
1550
+ R.updateMatrixWorld(!0);
1551
+ const Rt = T.mirrored ? -1 : 1;
1552
+ G.scale.set(p.scale * Rt, p.scale, p.scale);
1553
+ const et = (U, dt, pt, vt, St) => (Bt(H, U, G.anchor), Bt(H, dt, G.right), G.anchor.add(G.right).multiplyScalar(0.5).multiply(G.scale), St.copy(p.points[pt]).add(p.points[vt]).multiplyScalar(0.5).sub(G.anchor));
1554
+ et("leftUpLeg", "rightUpLeg", m.leftHip, m.rightHip, G.fromHips), et("leftArm", "rightArm", m.leftShoulder, m.rightShoulder, G.point), G.point.lerp(G.fromHips, p.hipsWeight), G.matrix.compose(G.point, G.identity, G.scale), k.parent && (k.parent.updateMatrixWorld(), G.matrix.premultiply(G.inverse.copy(k.parent.matrixWorld).invert())), k.matrix.copy(G.matrix), k.matrixWorldNeedsUpdate = !0, k.updateMatrixWorld(!0), G.inverse.copy(R.matrixWorld).invert();
1555
+ for (const U of fn) {
1556
+ const dt = typeof h == "boolean" ? h : h[U] ?? !0, pt = p.weights[Rn(U)];
1557
+ if (!dt || pt <= 0) continue;
1558
+ const vt = $o[U][2];
1559
+ G.point.copy(p.points[vt]).applyMatrix4(G.inverse), ai(H, U, G.point, pt);
1560
+ }
1561
+ (typeof h == "boolean" ? h : h.head ?? !0) && p.weights.head > 0 && (G.anchor.copy(p.points[m.leftEar]).applyMatrix4(G.inverse), G.right.copy(p.points[m.rightEar]).applyMatrix4(G.inverse), ci(H, G.anchor, G.right, G.point), ui(H, G.point, p.weights.head)), k.visible = !0, b && (p.tracked = !0, (Ye = z.current) == null || Ye.call(z, !0));
1562
+ }, Oi), /* @__PURE__ */ ie(us.Provider, { value: H, children: [
1563
+ /* @__PURE__ */ at("group", { ref: E, matrixAutoUpdate: !1, visible: !1, children: /* @__PURE__ */ at("primitive", { object: R }) }),
1564
+ L
1565
+ ] });
1566
+ }, Rn = (t) => t, Tn = /* @__PURE__ */ new WeakMap(), Di = (t) => {
1567
+ let e = Tn.get(t);
1568
+ if (e === void 0) {
1569
+ const n = t.restPositions;
1570
+ e = n.leftArm.clone().add(n.rightArm).multiplyScalar(0.5).distanceTo(n.leftUpLeg.clone().add(n.rightUpLeg).multiplyScalar(0.5)), Tn.set(t, e);
1571
+ }
1572
+ return e;
1573
+ }, ds = -1, Te = "void main() {", We = "#include <skinning_vertex>", Ni = [
1574
+ We,
1575
+ "#ifdef USE_SKINNING",
1576
+ " transformed += normalize( objectNormal ) * inflate;",
1577
+ "#endif"
1578
+ ].join(`
1579
+ `), je = (t) => !t.includes(Te) || !t.includes(We) ? t : t.replace(Te, `uniform float inflate;
1580
+ ${Te}`).replace(We, Ni), ps = () => {
1581
+ const t = new c.MeshBasicMaterial({
1582
+ color: 13948120,
1583
+ colorWrite: !1,
1584
+ depthWrite: !0,
1585
+ side: c.FrontSide
1586
+ }), e = { value: 0 };
1587
+ return t.userData.inflate = e, t.onBeforeCompile = (n) => {
1588
+ n.uniforms.inflate = e, n.vertexShader = je(n.vertexShader);
1589
+ }, t.customProgramCacheKey = () => "vincentt-skinned-occluder", t;
1590
+ }, Li = ({ inflate: t = 0, showDebugMaterial: e = !1, opacity: n = 0.5 }, s, o) => {
1591
+ const i = K(() => ps(), []);
1592
+ Z(() => () => i.dispose(), [i]), Z(() => {
1593
+ i.colorWrite = e, i.transparent = e, i.opacity = e ? n : 1, i.needsUpdate = !0;
1594
+ }, [i, e, n]), Z(() => {
1595
+ i.userData.inflate.value = t;
1596
+ }, [i, t]);
1597
+ const r = Kn(
1598
+ (a) => {
1599
+ a.traverse((l) => {
1600
+ l instanceof c.Mesh && l.userData[s] && (l.renderOrder = ds);
1601
+ }), o == null || o(a);
1602
+ },
1603
+ [s, o]
1604
+ );
1605
+ return { material: i, onModel: r };
1606
+ }, Hi = (t, e, n = new c.Quaternion()) => {
1607
+ const s = t.restQuaternions[e];
1608
+ return s ? n.copy(s).invert() : n.identity();
1609
+ };
1610
+ let On = !1;
1611
+ const Da = ({ bone: t, offset: e, children: n }) => {
1612
+ const s = qt(us), o = K(
1613
+ () => s ? Hi(s, t) : new c.Quaternion(),
1614
+ [s, t]
1615
+ ), i = (s == null ? void 0 : s.bones[t]) ?? null;
1616
+ return s ? i ? Pe(
1617
+ /* @__PURE__ */ at("group", { quaternion: o, children: /* @__PURE__ */ at("group", { position: e == null ? void 0 : e.position, rotation: e == null ? void 0 : e.rotation, scale: e == null ? void 0 : e.scale, children: n }) }),
1618
+ i
1619
+ ) : null : (On || (On = !0, console.warn(
1620
+ `${re.loggerPrefix} BodyAttachment must be inside a BodyRig or BodyOccluder`
1621
+ )), null);
1622
+ }, In = 29, Vi = 15, Dn = "varying float vBodyViewDepth;", Oe = "#include <project_vertex>", Ie = "#include <dithering_fragment>", Bi = (t) => {
1623
+ const { vertexShader: e, fragmentShader: n } = t;
1624
+ return !e.includes(Oe) || !e.includes("void main() {") || !n.includes(Ie) || !n.includes("void main() {") ? t : {
1625
+ vertexShader: je(e).replace("void main() {", `${Dn}
1626
+ void main() {`).replace(Oe, `${Oe}
1627
+ vBodyViewDepth = -mvPosition.z;`),
1628
+ fragmentShader: n.replace("void main() {", `${Dn}
1629
+ void main() {`).replace(Ie, `${Ie}
1630
+ gl_FragColor = vec4( vBodyViewDepth, 1.0, 0.0, 1.0 );`)
1631
+ };
1632
+ }, Na = () => {
1633
+ const t = new c.MeshBasicMaterial({ side: c.FrontSide, toneMapped: !1 }), e = { value: 0 };
1634
+ return t.userData.inflate = e, t.onBeforeCompile = (n) => {
1635
+ n.uniforms.inflate = e, Object.assign(n, Bi(n));
1636
+ }, t.customProgramCacheKey = () => "vincentt-body-depth", t;
1637
+ }, Nn = new c.Color(), La = (t, e, n, s, o, i, r) => {
1638
+ s.traverse((d) => {
1639
+ d.userData[o] && d.layers.enable(In);
1640
+ });
1641
+ const a = e.background, l = e.overrideMaterial, h = n.layers.mask, u = t.getRenderTarget(), f = t.getClearAlpha();
1642
+ t.getClearColor(Nn), e.background = null, e.overrideMaterial = r, n.layers.set(In), t.setRenderTarget(i), t.setClearColor(0, 0), t.clear(), t.render(e, n), t.setRenderTarget(u), t.setClearColor(Nn, f), n.layers.mask = h, e.overrideMaterial = l, e.background = a;
1643
+ }, Ln = { p: new c.Vector3(), s: new c.Vector3() }, Ha = (t, e, n = { near: 0, far: 0 }) => {
1644
+ let s = 1 / 0, o = -1 / 0;
1645
+ for (const r of Object.values(t.bones)) {
1646
+ if (!r) continue;
1647
+ const a = -Ln.p.setFromMatrixPosition(r.matrixWorld).applyMatrix4(e.matrixWorldInverse).z;
1648
+ s = Math.min(s, a), o = Math.max(o, a);
1649
+ }
1650
+ if (s > o) return n;
1651
+ const i = Vi * Ln.s.setFromMatrixScale(t.root.matrixWorld).x;
1652
+ return n.near = s - Math.abs(i), n.far = o + Math.abs(i), n;
1653
+ }, Va = (
1654
+ /* glsl */
1655
+ `
1656
+ uniform sampler2D bodyDepthMap;
1657
+ uniform float bodyDepthNear;
1658
+ uniform float bodyDepthFar;
1659
+ vec2 bodyDepthAt( vec2 uv ) {
1660
+ vec4 t = texture2D( bodyDepthMap, uv );
1661
+ return vec2( t.r, t.g );
1662
+ }
1663
+ float bodyDepth01( float viewDepth ) {
1664
+ return clamp( ( viewDepth - bodyDepthNear ) / max( bodyDepthFar - bodyDepthNear, 1e-4 ), 0.0, 1.0 );
1665
+ }
1666
+ `
1667
+ ), Fi = ({ along: t = 1, offset: e, children: n }) => {
1668
+ const s = qt(Me), o = qt(rs), i = Ot((g) => g.scene), r = Ot((g) => g.size), a = st(null), l = K(() => s ? is(s) : null, [s]), h = st(1);
1669
+ h.current = r.width / Math.max(1, r.height), Z(() => {
1670
+ if (!o) return;
1671
+ const g = new c.Matrix4();
1672
+ return de(i, (M, _, w) => {
1673
+ const x = a.current;
1674
+ if (!x) return;
1675
+ o.solve(w, h.current);
1676
+ const L = o.crossScale;
1677
+ x.matrix.multiplyMatrices(o.forearmFrame, g.makeScale(L, 1, L)), x.matrixWorldNeedsUpdate = !0, x.updateMatrixWorld(!0);
1678
+ });
1679
+ }, [o, i]);
1680
+ const u = !s;
1681
+ if (Z(() => {
1682
+ u && console.warn(
1683
+ `${re.loggerPrefix} WristAttachment must be inside a HandRig or HandOccluder`
1684
+ );
1685
+ }, [u]), !s || !l || !o) return null;
1686
+ const f = o.forearm, d = (e == null ? void 0 : e.position) ?? [0, 0, 0];
1687
+ return Pe(
1688
+ /* @__PURE__ */ at("group", { ref: a, matrixAutoUpdate: !1, children: /* @__PURE__ */ at(
1689
+ "group",
1690
+ {
1691
+ position: [d[0], d[1] - t, d[2]],
1692
+ rotation: (e == null ? void 0 : e.rotation) ?? [0, 0, 0],
1693
+ scale: (e == null ? void 0 : e.scale) ?? 1,
1694
+ children: typeof n == "function" ? n(l) : n
1695
+ }
1696
+ ) }),
1697
+ f
1698
+ );
1699
+ }, Wi = -1, Ui = (t, { length: e = Eo, scale: n = 1 } = {}) => {
1700
+ const s = t.palmLength * e, o = t.palmLength * Ro, i = t.width / 2 * n, r = new c.CylinderGeometry(
1701
+ i,
1702
+ i * ko,
1703
+ s + o,
1704
+ 24,
1705
+ 1,
1706
+ !1
1707
+ );
1708
+ return r.translate(0, (o - s) / 2, 0), r.scale(1, 1, t.depth / t.width), r;
1709
+ }, Pi = ({
1710
+ length: t,
1711
+ scale: e,
1712
+ showDebugMaterial: n = !1,
1713
+ opacity: s = 0.5
1714
+ }) => {
1715
+ const o = K(
1716
+ () => new c.MeshBasicMaterial({
1717
+ color: 13948120,
1718
+ colorWrite: !1,
1719
+ depthWrite: !0,
1720
+ side: c.DoubleSide
1721
+ }),
1722
+ []
1723
+ );
1724
+ return Z(() => () => o.dispose(), [o]), Z(() => {
1725
+ o.colorWrite = n, o.transparent = n, o.opacity = n ? s : 1, o.needsUpdate = !0;
1726
+ }, [o, n, s]), /* @__PURE__ */ at(Fi, { along: 0, children: (i) => /* @__PURE__ */ at(qi, { wrist: i, length: t, scale: e, material: o }) });
1727
+ }, qi = ({
1728
+ wrist: t,
1729
+ length: e,
1730
+ scale: n,
1731
+ material: s
1732
+ }) => {
1733
+ const o = K(
1734
+ () => Ui(t, { length: e, scale: n }),
1735
+ [t, e, n]
1736
+ );
1737
+ return Z(() => () => o.dispose(), [o]), /* @__PURE__ */ at(
1738
+ "mesh",
1739
+ {
1740
+ name: "ForearmOccluder",
1741
+ geometry: o,
1742
+ material: s,
1743
+ renderOrder: Wi,
1744
+ frustumCulled: !1
1745
+ }
1746
+ );
1747
+ }, Ba = ds, Fa = je, Wa = ps, Ua = ({
1748
+ inflate: t = 0,
1749
+ showDebugMaterial: e = !1,
1750
+ opacity: n = 0.5,
1751
+ onModel: s,
1752
+ forearm: o = !1,
1753
+ children: i,
1754
+ ...r
1755
+ }) => {
1756
+ const a = Li(
1757
+ { inflate: t, showDebugMaterial: e, opacity: n },
1758
+ we,
1759
+ s
1760
+ );
1761
+ return /* @__PURE__ */ ie(Uo, { ...r, material: a.material, onModel: a.onModel, children: [
1762
+ o && /* @__PURE__ */ at(
1763
+ Pi,
1764
+ {
1765
+ ...o === !0 ? {} : o,
1766
+ showDebugMaterial: e,
1767
+ opacity: n
1768
+ }
1769
+ ),
1770
+ i
1771
+ ] });
1772
+ }, Ci = 0.55, zi = 1, ji = [0.1, 0.4], Hn = ["indexMcp", "middleMcp", "ringMcp", "pinkyMcp"], Gi = (t, e) => {
1773
+ const n = (h) => t.restPositions[ut[h]], s = new c.Vector3();
1774
+ for (const h of Hn) s.add(n(h));
1775
+ s.multiplyScalar(1 / Hn.length);
1776
+ const o = new c.Vector3().addVectors(n("wrist"), s).multiplyScalar(0.5), i = t.restPalmNormal.clone().normalize();
1777
+ e === "back" && i.negate();
1778
+ const r = s.clone().sub(n("wrist"));
1779
+ r.addScaledVector(i, -r.dot(i)).normalize();
1780
+ const a = new c.Vector3().crossVectors(r, i).normalize(), l = Math.sign(n("thumbCmc").clone().sub(o).dot(a)) || 1;
1781
+ return {
1782
+ origin: o,
1783
+ normal: i,
1784
+ up: r,
1785
+ right: a,
1786
+ thumb: a.clone().multiplyScalar(l),
1787
+ palm: n("middleMcp").distanceTo(n("wrist"))
1788
+ };
1789
+ }, Qi = {
1790
+ basis: new c.Matrix4(),
1791
+ shift: new c.Matrix4(),
1792
+ centre: new c.Vector3()
1793
+ }, fs = (t, e, { size: n, offset: s }, o = new c.Matrix4()) => {
1794
+ const { basis: i, shift: r, centre: a } = Qi;
1795
+ a.copy(t.origin).addScaledVector(t.thumb, (s == null ? void 0 : s[0]) ?? 0).addScaledVector(t.up, (s == null ? void 0 : s[1]) ?? 0), i.makeBasis(t.right, t.up, t.normal).transpose(), r.makeTranslation(-a.x, -a.y, -a.z);
1796
+ const l = 1 / Math.max(n, 1e-9);
1797
+ return o.makeScale(l, l, l).multiply(i).multiply(r).multiply(e);
1798
+ }, Ki = new c.Matrix4(), Vn = (t, e, n) => {
1799
+ n.identity();
1800
+ for (let s = t; s && s !== e; s = s.parent)
1801
+ s.updateMatrix(), n.premultiply(s.matrix);
1802
+ return n;
1803
+ }, ms = (t, e, n = new c.Matrix4()) => {
1804
+ const s = e, o = t.bones.wrist, i = s.isSkinnedMesh && o ? s.skeleton.bones.indexOf(o) : -1;
1805
+ return i < 0 ? Vn(e, t.root, n) : (Vn(o, t.root, n), n.multiply(Ki.copy(s.skeleton.boneInverses[i])).multiply(s.bindMatrix));
1806
+ }, Pa = (t, { rotation: e = 0, aspect: n = 1, mirrored: s = !1 } = {}, o = new c.Vector2()) => {
1807
+ if (t.z < 0) return null;
1808
+ const i = s ? -t.x : t.x, r = Math.cos(e), a = Math.sin(e), l = r * i + a * t.y + 0.5, h = (-a * i + r * t.y) * n + 0.5;
1809
+ return l < 0 || l > 1 || h < 0 || h > 1 ? null : o.set(l, h);
1810
+ }, Yi = (
1811
+ /* glsl */
1812
+ `
1813
+ #include <common>
1814
+ #include <skinning_pars_vertex>
1815
+ #include <logdepthbuf_pars_vertex>
1816
+ uniform mat4 decalMatrix;
1817
+ varying vec3 vDecal;
1818
+ varying float vFacing;
1819
+ varying float vMirror;
1820
+ void main() {
1821
+ // Decal space from the REST surface (before skinning): the art deforms with the skin.
1822
+ vDecal = ( decalMatrix * vec4( position, 1.0 ) ).xyz;
1823
+ vFacing = normalize( mat3( decalMatrix ) * normal ).z;
1824
+ // A mirrored hand (the model's other chirality): the art is flipped back.
1825
+ vMirror = determinant( mat3( modelMatrix ) ) < 0.0 ? 1.0 : 0.0;
1826
+ #include <begin_vertex>
1827
+ #include <skinbase_vertex>
1828
+ #include <skinning_vertex>
1829
+ #include <project_vertex>
1830
+ #include <logdepthbuf_vertex>
1831
+ }
1832
+ `
1833
+ ), $i = (
1834
+ /* glsl */
1835
+ `
1836
+ #include <common>
1837
+ #include <logdepthbuf_pars_fragment>
1838
+ uniform sampler2D map;
1839
+ uniform float opacity;
1840
+ uniform vec2 turn;
1841
+ uniform float aspect;
1842
+ uniform vec2 fade;
1843
+ varying vec3 vDecal;
1844
+ varying float vFacing;
1845
+ varying float vMirror;
1846
+ void main() {
1847
+ #include <logdepthbuf_fragment>
1848
+ if ( vDecal.z < 0.0 ) discard;
1849
+ vec2 p = vDecal.xy;
1850
+ if ( vMirror > 0.5 ) p.x = -p.x;
1851
+ vec2 uv = vec2( turn.x * p.x + turn.y * p.y, ( -turn.y * p.x + turn.x * p.y ) * aspect ) + 0.5;
1852
+ if ( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 ) discard;
1853
+ vec4 art = texture2D( map, uv );
1854
+ float a = art.a * opacity * smoothstep( fade.x, fade.y, vFacing );
1855
+ if ( a < 0.002 ) discard;
1856
+ gl_FragColor = vec4( art.rgb, 1.0 );
1857
+ #include <colorspace_fragment>
1858
+ // Premultiplied: the blend factors (setHandTattooBlend) mix by alpha.
1859
+ gl_FragColor = vec4( gl_FragColor.rgb * a, a );
1860
+ }
1861
+ `
1862
+ ), gs = (t, e) => {
1863
+ t.blending = c.CustomBlending, t.blendEquation = c.AddEquation, t.blendEquationAlpha = c.AddEquation, e === "multiply" ? (t.blendSrc = c.DstColorFactor, t.blendDst = c.OneMinusSrcAlphaFactor, t.blendSrcAlpha = c.ZeroFactor, t.blendDstAlpha = c.OneFactor) : (t.blendSrc = c.OneFactor, t.blendDst = c.OneMinusSrcAlphaFactor, t.blendSrcAlpha = c.OneFactor, t.blendDstAlpha = c.OneMinusSrcAlphaFactor);
1864
+ }, Ji = (t = "multiply") => {
1865
+ const e = new c.ShaderMaterial({
1866
+ uniforms: {
1867
+ map: { value: null },
1868
+ decalMatrix: { value: new c.Matrix4() },
1869
+ opacity: { value: 1 },
1870
+ turn: { value: new c.Vector2(1, 0) },
1871
+ aspect: { value: 1 },
1872
+ fade: { value: new c.Vector2(...ji) }
1873
+ },
1874
+ vertexShader: Yi,
1875
+ fragmentShader: $i,
1876
+ transparent: !0,
1877
+ depthWrite: !1,
1878
+ premultipliedAlpha: !0,
1879
+ polygonOffset: !0,
1880
+ polygonOffsetFactor: -1,
1881
+ polygonOffsetUnits: -1,
1882
+ toneMapped: !1
1883
+ });
1884
+ return gs(e, t), e;
1885
+ }, Xi = (t) => {
1886
+ const [e, n] = Vs(null), s = typeof t == "string" ? t : null;
1887
+ return Z(() => {
1888
+ if (!s) return;
1889
+ let o = !0, i = null;
1890
+ return new c.TextureLoader().load(
1891
+ s,
1892
+ (r) => {
1893
+ if (i = r, !o) {
1894
+ r.dispose();
1895
+ return;
1896
+ }
1897
+ r.colorSpace = c.SRGBColorSpace, n({ url: s, texture: r });
1898
+ },
1899
+ void 0,
1900
+ () => console.warn(`${re.loggerPrefix} HandTattoo could not load ${s}`)
1901
+ ), () => {
1902
+ o = !1, i == null || i.dispose();
1903
+ };
1904
+ }, [s]), typeof t != "string" ? t : (e == null ? void 0 : e.url) === t ? e.texture : null;
1905
+ }, Zi = (t) => {
1906
+ const e = t.image;
1907
+ return e != null && e.width && (e != null && e.height) ? e.width / e.height : 1;
1908
+ }, qa = ({
1909
+ src: t,
1910
+ placement: e = "back",
1911
+ size: n,
1912
+ offset: s,
1913
+ rotation: o = 0,
1914
+ opacity: i = 0.9,
1915
+ blend: r = "multiply",
1916
+ renderOrder: a = zi
1917
+ }) => {
1918
+ const l = qt(Me), h = Xi(t), u = K(() => {
1919
+ if (!l) return [];
1920
+ const _ = [];
1921
+ return l.root.traverse((w) => {
1922
+ w instanceof c.Mesh && w.userData[we] && _.push(w);
1923
+ }), _.map((w) => {
1924
+ const x = Ji(), L = w;
1925
+ let V;
1926
+ if (L.isSkinnedMesh) {
1927
+ const N = new c.SkinnedMesh(w.geometry, x);
1928
+ N.bindMode = L.bindMode, N.bind(L.skeleton, L.bindMatrix), V = N;
1929
+ } else
1930
+ V = new c.Mesh(w.geometry, x);
1931
+ return V.name = `${w.name}_tattoo`, V.frustumCulled = !1, V.position.copy(w.position), V.quaternion.copy(w.quaternion), V.scale.copy(w.scale), {
1932
+ mesh: V,
1933
+ source: w,
1934
+ material: x,
1935
+ geometryToRoot: ms(l, w)
1936
+ };
1937
+ });
1938
+ }, [l]);
1939
+ Z(() => {
1940
+ var _;
1941
+ for (const { mesh: w, source: x } of u) (_ = x.parent) == null || _.add(w);
1942
+ return () => {
1943
+ for (const { mesh: w, material: x } of u)
1944
+ w.removeFromParent(), x.dispose();
1945
+ };
1946
+ }, [u]);
1947
+ const f = K(
1948
+ () => l ? Gi(l, e) : null,
1949
+ [l, e]
1950
+ ), d = (s == null ? void 0 : s[0]) ?? 0, g = (s == null ? void 0 : s[1]) ?? 0;
1951
+ Z(() => {
1952
+ if (!f) return;
1953
+ const _ = n ?? Ci * f.palm;
1954
+ for (const { mesh: w, material: x, geometryToRoot: L } of u) {
1955
+ const V = x.uniforms;
1956
+ fs(
1957
+ f,
1958
+ L,
1959
+ { size: _, offset: [d, g] },
1960
+ V.decalMatrix.value
1961
+ ), V.map.value = h, V.opacity.value = c.MathUtils.clamp(i, 0, 1), V.turn.value.set(Math.cos(o), Math.sin(o)), V.aspect.value = h ? Zi(h) : 1, gs(x, r), w.renderOrder = a, w.visible = !!h;
1962
+ }
1963
+ }, [u, f, h, n, d, g, o, i, r, a]);
1964
+ const M = !l;
1965
+ return Z(() => {
1966
+ M && console.warn(`${re.loggerPrefix} HandTattoo must be inside a HandRig or HandOccluder`);
1967
+ }, [M]), null;
1968
+ }, Ht = ["thumb", "index", "middle", "ring", "pinky"], tr = ["round", "almond", "square"], Ca = [
1969
+ "matte",
1970
+ "gloss",
1971
+ "metallic"
1972
+ ], Bn = {
1973
+ matte: { shine: 0.08, metal: 0 },
1974
+ gloss: { shine: 0.8, metal: 0 },
1975
+ metallic: { shine: 0.65, metal: 1 }
1976
+ }, Fn = {
1977
+ cherry: "#c8102e",
1978
+ coral: "#ff6f61",
1979
+ ballet: "#f1c4cc",
1980
+ nude: "#d9a692",
1981
+ plum: "#5a1a3a",
1982
+ noir: "#1a1419",
1983
+ mint: "#a8e0cf",
1984
+ sky: "#8ec5ff"
1985
+ }, er = [0.1, 0.4], nr = 2, sr = 0.42, or = 0.55, ir = 0.62, rr = {
1986
+ thumb: ["thumbIp", "thumbTip"],
1987
+ index: ["indexDip", "indexTip"],
1988
+ middle: ["middleDip", "middleTip"],
1989
+ ring: ["ringDip", "ringTip"],
1990
+ pinky: ["pinkyDip", "pinkyTip"]
1991
+ }, ar = (t, e, {
1992
+ widthRatio: n = sr,
1993
+ lengthRatio: s = or
1994
+ } = {}) => {
1995
+ const o = (_) => t.restPositions[ut[_]], [i, r] = rr[e], a = o(i), l = o(r), h = l.clone().sub(a), u = h.length();
1996
+ h.normalize();
1997
+ const f = t.restPalmNormal.clone().negate();
1998
+ f.addScaledVector(h, -f.dot(h)).normalize();
1999
+ const d = new c.Vector3().crossVectors(h, f).normalize(), g = l.clone().addScaledVector(h, -u * ir), M = Math.sign(o("thumbCmc").clone().sub(o("wrist")).dot(d)) || 1;
2000
+ return {
2001
+ finger: e,
2002
+ origin: g,
2003
+ normal: f,
2004
+ up: h,
2005
+ right: d,
2006
+ thumb: d.clone().multiplyScalar(M),
2007
+ palm: o("middleMcp").distanceTo(o("wrist")),
2008
+ segment: u,
2009
+ width: u * n,
2010
+ length: u * s
2011
+ };
2012
+ }, ys = (t) => Math.min(1, Math.max(0, t)), lr = (t, e, n, s) => {
2013
+ const o = 0.5 / n;
2014
+ let i = Math.abs(t);
2015
+ s === "almond" && e > 0 && (i /= 1 - 0.3 * ys(e / o));
2016
+ const r = s === "square" ? 0.12 : 0.5, l = e > 0 ? r : 0.22, h = i - 0.5 + l, u = Math.abs(e) - o + l;
2017
+ return Math.hypot(Math.max(h, 0), Math.max(u, 0)) + Math.min(Math.max(h, u), 0) - l;
2018
+ }, za = (t, e, n, s, o = 0.04) => ys(0.5 - lr(t, e, n, s) / o), cr = { width: 0.42, length: 0.55, centre: 0.62 }, hr = (t, { base: e, tip: n }, s, { width: o, length: i, centre: r } = cr) => {
2019
+ const a = n.x - e.x, l = n.y - e.y, h = Math.hypot(a, l);
2020
+ if (!(h > 1e-6)) return 0;
2021
+ const u = a / h, f = l / h, d = n.x - u * h * r, g = n.y - f * h * r, M = o * h / 2, _ = i * h / 2, w = Math.min(M, _) * 0.8, x = Math.max(0, Math.floor(d - h)), L = Math.min(t.width - 1, Math.ceil(d + h)), V = Math.max(0, Math.floor(g - h)), N = Math.min(t.height - 1, Math.ceil(g + h));
2022
+ let W = 0;
2023
+ for (let E = V; E <= N; E += 1)
2024
+ for (let R = x; R <= L; R += 1) {
2025
+ const J = R + 0.5 - d, H = E + 0.5 - g, C = J * u + H * f, tt = -J * f + H * u, Y = Math.abs(tt) - M + w, ot = Math.abs(C) - _ + w;
2026
+ Math.hypot(Math.max(Y, 0), Math.max(ot, 0)) + Math.min(Math.max(Y, ot), 0) - w <= 0 && (t.indices[E * t.width + R] = s, W += 1);
2027
+ }
2028
+ return W;
2029
+ }, ur = (t, e, n, s, { rise: o = 96, fall: i = 64 } = {}) => {
2030
+ const r = t.width * t.height;
2031
+ for (let a = 0; a < r; a += 1) {
2032
+ const l = e[a], h = t.indices[a] === s ? Math.min(255, l + o) : Math.max(0, l - i);
2033
+ e[a] = h, n.indices[a] = h >= 128 ? s : 0;
2034
+ }
2035
+ }, dr = (t, e, n, s, o, i = 6) => {
2036
+ const { width: r, height: a, indices: l } = t, h = n.map(() => !1);
2037
+ if (s.width !== r || s.height !== a) return h;
2038
+ const u = new Uint8Array(r * a), f = [], d = [];
2039
+ for (let g = 0; g < l.length; g += 1) {
2040
+ if (l[g] !== e || u[g]) continue;
2041
+ d.length = 0, f.length = 0, f.push(g), u[g] = 1;
2042
+ let M = 0, _ = 0;
2043
+ for (; f.length; ) {
2044
+ const N = f.pop();
2045
+ d.push(N);
2046
+ const W = N % r, E = (N - W) / r;
2047
+ M += W, _ += E, W > 0 && !u[N - 1] && l[N - 1] === e && (u[N - 1] = 1, f.push(N - 1)), W < r - 1 && !u[N + 1] && l[N + 1] === e && (u[N + 1] = 1, f.push(N + 1)), E > 0 && !u[N - r] && l[N - r] === e && (u[N - r] = 1, f.push(N - r)), E < a - 1 && !u[N + r] && l[N + r] === e && (u[N + r] = 1, f.push(N + r));
2048
+ }
2049
+ if (d.length < i) continue;
2050
+ const w = M / d.length, x = _ / d.length;
2051
+ let L = -1, V = 1 / 0;
2052
+ if (n.forEach((N, W) => {
2053
+ if (!N) return;
2054
+ const E = Math.hypot(N.x - w, N.y - x);
2055
+ E <= N.reach && E < V && (V = E, L = W);
2056
+ }), !(L < 0)) {
2057
+ h[L] = !0;
2058
+ for (const N of d) s.indices[N] = o;
2059
+ }
2060
+ }
2061
+ return h;
2062
+ }, De = (t, e, n, s) => {
2063
+ const o = Math.round(e * s), i = Math.round(n * s);
2064
+ return o < 0 || i < 0 || o >= t.width || i >= t.height ? !1 : t.inside(i * t.width + o);
2065
+ }, pr = (t, e, n, { from: s = 0.6, to: o = 1.2, spread: i = 0.12, gap: r = 0.12, samples: a = 24 } = {}) => {
2066
+ const l = n.x - e.x, h = n.y - e.y, u = Math.hypot(l, h);
2067
+ if (!(u > 1e-6) || t.width <= 0 || t.height <= 0) return null;
2068
+ const f = l / u, d = h / u, g = -d * i * u, M = f * i * u, _ = 1 / a, w = t.height, x = (R) => {
2069
+ const J = n.x + f * R * u, H = n.y + d * R * u;
2070
+ return De(t, J, H, w) || De(t, J + g, H + M, w) || De(t, J - g, H - M, w);
2071
+ };
2072
+ let L = 0, V = 0;
2073
+ for (let R = -s; R < -s + 0.25; R += _)
2074
+ V += 1, x(R) && (L += 1);
2075
+ const N = V > 0 ? L / V : 0;
2076
+ if (N < 0.5) return null;
2077
+ let W = -s, E = 0;
2078
+ for (let R = -s; R <= o; R += _)
2079
+ if (x(R))
2080
+ W = R, E = 0;
2081
+ else if (E += _, E > r) break;
2082
+ return { offset: W * u, confidence: N };
2083
+ }, ws = Ht.length, fr = (
2084
+ /* glsl */
2085
+ `
2086
+ #include <common>
2087
+ #include <skinning_pars_vertex>
2088
+ #include <logdepthbuf_pars_vertex>
2089
+ #define NAILS ${ws}
2090
+ uniform mat4 decalMatrix[NAILS];
2091
+ varying vec3 vDecal[NAILS];
2092
+ varying float vFacing[NAILS];
2093
+ varying vec3 vViewNormal;
2094
+ void main() {
2095
+ // Decal space from the REST surface (before skinning): the polish deforms with the finger.
2096
+ for ( int i = 0; i < NAILS; i ++ ) {
2097
+ vDecal[i] = ( decalMatrix[i] * vec4( position, 1.0 ) ).xyz;
2098
+ vFacing[i] = normalize( mat3( decalMatrix[i] ) * normal ).z;
2099
+ }
2100
+ #include <beginnormal_vertex>
2101
+ #include <skinbase_vertex>
2102
+ #include <skinnormal_vertex>
2103
+ #include <defaultnormal_vertex>
2104
+ vViewNormal = normalize( transformedNormal );
2105
+ #include <begin_vertex>
2106
+ #include <skinning_vertex>
2107
+ #include <project_vertex>
2108
+ #include <logdepthbuf_vertex>
2109
+ }
2110
+ `
2111
+ ), mr = (
2112
+ /* glsl */
2113
+ `
2114
+ #include <common>
2115
+ #include <logdepthbuf_pars_fragment>
2116
+ #define NAILS ${ws}
2117
+ uniform vec3 color;
2118
+ uniform float opacity;
2119
+ uniform float shine;
2120
+ uniform float metal;
2121
+ uniform float shape;
2122
+ uniform float aspect[NAILS];
2123
+ uniform float enabled[NAILS];
2124
+ uniform vec2 fade;
2125
+ varying vec3 vDecal[NAILS];
2126
+ varying float vFacing[NAILS];
2127
+ varying vec3 vViewNormal;
2128
+
2129
+ // Signed distance to the nail outline, in nail widths (handNailDistance in JS).
2130
+ float nailDistance( vec2 p, float asp ) {
2131
+ float halfH = 0.5 / asp;
2132
+ float px = abs( p.x );
2133
+ if ( shape > 0.5 && shape < 1.5 && p.y > 0.0 ) px /= 1.0 - 0.3 * clamp( p.y / halfH, 0.0, 1.0 );
2134
+ float tipRadius = shape > 1.5 ? 0.12 : 0.5;
2135
+ float r = p.y > 0.0 ? tipRadius : 0.22;
2136
+ vec2 q = vec2( px - 0.5 + r, abs( p.y ) - halfH + r );
2137
+ return length( max( q, 0.0 ) ) + min( max( q.x, q.y ), 0.0 ) - r;
2138
+ }
2139
+
2140
+ void main() {
2141
+ #include <logdepthbuf_fragment>
2142
+ float cover = 0.0;
2143
+ float band = 0.0;
2144
+ for ( int i = 0; i < NAILS; i ++ ) {
2145
+ if ( enabled[i] < 0.5 || vDecal[i].z < 0.0 ) continue;
2146
+ float d = nailDistance( vDecal[i].xy, aspect[i] );
2147
+ float edge = max( fwidth( d ), 0.01 );
2148
+ float a = clamp( 0.5 - d / edge, 0.0, 1.0 ) * smoothstep( fade.x, fade.y, vFacing[i] );
2149
+ if ( a > cover ) {
2150
+ cover = a;
2151
+ // A soft reflection band across the nail, a third of the way from the base.
2152
+ float along = vDecal[i].y * aspect[i] + 0.5;
2153
+ band = smoothstep( 0.22, 0.0, abs( along - 0.3 ) ) * ( 1.0 - 0.5 * abs( vDecal[i].x ) * 2.0 );
2154
+ }
2155
+ }
2156
+ float a = cover * opacity;
2157
+ if ( a < 0.002 ) discard;
2158
+ // A soft studio light from above the camera.
2159
+ vec3 n = normalize( vViewNormal );
2160
+ vec3 l = normalize( vec3( 0.3, 0.6, 1.0 ) );
2161
+ float diffuse = mix( 0.72, 0.45, metal ) + mix( 0.28, 0.75, metal ) * max( dot( n, l ), 0.0 );
2162
+ vec3 h = normalize( l + vec3( 0.0, 0.0, 1.0 ) );
2163
+ float spec = pow( max( dot( n, h ), 0.0 ), mix( 40.0, 10.0, metal ) ) * shine * 1.2;
2164
+ float rim = pow( 1.0 - max( n.z, 0.0 ), 2.0 ) * 0.4 * shine;
2165
+ vec3 tint = mix( vec3( 1.0 ), mix( color, vec3( 1.0 ), 0.25 ), metal );
2166
+ vec3 rgb = color * diffuse + tint * ( spec * 0.8 + rim * 0.6 + band * shine * 0.3 );
2167
+ gl_FragColor = vec4( rgb, 1.0 );
2168
+ #include <colorspace_fragment>
2169
+ gl_FragColor = vec4( gl_FragColor.rgb * a, a );
2170
+ }
2171
+ `
2172
+ ), gr = () => new c.ShaderMaterial({
2173
+ uniforms: {
2174
+ decalMatrix: { value: Ht.map(() => new c.Matrix4()) },
2175
+ aspect: { value: Ht.map(() => 1) },
2176
+ enabled: { value: Ht.map(() => 1) },
2177
+ color: { value: new c.Color("#c8102e") },
2178
+ opacity: { value: 1 },
2179
+ shine: { value: 0.8 },
2180
+ metal: { value: 0 },
2181
+ shape: { value: 0 },
2182
+ fade: { value: new c.Vector2(...er) }
2183
+ },
2184
+ vertexShader: fr,
2185
+ fragmentShader: mr,
2186
+ transparent: !0,
2187
+ depthWrite: !1,
2188
+ premultipliedAlpha: !0,
2189
+ blending: c.CustomBlending,
2190
+ blendSrc: c.OneFactor,
2191
+ blendDst: c.OneMinusSrcAlphaFactor,
2192
+ blendSrcAlpha: c.OneFactor,
2193
+ blendDstAlpha: c.OneMinusSrcAlphaFactor,
2194
+ polygonOffset: !0,
2195
+ polygonOffsetFactor: -2,
2196
+ polygonOffsetUnits: -2,
2197
+ toneMapped: !1
2198
+ }), yr = ["bg", "nail"], Ne = 1, Le = zs.BACKGROUND + 12, wr = 1.2, He = (t) => t in Fn ? Fn[t] : t, Wn = {
2199
+ thumb: ["thumbIp", "thumbTip"],
2200
+ index: ["indexDip", "indexTip"],
2201
+ middle: ["middleDip", "middleTip"],
2202
+ ring: ["ringDip", "ringTip"],
2203
+ pinky: ["pinkyDip", "pinkyTip"]
2204
+ }, Mr = 1, ja = ({
2205
+ color: t = "cherry",
2206
+ finish: e = "gloss",
2207
+ shape: n = "round",
2208
+ opacity: s = 1,
2209
+ fingers: o = Ht,
2210
+ size: i = 1,
2211
+ along: r = 0,
2212
+ refine: a = !0,
2213
+ refineSmoothing: l = 0.35,
2214
+ mode: h = "image",
2215
+ view: u = "polish",
2216
+ modelUrl: f,
2217
+ renderOrder: d = nr
2218
+ }) => {
2219
+ const g = qt(Me), M = qt(as), _ = Ot((S) => S.scene), w = Ot((S) => S.size), x = te(Et.HAND_TRACKER), L = h === "image", V = K(
2220
+ () => f ? { preset: "nails", modelUrl: f } : { preset: "nails" },
2221
+ [f]
2222
+ );
2223
+ ee(
2224
+ Et.SEMANTIC_SEGMENTATION,
2225
+ V,
2226
+ L
2227
+ );
2228
+ const N = te(Et.SEMANTIC_SEGMENTATION), W = Fe(a && !L ? "skin" : !1), E = st(Ht.map(() => 0)), R = K(
2229
+ () => ({
2230
+ width: 1,
2231
+ height: 1,
2232
+ indices: new Uint8Array(1),
2233
+ labels: yr,
2234
+ space: "feed",
2235
+ version: 0
2236
+ }),
2237
+ []
2238
+ ), J = st(
2239
+ null
2240
+ ), H = K(() => {
2241
+ if (!g) return [];
2242
+ const S = [];
2243
+ return g.root.traverse((y) => {
2244
+ y instanceof c.Mesh && y.userData[we] && S.push(y);
2245
+ }), S.map((y) => {
2246
+ const k = gr(), p = y;
2247
+ let v;
2248
+ if (p.isSkinnedMesh) {
2249
+ const b = new c.SkinnedMesh(y.geometry, k);
2250
+ b.bindMode = p.bindMode, b.bind(p.skeleton, p.bindMatrix), v = b;
2251
+ } else
2252
+ v = new c.Mesh(y.geometry, k);
2253
+ return v.name = `${y.name}_nails`, v.frustumCulled = !1, v.position.copy(y.position), v.quaternion.copy(y.quaternion), v.scale.copy(y.scale), { mesh: v, source: y, material: k, geometryToRoot: ms(g, y) };
2254
+ });
2255
+ }, [g]);
2256
+ Z(() => {
2257
+ var S;
2258
+ for (const { mesh: y, source: k } of H) (S = k.parent) == null || S.add(y);
2259
+ return () => {
2260
+ for (const { mesh: y, material: k } of H)
2261
+ y.removeFromParent(), k.dispose();
2262
+ };
2263
+ }, [H]);
2264
+ const C = K(
2265
+ () => g ? Ht.map((S) => ar(g, S)) : null,
2266
+ [g]
2267
+ ), tt = o.join(","), Y = st({ size: i, along: r, fingers: o });
2268
+ Y.current = { size: i, along: r, fingers: o };
2269
+ const ot = K(
2270
+ () => () => {
2271
+ if (!C) return;
2272
+ const { size: S, along: y } = Y.current;
2273
+ for (const { material: k, geometryToRoot: p } of H) {
2274
+ const v = k.uniforms;
2275
+ C.forEach((b, T) => {
2276
+ fs(
2277
+ b,
2278
+ p,
2279
+ { size: b.width * S, offset: [0, y + E.current[T]] },
2280
+ v.decalMatrix.value[T]
2281
+ );
2282
+ });
2283
+ }
2284
+ },
2285
+ [C, H]
2286
+ );
2287
+ Z(() => {
2288
+ if (!(L || !W || !C || !M))
2289
+ return de(_, () => {
2290
+ var T, A;
2291
+ const S = ((T = x == null ? void 0 : x.getHandPose) == null ? void 0 : T.call(x, M)) ?? ((A = x == null ? void 0 : x.poses) == null ? void 0 : A[M]) ?? null;
2292
+ if (!S || S.image.length < 21 || S.held) return;
2293
+ const y = w.width / Math.max(1, w.height);
2294
+ if (!W.refresh(performance.now())) return;
2295
+ const k = Zn(S, y);
2296
+ if (!k) return;
2297
+ const p = (D) => ({
2298
+ x: (S.image[D].x + 1) / 2 * y,
2299
+ y: (1 - S.image[D].y) / 2
2300
+ }), v = c.MathUtils.clamp(l, 0.01, 1);
2301
+ let b = !1;
2302
+ C.forEach((D, F) => {
2303
+ const [I, q] = Wn[D.finger], j = pr(
2304
+ W,
2305
+ p(ut[I]),
2306
+ p(ut[q])
2307
+ ), Q = j ? j.offset / k.unitsPerCm : 0, $ = D.segment * Mr, it = c.MathUtils.clamp(Q, -$, $), X = E.current[F], lt = X + (it - X) * v;
2308
+ Math.abs(lt - X) > 1e-4 && (E.current[F] = lt, b = !0);
2309
+ }), b && ot();
2310
+ });
2311
+ }, [L, W, C, M, x, _, w, l, ot]), Z(() => {
2312
+ if (!(!L || !M))
2313
+ return de(_, () => {
2314
+ var T, A;
2315
+ const S = N == null ? void 0 : N.getMask();
2316
+ if (!S || S.version === 0) return;
2317
+ let y = J.current;
2318
+ if (!y || R.width !== S.width || R.height !== S.height) {
2319
+ const D = S.width * S.height;
2320
+ R.width = S.width, R.height = S.height, R.indices = new Uint8Array(D), y = J.current = {
2321
+ fresh: { width: S.width, height: S.height, indices: new Uint8Array(D) },
2322
+ coverage: new Uint8Array(D),
2323
+ seen: -1
2324
+ };
2325
+ }
2326
+ if (y.seen === S.version) return;
2327
+ y.seen = S.version;
2328
+ const k = S.labels.indexOf("nail"), p = ((T = x == null ? void 0 : x.getHandPose) == null ? void 0 : T.call(x, M)) ?? ((A = x == null ? void 0 : x.poses) == null ? void 0 : A[M]) ?? null, { fresh: v, coverage: b } = y;
2329
+ if (v.indices.fill(0), k >= 0 && p && p.image.length >= 21 && !p.held) {
2330
+ const D = (Q) => ({
2331
+ x: (p.image[Q].x + 1) / 2 * S.width,
2332
+ y: (1 - p.image[Q].y) / 2 * S.height
2333
+ }), F = Y.current.fingers, I = Ht.map((Q) => {
2334
+ const [$, it] = Wn[Q];
2335
+ return {
2336
+ finger: Q,
2337
+ base: D(ut[$]),
2338
+ tip: D(ut[it])
2339
+ };
2340
+ }), q = I.map(({ finger: Q, base: $, tip: it }) => {
2341
+ if (!F.includes(Q)) return null;
2342
+ const X = Math.hypot(it.x - $.x, it.y - $.y);
2343
+ return { x: it.x, y: it.y, reach: Math.max(X * wr, 8) };
2344
+ }), j = dr(S, k, q, v, Ne);
2345
+ I.forEach((Q, $) => {
2346
+ q[$] && !j[$] && hr(v, Q, Ne);
2347
+ });
2348
+ }
2349
+ ur(v, b, R, Ne), R.version += 1, R.timestampMs = S.timestampMs;
2350
+ });
2351
+ }, [L, M, x, _, N, R]), Z(() => {
2352
+ a || E.current.fill(0);
2353
+ }, [a]), Z(() => {
2354
+ if (!C) return;
2355
+ const S = Bn[e];
2356
+ ot();
2357
+ for (const { mesh: y, material: k } of H) {
2358
+ const p = k.uniforms;
2359
+ C.forEach((v, b) => {
2360
+ p.aspect.value[b] = v.width / v.length, p.enabled.value[b] = o.includes(v.finger) ? 1 : 0;
2361
+ }), p.color.value.set(He(t)), p.opacity.value = c.MathUtils.clamp(s, 0, 1), p.shine.value = S.shine, p.metal.value = S.metal, p.shape.value = tr.indexOf(n), y.renderOrder = d, y.visible = !L;
2362
+ }
2363
+ }, [
2364
+ H,
2365
+ C,
2366
+ t,
2367
+ e,
2368
+ n,
2369
+ s,
2370
+ tt,
2371
+ i,
2372
+ r,
2373
+ d,
2374
+ ot,
2375
+ L
2376
+ ]);
2377
+ const z = !g;
2378
+ if (Z(() => {
2379
+ z && console.warn(`${re.loggerPrefix} HandNails must be inside a HandRig or HandOccluder`);
2380
+ }, [z]), !L || !g) return null;
2381
+ const rt = Bn[e];
2382
+ return Pe(
2383
+ u === "mask" ? /* @__PURE__ */ at(
2384
+ be,
2385
+ {
2386
+ mask: R,
2387
+ label: "nail",
2388
+ color: "#ff2bd6",
2389
+ opacity: 1,
2390
+ blendMode: "normal",
2391
+ feather: 0,
2392
+ renderOrder: Le
2393
+ }
2394
+ ) : /* @__PURE__ */ ie(Ws, { children: [
2395
+ /* @__PURE__ */ at(
2396
+ be,
2397
+ {
2398
+ mask: R,
2399
+ label: "nail",
2400
+ color: He(t),
2401
+ opacity: c.MathUtils.clamp(s, 0, 1),
2402
+ blendMode: "multiply",
2403
+ feather: 1,
2404
+ renderOrder: Le
2405
+ }
2406
+ ),
2407
+ rt.shine > 0.2 && /* @__PURE__ */ at(
2408
+ be,
2409
+ {
2410
+ mask: R,
2411
+ label: "nail",
2412
+ color: rt.metal > 0.5 ? He(t) : "#ffffff",
2413
+ opacity: c.MathUtils.clamp(s, 0, 1) * rt.shine * 0.35,
2414
+ blendMode: "screen",
2415
+ feather: 1,
2416
+ renderOrder: Le + 1
2417
+ }
2418
+ )
2419
+ ] }),
2420
+ _
2421
+ );
2422
+ }, ae = [
2423
+ "thumbTip",
2424
+ "indexTip",
2425
+ "middleTip",
2426
+ "ringTip",
2427
+ "pinkyTip"
2428
+ ], Ms = Object.freeze({
2429
+ palmRadius: 0.5,
2430
+ tipRadius: 0.12,
2431
+ pinchStart: 0.3,
2432
+ pinchEnd: 0.45,
2433
+ pinchReady: 0.6,
2434
+ smoothing: 0.6
2435
+ }), xr = 100, vr = 8, Sr = 0.05, Un = () => ({
2436
+ center: new c.Vector3(),
2437
+ velocity: new c.Vector3(),
2438
+ radius: 0
2439
+ }), Ve = (t) => ({
2440
+ hand: t,
2441
+ tracked: !1,
2442
+ palmLength: 0,
2443
+ palm: Un(),
2444
+ tips: Object.fromEntries(ae.map((e) => [e, Un()])),
2445
+ pinchDistance: 1 / 0,
2446
+ pinching: !1,
2447
+ pinch: new c.Vector3(),
2448
+ pinchVelocity: new c.Vector3(),
2449
+ timeMs: null,
2450
+ history: []
2451
+ }), Vt = {
2452
+ palm: new c.Vector3(),
2453
+ knuckles: new c.Vector3(),
2454
+ previous: new c.Vector3(),
2455
+ raw: new c.Vector3()
2456
+ }, fe = (t, e, n, s, o, i) => {
2457
+ if (t.radius = n, s || i <= 0) {
2458
+ t.center.copy(e), t.velocity.set(0, 0, 0);
2459
+ return;
2460
+ }
2461
+ Vt.previous.copy(t.center), t.center.lerp(e, o), Vt.raw.subVectors(t.center, Vt.previous).divideScalar(i), t.velocity.lerp(Vt.raw, 1 - Math.exp(-i / Sr));
2462
+ }, xs = (t, e) => {
2463
+ const { history: n } = t;
2464
+ for (n.length >= vr && n.shift(), n.push({ timeMs: e, point: t.pinch.clone() }); n.length > 2 && e - n[1].timeMs >= xr; ) n.shift();
2465
+ const s = n[0], o = (e - s.timeMs) / 1e3;
2466
+ o > 0 ? t.pinchVelocity.subVectors(t.pinch, s.point).divideScalar(o) : t.pinchVelocity.set(0, 0, 0);
2467
+ }, vs = (t) => (t.tracked = !1, t.pinching = !1, t.pinchDistance = 1 / 0, t.timeMs = null, t.history.length = 0, t.pinchVelocity.set(0, 0, 0), t), Pn = (t, e, n, s = {}) => {
2468
+ const o = { ...Ms, ...s };
2469
+ if (!e || e.length < 21)
2470
+ return vs(t);
2471
+ if (t.tracked && t.timeMs === n) return t;
2472
+ const i = !t.tracked || t.timeMs === null, r = i ? 0 : Math.max(0, (n - t.timeMs) / 1e3), a = c.MathUtils.clamp(o.smoothing, 0.01, 1), l = (d) => e[ut[d]], h = l("wrist").distanceTo(l("middleMcp"));
2473
+ t.palmLength = i ? h : t.palmLength + (h - t.palmLength) * a, Vt.knuckles.copy(l("indexMcp")).add(l("middleMcp")).add(l("ringMcp")).add(l("pinkyMcp")).multiplyScalar(0.25), Vt.palm.copy(l("wrist")).add(Vt.knuckles).multiplyScalar(0.5), fe(t.palm, Vt.palm, t.palmLength * o.palmRadius, i, a, r);
2474
+ for (const d of ae)
2475
+ fe(t.tips[d], l(d), t.palmLength * o.tipRadius, i, a, r);
2476
+ const u = t.tips.thumbTip.center, f = t.tips.indexTip.center;
2477
+ return t.pinchDistance = u.distanceTo(f) / Math.max(t.palmLength, 1e-9), t.pinching ? t.pinching = t.pinchDistance <= o.pinchEnd : t.pinching = t.pinchDistance < o.pinchStart, t.pinch.addVectors(u, f).multiplyScalar(0.5), xs(t, n), t.tracked = !0, t.timeMs = n, t;
2478
+ }, br = (t, e, n, s, o) => {
2479
+ if (!e)
2480
+ return vs(t);
2481
+ const i = !t.tracked || t.timeMs === null, r = i ? 0 : Math.max(0, (s - t.timeMs) / 1e3);
2482
+ if (!i && r === 0) return t;
2483
+ t.palmLength = o, fe(t.palm, e, o, i, 1, r);
2484
+ for (const a of ae) fe(t.tips[a], e, 0, i, 1, r);
2485
+ return t.pinchDistance = n ? 0 : 1 / 0, t.pinching = n, t.pinch.copy(e), xs(t, s), t.tracked = !0, t.timeMs = s, t;
2486
+ }, Ss = Object.freeze({
2487
+ gravity: 9,
2488
+ damping: 0.4,
2489
+ bounce: 0.5,
2490
+ friction: 4,
2491
+ grabReach: 0.35,
2492
+ hoverReach: 0.5,
2493
+ tapMs: 350,
2494
+ tapSpeed: 1,
2495
+ throwScale: 1,
2496
+ maxSpeed: 14,
2497
+ flat: !0
2498
+ }), Ar = 1 / 120, _r = 1 / 20, Er = 0.35, kr = 0.5, Rr = 1.08, Tr = 1.2, he = new c.Vector3(0, 1, 0), qn = [new c.Vector3(1, 0, 0), new c.Vector3(0, 1, 0), new c.Vector3(0, 0, 1)], Or = ["x", "y", "z"], P = {
2499
+ d: new c.Vector3(),
2500
+ n: new c.Vector3(),
2501
+ v: new c.Vector3(),
2502
+ t: new c.Vector3(),
2503
+ q: new c.Quaternion(),
2504
+ q2: new c.Quaternion(),
2505
+ axis: new c.Vector3()
2506
+ }, Ir = (t) => [
2507
+ ["palm", t.palm],
2508
+ ...ae.map((e) => [e, t.tips[e]])
2509
+ ];
2510
+ class Dr {
2511
+ constructor(e = {}, n = {}) {
2512
+ B(this, "bodies", []);
2513
+ B(this, "bounds", new c.Box3(new c.Vector3(-2, -2, -1), new c.Vector3(2, 2, 1)));
2514
+ B(this, "settings");
2515
+ /** Simulated time, ms. */
2516
+ B(this, "timeMs", 0);
2517
+ B(this, "nextId", 1);
2518
+ B(this, "pinched", /* @__PURE__ */ new Map());
2519
+ /** What the pointer pressed on, and when (a quick click is a tap). */
2520
+ B(this, "press", null);
2521
+ B(this, "handSettings");
2522
+ this.settings = { ...Ss, ...e }, this.handSettings = n;
2523
+ }
2524
+ /** The hand collider settings `pinchReady` is read from. */
2525
+ setHandSettings(e) {
2526
+ this.handSettings = e;
2527
+ }
2528
+ add(e = {}) {
2529
+ const n = Math.max(1e-4, e.size ?? 0.4), s = {
2530
+ id: this.nextId,
2531
+ shape: e.shape ?? "sphere",
2532
+ size: n,
2533
+ radius: n / 2,
2534
+ mass: Math.max(1e-6, e.mass ?? n ** 3),
2535
+ bounce: e.bounce,
2536
+ grabbable: e.grabbable ?? !0,
2537
+ pushable: e.pushable ?? !0,
2538
+ gravity: e.gravity ?? !0,
2539
+ position: new c.Vector3(...e.position ?? [0, 0, 0]),
2540
+ velocity: new c.Vector3(...e.velocity ?? [0, 0, 0]),
2541
+ quaternion: new c.Quaternion(),
2542
+ spin: new c.Vector3(),
2543
+ grabbedBy: null,
2544
+ hoveredBy: null,
2545
+ resting: !1,
2546
+ userData: {},
2547
+ grabOffset: new c.Vector3(),
2548
+ contacts: /* @__PURE__ */ new Set(),
2549
+ tapStart: {}
2550
+ };
2551
+ return this.nextId += 1, this.bodies.push(s), s;
2552
+ }
2553
+ remove(e) {
2554
+ const n = this.bodies.indexOf(e);
2555
+ n >= 0 && this.bodies.splice(n, 1);
2556
+ }
2557
+ /** The nearest grabbable (`any`: any) object whose surface is within `reach` of `point`. */
2558
+ pick(e, n, s = !1) {
2559
+ let o = null, i = 1 / 0;
2560
+ for (const r of this.bodies) {
2561
+ if (!r.grabbable && !s) continue;
2562
+ const a = this.distance(r.position, e) - r.radius;
2563
+ a <= n && a < i && (o = r, i = a);
2564
+ }
2565
+ return o;
2566
+ }
2567
+ /** Advances `dt` seconds with these hands; returns what happened. */
2568
+ step(e, n) {
2569
+ const s = [], o = c.MathUtils.clamp(e, 0, _r);
2570
+ this.timeMs += o * 1e3;
2571
+ const i = /* @__PURE__ */ new Map();
2572
+ for (const l of n) l.tracked && i.set(l.hand, l);
2573
+ this.grabAndRelease(n, i, s);
2574
+ const r = /* @__PURE__ */ new Map(), a = Math.max(1, Math.ceil(o / Ar - 1e-9));
2575
+ for (let l = 0; l < a; l += 1) this.substep(o / a, i, r);
2576
+ for (const l of this.bodies) {
2577
+ const h = r.get(l);
2578
+ for (const [u, f] of h ?? []) {
2579
+ if (l.contacts.has(u)) continue;
2580
+ const [d, g] = u.split(":");
2581
+ s.push({ type: "touch", body: l, hand: d, part: g, speed: f });
2582
+ }
2583
+ l.contacts = new Set((h == null ? void 0 : h.keys()) ?? []);
2584
+ }
2585
+ return this.hoverAndTap(i, s), s;
2586
+ }
2587
+ /** Grab / hover reach: palm lengths for a hand; the pointer reaches as far as its sphere. */
2588
+ reach(e, n) {
2589
+ return e.hand === "pointer" ? e.palm.radius : e.palmLength * n;
2590
+ }
2591
+ distance(e, n) {
2592
+ return this.settings.flat ? Math.hypot(e.x - n.x, e.y - n.y) : e.distanceTo(n);
2593
+ }
2594
+ release(e, n, s) {
2595
+ const o = e.grabbedBy;
2596
+ e.grabbedBy = null, n && e.velocity.copy(n.pinchVelocity).multiplyScalar(this.settings.throwScale), e.velocity.clampLength(0, this.settings.maxSpeed), s.push({ type: "release", body: e, hand: o, speed: e.velocity.length() });
2597
+ }
2598
+ grabAndRelease(e, n, s) {
2599
+ for (const o of this.bodies)
2600
+ if (o.grabbedBy && !n.has(o.grabbedBy)) {
2601
+ const i = e.find((r) => r.hand === o.grabbedBy);
2602
+ this.release(o, i, s);
2603
+ }
2604
+ for (const o of e) {
2605
+ const i = o.tracked && o.pinching, r = this.pinched.get(o.hand) ?? !1, a = this.bodies.find((l) => l.grabbedBy === o.hand);
2606
+ if (i && !r && !a) {
2607
+ const l = this.pick(o.pinch, this.reach(o, this.settings.grabReach));
2608
+ l && (l.grabbedBy && s.push({ type: "release", body: l, hand: l.grabbedBy, speed: 0 }), l.grabbedBy = o.hand, l.grabOffset.subVectors(l.position, o.pinch).clampLength(0, l.radius), s.push({ type: "grab", body: l, hand: o.hand }));
2609
+ } else !i && a && this.release(a, o, s);
2610
+ o.hand === "pointer" && this.clickTap(o, i, r, s), this.pinched.set(o.hand, i);
2611
+ }
2612
+ }
2613
+ substep(e, n, s) {
2614
+ const o = this.settings;
2615
+ for (const i of this.bodies) {
2616
+ const r = i.grabbedBy ? n.get(i.grabbedBy) : void 0;
2617
+ r ? (P.t.addVectors(r.pinch, i.grabOffset), i.position.lerp(P.t, 1 - Math.exp(-30 * e)), i.velocity.copy(r.pinchVelocity), i.spin.multiplyScalar(Math.exp(-4 * e))) : (i.gravity && (i.velocity.y -= o.gravity * e), i.velocity.multiplyScalar(Math.exp(-o.damping * e)), i.velocity.clampLength(0, o.maxSpeed), i.spin.multiplyScalar(Math.exp(-o.damping * e)), i.position.addScaledVector(i.velocity, e)), this.turn(i, e), this.walls(i, e, !!r);
2618
+ }
2619
+ this.collideBodies(n), this.collideHands(n, s);
2620
+ }
2621
+ turn(e, n) {
2622
+ const s = e.spin.length() * n;
2623
+ s < 1e-9 || (P.axis.copy(e.spin).normalize(), P.q.setFromAxisAngle(P.axis, s), e.quaternion.premultiply(P.q).normalize());
2624
+ }
2625
+ walls(e, n, s) {
2626
+ const o = this.settings, { min: i, max: r } = this.bounds, a = e.bounce ?? o.bounce;
2627
+ let l = !1;
2628
+ for (const u of Or) {
2629
+ const f = i[u] + e.radius, d = Math.max(f, r[u] - e.radius);
2630
+ e.position[u] < f ? (e.position[u] = f, e.velocity[u] < 0 && (e.velocity[u] = s ? 0 : -e.velocity[u] * a), u === "y" && (l = !0)) : e.position[u] > d && (e.position[u] = d, e.velocity[u] > 0 && (e.velocity[u] = s ? 0 : -e.velocity[u] * a));
2631
+ }
2632
+ if (s) {
2633
+ e.resting = !1;
2634
+ return;
2635
+ }
2636
+ if (!l && e.position.y - (i.y + e.radius) < 1e-4 && e.velocity.y <= 0 && (l = !0), !l) {
2637
+ e.resting = !1;
2638
+ return;
2639
+ }
2640
+ Math.abs(e.velocity.y) < Er && (e.velocity.y = 0);
2641
+ const h = Math.exp(-o.friction * n);
2642
+ e.velocity.x *= h, e.velocity.z *= h, e.shape === "sphere" ? e.spin.crossVectors(he, e.velocity).divideScalar(e.radius) : (e.spin.multiplyScalar(Math.exp(-10 * n)), this.settleFlat(e, n)), e.resting = e.velocity.lengthSq() < 0.05 * 0.05;
2643
+ }
2644
+ /** Turns a box toward its nearest face-down orientation. */
2645
+ settleFlat(e, n) {
2646
+ let s = 0, o = 0;
2647
+ qn.forEach((i, r) => {
2648
+ const a = P.v.copy(i).applyQuaternion(e.quaternion).y;
2649
+ Math.abs(a) > Math.abs(o) && (s = r, o = a);
2650
+ }), P.v.copy(qn[s]).applyQuaternion(e.quaternion).multiplyScalar(Math.sign(o) || 1), P.q2.setFromUnitVectors(P.v, he).multiply(e.quaternion), e.quaternion.slerp(P.q2, 1 - Math.exp(-10 * n));
2651
+ }
2652
+ collideBodies(e) {
2653
+ const { bodies: n } = this;
2654
+ for (let s = 0; s < n.length; s += 1)
2655
+ for (let o = s + 1; o < n.length; o += 1) {
2656
+ const i = n[s], r = n[o];
2657
+ P.d.subVectors(r.position, i.position);
2658
+ const a = P.d.length(), l = i.radius + r.radius;
2659
+ if (a >= l) continue;
2660
+ const h = i.grabbedBy && e.has(i.grabbedBy) ? 0 : 1 / i.mass, u = r.grabbedBy && e.has(r.grabbedBy) ? 0 : 1 / r.mass;
2661
+ if (h + u === 0) continue;
2662
+ a > 1e-9 ? P.n.copy(P.d).divideScalar(a) : P.n.copy(he);
2663
+ const f = (l - a) / (h + u);
2664
+ i.position.addScaledVector(P.n, -f * h), r.position.addScaledVector(P.n, f * u);
2665
+ const d = P.v.subVectors(r.velocity, i.velocity).dot(P.n);
2666
+ if (d >= 0) continue;
2667
+ const M = -(1 + Math.min(i.bounce ?? this.settings.bounce, r.bounce ?? this.settings.bounce)) * d / (h + u);
2668
+ i.velocity.addScaledVector(P.n, -M * h), r.velocity.addScaledVector(P.n, M * u);
2669
+ }
2670
+ }
2671
+ collideHands(e, n) {
2672
+ const s = this.settings, o = this.handSettings.pinchReady ?? Ms.pinchReady;
2673
+ for (const i of e.values()) {
2674
+ if (i.hand === "pointer" && !i.pinching) continue;
2675
+ const r = i.pinchDistance < o;
2676
+ for (const [a, l] of Ir(i))
2677
+ if (!(l.radius <= 0 || r && (a === "thumbTip" || a === "indexTip")))
2678
+ for (const h of this.bodies) {
2679
+ if (!h.pushable || h.grabbedBy) continue;
2680
+ P.d.subVectors(h.position, l.center), s.flat && (P.d.z = 0);
2681
+ const u = P.d.length(), f = h.radius + l.radius;
2682
+ if (u >= f) continue;
2683
+ u > 1e-9 ? P.n.copy(P.d).divideScalar(u) : P.n.copy(he), h.position.addScaledVector(P.n, f - u), P.v.subVectors(h.velocity, l.velocity);
2684
+ const d = P.v.dot(P.n);
2685
+ d < 0 && (h.velocity.addScaledVector(P.n, -(1 + (h.bounce ?? s.bounce)) * d), h.velocity.clampLength(0, s.maxSpeed)), P.t.copy(P.v).addScaledVector(P.n, -P.v.dot(P.n)).negate(), P.axis.crossVectors(P.n, P.t).divideScalar(-h.radius), h.spin.lerp(P.axis, kr);
2686
+ const g = `${i.hand}:${a}`, M = n.get(h) ?? /* @__PURE__ */ new Map();
2687
+ M.set(g, Math.max(M.get(g) ?? 0, Math.max(0, -d))), n.set(h, M);
2688
+ }
2689
+ }
2690
+ }
2691
+ /** The pointer: a press and a quick release on the same object is a tap. */
2692
+ clickTap(e, n, s, o) {
2693
+ const i = this.reach(e, this.settings.grabReach);
2694
+ if (n && !s) {
2695
+ const r = this.pick(e.pinch, i, !0);
2696
+ this.press = r ? { body: r, timeMs: this.timeMs } : null;
2697
+ } else if (!n && s && this.press) {
2698
+ const { body: r, timeMs: a } = this.press;
2699
+ this.press = null, this.distance(r.position, e.pinch) - r.radius <= i && this.timeMs - a <= this.settings.tapMs && this.bodies.includes(r) && o.push({ type: "tap", body: r, hand: e.hand });
2700
+ }
2701
+ }
2702
+ hoverAndTap(e, n) {
2703
+ const s = this.settings;
2704
+ for (const o of this.bodies) {
2705
+ let i = null;
2706
+ for (const r of e.values()) {
2707
+ const a = r.tips.indexTip, l = this.distance(o.position, a.center) - o.radius;
2708
+ if (l <= this.reach(r, s.hoverReach) && !o.grabbedBy && (i === null || o.hoveredBy === r.hand) && (i = r.hand), r.hand === "pointer") continue;
2709
+ const u = (o.radius + a.radius) * Rr, f = (o.radius + a.radius) * Tr, d = l + o.radius, g = o.tapStart[r.hand];
2710
+ if (g === void 0 && d < u && !o.grabbedBy) {
2711
+ P.d.subVectors(o.position, a.center), s.flat && (P.d.z = 0);
2712
+ const M = a.velocity.dot(P.d.normalize());
2713
+ o.tapStart[r.hand] = M >= s.tapSpeed * r.palmLength ? this.timeMs : NaN;
2714
+ } else g !== void 0 && (d > f || o.grabbedBy) && (delete o.tapStart[r.hand], !o.grabbedBy && this.timeMs - g <= s.tapMs && n.push({ type: "tap", body: o, hand: r.hand }));
2715
+ }
2716
+ for (const r of Object.keys(o.tapStart))
2717
+ e.has(r) || delete o.tapStart[r];
2718
+ i !== o.hoveredBy && (o.hoveredBy && n.push({ type: "hoverend", body: o, hand: o.hoveredBy }), i && n.push({ type: "hoverstart", body: o, hand: i }), o.hoveredBy = i);
2719
+ }
2720
+ }
2721
+ }
2722
+ const Nr = 0.15, Lr = 0.6, bs = oe(null), Ga = () => qt(bs), Hr = ["left", "right"], Vr = new c.Vector3(1, 1, 1), Qa = ({
2723
+ hands: t = "both",
2724
+ pointer: e = !1,
2725
+ depth: n = Lr,
2726
+ floor: s = 0,
2727
+ bounds: o,
2728
+ showColliders: i = !1,
2729
+ onEvent: r,
2730
+ paused: a = !1,
2731
+ active: l = !0,
2732
+ children: h,
2733
+ palmRadius: u,
2734
+ tipRadius: f,
2735
+ pinchStart: d,
2736
+ pinchEnd: g,
2737
+ pinchReady: M,
2738
+ smoothing: _,
2739
+ ...w
2740
+ }) => {
2741
+ const { node: x } = ee(Et.HAND_TRACKER, void 0, l), L = Ot((S) => S.camera), V = Ot((S) => S.gl), N = Object.fromEntries(
2742
+ Object.entries({ palmRadius: u, tipRadius: f, pinchStart: d, pinchEnd: g, pinchReady: M, smoothing: _ }).filter(
2743
+ ([, S]) => S !== void 0
2744
+ )
2745
+ ), W = K(() => new Dr(), []);
2746
+ W.settings = { ...Ss, ...Br(w) }, W.setHandSettings(N);
2747
+ const E = st(N);
2748
+ E.current = N;
2749
+ const R = K(
2750
+ () => ({
2751
+ left: Ve("left"),
2752
+ right: Ve("right"),
2753
+ pointer: Ve("pointer")
2754
+ }),
2755
+ []
2756
+ ), J = K(
2757
+ () => ({
2758
+ left: Je.map(() => new c.Vector3()),
2759
+ right: Je.map(() => new c.Vector3())
2760
+ }),
2761
+ []
2762
+ ), H = K(() => /* @__PURE__ */ new Map(), []), C = st(r);
2763
+ C.current = r;
2764
+ const tt = st({
2765
+ ndc: null,
2766
+ pressed: !1,
2767
+ clicked: !1,
2768
+ lifted: !1
2769
+ }), Y = !!e, ot = (typeof e == "object" ? e.radius : void 0) ?? Nr;
2770
+ Z(() => {
2771
+ if (!Y) return;
2772
+ const S = V.domElement, y = tt.current, k = S.style.touchAction;
2773
+ S.style.touchAction = "none";
2774
+ const p = (A) => {
2775
+ const D = S.getBoundingClientRect();
2776
+ y.ndc ?? (y.ndc = new c.Vector2()), y.ndc.set(
2777
+ (A.clientX - D.left) / D.width * 2 - 1,
2778
+ 1 - (A.clientY - D.top) / D.height * 2
2779
+ );
2780
+ }, v = (A) => {
2781
+ p(A), y.pressed = !0, y.clicked = !0, y.lifted = !1;
2782
+ }, b = () => {
2783
+ y.pressed = !1;
2784
+ }, T = (A) => {
2785
+ y.pressed = !1, A.type === "pointerup" ? A.pointerType !== "mouse" && (y.lifted = !0) : y.ndc = null;
2786
+ };
2787
+ return S.addEventListener("pointermove", p), S.addEventListener("pointerdown", v), window.addEventListener("pointerup", b), S.addEventListener("pointerup", T), S.addEventListener("pointerleave", T), S.addEventListener("pointercancel", T), () => {
2788
+ S.style.touchAction = k, S.removeEventListener("pointermove", p), S.removeEventListener("pointerdown", v), window.removeEventListener("pointerup", b), S.removeEventListener("pointerup", T), S.removeEventListener("pointerleave", T), S.removeEventListener("pointercancel", T), y.ndc = null, y.pressed = !1, y.clicked = !1, y.lifted = !1;
2789
+ };
2790
+ }, [V, Y]);
2791
+ const z = K(
2792
+ () => ({
2793
+ lo: new c.Vector3(),
2794
+ hi: new c.Vector3(),
2795
+ point: new c.Vector3(),
2796
+ matrix: new c.Matrix4(),
2797
+ inverse: new c.Matrix4()
2798
+ }),
2799
+ []
2800
+ );
2801
+ ye((S, y) => {
2802
+ var p, v, b, T;
2803
+ o ? (W.bounds.min.set(...o.min), W.bounds.max.set(...o.max)) : (Jt({ x: -1, y: -1 }, L, z.lo), Jt({ x: 1, y: 1 }, L, z.hi), W.bounds.min.set(
2804
+ Math.min(z.lo.x, z.hi.x),
2805
+ Math.min(z.lo.y, z.hi.y) + s,
2806
+ -n
2807
+ ), W.bounds.max.set(Math.max(z.lo.x, z.hi.x), Math.max(z.lo.y, z.hi.y), n));
2808
+ for (const A of Hr) {
2809
+ const F = t === "both" || t === A ? ((p = x == null ? void 0 : x.getHandPose) == null ? void 0 : p.call(x, A)) ?? ((v = x == null ? void 0 : x.poses) == null ? void 0 : v[A]) ?? null : null;
2810
+ F && F.world.length >= 21 && F.image.length >= 21 ? ($s(F, L, J[A]), Pn(
2811
+ R[A],
2812
+ J[A],
2813
+ F.timestampMs,
2814
+ E.current
2815
+ )) : Pn(R[A], null, 0);
2816
+ }
2817
+ const k = tt.current;
2818
+ if (br(
2819
+ R.pointer,
2820
+ Y && k.ndc ? Jt({ x: k.ndc.x, y: k.ndc.y }, L, z.point) : null,
2821
+ k.pressed || k.clicked,
2822
+ performance.now(),
2823
+ ot
2824
+ ), k.lifted && !k.clicked && (k.ndc = null, k.lifted = !1), k.clicked = !1, !a) {
2825
+ const A = W.step(y, [R.left, R.right, R.pointer]);
2826
+ for (const D of A)
2827
+ (b = H.get(D.body)) == null || b.onEvent.current(D), (T = C.current) == null || T.call(C, D);
2828
+ }
2829
+ for (const [A, { object: D }] of H)
2830
+ z.matrix.compose(A.position, A.quaternion, Vr), D.parent && z.matrix.premultiply(z.inverse.copy(D.parent.matrixWorld).invert()), z.matrix.decompose(D.position, D.quaternion, z.point);
2831
+ });
2832
+ const rt = K(
2833
+ () => ({
2834
+ world: W,
2835
+ hands: [R.left, R.right, R.pointer],
2836
+ register: (S, y) => (H.set(S, y), () => {
2837
+ H.delete(S);
2838
+ })
2839
+ }),
2840
+ [W, R, H]
2841
+ );
2842
+ return /* @__PURE__ */ ie(bs.Provider, { value: rt, children: [
2843
+ h,
2844
+ i && /* @__PURE__ */ at(Fr, { hands: rt.hands })
2845
+ ] });
2846
+ }, Br = (t) => Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0)), Fr = ({ hands: t }) => {
2847
+ const e = K(
2848
+ () => t.flatMap((i) => [
2849
+ { hand: i, sphere: i.palm },
2850
+ ...ae.map((r) => ({ hand: i, sphere: i.tips[r] }))
2851
+ ]),
2852
+ [t]
2853
+ ), n = K(() => new c.SphereGeometry(1, 20, 12), []), s = K(
2854
+ () => ({
2855
+ open: new c.MeshBasicMaterial({
2856
+ color: 8246268,
2857
+ transparent: !0,
2858
+ opacity: 0.35,
2859
+ depthWrite: !1
2860
+ }),
2861
+ pinch: new c.MeshBasicMaterial({
2862
+ color: 16020150,
2863
+ transparent: !0,
2864
+ opacity: 0.5,
2865
+ depthWrite: !1
2866
+ })
2867
+ }),
2868
+ []
2869
+ );
2870
+ Z(
2871
+ () => () => {
2872
+ n.dispose(), s.open.dispose(), s.pinch.dispose();
2873
+ },
2874
+ [n, s]
2875
+ );
2876
+ const o = st([]);
2877
+ return ye(() => {
2878
+ e.forEach(({ hand: i, sphere: r }, a) => {
2879
+ const l = o.current[a];
2880
+ l && (l.visible = i.tracked && r.radius > 0, l.position.copy(r.center), l.scale.setScalar(Math.max(r.radius, 1e-6)), l.material = i.pinching ? s.pinch : s.open);
2881
+ });
2882
+ }), /* @__PURE__ */ at("group", { name: "HandTouchColliders", children: e.map((i, r) => /* @__PURE__ */ at(
2883
+ "mesh",
2884
+ {
2885
+ ref: (a) => {
2886
+ o.current[r] = a;
2887
+ },
2888
+ geometry: n,
2889
+ material: s.open,
2890
+ renderOrder: 10,
2891
+ frustumCulled: !1,
2892
+ visible: !1
2893
+ },
2894
+ r
2895
+ )) });
2896
+ }, It = (t) => Number.isFinite(t) ? Math.max(0, Math.min(1, t)) : 0, Gt = (t, e) => Math.hypot(t.x - e.x, t.y - e.y), ct = {
2897
+ wrist: 0,
2898
+ thumbTip: 4,
2899
+ indexBase: 5,
2900
+ indexTip: 8,
2901
+ middleBase: 9,
2902
+ middleTip: 12,
2903
+ ringBase: 13,
2904
+ ringTip: 16,
2905
+ pinkyBase: 17,
2906
+ pinkyTip: 20
2907
+ }, me = [
2908
+ [ct.indexBase, ct.indexTip],
2909
+ [ct.middleBase, ct.middleTip],
2910
+ [ct.ringBase, ct.ringTip],
2911
+ [ct.pinkyBase, ct.pinkyTip]
2912
+ ], Ct = (t) => t !== void 0 && t.length >= 21, Ge = (t) => Ct(t) ? Gt(t[ct.wrist], t[ct.middleBase]) : 0, Ka = (t) => {
2913
+ if (!Ct(t)) return 0;
2914
+ const e = Ge(t);
2915
+ if (e <= 0) return 0;
2916
+ const n = Gt(t[ct.thumbTip], t[ct.indexTip]) / e;
2917
+ return It(1 - (n - 0.15) / 0.85);
2918
+ }, As = (t, e, n) => {
2919
+ const s = t[ct.wrist], o = Gt(t[e], s);
2920
+ if (o <= 0) return 0;
2921
+ const i = Gt(t[n], s) / o;
2922
+ return It((1.6 - i) / 0.6);
2923
+ }, Wr = (t, e = [0, 0, 0, 0]) => {
2924
+ for (let n = 0; n < me.length; n += 1) {
2925
+ const [s, o] = me[n];
2926
+ e[n] = 1 - As(t, s, o);
2927
+ }
2928
+ return e;
2929
+ }, _s = (t) => {
2930
+ const e = Ge(t);
2931
+ if (e <= 0) return 0;
2932
+ const n = Gt(t[ct.thumbTip], t[ct.indexBase]) / e;
2933
+ return It((n - 0.45) / 0.5);
2934
+ }, Cn = (t) => {
2935
+ const e = Ge(t);
2936
+ if (e <= 0) return 0;
2937
+ const n = (t[ct.thumbTip].y - t[ct.indexBase].y) / e;
2938
+ return Math.max(-1, Math.min(1, n / 0.6));
2939
+ }, Ur = (t, e) => {
2940
+ if (!Ct(t)) return 0;
2941
+ const n = Wr(t);
2942
+ let s = 1;
2943
+ for (let o = 0; o < 4; o += 1) {
2944
+ const i = e.fingers[o];
2945
+ i !== null && (s = Math.min(s, i ? n[o] : 1 - n[o]));
2946
+ }
2947
+ if (e.thumb !== void 0 && e.thumb !== null) {
2948
+ const o = _s(t);
2949
+ s = Math.min(s, e.thumb ? o : 1 - o);
2950
+ }
2951
+ return s;
2952
+ }, Ya = (t, e) => {
2953
+ if (!Ct(t)) return 0;
2954
+ const n = Ur(t, { fingers: [!1, !1, !1, !1] }), s = It(e === "up" ? Cn(t) : -Cn(t));
2955
+ return Math.min(n, _s(t), s);
2956
+ }, Pr = (t) => {
2957
+ if (!Ct(t)) return 0;
2958
+ let e = 0;
2959
+ for (const [n, s] of me) e += As(t, n, s);
2960
+ return e / me.length;
2961
+ }, $a = (t) => Ct(t) ? 1 - Pr(t) : 0, Ja = (t) => Ct(t) ? It((t[ct.wrist].y + 1) / 2) : 0, kt = {
2962
+ leftShoulder: 11,
2963
+ rightShoulder: 12,
2964
+ leftElbow: 13,
2965
+ rightElbow: 14,
2966
+ leftWrist: 15,
2967
+ rightWrist: 16,
2968
+ leftHip: 23,
2969
+ rightHip: 24
2970
+ }, Es = (t) => t !== void 0 && t.length >= 33, ks = (t) => Gt(t[kt.leftShoulder], t[kt.rightShoulder]), Xa = (t, e, n = !1) => {
2971
+ if (!Es(t)) return 0;
2972
+ const s = ks(t);
2973
+ if (s <= 0) return 0;
2974
+ const o = Us(e, n), i = t[o === "left" ? kt.leftWrist : kt.rightWrist], r = t[o === "left" ? kt.leftShoulder : kt.rightShoulder];
2975
+ return It((i.y - r.y) / s);
2976
+ }, Za = (t) => {
2977
+ if (!Es(t)) return 0;
2978
+ const e = ks(t);
2979
+ if (e <= 0) return 0;
2980
+ let n = 1;
2981
+ for (const s of ["left", "right"]) {
2982
+ const o = t[s === "left" ? kt.leftWrist : kt.rightWrist], i = t[s === "left" ? kt.leftShoulder : kt.rightShoulder], r = It(1 - Math.abs(o.y - i.y) / (e * 0.5)), a = s === "left" ? o.x - i.x : i.x - o.x, l = It(a / e);
2983
+ n = Math.min(n, r, l);
2984
+ }
2985
+ return n;
2986
+ };
2987
+ class qr {
2988
+ constructor(e) {
2989
+ B(this, "reversals", []);
2990
+ /** Running extreme in the current direction (max rising, min falling). */
2991
+ B(this, "extreme", null);
2992
+ /** Range seen before the first swing (direction still unknown). */
2993
+ B(this, "low", 0);
2994
+ B(this, "high", 0);
2995
+ B(this, "direction", 0);
2996
+ this.options = e;
2997
+ }
2998
+ reset() {
2999
+ this.reversals = [], this.extreme = null, this.direction = 0;
3000
+ }
3001
+ /** Feed one sample; returns the oscillation progress 0..1. */
3002
+ push(e, n) {
3003
+ const { minAmplitude: s } = this.options;
3004
+ return this.extreme === null ? (this.extreme = e, this.low = e, this.high = e, this.direction = 0, this.progress(n)) : (this.direction === 0 ? e - this.low >= s ? (this.direction = 1, this.extreme = e) : this.high - e >= s ? (this.direction = -1, this.extreme = e) : (this.low = Math.min(this.low, e), this.high = Math.max(this.high, e)) : (this.direction > 0 ? e > this.extreme : e < this.extreme) ? this.extreme = e : Math.abs(this.extreme - e) >= s && (this.reversals.push(n), this.direction = -this.direction, this.extreme = e), this.progress(n));
3005
+ }
3006
+ progress(e) {
3007
+ const { requiredReversals: n, windowMs: s } = this.options;
3008
+ for (; this.reversals.length > 0 && e - this.reversals[0] > s; )
3009
+ this.reversals.shift();
3010
+ return It(this.reversals.length / n);
3011
+ }
3012
+ }
3013
+ const Rs = {
3014
+ nose: ft.nose,
3015
+ leftShoulder: ft.leftShoulder,
3016
+ rightShoulder: ft.rightShoulder,
3017
+ leftElbow: ft.leftElbow,
3018
+ rightElbow: ft.rightElbow,
3019
+ leftWrist: ft.leftWrist,
3020
+ rightWrist: ft.rightWrist,
3021
+ leftIndex: ft.leftIndex,
3022
+ rightIndex: ft.rightIndex,
3023
+ leftHip: ft.leftHip,
3024
+ rightHip: ft.rightHip,
3025
+ leftKnee: ft.leftKnee,
3026
+ rightKnee: ft.rightKnee,
3027
+ leftAnkle: ft.leftAnkle,
3028
+ rightAnkle: ft.rightAnkle
3029
+ }, Cr = Object.keys(Rs), zr = [
3030
+ "leftShoulder",
3031
+ "rightShoulder",
3032
+ "leftElbow",
3033
+ "rightElbow",
3034
+ "leftWrist",
3035
+ "rightWrist"
3036
+ ], jr = [
3037
+ "leftShoulder",
3038
+ "rightShoulder",
3039
+ "leftHip",
3040
+ "rightHip",
3041
+ "leftKnee",
3042
+ "rightKnee",
3043
+ "leftAnkle",
3044
+ "rightAnkle"
3045
+ ], zn = Object.freeze({
3046
+ /** MediaPipe visibility at or above which a joint counts. */
3047
+ visible: 0.2,
3048
+ /**
3049
+ * How far past the frame edge a joint may sit (frame units: each axis spans
3050
+ * −1..1), so an ankle right at the edge, feet partly cropped, still counts.
3051
+ */
3052
+ edge: 0.12
3053
+ }), tl = (t, { mirrored: e = !1, visibility: n, limits: s, aspect: o = 1, view: i } = {}) => {
3054
+ if (t.length < tn)
3055
+ throw new Error(
3056
+ `createBodyMoveFrame needs MediaPipe's ${tn} pose landmarks (got ${t.length})`
3057
+ );
3058
+ const r = Js(t, o), a = Xs(r, { mirrored: e, visibility: n, limits: s }), l = (i == null ? void 0 : i.visible) ?? zn.visible, h = 1 + ((i == null ? void 0 : i.edge) ?? zn.edge), u = {}, f = {}, d = {};
3059
+ for (const w of Cr) {
3060
+ const x = Rs[Ps(w, e)], L = t[x];
3061
+ u[w] = r[x], f[w] = (n == null ? void 0 : n[x]) ?? 1, d[w] = f[w] >= l && Math.abs(L.x) <= h && Math.abs(L.y) <= h;
3062
+ }
3063
+ const g = (u.leftShoulder.y + u.rightShoulder.y) / 2, M = (u.leftHip.y + u.rightHip.y) / 2, _ = u.leftShoulder.x - u.rightShoulder.x;
3064
+ return {
3065
+ shape: a,
3066
+ landmarks: t,
3067
+ joints: u,
3068
+ visibility: f,
3069
+ seen: d,
3070
+ shoulderWidth: a.shoulderWidth,
3071
+ torso: Math.max(0, g - M),
3072
+ leftward: Math.abs(_) > 1e-6 ? _ > 0 ? 1 : -1 : e ? -1 : 1,
3073
+ upperInView: zr.every((w) => d[w]),
3074
+ fullInView: jr.every((w) => d[w]),
3075
+ mirrored: e,
3076
+ aspect: o
3077
+ };
3078
+ }, Gr = Object.fromEntries(
3079
+ ["left", "right"].map((t) => [
3080
+ t,
3081
+ Object.fromEntries(
3082
+ ["Shoulder", "Elbow", "Wrist", "Index", "Hip", "Knee", "Ankle"].map((e) => [
3083
+ e,
3084
+ `${t}${e}`
3085
+ ])
3086
+ )
3087
+ ])
3088
+ ), nt = (t, e) => Gr[t][e], Qt = (t, e) => t.seen[nt(e, "Shoulder")] && t.seen[nt(e, "Elbow")] && t.seen[nt(e, "Wrist")], Ue = Object.freeze({
3089
+ /** `jump`: shoulders, hips and both ankles rise at least this far above standing (torso lengths) … */
3090
+ jumpRise: 0.12,
3091
+ /** … and it lands when both ankles are back within this of the ground. */
3092
+ jumpLand: 0.06,
3093
+ /** Longer in the air than this is not a jump (the camera moved): the move ends and re-levels. */
3094
+ jumpMaxAirMs: 900,
3095
+ /** The standing level follows the body with this time constant (ms), so slow drift never jumps. */
3096
+ jumpLevelMs: 300,
3097
+ /**
3098
+ * `squat`: hips down when the thigh's height falls to this × the shin's
3099
+ * (standing ≈ 1, thighs level ≈ 0), on the straighter leg …
3100
+ */
3101
+ squatDown: 0.6,
3102
+ /** … and back up (the rep ends, the next can start) above this. */
3103
+ squatUp: 0.85,
3104
+ /** `wave`: the forearm points up (wrist above the elbow by at least this, shoulder widths) … */
3105
+ waveForearmUp: 0.25,
3106
+ /** … and swings side to side by at least this between turning points … */
3107
+ waveAmplitude: 0.3,
3108
+ /** … this many turning points … */
3109
+ waveReversals: 3,
3110
+ /** … within this long (ms). */
3111
+ waveWindowMs: 1500,
3112
+ /** `clap`: the hands were at least this far apart (shoulder widths) … */
3113
+ clapApart: 0.6,
3114
+ /** … then meet within this … */
3115
+ clapTogether: 0.3,
3116
+ /** … in at most this long (ms). */
3117
+ clapWithinMs: 250,
3118
+ /** The clap ends when the hands part past this. */
3119
+ clapRelease: 0.45,
3120
+ /**
3121
+ * `punch`: the arm was bent (shoulder → wrist ÷ upper arm + forearm, 1 =
3122
+ * straight, read in 3D) below this …
3123
+ */
3124
+ punchBent: 0.75,
3125
+ /** … then straightens past this … */
3126
+ punchStraight: 0.93,
3127
+ /** … within this long (ms) … */
3128
+ punchWithinMs: 200,
3129
+ /** … with the wrist within this of shoulder height (shoulder widths): not a raise or a drop. */
3130
+ punchBand: 0.9,
3131
+ /** `armFlap`: both wrists drop at least this far (shoulder widths) … */
3132
+ flapStroke: 0.7,
3133
+ /** … within this long (ms) … */
3134
+ flapWithinMs: 500,
3135
+ /** … from a top no lower than this relative to the shoulders (arms up like wings, not lowered from the front) … */
3136
+ flapTop: -0.4,
3137
+ /** … with both wrists out past their shoulders by at least this. */
3138
+ flapOut: 0.3,
3139
+ /** `kick`: the foot rises at least this far above the standing foot (torso lengths) … */
3140
+ kickLift: 0.35,
3141
+ /** … the knee at least this far above the standing knee … */
3142
+ kickKnee: 0.15,
3143
+ /**
3144
+ * … and the lower leg swings up: the foot hangs below its knee by at most
3145
+ * this × the standing shin (a march's foot hangs ≈ 1 below the knee) …
3146
+ */
3147
+ kickShin: 0.6,
3148
+ /** … in at most this long from the foot leaving the ground (ms). */
3149
+ kickWithinMs: 600,
3150
+ /** `stepLeft` / `stepRight`: hips and feet move sideways at least this far (shoulder widths) … */
3151
+ stepShift: 0.5,
3152
+ /** … within this long (ms). */
3153
+ stepWithinMs: 700,
3154
+ /** `march`: a knee or foot rises at least this far above the other one (torso lengths) … */
3155
+ marchLift: 0.2,
3156
+ /** … and comes back down below this … */
3157
+ marchDrop: 0.08,
3158
+ /** … alternating: the other leg lifted at most this long before (ms). */
3159
+ marchWithinMs: 1200
3160
+ }), el = (t) => {
3161
+ if (typeof t.measure != "function" || typeof t.createMemory != "function")
3162
+ throw new Error("defineBodyMove needs createMemory and measure functions");
3163
+ return t;
3164
+ };
3165
+ class ge {
3166
+ constructor(e = 64) {
3167
+ B(this, "times");
3168
+ B(this, "values");
3169
+ B(this, "start", 0);
3170
+ B(this, "count", 0);
3171
+ this.capacity = e, this.times = new Float64Array(e), this.values = new Float64Array(e);
3172
+ }
3173
+ clear() {
3174
+ this.start = 0, this.count = 0;
3175
+ }
3176
+ push(e, n) {
3177
+ const s = (this.start + this.count) % this.capacity;
3178
+ this.times[s] = e, this.values[s] = n, this.count < this.capacity ? this.count += 1 : this.start = (this.start + 1) % this.capacity;
3179
+ }
3180
+ /** Largest value at or after `sinceMs` (−Infinity when none). */
3181
+ max(e) {
3182
+ let n = -1 / 0;
3183
+ for (let s = 0; s < this.count; s += 1) {
3184
+ const o = (this.start + s) % this.capacity;
3185
+ this.times[o] >= e && this.values[o] > n && (n = this.values[o]);
3186
+ }
3187
+ return n;
3188
+ }
3189
+ /** Smallest value at or after `sinceMs` (Infinity when none). */
3190
+ min(e) {
3191
+ let n = 1 / 0;
3192
+ for (let s = 0; s < this.count; s += 1) {
3193
+ const o = (this.start + s) % this.capacity;
3194
+ this.times[o] >= e && this.values[o] < n && (n = this.values[o]);
3195
+ }
3196
+ return n;
3197
+ }
3198
+ }
3199
+ const xe = ["left", "right"], Zt = (t) => t === "left" ? "right" : "left", se = (t, e) => e === "either" || e === t, gt = { value: 0, side: null }, Qr = {
3200
+ left: { value: 1, side: "left" },
3201
+ right: { value: 1, side: "right" },
3202
+ none: { value: 1, side: null }
3203
+ }, yt = (t) => Qr[t ?? "none"], Wt = {
3204
+ enterThreshold: 0.5,
3205
+ exitThreshold: 0.5,
3206
+ holdMs: 0,
3207
+ lostGraceMs: 250
3208
+ }, Ts = (t) => t.seen.leftShoulder && t.seen.rightShoulder && Qt(t, "left") && Qt(t, "right"), Os = (t, { side: e }) => t.seen.leftShoulder && t.seen.rightShoulder && (se("left", e) && Qt(t, "left") || se("right", e) && Qt(t, "right")), le = (t) => t.fullInView && t.torso > 1e-3, Kr = {
3209
+ name: "jump",
3210
+ label: "Jump",
3211
+ description: "Shoulders, hips and both feet rise together above the standing level (a fast rise), then land.",
3212
+ view: "full",
3213
+ limitKeys: ["jumpRise", "jumpLand", "jumpMaxAirMs", "jumpLevelMs"],
3214
+ defaults: { ...Wt, cooldownMs: 150 },
3215
+ createMemory: () => ({ level: null, lastMs: 0, airborne: !1, airSinceMs: 0 }),
3216
+ inView: le,
3217
+ measure: (t, e, n, { limits: s }) => {
3218
+ const { joints: o, torso: i } = t, r = (o.leftShoulder.y + o.rightShoulder.y) / 2, a = (o.leftHip.y + o.rightHip.y) / 2, l = o.leftAnkle.y, h = o.rightAnkle.y, u = e.level;
3219
+ if (!u)
3220
+ return e.level = { shoulders: r, hips: a, left: l, right: h }, e.lastMs = n, gt;
3221
+ const f = Math.max(0, n - e.lastMs);
3222
+ e.lastMs = n;
3223
+ const d = (M, _) => (M - _) / i;
3224
+ if (e.airborne) {
3225
+ const M = d(l, u.left) <= s.jumpLand && d(h, u.right) <= s.jumpLand, _ = n - e.airSinceMs > s.jumpMaxAirMs;
3226
+ return !M && !_ ? yt(null) : (e.airborne = !1, _ && Object.assign(u, { shoulders: r, hips: a, left: l, right: h }), gt);
3227
+ }
3228
+ if (d(r, u.shoulders) >= s.jumpRise && d(a, u.hips) >= s.jumpRise && d(l, u.left) >= s.jumpRise && d(h, u.right) >= s.jumpRise)
3229
+ return e.airborne = !0, e.airSinceMs = n, yt(null);
3230
+ const g = 1 - Math.exp(-f / Math.max(1, s.jumpLevelMs));
3231
+ return u.shoulders += (r - u.shoulders) * g, u.hips += (a - u.hips) * g, u.left += (l - u.left) * g, u.right += (h - u.right) * g, gt;
3232
+ }
3233
+ }, jn = (t, e) => {
3234
+ const n = t.joints[nt(e, "Hip")], s = t.joints[nt(e, "Knee")], o = t.joints[nt(e, "Ankle")], i = s.y - o.y;
3235
+ return i > 1e-4 ? (n.y - s.y) / i : null;
3236
+ }, Yr = {
3237
+ name: "squat",
3238
+ label: "Squat",
3239
+ description: "From standing, both thighs drop toward level (the hips sink to the knees), then the body stands back up.",
3240
+ view: "full",
3241
+ limitKeys: ["squatDown", "squatUp"],
3242
+ defaults: { ...Wt, cooldownMs: 200 },
3243
+ createMemory: () => ({ ready: !1, down: !1 }),
3244
+ inView: le,
3245
+ measure: (t, e, n, { limits: s }) => {
3246
+ const o = jn(t, "left"), i = jn(t, "right");
3247
+ if (o === null || i === null) return e.down ? yt(null) : gt;
3248
+ const r = Math.max(o, i), a = Math.abs(t.joints.leftAnkle.y - t.joints.rightAnkle.y) / t.torso <= 0.25;
3249
+ return e.down ? r < s.squatUp ? yt(null) : (e.down = !1, e.ready = !0, gt) : (r >= s.squatUp && (e.ready = !0), e.ready && a && r <= s.squatDown ? (e.ready = !1, e.down = !0, yt(null)) : gt);
3250
+ }
3251
+ }, Gn = (t) => {
3252
+ const e = () => new qr({
3253
+ minAmplitude: t.waveAmplitude,
3254
+ requiredReversals: Math.max(1, Math.round(t.waveReversals)),
3255
+ windowMs: t.waveWindowMs
3256
+ });
3257
+ return {
3258
+ built: { amplitude: t.waveAmplitude, reversals: t.waveReversals, windowMs: t.waveWindowMs },
3259
+ left: e(),
3260
+ right: e(),
3261
+ sample: { value: 0, side: null }
3262
+ };
3263
+ }, $r = {
3264
+ name: "wave",
3265
+ label: "Wave",
3266
+ description: "A forearm held up swings side to side about the elbow: three turning points of 0.3 shoulder widths within 1.5 s.",
3267
+ view: "upper",
3268
+ sided: !0,
3269
+ limitKeys: ["waveForearmUp", "waveAmplitude", "waveReversals", "waveWindowMs"],
3270
+ // Like the hand / face oscillations: begin at full progress, end once the swinging stops.
3271
+ defaults: { enterThreshold: 0.99, exitThreshold: 0.3, cooldownMs: 600, lostGraceMs: 250 },
3272
+ createMemory: () => Gn(Ue),
3273
+ inView: Os,
3274
+ measure: (t, e, n, { side: s, limits: o }) => {
3275
+ const { built: i } = e;
3276
+ (i.amplitude !== o.waveAmplitude || i.reversals !== o.waveReversals || i.windowMs !== o.waveWindowMs) && Object.assign(e, Gn(o));
3277
+ const r = t.shoulderWidth;
3278
+ let a = 0, l = null;
3279
+ for (const h of xe) {
3280
+ if (!se(h, s)) continue;
3281
+ const u = e[h], f = t.joints[nt(h, "Elbow")], d = t.joints[nt(h, "Wrist")];
3282
+ if (!Qt(t, h) || (d.y - f.y) / r < o.waveForearmUp) {
3283
+ u.reset();
3284
+ continue;
3285
+ }
3286
+ const g = u.push((d.x - f.x) / r, n);
3287
+ g > a && (a = g, l = h);
3288
+ }
3289
+ return a <= 0 ? gt : (e.sample.value = a, e.sample.side = l, e.sample);
3290
+ }
3291
+ }, ue = (t, e, n) => {
3292
+ const s = t.joints[nt(e, "Wrist")][n];
3293
+ return t.seen[nt(e, "Index")] ? (s + t.joints[nt(e, "Index")][n]) / 2 : s;
3294
+ }, Jr = {
3295
+ name: "clap",
3296
+ label: "Clap",
3297
+ description: "The hands come together fast (apart to touching within 0.25 s); ends when they part. Each clap counts.",
3298
+ view: "upper",
3299
+ limitKeys: ["clapApart", "clapTogether", "clapWithinMs", "clapRelease"],
3300
+ defaults: { ...Wt, cooldownMs: 100 },
3301
+ createMemory: () => ({ apartAtMs: -1 / 0, clapped: !1 }),
3302
+ inView: Ts,
3303
+ measure: (t, e, n, { limits: s }) => {
3304
+ const o = Math.hypot(
3305
+ ue(t, "left", "x") - ue(t, "right", "x"),
3306
+ ue(t, "left", "y") - ue(t, "right", "y")
3307
+ ) / t.shoulderWidth;
3308
+ if (e.clapped) {
3309
+ if (o < s.clapRelease) return yt(null);
3310
+ e.clapped = !1;
3311
+ }
3312
+ return o >= s.clapApart && (e.apartAtMs = n), o <= s.clapTogether && n - e.apartAtMs <= s.clapWithinMs ? (e.clapped = !0, e.apartAtMs = -1 / 0, yt(null)) : gt;
3313
+ }
3314
+ }, Xr = (t, e) => {
3315
+ const n = t.joints[nt(e, "Shoulder")], s = t.joints[nt(e, "Elbow")], o = t.joints[nt(e, "Wrist")], i = (a, l) => Math.hypot(a.x - l.x, a.y - l.y, 2 * (a.z - l.z)), r = i(n, s) + i(s, o);
3316
+ return r < 0.1 * t.shoulderWidth ? null : i(n, o) / r;
3317
+ }, Zr = {
3318
+ name: "punch",
3319
+ label: "Punch",
3320
+ 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.",
3321
+ view: "upper",
3322
+ sided: !0,
3323
+ limitKeys: ["punchBent", "punchStraight", "punchWithinMs", "punchBand"],
3324
+ defaults: { ...Wt, cooldownMs: 150 },
3325
+ createMemory: () => ({
3326
+ left: { bentAtMs: -1 / 0, punching: !1 },
3327
+ right: { bentAtMs: -1 / 0, punching: !1 }
3328
+ }),
3329
+ inView: Os,
3330
+ measure: (t, e, n, { side: s, limits: o }) => {
3331
+ let i = null;
3332
+ for (const r of xe) {
3333
+ const a = e[r];
3334
+ if (!se(r, s) || !Qt(t, r)) {
3335
+ a.punching = !1, a.bentAtMs = -1 / 0;
3336
+ continue;
3337
+ }
3338
+ const l = Xr(t, r);
3339
+ if (l === null) {
3340
+ a.punching && (i ?? (i = r));
3341
+ continue;
3342
+ }
3343
+ const h = t.joints[nt(r, "Shoulder")], u = t.joints[nt(r, "Wrist")], f = Math.abs(u.y - h.y) / t.shoulderWidth <= o.punchBand;
3344
+ if (a.punching) {
3345
+ if (l >= o.punchStraight - 0.1 && f) {
3346
+ i ?? (i = r);
3347
+ continue;
3348
+ }
3349
+ a.punching = !1;
3350
+ }
3351
+ l <= o.punchBent ? a.bentAtMs = n : l >= o.punchStraight && f && n - a.bentAtMs <= o.punchWithinMs && (a.punching = !0, a.bentAtMs = -1 / 0, i ?? (i = r));
3352
+ }
3353
+ return i ? yt(i) : gt;
3354
+ }
3355
+ }, ta = {
3356
+ name: "armFlap",
3357
+ label: "Flap your arms",
3358
+ 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.",
3359
+ view: "upper",
3360
+ limitKeys: ["flapStroke", "flapWithinMs", "flapTop", "flapOut"],
3361
+ defaults: { ...Wt, cooldownMs: 100 },
3362
+ createMemory: () => ({ left: new ge(), right: new ge(), flapping: !1 }),
3363
+ inView: Ts,
3364
+ measure: (t, e, n, { limits: s }) => {
3365
+ const { left: o, right: i } = t.shape.arms;
3366
+ e.left.push(n, o.up), e.right.push(n, i.up);
3367
+ const r = n - s.flapWithinMs, a = e.left.max(r), l = e.right.max(r), h = Math.min(a - o.up, l - i.up);
3368
+ return e.flapping ? h >= s.flapStroke * 0.5 ? yt(null) : (e.flapping = !1, gt) : h >= s.flapStroke && Math.min(a, l) >= s.flapTop && o.out >= s.flapOut && i.out >= s.flapOut ? (e.flapping = !0, yt(null)) : gt;
3369
+ }
3370
+ }, ea = {
3371
+ name: "kick",
3372
+ label: "Kick",
3373
+ 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.",
3374
+ view: "full",
3375
+ sided: !0,
3376
+ limitKeys: ["kickLift", "kickKnee", "kickShin", "kickWithinMs"],
3377
+ defaults: { ...Wt, cooldownMs: 300 },
3378
+ createMemory: () => ({
3379
+ left: { downAtMs: -1 / 0, kicking: !1 },
3380
+ right: { downAtMs: -1 / 0, kicking: !1 }
3381
+ }),
3382
+ inView: le,
3383
+ measure: (t, e, n, { side: s, limits: o }) => {
3384
+ const { joints: i, torso: r } = t;
3385
+ let a = null;
3386
+ for (const l of xe) {
3387
+ const h = e[l], u = i[nt(l, "Knee")], f = i[nt(l, "Ankle")], d = i[nt(Zt(l), "Knee")], g = i[nt(Zt(l), "Ankle")], M = (f.y - g.y) / r;
3388
+ if (h.kicking) {
3389
+ if (M > o.kickLift * 0.4) {
3390
+ a ?? (a = l);
3391
+ continue;
3392
+ }
3393
+ h.kicking = !1;
3394
+ }
3395
+ if (M <= o.kickLift * 0.3 && (h.downAtMs = n), !se(l, s)) continue;
3396
+ const _ = d.y - g.y;
3397
+ if (_ <= 1e-4) continue;
3398
+ const w = (u.y - d.y) / r, x = (u.y - f.y) / _;
3399
+ M >= o.kickLift && w >= o.kickKnee && x <= o.kickShin && n - h.downAtMs <= o.kickWithinMs && (h.kicking = !0, a ?? (a = l));
3400
+ }
3401
+ return a ? yt(a) : gt;
3402
+ }
3403
+ }, na = 150, Qn = (t) => ({
3404
+ name: t === "left" ? "stepLeft" : "stepRight",
3405
+ label: t === "left" ? "Step to your left" : "Step to your right",
3406
+ description: `Hips and both feet move to the person's own ${t} by half a shoulder width within 0.7 s; ends when the body settles.`,
3407
+ view: "full",
3408
+ limitKeys: ["stepShift", "stepWithinMs"],
3409
+ defaults: { ...Wt, cooldownMs: 300 },
3410
+ createMemory: () => ({
3411
+ hips: new ge(),
3412
+ feet: new ge(),
3413
+ stepping: !1,
3414
+ peak: 0,
3415
+ peakAtMs: 0
3416
+ }),
3417
+ inView: le,
3418
+ measure: (e, n, s, { limits: o }) => {
3419
+ const { joints: i } = e, r = (t === "left" ? 1 : -1) * e.leftward, a = r * (i.leftHip.x + i.rightHip.x) / 2, l = r * (i.leftAnkle.x + i.rightAnkle.x) / 2, h = e.shoulderWidth;
3420
+ if (n.stepping) {
3421
+ if (a > n.peak && (n.peak = a, n.peakAtMs = s), !(s - n.peakAtMs >= na || (n.peak - a) / h > 0.15)) return yt(t);
3422
+ n.stepping = !1, n.hips.clear(), n.feet.clear();
3423
+ }
3424
+ n.hips.push(s, a), n.feet.push(s, l);
3425
+ const u = s - o.stepWithinMs, f = (a - n.hips.min(u)) / h, d = (l - n.feet.min(u)) / h;
3426
+ return f >= o.stepShift && d >= o.stepShift * 0.8 ? (n.stepping = !0, n.peak = a, n.peakAtMs = s, yt(t)) : gt;
3427
+ }
3428
+ }), sa = {
3429
+ name: "march",
3430
+ label: "March in place",
3431
+ 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.",
3432
+ view: "full",
3433
+ limitKeys: ["marchLift", "marchDrop", "marchWithinMs"],
3434
+ defaults: { ...Wt, cooldownMs: 0 },
3435
+ createMemory: () => ({
3436
+ up: { left: !1, right: !1 },
3437
+ liftedAtMs: { left: -1 / 0, right: -1 / 0 },
3438
+ stepping: null
3439
+ }),
3440
+ inView: le,
3441
+ measure: (t, e, n, { limits: s }) => {
3442
+ const { joints: o, torso: i } = t;
3443
+ for (const r of xe) {
3444
+ const a = o[nt(r, "Knee")], l = o[nt(r, "Ankle")], h = o[nt(Zt(r), "Knee")], u = o[nt(Zt(r), "Ankle")], f = Math.max(a.y - h.y, l.y - u.y) / i;
3445
+ e.up[r] ? f <= s.marchDrop && (e.up[r] = !1) : f >= s.marchLift && (e.up[r] = !0, n - e.liftedAtMs[Zt(r)] <= s.marchWithinMs && (e.stepping = r), e.liftedAtMs[r] = n);
3446
+ }
3447
+ return e.stepping && !e.up[e.stepping] && (e.stepping = null), e.stepping ? yt(e.stepping) : gt;
3448
+ }
3449
+ }, Is = {
3450
+ jump: Kr,
3451
+ squat: Yr,
3452
+ wave: $r,
3453
+ clap: Jr,
3454
+ punch: Zr,
3455
+ armFlap: ta,
3456
+ kick: ea,
3457
+ stepLeft: Qn("left"),
3458
+ stepRight: Qn("right"),
3459
+ march: sa
3460
+ }, nl = Object.keys(Is), Qe = (t) => typeof t == "string" ? Is[t] : t, oa = (t) => t ? { ...Ue, ...t } : Ue, ia = Object.freeze({
3461
+ enterThreshold: 0.6,
3462
+ exitThreshold: 0.25,
3463
+ holdMs: 150,
3464
+ lostGraceMs: 250
3465
+ }), ra = 80, aa = (t) => {
3466
+ if (typeof t == "function") return "upper";
3467
+ const e = Jn(t);
3468
+ if (e) return e.view === "full" ? "full" : "upper";
3469
+ 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);
3470
+ return n(t) ? "full" : "upper";
3471
+ }, la = (t) => {
3472
+ var n;
3473
+ if (t.move !== void 0) return Qe(t.move).name;
3474
+ const e = t.pose;
3475
+ return typeof e == "string" ? e : ((n = Jn(e)) == null ? void 0 : n.label) ?? "pose";
3476
+ }, Ds = (t, e = {}) => en(
3477
+ e,
3478
+ en(
3479
+ t.move !== void 0 ? Qe(t.move).defaults : ia
3480
+ )
3481
+ ), Ns = ({ side: t = "either", limits: e, ...n }) => ({
3482
+ engine: n,
3483
+ context: { side: t, limits: oa(e) }
3484
+ }), sl = (t, e = {}) => {
3485
+ const n = la(t), s = t.move !== void 0 ? Qe(t.move) : null, o = t.move !== void 0 ? null : t.pose, { engine: i, context: r } = Ns(e), a = eo(n);
3486
+ return {
3487
+ ...Xn(a),
3488
+ kind: s ? "move" : "pose",
3489
+ view: s ? s.view : aa(o),
3490
+ inView: !1,
3491
+ side: null,
3492
+ pose: o,
3493
+ move: s,
3494
+ memory: s ? s.createMemory() : null,
3495
+ memoryUsed: !1,
3496
+ detector: a,
3497
+ options: Ds(t, i),
3498
+ context: r,
3499
+ sample: null,
3500
+ sampleSide: null,
3501
+ lastSampleMs: null
3502
+ };
3503
+ }, ol = (t, e, n = {}) => {
3504
+ const { engine: s, context: o } = Ns(n);
3505
+ t.options = Ds(e, s), t.context = o;
3506
+ }, Be = (t) => {
3507
+ t.move && t.memoryUsed && (t.memory = t.move.createMemory(), t.memoryUsed = !1), t.lastSampleMs = null;
3508
+ }, ca = (t, e, n) => {
3509
+ if (t.sampleSide = null, !e) {
3510
+ t.inView = !1, t.sample = null, Be(t);
3511
+ return;
3512
+ }
3513
+ const s = t.sample ?? { value: 0, confidence: 0 };
3514
+ if (t.sample = s, t.pose !== null) {
3515
+ const a = e.shape.upperBodyVisible;
3516
+ if (t.inView = a && (t.view !== "full" || e.shape.lowerBodyVisible), !a) {
3517
+ Be(t), s.value = 0, s.confidence = 0;
3518
+ return;
3519
+ }
3520
+ const l = Zs(e.shape, t.pose) ? 1 : 0;
3521
+ s.value = t.lastSampleMs === null ? l : s.value + (l - s.value) * (1 - Math.exp(-(n - t.lastSampleMs) / ra)), s.confidence = 1, t.lastSampleMs = n;
3522
+ return;
3523
+ }
3524
+ const o = t.move, i = t.context;
3525
+ if (t.inView = o.inView ? o.inView(e, i) : o.view === "full" ? e.fullInView && e.torso > 0 : e.upperInView, !t.inView) {
3526
+ Be(t), s.value = 0, s.confidence = 0;
3527
+ return;
3528
+ }
3529
+ const r = o.measure(e, t.memory, n, i);
3530
+ t.memoryUsed = !0, t.lastSampleMs = n, s.value = Number.isFinite(r.value) ? r.value : 0, s.confidence = 1, t.sampleSide = r.side ?? null;
3531
+ }, il = (t, e, n, s = !0) => {
3532
+ (s || !e) && ca(t, e, n);
3533
+ const o = no(t.detector, t.sample, n, t.options);
3534
+ return o.justBegan && (t.side = t.sampleSide), Xn(o, t), t;
3535
+ }, rl = (t, e) => {
3536
+ const n = e ?? {};
3537
+ return n.name = t.name, n.active = t.active, n.value = t.value, n.confidence = t.confidence, n.tracked = t.tracked, n.phase = t.phase, n.justBegan = t.justBegan, n.justEnded = t.justEnded, n.endReason = t.endReason, n.startedAtMs = t.startedAtMs, n.durationMs = t.durationMs, n.count = t.count, n.kind = t.kind, n.view = t.view, n.inView = t.inView, n.side = t.side, n;
3538
+ }, al = (t, e) => to(t, e) && t.kind === e.kind && t.view === e.view && t.inView === e.inView && t.side === e.side;
3539
+ export {
3540
+ Fn as $,
3541
+ _n as A,
3542
+ Ia as B,
3543
+ Ti as C,
3544
+ Da as D,
3545
+ Va as E,
3546
+ Pi as F,
3547
+ Ui as G,
3548
+ Me as H,
3549
+ ko as I,
3550
+ Eo as J,
3551
+ Ro as K,
3552
+ Ao as L,
3553
+ bo as M,
3554
+ is as N,
3555
+ qr as O,
3556
+ Ba as P,
3557
+ Ua as Q,
3558
+ qa as R,
3559
+ ds as S,
3560
+ Ci as T,
3561
+ zi as U,
3562
+ ja as V,
3563
+ Fi as W,
3564
+ as as X,
3565
+ Ht as Y,
3566
+ Ca as Z,
3567
+ nr as _,
3568
+ _i as a,
3569
+ oi as a$,
3570
+ tr as a0,
3571
+ Lr as a1,
3572
+ Nr as a2,
3573
+ Qa as a3,
3574
+ Ga as a4,
3575
+ Ms as a5,
3576
+ ae as a6,
3577
+ Ss as a7,
3578
+ Pt as a8,
3579
+ vn as a9,
3580
+ Ta as aA,
3581
+ gi as aB,
3582
+ wi as aC,
3583
+ Oa as aD,
3584
+ Ai as aE,
3585
+ yn as aF,
3586
+ gn as aG,
3587
+ ii as aH,
3588
+ li as aI,
3589
+ Zo as aJ,
3590
+ Mn as aK,
3591
+ mn as aL,
3592
+ fn as aM,
3593
+ Yo as aN,
3594
+ $o as aO,
3595
+ pe as aP,
3596
+ ls as aQ,
3597
+ ei as aR,
3598
+ xn as aS,
3599
+ wn as aT,
3600
+ Xo as aU,
3601
+ si as aV,
3602
+ di as aW,
3603
+ Bt as aX,
3604
+ hi as aY,
3605
+ ri as aZ,
3606
+ ci as a_,
3607
+ pi as aa,
3608
+ Is as ab,
3609
+ Ue as ac,
3610
+ nl as ad,
3611
+ zn as ae,
3612
+ el as af,
3613
+ _a as ag,
3614
+ ct as ah,
3615
+ kt as ai,
3616
+ Wr as aj,
3617
+ Cn as ak,
3618
+ _s as al,
3619
+ ia as am,
3620
+ ge as an,
3621
+ oa as ao,
3622
+ Ds as ap,
3623
+ nt as aq,
3624
+ we as ar,
3625
+ mi as as,
3626
+ vi as at,
3627
+ Mi as au,
3628
+ yi as av,
3629
+ Sn as aw,
3630
+ xi as ax,
3631
+ hs as ay,
3632
+ fi as az,
3633
+ us as b,
3634
+ Oo as b$,
3635
+ Ce as b0,
3636
+ ti as b1,
3637
+ cs as b2,
3638
+ ui as b3,
3639
+ ai as b4,
3640
+ Qo as b5,
3641
+ Ko as b6,
3642
+ ps as b7,
3643
+ je as b8,
3644
+ Wa as b9,
3645
+ yo as bA,
3646
+ go as bB,
3647
+ ss as bC,
3648
+ vo as bD,
3649
+ xo as bE,
3650
+ Ra as bF,
3651
+ Ea as bG,
3652
+ ka as bH,
3653
+ So as bI,
3654
+ os as bJ,
3655
+ jo as bK,
3656
+ io as bL,
3657
+ Zn as bM,
3658
+ ro as bN,
3659
+ Fe as bO,
3660
+ ts as bP,
3661
+ ho as bQ,
3662
+ mo as bR,
3663
+ on as bS,
3664
+ es as bT,
3665
+ po as bU,
3666
+ ne as bV,
3667
+ ln as bW,
3668
+ Bo as bX,
3669
+ rs as bY,
3670
+ Fo as bZ,
3671
+ To as b_,
3672
+ Fa as ba,
3673
+ Hi as bb,
3674
+ In as bc,
3675
+ Vi as bd,
3676
+ Bi as be,
3677
+ ji as bf,
3678
+ ms as bg,
3679
+ Gi as bh,
3680
+ fs as bi,
3681
+ Pa as bj,
3682
+ Ji as bk,
3683
+ gs as bl,
3684
+ er as bm,
3685
+ Bn as bn,
3686
+ za as bo,
3687
+ lr as bp,
3688
+ ar as bq,
3689
+ pr as br,
3690
+ cr as bs,
3691
+ hr as bt,
3692
+ ur as bu,
3693
+ dr as bv,
3694
+ gr as bw,
3695
+ _o as bx,
3696
+ rn as by,
3697
+ wo as bz,
3698
+ Na as c,
3699
+ Dr as c0,
3700
+ Ve as c1,
3701
+ br as c2,
3702
+ Pn as c3,
3703
+ Ha as d,
3704
+ bs as e,
3705
+ Xa as f,
3706
+ Ya as g,
3707
+ Ur as h,
3708
+ Ja as i,
3709
+ $a as j,
3710
+ Pr as k,
3711
+ Ka as l,
3712
+ Za as m,
3713
+ sl as n,
3714
+ Qe as o,
3715
+ ol as p,
3716
+ il as q,
3717
+ La as r,
3718
+ rl as s,
3719
+ al as t,
3720
+ Li as u,
3721
+ tl as v,
3722
+ Uo as w,
3723
+ Ei as x,
3724
+ En as y,
3725
+ Oi as z
3726
+ };