@vincentt-xr/sdk 2.0.0-alpha.1 → 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 +1588 -20
- package/dist/{DebuggerUI-CatYc-RG.cjs → DebuggerUI-B45_Gb9d.cjs} +1 -1
- package/dist/{DebuggerUI-gLMKiVwJ.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 +17 -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 +70 -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 +2 -2
- package/dist/components/FaceRetouch/Background.d.ts +5 -6
- package/dist/components/FaceRetouch/FaceRetouch.d.ts +47 -0
- package/dist/components/FaceRetouch/index.d.ts +2 -8
- package/dist/components/FaceRetouch/landmarkMask.d.ts +0 -5
- package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +3 -7
- package/dist/components/FaceTracker/index.d.ts +5 -3
- package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +1 -1
- package/dist/components/HandJoints2D/index.d.ts +1 -1
- package/dist/components/HandTracking2D/HandVisual.d.ts +1 -1
- package/dist/components/HandTracking2D/index.d.ts +1 -1
- package/dist/components/HandTracking2DController/index.d.ts +1 -1
- package/dist/components/HandTracking3D/index.d.ts +1 -1
- 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 -87
- 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 -20
- 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 -161
- 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/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 -118
- 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 +12 -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/face-mesh-renderer-settings/index.d.ts +8 -0
- package/dist/debug-ui/face-retouch/index.d.ts +11 -0
- package/dist/debug-ui/hand-joints-2d/index.d.ts +1 -1
- package/dist/debug-ui/hand-tracking-2d/index.d.ts +1 -1
- package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +1 -1
- package/dist/debug-ui/hand-tracking-3d/index.d.ts +1 -1
- package/dist/debug-ui/hierarchy-panel/index.d.ts +29 -0
- package/dist/debug-ui/index.d.ts +25 -2
- package/dist/debug-ui/layer-panel/index.d.ts +3 -2
- package/dist/debug-ui/media-source/index.d.ts +2 -0
- package/dist/debug-ui/media-source/session.d.ts +12 -0
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +6 -4
- 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 +4 -2
- 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 -122
- 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/shared/ScreenTransformSection.d.ts +6 -3
- package/dist/debug-ui/transform-3d-settings/index.d.ts +11 -0
- package/dist/debug-ui.cjs +3 -13
- package/dist/debug-ui.js +7896 -5098
- 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 +53 -6
- package/dist/entries/face-effects.d.ts +10 -8
- package/dist/entries/internal.d.ts +1 -1
- package/dist/entries/low-level.d.ts +18 -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 -342
- package/dist/face-effects.js +1391 -2767
- 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/{handJoints2d.d.ts → hand/handJoints2d.d.ts} +1 -1
- package/dist/{handTracking2d.d.ts → hand/handTracking2d.d.ts} +1 -1
- package/dist/{handTracking2dController.d.ts → hand/handTracking2dController.d.ts} +1 -1
- package/dist/{handTracking3d.d.ts → hand/handTracking3d.d.ts} +1 -1
- 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-BGNbrc4C.js → index-BgQAX8rs.js} +213 -125
- 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-safCs_af.js → index-JygePOwo.js} +565 -508
- package/dist/index-UC0Ux38E.js +111 -0
- package/dist/{internal-Cae1ps15.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 +1229 -86
- package/dist/main.cjs +1 -73
- package/dist/main.js +545 -1693
- 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/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/{screenImageSettings.d.ts → screen-image/screenImageSettings.d.ts} +9 -2
- package/dist/{screenTextSettings.d.ts → screen-text/screenTextSettings.d.ts} +18 -2
- package/dist/screen2d/coordinates.d.ts +87 -0
- package/dist/screen2d/index.d.ts +3 -0
- package/dist/screen2d/screenTransform.d.ts +47 -0
- package/dist/screen2d/smoothing.d.ts +5 -0
- package/dist/{selectors-BLl2JUWW.cjs → selectors-2QvO5RYY.cjs} +1 -1
- package/dist/{selectors-CXd_x-6t.js → selectors-Dw3C-gSk.js} +3 -3
- 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 +580 -321
- package/dist/types/face.d.ts +1 -13
- package/dist/types/index.d.ts +0 -1
- package/dist/types/nodes.d.ts +2 -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/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 +37 -7
- package/dist/MediaSourceSwitcher-C-xYg0nQ.js +0 -317
- package/dist/MediaSourceSwitcher-Cq3g4IKw.cjs +0 -31
- package/dist/components/FaceRetouch/defaults.d.ts +0 -13
- package/dist/components/FaceRetouch/retouchRegions.d.ts +0 -23
- package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +0 -12
- package/dist/defaults-BLpcN3pG.cjs +0 -1
- package/dist/defaults-LtY4M7dg.js +0 -55
- package/dist/index-BXyObVHF.cjs +0 -1
- package/dist/index-CY3bUAcW.js +0 -12
- package/dist/index-C_Duh13c.cjs +0 -1
- package/dist/index-D8fpPQkC.cjs +0 -1
- package/dist/index-DxshgBu0.cjs +0 -1
- package/dist/index-O-2crZ3M.js +0 -1102
- package/dist/internal-BjyhBP8i.cjs +0 -1
- package/dist/modules/XRClient/index.d.ts +0 -9
- package/dist/modules/index.d.ts +0 -1
- package/dist/screenImageSettings-6NRg4cx9.js +0 -39
- package/dist/screenImageSettings-y_B4_767.cjs +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
- package/dist/useXRModel-3DcUa28n.cjs +0 -1
- package/dist/useXRModel-BMJE1hrk.js +0 -28
- /package/dist/{layerStack.d.ts → render/layerStack.d.ts} +0 -0
- /package/dist/{screenImagePresets.d.ts → screen-image/screenImagePresets.d.ts} +0 -0
- /package/dist/{screenTextPresets.d.ts → screen-text/screenTextPresets.d.ts} +0 -0
package/dist/index-DxshgBu0.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var le=Object.defineProperty;var ge=(i,s,e)=>s in i?le(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e;var h=(i,s,e)=>ge(i,typeof s!="symbol"?s+"":s,e);const me=require("react/jsx-runtime"),V=require("react"),I=require("./index-D8fpPQkC.cjs"),E=require("@mediapipe/tasks-vision"),D=require("three");function fe(i){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const e in i)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>i[e]})}}return s.default=i,Object.freeze(s)}const x=fe(D);var M=(i=>(i.WEBCAM="webcam",i.STREAM="stream",i.CANVAS="canvas",i))(M||{}),O=(i=>(i.HAND_TRACKER="vincentt.xr.hand-tracker",i.GESTURE_TRACKER="vincentt.xr.gesture-tracker",i.FACE_TRACKER="vincentt.xr.face-tracker",i.BODY_TRACKER="vincentt.xr.body-tracker",i.BACKGROUND_SEGMENTATION="vincentt.xr.background-segmentation",i))(O||{});const pe={BACKGROUND:-1e3,WORLD:0,TRACKED:100,SCREEN_UI:1e3};class b extends Error{constructor(s){super(s),this.name="VincenttXRError"}}class we{constructor(s){h(this,"options");const e={verbose:!1,prefix:I.libConfig.loggerPrefix};this.options={...e,...s}}log(...s){const{verbose:e,prefix:t}=this.options;e&&console.log(t,...s)}error(...s){const{verbose:e,prefix:t}=this.options;e&&console.error(t,...s)}}const L=i=>i*2-1,G=new x.Vector3,X=new x.Vector3,z=({x:i,y:s,z:e},t,a)=>{G.set((i-.5)*2,(.5-s)*2,-e),G.unproject(t),X.copy(G).sub(t.position).normalize();const o=-t.position.z/X.z;return a.copy(t.position).addScaledVector(X,o),a},ve=(i,s)=>z(i,s,new x.Vector3),Ce=(i,s,e=.2)=>e*s+(1-e)*i;class j{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 o=Math.max(1,Math.round(e*a)),c=Math.max(1,Math.round(t*a));(!this.canvas||this.canvas.width!==o||this.canvas.height!==c)&&(this.canvas=new OffscreenCanvas(o,c));const u=this.canvas.getContext("2d");return u?(u.setTransform(1,0,0,1,0,0),u.clearRect(0,0,o,c),u.drawImage(s,0,0,o,c),this.canvas):s}dispose(){this.canvas=void 0}}const Se={};async function ee(i){const s=await fetch(i);if(!s.ok)throw new Error(`fetchAndVerify: ${s.status} ${i}`);const e=await s.arrayBuffer(),t=ke(i);if(!t)return console.warn(`[xr-sdk integrity] no SRI hash for ${i} — passing through`),e;const a=await ye(e);if(a!==t)throw new Error(`[xr-sdk integrity] SRI mismatch for ${i}: expected ${t}, got ${a}`);return e}async function B(i){const s=await ee(i);return new Uint8Array(s)}function ke(i){try{const s=new URL(i);return Se[s.pathname]}catch{return}}async function ye(i){const s=await crypto.subtle.digest("SHA-384",i),e=new Uint8Array(s);let t="";for(let a=0;a<e.byteLength;a++)t+=String.fromCharCode(e[a]);return`sha384-${btoa(t)}`}class H{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 Me=768;class Te extends H{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"coordinates");h(this,"sourceCanvas");h(this,"downscaler",new j(Me))}async getBodyData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),a=this.landmarker.detectForVideo(e,t),o=performance.now();this.processingTime=o-t;const c=a.landmarks,u=[];if(c)return c.forEach((m,d)=>{u[d]||(u[d]=[]),m.forEach(g=>{const f=L(g.x),w=L(1-g.y),p=L(g.z);u[d].push({x:f,y:w,z:p})})}),{coordinatesList:u}}async processBodyTracking(){if(this.disposed||!this.landmarker)return;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 E.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",I.libConfig.assetStorageEndpoint).toString()),a=await B(new URL("/assets/xr/models/body_tracking.task",I.libConfig.assetStorageEndpoint).toString());this.landmarker=await E.PoseLandmarker.createFromOptions(t,{baseOptions:{modelAssetBuffer:a,delegate:"GPU"},runningMode:"VIDEO",numPoses:(e==null?void 0:e.numPoses)||1})}async run({sourceCanvas:e}){this.sourceCanvas=e,this.rafId===null&&await this.processBodyTracking()}getModelNode(){return{getLandmarks2D:this.getLandmarks2D.bind(this)}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const Re=.11,Fe=.004;class xe extends H{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 x.Matrix4);h(this,"rotQuatScratch",new x.Quaternion);h(this,"rotEulerScratch",new x.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 x.Vector3,rotation:new x.Vector3,scale:new x.Vector3},gestures:{}}),this.leftCheekScratch.push(new x.Vector3),this.rightCheekScratch.push(new x.Vector3);for(let o=0;o<t;o+=1){if(!this.cameras[o])continue;const c=this.faces[o],u=(a=this.getSource)==null?void 0:a.call(this),m=!(u==="webcam"||!u),d=e.faceLandmarks[o],g=e.facialTransformationMatrixes[o];this.rotMatrixScratch.fromArray(g.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"),c.transform.rotation.set(-this.rotEulerScratch.x,this.rotEulerScratch.y,this.rotEulerScratch.z),z(this.landmarkForSource(d[4],m),this.cameras[o],c.transform.position),z(this.landmarkForSource(d[50],m),this.cameras[o],this.leftCheekScratch[o]),z(this.landmarkForSource(d[280],m),this.cameras[o],this.rightCheekScratch[o]);const w=this.leftCheekScratch[o].distanceTo(this.rightCheekScratch[o])*Re,p=Math.abs(x.MathUtils.radToDeg(this.rotEulerScratch.y)),S=w+p*Fe,C=c.transform.scale.x,y=Ce(isNaN(C)?0:C,S);c.transform.scale.set(y,y,y);const F=c.gestures,T=e.faceBlendshapes[o].categories;for(const A of T)F[A.categoryName]=A.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=Ae(this.numFaces),t=this.sourceCanvas.width,a=this.sourceCanvas.height,o=Math.min(1,e/Math.max(t,a)),c=Math.max(1,Math.round(t*o)),u=Math.max(1,Math.round(a*o));(!this.analysisCanvas||this.analysisCanvas.width!==c||this.analysisCanvas.height!==u)&&(this.analysisCanvas=new OffscreenCanvas(c,u));const m=this.analysisCanvas.getContext("2d");if(!m)return;m.setTransform(1,0,0,1,0,0),m.clearRect(0,0,c,u),m.drawImage(this.sourceCanvas,0,0,c,u);const d=performance.now(),g=this.landmarker.detectForVideo(this.analysisCanvas,d),f=performance.now();this.processingTime=f-d,this.detectionResults=g,this.extractAndUpdateFaceData(g),!(this.disposed||this.paused)&&(this.rafId=requestAnimationFrame(this.processFaceTracking.bind(this)))}resume(){this.paused&&(super.resume(),this.processFaceTracking())}getFace(e=0){return this.faces[e]}getDetectionResults(){return this.detectionResults}getRawFaceTrackingData(e=0){var t,a,o,c;if(this.detectionResults)return{landmarks:(t=this.detectionResults.faceLandmarks)==null?void 0:t[e],blendshapes:(o=(a=this.detectionResults.faceBlendshapes)==null?void 0:a[e])==null?void 0:o.categories,transformationMatrix:(c=this.detectionResults.facialTransformationMatrixes)==null?void 0:c[e]}}async initialize(e){this.numFaces=(e==null?void 0:e.numFaces)||1;const t=await E.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",I.libConfig.assetStorageEndpoint).toString()),a=await B(new URL("/assets/xr/models/face_tracking.task",I.libConfig.assetStorageEndpoint).toString()),o=await E.FaceLandmarker.createFromOptions(t,{baseOptions:{modelAssetBuffer:a,delegate:"GPU"},minFaceDetectionConfidence:.3,minFacePresenceConfidence:.3,minTrackingConfidence:.3,outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0,runningMode:"VIDEO",numFaces:this.numFaces});this.landmarker=o}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,t={get detectionResults(){return e.detectionResults},getDetectionResults:this.getDetectionResults.bind(this),getFace:this.getFace.bind(this),getRawFaceTrackingData:this.getRawFaceTrackingData.bind(this)};return Object.assign(t,{_setCamera:(a,o)=>{this.cameras[o]=a}}),t}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const Ae=i=>i>1?1024:512;var _=(i=>(i.ClosedFist="closed_fist",i.OpenPalm="open_palm",i.PointingUp="pointing_up",i.ThumbDown="thumb_down",i.ThumbUp="thumb_up",i.Victory="victory",i.ILoveYou="i_love_you",i.None="none",i))(_||{});const be=512,Ee={Closed_Fist:_.ClosedFist,Open_Palm:_.OpenPalm,Pointing_Up:_.PointingUp,Thumb_Down:_.ThumbDown,Thumb_Up:_.ThumbUp,Victory:_.Victory,ILoveYou:_.ILoveYou,None:_.None},Ie=15;class De extends H{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"coordinates");h(this,"gesture");h(this,"sourceCanvas");h(this,"downscaler",new j(be))}async getGestureData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),a=this.landmarker.recognizeForVideo(e,t),o=performance.now();this.processingTime=o-t;const c=a.landmarks[0],u=[];if(c){const m=a.gestures[0][0].categoryName;return c.forEach(d=>{u.push({x:L(d.x),y:L(1-d.y),z:-d.z})}),{coordinates:u,gesture:Ee[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 E.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",I.libConfig.assetStorageEndpoint).toString()),t=await B(new URL("/assets/xr/models/gesture_tracking.task",I.libConfig.assetStorageEndpoint).toString()),a=await E.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??Ie),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 _e=512;class Pe extends H{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 j(_e))}async getHandData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),a=this.landmarker.detectForVideo(e,t),o=performance.now();this.processingTime=o-t;const c=[],u=a.handedness??a.handednesses??[];if(a.landmarks.forEach((d,g)=>{var C,y,F;if(!d||d.length===0)return;const f=d.map(T=>({x:L(T.x),y:L(1-T.y),z:-T.z})),w=(F=(y=(C=u[g])==null?void 0:C[0])==null?void 0:y.categoryName)==null?void 0:F.toLowerCase(),p=w==="left"||w==="right"?w:void 0,S=d[0].z<0?"closed_fist":"open_palm";c.push({coordinates:f,gesture:S,handedness:p})}),!c.length)return{hands:void 0,coordinates:void 0,gesture:void 0,handedness:void 0};const m=c[0];return{hands:c,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 E.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",I.libConfig.assetStorageEndpoint).toString()),t=await B(new URL("/assets/xr/models/hand_tracking.task",I.libConfig.assetStorageEndpoint).toString()),a=await E.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 Oe=24,Le=720,Ue=[[255,255,255,255],[0,0,0,0]];class Ne extends H{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,Le/Math.max(e.width,e.height)),a=Math.max(1,Math.round(e.width*t)),o=Math.max(1,Math.round(e.height*t));this.processCanvas.width===a&&this.processCanvas.height===o||(this.processCanvas.width=a,this.processCanvas.height=o,this.glCanvas&&(this.glCanvas.width=a,this.glCanvas.height=o),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:g}=this.inputSourceSize,f=Math.min(u/d,m/g),w=d*f,p=g*f;a.drawImage(this.inputSource,(u-w)/2,(m-p)/2,w,p)}else a.drawImage(e,0,0,u,m)}const c=this.segmenter.segmentForVideo(this.processCanvas,performance.now()).categoryMask;if(!c){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(c,Ue),this.latestMask=c.clone(),c.close(),this.blitGlToMask();else{this.latestMask=c.clone();const u=this.readMaskToImageData(c);c.close(),u&&this.blitImageDataToMask(u)}this.segmentationMaskTexture&&(this.isMaskSetup||(this.segmentationMaskTexture.format=D.RGBAFormat,this.segmentationMaskTexture.minFilter=D.LinearFilter,this.segmentationMaskTexture.magFilter=D.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:o}=e;if(!t||a<=0||o<=0)return null;(!this.maskImageData||this.maskImageData.width!==a||this.maskImageData.height!==o)&&(this.maskImageData=new ImageData(a,o));const c=this.maskImageData.data;for(let u=0;u<t.length;u+=1){const m=t[u]===255?0:255;c[u*4]=255,c[u*4+1]=m,c[u*4+2]=255,c[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 o=this.getStagingCanvas(e.width,e.height),c=o.getContext("2d");c&&(c.putImageData(e,0,0),a.filter="blur(0.5px)",a.clearRect(0,0,this.filterCanvas.width,this.filterCanvas.height),a.drawImage(o,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 E.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",I.libConfig.assetStorageEndpoint).toString()),a=await B(new URL("/assets/xr/models/segmentation.tflite",I.libConfig.assetStorageEndpoint).toString());this.glCanvas=new OffscreenCanvas(1,1);const o=this.glCanvas.getContext("webgl2",{preserveDrawingBuffer:!0});this.segmenter=await E.ImageSegmenter.createFromOptions(t,{baseOptions:{modelAssetBuffer:a,delegate:"GPU"},...o?{canvas:this.glCanvas}:{},outputCategoryMask:!0,outputConfidenceMasks:!1,runningMode:"VIDEO"}),o?(this.drawingUtils=new E.DrawingUtils(o),this.useGpuMaskPath=!0):this.useGpuMaskPath=!1}async run({sourceCanvas:e,renderWidth:t,renderHeight:a,targetFps:o}){if(!e)return;this.setTargetFps(o??Oe),this.isProcessing=!1,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null);const c=this.getQualityScaleFactor();this.sourceCanvas=e,this.processCanvas=document.createElement("canvas"),this.processCanvas.width=e.width*c,this.processCanvas.height=e.height*c,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,this.segmentationMaskTexture=new D.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 J={[O.BACKGROUND_SEGMENTATION]:Ne,[O.HAND_TRACKER]:Pe,[O.GESTURE_TRACKER]:De,[O.FACE_TRACKER]:xe,[O.BODY_TRACKER]:Te},ze=async i=>{const s=document.createElement("video");s.srcObject=i,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),o=()=>{clearTimeout(a),t()};typeof e.requestVideoFrameCallback=="function"?e.requestVideoFrameCallback(o):requestAnimationFrame(()=>requestAnimationFrame(()=>o()))}),s},Ve=i=>{const s=new D.CanvasTexture(i);return s.colorSpace=D.SRGBColorSpace,s.format=D.RGBAFormat,s.minFilter=D.LinearFilter,s.magFilter=D.LinearFilter,s.generateMipmaps=!1,s.needsUpdate=!0,s},Be=(i,s)=>{const e=i.videoWidth,t=i.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(i,-s.width,0,s.width,s.height),a.restore()},He=(i,s,e=1)=>{const t=s.getContext("2d",{colorSpace:"srgb"}),a=s.width/s.height,o=i.width/i.height;let c,u;o>a?(u=s.height,c=i.width*(s.height/i.height)):(c=s.width,u=i.height*(s.width/i.width));const m=Number.isFinite(e)&&e>0?e:1;c*=m,u*=m;const d=(s.width-c)/2,g=(s.height-u)/2;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,s.width,s.height),t.drawImage(i,0,0,i.width,i.height,d,g,c,u)},qe=(i,s,e)=>{const t=new Map;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 S=s[g];if(!S)throw new Error(`Invalid model: ${g}`);const C=new S,y=new Set([f]),F=new Set([f]),T=(async()=>{await C.initialize(w),e&&await e(g,C);const A=t.get(g);return A&&A.refs.size>0&&i.setPipeline(P=>P.set(g,C)),C})();return p={model:C,refs:y,activeRefs:F,initPromise:T,options:w},t.set(g,p),T.catch(()=>{t.get(g)===p&&(t.delete(g),i.setPipeline(P=>P.delete(g)))}),T},release:(g,f)=>{var S;const w=t.get(g);if(!w||(w.refs.delete(f),w.activeRefs.delete(f)&&w.refs.size>0&&w.activeRefs.size===0&&w.model.pause(),w.refs.size>0))return;t.delete(g);const p=w.model;try{(S=p.dispose)==null||S.call(p)}catch(C){console.warn(`[xr-sdk registry] dispose threw for ${g}`,C)}i.setPipeline(C=>C.delete(g))},setActive:(g,f,w)=>{const p=t.get(g);if(!p||!p.refs.has(f))return;const S=p.activeRefs.size>0;w?p.activeRefs.add(f):p.activeRefs.delete(f);const C=p.activeRefs.size>0;S!==C&&(C?p.model.resume():p.model.pause())},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:()=>{var g;for(const f of Array.from(t.keys())){const w=t.get(f);if(!w)continue;w.refs.clear(),t.delete(f);const p=w.model;try{(g=p.dispose)==null||g.call(p)}catch(S){console.warn(`[xr-sdk registry] dispose threw for ${f}`,S)}}i.setPipeline(f=>f.clear())}}},Ke={lifecycle:"idle",ready:!1,error:void 0,cameraTexture:void 0,renderWidth:0,renderHeight:0,source:void 0,sourceKind:void 0,pipeline:new Map},We=()=>{let i={...Ke,pipeline:new Map};const s=new Set,e=()=>{s.forEach(t=>t())};return{getSnapshot:()=>i,set:t=>{let a=!1;for(const o of Object.keys(t))if(t[o]!==i[o]){a=!0;break}a&&(i={...i,...t},e())},setPipeline:t=>{const a=new Map(i.pipeline);return t(a),i={...i,pipeline:a},e(),a},subscribe:t=>(s.add(t),()=>{s.delete(t)})}},Ge=({renderHeight:i,renderWidth:s,videoHeight:e,videoWidth:t})=>({height:i||e,width:s||t}),Xe=i=>{const s=new we({verbose:!0}),e=We();let t=i;const a=n=>{var l;const r=(l=U.getOptions(n))==null?void 0:l.targetFps;return typeof r=="number"?r:t==null?void 0:t.targetFps};let o,c,u,m,d,g,f,w,p,S,C=!1,y=!1;const F=new Set,T=new Set,A=n=>{const r=e.getSnapshot().cameraTexture;r&&r.dispose();const l=Ve(n);return e.set({cameraTexture:l}),l},P=async(n,r)=>{if(!F.has(n)&&e.getSnapshot().lifecycle==="running"&&d){F.add(n);try{await r.run({sourceCanvas:d,renderWidth:e.getSnapshot().renderWidth,renderHeight:e.getSnapshot().renderHeight,getSource:()=>e.getSnapshot().sourceKind,targetFps:a(n)}),y&&(await new Promise(l=>requestAnimationFrame(()=>l())),await new Promise(l=>requestAnimationFrame(()=>l())),r.pause())}catch(l){throw F.delete(n),l}}},U=qe(e,J,(n,r)=>P(n,r));e.subscribe(()=>{if(e.getSnapshot().lifecycle!=="running")return;const n=e.getSnapshot().pipeline;for(const[r,l]of n.entries())F.has(r)||P(r,l)});const N=()=>{if(S!==void 0&&(cancelAnimationFrame(S),S=void 0),c){try{c.pause()}catch{}try{c.srcObject=null}catch{}c=void 0}if(u){try{u.getTracks().forEach(n=>n.stop())}catch{}u=void 0}},q=()=>{if(C||!c||!m||!d)return;const n=window.__xr_debugger_metrics;if(n!=null&&n.trackCameraFrame&&n.trackCameraFrame(),(e.getSnapshot().sourceKind??"webcam")==="webcam")Be(c,m);else{const v=m.getContext("2d");if(!v)return;const k=c.videoWidth,R=c.videoHeight;m.width!==k&&(m.width=k),m.height!==R&&(m.height=R),v.setTransform(1,0,0,1,0,0),v.clearRect(0,0,k,R),v.drawImage(c,0,0,k,R)}He(m,d,(t==null?void 0:t.cameraZoom)??1.2);const l=e.getSnapshot().cameraTexture;l&&(l.needsUpdate=!0)},Y=()=>{if(!c||!m||!d)return;if(y){q();return}const n=()=>{S=requestAnimationFrame(n),q()};S=requestAnimationFrame(n)},se=async n=>{if(n.source===M.WEBCAM)try{const r=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:r}}})}catch(r){const l=r instanceof DOMException?r.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 b(r instanceof Error?r.message:"getUserMedia failed")}return n.stream},K=async n=>{const r=await se(n);u=r;const l=await ze(r);c=l,m=new OffscreenCanvas(l.videoWidth,l.videoHeight);const{renderWidth:v,renderHeight:k}=e.getSnapshot(),R=Ge({renderWidth:v,renderHeight:k,videoWidth:l.videoWidth,videoHeight:l.videoHeight});d?(d.width!==R.width||d.height!==R.height)&&(d.width=R.width,d.height=R.height,A(d)):(d=new OffscreenCanvas(R.width,R.height),A(d));const Z=n.source===M.STREAM?n.static===!0:!1;y=Z,o=n.source===M.WEBCAM?{source:M.WEBCAM,sourceKind:"webcam"}:{source:M.STREAM,stream:n.stream,static:Z,sourceKind:n.sourceKind??"webcam"},e.set({source:n.source,sourceKind:o.sourceKind,error:void 0})},W=async n=>{const r=n.sourceKind??"webcam";d=n.canvas;const l=A(d);e.set({cameraTexture:l,source:M.CANVAS,sourceKind:r,renderWidth:d.width,renderHeight:d.height,error:void 0}),o={source:M.CANVAS,canvas:n.canvas,sourceKind:r}},ie=(n,r)=>!r||n.source!==r.source?!1:n.source===M.STREAM&&r.source===M.STREAM?n.stream===r.stream&&(n.sourceKind??"webcam")===r.sourceKind:!0,ne=async()=>{if(!d)return;const n=e.getSnapshot().pipeline;for(const[,r]of n.entries())r.resume();await new Promise(r=>requestAnimationFrame(()=>r())),await new Promise(r=>requestAnimationFrame(()=>r()));for(const[,r]of n.entries())r.pause()},ae=(n,r)=>!r||r.source!==M.CANVAS?!1:n.canvas===r.canvas&&(n.sourceKind??"webcam")===r.sourceKind,re=async n=>{const r=n.source;if(r!==M.WEBCAM&&r!==M.STREAM)throw new b(`Invalid media source: ${String(r)}`);if(ie(n,o)){s.log("Media source unchanged, skipping rebind.");return}const{lifecycle:l}=e.getSnapshot();if(l==="idle"||l==="stopped"){await K(n),e.set({lifecycle:"media-bound"}),s.log("Media source set to:",n.source);return}if(l==="media-bound"){N(),await K(n),s.log("Media source rebound to:",n.source);return}if(C=!0,await new Promise(v=>requestAnimationFrame(()=>v())),N(),await K(n),C=!1,Y(),y)await ne();else{const v=e.getSnapshot().pipeline;for(const[,k]of v.entries())k.resume()}s.log("Media source swapped to:",n.source)},oe=async n=>{if(ae(n,o)){s.log("Frame source unchanged, skipping rebind.");return}const{lifecycle:r}=e.getSnapshot();if(r==="idle"||r==="stopped"){await W(n),e.set({lifecycle:"media-bound"}),s.log("Frame source set to canvas.");return}if(r==="media-bound"){N(),await W(n),s.log("Frame source rebound to canvas.");return}C=!0,await new Promise(l=>requestAnimationFrame(()=>l())),N(),await W(n),C=!1,s.log("Frame source swapped to canvas.")},ce=async()=>{const{lifecycle:n}=e.getSnapshot();if(n==="running")return;if(n==="idle")throw new b("session.start() called before setMediaSource — call setMediaSource first");if(!d)throw new b("session.start(): media source not bound");const r=(o==null?void 0:o.source)===M.CANVAS;if(!r&&(!c||!m))throw n==="stopped"?new b("session.start() called from stopped state without a media source — call setMediaSource first"):new b("session.start(): media source not bound");r||Y(),e.set({lifecycle:"running"}),await new Promise(v=>requestAnimationFrame(()=>v()));const l=e.getSnapshot().pipeline;for(const[v,k]of l.entries())await P(v,k);e.set({ready:!0}),s.log("XR session started.")},$=async()=>{const{lifecycle:n}=e.getSnapshot();n==="stopped"||n==="idle"||(N(),e.set({lifecycle:"stopped",ready:!1}),s.log("XR session stopped."))},he=async()=>{await $(),U.releaseAll(),T.clear();const n=e.getSnapshot().cameraTexture;n&&n.dispose(),F.clear(),o=void 0,d=void 0,m=void 0,y=!1,e.set({lifecycle:"idle",cameraTexture:void 0,source:void 0}),s.log("XR session reset.")},de=async n=>{const r="legacy:registerXRPipeline",l=[];await Promise.all(n.map(async v=>{const{model:k}=v;if(!J[k])throw new b(`Invalid model: ${k}`);T.has(k)||l.push(k);const R="options"in v?v.options:void 0;await U.acquire(k,r,R)})),l.length>0&&(l.forEach(v=>T.add(v)),s.log("XR pipeline registered."))},ue=n=>{const r=U.get(n);if(!r)throw new b(`Model ${n} is not registered in the pipeline`);return r.getModelNode()},Q=async(n,r)=>{n<=0||r<=0||(e.set({renderWidth:n,renderHeight:r}),d&&(d.width!==n||d.height!==r)&&(d.width=n,d.height=r,A(d),y&&q()),s.log(`Source canvas set. Render size: ${n}x${r}`))};return{store:e,registry:U,setMediaSource:re,start:ce,stop:$,reset:he,setFrameSource:oe,registerXRPipeline:de,getModelNode:ue,captureFrame:()=>{if(!g)throw new b("session.captureFrame() called before the XRScene render target was bound — make sure <XRScene> is mounted");if(!f||!w||!p)throw new b("session.captureFrame() called before the R3F state was bound — make sure <XRScene> is mounted");return f.render(w,p),g.toDataURL("image/png")},_setRenderTarget:async n=>{var k;g=n;const r=(k=n.getBoundingClientRect)==null?void 0:k.call(n),l=r&&r.width>0?Math.round(r.width):n.clientWidth,v=r&&r.height>0?Math.round(r.height):n.clientHeight;await Q(l,v)},_setRenderSize:Q,_setR3FState:n=>{f=n.renderer,w=n.scene,p=n.camera},_getVideoElement:()=>c,_setPerf:n=>{if(t=n,e.getSnapshot().lifecycle!=="running"||!d)return;const r=e.getSnapshot().pipeline;for(const[l,v]of r.entries())v.run({sourceCanvas:d,renderWidth:e.getSnapshot().renderWidth,renderHeight:e.getSnapshot().renderHeight,getSource:()=>e.getSnapshot().sourceKind,targetFps:a(l)})}}},je=i=>{const s=V.useMemo(()=>Xe(i),[]),e=JSON.stringify(i??{});return V.useEffect(()=>{s._setPerf(i)},[s,e]),s},te=V.createContext(void 0),Ye=()=>{const i=V.useContext(te);if(!i)throw new b("XR context can only be used inside XRProvider, did you forget to wrap your app in <XRProvider>?");return i},$e=({children:i,perf:s})=>{const e=je(s),t=V.useMemo(()=>({session:e}),[e]);return me.jsx(te.Provider,{value:t,children:i})};exports.RENDER_LAYERS=pe;exports.XRMediaSource=M;exports.XRModel=O;exports.XRProvider=$e;exports.fetchAndVerify=ee;exports.unprojectToZZero=ve;exports.unprojectToZZeroInto=z;exports.useXRContext=Ye;
|