@vincentt-xr/sdk 2.0.0-alpha.0 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GROUNDING.md +1813 -27
- package/dist/{DebuggerUI-CEfdddkZ.cjs → DebuggerUI-B45_Gb9d.cjs} +1 -1
- package/dist/{DebuggerUI-Dgop6Q6o.js → DebuggerUI-Cq28c18s.js} +1 -1
- package/dist/FaceMeshRenderer-6t8OsQhK.js +1195 -0
- package/dist/FaceMeshRenderer-lQLhYIW-.cjs +155 -0
- package/dist/FaceRetouch-CDrL0pXg.js +551 -0
- package/dist/FaceRetouch-DtNl8-4e.cjs +134 -0
- package/dist/audio/AudioEngine.d.ts +3 -1
- package/dist/audio/AudioPlayer.d.ts +29 -0
- package/dist/audio/AudioPlayerLogic.d.ts +4 -0
- package/dist/audio/index.d.ts +2 -0
- package/dist/components/Axes/index.d.ts +6 -0
- package/dist/components/FaceMesh/FaceMeshRenderer.d.ts +17 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +22 -1
- package/dist/components/FaceMesh/canonical/FaceMeshMaterial.d.ts +25 -0
- package/dist/components/FaceMesh/canonical/assets.d.ts +3 -0
- package/dist/components/FaceMesh/canonical/geometryGroups.d.ts +9 -0
- package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +2 -0
- package/dist/components/FaceMesh/canonical/shaders.d.ts +2 -0
- package/dist/components/FaceMesh/deform.d.ts +3 -0
- package/dist/components/FaceMesh/index.d.ts +5 -0
- package/dist/components/FaceMesh/material/defaults.d.ts +74 -0
- package/dist/components/FaceMesh/material/index.d.ts +1 -0
- package/dist/components/FaceMesh/material/options.d.ts +5 -1
- package/dist/components/FaceMesh/material/support.d.ts +7 -2
- package/dist/components/FaceMesh/material/textures.d.ts +4 -0
- package/dist/components/FaceMesh/material/types.d.ts +4 -2
- package/dist/components/FaceRetouch/Background.d.ts +9 -5
- package/dist/components/FaceRetouch/FaceRetouch.d.ts +47 -0
- package/dist/components/FaceRetouch/index.d.ts +2 -6
- package/dist/components/FaceRetouch/landmarkMask.d.ts +4 -6
- package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +4 -7
- package/dist/components/FaceTracker/index.d.ts +5 -3
- package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +15 -0
- package/dist/components/FaceWarp3D/defaults.d.ts +37 -0
- package/dist/components/FaceWarp3D/index.d.ts +3 -0
- package/dist/components/FaceWarp3D/warp.d.ts +13 -0
- package/dist/components/HandJoints2D/index.d.ts +6 -0
- package/dist/components/HandTracker/index.d.ts +2 -2
- package/dist/components/HandTracking2D/HandVisual.d.ts +12 -0
- package/dist/components/HandTracking2D/index.d.ts +5 -0
- package/dist/components/HandTracking2DController/index.d.ts +5 -0
- package/dist/components/HandTracking3D/index.d.ts +6 -0
- package/dist/components/LightObject/index.d.ts +20 -0
- package/dist/components/LookAt/index.d.ts +23 -0
- package/dist/components/MeshRenderer/index.d.ts +58 -0
- package/dist/components/PerspectiveCamera/index.d.ts +2 -8
- package/dist/components/PinToMesh/index.d.ts +47 -0
- package/dist/components/RenderGroupLayer/index.d.ts +6 -0
- package/dist/components/SceneObjectRenderer/index.d.ts +16 -0
- package/dist/components/Screen2D/ScreenTransformFrame.d.ts +11 -0
- package/dist/components/Screen2D/ScreenTransformHelpers.d.ts +19 -0
- package/dist/components/Screen2D/ScreenTransformInteraction.d.ts +18 -0
- package/dist/components/Screen2D/index.d.ts +5 -0
- package/dist/components/ScreenGlass/defaults.d.ts +3 -0
- package/dist/components/ScreenGlass/index.d.ts +5 -0
- package/dist/components/ScreenGlass/shaders.d.ts +2 -0
- package/dist/components/ScreenGlass/types.d.ts +10 -0
- package/dist/components/ScreenGradient/defaults.d.ts +5 -0
- package/dist/components/ScreenGradient/index.d.ts +5 -0
- package/dist/components/ScreenGradient/shaders.d.ts +2 -0
- package/dist/components/ScreenGradient/types.d.ts +19 -0
- package/dist/components/ScreenImage/ScreenImage.d.ts +4 -0
- package/dist/components/ScreenImage/components/DynamicTextureSync.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageFrame.d.ts +9 -0
- package/dist/components/ScreenImage/components/ScreenImageTransformFrame.d.ts +9 -0
- package/dist/components/ScreenImage/fit.d.ts +52 -0
- package/dist/components/ScreenImage/index.d.ts +8 -0
- package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +9 -0
- package/dist/components/ScreenImage/materials/ScreenImageMatcap.d.ts +3 -0
- package/dist/components/ScreenImage/source.d.ts +16 -0
- package/dist/components/ScreenImage/types.d.ts +37 -0
- package/dist/components/ScreenImage/utils/ScreenImageConstants.d.ts +9 -0
- package/dist/components/ScreenImage/utils/ScreenImageHelpers.d.ts +4 -0
- package/dist/components/ScreenShape/geometry.d.ts +5 -0
- package/dist/components/ScreenShape/index.d.ts +5 -0
- package/dist/components/ScreenShape/types.d.ts +41 -0
- package/dist/components/ScreenSpaceUI/ScreenTransformGuide.d.ts +15 -0
- package/dist/components/ScreenSpaceUI/ScreenTransformOverlayGuide.d.ts +9 -0
- package/dist/components/ScreenSpaceUI/index.d.ts +2 -0
- package/dist/components/ScreenText/components/ScreenTextBody.d.ts +2 -0
- package/dist/components/ScreenText/components/ScreenTextTransformFrame.d.ts +9 -0
- package/dist/components/ScreenText/constants.d.ts +5 -0
- package/dist/components/ScreenText/index.d.ts +6 -0
- package/dist/components/ScreenText/types.d.ts +31 -0
- package/dist/components/ScreenText/utils/ScreenTextHelpers.d.ts +14 -0
- package/dist/components/ScreenText/utils/ScreenTextMappings.d.ts +17 -0
- package/dist/components/SequentialRenderPasses/index.d.ts +6 -0
- package/dist/components/TextLabel/TextLabel.d.ts +5 -0
- package/dist/components/TextLabel/alignment.d.ts +4 -0
- package/dist/components/TextLabel/bend.d.ts +9 -0
- package/dist/components/TextLabel/canvas/buildTextLabelTexture.d.ts +4 -0
- package/dist/components/TextLabel/canvas/canvasTypography.d.ts +13 -0
- package/dist/components/TextLabel/canvas/drawBackground.d.ts +21 -0
- package/dist/components/TextLabel/canvas/drawEffects.d.ts +34 -0
- package/dist/components/TextLabel/canvas/drawText.d.ts +19 -0
- package/dist/components/TextLabel/components/TextLabelMesh.d.ts +13 -0
- package/dist/components/TextLabel/constants.d.ts +2 -0
- package/dist/components/TextLabel/hooks/useTextLabelTexture.d.ts +7 -0
- package/dist/components/TextLabel/index.d.ts +2 -62
- package/dist/components/TextLabel/layout/measurement.d.ts +8 -0
- package/dist/components/TextLabel/layout/resolveTextLayout.d.ts +25 -0
- package/dist/components/TextLabel/layout/wrapText.d.ts +6 -0
- package/dist/components/TextLabel/types.d.ts +227 -0
- package/dist/components/TrackingAnchor/index.d.ts +18 -2
- package/dist/components/Transform3D/index.d.ts +30 -0
- package/dist/components/XRMediaSurface/index.d.ts +6 -6
- package/dist/components/XRScene/index.d.ts +14 -3
- package/dist/components/XRViewport/XRViewport.d.ts +11 -0
- package/dist/components/XRViewport/components/HiddenMedia.d.ts +7 -0
- package/dist/components/XRViewport/components/MediaAssetPicker.d.ts +8 -0
- package/dist/components/XRViewport/components/MediaControlStack.d.ts +13 -0
- package/dist/components/XRViewport/components/XRViewportLayers.d.ts +30 -0
- package/dist/components/XRViewport/constants.d.ts +24 -0
- package/dist/components/XRViewport/contexts.d.ts +6 -0
- package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +13 -0
- package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +16 -0
- package/dist/components/XRViewport/hooks/useViewportMediaTexture.d.ts +10 -0
- package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +41 -0
- package/dist/components/XRViewport/hooks/useViewportRenderState.d.ts +47 -0
- package/dist/components/XRViewport/index.d.ts +3 -101
- package/dist/components/XRViewport/layout.d.ts +16 -0
- package/dist/components/XRViewport/slots.d.ts +16 -0
- package/dist/components/XRViewport/types.d.ts +89 -0
- package/dist/components/XRViewport/useViewportSize.d.ts +3 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/contexts-BKvTIayr.cjs +1 -0
- package/dist/contexts-Bk5zz_VR.js +214 -0
- package/dist/debug-ui/component-editor/index.d.ts +19 -0
- package/dist/debug-ui/default-setting/index.d.ts +37 -0
- package/dist/debug-ui/default-setting.cjs +21 -0
- package/dist/debug-ui/default-setting.js +777 -0
- package/dist/debug-ui/face-mesh-renderer-settings/index.d.ts +8 -0
- package/dist/debug-ui/face-retouch/index.d.ts +11 -0
- package/dist/debug-ui/face-warp-3d/index.d.ts +6 -0
- package/dist/debug-ui/hand-joints-2d/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-2d/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-3d/index.d.ts +6 -0
- package/dist/debug-ui/hierarchy-panel/index.d.ts +29 -0
- package/dist/debug-ui/index.d.ts +46 -0
- package/dist/debug-ui/layer-panel/index.d.ts +18 -0
- package/dist/debug-ui/media-source/MediaSourceSwitcher.d.ts +10 -0
- package/dist/debug-ui/media-source/index.d.ts +6 -0
- package/dist/debug-ui/media-source/media-preset.d.ts +9 -0
- package/dist/debug-ui/media-source/session.d.ts +12 -0
- package/dist/debug-ui/media-source.cjs +1 -0
- package/dist/debug-ui/media-source.js +9 -0
- package/dist/debug-ui/mesh-renderer-settings/index.d.ts +6 -0
- package/dist/debug-ui/object-inspector-panel/index.d.ts +25 -0
- package/dist/debug-ui/pin-to-mesh-settings/index.d.ts +10 -0
- package/dist/debug-ui/scene-editor/context.d.ts +38 -0
- package/dist/debug-ui/scene-editor/hierarchy-panel.d.ts +9 -0
- package/dist/debug-ui/scene-editor/index.d.ts +11 -0
- package/dist/debug-ui/scene-editor/inspector-panel.d.ts +7 -0
- package/dist/debug-ui/scene-editor/store-utils.d.ts +2 -0
- package/dist/debug-ui/scene-editor/viewport-toolbar.d.ts +4 -0
- package/dist/debug-ui/scene-editor/viewport.d.ts +21 -0
- package/dist/debug-ui/screen-glass-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-gradient-settings/GradientStopsEditor.d.ts +5 -0
- package/dist/debug-ui/screen-gradient-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-gradient-settings/styles.d.ts +3 -0
- package/dist/debug-ui/screen-image-settings/index.d.ts +9 -0
- package/dist/debug-ui/screen-shape-settings/index.d.ts +6 -0
- package/dist/debug-ui/screen-text-settings/NumberField.d.ts +9 -0
- package/dist/debug-ui/screen-text-settings/ScreenTextSettingsPanel.d.ts +3 -0
- package/dist/debug-ui/screen-text-settings/controls/NestedSection.d.ts +7 -0
- package/dist/debug-ui/screen-text-settings/controls/Section.d.ts +8 -0
- package/dist/debug-ui/screen-text-settings/controls/icons.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/index.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/BackgroundSection.d.ts +8 -0
- package/dist/debug-ui/screen-text-settings/sections/ContentSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/EffectsSection.d.ts +25 -0
- package/dist/debug-ui/screen-text-settings/sections/StyleSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/TransformSection.d.ts +5 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundFillControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundSizeControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/BackgroundStrokeControls.d.ts +2 -0
- package/dist/debug-ui/screen-text-settings/sections/background/types.d.ts +7 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/BendEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/EffectChrome.d.ts +21 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/GlowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/InnerShadowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/OutlineEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/ShadowEffectSection.d.ts +4 -0
- package/dist/debug-ui/screen-text-settings/sections/effects/types.d.ts +14 -0
- package/dist/debug-ui/screen-text-settings/settings.d.ts +90 -0
- package/dist/debug-ui/screen-text-settings/styles.d.ts +26 -0
- package/dist/debug-ui/screen-text-settings/transform.d.ts +6 -0
- package/dist/debug-ui/screen-text-settings/types.d.ts +9 -0
- package/dist/debug-ui/settings-panel/index.d.ts +38 -0
- package/dist/debug-ui/shared/MaterialSection.d.ts +13 -0
- package/dist/debug-ui/shared/ScreenTransformSection.d.ts +32 -0
- package/dist/debug-ui/transform-3d-settings/index.d.ts +11 -0
- package/dist/debug-ui.cjs +10 -0
- package/dist/debug-ui.js +8861 -0
- package/dist/drawNormalizedCrop-B-7zU-Xw.cjs +1 -0
- package/dist/drawNormalizedCrop-CRdIDyl1.js +44 -0
- package/dist/entries/all.d.ts +1 -0
- package/dist/entries/core.d.ts +55 -4
- package/dist/entries/face-effects.d.ts +12 -8
- package/dist/entries/internal.d.ts +1 -1
- package/dist/entries/low-level.d.ts +21 -4
- package/dist/entries/scene-object.d.ts +10 -0
- package/dist/entries/tracking.d.ts +25 -2
- package/dist/face-action/index.d.ts +34 -0
- package/dist/face-attribute-expression/index.d.ts +10 -0
- package/dist/face-effects.cjs +1 -252
- package/dist/face-effects.js +1404 -2613
- package/dist/face-info/blendshapes.d.ts +3 -0
- package/dist/face-info/derive.d.ts +8 -0
- package/dist/face-info/drawFaceCrop.d.ts +10 -0
- package/dist/face-info/getFaceInfo.d.ts +8 -0
- package/dist/face-info/index.d.ts +8 -0
- package/dist/face-info/landmarks.d.ts +21 -0
- package/dist/face-info/types.d.ts +52 -0
- package/dist/getFaceInfo-CyPAKh3h.cjs +1 -0
- package/dist/getFaceInfo-hUKMLFcr.js +118 -0
- package/dist/hand/handJoints2d.d.ts +49 -0
- package/dist/hand/handTracking2d.d.ts +33 -0
- package/dist/hand/handTracking2dController.d.ts +65 -0
- package/dist/hand/handTracking3d.d.ts +52 -0
- package/dist/hooks/faceResults.d.ts +1 -1
- package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
- package/dist/hooks/useFaceAction.d.ts +3 -0
- package/dist/hooks/useFaceAttributeExpression.d.ts +16 -0
- package/dist/hooks/useFaceDetection.d.ts +18 -0
- package/dist/hooks/useFaceInfo.d.ts +7 -0
- package/dist/hooks/useFaceInfos.d.ts +15 -0
- package/dist/hooks/useFaceResultReader.d.ts +10 -0
- package/dist/hooks/useFrameCapture.d.ts +18 -0
- package/dist/hooks/useMediaRecorder.d.ts +14 -2
- package/dist/hooks/useOwnedTexture.d.ts +6 -0
- package/dist/hooks/useTrackerContext.d.ts +2 -2
- package/dist/hooks/useXRSession/facade.d.ts +3 -0
- package/dist/hooks/useXRSession/registry.d.ts +9 -0
- package/dist/index-82aENaRq.cjs +1 -0
- package/dist/{index-BD-JWMjE.js → index-BgQAX8rs.js} +198 -134
- package/dist/index-CEc1CAmB.cjs +1 -0
- package/dist/index-CTHeBQOs.js +178 -0
- package/dist/index-D4bLzBr6.cjs +1 -0
- package/dist/index-DSpzjuqd.cjs +1 -0
- package/dist/index-Di70KWuY.js +2049 -0
- package/dist/index-DzEzkBIH.cjs +17 -0
- package/dist/{index-CYMj26Ej.js → index-JygePOwo.js} +565 -498
- package/dist/index-UC0Ux38E.js +111 -0
- package/dist/{internal-KOKJDxCG.js → internal-DuMPpcbp.js} +86 -80
- package/dist/internal-i2JkM85N.cjs +1 -0
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +959 -632
- package/dist/main.cjs +1 -1
- package/dist/main.js +556 -455
- package/dist/material/MaterialFill.d.ts +20 -0
- package/dist/material/MeshMaterial.d.ts +14 -0
- package/dist/material/index.d.ts +2 -0
- package/dist/models/Body/index.d.ts +1 -1
- package/dist/models/Face/index.d.ts +1 -0
- package/dist/models/Face/rotation.d.ts +3 -0
- package/dist/models/Hand/HandTracking.d.ts +2 -0
- package/dist/render/layerStack.d.ts +29 -0
- package/dist/render/renderGroups.d.ts +47 -0
- package/dist/render/renderPasses.d.ts +18 -0
- package/dist/renderGroups-C9QJrAXu.js +152 -0
- package/dist/renderGroups-Dvm1J4lW.cjs +1 -0
- package/dist/renderLayers-lDtL0_43.cjs +1 -0
- package/dist/renderLayers-zrK2pv5O.js +13 -0
- package/dist/renderPasses-CT5iBwtg.cjs +21 -0
- package/dist/renderPasses-CjgG_6kQ.js +1500 -0
- package/dist/scene-object/index.d.ts +146 -0
- package/dist/scene-object/runtimeRegistry.d.ts +14 -0
- package/dist/scene-object.cjs +1 -0
- package/dist/scene-object.js +40 -0
- package/dist/screen-image/screenImagePresets.d.ts +13 -0
- package/dist/screen-image/screenImageSettings.d.ts +57 -0
- package/dist/screen-text/screenTextPresets.d.ts +6 -0
- package/dist/screen-text/screenTextSettings.d.ts +147 -0
- package/dist/screen2d/coordinates.d.ts +87 -0
- package/dist/screen2d/index.d.ts +7 -0
- package/dist/screen2d/material-runtime.d.ts +32 -0
- package/dist/screen2d/screenTransform.d.ts +47 -0
- package/dist/screen2d/smoothing.d.ts +5 -0
- package/dist/screen2d/texture.d.ts +10 -0
- package/dist/screen2d/transform.d.ts +25 -0
- package/dist/screen2d/types.d.ts +90 -0
- package/dist/{selectors-Bub0o3qy.cjs → selectors-2QvO5RYY.cjs} +1 -1
- package/dist/{selectors-BHO6TnoC.js → selectors-Dw3C-gSk.js} +5 -5
- package/dist/services/MetricsCollector/index.d.ts +7 -1
- package/dist/services/MetricsCollector/utils.d.ts +1 -1
- package/dist/session-BChR4TgK.cjs +31 -0
- package/dist/session-C1StwN0f.js +363 -0
- package/dist/texture/animatedTexture.d.ts +61 -0
- package/dist/texture/animationMath.d.ts +8 -0
- package/dist/texture/sourceResolver.d.ts +30 -0
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +582 -298
- package/dist/types/face.d.ts +1 -13
- package/dist/types/hand-tracking.d.ts +8 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/nodes.d.ts +4 -1
- package/dist/types/session.d.ts +2 -0
- package/dist/types/tracking.d.ts +8 -2
- package/dist/types/util-types.d.ts +1 -1
- package/dist/useFaceInfo-C-WfMlYp.cjs +1 -0
- package/dist/useFaceInfo-CwsHZedC.js +62 -0
- package/dist/useFaceResults-CkFc1egZ.js +19 -0
- package/dist/useFaceResults-VcFdOUFV.cjs +1 -0
- package/dist/utils/drawNormalizedCrop.d.ts +22 -0
- package/dist/utils/integrity.d.ts +4 -25
- package/dist/utils/landmarkBounds.d.ts +1 -1
- package/dist/utils/logger.d.ts +2 -2
- package/dist/x-Co8jPhP0.js +127 -0
- package/dist/x-KC8E4Gaj.cjs +41 -0
- package/docs/MIGRATION_GUIDE.md +589 -0
- package/docs/SDK_DOCUMENTATION.md +1155 -0
- package/docs/api/audio.mdx +36 -0
- package/docs/api/behavior-components.mdx +164 -0
- package/docs/api/capture-recording.mdx +103 -0
- package/docs/api/debug-ui-scene-editor.mdx +249 -0
- package/docs/api/face-actions.mdx +104 -0
- package/docs/api/face-attribute-expression.mdx +87 -0
- package/docs/api/face-binding-anchors.mdx +53 -0
- package/docs/api/face-effects.mdx +19 -0
- package/docs/api/face-info.mdx +112 -0
- package/docs/api/face-mesh.mdx +98 -0
- package/docs/api/face-painting.mdx +33 -0
- package/docs/api/face-retouching.mdx +73 -0
- package/docs/api/material-render-state.mdx +132 -0
- package/docs/api/runtime-3d.mdx +311 -0
- package/docs/api/scene-object-store.mdx +213 -0
- package/docs/api/screen-image.mdx +41 -0
- package/docs/api/screen-shape.mdx +64 -0
- package/docs/api/screen-space-coordinates.mdx +41 -0
- package/docs/api/screen-text.mdx +39 -0
- package/docs/api/texture-sources.mdx +55 -0
- package/docs/api/trackers.mdx +46 -0
- package/docs/docs.json +70 -0
- package/docs/examples/scene-object-recipes.mdx +194 -0
- package/docs/guides/harness-debug-ui.mdx +139 -0
- package/docs/inspector/hierarchy-panel.mdx +51 -0
- package/docs/inspector/object-inspector-panel.mdx +51 -0
- package/docs/introduction.mdx +121 -0
- package/docs/scene-objects/overview.mdx +127 -0
- package/docs/scene-objects/render-groups.mdx +77 -0
- package/docs/scene-objects/runtime-rendering.mdx +75 -0
- package/docs/texture-api-consumer.md +58 -0
- package/package.json +55 -7
- package/dist/components/FaceRetouch/retouchRegions.d.ts +0 -23
- package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +0 -12
- package/dist/index-B5J4gzn2.cjs +0 -1
- package/dist/index-BVBVg96G.cjs +0 -1
- package/dist/index-DtwHElmG.js +0 -157
- package/dist/index-PtFmD6B8.cjs +0 -1
- package/dist/internal-DH5d1Xnq.cjs +0 -1
- package/dist/modules/XRClient/index.d.ts +0 -9
- package/dist/modules/index.d.ts +0 -1
- package/dist/services/ApiService.d.ts +0 -12
- package/dist/types/client.d.ts +0 -3
- package/dist/useFaceResults-cpsSmKKc.js +0 -81
- package/dist/useFaceResults-hVUJYSEY.cjs +0 -1
package/dist/low-level.js
CHANGED
|
@@ -1,80 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { u as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { c as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
fontWeight: 700,
|
|
22
|
-
padding: "4px 8px",
|
|
23
|
-
whiteSpace: "nowrap"
|
|
24
|
-
}, Ze = ({
|
|
25
|
-
boundingBox: e,
|
|
26
|
-
label: t = "face bounding box",
|
|
27
|
-
color: n = "#22c55e",
|
|
28
|
-
style: a,
|
|
29
|
-
labelStyle: r
|
|
30
|
-
}) => /* @__PURE__ */ f(
|
|
31
|
-
"div",
|
|
32
|
-
{
|
|
33
|
-
style: {
|
|
34
|
-
position: "absolute",
|
|
35
|
-
left: `${e.left * 100}%`,
|
|
36
|
-
top: `${e.top * 100}%`,
|
|
37
|
-
width: `${e.width * 100}%`,
|
|
38
|
-
height: `${e.height * 100}%`,
|
|
39
|
-
border: `3px solid ${n}`,
|
|
40
|
-
boxSizing: "border-box",
|
|
41
|
-
pointerEvents: "none",
|
|
42
|
-
zIndex: 20,
|
|
43
|
-
...a
|
|
44
|
-
},
|
|
45
|
-
children: t !== null && /* @__PURE__ */ f("div", { style: { ...Ee, ...r }, children: t })
|
|
46
|
-
}
|
|
47
|
-
), et = (e) => {
|
|
48
|
-
const { makeDefault: t = !0, ...n } = e, a = {
|
|
49
|
-
position: [0, 0, 40],
|
|
50
|
-
fov: 30,
|
|
51
|
-
near: 0.1,
|
|
52
|
-
far: 1e3,
|
|
53
|
-
makeDefault: t,
|
|
54
|
-
...n
|
|
55
|
-
};
|
|
56
|
-
return /* @__PURE__ */ f(Re, { ...a });
|
|
57
|
-
}, tt = ({
|
|
58
|
-
background: e = "#000",
|
|
59
|
-
children: t,
|
|
60
|
-
style: n
|
|
61
|
-
}) => /* @__PURE__ */ f(
|
|
62
|
-
"div",
|
|
63
|
-
{
|
|
64
|
-
style: {
|
|
65
|
-
position: "fixed",
|
|
66
|
-
inset: 0,
|
|
67
|
-
overflow: "hidden",
|
|
68
|
-
background: e,
|
|
69
|
-
...n
|
|
70
|
-
},
|
|
71
|
-
children: t
|
|
72
|
-
}
|
|
73
|
-
), $ = ({
|
|
1
|
+
var ce = Object.defineProperty;
|
|
2
|
+
var de = (e, t, r) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var X = (e, t, r) => de(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { u as ue, X as te } from "./index-JygePOwo.js";
|
|
5
|
+
import { u as he } from "./index-BgQAX8rs.js";
|
|
6
|
+
import { H as Ct, a as St } from "./index-BgQAX8rs.js";
|
|
7
|
+
import { c as pe } from "./selectors-Dw3C-gSk.js";
|
|
8
|
+
import { b as Et, a as It, e as Mt, u as Tt, d as Ft } from "./selectors-Dw3C-gSk.js";
|
|
9
|
+
import { useEffect as F, useState as S, useRef as L, useCallback as fe, useLayoutEffect as me, useMemo as q, Children as ge, isValidElement as be } from "react";
|
|
10
|
+
import { c as we } from "./getFaceInfo-hUKMLFcr.js";
|
|
11
|
+
import { d as Lt, e as zt } from "./getFaceInfo-hUKMLFcr.js";
|
|
12
|
+
import { jsx as g, jsxs as z, Fragment as P } from "react/jsx-runtime";
|
|
13
|
+
import { PerspectiveCamera as xe } from "@react-three/drei";
|
|
14
|
+
import { S as Dt, g as Vt, c as At, d as Bt, u as Wt } from "./index-CTHeBQOs.js";
|
|
15
|
+
import { u as re } from "./useFaceResults-CkFc1egZ.js";
|
|
16
|
+
import { h as Ht } from "./hasFullUnitUVBounds-BGvcFsQM.js";
|
|
17
|
+
import { X as ve, a as ye, b as Ce } from "./contexts-Bk5zz_VR.js";
|
|
18
|
+
import { c as $t, d as qt, u as Nt } from "./contexts-Bk5zz_VR.js";
|
|
19
|
+
import * as V from "three";
|
|
20
|
+
const W = ({
|
|
74
21
|
children: e,
|
|
75
22
|
config: t,
|
|
76
|
-
style:
|
|
77
|
-
}) => /* @__PURE__ */
|
|
23
|
+
style: r
|
|
24
|
+
}) => /* @__PURE__ */ g(
|
|
78
25
|
"div",
|
|
79
26
|
{
|
|
80
27
|
"data-render-target": t.name,
|
|
@@ -86,83 +33,83 @@ const Ee = {
|
|
|
86
33
|
pointerEvents: t.pointerEvents ?? "none",
|
|
87
34
|
zIndex: t.zIndex,
|
|
88
35
|
opacity: t.hidden ? 0 : 1,
|
|
89
|
-
...
|
|
36
|
+
...r
|
|
90
37
|
},
|
|
91
38
|
children: e
|
|
92
39
|
}
|
|
93
|
-
),
|
|
40
|
+
), N = ({
|
|
94
41
|
canvas: e,
|
|
95
42
|
layout: t,
|
|
96
|
-
media:
|
|
97
|
-
mirrored:
|
|
98
|
-
filter:
|
|
43
|
+
media: r,
|
|
44
|
+
mirrored: n,
|
|
45
|
+
filter: o
|
|
99
46
|
}) => {
|
|
100
|
-
const i = Math.round(t.destination.width),
|
|
101
|
-
e.width !== i && (e.width = i), e.height !==
|
|
102
|
-
const
|
|
103
|
-
|
|
47
|
+
const i = Math.round(t.destination.width), a = Math.round(t.destination.height);
|
|
48
|
+
e.width !== i && (e.width = i), e.height !== a && (e.height = a);
|
|
49
|
+
const s = e.getContext("2d");
|
|
50
|
+
s && (s.setTransform(1, 0, 0, 1, 0, 0), s.clearRect(0, 0, i, a), n && (s.translate(i, 0), s.scale(-1, 1)), o && (s.filter = o), s.drawImage(r, t.offsetX, t.offsetY, t.drawWidth, t.drawHeight), o && (s.filter = "none"), s.setTransform(1, 0, 0, 1, 0, 0));
|
|
104
51
|
}, ne = ({
|
|
105
52
|
canvasRef: e,
|
|
106
53
|
enabled: t = !0,
|
|
107
|
-
fps:
|
|
108
|
-
imageRef:
|
|
109
|
-
layout:
|
|
54
|
+
fps: r = 30,
|
|
55
|
+
imageRef: n,
|
|
56
|
+
layout: o,
|
|
110
57
|
mirrored: i,
|
|
111
|
-
sourceKind:
|
|
112
|
-
videoRef:
|
|
58
|
+
sourceKind: a,
|
|
59
|
+
videoRef: s
|
|
113
60
|
}) => {
|
|
114
|
-
|
|
61
|
+
F(() => {
|
|
115
62
|
if (!t) {
|
|
116
|
-
const
|
|
117
|
-
|
|
63
|
+
const b = e.current, f = b == null ? void 0 : b.getContext("2d");
|
|
64
|
+
b && f && f.clearRect(0, 0, b.width, b.height);
|
|
118
65
|
return;
|
|
119
66
|
}
|
|
120
|
-
let
|
|
121
|
-
const d =
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
126
|
-
if (
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
67
|
+
let l = 0, c = 0;
|
|
68
|
+
const d = r > 0 ? 1e3 / r : 0, h = (b) => {
|
|
69
|
+
if (l = requestAnimationFrame(h), d > 0 && b - c < d) return;
|
|
70
|
+
c = b;
|
|
71
|
+
const f = e.current;
|
|
72
|
+
if (!f || !o) return;
|
|
73
|
+
if (a === "image") {
|
|
74
|
+
const m = n.current;
|
|
75
|
+
if (!m || !m.complete || m.naturalWidth <= 0 || m.naturalHeight <= 0)
|
|
129
76
|
return;
|
|
130
|
-
|
|
131
|
-
canvas:
|
|
132
|
-
layout:
|
|
133
|
-
media:
|
|
77
|
+
N({
|
|
78
|
+
canvas: f,
|
|
79
|
+
layout: o,
|
|
80
|
+
media: m,
|
|
134
81
|
mirrored: i
|
|
135
82
|
});
|
|
136
83
|
return;
|
|
137
84
|
}
|
|
138
|
-
const
|
|
139
|
-
!
|
|
140
|
-
canvas:
|
|
141
|
-
layout:
|
|
142
|
-
media:
|
|
85
|
+
const w = s.current;
|
|
86
|
+
!w || w.readyState < 2 || w.videoWidth <= 0 || w.videoHeight <= 0 || N({
|
|
87
|
+
canvas: f,
|
|
88
|
+
layout: o,
|
|
89
|
+
media: w,
|
|
143
90
|
mirrored: i
|
|
144
91
|
});
|
|
145
92
|
};
|
|
146
|
-
return
|
|
147
|
-
cancelAnimationFrame(
|
|
93
|
+
return l = requestAnimationFrame(h), () => {
|
|
94
|
+
cancelAnimationFrame(l);
|
|
148
95
|
};
|
|
149
|
-
}, [e, t,
|
|
96
|
+
}, [e, t, r, n, o, i, a, s]);
|
|
150
97
|
}, Se = ({
|
|
151
98
|
canvasRef: e,
|
|
152
99
|
imageRef: t,
|
|
153
|
-
layer:
|
|
154
|
-
layout:
|
|
155
|
-
mirrored:
|
|
100
|
+
layer: r,
|
|
101
|
+
layout: n,
|
|
102
|
+
mirrored: o,
|
|
156
103
|
sourceKind: i,
|
|
157
|
-
videoRef:
|
|
104
|
+
videoRef: a
|
|
158
105
|
}) => (ne({
|
|
159
106
|
canvasRef: e,
|
|
160
107
|
imageRef: t,
|
|
161
|
-
layout:
|
|
162
|
-
mirrored:
|
|
108
|
+
layout: n,
|
|
109
|
+
mirrored: o,
|
|
163
110
|
sourceKind: i,
|
|
164
|
-
videoRef:
|
|
165
|
-
}), /* @__PURE__ */
|
|
111
|
+
videoRef: a
|
|
112
|
+
}), /* @__PURE__ */ g(W, { config: r, children: /* @__PURE__ */ g(
|
|
166
113
|
"canvas",
|
|
167
114
|
{
|
|
168
115
|
ref: e,
|
|
@@ -175,339 +122,84 @@ const Ee = {
|
|
|
175
122
|
background: "#000"
|
|
176
123
|
}
|
|
177
124
|
}
|
|
178
|
-
) })),
|
|
125
|
+
) })), lt = ({
|
|
179
126
|
canvasRef: e,
|
|
180
127
|
controlInsetTop: t,
|
|
181
|
-
debugVisible:
|
|
182
|
-
fps:
|
|
183
|
-
imageRef:
|
|
128
|
+
debugVisible: r,
|
|
129
|
+
fps: n = 15,
|
|
130
|
+
imageRef: o,
|
|
184
131
|
layer: i,
|
|
185
|
-
layout:
|
|
186
|
-
mirrored:
|
|
187
|
-
sourceKind:
|
|
188
|
-
videoRef:
|
|
132
|
+
layout: a,
|
|
133
|
+
mirrored: s,
|
|
134
|
+
sourceKind: l,
|
|
135
|
+
videoRef: c,
|
|
189
136
|
viewportSize: d
|
|
190
137
|
}) => {
|
|
191
138
|
ne({
|
|
192
139
|
canvasRef: e,
|
|
193
|
-
enabled:
|
|
194
|
-
fps:
|
|
195
|
-
imageRef:
|
|
196
|
-
layout:
|
|
197
|
-
mirrored:
|
|
198
|
-
sourceKind:
|
|
199
|
-
videoRef:
|
|
140
|
+
enabled: r,
|
|
141
|
+
fps: n,
|
|
142
|
+
imageRef: o,
|
|
143
|
+
layout: a,
|
|
144
|
+
mirrored: s,
|
|
145
|
+
sourceKind: l,
|
|
146
|
+
videoRef: c
|
|
200
147
|
});
|
|
201
|
-
const
|
|
202
|
-
return /* @__PURE__ */
|
|
148
|
+
const h = Math.min(220, Math.max(120, d.width * 0.22)), b = d.width > 0 && d.height > 0 ? d.width / d.height : 1, f = Math.min(d.height - 24, Math.max(t ?? 16, 16));
|
|
149
|
+
return /* @__PURE__ */ g(W, { config: i, children: /* @__PURE__ */ g(
|
|
203
150
|
"canvas",
|
|
204
151
|
{
|
|
205
152
|
ref: e,
|
|
206
153
|
style: {
|
|
207
154
|
position: "absolute",
|
|
208
155
|
left: 16,
|
|
209
|
-
top:
|
|
210
|
-
width:
|
|
211
|
-
height:
|
|
212
|
-
aspectRatio: `${
|
|
213
|
-
opacity:
|
|
156
|
+
top: f,
|
|
157
|
+
width: r ? h : 1,
|
|
158
|
+
height: r ? "auto" : 1,
|
|
159
|
+
aspectRatio: `${b}`,
|
|
160
|
+
opacity: r ? 0.85 : 0,
|
|
214
161
|
borderRadius: 10,
|
|
215
|
-
border:
|
|
162
|
+
border: r ? "1px solid rgba(255,255,255,0.16)" : "none",
|
|
216
163
|
pointerEvents: "none",
|
|
217
164
|
objectFit: "contain",
|
|
218
165
|
background: "#000"
|
|
219
166
|
}
|
|
220
167
|
}
|
|
221
168
|
) });
|
|
222
|
-
},
|
|
223
|
-
enabled: e,
|
|
224
|
-
displayMirrored: t,
|
|
225
|
-
imageRef: n,
|
|
226
|
-
layout: a,
|
|
227
|
-
mode: r,
|
|
228
|
-
numFaces: i,
|
|
229
|
-
selectedSource: s,
|
|
230
|
-
sourceStream: o,
|
|
231
|
-
videoRef: h
|
|
232
|
-
}) => {
|
|
233
|
-
const { session: m } = ye(), d = k(null), g = k(!1), p = k(document.createElement("canvas")), {
|
|
234
|
-
ready: c,
|
|
235
|
-
node: b,
|
|
236
|
-
error: w
|
|
237
|
-
} = he(re.FACE_TRACKER, {
|
|
238
|
-
numFaces: i ?? (r === "head-binding" ? Fe : Ie)
|
|
239
|
-
}), [S, v] = y("idle"), [A, I] = y(null), F = e && c && !!b, L = te({
|
|
240
|
-
node: F ? b : null,
|
|
241
|
-
enabled: F,
|
|
242
|
-
selectedSource: s,
|
|
243
|
-
onFrame: fe(() => {
|
|
244
|
-
I(null), v("ready");
|
|
245
|
-
}, [])
|
|
246
|
-
});
|
|
247
|
-
return M(() => {
|
|
248
|
-
if (!e || !a) return;
|
|
249
|
-
const u = () => {
|
|
250
|
-
const x = s === "image" ? n.current : h.current;
|
|
251
|
-
if (x) {
|
|
252
|
-
if (x instanceof HTMLImageElement) {
|
|
253
|
-
if (!x.complete || x.naturalWidth <= 0 || x.naturalHeight <= 0) return;
|
|
254
|
-
} else if (x.readyState < 2 || x.videoWidth <= 0 || x.videoHeight <= 0)
|
|
255
|
-
return;
|
|
256
|
-
j({
|
|
257
|
-
canvas: p.current,
|
|
258
|
-
layout: a,
|
|
259
|
-
media: x,
|
|
260
|
-
mirrored: t,
|
|
261
|
-
filter: s === "webcam" ? ke : void 0
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
if (s === "image") {
|
|
266
|
-
u();
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
let l = 0;
|
|
270
|
-
const C = () => {
|
|
271
|
-
l = requestAnimationFrame(C), u();
|
|
272
|
-
};
|
|
273
|
-
return l = requestAnimationFrame(C), () => cancelAnimationFrame(l);
|
|
274
|
-
}, [t, e, n, a, s, h]), M(() => {
|
|
275
|
-
var T;
|
|
276
|
-
if (!e) {
|
|
277
|
-
v("idle"), I(null), g.current = !1, d.current = null;
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (!a) {
|
|
281
|
-
v("initializing");
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
const u = (o == null ? void 0 : o.id) ?? (((T = h.current) == null ? void 0 : T.srcObject) instanceof MediaStream ? h.current.srcObject.id : "none"), C = s === "webcam" ? `webcam:${u}` : s;
|
|
285
|
-
d.current !== C && (g.current = !1, d.current = C);
|
|
286
|
-
let x = !1;
|
|
287
|
-
return (async () => {
|
|
288
|
-
try {
|
|
289
|
-
if (v("initializing"), g.current || (await m.setFrameSource({
|
|
290
|
-
canvas: p.current,
|
|
291
|
-
sourceKind: s
|
|
292
|
-
}), await m.start(), g.current = !0), x) return;
|
|
293
|
-
I(null), v("initializing");
|
|
294
|
-
} catch (E) {
|
|
295
|
-
if (x) return;
|
|
296
|
-
v("error"), I(E instanceof Error ? E.message : "Failed to initialize SDK face tracking");
|
|
297
|
-
}
|
|
298
|
-
})(), () => {
|
|
299
|
-
x = !0;
|
|
300
|
-
};
|
|
301
|
-
}, [e, a, s, m, o, h]), M(() => {
|
|
302
|
-
!F && e && !w && v("initializing");
|
|
303
|
-
}, [F, e, w]), M(() => {
|
|
304
|
-
w && (v("error"), I(w.message));
|
|
305
|
-
}, [w]), M(() => () => {
|
|
306
|
-
g.current = !1, m.stop();
|
|
307
|
-
}, [m]), {
|
|
308
|
-
activeDelegate: "GPU",
|
|
309
|
-
faces: L,
|
|
310
|
-
status: S,
|
|
311
|
-
error: A
|
|
312
|
-
};
|
|
313
|
-
}, ie = pe(null), Te = {
|
|
169
|
+
}, Re = {
|
|
314
170
|
audio: !1,
|
|
315
171
|
video: {
|
|
316
172
|
facingMode: "user",
|
|
317
173
|
frameRate: { ideal: 30, max: 60 }
|
|
318
174
|
}
|
|
319
|
-
},
|
|
175
|
+
}, Ee = {
|
|
320
176
|
name: "viewport-live",
|
|
321
177
|
clearColor: "#000000",
|
|
322
178
|
pointerEvents: "none",
|
|
323
179
|
zIndex: 0
|
|
324
|
-
},
|
|
180
|
+
}, Ie = {
|
|
325
181
|
name: "viewport-ui",
|
|
326
182
|
clearColor: "transparent",
|
|
327
183
|
pointerEvents: "auto",
|
|
328
184
|
zIndex: 5
|
|
329
|
-
},
|
|
185
|
+
}, Me = {
|
|
330
186
|
name: "viewport-scene",
|
|
331
187
|
clearColor: "transparent",
|
|
332
188
|
pointerEvents: "auto",
|
|
333
189
|
zIndex: 1
|
|
334
|
-
},
|
|
190
|
+
}, D = {
|
|
335
191
|
webcam: { icon: "◉", label: "Webcam" },
|
|
336
192
|
image: { icon: "▣", label: "Images" },
|
|
337
193
|
video: { icon: "▶", label: "Videos" }
|
|
338
|
-
},
|
|
339
|
-
K.displayName = "XRViewport.Scene";
|
|
340
|
-
const O = ({ children: e }) => /* @__PURE__ */ f(q, { children: e });
|
|
341
|
-
O.displayName = "XRViewport.Overlay";
|
|
342
|
-
const We = (e) => {
|
|
343
|
-
if (!e)
|
|
344
|
-
return { width: 0, height: 0 };
|
|
345
|
-
const t = e.getBoundingClientRect();
|
|
346
|
-
return {
|
|
347
|
-
width: t.width || e.clientWidth,
|
|
348
|
-
height: t.height || e.clientHeight
|
|
349
|
-
};
|
|
350
|
-
}, Be = (e) => {
|
|
351
|
-
const [t, n] = y({ width: 0, height: 0 });
|
|
352
|
-
return be(() => {
|
|
353
|
-
const a = e.current;
|
|
354
|
-
if (!a) return;
|
|
355
|
-
let r = 0;
|
|
356
|
-
const i = () => {
|
|
357
|
-
const m = We(a);
|
|
358
|
-
n(
|
|
359
|
-
(d) => d.width === m.width && d.height === m.height ? d : m
|
|
360
|
-
);
|
|
361
|
-
};
|
|
362
|
-
i(), r = requestAnimationFrame(i);
|
|
363
|
-
const s = new ResizeObserver(() => {
|
|
364
|
-
i(), r && cancelAnimationFrame(r), r = requestAnimationFrame(i);
|
|
365
|
-
});
|
|
366
|
-
s.observe(a);
|
|
367
|
-
const o = window.visualViewport, h = () => {
|
|
368
|
-
i(), r && cancelAnimationFrame(r), r = requestAnimationFrame(i);
|
|
369
|
-
};
|
|
370
|
-
return window.addEventListener("resize", h), window.addEventListener("orientationchange", h), o == null || o.addEventListener("resize", h), o == null || o.addEventListener("scroll", h), () => {
|
|
371
|
-
r && cancelAnimationFrame(r), s.disconnect(), window.removeEventListener("resize", h), window.removeEventListener("orientationchange", h), o == null || o.removeEventListener("resize", h), o == null || o.removeEventListener("scroll", h);
|
|
372
|
-
};
|
|
373
|
-
}, [e]), t;
|
|
374
|
-
}, J = (e) => {
|
|
375
|
-
e && (e.pause(), e.removeAttribute("src"), e.srcObject = null, e.load());
|
|
376
|
-
}, Q = (e) => {
|
|
377
|
-
e && e.removeAttribute("src");
|
|
378
|
-
}, He = ({
|
|
379
|
-
enabled: e,
|
|
380
|
-
imageAsset: t,
|
|
381
|
-
selectedSource: n,
|
|
382
|
-
videoAsset: a
|
|
383
|
-
}) => {
|
|
384
|
-
const r = k(null), i = k(null), [s, o] = y(null), [h, m] = y({ width: 0, height: 0 }), [d, g] = y("idle"), [p, c] = y(null);
|
|
385
|
-
return M(() => {
|
|
386
|
-
if (!e) {
|
|
387
|
-
J(r.current), Q(i.current), o(null), m({ width: 0, height: 0 }), g("idle"), c(null);
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
let b = !1, w = null;
|
|
391
|
-
const S = (u, l) => {
|
|
392
|
-
b || (m({ width: u, height: l }), g("ready"), c(null));
|
|
393
|
-
}, v = () => {
|
|
394
|
-
J(r.current), Q(i.current), w == null || w.getTracks().forEach((u) => u.stop()), w = null, o(null);
|
|
395
|
-
}, A = async () => {
|
|
396
|
-
g("requesting");
|
|
397
|
-
const u = await navigator.mediaDevices.getUserMedia(Te);
|
|
398
|
-
if (b) {
|
|
399
|
-
u.getTracks().forEach((C) => C.stop());
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
w = u, o(u);
|
|
403
|
-
const l = r.current;
|
|
404
|
-
l && (l.srcObject = u, l.muted = !0, l.playsInline = !0, l.autoplay = !0, await l.play(), S(l.videoWidth, l.videoHeight));
|
|
405
|
-
}, I = async (u) => {
|
|
406
|
-
g("requesting"), o(null);
|
|
407
|
-
const l = r.current;
|
|
408
|
-
l && (l.src = u, l.muted = !0, l.loop = !0, l.playsInline = !0, l.autoplay = !0, l.crossOrigin = "anonymous", await l.play(), S(l.videoWidth, l.videoHeight));
|
|
409
|
-
}, F = async (u) => {
|
|
410
|
-
g("requesting"), o(null);
|
|
411
|
-
const l = i.current;
|
|
412
|
-
l && (await new Promise((C, x) => {
|
|
413
|
-
l.onload = () => C(), l.onerror = () => x(new Error("Unable to load image")), l.src = u;
|
|
414
|
-
}), S(l.naturalWidth, l.naturalHeight));
|
|
415
|
-
};
|
|
416
|
-
return v(), (async () => {
|
|
417
|
-
try {
|
|
418
|
-
if (n === "webcam") {
|
|
419
|
-
await A();
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
if (n === "video") {
|
|
423
|
-
if (!(a != null && a.src))
|
|
424
|
-
throw new Error("Missing video source");
|
|
425
|
-
await I(a.src);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
if (!(t != null && t.src))
|
|
429
|
-
throw new Error("Missing image source");
|
|
430
|
-
await F(t.src);
|
|
431
|
-
} catch (u) {
|
|
432
|
-
if (b) return;
|
|
433
|
-
g("error"), c(u instanceof Error ? u.message : `Unable to initialize ${n}`);
|
|
434
|
-
}
|
|
435
|
-
})(), () => {
|
|
436
|
-
b = !0, v();
|
|
437
|
-
};
|
|
438
|
-
}, [e, t, n, a]), {
|
|
439
|
-
videoRef: r,
|
|
440
|
-
imageRef: i,
|
|
441
|
-
stream: s,
|
|
442
|
-
mediaSize: h,
|
|
443
|
-
status: d,
|
|
444
|
-
error: p
|
|
445
|
-
};
|
|
446
|
-
}, Ve = (e, t) => e === "auto" ? t === "webcam" ? "cover" : "contain" : e, De = ({
|
|
447
|
-
imageOptions: e,
|
|
448
|
-
initialImageId: t,
|
|
449
|
-
initialSource: n,
|
|
450
|
-
initialVideoId: a,
|
|
451
|
-
source: r,
|
|
452
|
-
videoOptions: i
|
|
453
|
-
}) => {
|
|
454
|
-
var d, g, p, c;
|
|
455
|
-
const s = (r == null ? void 0 : r.kind) ?? n ?? "webcam", o = s === "image" && e.length === 0 || s === "video" && i.length === 0 ? "webcam" : s, h = (r == null ? void 0 : r.kind) === "image" ? r.assetId ?? ((d = e[0]) == null ? void 0 : d.id) ?? "" : t ?? ((g = e[0]) == null ? void 0 : g.id) ?? "", m = (r == null ? void 0 : r.kind) === "video" ? r.assetId ?? ((p = i[0]) == null ? void 0 : p.id) ?? "" : a ?? ((c = i[0]) == null ? void 0 : c.id) ?? "";
|
|
456
|
-
return {
|
|
457
|
-
selectedSource: o,
|
|
458
|
-
selectedImageId: h,
|
|
459
|
-
selectedVideoId: m
|
|
460
|
-
};
|
|
461
|
-
}, _e = (e, t, n) => {
|
|
462
|
-
if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0)
|
|
463
|
-
return null;
|
|
464
|
-
const a = n === "contain" ? Math.min(t.width / e.width, t.height / e.height) : Math.max(t.width / e.width, t.height / e.height), r = e.width * a, i = e.height * a, s = (t.width - r) * 0.5, o = (t.height - i) * 0.5;
|
|
465
|
-
return {
|
|
466
|
-
source: e,
|
|
467
|
-
destination: t,
|
|
468
|
-
drawWidth: r,
|
|
469
|
-
drawHeight: i,
|
|
470
|
-
offsetX: s,
|
|
471
|
-
offsetY: o,
|
|
472
|
-
scale: a
|
|
473
|
-
};
|
|
474
|
-
}, $e = (e, t) => {
|
|
475
|
-
if (e === "dom")
|
|
476
|
-
return {
|
|
477
|
-
sceneContent: null,
|
|
478
|
-
overlayContent: t
|
|
479
|
-
};
|
|
480
|
-
let n = null, a = null;
|
|
481
|
-
const r = [];
|
|
482
|
-
return we.forEach(t, (i) => {
|
|
483
|
-
var o;
|
|
484
|
-
if (!ve(i)) {
|
|
485
|
-
i != null && r.push(i);
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
const s = (o = i.type) == null ? void 0 : o.displayName;
|
|
489
|
-
if (s === K.displayName) {
|
|
490
|
-
n = i.props.children;
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
if (s === O.displayName) {
|
|
494
|
-
a = i.props.children;
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
r.push(i);
|
|
498
|
-
}), !a && r.length > 0 && (a = r), {
|
|
499
|
-
sceneContent: n,
|
|
500
|
-
overlayContent: a
|
|
501
|
-
};
|
|
502
|
-
}, Z = (e, t) => typeof e == "function" ? e(t) : e, nt = () => ge(ie), qe = ({
|
|
194
|
+
}, Te = ({
|
|
503
195
|
imageRef: e,
|
|
504
196
|
selectedSource: t,
|
|
505
|
-
videoRef:
|
|
506
|
-
}) => /* @__PURE__ */ z(
|
|
507
|
-
/* @__PURE__ */
|
|
197
|
+
videoRef: r
|
|
198
|
+
}) => /* @__PURE__ */ z(P, { children: [
|
|
199
|
+
/* @__PURE__ */ g(
|
|
508
200
|
"video",
|
|
509
201
|
{
|
|
510
|
-
ref:
|
|
202
|
+
ref: r,
|
|
511
203
|
style: {
|
|
512
204
|
position: "absolute",
|
|
513
205
|
width: 1,
|
|
@@ -517,7 +209,7 @@ const We = (e) => {
|
|
|
517
209
|
}
|
|
518
210
|
}
|
|
519
211
|
),
|
|
520
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ g(
|
|
521
213
|
"img",
|
|
522
214
|
{
|
|
523
215
|
ref: e,
|
|
@@ -531,13 +223,13 @@ const We = (e) => {
|
|
|
531
223
|
}
|
|
532
224
|
}
|
|
533
225
|
)
|
|
534
|
-
] }),
|
|
226
|
+
] }), J = ({
|
|
535
227
|
dock: e,
|
|
536
228
|
label: t,
|
|
537
|
-
onChange:
|
|
538
|
-
options:
|
|
539
|
-
value:
|
|
540
|
-
}) => /* @__PURE__ */
|
|
229
|
+
onChange: r,
|
|
230
|
+
options: n,
|
|
231
|
+
value: o
|
|
232
|
+
}) => /* @__PURE__ */ g(
|
|
541
233
|
"div",
|
|
542
234
|
{
|
|
543
235
|
style: {
|
|
@@ -565,12 +257,12 @@ const We = (e) => {
|
|
|
565
257
|
fontWeight: 700
|
|
566
258
|
},
|
|
567
259
|
children: [
|
|
568
|
-
/* @__PURE__ */
|
|
569
|
-
/* @__PURE__ */
|
|
260
|
+
/* @__PURE__ */ g("span", { children: t }),
|
|
261
|
+
/* @__PURE__ */ g(
|
|
570
262
|
"select",
|
|
571
263
|
{
|
|
572
|
-
value:
|
|
573
|
-
onChange: (i) =>
|
|
264
|
+
value: o,
|
|
265
|
+
onChange: (i) => r(i.target.value),
|
|
574
266
|
style: {
|
|
575
267
|
minWidth: 180,
|
|
576
268
|
maxWidth: "calc(100vw - 52px)",
|
|
@@ -581,31 +273,31 @@ const We = (e) => {
|
|
|
581
273
|
color: "#e5eefb",
|
|
582
274
|
padding: "0 10px"
|
|
583
275
|
},
|
|
584
|
-
children:
|
|
276
|
+
children: n.map((i) => /* @__PURE__ */ g("option", { value: i.id, style: { color: "#111827" }, children: i.label }, i.id))
|
|
585
277
|
}
|
|
586
278
|
)
|
|
587
279
|
]
|
|
588
280
|
}
|
|
589
281
|
)
|
|
590
282
|
}
|
|
591
|
-
),
|
|
283
|
+
), Fe = ({
|
|
592
284
|
dock: e,
|
|
593
285
|
imageOptions: t,
|
|
594
|
-
selectedImageId:
|
|
595
|
-
selectedSource:
|
|
596
|
-
selectedVideoId:
|
|
286
|
+
selectedImageId: r,
|
|
287
|
+
selectedSource: n,
|
|
288
|
+
selectedVideoId: o,
|
|
597
289
|
setSelectedImageId: i,
|
|
598
|
-
setSelectedSource:
|
|
599
|
-
setSelectedVideoId:
|
|
600
|
-
showMediaControls:
|
|
601
|
-
videoOptions:
|
|
290
|
+
setSelectedSource: a,
|
|
291
|
+
setSelectedVideoId: s,
|
|
292
|
+
showMediaControls: l,
|
|
293
|
+
videoOptions: c
|
|
602
294
|
}) => {
|
|
603
|
-
const [d,
|
|
604
|
-
return
|
|
295
|
+
const [d, h] = S(!1), b = ["webcam", "image", "video"].filter((f) => f === "image" ? t.length > 0 : f === "video" ? c.length > 0 : !0);
|
|
296
|
+
return l ? d ? /* @__PURE__ */ g(
|
|
605
297
|
"button",
|
|
606
298
|
{
|
|
607
299
|
type: "button",
|
|
608
|
-
onClick: () =>
|
|
300
|
+
onClick: () => h(!1),
|
|
609
301
|
"aria-label": "Open media controls",
|
|
610
302
|
title: "Open media controls",
|
|
611
303
|
style: {
|
|
@@ -626,7 +318,7 @@ const We = (e) => {
|
|
|
626
318
|
},
|
|
627
319
|
children: "≡"
|
|
628
320
|
}
|
|
629
|
-
) : /* @__PURE__ */ z(
|
|
321
|
+
) : /* @__PURE__ */ z(P, { children: [
|
|
630
322
|
/* @__PURE__ */ z(
|
|
631
323
|
"div",
|
|
632
324
|
{
|
|
@@ -642,7 +334,7 @@ const We = (e) => {
|
|
|
642
334
|
maxWidth: "calc(100vw - 32px)"
|
|
643
335
|
},
|
|
644
336
|
children: [
|
|
645
|
-
/* @__PURE__ */
|
|
337
|
+
/* @__PURE__ */ g(
|
|
646
338
|
"div",
|
|
647
339
|
{
|
|
648
340
|
style: {
|
|
@@ -657,15 +349,15 @@ const We = (e) => {
|
|
|
657
349
|
backdropFilter: "blur(10px)",
|
|
658
350
|
overflowX: "auto"
|
|
659
351
|
},
|
|
660
|
-
children:
|
|
661
|
-
const
|
|
352
|
+
children: b.map((f) => {
|
|
353
|
+
const w = f === n;
|
|
662
354
|
return /* @__PURE__ */ z(
|
|
663
355
|
"button",
|
|
664
356
|
{
|
|
665
357
|
type: "button",
|
|
666
|
-
onClick: () =>
|
|
667
|
-
"aria-pressed":
|
|
668
|
-
title:
|
|
358
|
+
onClick: () => a(f),
|
|
359
|
+
"aria-pressed": w,
|
|
360
|
+
title: D[f].label,
|
|
669
361
|
style: {
|
|
670
362
|
border: "none",
|
|
671
363
|
borderRadius: 999,
|
|
@@ -676,26 +368,26 @@ const We = (e) => {
|
|
|
676
368
|
alignItems: "center",
|
|
677
369
|
justifyContent: "center",
|
|
678
370
|
gap: 8,
|
|
679
|
-
background:
|
|
680
|
-
color:
|
|
371
|
+
background: w ? "rgba(56, 189, 248, 0.18)" : "rgba(255,255,255,0.04)",
|
|
372
|
+
color: w ? "#e0f2fe" : "rgba(229,238,251,0.82)",
|
|
681
373
|
cursor: "pointer",
|
|
682
374
|
flex: "0 0 auto"
|
|
683
375
|
},
|
|
684
376
|
children: [
|
|
685
|
-
/* @__PURE__ */
|
|
686
|
-
/* @__PURE__ */
|
|
377
|
+
/* @__PURE__ */ g("span", { style: { fontSize: 14, lineHeight: 1 }, children: D[f].icon }),
|
|
378
|
+
/* @__PURE__ */ g("span", { style: { fontSize: 12, fontWeight: 700, letterSpacing: "0.01em" }, children: D[f].label })
|
|
687
379
|
]
|
|
688
380
|
},
|
|
689
|
-
|
|
381
|
+
f
|
|
690
382
|
);
|
|
691
383
|
})
|
|
692
384
|
}
|
|
693
385
|
),
|
|
694
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ g(
|
|
695
387
|
"button",
|
|
696
388
|
{
|
|
697
389
|
type: "button",
|
|
698
|
-
onClick: () =>
|
|
390
|
+
onClick: () => h(!0),
|
|
699
391
|
"aria-label": "Close media controls",
|
|
700
392
|
title: "Close media controls",
|
|
701
393
|
style: {
|
|
@@ -716,226 +408,861 @@ const We = (e) => {
|
|
|
716
408
|
]
|
|
717
409
|
}
|
|
718
410
|
),
|
|
719
|
-
|
|
720
|
-
|
|
411
|
+
n === "image" && t.length > 0 && /* @__PURE__ */ g(
|
|
412
|
+
J,
|
|
721
413
|
{
|
|
722
414
|
dock: e,
|
|
723
415
|
label: "Image Asset",
|
|
724
416
|
options: t,
|
|
725
|
-
value:
|
|
417
|
+
value: r,
|
|
726
418
|
onChange: i
|
|
727
419
|
}
|
|
728
420
|
),
|
|
729
|
-
|
|
730
|
-
|
|
421
|
+
n === "video" && c.length > 0 && /* @__PURE__ */ g(
|
|
422
|
+
J,
|
|
731
423
|
{
|
|
732
424
|
dock: e,
|
|
733
425
|
label: "Video Asset",
|
|
734
|
-
options:
|
|
735
|
-
value:
|
|
736
|
-
onChange:
|
|
426
|
+
options: c,
|
|
427
|
+
value: o,
|
|
428
|
+
onChange: s
|
|
737
429
|
}
|
|
738
430
|
)
|
|
739
431
|
] }) : null;
|
|
740
|
-
},
|
|
432
|
+
}, ke = ({
|
|
433
|
+
containerRef: e,
|
|
434
|
+
displayCanvasRef: t,
|
|
435
|
+
imageOptions: r,
|
|
436
|
+
imageRef: n,
|
|
437
|
+
layout: o,
|
|
438
|
+
managesOwnMedia: i,
|
|
439
|
+
mediaDock: a,
|
|
440
|
+
mode: s,
|
|
441
|
+
overlayContent: l,
|
|
442
|
+
renderOutputs: c,
|
|
443
|
+
sceneContent: d,
|
|
444
|
+
selectedImageId: h,
|
|
445
|
+
selectedSource: b,
|
|
446
|
+
selectedVideoId: f,
|
|
447
|
+
setSceneRenderOutputs: w,
|
|
448
|
+
setSelectedImageId: m,
|
|
449
|
+
setSelectedSource: p,
|
|
450
|
+
setSelectedVideoId: y,
|
|
451
|
+
showMediaControls: T,
|
|
452
|
+
style: R,
|
|
453
|
+
videoOptions: v,
|
|
454
|
+
videoRef: E,
|
|
455
|
+
viewportSize: x,
|
|
456
|
+
mirrored: u
|
|
457
|
+
}) => /* @__PURE__ */ z(
|
|
458
|
+
"div",
|
|
459
|
+
{
|
|
460
|
+
ref: e,
|
|
461
|
+
style: {
|
|
462
|
+
position: "fixed",
|
|
463
|
+
inset: 0,
|
|
464
|
+
overflow: "hidden",
|
|
465
|
+
background: "#000",
|
|
466
|
+
...R
|
|
467
|
+
},
|
|
468
|
+
children: [
|
|
469
|
+
/* @__PURE__ */ g(Te, { imageRef: n, selectedSource: b, videoRef: E }),
|
|
470
|
+
s === "dom" && i && /* @__PURE__ */ g(
|
|
471
|
+
Se,
|
|
472
|
+
{
|
|
473
|
+
canvasRef: t,
|
|
474
|
+
imageRef: n,
|
|
475
|
+
videoRef: E,
|
|
476
|
+
layer: Ee,
|
|
477
|
+
layout: o,
|
|
478
|
+
mirrored: u,
|
|
479
|
+
sourceKind: b === "image" ? "image" : "video"
|
|
480
|
+
}
|
|
481
|
+
),
|
|
482
|
+
(s === "r3f" || s === "hybrid") && /* @__PURE__ */ g(W, { config: Me, children: /* @__PURE__ */ g(
|
|
483
|
+
ve,
|
|
484
|
+
{
|
|
485
|
+
onRenderOutputs: w,
|
|
486
|
+
renderOutputs: {
|
|
487
|
+
sceneColor: c.sceneColor || c.finalColor,
|
|
488
|
+
sceneDepth: c.sceneDepth
|
|
489
|
+
},
|
|
490
|
+
renderTargetSize: x,
|
|
491
|
+
style: { width: "100%", height: "100%" },
|
|
492
|
+
children: d
|
|
493
|
+
}
|
|
494
|
+
) }),
|
|
495
|
+
/* @__PURE__ */ z(W, { config: Ie, children: [
|
|
496
|
+
i && /* @__PURE__ */ g(
|
|
497
|
+
Fe,
|
|
498
|
+
{
|
|
499
|
+
dock: a,
|
|
500
|
+
imageOptions: r,
|
|
501
|
+
selectedImageId: h,
|
|
502
|
+
selectedSource: b,
|
|
503
|
+
selectedVideoId: f,
|
|
504
|
+
setSelectedImageId: m,
|
|
505
|
+
setSelectedSource: p,
|
|
506
|
+
setSelectedVideoId: y,
|
|
507
|
+
showMediaControls: T,
|
|
508
|
+
videoOptions: v
|
|
509
|
+
}
|
|
510
|
+
),
|
|
511
|
+
l
|
|
512
|
+
] })
|
|
513
|
+
]
|
|
514
|
+
}
|
|
515
|
+
), Le = 5, ze = 1, Xe = (e, t) => t, De = "brightness(2.2) contrast(1.5) saturate(1.25)", Ve = ({
|
|
516
|
+
enabled: e,
|
|
517
|
+
displayMirrored: t,
|
|
518
|
+
imageRef: r,
|
|
519
|
+
layout: n,
|
|
520
|
+
mode: o,
|
|
521
|
+
numFaces: i,
|
|
522
|
+
selectedSource: a,
|
|
523
|
+
sourceStream: s,
|
|
524
|
+
videoRef: l
|
|
525
|
+
}) => {
|
|
526
|
+
const { session: c } = ue(), d = L(null), h = L(!1), b = L(document.createElement("canvas")), {
|
|
527
|
+
ready: f,
|
|
528
|
+
node: w,
|
|
529
|
+
error: m
|
|
530
|
+
} = he(te.FACE_TRACKER, {
|
|
531
|
+
numFaces: i ?? (o === "head-binding" ? ze : Le)
|
|
532
|
+
}), [p, y] = S("idle"), [T, R] = S(null), v = e && f && !!w, E = re({
|
|
533
|
+
node: v ? w : null,
|
|
534
|
+
enabled: v,
|
|
535
|
+
selectedSource: a,
|
|
536
|
+
onFrame: fe(() => {
|
|
537
|
+
R(null), y("ready");
|
|
538
|
+
}, [])
|
|
539
|
+
});
|
|
540
|
+
return F(() => {
|
|
541
|
+
if (!e || !n) return;
|
|
542
|
+
const x = () => {
|
|
543
|
+
const C = a === "image" ? r.current : l.current;
|
|
544
|
+
if (C) {
|
|
545
|
+
if (C instanceof HTMLImageElement) {
|
|
546
|
+
if (!C.complete || C.naturalWidth <= 0 || C.naturalHeight <= 0) return;
|
|
547
|
+
} else if (C.readyState < 2 || C.videoWidth <= 0 || C.videoHeight <= 0)
|
|
548
|
+
return;
|
|
549
|
+
N({
|
|
550
|
+
canvas: b.current,
|
|
551
|
+
layout: n,
|
|
552
|
+
media: C,
|
|
553
|
+
mirrored: t,
|
|
554
|
+
filter: a === "webcam" ? De : void 0
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
if (a === "image") {
|
|
559
|
+
x();
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
let u = 0;
|
|
563
|
+
const I = () => {
|
|
564
|
+
u = requestAnimationFrame(I), x();
|
|
565
|
+
};
|
|
566
|
+
return u = requestAnimationFrame(I), () => cancelAnimationFrame(u);
|
|
567
|
+
}, [t, e, r, n, a, l]), F(() => {
|
|
568
|
+
var A;
|
|
569
|
+
if (!e) {
|
|
570
|
+
y("idle"), R(null), h.current = !1, d.current = null;
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (!n) {
|
|
574
|
+
y("initializing");
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
const x = (s == null ? void 0 : s.id) ?? (((A = l.current) == null ? void 0 : A.srcObject) instanceof MediaStream ? l.current.srcObject.id : "none"), I = a === "webcam" ? `webcam:${x}` : a;
|
|
578
|
+
d.current !== I && (h.current = !1, d.current = I);
|
|
579
|
+
let C = !1;
|
|
580
|
+
return (async () => {
|
|
581
|
+
try {
|
|
582
|
+
if (y("initializing"), h.current || (await c.setFrameSource({
|
|
583
|
+
canvas: b.current,
|
|
584
|
+
sourceKind: a
|
|
585
|
+
}), await c.start(), h.current = !0), C) return;
|
|
586
|
+
R(null), y("initializing");
|
|
587
|
+
} catch (k) {
|
|
588
|
+
if (C) return;
|
|
589
|
+
y("error"), R(k instanceof Error ? k.message : "Failed to initialize SDK face tracking");
|
|
590
|
+
}
|
|
591
|
+
})(), () => {
|
|
592
|
+
C = !0;
|
|
593
|
+
};
|
|
594
|
+
}, [e, n, a, c, s, l]), F(() => {
|
|
595
|
+
!v && e && !m && y("initializing");
|
|
596
|
+
}, [v, e, m]), F(() => {
|
|
597
|
+
m && (y("error"), R(m.message));
|
|
598
|
+
}, [m]), F(() => () => {
|
|
599
|
+
h.current = !1, c.stop();
|
|
600
|
+
}, [c]), {
|
|
601
|
+
activeDelegate: "GPU",
|
|
602
|
+
faces: E,
|
|
603
|
+
status: p,
|
|
604
|
+
error: T
|
|
605
|
+
};
|
|
606
|
+
}, Ae = (e, t) => e === "auto" ? t === "webcam" ? "cover" : "contain" : e, Be = ({
|
|
607
|
+
imageOptions: e,
|
|
608
|
+
initialImageId: t,
|
|
609
|
+
initialSource: r,
|
|
610
|
+
initialVideoId: n,
|
|
611
|
+
source: o,
|
|
612
|
+
videoOptions: i
|
|
613
|
+
}) => {
|
|
614
|
+
var l, c, d, h;
|
|
615
|
+
const a = (o == null ? void 0 : o.kind) ?? r ?? "webcam";
|
|
616
|
+
return {
|
|
617
|
+
selectedSource: a === "image" && e.length === 0 || a === "video" && i.length === 0 ? "webcam" : a,
|
|
618
|
+
selectedImageId: (o == null ? void 0 : o.kind) === "image" ? o.assetId ?? ((l = e[0]) == null ? void 0 : l.id) ?? "" : t ?? ((c = e[0]) == null ? void 0 : c.id) ?? "",
|
|
619
|
+
selectedVideoId: (o == null ? void 0 : o.kind) === "video" ? o.assetId ?? ((d = i[0]) == null ? void 0 : d.id) ?? "" : n ?? ((h = i[0]) == null ? void 0 : h.id) ?? ""
|
|
620
|
+
};
|
|
621
|
+
}, We = (e, t, r) => {
|
|
622
|
+
if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0)
|
|
623
|
+
return null;
|
|
624
|
+
const n = r === "contain" ? Math.min(t.width / e.width, t.height / e.height) : Math.max(t.width / e.width, t.height / e.height), o = e.width * n, i = e.height * n;
|
|
625
|
+
return {
|
|
626
|
+
source: e,
|
|
627
|
+
destination: t,
|
|
628
|
+
drawWidth: o,
|
|
629
|
+
drawHeight: i,
|
|
630
|
+
offsetX: (t.width - o) * 0.5,
|
|
631
|
+
offsetY: (t.height - i) * 0.5,
|
|
632
|
+
scale: n
|
|
633
|
+
};
|
|
634
|
+
}, Pe = (e) => {
|
|
635
|
+
if (!e) return { width: 0, height: 0 };
|
|
636
|
+
const t = e.getBoundingClientRect();
|
|
637
|
+
return {
|
|
638
|
+
width: t.width || e.clientWidth,
|
|
639
|
+
height: t.height || e.clientHeight
|
|
640
|
+
};
|
|
641
|
+
}, He = (e) => {
|
|
642
|
+
const [t, r] = S({ width: 0, height: 0 });
|
|
643
|
+
return me(() => {
|
|
644
|
+
const n = e.current;
|
|
645
|
+
if (!n) return;
|
|
646
|
+
let o = 0;
|
|
647
|
+
const i = () => {
|
|
648
|
+
const c = Pe(n);
|
|
649
|
+
r(
|
|
650
|
+
(d) => d.width === c.width && d.height === c.height ? d : c
|
|
651
|
+
);
|
|
652
|
+
}, a = () => {
|
|
653
|
+
i(), o && cancelAnimationFrame(o), o = requestAnimationFrame(i);
|
|
654
|
+
};
|
|
655
|
+
a();
|
|
656
|
+
const s = new ResizeObserver(a);
|
|
657
|
+
s.observe(n);
|
|
658
|
+
const l = window.visualViewport;
|
|
659
|
+
return window.addEventListener("resize", a), window.addEventListener("orientationchange", a), l == null || l.addEventListener("resize", a), l == null || l.addEventListener("scroll", a), () => {
|
|
660
|
+
o && cancelAnimationFrame(o), s.disconnect(), window.removeEventListener("resize", a), window.removeEventListener("orientationchange", a), l == null || l.removeEventListener("resize", a), l == null || l.removeEventListener("scroll", a);
|
|
661
|
+
};
|
|
662
|
+
}, [e]), t;
|
|
663
|
+
}, _e = ({
|
|
741
664
|
enabled: e,
|
|
742
665
|
selectedSource: t
|
|
743
666
|
}) => {
|
|
744
|
-
const
|
|
667
|
+
const r = pe(te.FACE_TRACKER);
|
|
745
668
|
return {
|
|
746
|
-
faces:
|
|
747
|
-
trackerStatus:
|
|
669
|
+
faces: re({ node: r, enabled: e, selectedSource: t }),
|
|
670
|
+
trackerStatus: r ? "ready" : "idle"
|
|
671
|
+
};
|
|
672
|
+
}, O = (e) => {
|
|
673
|
+
e && (e.pause(), e.removeAttribute("src"), e.srcObject = null, e.load());
|
|
674
|
+
}, Q = (e) => {
|
|
675
|
+
e && e.removeAttribute("src");
|
|
676
|
+
}, $e = ({
|
|
677
|
+
enabled: e,
|
|
678
|
+
imageAsset: t,
|
|
679
|
+
selectedSource: r,
|
|
680
|
+
videoAsset: n
|
|
681
|
+
}) => {
|
|
682
|
+
const o = L(null), i = L(null), [a, s] = S(null), [l, c] = S({ width: 0, height: 0 }), [d, h] = S("idle"), [b, f] = S(null);
|
|
683
|
+
return F(() => {
|
|
684
|
+
if (!e) {
|
|
685
|
+
O(o.current), Q(i.current), s(null), c({ width: 0, height: 0 }), h("idle"), f(null);
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
let w = !1, m = null;
|
|
689
|
+
const p = (x, u) => {
|
|
690
|
+
w || (c({ width: x, height: u }), h("ready"), f(null));
|
|
691
|
+
}, y = () => {
|
|
692
|
+
O(o.current), Q(i.current), m == null || m.getTracks().forEach((x) => x.stop()), m = null, s(null);
|
|
693
|
+
}, T = async () => {
|
|
694
|
+
h("requesting");
|
|
695
|
+
const x = await navigator.mediaDevices.getUserMedia(Re);
|
|
696
|
+
if (w) {
|
|
697
|
+
x.getTracks().forEach((I) => I.stop());
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
m = x, s(x);
|
|
701
|
+
const u = o.current;
|
|
702
|
+
u && (u.srcObject = x, u.muted = !0, u.playsInline = !0, u.autoplay = !0, await u.play(), p(u.videoWidth, u.videoHeight));
|
|
703
|
+
}, R = async (x) => {
|
|
704
|
+
h("requesting"), s(null);
|
|
705
|
+
const u = o.current;
|
|
706
|
+
u && (u.src = x, u.muted = !0, u.loop = !0, u.playsInline = !0, u.autoplay = !0, u.crossOrigin = "anonymous", await u.play(), p(u.videoWidth, u.videoHeight));
|
|
707
|
+
}, v = async (x) => {
|
|
708
|
+
h("requesting"), s(null);
|
|
709
|
+
const u = i.current;
|
|
710
|
+
u && (await new Promise((I, C) => {
|
|
711
|
+
u.onload = () => I(), u.onerror = () => C(new Error("Unable to load image")), u.src = x;
|
|
712
|
+
}), p(u.naturalWidth, u.naturalHeight));
|
|
713
|
+
};
|
|
714
|
+
return y(), (async () => {
|
|
715
|
+
try {
|
|
716
|
+
if (r === "webcam") {
|
|
717
|
+
await T();
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (r === "video") {
|
|
721
|
+
if (!(n != null && n.src)) throw new Error("Missing video source");
|
|
722
|
+
await R(n.src);
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
if (!(t != null && t.src)) throw new Error("Missing image source");
|
|
726
|
+
await v(t.src);
|
|
727
|
+
} catch (x) {
|
|
728
|
+
if (w) return;
|
|
729
|
+
h("error"), f(x instanceof Error ? x.message : `Unable to initialize ${r}`);
|
|
730
|
+
}
|
|
731
|
+
})(), () => {
|
|
732
|
+
w = !0, y();
|
|
733
|
+
};
|
|
734
|
+
}, [e, t, r, n]), {
|
|
735
|
+
videoRef: o,
|
|
736
|
+
imageRef: i,
|
|
737
|
+
stream: a,
|
|
738
|
+
mediaSize: l,
|
|
739
|
+
status: d,
|
|
740
|
+
error: b
|
|
741
|
+
};
|
|
742
|
+
}, qe = ({
|
|
743
|
+
enabled: e,
|
|
744
|
+
imageRef: t,
|
|
745
|
+
selectedSource: r,
|
|
746
|
+
status: n,
|
|
747
|
+
videoRef: o
|
|
748
|
+
}) => {
|
|
749
|
+
const [i, a] = S(null);
|
|
750
|
+
return F(() => {
|
|
751
|
+
if (!e || n !== "ready") {
|
|
752
|
+
a((c) => (c == null || c.dispose(), null));
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
const s = r === "image" ? t.current : o.current;
|
|
756
|
+
if (!s) return;
|
|
757
|
+
const l = r === "image" ? new V.Texture(s) : new V.VideoTexture(s);
|
|
758
|
+
return l.colorSpace = V.SRGBColorSpace, l.minFilter = V.LinearFilter, l.magFilter = V.LinearFilter, l.generateMipmaps = !1, l.needsUpdate = !0, a((c) => (c == null || c.dispose(), l)), () => {
|
|
759
|
+
l.dispose();
|
|
760
|
+
};
|
|
761
|
+
}, [e, t, r, n, o]), i;
|
|
762
|
+
}, Ne = ({
|
|
763
|
+
externalTracker: e,
|
|
764
|
+
imageOptions: t,
|
|
765
|
+
layout: r,
|
|
766
|
+
managesOwnMedia: n,
|
|
767
|
+
mediaError: o,
|
|
768
|
+
mediaFitMode: i,
|
|
769
|
+
mediaSize: a,
|
|
770
|
+
mediaStatus: s,
|
|
771
|
+
mirrored: l,
|
|
772
|
+
selectedImage: c,
|
|
773
|
+
selectedImageId: d,
|
|
774
|
+
selectedSource: h,
|
|
775
|
+
selectedVideo: b,
|
|
776
|
+
selectedVideoId: f,
|
|
777
|
+
setMirrored: w,
|
|
778
|
+
setSelectedImageId: m,
|
|
779
|
+
setSelectedSource: p,
|
|
780
|
+
setSelectedVideoId: y,
|
|
781
|
+
setShowMediaControls: T,
|
|
782
|
+
showMediaControls: R,
|
|
783
|
+
tracker: v,
|
|
784
|
+
videoOptions: E,
|
|
785
|
+
viewportSize: x
|
|
786
|
+
}) => {
|
|
787
|
+
const u = h === "image" ? `${D.image.label}: ${(c == null ? void 0 : c.label) ?? ""}` : h === "video" ? `${D.video.label}: ${(b == null ? void 0 : b.label) ?? ""}` : D.webcam.label;
|
|
788
|
+
return {
|
|
789
|
+
activeDelegate: n ? v.activeDelegate : null,
|
|
790
|
+
faces: n ? v.faces : e.faces,
|
|
791
|
+
imageOptions: t,
|
|
792
|
+
layout: r,
|
|
793
|
+
mediaError: o,
|
|
794
|
+
mediaFitMode: i,
|
|
795
|
+
mediaLabel: u,
|
|
796
|
+
mediaStatus: s,
|
|
797
|
+
mirrored: l,
|
|
798
|
+
selectedImageId: d,
|
|
799
|
+
selectedSource: h,
|
|
800
|
+
selectedVideoId: f,
|
|
801
|
+
setMirrored: w,
|
|
802
|
+
setSelectedImageId: m,
|
|
803
|
+
setSelectedSource: p,
|
|
804
|
+
setSelectedVideoId: y,
|
|
805
|
+
setShowMediaControls: T,
|
|
806
|
+
showMediaControls: R,
|
|
807
|
+
trackerError: n ? v.error : null,
|
|
808
|
+
trackerStatus: n ? v.status : e.trackerStatus,
|
|
809
|
+
videoOptions: E,
|
|
810
|
+
viewportSize: x,
|
|
811
|
+
mediaSize: a
|
|
812
|
+
};
|
|
813
|
+
}, Ue = ({
|
|
814
|
+
mediaTexture: e,
|
|
815
|
+
previewMode: t,
|
|
816
|
+
renderOutputs: r,
|
|
817
|
+
sceneRenderOutputs: n
|
|
818
|
+
}) => q(
|
|
819
|
+
() => ({
|
|
820
|
+
requested: r,
|
|
821
|
+
previewMode: t,
|
|
822
|
+
mediaColorTexture: e,
|
|
823
|
+
sceneColorTexture: n.sceneColorTexture,
|
|
824
|
+
finalColorTexture: r.finalColor ? n.sceneColorTexture : null,
|
|
825
|
+
sceneDepthTexture: n.sceneDepthTexture,
|
|
826
|
+
estimatedDepthTexture: null,
|
|
827
|
+
available: {
|
|
828
|
+
mediaColor: e !== null,
|
|
829
|
+
sceneColor: n.sceneColorTexture !== null,
|
|
830
|
+
finalColor: !!(r.finalColor && n.sceneColorTexture),
|
|
831
|
+
sceneDepth: n.sceneDepthTexture !== null,
|
|
832
|
+
estimatedDepth: !1
|
|
833
|
+
}
|
|
834
|
+
}),
|
|
835
|
+
[e, t, r, n]
|
|
836
|
+
), je = ({
|
|
837
|
+
fitMode: e,
|
|
838
|
+
imageOptions: t,
|
|
839
|
+
initialImageId: r,
|
|
840
|
+
initialMirrored: n,
|
|
841
|
+
initialSource: o,
|
|
842
|
+
initialVideoId: i,
|
|
843
|
+
mediaStrategy: a,
|
|
844
|
+
previewMode: s,
|
|
845
|
+
renderOutputs: l,
|
|
846
|
+
showMediaControlsByDefault: c,
|
|
847
|
+
source: d,
|
|
848
|
+
videoOptions: h
|
|
849
|
+
}) => {
|
|
850
|
+
const b = L(null), f = L(null), w = He(b), m = q(
|
|
851
|
+
() => Be({
|
|
852
|
+
imageOptions: t,
|
|
853
|
+
initialImageId: r,
|
|
854
|
+
initialSource: o,
|
|
855
|
+
initialVideoId: i,
|
|
856
|
+
source: d,
|
|
857
|
+
videoOptions: h
|
|
858
|
+
}),
|
|
859
|
+
[t, r, o, i, d, h]
|
|
860
|
+
), [p, y] = S(n), [T, R] = S(c), [v, E] = S(
|
|
861
|
+
m.selectedSource
|
|
862
|
+
), [x, u] = S(m.selectedImageId), [I, C] = S(m.selectedVideoId), [K, A] = S({
|
|
863
|
+
sceneColorTexture: null,
|
|
864
|
+
sceneDepthTexture: null
|
|
865
|
+
}), k = a === "internal";
|
|
866
|
+
F(() => {
|
|
867
|
+
d && (E(m.selectedSource), u(m.selectedImageId), C(m.selectedVideoId));
|
|
868
|
+
}, [m, d]);
|
|
869
|
+
const G = t.find(($) => $.id === x) ?? t[0], Y = h.find(($) => $.id === I) ?? h[0], M = $e({
|
|
870
|
+
enabled: k,
|
|
871
|
+
imageAsset: G,
|
|
872
|
+
selectedSource: v,
|
|
873
|
+
videoAsset: Y
|
|
874
|
+
}), H = Ae(e, v), B = q(
|
|
875
|
+
() => We(M.mediaSize, w, H),
|
|
876
|
+
[M.mediaSize, H, w]
|
|
877
|
+
), oe = qe({
|
|
878
|
+
enabled: !!(l.mediaColor || l.finalColor),
|
|
879
|
+
imageRef: M.imageRef,
|
|
880
|
+
selectedSource: v,
|
|
881
|
+
status: M.status,
|
|
882
|
+
videoRef: M.videoRef
|
|
883
|
+
}), _ = Xe(v, p), ie = Ve({
|
|
884
|
+
displayMirrored: _,
|
|
885
|
+
enabled: k && M.status === "ready" && B !== null,
|
|
886
|
+
imageRef: M.imageRef,
|
|
887
|
+
layout: B,
|
|
888
|
+
selectedSource: v,
|
|
889
|
+
sourceStream: M.stream,
|
|
890
|
+
videoRef: M.videoRef
|
|
891
|
+
}), ae = _e({
|
|
892
|
+
enabled: !k,
|
|
893
|
+
selectedSource: v
|
|
894
|
+
}), se = Ne({
|
|
895
|
+
externalTracker: ae,
|
|
896
|
+
imageOptions: t,
|
|
897
|
+
layout: B,
|
|
898
|
+
managesOwnMedia: k,
|
|
899
|
+
mediaError: M.error,
|
|
900
|
+
mediaFitMode: H,
|
|
901
|
+
mediaSize: M.mediaSize,
|
|
902
|
+
mediaStatus: M.status,
|
|
903
|
+
mirrored: _,
|
|
904
|
+
selectedImage: G,
|
|
905
|
+
selectedImageId: x,
|
|
906
|
+
selectedSource: v,
|
|
907
|
+
selectedVideo: Y,
|
|
908
|
+
selectedVideoId: I,
|
|
909
|
+
setMirrored: y,
|
|
910
|
+
setSelectedImageId: u,
|
|
911
|
+
setSelectedSource: E,
|
|
912
|
+
setSelectedVideoId: C,
|
|
913
|
+
setShowMediaControls: R,
|
|
914
|
+
showMediaControls: T,
|
|
915
|
+
tracker: ie,
|
|
916
|
+
videoOptions: h,
|
|
917
|
+
viewportSize: w
|
|
918
|
+
}), le = Ue({
|
|
919
|
+
mediaTexture: oe,
|
|
920
|
+
previewMode: s,
|
|
921
|
+
renderOutputs: l,
|
|
922
|
+
sceneRenderOutputs: K
|
|
923
|
+
});
|
|
924
|
+
return {
|
|
925
|
+
containerRef: b,
|
|
926
|
+
displayCanvasRef: f,
|
|
927
|
+
displayMirrored: _,
|
|
928
|
+
layout: B,
|
|
929
|
+
managesOwnMedia: k,
|
|
930
|
+
media: M,
|
|
931
|
+
renderOutputState: le,
|
|
932
|
+
renderState: se,
|
|
933
|
+
selectedImageId: x,
|
|
934
|
+
selectedSource: v,
|
|
935
|
+
selectedVideoId: I,
|
|
936
|
+
setSceneRenderOutputs: A,
|
|
937
|
+
setSelectedImageId: u,
|
|
938
|
+
setSelectedSource: E,
|
|
939
|
+
setSelectedVideoId: C,
|
|
940
|
+
showMediaControls: T,
|
|
941
|
+
viewportSize: w
|
|
942
|
+
};
|
|
943
|
+
}, U = ({ children: e }) => /* @__PURE__ */ g(P, { children: e });
|
|
944
|
+
U.displayName = "XRViewport.Scene";
|
|
945
|
+
const j = ({ children: e }) => /* @__PURE__ */ g(P, { children: e });
|
|
946
|
+
j.displayName = "XRViewport.Overlay";
|
|
947
|
+
const Ke = (e, t) => {
|
|
948
|
+
if (e === "dom")
|
|
949
|
+
return {
|
|
950
|
+
sceneContent: null,
|
|
951
|
+
overlayContent: t
|
|
952
|
+
};
|
|
953
|
+
let r = null, n = null;
|
|
954
|
+
const o = [];
|
|
955
|
+
return ge.forEach(t, (i) => {
|
|
956
|
+
var s;
|
|
957
|
+
if (!be(i)) {
|
|
958
|
+
i != null && o.push(i);
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
const a = (s = i.type) == null ? void 0 : s.displayName;
|
|
962
|
+
if (a === U.displayName) {
|
|
963
|
+
r = i.props.children;
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
if (a === j.displayName) {
|
|
967
|
+
n = i.props.children;
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
o.push(i);
|
|
971
|
+
}), !n && o.length > 0 && (n = o), {
|
|
972
|
+
sceneContent: r,
|
|
973
|
+
overlayContent: n
|
|
748
974
|
};
|
|
749
|
-
},
|
|
975
|
+
}, Z = (e, t) => typeof e == "function" ? e(t) : e;
|
|
976
|
+
function Ge(e) {
|
|
977
|
+
return e.Scene = U, e.Overlay = j, e;
|
|
978
|
+
}
|
|
979
|
+
const ct = Ge(({
|
|
750
980
|
children: e,
|
|
751
981
|
fitMode: t = "auto",
|
|
752
|
-
imageOptions:
|
|
753
|
-
initialImageId:
|
|
754
|
-
initialMirrored:
|
|
982
|
+
imageOptions: r = [],
|
|
983
|
+
initialImageId: n,
|
|
984
|
+
initialMirrored: o = !0,
|
|
755
985
|
initialSource: i = "webcam",
|
|
756
|
-
initialVideoId:
|
|
757
|
-
mediaStrategy:
|
|
758
|
-
mediaDock:
|
|
759
|
-
mode:
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
986
|
+
initialVideoId: a,
|
|
987
|
+
mediaStrategy: s = "internal",
|
|
988
|
+
mediaDock: l = "bottom-left",
|
|
989
|
+
mode: c = "dom",
|
|
990
|
+
previewMode: d = "finalColor",
|
|
991
|
+
renderOutputs: h = {},
|
|
992
|
+
showMediaControlsByDefault: b = !0,
|
|
993
|
+
source: f,
|
|
994
|
+
style: w,
|
|
995
|
+
videoOptions: m = []
|
|
764
996
|
}) => {
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
selectedSource: u,
|
|
785
|
-
videoAsset: H
|
|
786
|
-
}), N = Ve(t, u), V = G(
|
|
787
|
-
() => _e(R.mediaSize, S, N),
|
|
788
|
-
[R.mediaSize, N, S]
|
|
789
|
-
), P = Me(u, A), D = ze({
|
|
790
|
-
displayMirrored: P,
|
|
791
|
-
enabled: E && R.status === "ready" && V !== null,
|
|
792
|
-
imageRef: R.imageRef,
|
|
793
|
-
layout: V,
|
|
794
|
-
selectedSource: u,
|
|
795
|
-
sourceStream: R.stream,
|
|
796
|
-
videoRef: R.videoRef
|
|
797
|
-
}), Y = Pe({
|
|
798
|
-
enabled: !E,
|
|
799
|
-
selectedSource: u
|
|
800
|
-
}), ae = u === "image" ? `${X.image.label}: ${(B == null ? void 0 : B.label) ?? ""}` : u === "video" ? `${X.video.label}: ${(H == null ? void 0 : H.label) ?? ""}` : X.webcam.label, _ = {
|
|
801
|
-
activeDelegate: E ? D.activeDelegate : null,
|
|
802
|
-
faces: E ? D.faces : Y.faces,
|
|
803
|
-
imageOptions: n,
|
|
804
|
-
layout: V,
|
|
805
|
-
mediaError: R.error,
|
|
806
|
-
mediaFitMode: N,
|
|
807
|
-
mediaLabel: ae,
|
|
808
|
-
mediaStatus: R.status,
|
|
809
|
-
mirrored: P,
|
|
810
|
-
selectedImageId: C,
|
|
811
|
-
selectedSource: u,
|
|
812
|
-
selectedVideoId: W,
|
|
813
|
-
setMirrored: I,
|
|
814
|
-
setSelectedImageId: x,
|
|
815
|
-
setSelectedSource: l,
|
|
816
|
-
setSelectedVideoId: T,
|
|
817
|
-
setShowMediaControls: L,
|
|
818
|
-
showMediaControls: F,
|
|
819
|
-
trackerError: E ? D.error : null,
|
|
820
|
-
trackerStatus: E ? D.status : Y.trackerStatus,
|
|
821
|
-
videoOptions: c,
|
|
822
|
-
viewportSize: S,
|
|
823
|
-
mediaSize: R.mediaSize
|
|
824
|
-
}, se = typeof e == "function" ? e(_) : e, { sceneContent: le, overlayContent: ce } = $e(m, se), de = Z(
|
|
825
|
-
le,
|
|
826
|
-
_
|
|
827
|
-
), ue = Z(
|
|
828
|
-
ce,
|
|
829
|
-
_
|
|
997
|
+
const p = je({
|
|
998
|
+
fitMode: t,
|
|
999
|
+
imageOptions: r,
|
|
1000
|
+
initialImageId: n,
|
|
1001
|
+
initialMirrored: o,
|
|
1002
|
+
initialSource: i,
|
|
1003
|
+
initialVideoId: a,
|
|
1004
|
+
mediaStrategy: s,
|
|
1005
|
+
previewMode: d,
|
|
1006
|
+
renderOutputs: h,
|
|
1007
|
+
showMediaControlsByDefault: b,
|
|
1008
|
+
source: f,
|
|
1009
|
+
videoOptions: m
|
|
1010
|
+
}), y = typeof e == "function" ? e(p.renderState) : e, { sceneContent: T, overlayContent: R } = Ke(c, y), v = Z(
|
|
1011
|
+
T,
|
|
1012
|
+
p.renderState
|
|
1013
|
+
), E = Z(
|
|
1014
|
+
R,
|
|
1015
|
+
p.renderState
|
|
830
1016
|
);
|
|
831
|
-
return /* @__PURE__ */
|
|
832
|
-
|
|
1017
|
+
return /* @__PURE__ */ g(ye.Provider, { value: p.renderState, children: /* @__PURE__ */ g(Ce.Provider, { value: p.renderOutputState, children: /* @__PURE__ */ g(
|
|
1018
|
+
ke,
|
|
833
1019
|
{
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
layout: V,
|
|
859
|
-
mirrored: P,
|
|
860
|
-
sourceKind: u === "image" ? "image" : "video"
|
|
861
|
-
}
|
|
862
|
-
),
|
|
863
|
-
(m === "r3f" || m === "hybrid") && /* @__PURE__ */ f($, { config: Le, children: /* @__PURE__ */ f(Ce, { renderTargetSize: S, style: { width: "100%", height: "100%" }, children: de }) }),
|
|
864
|
-
/* @__PURE__ */ z($, { config: Ae, children: [
|
|
865
|
-
E && /* @__PURE__ */ f(
|
|
866
|
-
Ne,
|
|
867
|
-
{
|
|
868
|
-
dock: h,
|
|
869
|
-
imageOptions: n,
|
|
870
|
-
selectedImageId: C,
|
|
871
|
-
selectedSource: u,
|
|
872
|
-
selectedVideoId: W,
|
|
873
|
-
setSelectedImageId: x,
|
|
874
|
-
setSelectedSource: l,
|
|
875
|
-
setSelectedVideoId: T,
|
|
876
|
-
showMediaControls: F,
|
|
877
|
-
videoOptions: c
|
|
878
|
-
}
|
|
879
|
-
),
|
|
880
|
-
ue
|
|
881
|
-
] })
|
|
882
|
-
]
|
|
1020
|
+
containerRef: p.containerRef,
|
|
1021
|
+
displayCanvasRef: p.displayCanvasRef,
|
|
1022
|
+
imageOptions: r,
|
|
1023
|
+
imageRef: p.media.imageRef,
|
|
1024
|
+
layout: p.layout,
|
|
1025
|
+
managesOwnMedia: p.managesOwnMedia,
|
|
1026
|
+
mediaDock: l,
|
|
1027
|
+
mirrored: p.displayMirrored,
|
|
1028
|
+
mode: c,
|
|
1029
|
+
overlayContent: E,
|
|
1030
|
+
renderOutputs: h,
|
|
1031
|
+
sceneContent: v,
|
|
1032
|
+
selectedImageId: p.selectedImageId,
|
|
1033
|
+
selectedSource: p.selectedSource,
|
|
1034
|
+
selectedVideoId: p.selectedVideoId,
|
|
1035
|
+
setSceneRenderOutputs: p.setSceneRenderOutputs,
|
|
1036
|
+
setSelectedImageId: p.setSelectedImageId,
|
|
1037
|
+
setSelectedSource: p.setSelectedSource,
|
|
1038
|
+
setSelectedVideoId: p.setSelectedVideoId,
|
|
1039
|
+
showMediaControls: p.showMediaControls,
|
|
1040
|
+
style: w,
|
|
1041
|
+
videoOptions: m,
|
|
1042
|
+
videoRef: p.media.videoRef,
|
|
1043
|
+
viewportSize: p.viewportSize
|
|
883
1044
|
}
|
|
884
|
-
) });
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1045
|
+
) }) });
|
|
1046
|
+
}), Ye = {
|
|
1047
|
+
position: "absolute",
|
|
1048
|
+
top: -28,
|
|
1049
|
+
left: 0,
|
|
1050
|
+
background: "rgba(34, 197, 94, 0.9)",
|
|
1051
|
+
color: "#04130a",
|
|
1052
|
+
fontFamily: "Menlo, Monaco, Consolas, monospace",
|
|
1053
|
+
fontSize: 12,
|
|
1054
|
+
fontWeight: 700,
|
|
1055
|
+
padding: "4px 8px",
|
|
1056
|
+
whiteSpace: "nowrap"
|
|
1057
|
+
}, dt = ({
|
|
1058
|
+
boundingBox: e,
|
|
1059
|
+
label: t = "face bounding box",
|
|
1060
|
+
color: r = "#22c55e",
|
|
1061
|
+
style: n,
|
|
1062
|
+
labelStyle: o
|
|
1063
|
+
}) => /* @__PURE__ */ g(
|
|
1064
|
+
"div",
|
|
1065
|
+
{
|
|
1066
|
+
style: {
|
|
1067
|
+
position: "absolute",
|
|
1068
|
+
left: `${e.left * 100}%`,
|
|
1069
|
+
top: `${e.top * 100}%`,
|
|
1070
|
+
width: `${e.width * 100}%`,
|
|
1071
|
+
height: `${e.height * 100}%`,
|
|
1072
|
+
border: `3px solid ${r}`,
|
|
1073
|
+
boxSizing: "border-box",
|
|
1074
|
+
pointerEvents: "none",
|
|
1075
|
+
zIndex: 20,
|
|
1076
|
+
...n
|
|
1077
|
+
},
|
|
1078
|
+
children: t !== null && /* @__PURE__ */ g("div", { style: { ...Ye, ...o }, children: t })
|
|
1079
|
+
}
|
|
1080
|
+
), ut = (e) => {
|
|
1081
|
+
const [t, r] = S(null);
|
|
1082
|
+
return F(() => {
|
|
1083
|
+
let n = 0;
|
|
1084
|
+
const o = () => {
|
|
1085
|
+
var l, c;
|
|
1086
|
+
n = requestAnimationFrame(o);
|
|
1087
|
+
const i = (c = (l = e == null ? void 0 : e.detectionResults) == null ? void 0 : l.faceLandmarks) == null ? void 0 : c[0];
|
|
896
1088
|
if (!i || i.length === 0) {
|
|
897
|
-
|
|
1089
|
+
r(null);
|
|
898
1090
|
return;
|
|
899
1091
|
}
|
|
900
|
-
const
|
|
901
|
-
left:
|
|
902
|
-
top:
|
|
903
|
-
width:
|
|
904
|
-
height:
|
|
1092
|
+
const a = we(i), s = {
|
|
1093
|
+
left: a.minX,
|
|
1094
|
+
top: a.minY,
|
|
1095
|
+
width: a.width,
|
|
1096
|
+
height: a.height
|
|
905
1097
|
};
|
|
906
|
-
|
|
1098
|
+
r((d) => d && d.left === s.left && d.top === s.top && d.width === s.width && d.height === s.height ? d : s);
|
|
907
1099
|
};
|
|
908
|
-
return
|
|
909
|
-
cancelAnimationFrame(
|
|
1100
|
+
return o(), () => {
|
|
1101
|
+
cancelAnimationFrame(n);
|
|
910
1102
|
};
|
|
911
1103
|
}, [e]), t;
|
|
912
|
-
},
|
|
1104
|
+
}, ht = ({
|
|
1105
|
+
background: e = "#000",
|
|
1106
|
+
children: t,
|
|
1107
|
+
style: r
|
|
1108
|
+
}) => /* @__PURE__ */ g(
|
|
1109
|
+
"div",
|
|
1110
|
+
{
|
|
1111
|
+
style: {
|
|
1112
|
+
position: "fixed",
|
|
1113
|
+
inset: 0,
|
|
1114
|
+
overflow: "hidden",
|
|
1115
|
+
background: e,
|
|
1116
|
+
...r
|
|
1117
|
+
},
|
|
1118
|
+
children: t
|
|
1119
|
+
}
|
|
1120
|
+
), pt = (e) => {
|
|
1121
|
+
const { makeDefault: t = !0, ...r } = e;
|
|
1122
|
+
return /* @__PURE__ */ g(
|
|
1123
|
+
xe,
|
|
1124
|
+
{
|
|
1125
|
+
position: [0, 0, 40],
|
|
1126
|
+
fov: 30,
|
|
1127
|
+
near: 0.1,
|
|
1128
|
+
far: 1e3,
|
|
1129
|
+
makeDefault: t,
|
|
1130
|
+
...r
|
|
1131
|
+
}
|
|
1132
|
+
);
|
|
1133
|
+
}, ft = ["fill", "contain"], mt = (e, t, r, n, o) => {
|
|
1134
|
+
const i = Math.max(1, Math.floor(t)), a = Math.max(0, Math.floor(e)), s = r === "ping-pong" && i > 1 ? i * 2 - 2 : i, l = Math.floor(a / s), c = o > 0 ? l >= o : !n && a >= s, d = c ? s - 1 : a % s;
|
|
1135
|
+
return { frame: r === "reverse" ? i - 1 - d % i : r === "random" ? d * 7919 % i : r === "ping-pong" && d >= i ? s - d : d, ended: c, loop: l };
|
|
1136
|
+
}, gt = (e, t, r) => {
|
|
1137
|
+
const n = Math.max(1, Math.floor(r));
|
|
1138
|
+
return Math.floor(Math.max(0, e) * Math.max(0, t)) % n;
|
|
1139
|
+
};
|
|
1140
|
+
class bt {
|
|
1141
|
+
constructor(t, r) {
|
|
1142
|
+
X(this, "capabilities");
|
|
1143
|
+
X(this, "snapshot");
|
|
1144
|
+
X(this, "listeners", /* @__PURE__ */ new Set());
|
|
1145
|
+
X(this, "eventListeners", /* @__PURE__ */ new Map());
|
|
1146
|
+
this.capabilities = t, this.snapshot = {
|
|
1147
|
+
state: "idle",
|
|
1148
|
+
frame: 0,
|
|
1149
|
+
time: 0,
|
|
1150
|
+
playMode: "forward",
|
|
1151
|
+
loop: !0,
|
|
1152
|
+
loopCount: 0,
|
|
1153
|
+
...r
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
play() {
|
|
1157
|
+
const t = this.snapshot.state === "paused";
|
|
1158
|
+
this.update({ state: "playing" }), this.emit(t ? "Resume" : "PlayBegin");
|
|
1159
|
+
}
|
|
1160
|
+
pause() {
|
|
1161
|
+
this.update({ state: "paused" }), this.emit("Pause");
|
|
1162
|
+
}
|
|
1163
|
+
restart() {
|
|
1164
|
+
this.update({ state: "playing", frame: 0, time: 0 }), this.emit("PlayBegin");
|
|
1165
|
+
}
|
|
1166
|
+
setPlayMode(t) {
|
|
1167
|
+
this.update({ playMode: t });
|
|
1168
|
+
}
|
|
1169
|
+
setLoop(t, r = 0) {
|
|
1170
|
+
this.update({ loop: t, loopCount: r });
|
|
1171
|
+
}
|
|
1172
|
+
seek(t) {
|
|
1173
|
+
this.capabilities.canSeek && this.update({ frame: Math.max(0, Math.floor(t)), time: Math.max(0, t) });
|
|
1174
|
+
}
|
|
1175
|
+
subscribe(t) {
|
|
1176
|
+
return this.listeners.add(t), () => this.listeners.delete(t);
|
|
1177
|
+
}
|
|
1178
|
+
on(t, r) {
|
|
1179
|
+
const n = this.eventListeners.get(t) ?? /* @__PURE__ */ new Set();
|
|
1180
|
+
return n.add(r), this.eventListeners.set(t, n), () => this.off(t, r);
|
|
1181
|
+
}
|
|
1182
|
+
off(t, r) {
|
|
1183
|
+
var n;
|
|
1184
|
+
(n = this.eventListeners.get(t)) == null || n.delete(r);
|
|
1185
|
+
}
|
|
1186
|
+
getSnapshot() {
|
|
1187
|
+
return this.snapshot;
|
|
1188
|
+
}
|
|
1189
|
+
dispose() {
|
|
1190
|
+
this.listeners.clear(), this.eventListeners.clear(), this.snapshot = { ...this.snapshot, state: "idle" };
|
|
1191
|
+
}
|
|
1192
|
+
emit(t) {
|
|
1193
|
+
var r;
|
|
1194
|
+
(r = this.eventListeners.get(t)) == null || r.forEach((n) => n({ type: t, snapshot: this.snapshot }));
|
|
1195
|
+
}
|
|
1196
|
+
update(t) {
|
|
1197
|
+
this.snapshot = { ...this.snapshot, ...t }, this.listeners.forEach((r) => r(this.snapshot));
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
function wt(e) {
|
|
1201
|
+
return async (t, r) => {
|
|
1202
|
+
const n = e.find((o) => o.canResolve(t));
|
|
1203
|
+
if (!n) throw new Je("No texture provider matched source", t);
|
|
1204
|
+
return Oe(n.resolve.bind(n), t, r);
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
class Je extends Error {
|
|
1208
|
+
constructor(r, n) {
|
|
1209
|
+
super(r);
|
|
1210
|
+
X(this, "source");
|
|
1211
|
+
this.name = "TextureSourceLoadError", this.source = n;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
function ee(e) {
|
|
1215
|
+
if (e.aborted)
|
|
1216
|
+
throw new DOMException("Texture source load aborted", "AbortError");
|
|
1217
|
+
}
|
|
1218
|
+
async function Oe(e, t, r) {
|
|
1219
|
+
ee(r);
|
|
1220
|
+
const n = await e(t, r);
|
|
1221
|
+
return r.aborted && (n.dispose(), ee(r)), n;
|
|
1222
|
+
}
|
|
1223
|
+
function xt(e) {
|
|
1224
|
+
e == null || e.dispose();
|
|
1225
|
+
}
|
|
913
1226
|
export {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1227
|
+
bt as BasicAnimatedTextureController,
|
|
1228
|
+
dt as BoundingBoxOverlay,
|
|
1229
|
+
Ct as HeadTracker,
|
|
1230
|
+
pt as PerspectiveCamera,
|
|
1231
|
+
Dt as ScreenRectAspectContext,
|
|
1232
|
+
ft as TEXTURE_FITS,
|
|
1233
|
+
Je as TextureSourceLoadError,
|
|
1234
|
+
ht as XRCompositor,
|
|
1235
|
+
W as XRLayer,
|
|
921
1236
|
Se as XRMediaSurface,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1237
|
+
lt as XRTrackingOverlay,
|
|
1238
|
+
ct as XRViewport,
|
|
1239
|
+
we as computeLandmarkBounds,
|
|
1240
|
+
$t as computeScreenTransform,
|
|
1241
|
+
Lt as createFaceInfoTarget,
|
|
1242
|
+
wt as createTextureSourceResolver,
|
|
1243
|
+
xt as disposeResolvedTextureSource,
|
|
1244
|
+
zt as getFaceInfo,
|
|
1245
|
+
mt as getPlaybackFrame,
|
|
1246
|
+
gt as getSequenceFrame,
|
|
1247
|
+
Vt as getThreeBlending,
|
|
1248
|
+
At as getThreeDepthFunction,
|
|
1249
|
+
Bt as getThreeSide,
|
|
1250
|
+
Ht as hasFullUnitUVBounds,
|
|
1251
|
+
Xe as resolveCalibrationFaceDisplayMirrored,
|
|
1252
|
+
Oe as resolveTextureSource,
|
|
1253
|
+
ee as throwIfAborted,
|
|
1254
|
+
Ve as useCalibrationFaceTracker,
|
|
1255
|
+
ut as useFaceBoundingBox,
|
|
1256
|
+
Wt as useScreenSpace,
|
|
1257
|
+
St as useTrackerContext,
|
|
1258
|
+
Et as useXRCameraTexture,
|
|
1259
|
+
ue as useXRContext,
|
|
1260
|
+
It as useXRError,
|
|
935
1261
|
he as useXRModel,
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1262
|
+
pe as useXRModelNode,
|
|
1263
|
+
Mt as useXRPipelineSnapshot,
|
|
1264
|
+
Tt as useXRReady,
|
|
1265
|
+
Ft as useXRRenderSize,
|
|
1266
|
+
qt as useXRViewportRenderOutputs,
|
|
1267
|
+
Nt as useXRViewportState
|
|
941
1268
|
};
|