@vincentt-xr/sdk 2.0.0-alpha.0 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GROUNDING.md +1813 -27
- package/dist/{DebuggerUI-CEfdddkZ.cjs → DebuggerUI-B45_Gb9d.cjs} +1 -1
- package/dist/{DebuggerUI-Dgop6Q6o.js → DebuggerUI-Cq28c18s.js} +1 -1
- package/dist/FaceMeshRenderer-6t8OsQhK.js +1195 -0
- package/dist/FaceMeshRenderer-lQLhYIW-.cjs +155 -0
- package/dist/FaceRetouch-CDrL0pXg.js +551 -0
- package/dist/FaceRetouch-DtNl8-4e.cjs +134 -0
- package/dist/audio/AudioEngine.d.ts +3 -1
- package/dist/audio/AudioPlayer.d.ts +29 -0
- package/dist/audio/AudioPlayerLogic.d.ts +4 -0
- package/dist/audio/index.d.ts +2 -0
- package/dist/components/Axes/index.d.ts +6 -0
- package/dist/components/FaceMesh/FaceMeshRenderer.d.ts +17 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +22 -1
- package/dist/components/FaceMesh/canonical/FaceMeshMaterial.d.ts +25 -0
- package/dist/components/FaceMesh/canonical/assets.d.ts +3 -0
- package/dist/components/FaceMesh/canonical/geometryGroups.d.ts +9 -0
- package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +2 -0
- package/dist/components/FaceMesh/canonical/shaders.d.ts +2 -0
- package/dist/components/FaceMesh/deform.d.ts +3 -0
- package/dist/components/FaceMesh/index.d.ts +5 -0
- package/dist/components/FaceMesh/material/defaults.d.ts +74 -0
- package/dist/components/FaceMesh/material/index.d.ts +1 -0
- package/dist/components/FaceMesh/material/options.d.ts +5 -1
- package/dist/components/FaceMesh/material/support.d.ts +7 -2
- package/dist/components/FaceMesh/material/textures.d.ts +4 -0
- package/dist/components/FaceMesh/material/types.d.ts +4 -2
- package/dist/components/FaceRetouch/Background.d.ts +9 -5
- package/dist/components/FaceRetouch/FaceRetouch.d.ts +47 -0
- package/dist/components/FaceRetouch/index.d.ts +2 -6
- package/dist/components/FaceRetouch/landmarkMask.d.ts +4 -6
- package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +4 -7
- package/dist/components/FaceTracker/index.d.ts +5 -3
- package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +15 -0
- package/dist/components/FaceWarp3D/defaults.d.ts +37 -0
- package/dist/components/FaceWarp3D/index.d.ts +3 -0
- package/dist/components/FaceWarp3D/warp.d.ts +13 -0
- package/dist/components/HandJoints2D/index.d.ts +6 -0
- package/dist/components/HandTracker/index.d.ts +2 -2
- package/dist/components/HandTracking2D/HandVisual.d.ts +12 -0
- package/dist/components/HandTracking2D/index.d.ts +5 -0
- package/dist/components/HandTracking2DController/index.d.ts +5 -0
- package/dist/components/HandTracking3D/index.d.ts +6 -0
- package/dist/components/LightObject/index.d.ts +20 -0
- package/dist/components/LookAt/index.d.ts +23 -0
- package/dist/components/MeshRenderer/index.d.ts +58 -0
- package/dist/components/PerspectiveCamera/index.d.ts +2 -8
- package/dist/components/PinToMesh/index.d.ts +47 -0
- package/dist/components/RenderGroupLayer/index.d.ts +6 -0
- package/dist/components/SceneObjectRenderer/index.d.ts +16 -0
- package/dist/components/Screen2D/ScreenTransformFrame.d.ts +11 -0
- package/dist/components/Screen2D/ScreenTransformHelpers.d.ts +19 -0
- package/dist/components/Screen2D/ScreenTransformInteraction.d.ts +18 -0
- package/dist/components/Screen2D/index.d.ts +5 -0
- package/dist/components/ScreenGlass/defaults.d.ts +3 -0
- package/dist/components/ScreenGlass/index.d.ts +5 -0
- package/dist/components/ScreenGlass/shaders.d.ts +2 -0
- package/dist/components/ScreenGlass/types.d.ts +10 -0
- package/dist/components/ScreenGradient/defaults.d.ts +5 -0
- package/dist/components/ScreenGradient/index.d.ts +5 -0
- package/dist/components/ScreenGradient/shaders.d.ts +2 -0
- package/dist/components/ScreenGradient/types.d.ts +19 -0
- package/dist/components/ScreenImage/ScreenImage.d.ts +4 -0
- package/dist/components/ScreenImage/components/DynamicTextureSync.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageFrame.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageTransformFrame.d.ts +9 -0
- package/dist/components/ScreenImage/fit.d.ts +52 -0
- package/dist/components/ScreenImage/index.d.ts +8 -0
- package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +9 -0
- package/dist/components/ScreenImage/materials/ScreenImageMatcap.d.ts +3 -0
- package/dist/components/ScreenImage/source.d.ts +16 -0
- package/dist/components/ScreenImage/types.d.ts +37 -0
- package/dist/components/ScreenImage/utils/ScreenImageConstants.d.ts +9 -0
- package/dist/components/ScreenImage/utils/ScreenImageHelpers.d.ts +4 -0
- package/dist/components/ScreenShape/geometry.d.ts +5 -0
- package/dist/components/ScreenShape/index.d.ts +5 -0
- package/dist/components/ScreenShape/types.d.ts +41 -0
- package/dist/components/ScreenSpaceUI/ScreenTransformGuide.d.ts +15 -0
- package/dist/components/ScreenSpaceUI/ScreenTransformOverlayGuide.d.ts +9 -0
- package/dist/components/ScreenSpaceUI/index.d.ts +2 -0
- package/dist/components/ScreenText/components/ScreenTextBody.d.ts +2 -0
- package/dist/components/ScreenText/components/ScreenTextTransformFrame.d.ts +9 -0
- package/dist/components/ScreenText/constants.d.ts +5 -0
- package/dist/components/ScreenText/index.d.ts +6 -0
- package/dist/components/ScreenText/types.d.ts +31 -0
- package/dist/components/ScreenText/utils/ScreenTextHelpers.d.ts +14 -0
- package/dist/components/ScreenText/utils/ScreenTextMappings.d.ts +17 -0
- package/dist/components/SequentialRenderPasses/index.d.ts +6 -0
- package/dist/components/TextLabel/TextLabel.d.ts +5 -0
- package/dist/components/TextLabel/alignment.d.ts +4 -0
- package/dist/components/TextLabel/bend.d.ts +9 -0
- package/dist/components/TextLabel/canvas/buildTextLabelTexture.d.ts +4 -0
- package/dist/components/TextLabel/canvas/canvasTypography.d.ts +13 -0
- package/dist/components/TextLabel/canvas/drawBackground.d.ts +21 -0
- package/dist/components/TextLabel/canvas/drawEffects.d.ts +34 -0
- package/dist/components/TextLabel/canvas/drawText.d.ts +19 -0
- package/dist/components/TextLabel/components/TextLabelMesh.d.ts +13 -0
- package/dist/components/TextLabel/constants.d.ts +2 -0
- package/dist/components/TextLabel/hooks/useTextLabelTexture.d.ts +7 -0
- package/dist/components/TextLabel/index.d.ts +2 -62
- package/dist/components/TextLabel/layout/measurement.d.ts +8 -0
- package/dist/components/TextLabel/layout/resolveTextLayout.d.ts +25 -0
- package/dist/components/TextLabel/layout/wrapText.d.ts +6 -0
- package/dist/components/TextLabel/types.d.ts +227 -0
- package/dist/components/TrackingAnchor/index.d.ts +18 -2
- package/dist/components/Transform3D/index.d.ts +30 -0
- package/dist/components/XRMediaSurface/index.d.ts +6 -6
- package/dist/components/XRScene/index.d.ts +14 -3
- package/dist/components/XRViewport/XRViewport.d.ts +11 -0
- package/dist/components/XRViewport/components/HiddenMedia.d.ts +7 -0
- package/dist/components/XRViewport/components/MediaAssetPicker.d.ts +8 -0
- package/dist/components/XRViewport/components/MediaControlStack.d.ts +13 -0
- package/dist/components/XRViewport/components/XRViewportLayers.d.ts +30 -0
- package/dist/components/XRViewport/constants.d.ts +24 -0
- package/dist/components/XRViewport/contexts.d.ts +6 -0
- package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +13 -0
- package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +16 -0
- package/dist/components/XRViewport/hooks/useViewportMediaTexture.d.ts +10 -0
- package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +41 -0
- package/dist/components/XRViewport/hooks/useViewportRenderState.d.ts +47 -0
- package/dist/components/XRViewport/index.d.ts +3 -101
- package/dist/components/XRViewport/layout.d.ts +16 -0
- package/dist/components/XRViewport/slots.d.ts +16 -0
- package/dist/components/XRViewport/types.d.ts +89 -0
- package/dist/components/XRViewport/useViewportSize.d.ts +3 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/contexts-BKvTIayr.cjs +1 -0
- package/dist/contexts-Bk5zz_VR.js +214 -0
- package/dist/debug-ui/component-editor/index.d.ts +19 -0
- package/dist/debug-ui/default-setting/index.d.ts +37 -0
- package/dist/debug-ui/default-setting.cjs +21 -0
- package/dist/debug-ui/default-setting.js +777 -0
- package/dist/debug-ui/face-mesh-renderer-settings/index.d.ts +8 -0
- package/dist/debug-ui/face-retouch/index.d.ts +11 -0
- package/dist/debug-ui/face-warp-3d/index.d.ts +6 -0
- package/dist/debug-ui/hand-joints-2d/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-2d/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-3d/index.d.ts +6 -0
- package/dist/debug-ui/hierarchy-panel/index.d.ts +29 -0
- package/dist/debug-ui/index.d.ts +46 -0
- package/dist/debug-ui/layer-panel/index.d.ts +18 -0
- package/dist/debug-ui/media-source/MediaSourceSwitcher.d.ts +10 -0
- package/dist/debug-ui/media-source/index.d.ts +6 -0
- package/dist/debug-ui/media-source/media-preset.d.ts +9 -0
- package/dist/debug-ui/media-source/session.d.ts +12 -0
- package/dist/debug-ui/media-source.cjs +1 -0
- package/dist/debug-ui/media-source.js +9 -0
- package/dist/debug-ui/mesh-renderer-settings/index.d.ts +6 -0
- package/dist/debug-ui/object-inspector-panel/index.d.ts +25 -0
- package/dist/debug-ui/pin-to-mesh-settings/index.d.ts +10 -0
- package/dist/debug-ui/scene-editor/context.d.ts +38 -0
- package/dist/debug-ui/scene-editor/hierarchy-panel.d.ts +9 -0
- package/dist/debug-ui/scene-editor/index.d.ts +11 -0
- package/dist/debug-ui/scene-editor/inspector-panel.d.ts +7 -0
- package/dist/debug-ui/scene-editor/store-utils.d.ts +2 -0
- package/dist/debug-ui/scene-editor/viewport-toolbar.d.ts +4 -0
- package/dist/debug-ui/scene-editor/viewport.d.ts +21 -0
- package/dist/debug-ui/screen-glass-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-gradient-settings/GradientStopsEditor.d.ts +5 -0
- package/dist/debug-ui/screen-gradient-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-gradient-settings/styles.d.ts +3 -0
- package/dist/debug-ui/screen-image-settings/index.d.ts +9 -0
- package/dist/debug-ui/screen-shape-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-text-settings/NumberField.d.ts +9 -0
- package/dist/debug-ui/screen-text-settings/ScreenTextSettingsPanel.d.ts +3 -0
- package/dist/debug-ui/screen-text-settings/controls/NestedSection.d.ts +7 -0
- package/dist/debug-ui/screen-text-settings/controls/Section.d.ts +8 -0
- package/dist/debug-ui/screen-text-settings/controls/icons.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/index.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/BackgroundSection.d.ts +8 -0
- package/dist/debug-ui/screen-text-settings/sections/ContentSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/EffectsSection.d.ts +25 -0
- package/dist/debug-ui/screen-text-settings/sections/StyleSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/TransformSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundFillControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundSizeControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundStrokeControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/types.d.ts +7 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/BendEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/EffectChrome.d.ts +21 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/GlowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/InnerShadowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/OutlineEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/ShadowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/types.d.ts +14 -0
- package/dist/debug-ui/screen-text-settings/settings.d.ts +90 -0
- package/dist/debug-ui/screen-text-settings/styles.d.ts +26 -0
- package/dist/debug-ui/screen-text-settings/transform.d.ts +6 -0
- package/dist/debug-ui/screen-text-settings/types.d.ts +9 -0
- package/dist/debug-ui/settings-panel/index.d.ts +38 -0
- package/dist/debug-ui/shared/MaterialSection.d.ts +13 -0
- package/dist/debug-ui/shared/ScreenTransformSection.d.ts +32 -0
- package/dist/debug-ui/transform-3d-settings/index.d.ts +11 -0
- package/dist/debug-ui.cjs +10 -0
- package/dist/debug-ui.js +8861 -0
- package/dist/drawNormalizedCrop-B-7zU-Xw.cjs +1 -0
- package/dist/drawNormalizedCrop-CRdIDyl1.js +44 -0
- package/dist/entries/all.d.ts +1 -0
- package/dist/entries/core.d.ts +55 -4
- package/dist/entries/face-effects.d.ts +12 -8
- package/dist/entries/internal.d.ts +1 -1
- package/dist/entries/low-level.d.ts +21 -4
- package/dist/entries/scene-object.d.ts +10 -0
- package/dist/entries/tracking.d.ts +25 -2
- package/dist/face-action/index.d.ts +34 -0
- package/dist/face-attribute-expression/index.d.ts +10 -0
- package/dist/face-effects.cjs +1 -252
- package/dist/face-effects.js +1404 -2613
- package/dist/face-info/blendshapes.d.ts +3 -0
- package/dist/face-info/derive.d.ts +8 -0
- package/dist/face-info/drawFaceCrop.d.ts +10 -0
- package/dist/face-info/getFaceInfo.d.ts +8 -0
- package/dist/face-info/index.d.ts +8 -0
- package/dist/face-info/landmarks.d.ts +21 -0
- package/dist/face-info/types.d.ts +52 -0
- package/dist/getFaceInfo-CyPAKh3h.cjs +1 -0
- package/dist/getFaceInfo-hUKMLFcr.js +118 -0
- package/dist/hand/handJoints2d.d.ts +49 -0
- package/dist/hand/handTracking2d.d.ts +33 -0
- package/dist/hand/handTracking2dController.d.ts +65 -0
- package/dist/hand/handTracking3d.d.ts +52 -0
- package/dist/hooks/faceResults.d.ts +1 -1
- package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
- package/dist/hooks/useFaceAction.d.ts +3 -0
- package/dist/hooks/useFaceAttributeExpression.d.ts +16 -0
- package/dist/hooks/useFaceDetection.d.ts +18 -0
- package/dist/hooks/useFaceInfo.d.ts +7 -0
- package/dist/hooks/useFaceInfos.d.ts +15 -0
- package/dist/hooks/useFaceResultReader.d.ts +10 -0
- package/dist/hooks/useFrameCapture.d.ts +18 -0
- package/dist/hooks/useMediaRecorder.d.ts +14 -2
- package/dist/hooks/useOwnedTexture.d.ts +6 -0
- package/dist/hooks/useTrackerContext.d.ts +2 -2
- package/dist/hooks/useXRSession/facade.d.ts +3 -0
- package/dist/hooks/useXRSession/registry.d.ts +9 -0
- package/dist/index-82aENaRq.cjs +1 -0
- package/dist/{index-BD-JWMjE.js → index-BgQAX8rs.js} +198 -134
- package/dist/index-CEc1CAmB.cjs +1 -0
- package/dist/index-CTHeBQOs.js +178 -0
- package/dist/index-D4bLzBr6.cjs +1 -0
- package/dist/index-DSpzjuqd.cjs +1 -0
- package/dist/index-Di70KWuY.js +2049 -0
- package/dist/index-DzEzkBIH.cjs +17 -0
- package/dist/{index-CYMj26Ej.js → index-JygePOwo.js} +565 -498
- package/dist/index-UC0Ux38E.js +111 -0
- package/dist/{internal-KOKJDxCG.js → internal-DuMPpcbp.js} +86 -80
- package/dist/internal-i2JkM85N.cjs +1 -0
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +959 -632
- package/dist/main.cjs +1 -1
- package/dist/main.js +556 -455
- package/dist/material/MaterialFill.d.ts +20 -0
- package/dist/material/MeshMaterial.d.ts +14 -0
- package/dist/material/index.d.ts +2 -0
- package/dist/models/Body/index.d.ts +1 -1
- package/dist/models/Face/index.d.ts +1 -0
- package/dist/models/Face/rotation.d.ts +3 -0
- package/dist/models/Hand/HandTracking.d.ts +2 -0
- package/dist/render/layerStack.d.ts +29 -0
- package/dist/render/renderGroups.d.ts +47 -0
- package/dist/render/renderPasses.d.ts +18 -0
- package/dist/renderGroups-C9QJrAXu.js +152 -0
- package/dist/renderGroups-Dvm1J4lW.cjs +1 -0
- package/dist/renderLayers-lDtL0_43.cjs +1 -0
- package/dist/renderLayers-zrK2pv5O.js +13 -0
- package/dist/renderPasses-CT5iBwtg.cjs +21 -0
- package/dist/renderPasses-CjgG_6kQ.js +1500 -0
- package/dist/scene-object/index.d.ts +146 -0
- package/dist/scene-object/runtimeRegistry.d.ts +14 -0
- package/dist/scene-object.cjs +1 -0
- package/dist/scene-object.js +40 -0
- package/dist/screen-image/screenImagePresets.d.ts +13 -0
- package/dist/screen-image/screenImageSettings.d.ts +57 -0
- package/dist/screen-text/screenTextPresets.d.ts +6 -0
- package/dist/screen-text/screenTextSettings.d.ts +147 -0
- package/dist/screen2d/coordinates.d.ts +87 -0
- package/dist/screen2d/index.d.ts +7 -0
- package/dist/screen2d/material-runtime.d.ts +32 -0
- package/dist/screen2d/screenTransform.d.ts +47 -0
- package/dist/screen2d/smoothing.d.ts +5 -0
- package/dist/screen2d/texture.d.ts +10 -0
- package/dist/screen2d/transform.d.ts +25 -0
- package/dist/screen2d/types.d.ts +90 -0
- package/dist/{selectors-Bub0o3qy.cjs → selectors-2QvO5RYY.cjs} +1 -1
- package/dist/{selectors-BHO6TnoC.js → selectors-Dw3C-gSk.js} +5 -5
- package/dist/services/MetricsCollector/index.d.ts +7 -1
- package/dist/services/MetricsCollector/utils.d.ts +1 -1
- package/dist/session-BChR4TgK.cjs +31 -0
- package/dist/session-C1StwN0f.js +363 -0
- package/dist/texture/animatedTexture.d.ts +61 -0
- package/dist/texture/animationMath.d.ts +8 -0
- package/dist/texture/sourceResolver.d.ts +30 -0
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +582 -298
- package/dist/types/face.d.ts +1 -13
- package/dist/types/hand-tracking.d.ts +8 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/nodes.d.ts +4 -1
- package/dist/types/session.d.ts +2 -0
- package/dist/types/tracking.d.ts +8 -2
- package/dist/types/util-types.d.ts +1 -1
- package/dist/useFaceInfo-C-WfMlYp.cjs +1 -0
- package/dist/useFaceInfo-CwsHZedC.js +62 -0
- package/dist/useFaceResults-CkFc1egZ.js +19 -0
- package/dist/useFaceResults-VcFdOUFV.cjs +1 -0
- package/dist/utils/drawNormalizedCrop.d.ts +22 -0
- package/dist/utils/integrity.d.ts +4 -25
- package/dist/utils/landmarkBounds.d.ts +1 -1
- package/dist/utils/logger.d.ts +2 -2
- package/dist/x-Co8jPhP0.js +127 -0
- package/dist/x-KC8E4Gaj.cjs +41 -0
- package/docs/MIGRATION_GUIDE.md +589 -0
- package/docs/SDK_DOCUMENTATION.md +1155 -0
- package/docs/api/audio.mdx +36 -0
- package/docs/api/behavior-components.mdx +164 -0
- package/docs/api/capture-recording.mdx +103 -0
- package/docs/api/debug-ui-scene-editor.mdx +249 -0
- package/docs/api/face-actions.mdx +104 -0
- package/docs/api/face-attribute-expression.mdx +87 -0
- package/docs/api/face-binding-anchors.mdx +53 -0
- package/docs/api/face-effects.mdx +19 -0
- package/docs/api/face-info.mdx +112 -0
- package/docs/api/face-mesh.mdx +98 -0
- package/docs/api/face-painting.mdx +33 -0
- package/docs/api/face-retouching.mdx +73 -0
- package/docs/api/material-render-state.mdx +132 -0
- package/docs/api/runtime-3d.mdx +311 -0
- package/docs/api/scene-object-store.mdx +213 -0
- package/docs/api/screen-image.mdx +41 -0
- package/docs/api/screen-shape.mdx +64 -0
- package/docs/api/screen-space-coordinates.mdx +41 -0
- package/docs/api/screen-text.mdx +39 -0
- package/docs/api/texture-sources.mdx +55 -0
- package/docs/api/trackers.mdx +46 -0
- package/docs/docs.json +70 -0
- package/docs/examples/scene-object-recipes.mdx +194 -0
- package/docs/guides/harness-debug-ui.mdx +139 -0
- package/docs/inspector/hierarchy-panel.mdx +51 -0
- package/docs/inspector/object-inspector-panel.mdx +51 -0
- package/docs/introduction.mdx +121 -0
- package/docs/scene-objects/overview.mdx +127 -0
- package/docs/scene-objects/render-groups.mdx +77 -0
- package/docs/scene-objects/runtime-rendering.mdx +75 -0
- package/docs/texture-api-consumer.md +58 -0
- package/package.json +55 -7
- package/dist/components/FaceRetouch/retouchRegions.d.ts +0 -23
- package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +0 -12
- package/dist/index-B5J4gzn2.cjs +0 -1
- package/dist/index-BVBVg96G.cjs +0 -1
- package/dist/index-DtwHElmG.js +0 -157
- package/dist/index-PtFmD6B8.cjs +0 -1
- package/dist/internal-DH5d1Xnq.cjs +0 -1
- package/dist/modules/XRClient/index.d.ts +0 -9
- package/dist/modules/index.d.ts +0 -1
- package/dist/services/ApiService.d.ts +0 -12
- package/dist/types/client.d.ts +0 -3
- package/dist/useFaceResults-cpsSmKKc.js +0 -81
- package/dist/useFaceResults-hVUJYSEY.cjs +0 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { createContext as k, useContext as R, Suspense as C, useMemo as _ } from "react";
|
|
2
|
+
import { jsx as i, jsxs as b } from "react/jsx-runtime";
|
|
3
|
+
import { useGLTF as x } from "@react-three/drei";
|
|
4
|
+
import { AdditiveBlending as T, SubtractiveBlending as B, MultiplyBlending as N, NoBlending as P, NormalBlending as U, NeverDepth as W, LessDepth as q, EqualDepth as v, GreaterDepth as L, NotEqualDepth as G, GreaterEqualDepth as I, AlwaysDepth as K, LessEqualDepth as z, BackSide as F, DoubleSide as H, FrontSide as V } from "three";
|
|
5
|
+
import { M as Y } from "./index-BgQAX8rs.js";
|
|
6
|
+
const J = k(null), ce = () => {
|
|
7
|
+
const e = R(J);
|
|
8
|
+
if (!e)
|
|
9
|
+
throw new Error("useScreenSpace must be used within ScreenSpaceUI");
|
|
10
|
+
return e;
|
|
11
|
+
}, Q = k(null), ie = () => R(Q) ?? 1, fe = {
|
|
12
|
+
enabled: !0,
|
|
13
|
+
mesh: "cube",
|
|
14
|
+
material: {
|
|
15
|
+
type: "standard",
|
|
16
|
+
color: "#ffffff",
|
|
17
|
+
opacity: 1,
|
|
18
|
+
wireframe: !1,
|
|
19
|
+
roughness: 0.42,
|
|
20
|
+
metalness: 0.08
|
|
21
|
+
},
|
|
22
|
+
shadowMode: "off",
|
|
23
|
+
visible: !0
|
|
24
|
+
}, h = {
|
|
25
|
+
depthTest: !0,
|
|
26
|
+
depthWrite: !0,
|
|
27
|
+
depthFunc: "lessEqual",
|
|
28
|
+
colorWrite: !0,
|
|
29
|
+
colorMask: {
|
|
30
|
+
r: !0,
|
|
31
|
+
g: !0,
|
|
32
|
+
b: !0,
|
|
33
|
+
a: !0
|
|
34
|
+
},
|
|
35
|
+
cullMode: "back",
|
|
36
|
+
blendMode: "normal",
|
|
37
|
+
polygonOffset: {
|
|
38
|
+
enabled: !1,
|
|
39
|
+
factor: 0,
|
|
40
|
+
units: 0
|
|
41
|
+
}
|
|
42
|
+
}, M = (e) => ({
|
|
43
|
+
...h,
|
|
44
|
+
...e,
|
|
45
|
+
colorMask: {
|
|
46
|
+
...h.colorMask,
|
|
47
|
+
...e == null ? void 0 : e.colorMask
|
|
48
|
+
},
|
|
49
|
+
polygonOffset: {
|
|
50
|
+
...h.polygonOffset,
|
|
51
|
+
...e == null ? void 0 : e.polygonOffset
|
|
52
|
+
}
|
|
53
|
+
}), X = (e) => e === "never" ? W : e === "less" ? q : e === "equal" ? v : e === "greater" ? L : e === "notEqual" ? G : e === "greaterEqual" ? I : e === "always" ? K : z, Z = (e) => e === "front" ? F : e === "off" ? H : V, $ = (e) => e === "additive" ? T : e === "subtractive" ? B : e === "multiply" ? N : e === "none" ? P : U, E = (e) => {
|
|
54
|
+
const r = M(e), o = r.colorWrite && (r.colorMask.r || r.colorMask.g || r.colorMask.b || r.colorMask.a);
|
|
55
|
+
return {
|
|
56
|
+
depthTest: r.depthTest,
|
|
57
|
+
depthWrite: r.depthWrite,
|
|
58
|
+
depthFunc: X(r.depthFunc),
|
|
59
|
+
colorWrite: o,
|
|
60
|
+
side: Z(r.cullMode),
|
|
61
|
+
blending: $(r.blendMode),
|
|
62
|
+
polygonOffset: r.polygonOffset.enabled,
|
|
63
|
+
polygonOffsetFactor: r.polygonOffset.factor,
|
|
64
|
+
polygonOffsetUnits: r.polygonOffset.units
|
|
65
|
+
};
|
|
66
|
+
}, S = (e, r) => {
|
|
67
|
+
const o = M(r);
|
|
68
|
+
return e < 1 || o.blendMode !== "normal" && o.blendMode !== "none";
|
|
69
|
+
}, D = (e) => e.colorWrite && (!e.colorMask.r || !e.colorMask.g || !e.colorMask.b || !e.colorMask.a), d = "__vincenttPreviousColorMask", j = (e, r) => {
|
|
70
|
+
const o = e.onBeforeRender.bind(e), p = e.onAfterRender.bind(e);
|
|
71
|
+
if (!D(r)) {
|
|
72
|
+
e.onBeforeRender = o, e.onAfterRender = p;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
e.onBeforeRender = (a, c, m, f, l, t) => {
|
|
76
|
+
o(a, c, m, f, l, t);
|
|
77
|
+
const s = a.getContext();
|
|
78
|
+
e.userData[d] = s.getParameter(s.COLOR_WRITEMASK), s.colorMask(
|
|
79
|
+
r.colorMask.r,
|
|
80
|
+
r.colorMask.g,
|
|
81
|
+
r.colorMask.b,
|
|
82
|
+
r.colorMask.a
|
|
83
|
+
);
|
|
84
|
+
}, e.onAfterRender = (a, c, m, f, l, t) => {
|
|
85
|
+
const s = e.userData[d];
|
|
86
|
+
s && (a.getContext().colorMask(...s), delete e.userData[d]), p(a, c, m, f, l, t);
|
|
87
|
+
};
|
|
88
|
+
}, w = (e) => ({
|
|
89
|
+
castShadow: e === "cast" || e === "castReceive",
|
|
90
|
+
receiveShadow: e === "receive" || e === "castReceive"
|
|
91
|
+
}), ee = ({ mesh: e }) => e === "sphere" ? /* @__PURE__ */ i("sphereGeometry", { args: [0.85, 48, 32] }) : e === "plane" ? /* @__PURE__ */ i("planeGeometry", { args: [1.6, 1.6] }) : /* @__PURE__ */ i("boxGeometry", { args: [1.4, 1.4, 1.4] }), re = ({
|
|
92
|
+
url: e,
|
|
93
|
+
nodeName: r,
|
|
94
|
+
settings: o,
|
|
95
|
+
renderOrder: p
|
|
96
|
+
}) => {
|
|
97
|
+
const { scene: a } = x(e), c = _(() => {
|
|
98
|
+
const f = a.clone(!0), l = w(o.shadowMode), t = Math.min(1, Math.max(0, o.material.opacity)), s = E(o.material.renderState), A = S(t, o.material.renderState);
|
|
99
|
+
return f.traverse((O) => {
|
|
100
|
+
const n = O;
|
|
101
|
+
if (!n.isMesh || !n.material) return;
|
|
102
|
+
n.material = Array.isArray(n.material) ? n.material.map((u) => u.clone()) : n.material.clone(), n.castShadow = l.castShadow, n.receiveShadow = l.receiveShadow, (Array.isArray(n.material) ? n.material : [n.material]).forEach((u) => {
|
|
103
|
+
var y;
|
|
104
|
+
if (!u) return;
|
|
105
|
+
const g = u;
|
|
106
|
+
g.wireframe = o.material.wireframe, u.opacity = t, u.transparent = A, Object.assign(u, s), (y = g.color) == null || y.set(o.material.color), u.needsUpdate = !0;
|
|
107
|
+
}), j(n, M(o.material.renderState));
|
|
108
|
+
}), f;
|
|
109
|
+
}, [
|
|
110
|
+
a,
|
|
111
|
+
o.material.color,
|
|
112
|
+
o.material.opacity,
|
|
113
|
+
o.material.renderState,
|
|
114
|
+
o.material.wireframe,
|
|
115
|
+
o.shadowMode
|
|
116
|
+
]), m = r ? c.getObjectByName(r) : c;
|
|
117
|
+
return /* @__PURE__ */ i("group", { renderOrder: p, children: /* @__PURE__ */ i("primitive", { object: m ?? c }) });
|
|
118
|
+
}, ue = ({ renderOrder: e, value: r }) => {
|
|
119
|
+
if (!r.enabled || !r.visible) return null;
|
|
120
|
+
if (r.assetUrl)
|
|
121
|
+
return /* @__PURE__ */ i(C, { fallback: null, children: /* @__PURE__ */ i(
|
|
122
|
+
re,
|
|
123
|
+
{
|
|
124
|
+
url: r.assetUrl,
|
|
125
|
+
nodeName: r.assetNodeName,
|
|
126
|
+
settings: r,
|
|
127
|
+
renderOrder: e
|
|
128
|
+
}
|
|
129
|
+
) });
|
|
130
|
+
const o = Math.min(1, Math.max(0, r.material.opacity)), p = {
|
|
131
|
+
color: r.material.color,
|
|
132
|
+
transparent: S(o, r.material.renderState),
|
|
133
|
+
opacity: o,
|
|
134
|
+
wireframe: r.material.wireframe,
|
|
135
|
+
...E(r.material.renderState)
|
|
136
|
+
};
|
|
137
|
+
return /* @__PURE__ */ b(
|
|
138
|
+
"mesh",
|
|
139
|
+
{
|
|
140
|
+
...w(r.shadowMode),
|
|
141
|
+
onBeforeRender: (a, c, m, f, l) => {
|
|
142
|
+
const t = M(r.material.renderState);
|
|
143
|
+
if (!D(t)) return;
|
|
144
|
+
const s = a.getContext();
|
|
145
|
+
l.userData[d] = s.getParameter(
|
|
146
|
+
s.COLOR_WRITEMASK
|
|
147
|
+
), s.colorMask(
|
|
148
|
+
t.colorMask.r,
|
|
149
|
+
t.colorMask.g,
|
|
150
|
+
t.colorMask.b,
|
|
151
|
+
t.colorMask.a
|
|
152
|
+
);
|
|
153
|
+
},
|
|
154
|
+
onAfterRender: (a, c, m, f, l) => {
|
|
155
|
+
const t = l.userData[d];
|
|
156
|
+
t && (a.getContext().colorMask(...t), delete l.userData[d]);
|
|
157
|
+
},
|
|
158
|
+
renderOrder: e,
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ i(ee, { mesh: r.mesh }),
|
|
161
|
+
/* @__PURE__ */ i(Y, { settings: r.material, materialProps: p })
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
export {
|
|
167
|
+
fe as D,
|
|
168
|
+
ue as M,
|
|
169
|
+
Q as S,
|
|
170
|
+
ie as a,
|
|
171
|
+
h as b,
|
|
172
|
+
X as c,
|
|
173
|
+
Z as d,
|
|
174
|
+
J as e,
|
|
175
|
+
$ as g,
|
|
176
|
+
M as n,
|
|
177
|
+
ce as u
|
|
178
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Re=Object.defineProperty;var Me=(n,s,e)=>s in n?Re(n,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[s]=e;var h=(n,s,e)=>Me(n,typeof s!="symbol"?s+"":s,e);const ie=require("react/jsx-runtime"),b=require("react"),_=require("@mediapipe/tasks-vision"),P=require("three");function Te(n){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>n[e]})}}return s.default=n,Object.freeze(s)}const D=Te(P);var x=(n=>(n.WEBCAM="webcam",n.STREAM="stream",n.CANVAS="canvas",n))(x||{}),L=(n=>(n.HAND_TRACKER="vincentt.xr.hand-tracker",n.GESTURE_TRACKER="vincentt.xr.gesture-tracker",n.FACE_TRACKER="vincentt.xr.face-tracker",n.BODY_TRACKER="vincentt.xr.body-tracker",n.BACKGROUND_SEGMENTATION="vincentt.xr.background-segmentation",n))(L||{});class I extends Error{constructor(s){super(s),this.name="VincenttXRError"}}const xe=(n,s)=>s,E={apiBaseUrl:xe(void 0,"https://api.vincentt.studio"),assetStorageEndpoint:"https://cdn.vincentt.studio",sdkAssetsBaseUrl:"https://cdn.vincentt.studio/assets/sdk/face/v1",loggerPrefix:"[vincentt-xr]:",sessionCheckInterval:3e4};class Fe{constructor(s){h(this,"options");const e={verbose:!1,prefix:E.loggerPrefix};this.options={...e,...s}}log(...s){const{verbose:e,prefix:t}=this.options;e&&console.info(t,...s)}error(...s){const{verbose:e,prefix:t}=this.options;e&&console.error(t,...s)}}const B=n=>n*2-1,Y=new D.Vector3,Q=new D.Vector3,q=({x:n,y:s,z:e},t,a)=>{Y.set((n-.5)*2,(.5-s)*2,-e),Y.unproject(t),Q.copy(Y).sub(t.position).normalize();const r=-t.position.z/Q.z;return a.copy(t.position).addScaledVector(Q,r),a},Ae=(n,s)=>q(n,s,new D.Vector3),be=(n,s,e=.2)=>e*s+(1-e)*n;class ${constructor(s){h(this,"canvas");this.maxDimension=s}draw(s){const e=s.width,t=s.height,a=Math.min(1,this.maxDimension/Math.max(e,t));if(a>=1)return s;const r=Math.max(1,Math.round(e*a)),o=Math.max(1,Math.round(t*a));(!this.canvas||this.canvas.width!==r||this.canvas.height!==o)&&(this.canvas=new OffscreenCanvas(r,o));const u=this.canvas.getContext("2d");return u?(u.setTransform(1,0,0,1,0,0),u.clearRect(0,0,r,o),u.drawImage(s,0,0,r,o),this.canvas):s}dispose(){this.canvas=void 0}}const Ee={"/assets/xr/models/face_tracking.task":"sha384-tYQh+yJE8llY+zO4RviZmWaSKs5W9tsB0ix5rjQVpF5/CLTqmwtP7bYtkUi2w65P","/assets/xr/models/hand_tracking.task":"sha384-uWvruVKd887ov8k43S+DBHCsi7UXXS+CKvvdM1PX00rjPzx/B0QrAPfJ1U9yKcze","/assets/xr/models/gesture_tracking.task":"sha384-2zuseP9JKKWAYlWQGKA2N+ooabB8V/yIxu23Mv8mtY7SowcySB+xKiOmqBhVvlUC","/assets/xr/models/body_tracking.task":"sha384-3Wk9dvRYo36b3Nc9xVjKamb4wCKt9FwiPjcHKfrvyJL/jXoGs+uRLnii6yjWLKul","/assets/xr/models/segmentation.tflite":"sha384-A2bQ8+iZyQM3KIGVBUf0FyetqxuynyKpjsjCE8uzoJEnj1ghCu6ge2daiRffAiS5","/assets/xr/3d-models/head-occluder-v2.glb":"sha384-+0G60Q6EBVE6hpITxGzQgofAeKexPltpsfPq5T5et9GGBjRhFP5HOdsKAhe73OaI","/assets/sdk/face/v1/canonical_face_model.obj":"sha384-xP8YM/72TXKvbMptXB9a8JUlUf3MZQ8uLurExrsZc05v6/P5RrsaNGMUYS/BZx8A","/opencv/facial_expression_recognition/resolve/main/facial_expression_recognition_mobilefacenet_2022july_int8.onnx":"sha384-g8mtFubiIc/yhqi591RsxD76AJLw2CfYgKhKbVkIiFlwBmIyG7ZAIVyGPXafrDGB"};async function re(n){const s=await fetch(n);if(!s.ok)throw new Error(`fetchAndVerify: ${s.status} ${n}`);const e=await s.arrayBuffer(),t=De(n);if(!t){if(Ie(n))throw new Error(`[xr-sdk integrity] no SRI hash for SDK asset ${n}`);return console.warn(`[xr-sdk integrity] no SRI hash for ${n} — passing through`),e}const a=await _e(e);if(a!==t)throw new Error(`[xr-sdk integrity] SRI mismatch for ${n}: expected ${t}, got ${a}`);return e}function Ie(n){try{return new URL(n).origin===new URL(E.assetStorageEndpoint).origin}catch{return!1}}async function H(n){const s=await re(n);return new Uint8Array(s)}function De(n){try{const s=new URL(n);return Ee[s.pathname]}catch{return}}async function _e(n){const s=await crypto.subtle.digest("SHA-384",n),e=new Uint8Array(s);let t="";for(let a=0;a<e.byteLength;a++)t+=String.fromCharCode(e[a]);return`sha384-${btoa(t)}`}class G{constructor(){h(this,"disposed",!1);h(this,"paused",!1);h(this,"rafId",null);h(this,"targetFrameIntervalMs",0);h(this,"lastInferenceMs",0)}setTargetFps(s){this.targetFrameIntervalMs=s&&s>0?1e3/s:0}shouldRunInference(){if(this.targetFrameIntervalMs<=0)return!0;const s=performance.now();return s-this.lastInferenceMs<this.targetFrameIntervalMs?!1:(this.lastInferenceMs=s,!0)}async initialize(s){}async run(s){}getModelNode(){return{}}async getPerformanceData(){return{name:this.constructor.name,processingTime:null}}pause(){this.paused=!0,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}resume(){this.paused=!1}dispose(){this.disposed=!0,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}const Pe=768;class Oe extends G{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"coordinates");h(this,"sourceCanvas");h(this,"downscaler",new $(Pe))}async getBodyData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),a=this.landmarker.detectForVideo(e,t),r=performance.now();this.processingTime=r-t;const o=a.landmarks,u=[];if(o)return o.forEach((m,d)=>{u[d]||(u[d]=[]),m.forEach(S=>{const M=B(S.x),R=B(1-S.y),F=B(S.z);u[d].push({x:M,y:R,z:F})})}),{coordinatesList:u}}async processBodyTracking(){if(!(this.disposed||this.paused||!this.landmarker)){if(this.shouldRunInference()){const e=await this.getBodyData();e&&(this.coordinates=e.coordinatesList)}this.disposed||this.paused||(this.rafId=requestAnimationFrame(this.processBodyTracking.bind(this)))}}resume(){this.paused&&(super.resume(),this.processBodyTracking())}dispose(){if(super.dispose(),this.landmarker){try{this.landmarker.close()}catch{}this.landmarker=null}this.sourceCanvas=void 0,this.downscaler.dispose(),this.coordinates=void 0}getLandmarks2D(e=0){if(this.coordinates)return this.coordinates[e]}async initialize(e){const t=await _.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",E.assetStorageEndpoint).toString()),a=await H(new URL("/assets/xr/models/body_tracking.task",E.assetStorageEndpoint).toString());this.landmarker=await _.PoseLandmarker.createFromOptions(t,{baseOptions:{modelAssetBuffer:a,delegate:"GPU"},runningMode:"VIDEO",numPoses:(e==null?void 0:e.numPoses)||1})}async run({sourceCanvas:e,targetFps:t}){this.sourceCanvas=e,this.setTargetFps(t),this.rafId===null&&await this.processBodyTracking()}getModelNode(){return{getLandmarks2D:this.getLandmarks2D.bind(this)}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const Ue=.11,ze=.004,Le=(n,s)=>s.set(n.x,-n.y,n.z);class Be extends G{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"sourceCanvas");h(this,"analysisCanvas");h(this,"getSource");h(this,"detectionResults");h(this,"numFaces",1);h(this,"cameras",[]);h(this,"faces",[]);h(this,"leftCheekScratch",[]);h(this,"rightCheekScratch",[]);h(this,"landmarkScratch",{x:0,y:0,z:0,visibility:0});h(this,"rotMatrixScratch",new D.Matrix4);h(this,"rotQuatScratch",new D.Quaternion);h(this,"rotEulerScratch",new D.Euler)}landmarkForSource(e,t){return t?(this.landmarkScratch.x=1-e.x,this.landmarkScratch.y=e.y,this.landmarkScratch.z=e.z,this.landmarkScratch.visibility=e.visibility,this.landmarkScratch):e}extractAndUpdateFaceData(e){var a;if(!e.faceLandmarks.length){this.faces=[];return}const t=e.faceLandmarks.length;for(this.faces.length>t&&(this.faces.length=t,this.leftCheekScratch.length=t,this.rightCheekScratch.length=t);this.faces.length<t;)this.faces.push({transform:{position:new D.Vector3,rotation:new D.Vector3,scale:new D.Vector3},gestures:{}}),this.leftCheekScratch.push(new D.Vector3),this.rightCheekScratch.push(new D.Vector3);for(let r=0;r<t;r+=1){if(!this.cameras[r])continue;const o=this.faces[r],u=(a=this.getSource)==null?void 0:a.call(this),m=!(u==="webcam"||!u),d=e.faceLandmarks[r],S=e.facialTransformationMatrixes[r];this.rotMatrixScratch.fromArray(S.data),this.rotQuatScratch.setFromRotationMatrix(this.rotMatrixScratch),this.rotQuatScratch.set(-this.rotQuatScratch.x,this.rotQuatScratch.y,this.rotQuatScratch.z,this.rotQuatScratch.w),this.rotEulerScratch.setFromQuaternion(this.rotQuatScratch,"XYZ"),Le(this.rotEulerScratch,o.transform.rotation),q(this.landmarkForSource(d[4],m),this.cameras[r],o.transform.position),q(this.landmarkForSource(d[50],m),this.cameras[r],this.leftCheekScratch[r]),q(this.landmarkForSource(d[280],m),this.cameras[r],this.rightCheekScratch[r]);const R=this.leftCheekScratch[r].distanceTo(this.rightCheekScratch[r])*Ue,F=Math.abs(D.MathUtils.radToDeg(this.rotEulerScratch.y)),g=R+F*ze,f=o.transform.scale.x,w=be(isNaN(f)?0:f,g);o.transform.scale.set(w,w,w);const p=o.gestures,k=e.faceBlendshapes[r].categories;for(const C of k)p[C.categoryName]=C.score}}async processFaceTracking(){if(this.disposed||this.paused||!this.landmarker||!this.sourceCanvas)return null;if(!this.shouldRunInference()){this.rafId=requestAnimationFrame(this.processFaceTracking.bind(this));return}const e=Ve(this.numFaces),t=this.sourceCanvas.width,a=this.sourceCanvas.height,r=Math.min(1,e/Math.max(t,a)),o=Math.max(1,Math.round(t*r)),u=Math.max(1,Math.round(a*r));(!this.analysisCanvas||this.analysisCanvas.width!==o||this.analysisCanvas.height!==u)&&(this.analysisCanvas=new OffscreenCanvas(o,u));const m=this.analysisCanvas.getContext("2d");if(!m){this.rafId=requestAnimationFrame(this.processFaceTracking.bind(this));return}m.setTransform(1,0,0,1,0,0),m.clearRect(0,0,o,u),m.drawImage(this.sourceCanvas,0,0,o,u);const d=performance.now(),S=this.landmarker.detectForVideo(this.analysisCanvas,d),M=performance.now();this.processingTime=M-d,this.detectionResults=S,this.extractAndUpdateFaceData(S),!(this.disposed||this.paused)&&(this.rafId=requestAnimationFrame(this.processFaceTracking.bind(this)))}resume(){this.paused&&(super.resume(),this.processFaceTracking())}dispose(){if(super.dispose(),this.landmarker){try{this.landmarker.close()}catch{}this.landmarker=null}this.sourceCanvas=void 0,this.analysisCanvas=void 0,this.getSource=void 0,this.detectionResults=void 0,this.processingTime=null,this.cameras=[],this.faces=[],this.leftCheekScratch=[],this.rightCheekScratch=[]}getFace(e=0){return this.faces[e]}getDetectionResults(){return this.detectionResults}getRawFaceTrackingData(e=0){var t,a,r,o;if(this.detectionResults)return{landmarks:(t=this.detectionResults.faceLandmarks)==null?void 0:t[e],blendshapes:(r=(a=this.detectionResults.faceBlendshapes)==null?void 0:a[e])==null?void 0:r.categories,transformationMatrix:(o=this.detectionResults.facialTransformationMatrixes)==null?void 0:o[e]}}async initialize(e){this.numFaces=(e==null?void 0:e.numFaces)||1;const t=await _.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",E.assetStorageEndpoint).toString()),a=await H(new URL("/assets/xr/models/face_tracking.task",E.assetStorageEndpoint).toString()),r=await _.FaceLandmarker.createFromOptions(t,{baseOptions:{modelAssetBuffer:a,delegate:"GPU"},minFaceDetectionConfidence:.3,minFacePresenceConfidence:.3,minTrackingConfidence:.3,outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0,runningMode:"VIDEO",numFaces:this.numFaces});if(this.disposed){r.close();return}this.landmarker=r}async run({sourceCanvas:e,getSource:t,targetFps:a}){this.sourceCanvas=e,this.getSource=t,this.setTargetFps(a),this.analysisCanvas=void 0,this.rafId===null&&this.processFaceTracking()}getModelNode(){const e=this;return{get detectionResults(){return e.detectionResults},getDetectionResults:this.getDetectionResults.bind(this),getFace:this.getFace.bind(this),getRawFaceTrackingData:this.getRawFaceTrackingData.bind(this),setCamera:(a,r=0)=>{this.cameras[r]=a}}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const Ve=n=>n>1?1024:512;var O=(n=>(n.ClosedFist="closed_fist",n.OpenPalm="open_palm",n.PointingUp="pointing_up",n.ThumbDown="thumb_down",n.ThumbUp="thumb_up",n.Victory="victory",n.ILoveYou="i_love_you",n.None="none",n))(O||{});const Ke=512,Ne={Closed_Fist:O.ClosedFist,Open_Palm:O.OpenPalm,Pointing_Up:O.PointingUp,Thumb_Down:O.ThumbDown,Thumb_Up:O.ThumbUp,Victory:O.Victory,ILoveYou:O.ILoveYou,None:O.None},qe=15;class He extends G{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"coordinates");h(this,"gesture");h(this,"sourceCanvas");h(this,"downscaler",new $(Ke))}async getGestureData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),a=this.landmarker.recognizeForVideo(e,t),r=performance.now();this.processingTime=r-t;const o=a.landmarks[0],u=[];if(o){const m=a.gestures[0][0].categoryName;return o.forEach(d=>{u.push({x:B(d.x),y:B(1-d.y),z:-d.z})}),{coordinates:u,gesture:Ne[m]}}return{coordinates:void 0,gesture:void 0}}async processGestureTracking(){if(!this.disposed){if(this.shouldRunInference()){const e=await this.getGestureData();e&&(this.coordinates=e.coordinates,this.gesture=e.gesture)}this.disposed||this.paused||(this.rafId=requestAnimationFrame(this.processGestureTracking.bind(this)))}}resume(){this.paused&&(super.resume(),this.processGestureTracking())}dispose(){if(super.dispose(),this.landmarker){try{this.landmarker.close()}catch{}this.landmarker=null}this.sourceCanvas=void 0,this.downscaler.dispose(),this.coordinates=void 0,this.gesture=void 0}async initialize(){const e=await _.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",E.assetStorageEndpoint).toString()),t=await H(new URL("/assets/xr/models/gesture_tracking.task",E.assetStorageEndpoint).toString()),a=await _.GestureRecognizer.createFromOptions(e,{baseOptions:{modelAssetBuffer:t,delegate:"GPU"},runningMode:"VIDEO",numHands:1});this.landmarker=a}async run({sourceCanvas:e,targetFps:t}){this.sourceCanvas=e,this.setTargetFps(t??qe),this.rafId===null&&await this.processGestureTracking()}getModelNode(){const e=this;return{get coordinates(){return e.coordinates},get gesture(){return e.gesture}}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const Ge=512;class je extends G{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"hands");h(this,"coordinates");h(this,"gesture");h(this,"handedness");h(this,"sourceCanvas");h(this,"downscaler",new $(Ge))}async getHandData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),a=this.landmarker.detectForVideo(e,t),r=performance.now();this.processingTime=r-t;const o=[],u=a.handedness??a.handednesses??[];if(a.landmarks.forEach((d,S)=>{var f,w,p;if(!d||d.length===0)return;const M=d.map(k=>({x:B(k.x),y:B(1-k.y),z:-k.z})),R=(p=(w=(f=u[S])==null?void 0:f[0])==null?void 0:w.categoryName)==null?void 0:p.toLowerCase(),F=R==="left"||R==="right"?R:void 0,g=d[0].z<0?"closed_fist":"open_palm";o.push({coordinates:M,gesture:g,handedness:F})}),!o.length)return{hands:void 0,coordinates:void 0,gesture:void 0,handedness:void 0};const m=o[0];return{hands:o,coordinates:m.coordinates,gesture:m.gesture,handedness:m.handedness}}async processHandTracking(){if(!this.disposed){if(this.shouldRunInference()){const e=await this.getHandData();e&&(this.hands=e.hands,this.coordinates=e.coordinates,this.gesture=e.gesture,this.handedness=e.handedness)}this.disposed||this.paused||(this.rafId=requestAnimationFrame(this.processHandTracking.bind(this)))}}resume(){this.paused&&(super.resume(),this.processHandTracking())}dispose(){if(super.dispose(),this.landmarker){try{this.landmarker.close()}catch{}this.landmarker=null}this.sourceCanvas=void 0,this.hands=void 0,this.downscaler.dispose(),this.coordinates=void 0,this.gesture=void 0,this.handedness=void 0}async initialize(){const e=await _.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",E.assetStorageEndpoint).toString()),t=await H(new URL("/assets/xr/models/hand_tracking.task",E.assetStorageEndpoint).toString()),a=await _.HandLandmarker.createFromOptions(e,{baseOptions:{modelAssetBuffer:t,delegate:"GPU"},runningMode:"VIDEO",numHands:2});this.landmarker=a}async run({sourceCanvas:e,targetFps:t}){this.sourceCanvas=e,this.setTargetFps(t),this.rafId===null&&await this.processHandTracking()}getModelNode(){const e=this;return{get hands(){return e.hands},get coordinates(){return e.coordinates},get gesture(){return e.gesture},get handedness(){return e.handedness}}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const We=24,Xe=720,Ye=[[255,255,255,255],[0,0,0,0]];class Qe extends G{constructor(){super();h(this,"segmenter",null);h(this,"processingTime",null);h(this,"sourceCanvas");h(this,"processCanvas");h(this,"filterCanvas");h(this,"inputSource");h(this,"inputSourceSize");h(this,"glCanvas");h(this,"drawingUtils");h(this,"useGpuMaskPath",!1);h(this,"maskImageData");h(this,"maskCanvas",null);h(this,"segmentationMaskTexture");h(this,"isMaskSetup",!1);h(this,"isProcessing",!1);h(this,"latestMask",null);h(this,"rawCache",null);h(this,"quality","medium");h(this,"stagingCanvas")}getQualityScaleFactor(){switch(this.quality){case"low":return .5;case"medium":return .75;case"high":return 1;default:return .5}}setInputSource(e){this.inputSource=e,this.inputSourceSize=e?this.readIntrinsicSize(e):void 0}readIntrinsicSize(e){if(e instanceof HTMLVideoElement)return e.videoWidth>0?{width:e.videoWidth,height:e.videoHeight}:void 0;if(e instanceof HTMLImageElement)return e.naturalWidth>0?{width:e.naturalWidth,height:e.naturalHeight}:void 0;const t=e.width,a=e.height;return typeof t=="number"&&t>0&&typeof a=="number"&&a>0?{width:t,height:a}:void 0}ensureProcessCanvasForInput(){if(!this.processCanvas||!this.inputSource)return;const e=this.readIntrinsicSize(this.inputSource);if(!e)return;this.inputSourceSize=e;const t=Math.min(1,Xe/Math.max(e.width,e.height)),a=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));this.processCanvas.width===a&&this.processCanvas.height===r||(this.processCanvas.width=a,this.processCanvas.height=r,this.glCanvas&&(this.glCanvas.width=a,this.glCanvas.height=r),this.maskImageData=void 0)}async processSegmentation(){if(this.disposed||!this.isProcessing||!this.maskCanvas||!this.processCanvas)return;if(!this.shouldRunInference()){if(this.disposed||this.paused)return;this.rafId=requestAnimationFrame(this.processSegmentation.bind(this));return}const e=this.inputSource??this.sourceCanvas;if(!this.segmenter||!e){if(this.disposed||this.paused)return;this.rafId=requestAnimationFrame(this.processSegmentation.bind(this));return}const t=performance.now();this.ensureProcessCanvasForInput();const a=this.processCanvas.getContext("2d");if(a){const u=this.processCanvas.width,m=this.processCanvas.height;if(a.clearRect(0,0,u,m),this.inputSource&&this.inputSourceSize){const{width:d,height:S}=this.inputSourceSize,M=Math.min(u/d,m/S),R=d*M,F=S*M;a.drawImage(this.inputSource,(u-R)/2,(m-F)/2,R,F)}else a.drawImage(e,0,0,u,m)}const o=this.segmenter.segmentForVideo(this.processCanvas,performance.now()).categoryMask;if(!o){if(this.disposed||this.paused)return;this.rafId=requestAnimationFrame(this.processSegmentation.bind(this));return}if(this.rawCache=null,this.latestMask&&(this.latestMask.close(),this.latestMask=null),this.useGpuMaskPath&&this.drawingUtils&&this.glCanvas)this.drawingUtils.drawCategoryMask(o,Ye),this.latestMask=o.clone(),o.close(),this.blitGlToMask();else{this.latestMask=o.clone();const u=this.readMaskToImageData(o);o.close(),u&&this.blitImageDataToMask(u)}this.segmentationMaskTexture&&(this.isMaskSetup||(this.segmentationMaskTexture.format=P.RGBAFormat,this.segmentationMaskTexture.minFilter=P.LinearFilter,this.segmentationMaskTexture.magFilter=P.LinearFilter,this.segmentationMaskTexture.generateMipmaps=!1,this.isMaskSetup=!0),this.segmentationMaskTexture.needsUpdate=!0),this.processingTime=performance.now()-t,!(this.disposed||this.paused)&&(this.rafId=requestAnimationFrame(this.processSegmentation.bind(this)))}blitGlToMask(){if(!this.maskCanvas||!this.filterCanvas||!this.glCanvas)return;const e=this.maskCanvas.getContext("2d"),t=this.filterCanvas.getContext("2d");!e||!t||(t.filter="blur(0.5px)",t.clearRect(0,0,this.filterCanvas.width,this.filterCanvas.height),t.drawImage(this.glCanvas,0,0,this.filterCanvas.width,this.filterCanvas.height),e.clearRect(0,0,this.maskCanvas.width,this.maskCanvas.height),e.drawImage(this.filterCanvas,0,0,this.maskCanvas.width,this.maskCanvas.height))}readMaskToImageData(e){const t=e.getAsUint8Array(),{width:a,height:r}=e;if(!t||a<=0||r<=0)return null;(!this.maskImageData||this.maskImageData.width!==a||this.maskImageData.height!==r)&&(this.maskImageData=new ImageData(a,r));const o=this.maskImageData.data;for(let u=0;u<t.length;u+=1){const m=t[u]===255?0:255;o[u*4]=255,o[u*4+1]=m,o[u*4+2]=255,o[u*4+3]=m}return this.maskImageData}blitImageDataToMask(e){if(!this.maskCanvas||!this.filterCanvas)return;const t=this.maskCanvas.getContext("2d"),a=this.filterCanvas.getContext("2d");if(!t||!a)return;const r=this.getStagingCanvas(e.width,e.height),o=r.getContext("2d");o&&(o.putImageData(e,0,0),a.filter="blur(0.5px)",a.clearRect(0,0,this.filterCanvas.width,this.filterCanvas.height),a.drawImage(r,0,0,this.filterCanvas.width,this.filterCanvas.height),t.clearRect(0,0,this.maskCanvas.width,this.maskCanvas.height),t.drawImage(this.filterCanvas,0,0,this.maskCanvas.width,this.maskCanvas.height))}getStagingCanvas(e,t){return this.stagingCanvas||(this.stagingCanvas=document.createElement("canvas")),this.stagingCanvas.width!==e&&(this.stagingCanvas.width=e),this.stagingCanvas.height!==t&&(this.stagingCanvas.height=t),this.stagingCanvas}resume(){this.paused&&(super.resume(),this.processSegmentation())}dispose(){if(super.dispose(),this.isProcessing=!1,this.latestMask){try{this.latestMask.close()}catch{}this.latestMask=null}if(this.rawCache=null,this.segmenter){try{this.segmenter.close()}catch{}this.segmenter=null}this.drawingUtils=void 0,this.glCanvas=void 0,this.maskImageData=void 0,this.segmentationMaskTexture&&(this.segmentationMaskTexture.dispose(),this.segmentationMaskTexture=void 0),this.sourceCanvas=void 0,this.inputSource=void 0,this.inputSourceSize=void 0,this.processCanvas=void 0,this.filterCanvas=void 0,this.stagingCanvas=void 0,this.maskCanvas=null}async initialize(e){this.quality=(e==null?void 0:e.quality)??"low";const t=await _.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",E.assetStorageEndpoint).toString()),a=await H(new URL("/assets/xr/models/segmentation.tflite",E.assetStorageEndpoint).toString());this.glCanvas=new OffscreenCanvas(1,1);const r=this.glCanvas.getContext("webgl2",{preserveDrawingBuffer:!0});this.segmenter=await _.ImageSegmenter.createFromOptions(t,{baseOptions:{modelAssetBuffer:a,delegate:"GPU"},...r?{canvas:this.glCanvas}:{},outputCategoryMask:!0,outputConfidenceMasks:!1,runningMode:"VIDEO"}),r?(this.drawingUtils=new _.DrawingUtils(r),this.useGpuMaskPath=!0):this.useGpuMaskPath=!1}async run({sourceCanvas:e,renderWidth:t,renderHeight:a,targetFps:r}){var u;if(!e)return;this.setTargetFps(r??We),this.isProcessing=!1,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null);const o=this.getQualityScaleFactor();this.sourceCanvas=e,this.processCanvas=document.createElement("canvas"),this.processCanvas.width=e.width*o,this.processCanvas.height=e.height*o,this.glCanvas&&(this.glCanvas.width=this.processCanvas.width,this.glCanvas.height=this.processCanvas.height),this.maskImageData=void 0,this.maskCanvas=document.createElement("canvas"),this.maskCanvas.width=t,this.maskCanvas.height=a,this.filterCanvas=document.createElement("canvas"),this.filterCanvas.width=t,this.filterCanvas.height=a,(u=this.segmentationMaskTexture)==null||u.dispose(),this.segmentationMaskTexture=new P.CanvasTexture(this.maskCanvas),this.isMaskSetup=!1,this.rawCache=null,this.isProcessing=!0,this.lastInferenceMs=0,this.rafId=requestAnimationFrame(this.processSegmentation.bind(this))}getRawSegmentationData(){if(this.rawCache)return this.rawCache;if(!this.latestMask)return null;const e=this.latestMask.getAsUint8Array();return this.rawCache={maskData:e,width:this.latestMask.width,height:this.latestMask.height},this.rawCache}getModelNode(){const e=this;return{get backgroundSegmentationMask(){return e.segmentationMaskTexture},getMaskCanvas:()=>e.maskCanvas,getRawSegmentationData:()=>e.getRawSegmentationData(),setInputSource:t=>e.setInputSource(t??void 0)}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const ae={[L.BACKGROUND_SEGMENTATION]:Qe,[L.HAND_TRACKER]:je,[L.GESTURE_TRACKER]:He,[L.FACE_TRACKER]:Be,[L.BODY_TRACKER]:Oe},Ze=async n=>{const s=document.createElement("video");s.srcObject=n,s.muted=!0,s.playsInline=!0,s.autoplay=!0,await new Promise(t=>{s.onloadedmetadata=()=>{s.play(),t()}});const e=s;return await new Promise(t=>{const a=setTimeout(t,150),r=()=>{clearTimeout(a),t()};typeof e.requestVideoFrameCallback=="function"?e.requestVideoFrameCallback(r):requestAnimationFrame(()=>requestAnimationFrame(()=>r()))}),s},$e=n=>{const s=new P.CanvasTexture(n);return s.colorSpace=P.SRGBColorSpace,s.format=P.RGBAFormat,s.minFilter=P.LinearFilter,s.magFilter=P.LinearFilter,s.generateMipmaps=!1,s.needsUpdate=!0,s},Je=(n,s)=>{const e=n.videoWidth,t=n.videoHeight;e>0&&t>0&&(s.width!==e&&(s.width=e),s.height!==t&&(s.height=t));const a=s.getContext("2d",{colorSpace:"srgb"});a.save(),a.scale(-1,1),a.drawImage(n,-s.width,0,s.width,s.height),a.restore()},et=(n,s,e=1)=>{const t=s.getContext("2d",{colorSpace:"srgb"}),a=s.width/s.height,r=n.width/n.height;let o,u;r>a?(u=s.height,o=n.width*(s.height/n.height)):(o=s.width,u=n.height*(s.width/n.width));const m=Number.isFinite(e)&&e>0?e:1;o*=m,u*=m;const d=(s.width-o)/2,S=(s.height-u)/2;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,s.width,s.height),t.drawImage(n,0,0,n.width,n.height,d,S,o,u)},tt=(n,s,e)=>{const t=new Map;let a=!1;const r=(g,f)=>{var w;try{(w=f.dispose)==null||w.call(f)}catch(p){console.warn(`[xr-sdk registry] dispose threw for ${g}`,p)}};return{acquire:async(g,f,w)=>{let p=t.get(g);if(p)return p.refs.add(f),p.activeRefs.add(f),p.initPromise;const k=s[g];if(!k)throw new Error(`Invalid model: ${g}`);const C=new k,K=new Set([f]),V=new Set([f]),U=(async()=>{await C.initialize(w);const N=t.get(g);if(!N||N.model!==C||N.refs.size===0)return r(g,C),C;e&&await e(g,C);const T=t.get(g);return T&&T.refs.size>0&&n.setPipeline(z=>z.set(g,C)),C})();return p={model:C,refs:K,activeRefs:V,initPromise:U,options:w},t.set(g,p),U.catch(()=>{t.get(g)===p&&(t.delete(g),n.setPipeline(T=>T.delete(g))),r(g,C)}),U},release:(g,f)=>{const w=t.get(g);w&&(w.refs.delete(f),w.activeRefs.delete(f)&&w.refs.size>0&&w.activeRefs.size===0&&w.model.pause(),!(w.refs.size>0)&&(t.delete(g),r(g,w.model),n.setPipeline(p=>p.delete(g))))},setActive:(g,f,w)=>{const p=t.get(g);if(!p||!p.refs.has(f))return;const k=p.activeRefs.size>0;w?p.activeRefs.add(f):p.activeRefs.delete(f);const C=p.activeRefs.size>0;k!==C&&(C&&!a?p.model.resume():p.model.pause())},suspendAll:()=>{a=!0;for(const g of t.values())g.model.pause()},resumeActive:()=>{a=!1;for(const g of t.values())g.activeRefs.size>0&&g.model.resume()},get:g=>{var f;return(f=t.get(g))==null?void 0:f.model},getOptions:g=>{var f;return(f=t.get(g))==null?void 0:f.options},releaseAll:()=>{for(const g of Array.from(t.keys())){const f=t.get(g);f&&(f.refs.clear(),t.delete(g),r(g,f.model))}n.setPipeline(g=>g.clear())}}},st={lifecycle:"idle",ready:!1,error:void 0,cameraTexture:void 0,renderWidth:0,renderHeight:0,source:void 0,sourceKind:void 0,pipeline:new Map},nt=()=>{let n={...st,pipeline:new Map};const s=new Set,e=()=>{s.forEach(t=>t())};return{getSnapshot:()=>n,set:t=>{let a=!1;for(const r of Object.keys(t))if(t[r]!==n[r]){a=!0;break}a&&(n={...n,...t},e())},setPipeline:t=>{const a=new Map(n.pipeline);return t(a),n={...n,pipeline:a},e(),a},subscribe:t=>(s.add(t),()=>{s.delete(t)})}},it=({renderHeight:n,renderWidth:s,videoHeight:e,videoWidth:t})=>({height:n||e,width:s||t}),at=n=>{const s=new Fe({verbose:!0}),e=nt();let t=n;const a=i=>{var l;const c=(l=T.getOptions(i))==null?void 0:l.targetFps;return typeof c=="number"?c:t==null?void 0:t.targetFps};let r,o,u,m,d,S,M,R,F,g,f,w=!1,p=!1,k=0;const C=new Set,K=new Set,V=i=>{const c=e.getSnapshot().cameraTexture;c&&c.dispose();const l=$e(i);return e.set({cameraTexture:l}),l},U=async(i,c)=>{if(C.has(i)||e.getSnapshot().lifecycle!=="running"||!d)return;C.add(i);const l=k;try{await c.run({sourceCanvas:d,renderWidth:e.getSnapshot().renderWidth,renderHeight:e.getSnapshot().renderHeight,getSource:()=>e.getSnapshot().sourceKind,targetFps:a(i)}),p&&(await new Promise(v=>requestAnimationFrame(()=>v())),await new Promise(v=>requestAnimationFrame(()=>v())),p&&k===l&&T.suspendAll())}catch(v){throw C.delete(i),v}},T=tt(e,ae,(i,c)=>U(i,c));e.subscribe(()=>{if(e.getSnapshot().lifecycle!=="running")return;const i=e.getSnapshot().pipeline;for(const[c,l]of i.entries())C.has(c)||U(c,l)});const z=()=>{if(f!==void 0&&(cancelAnimationFrame(f),f=void 0),o){try{o.pause()}catch{}try{o.srcObject=null}catch{}o=void 0}if(u){try{u.getTracks().forEach(i=>i.stop())}catch{}u=void 0}},j=()=>{if(w||!o||!m||!d)return;const i=window.__xr_debugger_metrics;if(i!=null&&i.trackCameraFrame&&i.trackCameraFrame(),(e.getSnapshot().sourceKind??"webcam")==="webcam")Je(o,m);else{const v=m.getContext("2d");if(!v)return;const y=o.videoWidth,A=o.videoHeight;m.width!==y&&(m.width=y),m.height!==A&&(m.height=A),v.setTransform(1,0,0,1,0,0),v.clearRect(0,0,y,A),v.drawImage(o,0,0,y,A)}et(m,d,(t==null?void 0:t.cameraZoom)??1.2);const l=e.getSnapshot().cameraTexture;l&&(l.needsUpdate=!0)},J=()=>{if(!o||!m||!d)return;if(p){j();return}const i=()=>{f=requestAnimationFrame(i),j()};f=requestAnimationFrame(i)},ue=async i=>{if(i.source===x.WEBCAM)try{const c=t!=null&&t.camRes&&t.camRes>0?t.camRes:960;return await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",frameRate:{min:24,ideal:30,max:60},width:{ideal:c}}})}catch(c){const l=c instanceof DOMException?c.name:"",v=l==="NotReadableError"||l==="TrackStartError"?"Camera is already in use by another app or browser tab. Close it and refresh.":l==="NotFoundError"||l==="DevicesNotFoundError"?"No camera was found on this device.":l==="NotAllowedError"||l==="PermissionDeniedError"?"Camera access was blocked. Allow camera permissions in your browser, then refresh.":"Unable to access camera. Allow camera permissions in your browser, then refresh.";throw e.set({error:{error:"PermissionError",message:v}}),new I(c instanceof Error?c.message:"getUserMedia failed")}return i.stream},W=async i=>{const c=await ue(i);u=c;const l=await Ze(c);o=l,m=new OffscreenCanvas(l.videoWidth,l.videoHeight);const{renderWidth:v,renderHeight:y}=e.getSnapshot(),A=it({renderWidth:v,renderHeight:y,videoWidth:l.videoWidth,videoHeight:l.videoHeight});d?(d.width!==A.width||d.height!==A.height)&&(d.width=A.width,d.height=A.height,V(d)):(d=new OffscreenCanvas(A.width,A.height),V(d));const ne=i.source===x.STREAM?i.static===!0:!1;p=ne,r=i.source===x.WEBCAM?{source:x.WEBCAM,sourceKind:"webcam"}:{source:x.STREAM,stream:i.stream,static:ne,sourceKind:i.sourceKind??"webcam"},e.set({source:i.source,sourceKind:r.sourceKind,error:void 0})},X=async i=>{const c=i.sourceKind??"webcam";d=i.canvas;const l=V(d);e.set({cameraTexture:l,source:x.CANVAS,sourceKind:c,renderWidth:d.width,renderHeight:d.height,error:void 0}),r={source:x.CANVAS,canvas:i.canvas,sourceKind:c}},le=(i,c)=>!c||i.source!==c.source?!1:i.source===x.STREAM&&c.source===x.STREAM?i.stream===c.stream&&(i.sourceKind??"webcam")===c.sourceKind:!0,ge=async()=>{if(!d)return;const i=k,c=e.getSnapshot().pipeline;for(const[,l]of c.entries())l.resume();await new Promise(l=>requestAnimationFrame(()=>l())),await new Promise(l=>requestAnimationFrame(()=>l())),p&&k===i&&T.suspendAll()},me=(i,c)=>!c||c.source!==x.CANVAS?!1:i.canvas===c.canvas&&(i.sourceKind??"webcam")===c.sourceKind,fe=async i=>{const c=i.source;if(c!==x.WEBCAM&&c!==x.STREAM)throw new I(`Invalid media source: ${String(c)}`);if(le(i,r)){s.log("Media source unchanged, skipping rebind.");return}k+=1;const{lifecycle:l}=e.getSnapshot();if(l==="idle"||l==="stopped"){await W(i),e.set({lifecycle:"media-bound"}),s.log("Media source set to:",i.source);return}if(l==="media-bound"){z(),await W(i),s.log("Media source rebound to:",i.source);return}w=!0,await new Promise(v=>requestAnimationFrame(()=>v())),z(),await W(i),w=!1,J(),p?await ge():T.resumeActive(),s.log("Media source swapped to:",i.source)},pe=async i=>{if(me(i,r)){s.log("Frame source unchanged, skipping rebind.");return}k+=1;const{lifecycle:c}=e.getSnapshot();if(c==="idle"||c==="stopped"){await X(i),e.set({lifecycle:"media-bound"}),s.log("Frame source set to canvas.");return}if(c==="media-bound"){z(),await X(i),s.log("Frame source rebound to canvas.");return}w=!0,await new Promise(l=>requestAnimationFrame(()=>l())),z(),await X(i),w=!1,s.log("Frame source swapped to canvas.")},ve=async()=>{const{lifecycle:i}=e.getSnapshot();if(i==="running")return;if(i==="idle")throw new I("session.start() called before setMediaSource — call setMediaSource first");if(!d)throw new I("session.start(): media source not bound");const c=(r==null?void 0:r.source)===x.CANVAS;if(!c&&(!o||!m))throw i==="stopped"?new I("session.start() called from stopped state without a media source — call setMediaSource first"):new I("session.start(): media source not bound");c||J(),T.resumeActive(),e.set({lifecycle:"running"}),await new Promise(v=>requestAnimationFrame(()=>v()));const l=e.getSnapshot().pipeline;for(const[v,y]of l.entries())await U(v,y);e.set({ready:!0}),s.log("XR session started.")},ee=async()=>{const{lifecycle:i}=e.getSnapshot();i==="stopped"||i==="idle"||(z(),T.suspendAll(),e.set({lifecycle:"stopped",ready:!1}),s.log("XR session stopped."))},we=async()=>{await ee(),T.releaseAll(),K.clear();const i=e.getSnapshot().cameraTexture;i&&i.dispose(),C.clear(),r=void 0,k+=1,d=void 0,m=void 0,p=!1,e.set({lifecycle:"idle",cameraTexture:void 0,source:void 0}),s.log("XR session reset.")},Ce=async i=>{const c="legacy:registerXRPipeline",l=[];await Promise.all(i.map(async v=>{const{model:y}=v;if(!ae[y])throw new I(`Invalid model: ${y}`);K.has(y)||l.push(y);const A="options"in v?v.options:void 0;await T.acquire(y,c,A)})),l.length>0&&(l.forEach(v=>K.add(v)),s.log("XR pipeline registered."))},Se=i=>{const c=T.get(i);if(!c)throw new I(`Model ${i} is not registered in the pipeline`);return c.getModelNode()},te=async(i,c)=>{i<=0||c<=0||(e.set({renderWidth:i,renderHeight:c}),d&&(d.width!==i||d.height!==c)&&(d.width=i,d.height=c,V(d),p&&j()),s.log(`Source canvas set. Render size: ${i}x${c}`))},ke=async i=>{var y;S=i;const c=(y=i.getBoundingClientRect)==null?void 0:y.call(i),l=c&&c.width>0?Math.round(c.width):i.clientWidth,v=c&&c.height>0?Math.round(c.height):i.clientHeight;await te(l,v)},ye=i=>{M=i.renderer,R=i.scene,F=i.camera,g=i.renderFrame},se=()=>{if(!M||!R||!F)throw new I("XR frame render requested before the R3F state was bound — make sure <XRScene> is mounted");g?g():M.render(R,F)};return{store:e,registry:T,setMediaSource:fe,start:ve,stop:ee,reset:we,setFrameSource:pe,registerXRPipeline:Ce,getModelNode:Se,captureFrame:()=>{if(!S)throw new I("session.captureFrame() called before the XRScene render target was bound — make sure <XRScene> is mounted");if(!M||!R||!F)throw new I("session.captureFrame() called before the R3F state was bound — make sure <XRScene> is mounted");return se(),S.toDataURL("image/png")},getInputFrame:()=>d??null,_setRenderTarget:ke,_setRenderSize:te,_setR3FState:ye,_renderFrame:se,_getVideoElement:()=>o,_setPerf:i=>{if(t=i,e.getSnapshot().lifecycle!=="running"||!d)return;const c=e.getSnapshot().pipeline;for(const[l,v]of c.entries())v.run({sourceCanvas:d,renderWidth:e.getSnapshot().renderWidth,renderHeight:e.getSnapshot().renderHeight,getSource:()=>e.getSnapshot().sourceKind,targetFps:a(l)})}}},rt=n=>{const s=b.useRef(n),e=b.useMemo(()=>at(s.current),[]),t=JSON.stringify(n??{});return b.useEffect(()=>{e._setPerf(n)},[e,t]),e},Z=new Map,ot=()=>({register:(n,s)=>{s?Z.set(n,s):Z.delete(n)},resolve:n=>n?Z.get(n)??null:null}),oe=ot(),ce=b.createContext(null),ct=({children:n})=>{const s=b.useRef(new Map),e=b.useCallback((r,o)=>{o?s.current.set(r,o):s.current.delete(r)},[]),t=b.useCallback(r=>r?s.current.get(r)??null:null,[]),a=b.useMemo(()=>({register:e,resolve:t}),[e,t]);return b.createElement(ce.Provider,{value:a},n)},he=()=>b.useContext(ce)??oe,ht=()=>he().register,dt=()=>he().resolve;oe.register;const de=b.createContext(void 0),ut=()=>{const n=b.useContext(de);if(!n)throw new I("XR context can only be used inside XRProvider, did you forget to wrap your app in <XRProvider>?");return n},lt=({children:n,perf:s})=>{const e=rt(s),t=b.useMemo(()=>({session:e}),[e]);return ie.jsx(de.Provider,{value:t,children:ie.jsx(ct,{children:n})})};exports.XRMediaSource=x;exports.XRModel=L;exports.XRProvider=lt;exports.fetchAndVerify=re;exports.libConfig=E;exports.unprojectToZZero=Ae;exports.unprojectToZZeroInto=q;exports.useRegisterRuntimeObject=ht;exports.useResolveRuntimeObject=dt;exports.useXRContext=ut;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const w=require("react/jsx-runtime"),_=require("@react-three/fiber"),p=require("react"),H=require("three"),O=require("./renderLayers-lDtL0_43.cjs"),S=require("./index-82aENaRq.cjs");function D(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const h=D(H),q=["face.center","face.forehead","face.noseTip","face.chin","face.leftEyeOuter","face.rightEyeOuter","face.leftCheek","face.rightCheek","face.mouthCenter","face.leftEye","face.rightEye","face.leftEarlobe","face.rightEarlobe","face.custom"],v=["hand.wrist","hand.thumbTip","hand.indexTip","hand.middleTip","hand.ringTip","hand.pinkyTip","hand.indexBase","hand.middleBase","hand.ringBase","hand.pinkyBase"],z=["body.head","body.neck","body.leftShoulder","body.rightShoulder","body.leftElbow","body.rightElbow","body.leftWrist","body.rightWrist","body.leftHip","body.rightHip","body.leftKnee","body.rightKnee","body.leftAnkle","body.rightAnkle"],A=e=>e.startsWith("face.")?"face":e.startsWith("hand.")?"hand":e.startsWith("body.")?"body":null,N={target:"face.center",customAnchorPoint:{x:0,y:0,z:0},offset:{x:0,y:0,z:0},smoothing:0,followFaceRoll:!1},R=(e,r,n)=>r+n*(e-r),E=(e,r)=>1/(1+1/(2*Math.PI*e)/r),C=(e,r,n,a,T,t)=>{if(!e.initialized||n<=0)return e.pos.copy(r),e.prevRaw.copy(r),e.dxHat.set(0,0,0),e.initialized=!0,e;const c=E(t,n),u=["x","y","z"];for(const o of u){const l=(r[o]-e.prevRaw[o])/n,i=R(l,e.dxHat[o],c);e.dxHat[o]=i;const f=a+T*Math.abs(i),d=E(f,n);e.pos[o]=R(r[o],e.pos[o],d),e.prevRaw[o]=r[o]}return e},m=(e,r,n,a)=>C(e,r,n,a*.1,.5,1),F=({target:e,customAnchorPoint:r,offset:n,smoothing:a=0,children:T})=>{const t=S.useTrackerContext(),c=p.useRef(null),u=p.useRef(!1),o=p.useRef(new h.Vector3),l=p.useRef({pos:new h.Vector3,prevRaw:new h.Vector3,dxHat:new h.Vector3,initialized:!1}),i=A(e),f=t!==null&&i!==null&&t.type!==i,d=t===null,b=d||f||i===null;return p.useEffect(()=>{d?console.warn(`[TrackingAnchor] target "${e}" requires a FaceTracker / HandTracker / BodyTracker ancestor; rendering null.`):f?console.warn(`[TrackingAnchor] target "${e}" namespace does not match parent tracker type "${t==null?void 0:t.type}"; rendering null.`):i===null&&console.warn(`[TrackingAnchor] target "${e}" is not a recognized face/hand/body landmark; rendering null.`)},[e,i,d,f,t==null?void 0:t.type]),_.useFrame((G,k)=>{if(b||!c.current||!t)return;const y=t.resolveLandmark(e,r);if(!y){c.current.visible=!1,u.current=!1,l.current.initialized=!1;return}c.current.visible=!0;const s=o.current.copy(y.position),g=c.current.parent;if(g){g.updateMatrixWorld();const x=new h.Matrix4().copy(g.matrixWorld).invert();s.applyMatrix4(x)}n&&(s.x+=n[0],s.y+=n[1],s.z+=n[2]),a>0?(m(l.current,s,u.current?k:0,a),c.current.position.copy(l.current.pos)):c.current.position.copy(s),u.current=!0,y.quaternion&&c.current.quaternion.copy(y.quaternion)}),b?null:w.jsx("group",{ref:c,renderOrder:O.RENDER_LAYERS.TRACKED,children:T})};exports.BODY_TARGETS=z;exports.DEFAULT_TRACKING_ANCHOR=N;exports.FACE_TARGETS=q;exports.HAND_TARGETS=v;exports.TrackingAnchor=F;exports.getTargetNamespace=A;exports.stepTrackingSmoothing=m;
|