@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
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (
|
|
4
|
-
import { jsx as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const pt = {
|
|
12
|
-
/** Camera background and segmentation mask. `depthTest` disabled. */
|
|
13
|
-
BACKGROUND: -1e3,
|
|
14
|
-
/** Free world-space content. `depthTest` enabled. */
|
|
15
|
-
WORLD: 0,
|
|
16
|
-
/** Descendants of `FaceTracker` / `HandTracker` / `BodyTracker`. `depthTest` enabled. */
|
|
17
|
-
TRACKED: 100,
|
|
18
|
-
/** Descendants of `ScreenSpaceUI`. `depthTest` disabled. */
|
|
19
|
-
SCREEN_UI: 1e3
|
|
20
|
-
};
|
|
21
|
-
class E extends Error {
|
|
1
|
+
var Ae = Object.defineProperty;
|
|
2
|
+
var be = (i, s, e) => s in i ? Ae(i, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[s] = e;
|
|
3
|
+
var h = (i, s, e) => be(i, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
+
import { jsx as ne } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as oe, useMemo as $, useEffect as Ee, useContext as ce, useCallback as ae, createElement as Ie, createContext as he } from "react";
|
|
6
|
+
import { FilesetResolver as V, PoseLandmarker as De, FaceLandmarker as _e, GestureRecognizer as Pe, HandLandmarker as Oe, ImageSegmenter as Ue, DrawingUtils as ze } from "@mediapipe/tasks-vision";
|
|
7
|
+
import * as E from "three";
|
|
8
|
+
import { RGBAFormat as de, LinearFilter as q, CanvasTexture as ue, SRGBColorSpace as Le } from "three";
|
|
9
|
+
var F = /* @__PURE__ */ ((i) => (i.WEBCAM = "webcam", i.STREAM = "stream", i.CANVAS = "canvas", i))(F || {}), z = /* @__PURE__ */ ((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))(z || {});
|
|
10
|
+
class b extends Error {
|
|
22
11
|
constructor(s) {
|
|
23
12
|
super(s), this.name = "VincenttXRError";
|
|
24
13
|
}
|
|
25
14
|
}
|
|
26
|
-
|
|
15
|
+
const Be = (i, s) => s, I = {
|
|
16
|
+
apiBaseUrl: Be(void 0, "https://api.vincentt.studio"),
|
|
17
|
+
// Pinned to the CDN, NOT build-env-driven: a stale VITE_ASSET_STORAGE_ENDPOINT
|
|
18
|
+
// baked a now-deleted CloudFront domain into every published bundle, breaking
|
|
19
|
+
// WASM/model loads at runtime. The host must never come from a mutable env value.
|
|
20
|
+
assetStorageEndpoint: "https://cdn.vincentt.studio",
|
|
21
|
+
// Versioned bucket for SDK-shipped reference assets (canonical face model, face textures, etc.).
|
|
22
|
+
sdkAssetsBaseUrl: "https://cdn.vincentt.studio/assets/sdk/face/v1",
|
|
23
|
+
loggerPrefix: "[vincentt-xr]:",
|
|
24
|
+
sessionCheckInterval: 3e4
|
|
25
|
+
};
|
|
26
|
+
class Ve {
|
|
27
27
|
constructor(s) {
|
|
28
28
|
h(this, "options");
|
|
29
29
|
const e = {
|
|
30
30
|
verbose: !1,
|
|
31
|
-
prefix:
|
|
31
|
+
prefix: I.loggerPrefix
|
|
32
32
|
};
|
|
33
33
|
this.options = { ...e, ...s };
|
|
34
34
|
}
|
|
35
35
|
log(...s) {
|
|
36
36
|
const { verbose: e, prefix: t } = this.options;
|
|
37
|
-
e && console.
|
|
37
|
+
e && console.info(t, ...s);
|
|
38
38
|
}
|
|
39
39
|
error(...s) {
|
|
40
40
|
const { verbose: e, prefix: t } = this.options;
|
|
41
41
|
e && console.error(t, ...s);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
},
|
|
49
|
-
class
|
|
44
|
+
const O = (i) => i * 2 - 1, j = new E.Vector3(), Y = new E.Vector3(), H = ({ x: i, y: s, z: e }, t, a) => {
|
|
45
|
+
j.set((i - 0.5) * 2, (0.5 - s) * 2, -e), j.unproject(t), Y.copy(j).sub(t.position).normalize();
|
|
46
|
+
const r = -t.position.z / Y.z;
|
|
47
|
+
return a.copy(t.position).addScaledVector(Y, r), a;
|
|
48
|
+
}, It = (i, s) => H(i, s, new E.Vector3()), Ke = (i, s, e = 0.2) => e * s + (1 - e) * i;
|
|
49
|
+
class Z {
|
|
50
50
|
constructor(s) {
|
|
51
51
|
h(this, "canvas");
|
|
52
52
|
this.maxDimension = s;
|
|
@@ -57,49 +57,68 @@ class X {
|
|
|
57
57
|
* 2D context can't be obtained). The returned canvas is reused across calls.
|
|
58
58
|
*/
|
|
59
59
|
draw(s) {
|
|
60
|
-
const e = s.width, t = s.height,
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
(!this.canvas || this.canvas.width !==
|
|
60
|
+
const e = s.width, t = s.height, a = Math.min(1, this.maxDimension / Math.max(e, t));
|
|
61
|
+
if (a >= 1) return s;
|
|
62
|
+
const r = Math.max(1, Math.round(e * a)), o = Math.max(1, Math.round(t * a));
|
|
63
|
+
(!this.canvas || this.canvas.width !== r || this.canvas.height !== o) && (this.canvas = new OffscreenCanvas(r, o));
|
|
64
64
|
const u = this.canvas.getContext("2d");
|
|
65
|
-
return u ? (u.setTransform(1, 0, 0, 1, 0, 0), u.clearRect(0, 0,
|
|
65
|
+
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;
|
|
66
66
|
}
|
|
67
67
|
dispose() {
|
|
68
68
|
this.canvas = void 0;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const Ne = {
|
|
72
|
+
"/assets/xr/models/face_tracking.task": "sha384-tYQh+yJE8llY+zO4RviZmWaSKs5W9tsB0ix5rjQVpF5/CLTqmwtP7bYtkUi2w65P",
|
|
73
|
+
"/assets/xr/models/hand_tracking.task": "sha384-uWvruVKd887ov8k43S+DBHCsi7UXXS+CKvvdM1PX00rjPzx/B0QrAPfJ1U9yKcze",
|
|
74
|
+
"/assets/xr/models/gesture_tracking.task": "sha384-2zuseP9JKKWAYlWQGKA2N+ooabB8V/yIxu23Mv8mtY7SowcySB+xKiOmqBhVvlUC",
|
|
75
|
+
"/assets/xr/models/body_tracking.task": "sha384-3Wk9dvRYo36b3Nc9xVjKamb4wCKt9FwiPjcHKfrvyJL/jXoGs+uRLnii6yjWLKul",
|
|
76
|
+
"/assets/xr/models/segmentation.tflite": "sha384-A2bQ8+iZyQM3KIGVBUf0FyetqxuynyKpjsjCE8uzoJEnj1ghCu6ge2daiRffAiS5",
|
|
77
|
+
"/assets/xr/3d-models/head-occluder-v2.glb": "sha384-+0G60Q6EBVE6hpITxGzQgofAeKexPltpsfPq5T5et9GGBjRhFP5HOdsKAhe73OaI",
|
|
78
|
+
"/assets/sdk/face/v1/canonical_face_model.obj": "sha384-xP8YM/72TXKvbMptXB9a8JUlUf3MZQ8uLurExrsZc05v6/P5RrsaNGMUYS/BZx8A",
|
|
79
|
+
"/opencv/facial_expression_recognition/resolve/main/facial_expression_recognition_mobilefacenet_2022july_int8.onnx": "sha384-g8mtFubiIc/yhqi591RsxD76AJLw2CfYgKhKbVkIiFlwBmIyG7ZAIVyGPXafrDGB"
|
|
80
|
+
};
|
|
81
|
+
async function He(i) {
|
|
82
|
+
const s = await fetch(i);
|
|
74
83
|
if (!s.ok)
|
|
75
|
-
throw new Error(`fetchAndVerify: ${s.status} ${
|
|
76
|
-
const e = await s.arrayBuffer(), t =
|
|
77
|
-
if (!t)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
throw new Error(`fetchAndVerify: ${s.status} ${i}`);
|
|
85
|
+
const e = await s.arrayBuffer(), t = Ge(i);
|
|
86
|
+
if (!t) {
|
|
87
|
+
if (qe(i))
|
|
88
|
+
throw new Error(`[xr-sdk integrity] no SRI hash for SDK asset ${i}`);
|
|
89
|
+
return console.warn(`[xr-sdk integrity] no SRI hash for ${i} — passing through`), e;
|
|
90
|
+
}
|
|
91
|
+
const a = await We(e);
|
|
92
|
+
if (a !== t)
|
|
81
93
|
throw new Error(
|
|
82
|
-
`[xr-sdk integrity] SRI mismatch for ${
|
|
94
|
+
`[xr-sdk integrity] SRI mismatch for ${i}: expected ${t}, got ${a}`
|
|
83
95
|
);
|
|
84
96
|
return e;
|
|
85
97
|
}
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
function qe(i) {
|
|
99
|
+
try {
|
|
100
|
+
return new URL(i).origin === new URL(I.assetStorageEndpoint).origin;
|
|
101
|
+
} catch {
|
|
102
|
+
return !1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function K(i) {
|
|
106
|
+
const s = await He(i);
|
|
88
107
|
return new Uint8Array(s);
|
|
89
108
|
}
|
|
90
|
-
function
|
|
109
|
+
function Ge(i) {
|
|
91
110
|
try {
|
|
92
|
-
const s = new URL(
|
|
93
|
-
return
|
|
111
|
+
const s = new URL(i);
|
|
112
|
+
return Ne[s.pathname];
|
|
94
113
|
} catch {
|
|
95
114
|
return;
|
|
96
115
|
}
|
|
97
116
|
}
|
|
98
|
-
async function
|
|
99
|
-
const s = await crypto.subtle.digest("SHA-384",
|
|
117
|
+
async function We(i) {
|
|
118
|
+
const s = await crypto.subtle.digest("SHA-384", i), e = new Uint8Array(s);
|
|
100
119
|
let t = "";
|
|
101
|
-
for (let
|
|
102
|
-
t += String.fromCharCode(e[
|
|
120
|
+
for (let a = 0; a < e.byteLength; a++)
|
|
121
|
+
t += String.fromCharCode(e[a]);
|
|
103
122
|
return `sha384-${btoa(t)}`;
|
|
104
123
|
}
|
|
105
124
|
class N {
|
|
@@ -164,37 +183,40 @@ class N {
|
|
|
164
183
|
this.disposed = !0, this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
165
184
|
}
|
|
166
185
|
}
|
|
167
|
-
const
|
|
168
|
-
class
|
|
186
|
+
const Xe = 768;
|
|
187
|
+
class je extends N {
|
|
169
188
|
constructor() {
|
|
170
189
|
super();
|
|
171
190
|
h(this, "landmarker", null);
|
|
172
191
|
h(this, "processingTime", null);
|
|
173
192
|
h(this, "coordinates");
|
|
174
193
|
h(this, "sourceCanvas");
|
|
175
|
-
h(this, "downscaler", new
|
|
194
|
+
h(this, "downscaler", new Z(Xe));
|
|
176
195
|
}
|
|
177
196
|
async getBodyData() {
|
|
178
197
|
if (!this.landmarker || !this.sourceCanvas)
|
|
179
198
|
return;
|
|
180
|
-
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(),
|
|
181
|
-
this.processingTime =
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
return
|
|
185
|
-
u[d] || (u[d] = []), m.forEach((
|
|
186
|
-
const
|
|
187
|
-
u[d].push({ x:
|
|
199
|
+
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(), a = this.landmarker.detectForVideo(e, t), r = performance.now();
|
|
200
|
+
this.processingTime = r - t;
|
|
201
|
+
const o = a.landmarks, u = [];
|
|
202
|
+
if (o)
|
|
203
|
+
return o.forEach((m, d) => {
|
|
204
|
+
u[d] || (u[d] = []), m.forEach((S) => {
|
|
205
|
+
const R = O(S.x), M = O(1 - S.y), x = O(S.z);
|
|
206
|
+
u[d].push({ x: R, y: M, z: x });
|
|
188
207
|
});
|
|
189
208
|
}), {
|
|
190
209
|
coordinatesList: u
|
|
191
210
|
};
|
|
192
211
|
}
|
|
193
212
|
async processBodyTracking() {
|
|
194
|
-
if (this.disposed || !this.landmarker)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
213
|
+
if (!(this.disposed || this.paused || !this.landmarker)) {
|
|
214
|
+
if (this.shouldRunInference()) {
|
|
215
|
+
const e = await this.getBodyData();
|
|
216
|
+
e && (this.coordinates = e.coordinatesList);
|
|
217
|
+
}
|
|
218
|
+
this.disposed || this.paused || (this.rafId = requestAnimationFrame(this.processBodyTracking.bind(this)));
|
|
219
|
+
}
|
|
198
220
|
}
|
|
199
221
|
resume() {
|
|
200
222
|
this.paused && (super.resume(), this.processBodyTracking());
|
|
@@ -214,22 +236,22 @@ class _e extends N {
|
|
|
214
236
|
return this.coordinates[e];
|
|
215
237
|
}
|
|
216
238
|
async initialize(e) {
|
|
217
|
-
const t = await
|
|
218
|
-
new URL("/assets/xr/wasm",
|
|
219
|
-
),
|
|
220
|
-
new URL("/assets/xr/models/body_tracking.task",
|
|
239
|
+
const t = await V.forVisionTasks(
|
|
240
|
+
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
241
|
+
), a = await K(
|
|
242
|
+
new URL("/assets/xr/models/body_tracking.task", I.assetStorageEndpoint).toString()
|
|
221
243
|
);
|
|
222
|
-
this.landmarker = await
|
|
244
|
+
this.landmarker = await De.createFromOptions(t, {
|
|
223
245
|
baseOptions: {
|
|
224
|
-
modelAssetBuffer:
|
|
246
|
+
modelAssetBuffer: a,
|
|
225
247
|
delegate: "GPU"
|
|
226
248
|
},
|
|
227
249
|
runningMode: "VIDEO",
|
|
228
250
|
numPoses: (e == null ? void 0 : e.numPoses) || 1
|
|
229
251
|
});
|
|
230
252
|
}
|
|
231
|
-
async run({ sourceCanvas: e }) {
|
|
232
|
-
this.sourceCanvas = e, this.rafId === null && await this.processBodyTracking();
|
|
253
|
+
async run({ sourceCanvas: e, targetFps: t }) {
|
|
254
|
+
this.sourceCanvas = e, this.setTargetFps(t), this.rafId === null && await this.processBodyTracking();
|
|
233
255
|
}
|
|
234
256
|
getModelNode() {
|
|
235
257
|
return {
|
|
@@ -243,8 +265,8 @@ class _e extends N {
|
|
|
243
265
|
};
|
|
244
266
|
}
|
|
245
267
|
}
|
|
246
|
-
const
|
|
247
|
-
class
|
|
268
|
+
const Ye = 0.11, Qe = 4e-3, $e = (i, s) => s.set(i.x, -i.y, i.z);
|
|
269
|
+
class Ze extends N {
|
|
248
270
|
constructor() {
|
|
249
271
|
super();
|
|
250
272
|
h(this, "landmarker", null);
|
|
@@ -269,9 +291,9 @@ class Ue extends N {
|
|
|
269
291
|
h(this, "landmarkScratch", { x: 0, y: 0, z: 0, visibility: 0 });
|
|
270
292
|
// Reused per-frame rotation scratch (matrix -> quaternion -> mirror -> euler),
|
|
271
293
|
// allocated once to avoid per-frame churn at 30+ fps.
|
|
272
|
-
h(this, "rotMatrixScratch", new
|
|
273
|
-
h(this, "rotQuatScratch", new
|
|
274
|
-
h(this, "rotEulerScratch", new
|
|
294
|
+
h(this, "rotMatrixScratch", new E.Matrix4());
|
|
295
|
+
h(this, "rotQuatScratch", new E.Quaternion());
|
|
296
|
+
h(this, "rotEulerScratch", new E.Euler());
|
|
275
297
|
}
|
|
276
298
|
// For non-webcam sources MediaPipe landmarks read as mirrored; flip x in
|
|
277
299
|
// place into the reused scratch so downstream unprojection sees the
|
|
@@ -281,7 +303,7 @@ class Ue extends N {
|
|
|
281
303
|
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;
|
|
282
304
|
}
|
|
283
305
|
extractAndUpdateFaceData(e) {
|
|
284
|
-
var
|
|
306
|
+
var a;
|
|
285
307
|
if (!e.faceLandmarks.length) {
|
|
286
308
|
this.faces = [];
|
|
287
309
|
return;
|
|
@@ -290,46 +312,42 @@ class Ue extends N {
|
|
|
290
312
|
for (this.faces.length > t && (this.faces.length = t, this.leftCheekScratch.length = t, this.rightCheekScratch.length = t); this.faces.length < t; )
|
|
291
313
|
this.faces.push({
|
|
292
314
|
transform: {
|
|
293
|
-
position: new
|
|
294
|
-
rotation: new
|
|
295
|
-
scale: new
|
|
315
|
+
position: new E.Vector3(),
|
|
316
|
+
rotation: new E.Vector3(),
|
|
317
|
+
scale: new E.Vector3()
|
|
296
318
|
},
|
|
297
319
|
gestures: {}
|
|
298
|
-
}), this.leftCheekScratch.push(new
|
|
299
|
-
for (let
|
|
300
|
-
if (!this.cameras[
|
|
320
|
+
}), this.leftCheekScratch.push(new E.Vector3()), this.rightCheekScratch.push(new E.Vector3());
|
|
321
|
+
for (let r = 0; r < t; r += 1) {
|
|
322
|
+
if (!this.cameras[r])
|
|
301
323
|
continue;
|
|
302
|
-
const
|
|
303
|
-
this.rotMatrixScratch.fromArray(
|
|
324
|
+
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];
|
|
325
|
+
this.rotMatrixScratch.fromArray(S.data), this.rotQuatScratch.setFromRotationMatrix(this.rotMatrixScratch), this.rotQuatScratch.set(
|
|
304
326
|
-this.rotQuatScratch.x,
|
|
305
327
|
this.rotQuatScratch.y,
|
|
306
328
|
this.rotQuatScratch.z,
|
|
307
329
|
this.rotQuatScratch.w
|
|
308
|
-
), this.rotEulerScratch.setFromQuaternion(this.rotQuatScratch, "XYZ"),
|
|
309
|
-
-this.rotEulerScratch.x,
|
|
310
|
-
this.rotEulerScratch.y,
|
|
311
|
-
this.rotEulerScratch.z
|
|
312
|
-
), V(
|
|
330
|
+
), this.rotEulerScratch.setFromQuaternion(this.rotQuatScratch, "XYZ"), $e(this.rotEulerScratch, o.transform.rotation), H(
|
|
313
331
|
this.landmarkForSource(d[4], m),
|
|
314
|
-
this.cameras[
|
|
315
|
-
|
|
316
|
-
),
|
|
332
|
+
this.cameras[r],
|
|
333
|
+
o.transform.position
|
|
334
|
+
), H(
|
|
317
335
|
this.landmarkForSource(d[50], m),
|
|
318
|
-
this.cameras[
|
|
319
|
-
this.leftCheekScratch[
|
|
320
|
-
),
|
|
336
|
+
this.cameras[r],
|
|
337
|
+
this.leftCheekScratch[r]
|
|
338
|
+
), H(
|
|
321
339
|
this.landmarkForSource(d[280], m),
|
|
322
|
-
this.cameras[
|
|
323
|
-
this.rightCheekScratch[
|
|
340
|
+
this.cameras[r],
|
|
341
|
+
this.rightCheekScratch[r]
|
|
324
342
|
);
|
|
325
|
-
const
|
|
326
|
-
isNaN(
|
|
327
|
-
|
|
343
|
+
const M = this.leftCheekScratch[r].distanceTo(this.rightCheekScratch[r]) * Ye, x = Math.abs(E.MathUtils.radToDeg(this.rotEulerScratch.y)), g = M + x * Qe, f = o.transform.scale.x, w = Ke(
|
|
344
|
+
isNaN(f) ? 0 : f,
|
|
345
|
+
g
|
|
328
346
|
);
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
for (const
|
|
332
|
-
|
|
347
|
+
o.transform.scale.set(w, w, w);
|
|
348
|
+
const p = o.gestures, k = e.faceBlendshapes[r].categories;
|
|
349
|
+
for (const C of k)
|
|
350
|
+
p[C.categoryName] = C.score;
|
|
333
351
|
}
|
|
334
352
|
}
|
|
335
353
|
async processFaceTracking() {
|
|
@@ -339,18 +357,30 @@ class Ue extends N {
|
|
|
339
357
|
this.rafId = requestAnimationFrame(this.processFaceTracking.bind(this));
|
|
340
358
|
return;
|
|
341
359
|
}
|
|
342
|
-
const e =
|
|
343
|
-
(!this.analysisCanvas || this.analysisCanvas.width !==
|
|
360
|
+
const e = Je(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));
|
|
361
|
+
(!this.analysisCanvas || this.analysisCanvas.width !== o || this.analysisCanvas.height !== u) && (this.analysisCanvas = new OffscreenCanvas(o, u));
|
|
344
362
|
const m = this.analysisCanvas.getContext("2d");
|
|
345
|
-
if (!m)
|
|
363
|
+
if (!m) {
|
|
364
|
+
this.rafId = requestAnimationFrame(this.processFaceTracking.bind(this));
|
|
346
365
|
return;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
366
|
+
}
|
|
367
|
+
m.setTransform(1, 0, 0, 1, 0, 0), m.clearRect(0, 0, o, u), m.drawImage(this.sourceCanvas, 0, 0, o, u);
|
|
368
|
+
const d = performance.now(), S = this.landmarker.detectForVideo(this.analysisCanvas, d), R = performance.now();
|
|
369
|
+
this.processingTime = R - d, this.detectionResults = S, this.extractAndUpdateFaceData(S), !(this.disposed || this.paused) && (this.rafId = requestAnimationFrame(this.processFaceTracking.bind(this)));
|
|
350
370
|
}
|
|
351
371
|
resume() {
|
|
352
372
|
this.paused && (super.resume(), this.processFaceTracking());
|
|
353
373
|
}
|
|
374
|
+
dispose() {
|
|
375
|
+
if (super.dispose(), this.landmarker) {
|
|
376
|
+
try {
|
|
377
|
+
this.landmarker.close();
|
|
378
|
+
} catch {
|
|
379
|
+
}
|
|
380
|
+
this.landmarker = null;
|
|
381
|
+
}
|
|
382
|
+
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 = [];
|
|
383
|
+
}
|
|
354
384
|
getFace(e = 0) {
|
|
355
385
|
return this.faces[e];
|
|
356
386
|
}
|
|
@@ -358,23 +388,23 @@ class Ue extends N {
|
|
|
358
388
|
return this.detectionResults;
|
|
359
389
|
}
|
|
360
390
|
getRawFaceTrackingData(e = 0) {
|
|
361
|
-
var t,
|
|
391
|
+
var t, a, r, o;
|
|
362
392
|
if (this.detectionResults)
|
|
363
393
|
return {
|
|
364
394
|
landmarks: (t = this.detectionResults.faceLandmarks) == null ? void 0 : t[e],
|
|
365
|
-
blendshapes: (
|
|
366
|
-
transformationMatrix: (
|
|
395
|
+
blendshapes: (r = (a = this.detectionResults.faceBlendshapes) == null ? void 0 : a[e]) == null ? void 0 : r.categories,
|
|
396
|
+
transformationMatrix: (o = this.detectionResults.facialTransformationMatrixes) == null ? void 0 : o[e]
|
|
367
397
|
};
|
|
368
398
|
}
|
|
369
399
|
async initialize(e) {
|
|
370
400
|
this.numFaces = (e == null ? void 0 : e.numFaces) || 1;
|
|
371
|
-
const t = await
|
|
372
|
-
new URL("/assets/xr/wasm",
|
|
373
|
-
),
|
|
374
|
-
new URL("/assets/xr/models/face_tracking.task",
|
|
375
|
-
),
|
|
401
|
+
const t = await V.forVisionTasks(
|
|
402
|
+
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
403
|
+
), a = await K(
|
|
404
|
+
new URL("/assets/xr/models/face_tracking.task", I.assetStorageEndpoint).toString()
|
|
405
|
+
), r = await _e.createFromOptions(t, {
|
|
376
406
|
baseOptions: {
|
|
377
|
-
modelAssetBuffer:
|
|
407
|
+
modelAssetBuffer: a,
|
|
378
408
|
delegate: "GPU"
|
|
379
409
|
},
|
|
380
410
|
// Keep detection permissive for calibration workflows with dark webcam input.
|
|
@@ -386,25 +416,28 @@ class Ue extends N {
|
|
|
386
416
|
runningMode: "VIDEO",
|
|
387
417
|
numFaces: this.numFaces
|
|
388
418
|
});
|
|
389
|
-
this.
|
|
419
|
+
if (this.disposed) {
|
|
420
|
+
r.close();
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
this.landmarker = r;
|
|
390
424
|
}
|
|
391
|
-
async run({ sourceCanvas: e, getSource: t, targetFps:
|
|
392
|
-
this.sourceCanvas = e, this.getSource = t, this.setTargetFps(
|
|
425
|
+
async run({ sourceCanvas: e, getSource: t, targetFps: a }) {
|
|
426
|
+
this.sourceCanvas = e, this.getSource = t, this.setTargetFps(a), this.analysisCanvas = void 0, this.rafId === null && this.processFaceTracking();
|
|
393
427
|
}
|
|
394
428
|
getModelNode() {
|
|
395
|
-
const e = this
|
|
429
|
+
const e = this;
|
|
430
|
+
return {
|
|
396
431
|
get detectionResults() {
|
|
397
432
|
return e.detectionResults;
|
|
398
433
|
},
|
|
399
434
|
getDetectionResults: this.getDetectionResults.bind(this),
|
|
400
435
|
getFace: this.getFace.bind(this),
|
|
401
|
-
getRawFaceTrackingData: this.getRawFaceTrackingData.bind(this)
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
_setCamera: (n, o) => {
|
|
405
|
-
this.cameras[o] = n;
|
|
436
|
+
getRawFaceTrackingData: this.getRawFaceTrackingData.bind(this),
|
|
437
|
+
setCamera: (a, r = 0) => {
|
|
438
|
+
this.cameras[r] = a;
|
|
406
439
|
}
|
|
407
|
-
}
|
|
440
|
+
};
|
|
408
441
|
}
|
|
409
442
|
async getPerformanceData() {
|
|
410
443
|
return {
|
|
@@ -413,19 +446,19 @@ class Ue extends N {
|
|
|
413
446
|
};
|
|
414
447
|
}
|
|
415
448
|
}
|
|
416
|
-
const
|
|
417
|
-
var
|
|
418
|
-
const
|
|
419
|
-
Closed_Fist:
|
|
420
|
-
Open_Palm:
|
|
421
|
-
Pointing_Up:
|
|
422
|
-
Thumb_Down:
|
|
423
|
-
Thumb_Up:
|
|
424
|
-
Victory:
|
|
425
|
-
ILoveYou:
|
|
426
|
-
None:
|
|
427
|
-
},
|
|
428
|
-
class
|
|
449
|
+
const Je = (i) => i > 1 ? 1024 : 512;
|
|
450
|
+
var D = /* @__PURE__ */ ((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))(D || {});
|
|
451
|
+
const et = 512, tt = {
|
|
452
|
+
Closed_Fist: D.ClosedFist,
|
|
453
|
+
Open_Palm: D.OpenPalm,
|
|
454
|
+
Pointing_Up: D.PointingUp,
|
|
455
|
+
Thumb_Down: D.ThumbDown,
|
|
456
|
+
Thumb_Up: D.ThumbUp,
|
|
457
|
+
Victory: D.Victory,
|
|
458
|
+
ILoveYou: D.ILoveYou,
|
|
459
|
+
None: D.None
|
|
460
|
+
}, st = 15;
|
|
461
|
+
class it extends N {
|
|
429
462
|
constructor() {
|
|
430
463
|
super();
|
|
431
464
|
h(this, "landmarker", null);
|
|
@@ -433,25 +466,25 @@ class Be extends N {
|
|
|
433
466
|
h(this, "coordinates");
|
|
434
467
|
h(this, "gesture");
|
|
435
468
|
h(this, "sourceCanvas");
|
|
436
|
-
h(this, "downscaler", new
|
|
469
|
+
h(this, "downscaler", new Z(et));
|
|
437
470
|
}
|
|
438
471
|
async getGestureData() {
|
|
439
472
|
if (!this.landmarker || !this.sourceCanvas)
|
|
440
473
|
return;
|
|
441
|
-
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(),
|
|
442
|
-
this.processingTime =
|
|
443
|
-
const
|
|
444
|
-
if (
|
|
445
|
-
const m =
|
|
446
|
-
return
|
|
474
|
+
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(), a = this.landmarker.recognizeForVideo(e, t), r = performance.now();
|
|
475
|
+
this.processingTime = r - t;
|
|
476
|
+
const o = a.landmarks[0], u = [];
|
|
477
|
+
if (o) {
|
|
478
|
+
const m = a.gestures[0][0].categoryName;
|
|
479
|
+
return o.forEach((d) => {
|
|
447
480
|
u.push({
|
|
448
|
-
x:
|
|
449
|
-
y:
|
|
481
|
+
x: O(d.x),
|
|
482
|
+
y: O(1 - d.y),
|
|
450
483
|
z: -d.z
|
|
451
484
|
});
|
|
452
485
|
}), {
|
|
453
486
|
coordinates: u,
|
|
454
|
-
gesture:
|
|
487
|
+
gesture: tt[m]
|
|
455
488
|
};
|
|
456
489
|
}
|
|
457
490
|
return { coordinates: void 0, gesture: void 0 };
|
|
@@ -479,11 +512,11 @@ class Be extends N {
|
|
|
479
512
|
this.sourceCanvas = void 0, this.downscaler.dispose(), this.coordinates = void 0, this.gesture = void 0;
|
|
480
513
|
}
|
|
481
514
|
async initialize() {
|
|
482
|
-
const e = await
|
|
483
|
-
new URL("/assets/xr/wasm",
|
|
484
|
-
), t = await
|
|
485
|
-
new URL("/assets/xr/models/gesture_tracking.task",
|
|
486
|
-
),
|
|
515
|
+
const e = await V.forVisionTasks(
|
|
516
|
+
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
517
|
+
), t = await K(
|
|
518
|
+
new URL("/assets/xr/models/gesture_tracking.task", I.assetStorageEndpoint).toString()
|
|
519
|
+
), a = await Pe.createFromOptions(e, {
|
|
487
520
|
baseOptions: {
|
|
488
521
|
modelAssetBuffer: t,
|
|
489
522
|
delegate: "GPU"
|
|
@@ -491,10 +524,10 @@ class Be extends N {
|
|
|
491
524
|
runningMode: "VIDEO",
|
|
492
525
|
numHands: 1
|
|
493
526
|
});
|
|
494
|
-
this.landmarker =
|
|
527
|
+
this.landmarker = a;
|
|
495
528
|
}
|
|
496
529
|
async run({ sourceCanvas: e, targetFps: t }) {
|
|
497
|
-
this.sourceCanvas = e, this.setTargetFps(t ??
|
|
530
|
+
this.sourceCanvas = e, this.setTargetFps(t ?? st), this.rafId === null && await this.processGestureTracking();
|
|
498
531
|
}
|
|
499
532
|
getModelNode() {
|
|
500
533
|
const e = this;
|
|
@@ -514,8 +547,8 @@ class Be extends N {
|
|
|
514
547
|
};
|
|
515
548
|
}
|
|
516
549
|
}
|
|
517
|
-
const
|
|
518
|
-
class
|
|
550
|
+
const nt = 512;
|
|
551
|
+
class at extends N {
|
|
519
552
|
constructor() {
|
|
520
553
|
super();
|
|
521
554
|
h(this, "landmarker", null);
|
|
@@ -525,34 +558,34 @@ class qe extends N {
|
|
|
525
558
|
h(this, "gesture");
|
|
526
559
|
h(this, "handedness");
|
|
527
560
|
h(this, "sourceCanvas");
|
|
528
|
-
h(this, "downscaler", new
|
|
561
|
+
h(this, "downscaler", new Z(nt));
|
|
529
562
|
}
|
|
530
563
|
async getHandData() {
|
|
531
564
|
if (!this.landmarker || !this.sourceCanvas)
|
|
532
565
|
return;
|
|
533
|
-
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(),
|
|
534
|
-
this.processingTime =
|
|
535
|
-
const
|
|
536
|
-
if (
|
|
537
|
-
var
|
|
566
|
+
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(), a = this.landmarker.detectForVideo(e, t), r = performance.now();
|
|
567
|
+
this.processingTime = r - t;
|
|
568
|
+
const o = [], u = a.handedness ?? a.handednesses ?? [];
|
|
569
|
+
if (a.landmarks.forEach((d, S) => {
|
|
570
|
+
var f, w, p;
|
|
538
571
|
if (!d || d.length === 0)
|
|
539
572
|
return;
|
|
540
|
-
const
|
|
541
|
-
x:
|
|
542
|
-
y:
|
|
543
|
-
z: -
|
|
544
|
-
})),
|
|
545
|
-
|
|
546
|
-
}), !
|
|
573
|
+
const R = d.map((k) => ({
|
|
574
|
+
x: O(k.x),
|
|
575
|
+
y: O(1 - k.y),
|
|
576
|
+
z: -k.z
|
|
577
|
+
})), M = (p = (w = (f = u[S]) == null ? void 0 : f[0]) == null ? void 0 : w.categoryName) == null ? void 0 : p.toLowerCase(), x = M === "left" || M === "right" ? M : void 0, g = d[0].z < 0 ? "closed_fist" : "open_palm";
|
|
578
|
+
o.push({ coordinates: R, gesture: g, handedness: x });
|
|
579
|
+
}), !o.length)
|
|
547
580
|
return {
|
|
548
581
|
hands: void 0,
|
|
549
582
|
coordinates: void 0,
|
|
550
583
|
gesture: void 0,
|
|
551
584
|
handedness: void 0
|
|
552
585
|
};
|
|
553
|
-
const m =
|
|
586
|
+
const m = o[0];
|
|
554
587
|
return {
|
|
555
|
-
hands:
|
|
588
|
+
hands: o,
|
|
556
589
|
coordinates: m.coordinates,
|
|
557
590
|
gesture: m.gesture,
|
|
558
591
|
handedness: m.handedness
|
|
@@ -581,11 +614,11 @@ class qe extends N {
|
|
|
581
614
|
this.sourceCanvas = void 0, this.hands = void 0, this.downscaler.dispose(), this.coordinates = void 0, this.gesture = void 0, this.handedness = void 0;
|
|
582
615
|
}
|
|
583
616
|
async initialize() {
|
|
584
|
-
const e = await
|
|
585
|
-
new URL("/assets/xr/wasm",
|
|
586
|
-
), t = await
|
|
587
|
-
new URL("/assets/xr/models/hand_tracking.task",
|
|
588
|
-
),
|
|
617
|
+
const e = await V.forVisionTasks(
|
|
618
|
+
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
619
|
+
), t = await K(
|
|
620
|
+
new URL("/assets/xr/models/hand_tracking.task", I.assetStorageEndpoint).toString()
|
|
621
|
+
), a = await Oe.createFromOptions(e, {
|
|
589
622
|
baseOptions: {
|
|
590
623
|
modelAssetBuffer: t,
|
|
591
624
|
delegate: "GPU"
|
|
@@ -593,7 +626,7 @@ class qe extends N {
|
|
|
593
626
|
runningMode: "VIDEO",
|
|
594
627
|
numHands: 2
|
|
595
628
|
});
|
|
596
|
-
this.landmarker =
|
|
629
|
+
this.landmarker = a;
|
|
597
630
|
}
|
|
598
631
|
async run({ sourceCanvas: e, targetFps: t }) {
|
|
599
632
|
this.sourceCanvas = e, this.setTargetFps(t), this.rafId === null && await this.processHandTracking();
|
|
@@ -622,13 +655,13 @@ class qe extends N {
|
|
|
622
655
|
};
|
|
623
656
|
}
|
|
624
657
|
}
|
|
625
|
-
const
|
|
658
|
+
const rt = 24, ot = 720, ct = [
|
|
626
659
|
[255, 255, 255, 255],
|
|
627
660
|
// 0: background → green 255, kept
|
|
628
661
|
[0, 0, 0, 0]
|
|
629
662
|
// 1: person → green 0, discarded
|
|
630
663
|
];
|
|
631
|
-
class
|
|
664
|
+
class ht extends N {
|
|
632
665
|
constructor() {
|
|
633
666
|
super();
|
|
634
667
|
h(this, "segmenter", null);
|
|
@@ -700,8 +733,8 @@ class Xe extends N {
|
|
|
700
733
|
return e.videoWidth > 0 ? { width: e.videoWidth, height: e.videoHeight } : void 0;
|
|
701
734
|
if (e instanceof HTMLImageElement)
|
|
702
735
|
return e.naturalWidth > 0 ? { width: e.naturalWidth, height: e.naturalHeight } : void 0;
|
|
703
|
-
const t = e.width,
|
|
704
|
-
return typeof t == "number" && t > 0 && typeof
|
|
736
|
+
const t = e.width, a = e.height;
|
|
737
|
+
return typeof t == "number" && t > 0 && typeof a == "number" && a > 0 ? { width: t, height: a } : void 0;
|
|
705
738
|
}
|
|
706
739
|
/**
|
|
707
740
|
* Size the process canvas to the override input's aspect ratio, bounded by
|
|
@@ -714,8 +747,8 @@ class Xe extends N {
|
|
|
714
747
|
const e = this.readIntrinsicSize(this.inputSource);
|
|
715
748
|
if (!e) return;
|
|
716
749
|
this.inputSourceSize = e;
|
|
717
|
-
const t = Math.min(1,
|
|
718
|
-
this.processCanvas.width ===
|
|
750
|
+
const t = Math.min(1, ot / Math.max(e.width, e.height)), a = Math.max(1, Math.round(e.width * t)), r = Math.max(1, Math.round(e.height * t));
|
|
751
|
+
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);
|
|
719
752
|
}
|
|
720
753
|
async processSegmentation() {
|
|
721
754
|
if (this.disposed || !this.isProcessing || !this.maskCanvas || !this.processCanvas)
|
|
@@ -733,32 +766,32 @@ class Xe extends N {
|
|
|
733
766
|
}
|
|
734
767
|
const t = performance.now();
|
|
735
768
|
this.ensureProcessCanvasForInput();
|
|
736
|
-
const
|
|
737
|
-
if (
|
|
769
|
+
const a = this.processCanvas.getContext("2d");
|
|
770
|
+
if (a) {
|
|
738
771
|
const u = this.processCanvas.width, m = this.processCanvas.height;
|
|
739
|
-
if (
|
|
740
|
-
const { width: d, height:
|
|
741
|
-
|
|
772
|
+
if (a.clearRect(0, 0, u, m), this.inputSource && this.inputSourceSize) {
|
|
773
|
+
const { width: d, height: S } = this.inputSourceSize, R = Math.min(u / d, m / S), M = d * R, x = S * R;
|
|
774
|
+
a.drawImage(this.inputSource, (u - M) / 2, (m - x) / 2, M, x);
|
|
742
775
|
} else
|
|
743
|
-
|
|
776
|
+
a.drawImage(e, 0, 0, u, m);
|
|
744
777
|
}
|
|
745
|
-
const
|
|
778
|
+
const o = this.segmenter.segmentForVideo(
|
|
746
779
|
this.processCanvas,
|
|
747
780
|
performance.now()
|
|
748
781
|
).categoryMask;
|
|
749
|
-
if (!
|
|
782
|
+
if (!o) {
|
|
750
783
|
if (this.disposed || this.paused) return;
|
|
751
784
|
this.rafId = requestAnimationFrame(this.processSegmentation.bind(this));
|
|
752
785
|
return;
|
|
753
786
|
}
|
|
754
787
|
if (this.rawCache = null, this.latestMask && (this.latestMask.close(), this.latestMask = null), this.useGpuMaskPath && this.drawingUtils && this.glCanvas)
|
|
755
|
-
this.drawingUtils.drawCategoryMask(
|
|
788
|
+
this.drawingUtils.drawCategoryMask(o, ct), this.latestMask = o.clone(), o.close(), this.blitGlToMask();
|
|
756
789
|
else {
|
|
757
|
-
this.latestMask =
|
|
758
|
-
const u = this.readMaskToImageData(
|
|
759
|
-
|
|
790
|
+
this.latestMask = o.clone();
|
|
791
|
+
const u = this.readMaskToImageData(o);
|
|
792
|
+
o.close(), u && this.blitImageDataToMask(u);
|
|
760
793
|
}
|
|
761
|
-
this.segmentationMaskTexture && (this.isMaskSetup || (this.segmentationMaskTexture.format =
|
|
794
|
+
this.segmentationMaskTexture && (this.isMaskSetup || (this.segmentationMaskTexture.format = de, this.segmentationMaskTexture.minFilter = q, this.segmentationMaskTexture.magFilter = q, 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)));
|
|
762
795
|
}
|
|
763
796
|
/**
|
|
764
797
|
* Blit the GPU-rendered mask (already RGBA-inverted by drawCategoryMask)
|
|
@@ -778,13 +811,13 @@ class Xe extends N {
|
|
|
778
811
|
* background→opaque convention (green carries the signal for the alphaMap).
|
|
779
812
|
*/
|
|
780
813
|
readMaskToImageData(e) {
|
|
781
|
-
const t = e.getAsUint8Array(), { width:
|
|
782
|
-
if (!t ||
|
|
783
|
-
(!this.maskImageData || this.maskImageData.width !==
|
|
784
|
-
const
|
|
814
|
+
const t = e.getAsUint8Array(), { width: a, height: r } = e;
|
|
815
|
+
if (!t || a <= 0 || r <= 0) return null;
|
|
816
|
+
(!this.maskImageData || this.maskImageData.width !== a || this.maskImageData.height !== r) && (this.maskImageData = new ImageData(a, r));
|
|
817
|
+
const o = this.maskImageData.data;
|
|
785
818
|
for (let u = 0; u < t.length; u += 1) {
|
|
786
819
|
const m = t[u] === 255 ? 0 : 255;
|
|
787
|
-
|
|
820
|
+
o[u * 4] = 255, o[u * 4 + 1] = m, o[u * 4 + 2] = 255, o[u * 4 + 3] = m;
|
|
788
821
|
}
|
|
789
822
|
return this.maskImageData;
|
|
790
823
|
}
|
|
@@ -795,10 +828,10 @@ class Xe extends N {
|
|
|
795
828
|
*/
|
|
796
829
|
blitImageDataToMask(e) {
|
|
797
830
|
if (!this.maskCanvas || !this.filterCanvas) return;
|
|
798
|
-
const t = this.maskCanvas.getContext("2d"),
|
|
799
|
-
if (!t || !
|
|
800
|
-
const
|
|
801
|
-
|
|
831
|
+
const t = this.maskCanvas.getContext("2d"), a = this.filterCanvas.getContext("2d");
|
|
832
|
+
if (!t || !a) return;
|
|
833
|
+
const r = this.getStagingCanvas(e.width, e.height), o = r.getContext("2d");
|
|
834
|
+
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));
|
|
802
835
|
}
|
|
803
836
|
getStagingCanvas(e, t) {
|
|
804
837
|
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;
|
|
@@ -825,37 +858,38 @@ class Xe extends N {
|
|
|
825
858
|
}
|
|
826
859
|
async initialize(e) {
|
|
827
860
|
this.quality = (e == null ? void 0 : e.quality) ?? "low";
|
|
828
|
-
const t = await
|
|
829
|
-
new URL("/assets/xr/wasm",
|
|
830
|
-
),
|
|
831
|
-
new URL("/assets/xr/models/segmentation.tflite",
|
|
861
|
+
const t = await V.forVisionTasks(
|
|
862
|
+
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
863
|
+
), a = await K(
|
|
864
|
+
new URL("/assets/xr/models/segmentation.tflite", I.assetStorageEndpoint).toString()
|
|
832
865
|
);
|
|
833
866
|
this.glCanvas = new OffscreenCanvas(1, 1);
|
|
834
|
-
const
|
|
867
|
+
const r = this.glCanvas.getContext("webgl2", {
|
|
835
868
|
preserveDrawingBuffer: !0
|
|
836
869
|
});
|
|
837
|
-
this.segmenter = await
|
|
870
|
+
this.segmenter = await Ue.createFromOptions(t, {
|
|
838
871
|
baseOptions: {
|
|
839
|
-
modelAssetBuffer:
|
|
872
|
+
modelAssetBuffer: a,
|
|
840
873
|
delegate: "GPU"
|
|
841
874
|
},
|
|
842
|
-
...
|
|
875
|
+
...r ? { canvas: this.glCanvas } : {},
|
|
843
876
|
outputCategoryMask: !0,
|
|
844
877
|
outputConfidenceMasks: !1,
|
|
845
878
|
runningMode: "VIDEO"
|
|
846
|
-
}),
|
|
879
|
+
}), r ? (this.drawingUtils = new ze(r), this.useGpuMaskPath = !0) : this.useGpuMaskPath = !1;
|
|
847
880
|
}
|
|
848
881
|
async run({
|
|
849
882
|
sourceCanvas: e,
|
|
850
883
|
renderWidth: t,
|
|
851
|
-
renderHeight:
|
|
852
|
-
targetFps:
|
|
884
|
+
renderHeight: a,
|
|
885
|
+
targetFps: r
|
|
853
886
|
}) {
|
|
887
|
+
var u;
|
|
854
888
|
if (!e)
|
|
855
889
|
return;
|
|
856
|
-
this.setTargetFps(
|
|
857
|
-
const
|
|
858
|
-
this.sourceCanvas = e, this.processCanvas = document.createElement("canvas"), this.processCanvas.width = e.width *
|
|
890
|
+
this.setTargetFps(r ?? rt), this.isProcessing = !1, this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
891
|
+
const o = this.getQualityScaleFactor();
|
|
892
|
+
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 ue(this.maskCanvas), this.isMaskSetup = !1, this.rawCache = null, this.isProcessing = !0, this.lastInferenceMs = 0, this.rafId = requestAnimationFrame(this.processSegmentation.bind(this));
|
|
859
893
|
}
|
|
860
894
|
/**
|
|
861
895
|
* Lazily read the single-channel mask back to a Uint8Array. Only invoked when
|
|
@@ -890,92 +924,104 @@ class Xe extends N {
|
|
|
890
924
|
};
|
|
891
925
|
}
|
|
892
926
|
}
|
|
893
|
-
const
|
|
894
|
-
[
|
|
895
|
-
[
|
|
896
|
-
[
|
|
897
|
-
[
|
|
898
|
-
[
|
|
899
|
-
},
|
|
927
|
+
const re = {
|
|
928
|
+
[z.BACKGROUND_SEGMENTATION]: ht,
|
|
929
|
+
[z.HAND_TRACKER]: at,
|
|
930
|
+
[z.GESTURE_TRACKER]: it,
|
|
931
|
+
[z.FACE_TRACKER]: Ze,
|
|
932
|
+
[z.BODY_TRACKER]: je
|
|
933
|
+
}, dt = async (i) => {
|
|
900
934
|
const s = document.createElement("video");
|
|
901
|
-
s.srcObject =
|
|
935
|
+
s.srcObject = i, s.muted = !0, s.playsInline = !0, s.autoplay = !0, await new Promise((t) => {
|
|
902
936
|
s.onloadedmetadata = () => {
|
|
903
937
|
s.play(), t();
|
|
904
938
|
};
|
|
905
939
|
});
|
|
906
940
|
const e = s;
|
|
907
941
|
return await new Promise((t) => {
|
|
908
|
-
const
|
|
909
|
-
clearTimeout(
|
|
942
|
+
const a = setTimeout(t, 150), r = () => {
|
|
943
|
+
clearTimeout(a), t();
|
|
910
944
|
};
|
|
911
|
-
typeof e.requestVideoFrameCallback == "function" ? e.requestVideoFrameCallback(
|
|
945
|
+
typeof e.requestVideoFrameCallback == "function" ? e.requestVideoFrameCallback(r) : requestAnimationFrame(() => requestAnimationFrame(() => r()));
|
|
912
946
|
}), s;
|
|
913
|
-
},
|
|
914
|
-
const s = new
|
|
915
|
-
return s.colorSpace =
|
|
916
|
-
},
|
|
917
|
-
const e =
|
|
947
|
+
}, ut = (i) => {
|
|
948
|
+
const s = new ue(i);
|
|
949
|
+
return s.colorSpace = Le, s.format = de, s.minFilter = q, s.magFilter = q, s.generateMipmaps = !1, s.needsUpdate = !0, s;
|
|
950
|
+
}, lt = (i, s) => {
|
|
951
|
+
const e = i.videoWidth, t = i.videoHeight;
|
|
918
952
|
e > 0 && t > 0 && (s.width !== e && (s.width = e), s.height !== t && (s.height = t));
|
|
919
|
-
const
|
|
953
|
+
const a = s.getContext("2d", {
|
|
920
954
|
colorSpace: "srgb"
|
|
921
955
|
});
|
|
922
|
-
|
|
923
|
-
},
|
|
956
|
+
a.save(), a.scale(-1, 1), a.drawImage(i, -s.width, 0, s.width, s.height), a.restore();
|
|
957
|
+
}, gt = (i, s, e = 1) => {
|
|
924
958
|
const t = s.getContext("2d", {
|
|
925
959
|
colorSpace: "srgb"
|
|
926
|
-
}),
|
|
927
|
-
let
|
|
928
|
-
|
|
960
|
+
}), a = s.width / s.height, r = i.width / i.height;
|
|
961
|
+
let o, u;
|
|
962
|
+
r > a ? (u = s.height, o = i.width * (s.height / i.height)) : (o = s.width, u = i.height * (s.width / i.width));
|
|
929
963
|
const m = Number.isFinite(e) && e > 0 ? e : 1;
|
|
930
|
-
|
|
931
|
-
const d = (s.width -
|
|
964
|
+
o *= m, u *= m;
|
|
965
|
+
const d = (s.width - o) / 2, S = (s.height - u) / 2;
|
|
932
966
|
t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, s.width, s.height), t.drawImage(
|
|
933
|
-
|
|
967
|
+
i,
|
|
934
968
|
0,
|
|
935
969
|
0,
|
|
936
|
-
|
|
937
|
-
|
|
970
|
+
i.width,
|
|
971
|
+
i.height,
|
|
938
972
|
d,
|
|
939
|
-
|
|
940
|
-
|
|
973
|
+
S,
|
|
974
|
+
o,
|
|
941
975
|
u
|
|
942
976
|
);
|
|
943
|
-
},
|
|
977
|
+
}, mt = (i, s, e) => {
|
|
944
978
|
const t = /* @__PURE__ */ new Map();
|
|
979
|
+
let a = !1;
|
|
980
|
+
const r = (g, f) => {
|
|
981
|
+
var w;
|
|
982
|
+
try {
|
|
983
|
+
(w = f.dispose) == null || w.call(f);
|
|
984
|
+
} catch (p) {
|
|
985
|
+
console.warn(`[xr-sdk registry] dispose threw for ${g}`, p);
|
|
986
|
+
}
|
|
987
|
+
};
|
|
945
988
|
return { acquire: async (g, f, w) => {
|
|
946
989
|
let p = t.get(g);
|
|
947
990
|
if (p)
|
|
948
991
|
return p.refs.add(f), p.activeRefs.add(f), p.initPromise;
|
|
949
|
-
const
|
|
950
|
-
if (!
|
|
992
|
+
const k = s[g];
|
|
993
|
+
if (!k)
|
|
951
994
|
throw new Error(`Invalid model: ${g}`);
|
|
952
|
-
const C = new
|
|
953
|
-
await C.initialize(w)
|
|
954
|
-
const
|
|
955
|
-
|
|
995
|
+
const C = new k(), L = /* @__PURE__ */ new Set([f]), U = /* @__PURE__ */ new Set([f]), _ = (async () => {
|
|
996
|
+
await C.initialize(w);
|
|
997
|
+
const B = t.get(g);
|
|
998
|
+
if (!B || B.model !== C || B.refs.size === 0)
|
|
999
|
+
return r(g, C), C;
|
|
1000
|
+
e && await e(g, C);
|
|
1001
|
+
const T = t.get(g);
|
|
1002
|
+
return T && T.refs.size > 0 && i.setPipeline((P) => P.set(g, C)), C;
|
|
956
1003
|
})();
|
|
957
|
-
return p = { model: C, refs:
|
|
958
|
-
t.get(g) === p && (t.delete(g),
|
|
959
|
-
}),
|
|
1004
|
+
return p = { model: C, refs: L, activeRefs: U, initPromise: _, options: w }, t.set(g, p), _.catch(() => {
|
|
1005
|
+
t.get(g) === p && (t.delete(g), i.setPipeline((T) => T.delete(g))), r(g, C);
|
|
1006
|
+
}), _;
|
|
960
1007
|
}, release: (g, f) => {
|
|
961
|
-
var S;
|
|
962
1008
|
const w = t.get(g);
|
|
963
|
-
|
|
964
|
-
t.delete(g);
|
|
965
|
-
const p = w.model;
|
|
966
|
-
try {
|
|
967
|
-
(S = p.dispose) == null || S.call(p);
|
|
968
|
-
} catch (C) {
|
|
969
|
-
console.warn(`[xr-sdk registry] dispose threw for ${g}`, C);
|
|
970
|
-
}
|
|
971
|
-
a.setPipeline((C) => C.delete(g));
|
|
1009
|
+
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), i.setPipeline((p) => p.delete(g))));
|
|
972
1010
|
}, setActive: (g, f, w) => {
|
|
973
1011
|
const p = t.get(g);
|
|
974
1012
|
if (!p || !p.refs.has(f)) return;
|
|
975
|
-
const
|
|
1013
|
+
const k = p.activeRefs.size > 0;
|
|
976
1014
|
w ? p.activeRefs.add(f) : p.activeRefs.delete(f);
|
|
977
1015
|
const C = p.activeRefs.size > 0;
|
|
978
|
-
|
|
1016
|
+
k !== C && (C && !a ? p.model.resume() : p.model.pause());
|
|
1017
|
+
}, suspendAll: () => {
|
|
1018
|
+
a = !0;
|
|
1019
|
+
for (const g of t.values())
|
|
1020
|
+
g.model.pause();
|
|
1021
|
+
}, resumeActive: () => {
|
|
1022
|
+
a = !1;
|
|
1023
|
+
for (const g of t.values())
|
|
1024
|
+
g.activeRefs.size > 0 && g.model.resume();
|
|
979
1025
|
}, get: (g) => {
|
|
980
1026
|
var f;
|
|
981
1027
|
return (f = t.get(g)) == null ? void 0 : f.model;
|
|
@@ -983,21 +1029,13 @@ const Z = {
|
|
|
983
1029
|
var f;
|
|
984
1030
|
return (f = t.get(g)) == null ? void 0 : f.options;
|
|
985
1031
|
}, releaseAll: () => {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
if (!w) continue;
|
|
990
|
-
w.refs.clear(), t.delete(f);
|
|
991
|
-
const p = w.model;
|
|
992
|
-
try {
|
|
993
|
-
(g = p.dispose) == null || g.call(p);
|
|
994
|
-
} catch (S) {
|
|
995
|
-
console.warn(`[xr-sdk registry] dispose threw for ${f}`, S);
|
|
996
|
-
}
|
|
1032
|
+
for (const g of Array.from(t.keys())) {
|
|
1033
|
+
const f = t.get(g);
|
|
1034
|
+
f && (f.refs.clear(), t.delete(g), r(g, f.model));
|
|
997
1035
|
}
|
|
998
|
-
|
|
1036
|
+
i.setPipeline((g) => g.clear());
|
|
999
1037
|
} };
|
|
1000
|
-
},
|
|
1038
|
+
}, ft = {
|
|
1001
1039
|
lifecycle: "idle",
|
|
1002
1040
|
ready: !1,
|
|
1003
1041
|
error: void 0,
|
|
@@ -1007,335 +1045,354 @@ const Z = {
|
|
|
1007
1045
|
source: void 0,
|
|
1008
1046
|
sourceKind: void 0,
|
|
1009
1047
|
pipeline: /* @__PURE__ */ new Map()
|
|
1010
|
-
},
|
|
1011
|
-
let
|
|
1048
|
+
}, pt = () => {
|
|
1049
|
+
let i = { ...ft, pipeline: /* @__PURE__ */ new Map() };
|
|
1012
1050
|
const s = /* @__PURE__ */ new Set(), e = () => {
|
|
1013
1051
|
s.forEach((t) => t());
|
|
1014
1052
|
};
|
|
1015
1053
|
return {
|
|
1016
|
-
getSnapshot: () =>
|
|
1054
|
+
getSnapshot: () => i,
|
|
1017
1055
|
set: (t) => {
|
|
1018
|
-
let
|
|
1019
|
-
for (const
|
|
1020
|
-
if (t[
|
|
1021
|
-
|
|
1056
|
+
let a = !1;
|
|
1057
|
+
for (const r of Object.keys(t))
|
|
1058
|
+
if (t[r] !== i[r]) {
|
|
1059
|
+
a = !0;
|
|
1022
1060
|
break;
|
|
1023
1061
|
}
|
|
1024
|
-
|
|
1062
|
+
a && (i = { ...i, ...t }, e());
|
|
1025
1063
|
},
|
|
1026
1064
|
setPipeline: (t) => {
|
|
1027
|
-
const
|
|
1028
|
-
return t(
|
|
1065
|
+
const a = new Map(i.pipeline);
|
|
1066
|
+
return t(a), i = { ...i, pipeline: a }, e(), a;
|
|
1029
1067
|
},
|
|
1030
1068
|
subscribe: (t) => (s.add(t), () => {
|
|
1031
1069
|
s.delete(t);
|
|
1032
1070
|
})
|
|
1033
1071
|
};
|
|
1034
|
-
},
|
|
1035
|
-
renderHeight:
|
|
1072
|
+
}, vt = ({
|
|
1073
|
+
renderHeight: i,
|
|
1036
1074
|
renderWidth: s,
|
|
1037
1075
|
videoHeight: e,
|
|
1038
1076
|
videoWidth: t
|
|
1039
1077
|
}) => ({
|
|
1040
|
-
height:
|
|
1078
|
+
height: i || e,
|
|
1041
1079
|
width: s || t
|
|
1042
|
-
}),
|
|
1043
|
-
const s = new
|
|
1044
|
-
let t =
|
|
1045
|
-
const
|
|
1080
|
+
}), wt = (i) => {
|
|
1081
|
+
const s = new Ve({ verbose: !0 }), e = pt();
|
|
1082
|
+
let t = i;
|
|
1083
|
+
const a = (n) => {
|
|
1046
1084
|
var l;
|
|
1047
|
-
const
|
|
1048
|
-
return typeof
|
|
1085
|
+
const c = (l = T.getOptions(n)) == null ? void 0 : l.targetFps;
|
|
1086
|
+
return typeof c == "number" ? c : t == null ? void 0 : t.targetFps;
|
|
1049
1087
|
};
|
|
1050
|
-
let
|
|
1051
|
-
const
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
const l =
|
|
1088
|
+
let r, o, u, m, d, S, R, M, x, g, f, w = !1, p = !1, k = 0;
|
|
1089
|
+
const C = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Set(), U = (n) => {
|
|
1090
|
+
const c = e.getSnapshot().cameraTexture;
|
|
1091
|
+
c && c.dispose();
|
|
1092
|
+
const l = ut(n);
|
|
1055
1093
|
return e.set({ cameraTexture: l }), l;
|
|
1056
|
-
},
|
|
1057
|
-
if (
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1094
|
+
}, _ = async (n, c) => {
|
|
1095
|
+
if (C.has(n) || e.getSnapshot().lifecycle !== "running" || !d) return;
|
|
1096
|
+
C.add(n);
|
|
1097
|
+
const l = k;
|
|
1098
|
+
try {
|
|
1099
|
+
await c.run({
|
|
1100
|
+
sourceCanvas: d,
|
|
1101
|
+
renderWidth: e.getSnapshot().renderWidth,
|
|
1102
|
+
renderHeight: e.getSnapshot().renderHeight,
|
|
1103
|
+
getSource: () => e.getSnapshot().sourceKind,
|
|
1104
|
+
targetFps: a(n)
|
|
1105
|
+
}), p && (await new Promise((v) => requestAnimationFrame(() => v())), await new Promise((v) => requestAnimationFrame(() => v())), p && k === l && T.suspendAll());
|
|
1106
|
+
} catch (v) {
|
|
1107
|
+
throw C.delete(n), v;
|
|
1070
1108
|
}
|
|
1071
|
-
},
|
|
1109
|
+
}, T = mt(e, re, (n, c) => _(n, c));
|
|
1072
1110
|
e.subscribe(() => {
|
|
1073
1111
|
if (e.getSnapshot().lifecycle !== "running") return;
|
|
1074
|
-
const
|
|
1075
|
-
for (const [
|
|
1076
|
-
|
|
1112
|
+
const n = e.getSnapshot().pipeline;
|
|
1113
|
+
for (const [c, l] of n.entries())
|
|
1114
|
+
C.has(c) || _(c, l);
|
|
1077
1115
|
});
|
|
1078
|
-
const
|
|
1079
|
-
if (
|
|
1116
|
+
const P = () => {
|
|
1117
|
+
if (f !== void 0 && (cancelAnimationFrame(f), f = void 0), o) {
|
|
1080
1118
|
try {
|
|
1081
|
-
|
|
1119
|
+
o.pause();
|
|
1082
1120
|
} catch {
|
|
1083
1121
|
}
|
|
1084
1122
|
try {
|
|
1085
|
-
|
|
1123
|
+
o.srcObject = null;
|
|
1086
1124
|
} catch {
|
|
1087
1125
|
}
|
|
1088
|
-
|
|
1126
|
+
o = void 0;
|
|
1089
1127
|
}
|
|
1090
1128
|
if (u) {
|
|
1091
1129
|
try {
|
|
1092
|
-
u.getTracks().forEach((
|
|
1130
|
+
u.getTracks().forEach((n) => n.stop());
|
|
1093
1131
|
} catch {
|
|
1094
1132
|
}
|
|
1095
1133
|
u = void 0;
|
|
1096
1134
|
}
|
|
1097
|
-
},
|
|
1098
|
-
if (
|
|
1099
|
-
const
|
|
1100
|
-
if (
|
|
1101
|
-
|
|
1135
|
+
}, G = () => {
|
|
1136
|
+
if (w || !o || !m || !d) return;
|
|
1137
|
+
const n = window.__xr_debugger_metrics;
|
|
1138
|
+
if (n != null && n.trackCameraFrame && n.trackCameraFrame(), (e.getSnapshot().sourceKind ?? "webcam") === "webcam")
|
|
1139
|
+
lt(o, m);
|
|
1102
1140
|
else {
|
|
1103
1141
|
const v = m.getContext("2d");
|
|
1104
1142
|
if (!v) return;
|
|
1105
|
-
const
|
|
1106
|
-
m.width !==
|
|
1143
|
+
const y = o.videoWidth, A = o.videoHeight;
|
|
1144
|
+
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);
|
|
1107
1145
|
}
|
|
1108
|
-
|
|
1146
|
+
gt(m, d, (t == null ? void 0 : t.cameraZoom) ?? 1.2);
|
|
1109
1147
|
const l = e.getSnapshot().cameraTexture;
|
|
1110
1148
|
l && (l.needsUpdate = !0);
|
|
1111
|
-
},
|
|
1112
|
-
if (!
|
|
1113
|
-
if (
|
|
1114
|
-
|
|
1149
|
+
}, J = () => {
|
|
1150
|
+
if (!o || !m || !d) return;
|
|
1151
|
+
if (p) {
|
|
1152
|
+
G();
|
|
1115
1153
|
return;
|
|
1116
1154
|
}
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1155
|
+
const n = () => {
|
|
1156
|
+
f = requestAnimationFrame(n), G();
|
|
1119
1157
|
};
|
|
1120
|
-
|
|
1121
|
-
},
|
|
1122
|
-
if (
|
|
1158
|
+
f = requestAnimationFrame(n);
|
|
1159
|
+
}, pe = async (n) => {
|
|
1160
|
+
if (n.source === F.WEBCAM)
|
|
1123
1161
|
try {
|
|
1124
|
-
const
|
|
1162
|
+
const c = t != null && t.camRes && t.camRes > 0 ? t.camRes : 960;
|
|
1125
1163
|
return await navigator.mediaDevices.getUserMedia({
|
|
1126
1164
|
video: {
|
|
1127
1165
|
facingMode: "user",
|
|
1128
1166
|
frameRate: { min: 24, ideal: 30, max: 60 },
|
|
1129
|
-
width: { ideal:
|
|
1167
|
+
width: { ideal: c }
|
|
1130
1168
|
}
|
|
1131
1169
|
});
|
|
1132
|
-
} catch (
|
|
1133
|
-
const l =
|
|
1134
|
-
throw e.set({ error: { error: "PermissionError", message: v } }), new
|
|
1170
|
+
} catch (c) {
|
|
1171
|
+
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.";
|
|
1172
|
+
throw e.set({ error: { error: "PermissionError", message: v } }), new b(c instanceof Error ? c.message : "getUserMedia failed");
|
|
1135
1173
|
}
|
|
1136
|
-
return
|
|
1137
|
-
},
|
|
1138
|
-
const
|
|
1139
|
-
u =
|
|
1140
|
-
const l = await
|
|
1141
|
-
|
|
1142
|
-
const { renderWidth: v, renderHeight:
|
|
1174
|
+
return n.stream;
|
|
1175
|
+
}, W = async (n) => {
|
|
1176
|
+
const c = await pe(n);
|
|
1177
|
+
u = c;
|
|
1178
|
+
const l = await dt(c);
|
|
1179
|
+
o = l, m = new OffscreenCanvas(l.videoWidth, l.videoHeight);
|
|
1180
|
+
const { renderWidth: v, renderHeight: y } = e.getSnapshot(), A = vt({
|
|
1143
1181
|
renderWidth: v,
|
|
1144
|
-
renderHeight:
|
|
1182
|
+
renderHeight: y,
|
|
1145
1183
|
videoWidth: l.videoWidth,
|
|
1146
1184
|
videoHeight: l.videoHeight
|
|
1147
1185
|
});
|
|
1148
|
-
d ? (d.width !==
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
source:
|
|
1152
|
-
stream:
|
|
1153
|
-
static:
|
|
1154
|
-
sourceKind:
|
|
1186
|
+
d ? (d.width !== A.width || d.height !== A.height) && (d.width = A.width, d.height = A.height, U(d)) : (d = new OffscreenCanvas(A.width, A.height), U(d));
|
|
1187
|
+
const ie = n.source === F.STREAM ? n.static === !0 : !1;
|
|
1188
|
+
p = ie, r = n.source === F.WEBCAM ? { source: F.WEBCAM, sourceKind: "webcam" } : {
|
|
1189
|
+
source: F.STREAM,
|
|
1190
|
+
stream: n.stream,
|
|
1191
|
+
static: ie,
|
|
1192
|
+
sourceKind: n.sourceKind ?? "webcam"
|
|
1155
1193
|
}, e.set({
|
|
1156
|
-
source:
|
|
1157
|
-
sourceKind:
|
|
1194
|
+
source: n.source,
|
|
1195
|
+
sourceKind: r.sourceKind,
|
|
1158
1196
|
error: void 0
|
|
1159
1197
|
});
|
|
1160
|
-
},
|
|
1161
|
-
const
|
|
1162
|
-
d =
|
|
1163
|
-
const l =
|
|
1198
|
+
}, X = async (n) => {
|
|
1199
|
+
const c = n.sourceKind ?? "webcam";
|
|
1200
|
+
d = n.canvas;
|
|
1201
|
+
const l = U(d);
|
|
1164
1202
|
e.set({
|
|
1165
1203
|
cameraTexture: l,
|
|
1166
|
-
source:
|
|
1167
|
-
sourceKind:
|
|
1204
|
+
source: F.CANVAS,
|
|
1205
|
+
sourceKind: c,
|
|
1168
1206
|
renderWidth: d.width,
|
|
1169
1207
|
renderHeight: d.height,
|
|
1170
1208
|
error: void 0
|
|
1171
|
-
}),
|
|
1172
|
-
source:
|
|
1173
|
-
canvas:
|
|
1174
|
-
sourceKind:
|
|
1209
|
+
}), r = {
|
|
1210
|
+
source: F.CANVAS,
|
|
1211
|
+
canvas: n.canvas,
|
|
1212
|
+
sourceKind: c
|
|
1175
1213
|
};
|
|
1176
|
-
},
|
|
1214
|
+
}, ve = (n, c) => !c || n.source !== c.source ? !1 : n.source === F.STREAM && c.source === F.STREAM ? n.stream === c.stream && (n.sourceKind ?? "webcam") === c.sourceKind : !0, we = async () => {
|
|
1177
1215
|
if (!d) return;
|
|
1178
|
-
const
|
|
1179
|
-
for (const [,
|
|
1180
|
-
|
|
1181
|
-
await new Promise((
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
if (
|
|
1187
|
-
throw new E(`Invalid media source: ${String(r)}`);
|
|
1188
|
-
if (ie(i, o)) {
|
|
1216
|
+
const n = k, c = e.getSnapshot().pipeline;
|
|
1217
|
+
for (const [, l] of c.entries())
|
|
1218
|
+
l.resume();
|
|
1219
|
+
await new Promise((l) => requestAnimationFrame(() => l())), await new Promise((l) => requestAnimationFrame(() => l())), p && k === n && T.suspendAll();
|
|
1220
|
+
}, Ce = (n, c) => !c || c.source !== F.CANVAS ? !1 : n.canvas === c.canvas && (n.sourceKind ?? "webcam") === c.sourceKind, Se = async (n) => {
|
|
1221
|
+
const c = n.source;
|
|
1222
|
+
if (c !== F.WEBCAM && c !== F.STREAM)
|
|
1223
|
+
throw new b(`Invalid media source: ${String(c)}`);
|
|
1224
|
+
if (ve(n, r)) {
|
|
1189
1225
|
s.log("Media source unchanged, skipping rebind.");
|
|
1190
1226
|
return;
|
|
1191
1227
|
}
|
|
1228
|
+
k += 1;
|
|
1192
1229
|
const { lifecycle: l } = e.getSnapshot();
|
|
1193
1230
|
if (l === "idle" || l === "stopped") {
|
|
1194
|
-
await
|
|
1231
|
+
await W(n), e.set({ lifecycle: "media-bound" }), s.log("Media source set to:", n.source);
|
|
1195
1232
|
return;
|
|
1196
1233
|
}
|
|
1197
1234
|
if (l === "media-bound") {
|
|
1198
|
-
|
|
1235
|
+
P(), await W(n), s.log("Media source rebound to:", n.source);
|
|
1199
1236
|
return;
|
|
1200
1237
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
const v = e.getSnapshot().pipeline;
|
|
1205
|
-
for (const [, k] of v.entries()) k.resume();
|
|
1206
|
-
}
|
|
1207
|
-
s.log("Media source swapped to:", i.source);
|
|
1208
|
-
}, ce = async (i) => {
|
|
1209
|
-
if (re(i, o)) {
|
|
1238
|
+
w = !0, await new Promise((v) => requestAnimationFrame(() => v())), P(), await W(n), w = !1, J(), p ? await we() : T.resumeActive(), s.log("Media source swapped to:", n.source);
|
|
1239
|
+
}, ke = async (n) => {
|
|
1240
|
+
if (Ce(n, r)) {
|
|
1210
1241
|
s.log("Frame source unchanged, skipping rebind.");
|
|
1211
1242
|
return;
|
|
1212
1243
|
}
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1244
|
+
k += 1;
|
|
1245
|
+
const { lifecycle: c } = e.getSnapshot();
|
|
1246
|
+
if (c === "idle" || c === "stopped") {
|
|
1247
|
+
await X(n), e.set({ lifecycle: "media-bound" }), s.log("Frame source set to canvas.");
|
|
1216
1248
|
return;
|
|
1217
1249
|
}
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1250
|
+
if (c === "media-bound") {
|
|
1251
|
+
P(), await X(n), s.log("Frame source rebound to canvas.");
|
|
1220
1252
|
return;
|
|
1221
1253
|
}
|
|
1222
|
-
|
|
1223
|
-
},
|
|
1224
|
-
const { lifecycle:
|
|
1225
|
-
if (
|
|
1226
|
-
if (
|
|
1227
|
-
throw new
|
|
1254
|
+
w = !0, await new Promise((l) => requestAnimationFrame(() => l())), P(), await X(n), w = !1, s.log("Frame source swapped to canvas.");
|
|
1255
|
+
}, ye = async () => {
|
|
1256
|
+
const { lifecycle: n } = e.getSnapshot();
|
|
1257
|
+
if (n === "running") return;
|
|
1258
|
+
if (n === "idle")
|
|
1259
|
+
throw new b("session.start() called before setMediaSource — call setMediaSource first");
|
|
1228
1260
|
if (!d)
|
|
1229
|
-
throw new
|
|
1230
|
-
const
|
|
1231
|
-
if (!
|
|
1232
|
-
throw
|
|
1261
|
+
throw new b("session.start(): media source not bound");
|
|
1262
|
+
const c = (r == null ? void 0 : r.source) === F.CANVAS;
|
|
1263
|
+
if (!c && (!o || !m))
|
|
1264
|
+
throw n === "stopped" ? new b(
|
|
1233
1265
|
"session.start() called from stopped state without a media source — call setMediaSource first"
|
|
1234
|
-
) : new
|
|
1235
|
-
|
|
1266
|
+
) : new b("session.start(): media source not bound");
|
|
1267
|
+
c || J(), T.resumeActive(), e.set({ lifecycle: "running" }), await new Promise((v) => requestAnimationFrame(() => v()));
|
|
1236
1268
|
const l = e.getSnapshot().pipeline;
|
|
1237
|
-
for (const [v,
|
|
1238
|
-
await
|
|
1269
|
+
for (const [v, y] of l.entries())
|
|
1270
|
+
await _(v, y);
|
|
1239
1271
|
e.set({ ready: !0 }), s.log("XR session started.");
|
|
1240
|
-
},
|
|
1241
|
-
const { lifecycle:
|
|
1242
|
-
|
|
1243
|
-
},
|
|
1244
|
-
await
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1272
|
+
}, ee = async () => {
|
|
1273
|
+
const { lifecycle: n } = e.getSnapshot();
|
|
1274
|
+
n === "stopped" || n === "idle" || (P(), T.suspendAll(), e.set({ lifecycle: "stopped", ready: !1 }), s.log("XR session stopped."));
|
|
1275
|
+
}, Me = async () => {
|
|
1276
|
+
await ee(), T.releaseAll(), L.clear();
|
|
1277
|
+
const n = e.getSnapshot().cameraTexture;
|
|
1278
|
+
n && n.dispose(), C.clear(), r = void 0, k += 1, d = void 0, m = void 0, p = !1, e.set({
|
|
1247
1279
|
lifecycle: "idle",
|
|
1248
1280
|
cameraTexture: void 0,
|
|
1249
1281
|
source: void 0
|
|
1250
1282
|
}), s.log("XR session reset.");
|
|
1251
|
-
},
|
|
1252
|
-
const
|
|
1283
|
+
}, Re = async (n) => {
|
|
1284
|
+
const c = "legacy:registerXRPipeline", l = [];
|
|
1253
1285
|
await Promise.all(
|
|
1254
|
-
|
|
1255
|
-
const { model:
|
|
1256
|
-
if (!
|
|
1257
|
-
throw new
|
|
1258
|
-
|
|
1259
|
-
const
|
|
1260
|
-
await
|
|
1286
|
+
n.map(async (v) => {
|
|
1287
|
+
const { model: y } = v;
|
|
1288
|
+
if (!re[y])
|
|
1289
|
+
throw new b(`Invalid model: ${y}`);
|
|
1290
|
+
L.has(y) || l.push(y);
|
|
1291
|
+
const A = "options" in v ? v.options : void 0;
|
|
1292
|
+
await T.acquire(y, c, A);
|
|
1261
1293
|
})
|
|
1262
|
-
), l.length > 0 && (l.forEach((v) =>
|
|
1263
|
-
},
|
|
1264
|
-
const
|
|
1265
|
-
if (!
|
|
1266
|
-
throw new
|
|
1267
|
-
return
|
|
1268
|
-
},
|
|
1269
|
-
|
|
1294
|
+
), l.length > 0 && (l.forEach((v) => L.add(v)), s.log("XR pipeline registered."));
|
|
1295
|
+
}, Te = (n) => {
|
|
1296
|
+
const c = T.get(n);
|
|
1297
|
+
if (!c)
|
|
1298
|
+
throw new b(`Model ${n} is not registered in the pipeline`);
|
|
1299
|
+
return c.getModelNode();
|
|
1300
|
+
}, te = async (n, c) => {
|
|
1301
|
+
n <= 0 || c <= 0 || (e.set({ renderWidth: n, renderHeight: c }), d && (d.width !== n || d.height !== c) && (d.width = n, d.height = c, U(d), p && G()), s.log(`Source canvas set. Render size: ${n}x${c}`));
|
|
1302
|
+
}, xe = async (n) => {
|
|
1303
|
+
var y;
|
|
1304
|
+
S = n;
|
|
1305
|
+
const c = (y = n.getBoundingClientRect) == null ? void 0 : y.call(n), l = c && c.width > 0 ? Math.round(c.width) : n.clientWidth, v = c && c.height > 0 ? Math.round(c.height) : n.clientHeight;
|
|
1306
|
+
await te(l, v);
|
|
1307
|
+
}, Fe = (n) => {
|
|
1308
|
+
R = n.renderer, M = n.scene, x = n.camera, g = n.renderFrame;
|
|
1309
|
+
}, se = () => {
|
|
1310
|
+
if (!R || !M || !x)
|
|
1311
|
+
throw new b(
|
|
1312
|
+
"XR frame render requested before the R3F state was bound — make sure <XRScene> is mounted"
|
|
1313
|
+
);
|
|
1314
|
+
g ? g() : R.render(M, x);
|
|
1270
1315
|
};
|
|
1271
1316
|
return {
|
|
1272
1317
|
store: e,
|
|
1273
|
-
registry:
|
|
1274
|
-
setMediaSource:
|
|
1275
|
-
start:
|
|
1276
|
-
stop:
|
|
1277
|
-
reset:
|
|
1278
|
-
setFrameSource:
|
|
1279
|
-
registerXRPipeline:
|
|
1280
|
-
getModelNode:
|
|
1318
|
+
registry: T,
|
|
1319
|
+
setMediaSource: Se,
|
|
1320
|
+
start: ye,
|
|
1321
|
+
stop: ee,
|
|
1322
|
+
reset: Me,
|
|
1323
|
+
setFrameSource: ke,
|
|
1324
|
+
registerXRPipeline: Re,
|
|
1325
|
+
getModelNode: Te,
|
|
1281
1326
|
captureFrame: () => {
|
|
1282
|
-
if (!
|
|
1283
|
-
throw new
|
|
1327
|
+
if (!S)
|
|
1328
|
+
throw new b(
|
|
1284
1329
|
"session.captureFrame() called before the XRScene render target was bound — make sure <XRScene> is mounted"
|
|
1285
1330
|
);
|
|
1286
|
-
if (!
|
|
1287
|
-
throw new
|
|
1331
|
+
if (!R || !M || !x)
|
|
1332
|
+
throw new b(
|
|
1288
1333
|
"session.captureFrame() called before the R3F state was bound — make sure <XRScene> is mounted"
|
|
1289
1334
|
);
|
|
1290
|
-
return
|
|
1291
|
-
},
|
|
1292
|
-
_setRenderTarget: async (i) => {
|
|
1293
|
-
var k;
|
|
1294
|
-
g = i;
|
|
1295
|
-
const r = (k = i.getBoundingClientRect) == null ? void 0 : k.call(i), l = r && r.width > 0 ? Math.round(r.width) : i.clientWidth, v = r && r.height > 0 ? Math.round(r.height) : i.clientHeight;
|
|
1296
|
-
await Q(l, v);
|
|
1297
|
-
},
|
|
1298
|
-
_setRenderSize: Q,
|
|
1299
|
-
_setR3FState: (i) => {
|
|
1300
|
-
f = i.renderer, w = i.scene, p = i.camera;
|
|
1335
|
+
return se(), S.toDataURL("image/png");
|
|
1301
1336
|
},
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1337
|
+
getInputFrame: () => d ?? null,
|
|
1338
|
+
_setRenderTarget: xe,
|
|
1339
|
+
_setRenderSize: te,
|
|
1340
|
+
_setR3FState: Fe,
|
|
1341
|
+
_renderFrame: se,
|
|
1342
|
+
_getVideoElement: () => o,
|
|
1343
|
+
_setPerf: (n) => {
|
|
1344
|
+
if (t = n, e.getSnapshot().lifecycle !== "running" || !d) return;
|
|
1345
|
+
const c = e.getSnapshot().pipeline;
|
|
1346
|
+
for (const [l, v] of c.entries())
|
|
1307
1347
|
v.run({
|
|
1308
1348
|
sourceCanvas: d,
|
|
1309
1349
|
renderWidth: e.getSnapshot().renderWidth,
|
|
1310
1350
|
renderHeight: e.getSnapshot().renderHeight,
|
|
1311
1351
|
getSource: () => e.getSnapshot().sourceKind,
|
|
1312
|
-
targetFps:
|
|
1352
|
+
targetFps: a(l)
|
|
1313
1353
|
});
|
|
1314
1354
|
}
|
|
1315
1355
|
};
|
|
1316
|
-
},
|
|
1317
|
-
const s =
|
|
1318
|
-
return
|
|
1319
|
-
|
|
1320
|
-
}, [
|
|
1321
|
-
},
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1356
|
+
}, Ct = (i) => {
|
|
1357
|
+
const s = oe(i), e = $(() => wt(s.current), []), t = JSON.stringify(i ?? {});
|
|
1358
|
+
return Ee(() => {
|
|
1359
|
+
e._setPerf(i);
|
|
1360
|
+
}, [e, t]), e;
|
|
1361
|
+
}, Q = /* @__PURE__ */ new Map(), St = () => ({
|
|
1362
|
+
register: (i, s) => {
|
|
1363
|
+
s ? Q.set(i, s) : Q.delete(i);
|
|
1364
|
+
},
|
|
1365
|
+
resolve: (i) => i ? Q.get(i) ?? null : null
|
|
1366
|
+
}), le = St(), ge = he(null), kt = ({ children: i }) => {
|
|
1367
|
+
const s = oe(/* @__PURE__ */ new Map()), e = ae((r, o) => {
|
|
1368
|
+
o ? s.current.set(r, o) : s.current.delete(r);
|
|
1369
|
+
}, []), t = ae(
|
|
1370
|
+
(r) => r ? s.current.get(r) ?? null : null,
|
|
1371
|
+
[]
|
|
1372
|
+
), a = $(() => ({ register: e, resolve: t }), [e, t]);
|
|
1373
|
+
return Ie(ge.Provider, { value: a }, i);
|
|
1374
|
+
}, me = () => ce(ge) ?? le, Dt = () => me().register, _t = () => me().resolve;
|
|
1375
|
+
le.register;
|
|
1376
|
+
const fe = he(void 0), Pt = () => {
|
|
1377
|
+
const i = ce(fe);
|
|
1378
|
+
if (!i)
|
|
1379
|
+
throw new b(
|
|
1325
1380
|
"XR context can only be used inside XRProvider, did you forget to wrap your app in <XRProvider>?"
|
|
1326
1381
|
);
|
|
1327
|
-
return
|
|
1328
|
-
},
|
|
1329
|
-
const e =
|
|
1330
|
-
return /* @__PURE__ */ fe
|
|
1382
|
+
return i;
|
|
1383
|
+
}, Ot = ({ children: i, perf: s }) => {
|
|
1384
|
+
const e = Ct(s), t = $(() => ({ session: e }), [e]);
|
|
1385
|
+
return /* @__PURE__ */ ne(fe.Provider, { value: t, children: /* @__PURE__ */ ne(kt, { children: i }) });
|
|
1331
1386
|
};
|
|
1332
1387
|
export {
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1388
|
+
z as X,
|
|
1389
|
+
H as a,
|
|
1390
|
+
It as b,
|
|
1391
|
+
F as c,
|
|
1392
|
+
Ot as d,
|
|
1393
|
+
_t as e,
|
|
1394
|
+
He as f,
|
|
1395
|
+
Dt as g,
|
|
1396
|
+
I as l,
|
|
1397
|
+
Pt as u
|
|
1341
1398
|
};
|