@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.
Files changed (362) hide show
  1. package/GROUNDING.md +1813 -27
  2. package/dist/{DebuggerUI-CEfdddkZ.cjs → DebuggerUI-B45_Gb9d.cjs} +1 -1
  3. package/dist/{DebuggerUI-Dgop6Q6o.js → DebuggerUI-Cq28c18s.js} +1 -1
  4. package/dist/FaceMeshRenderer-6t8OsQhK.js +1195 -0
  5. package/dist/FaceMeshRenderer-lQLhYIW-.cjs +155 -0
  6. package/dist/FaceRetouch-CDrL0pXg.js +551 -0
  7. package/dist/FaceRetouch-DtNl8-4e.cjs +134 -0
  8. package/dist/audio/AudioEngine.d.ts +3 -1
  9. package/dist/audio/AudioPlayer.d.ts +29 -0
  10. package/dist/audio/AudioPlayerLogic.d.ts +4 -0
  11. package/dist/audio/index.d.ts +2 -0
  12. package/dist/components/Axes/index.d.ts +6 -0
  13. package/dist/components/FaceMesh/FaceMeshRenderer.d.ts +17 -0
  14. package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +22 -1
  15. package/dist/components/FaceMesh/canonical/FaceMeshMaterial.d.ts +25 -0
  16. package/dist/components/FaceMesh/canonical/assets.d.ts +3 -0
  17. package/dist/components/FaceMesh/canonical/geometryGroups.d.ts +9 -0
  18. package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +2 -0
  19. package/dist/components/FaceMesh/canonical/shaders.d.ts +2 -0
  20. package/dist/components/FaceMesh/deform.d.ts +3 -0
  21. package/dist/components/FaceMesh/index.d.ts +5 -0
  22. package/dist/components/FaceMesh/material/defaults.d.ts +74 -0
  23. package/dist/components/FaceMesh/material/index.d.ts +1 -0
  24. package/dist/components/FaceMesh/material/options.d.ts +5 -1
  25. package/dist/components/FaceMesh/material/support.d.ts +7 -2
  26. package/dist/components/FaceMesh/material/textures.d.ts +4 -0
  27. package/dist/components/FaceMesh/material/types.d.ts +4 -2
  28. package/dist/components/FaceRetouch/Background.d.ts +9 -5
  29. package/dist/components/FaceRetouch/FaceRetouch.d.ts +47 -0
  30. package/dist/components/FaceRetouch/index.d.ts +2 -6
  31. package/dist/components/FaceRetouch/landmarkMask.d.ts +4 -6
  32. package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +4 -7
  33. package/dist/components/FaceTracker/index.d.ts +5 -3
  34. package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +15 -0
  35. package/dist/components/FaceWarp3D/defaults.d.ts +37 -0
  36. package/dist/components/FaceWarp3D/index.d.ts +3 -0
  37. package/dist/components/FaceWarp3D/warp.d.ts +13 -0
  38. package/dist/components/HandJoints2D/index.d.ts +6 -0
  39. package/dist/components/HandTracker/index.d.ts +2 -2
  40. package/dist/components/HandTracking2D/HandVisual.d.ts +12 -0
  41. package/dist/components/HandTracking2D/index.d.ts +5 -0
  42. package/dist/components/HandTracking2DController/index.d.ts +5 -0
  43. package/dist/components/HandTracking3D/index.d.ts +6 -0
  44. package/dist/components/LightObject/index.d.ts +20 -0
  45. package/dist/components/LookAt/index.d.ts +23 -0
  46. package/dist/components/MeshRenderer/index.d.ts +58 -0
  47. package/dist/components/PerspectiveCamera/index.d.ts +2 -8
  48. package/dist/components/PinToMesh/index.d.ts +47 -0
  49. package/dist/components/RenderGroupLayer/index.d.ts +6 -0
  50. package/dist/components/SceneObjectRenderer/index.d.ts +16 -0
  51. package/dist/components/Screen2D/ScreenTransformFrame.d.ts +11 -0
  52. package/dist/components/Screen2D/ScreenTransformHelpers.d.ts +19 -0
  53. package/dist/components/Screen2D/ScreenTransformInteraction.d.ts +18 -0
  54. package/dist/components/Screen2D/index.d.ts +5 -0
  55. package/dist/components/ScreenGlass/defaults.d.ts +3 -0
  56. package/dist/components/ScreenGlass/index.d.ts +5 -0
  57. package/dist/components/ScreenGlass/shaders.d.ts +2 -0
  58. package/dist/components/ScreenGlass/types.d.ts +10 -0
  59. package/dist/components/ScreenGradient/defaults.d.ts +5 -0
  60. package/dist/components/ScreenGradient/index.d.ts +5 -0
  61. package/dist/components/ScreenGradient/shaders.d.ts +2 -0
  62. package/dist/components/ScreenGradient/types.d.ts +19 -0
  63. package/dist/components/ScreenImage/ScreenImage.d.ts +4 -0
  64. package/dist/components/ScreenImage/components/DynamicTextureSync.d.ts +9 -0
  65. package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +9 -0
  66. package/dist/components/ScreenImage/components/ScreenImageFrame.d.ts +9 -0
  67. package/dist/components/ScreenImage/components/ScreenImageTransformFrame.d.ts +9 -0
  68. package/dist/components/ScreenImage/fit.d.ts +52 -0
  69. package/dist/components/ScreenImage/index.d.ts +8 -0
  70. package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +9 -0
  71. package/dist/components/ScreenImage/materials/ScreenImageMatcap.d.ts +3 -0
  72. package/dist/components/ScreenImage/source.d.ts +16 -0
  73. package/dist/components/ScreenImage/types.d.ts +37 -0
  74. package/dist/components/ScreenImage/utils/ScreenImageConstants.d.ts +9 -0
  75. package/dist/components/ScreenImage/utils/ScreenImageHelpers.d.ts +4 -0
  76. package/dist/components/ScreenShape/geometry.d.ts +5 -0
  77. package/dist/components/ScreenShape/index.d.ts +5 -0
  78. package/dist/components/ScreenShape/types.d.ts +41 -0
  79. package/dist/components/ScreenSpaceUI/ScreenTransformGuide.d.ts +15 -0
  80. package/dist/components/ScreenSpaceUI/ScreenTransformOverlayGuide.d.ts +9 -0
  81. package/dist/components/ScreenSpaceUI/index.d.ts +2 -0
  82. package/dist/components/ScreenText/components/ScreenTextBody.d.ts +2 -0
  83. package/dist/components/ScreenText/components/ScreenTextTransformFrame.d.ts +9 -0
  84. package/dist/components/ScreenText/constants.d.ts +5 -0
  85. package/dist/components/ScreenText/index.d.ts +6 -0
  86. package/dist/components/ScreenText/types.d.ts +31 -0
  87. package/dist/components/ScreenText/utils/ScreenTextHelpers.d.ts +14 -0
  88. package/dist/components/ScreenText/utils/ScreenTextMappings.d.ts +17 -0
  89. package/dist/components/SequentialRenderPasses/index.d.ts +6 -0
  90. package/dist/components/TextLabel/TextLabel.d.ts +5 -0
  91. package/dist/components/TextLabel/alignment.d.ts +4 -0
  92. package/dist/components/TextLabel/bend.d.ts +9 -0
  93. package/dist/components/TextLabel/canvas/buildTextLabelTexture.d.ts +4 -0
  94. package/dist/components/TextLabel/canvas/canvasTypography.d.ts +13 -0
  95. package/dist/components/TextLabel/canvas/drawBackground.d.ts +21 -0
  96. package/dist/components/TextLabel/canvas/drawEffects.d.ts +34 -0
  97. package/dist/components/TextLabel/canvas/drawText.d.ts +19 -0
  98. package/dist/components/TextLabel/components/TextLabelMesh.d.ts +13 -0
  99. package/dist/components/TextLabel/constants.d.ts +2 -0
  100. package/dist/components/TextLabel/hooks/useTextLabelTexture.d.ts +7 -0
  101. package/dist/components/TextLabel/index.d.ts +2 -62
  102. package/dist/components/TextLabel/layout/measurement.d.ts +8 -0
  103. package/dist/components/TextLabel/layout/resolveTextLayout.d.ts +25 -0
  104. package/dist/components/TextLabel/layout/wrapText.d.ts +6 -0
  105. package/dist/components/TextLabel/types.d.ts +227 -0
  106. package/dist/components/TrackingAnchor/index.d.ts +18 -2
  107. package/dist/components/Transform3D/index.d.ts +30 -0
  108. package/dist/components/XRMediaSurface/index.d.ts +6 -6
  109. package/dist/components/XRScene/index.d.ts +14 -3
  110. package/dist/components/XRViewport/XRViewport.d.ts +11 -0
  111. package/dist/components/XRViewport/components/HiddenMedia.d.ts +7 -0
  112. package/dist/components/XRViewport/components/MediaAssetPicker.d.ts +8 -0
  113. package/dist/components/XRViewport/components/MediaControlStack.d.ts +13 -0
  114. package/dist/components/XRViewport/components/XRViewportLayers.d.ts +30 -0
  115. package/dist/components/XRViewport/constants.d.ts +24 -0
  116. package/dist/components/XRViewport/contexts.d.ts +6 -0
  117. package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +13 -0
  118. package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +16 -0
  119. package/dist/components/XRViewport/hooks/useViewportMediaTexture.d.ts +10 -0
  120. package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +41 -0
  121. package/dist/components/XRViewport/hooks/useViewportRenderState.d.ts +47 -0
  122. package/dist/components/XRViewport/index.d.ts +3 -101
  123. package/dist/components/XRViewport/layout.d.ts +16 -0
  124. package/dist/components/XRViewport/slots.d.ts +16 -0
  125. package/dist/components/XRViewport/types.d.ts +89 -0
  126. package/dist/components/XRViewport/useViewportSize.d.ts +3 -0
  127. package/dist/components/index.d.ts +19 -0
  128. package/dist/contexts-BKvTIayr.cjs +1 -0
  129. package/dist/contexts-Bk5zz_VR.js +214 -0
  130. package/dist/debug-ui/component-editor/index.d.ts +19 -0
  131. package/dist/debug-ui/default-setting/index.d.ts +37 -0
  132. package/dist/debug-ui/default-setting.cjs +21 -0
  133. package/dist/debug-ui/default-setting.js +777 -0
  134. package/dist/debug-ui/face-mesh-renderer-settings/index.d.ts +8 -0
  135. package/dist/debug-ui/face-retouch/index.d.ts +11 -0
  136. package/dist/debug-ui/face-warp-3d/index.d.ts +6 -0
  137. package/dist/debug-ui/hand-joints-2d/index.d.ts +6 -0
  138. package/dist/debug-ui/hand-tracking-2d/index.d.ts +6 -0
  139. package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +6 -0
  140. package/dist/debug-ui/hand-tracking-3d/index.d.ts +6 -0
  141. package/dist/debug-ui/hierarchy-panel/index.d.ts +29 -0
  142. package/dist/debug-ui/index.d.ts +46 -0
  143. package/dist/debug-ui/layer-panel/index.d.ts +18 -0
  144. package/dist/debug-ui/media-source/MediaSourceSwitcher.d.ts +10 -0
  145. package/dist/debug-ui/media-source/index.d.ts +6 -0
  146. package/dist/debug-ui/media-source/media-preset.d.ts +9 -0
  147. package/dist/debug-ui/media-source/session.d.ts +12 -0
  148. package/dist/debug-ui/media-source.cjs +1 -0
  149. package/dist/debug-ui/media-source.js +9 -0
  150. package/dist/debug-ui/mesh-renderer-settings/index.d.ts +6 -0
  151. package/dist/debug-ui/object-inspector-panel/index.d.ts +25 -0
  152. package/dist/debug-ui/pin-to-mesh-settings/index.d.ts +10 -0
  153. package/dist/debug-ui/scene-editor/context.d.ts +38 -0
  154. package/dist/debug-ui/scene-editor/hierarchy-panel.d.ts +9 -0
  155. package/dist/debug-ui/scene-editor/index.d.ts +11 -0
  156. package/dist/debug-ui/scene-editor/inspector-panel.d.ts +7 -0
  157. package/dist/debug-ui/scene-editor/store-utils.d.ts +2 -0
  158. package/dist/debug-ui/scene-editor/viewport-toolbar.d.ts +4 -0
  159. package/dist/debug-ui/scene-editor/viewport.d.ts +21 -0
  160. package/dist/debug-ui/screen-glass-settings/index.d.ts +6 -0
  161. package/dist/debug-ui/screen-gradient-settings/GradientStopsEditor.d.ts +5 -0
  162. package/dist/debug-ui/screen-gradient-settings/index.d.ts +6 -0
  163. package/dist/debug-ui/screen-gradient-settings/styles.d.ts +3 -0
  164. package/dist/debug-ui/screen-image-settings/index.d.ts +9 -0
  165. package/dist/debug-ui/screen-shape-settings/index.d.ts +6 -0
  166. package/dist/debug-ui/screen-text-settings/NumberField.d.ts +9 -0
  167. package/dist/debug-ui/screen-text-settings/ScreenTextSettingsPanel.d.ts +3 -0
  168. package/dist/debug-ui/screen-text-settings/controls/NestedSection.d.ts +7 -0
  169. package/dist/debug-ui/screen-text-settings/controls/Section.d.ts +8 -0
  170. package/dist/debug-ui/screen-text-settings/controls/icons.d.ts +4 -0
  171. package/dist/debug-ui/screen-text-settings/index.d.ts +2 -0
  172. package/dist/debug-ui/screen-text-settings/sections/BackgroundSection.d.ts +8 -0
  173. package/dist/debug-ui/screen-text-settings/sections/ContentSection.d.ts +5 -0
  174. package/dist/debug-ui/screen-text-settings/sections/EffectsSection.d.ts +25 -0
  175. package/dist/debug-ui/screen-text-settings/sections/StyleSection.d.ts +5 -0
  176. package/dist/debug-ui/screen-text-settings/sections/TransformSection.d.ts +5 -0
  177. package/dist/debug-ui/screen-text-settings/sections/background/BackgroundFillControls.d.ts +2 -0
  178. package/dist/debug-ui/screen-text-settings/sections/background/BackgroundSizeControls.d.ts +2 -0
  179. package/dist/debug-ui/screen-text-settings/sections/background/BackgroundStrokeControls.d.ts +2 -0
  180. package/dist/debug-ui/screen-text-settings/sections/background/types.d.ts +7 -0
  181. package/dist/debug-ui/screen-text-settings/sections/effects/BendEffectSection.d.ts +4 -0
  182. package/dist/debug-ui/screen-text-settings/sections/effects/EffectChrome.d.ts +21 -0
  183. package/dist/debug-ui/screen-text-settings/sections/effects/GlowEffectSection.d.ts +4 -0
  184. package/dist/debug-ui/screen-text-settings/sections/effects/InnerShadowEffectSection.d.ts +4 -0
  185. package/dist/debug-ui/screen-text-settings/sections/effects/OutlineEffectSection.d.ts +4 -0
  186. package/dist/debug-ui/screen-text-settings/sections/effects/ShadowEffectSection.d.ts +4 -0
  187. package/dist/debug-ui/screen-text-settings/sections/effects/types.d.ts +14 -0
  188. package/dist/debug-ui/screen-text-settings/settings.d.ts +90 -0
  189. package/dist/debug-ui/screen-text-settings/styles.d.ts +26 -0
  190. package/dist/debug-ui/screen-text-settings/transform.d.ts +6 -0
  191. package/dist/debug-ui/screen-text-settings/types.d.ts +9 -0
  192. package/dist/debug-ui/settings-panel/index.d.ts +38 -0
  193. package/dist/debug-ui/shared/MaterialSection.d.ts +13 -0
  194. package/dist/debug-ui/shared/ScreenTransformSection.d.ts +32 -0
  195. package/dist/debug-ui/transform-3d-settings/index.d.ts +11 -0
  196. package/dist/debug-ui.cjs +10 -0
  197. package/dist/debug-ui.js +8861 -0
  198. package/dist/drawNormalizedCrop-B-7zU-Xw.cjs +1 -0
  199. package/dist/drawNormalizedCrop-CRdIDyl1.js +44 -0
  200. package/dist/entries/all.d.ts +1 -0
  201. package/dist/entries/core.d.ts +55 -4
  202. package/dist/entries/face-effects.d.ts +12 -8
  203. package/dist/entries/internal.d.ts +1 -1
  204. package/dist/entries/low-level.d.ts +21 -4
  205. package/dist/entries/scene-object.d.ts +10 -0
  206. package/dist/entries/tracking.d.ts +25 -2
  207. package/dist/face-action/index.d.ts +34 -0
  208. package/dist/face-attribute-expression/index.d.ts +10 -0
  209. package/dist/face-effects.cjs +1 -252
  210. package/dist/face-effects.js +1404 -2613
  211. package/dist/face-info/blendshapes.d.ts +3 -0
  212. package/dist/face-info/derive.d.ts +8 -0
  213. package/dist/face-info/drawFaceCrop.d.ts +10 -0
  214. package/dist/face-info/getFaceInfo.d.ts +8 -0
  215. package/dist/face-info/index.d.ts +8 -0
  216. package/dist/face-info/landmarks.d.ts +21 -0
  217. package/dist/face-info/types.d.ts +52 -0
  218. package/dist/getFaceInfo-CyPAKh3h.cjs +1 -0
  219. package/dist/getFaceInfo-hUKMLFcr.js +118 -0
  220. package/dist/hand/handJoints2d.d.ts +49 -0
  221. package/dist/hand/handTracking2d.d.ts +33 -0
  222. package/dist/hand/handTracking2dController.d.ts +65 -0
  223. package/dist/hand/handTracking3d.d.ts +52 -0
  224. package/dist/hooks/faceResults.d.ts +1 -1
  225. package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
  226. package/dist/hooks/useFaceAction.d.ts +3 -0
  227. package/dist/hooks/useFaceAttributeExpression.d.ts +16 -0
  228. package/dist/hooks/useFaceDetection.d.ts +18 -0
  229. package/dist/hooks/useFaceInfo.d.ts +7 -0
  230. package/dist/hooks/useFaceInfos.d.ts +15 -0
  231. package/dist/hooks/useFaceResultReader.d.ts +10 -0
  232. package/dist/hooks/useFrameCapture.d.ts +18 -0
  233. package/dist/hooks/useMediaRecorder.d.ts +14 -2
  234. package/dist/hooks/useOwnedTexture.d.ts +6 -0
  235. package/dist/hooks/useTrackerContext.d.ts +2 -2
  236. package/dist/hooks/useXRSession/facade.d.ts +3 -0
  237. package/dist/hooks/useXRSession/registry.d.ts +9 -0
  238. package/dist/index-82aENaRq.cjs +1 -0
  239. package/dist/{index-BD-JWMjE.js → index-BgQAX8rs.js} +198 -134
  240. package/dist/index-CEc1CAmB.cjs +1 -0
  241. package/dist/index-CTHeBQOs.js +178 -0
  242. package/dist/index-D4bLzBr6.cjs +1 -0
  243. package/dist/index-DSpzjuqd.cjs +1 -0
  244. package/dist/index-Di70KWuY.js +2049 -0
  245. package/dist/index-DzEzkBIH.cjs +17 -0
  246. package/dist/{index-CYMj26Ej.js → index-JygePOwo.js} +565 -498
  247. package/dist/index-UC0Ux38E.js +111 -0
  248. package/dist/{internal-KOKJDxCG.js → internal-DuMPpcbp.js} +86 -80
  249. package/dist/internal-i2JkM85N.cjs +1 -0
  250. package/dist/internal.cjs +1 -1
  251. package/dist/internal.js +2 -2
  252. package/dist/low-level.cjs +1 -1
  253. package/dist/low-level.js +959 -632
  254. package/dist/main.cjs +1 -1
  255. package/dist/main.js +556 -455
  256. package/dist/material/MaterialFill.d.ts +20 -0
  257. package/dist/material/MeshMaterial.d.ts +14 -0
  258. package/dist/material/index.d.ts +2 -0
  259. package/dist/models/Body/index.d.ts +1 -1
  260. package/dist/models/Face/index.d.ts +1 -0
  261. package/dist/models/Face/rotation.d.ts +3 -0
  262. package/dist/models/Hand/HandTracking.d.ts +2 -0
  263. package/dist/render/layerStack.d.ts +29 -0
  264. package/dist/render/renderGroups.d.ts +47 -0
  265. package/dist/render/renderPasses.d.ts +18 -0
  266. package/dist/renderGroups-C9QJrAXu.js +152 -0
  267. package/dist/renderGroups-Dvm1J4lW.cjs +1 -0
  268. package/dist/renderLayers-lDtL0_43.cjs +1 -0
  269. package/dist/renderLayers-zrK2pv5O.js +13 -0
  270. package/dist/renderPasses-CT5iBwtg.cjs +21 -0
  271. package/dist/renderPasses-CjgG_6kQ.js +1500 -0
  272. package/dist/scene-object/index.d.ts +146 -0
  273. package/dist/scene-object/runtimeRegistry.d.ts +14 -0
  274. package/dist/scene-object.cjs +1 -0
  275. package/dist/scene-object.js +40 -0
  276. package/dist/screen-image/screenImagePresets.d.ts +13 -0
  277. package/dist/screen-image/screenImageSettings.d.ts +57 -0
  278. package/dist/screen-text/screenTextPresets.d.ts +6 -0
  279. package/dist/screen-text/screenTextSettings.d.ts +147 -0
  280. package/dist/screen2d/coordinates.d.ts +87 -0
  281. package/dist/screen2d/index.d.ts +7 -0
  282. package/dist/screen2d/material-runtime.d.ts +32 -0
  283. package/dist/screen2d/screenTransform.d.ts +47 -0
  284. package/dist/screen2d/smoothing.d.ts +5 -0
  285. package/dist/screen2d/texture.d.ts +10 -0
  286. package/dist/screen2d/transform.d.ts +25 -0
  287. package/dist/screen2d/types.d.ts +90 -0
  288. package/dist/{selectors-Bub0o3qy.cjs → selectors-2QvO5RYY.cjs} +1 -1
  289. package/dist/{selectors-BHO6TnoC.js → selectors-Dw3C-gSk.js} +5 -5
  290. package/dist/services/MetricsCollector/index.d.ts +7 -1
  291. package/dist/services/MetricsCollector/utils.d.ts +1 -1
  292. package/dist/session-BChR4TgK.cjs +31 -0
  293. package/dist/session-C1StwN0f.js +363 -0
  294. package/dist/texture/animatedTexture.d.ts +61 -0
  295. package/dist/texture/animationMath.d.ts +8 -0
  296. package/dist/texture/sourceResolver.d.ts +30 -0
  297. package/dist/tracking.cjs +1 -1
  298. package/dist/tracking.js +582 -298
  299. package/dist/types/face.d.ts +1 -13
  300. package/dist/types/hand-tracking.d.ts +8 -0
  301. package/dist/types/index.d.ts +0 -1
  302. package/dist/types/nodes.d.ts +4 -1
  303. package/dist/types/session.d.ts +2 -0
  304. package/dist/types/tracking.d.ts +8 -2
  305. package/dist/types/util-types.d.ts +1 -1
  306. package/dist/useFaceInfo-C-WfMlYp.cjs +1 -0
  307. package/dist/useFaceInfo-CwsHZedC.js +62 -0
  308. package/dist/useFaceResults-CkFc1egZ.js +19 -0
  309. package/dist/useFaceResults-VcFdOUFV.cjs +1 -0
  310. package/dist/utils/drawNormalizedCrop.d.ts +22 -0
  311. package/dist/utils/integrity.d.ts +4 -25
  312. package/dist/utils/landmarkBounds.d.ts +1 -1
  313. package/dist/utils/logger.d.ts +2 -2
  314. package/dist/x-Co8jPhP0.js +127 -0
  315. package/dist/x-KC8E4Gaj.cjs +41 -0
  316. package/docs/MIGRATION_GUIDE.md +589 -0
  317. package/docs/SDK_DOCUMENTATION.md +1155 -0
  318. package/docs/api/audio.mdx +36 -0
  319. package/docs/api/behavior-components.mdx +164 -0
  320. package/docs/api/capture-recording.mdx +103 -0
  321. package/docs/api/debug-ui-scene-editor.mdx +249 -0
  322. package/docs/api/face-actions.mdx +104 -0
  323. package/docs/api/face-attribute-expression.mdx +87 -0
  324. package/docs/api/face-binding-anchors.mdx +53 -0
  325. package/docs/api/face-effects.mdx +19 -0
  326. package/docs/api/face-info.mdx +112 -0
  327. package/docs/api/face-mesh.mdx +98 -0
  328. package/docs/api/face-painting.mdx +33 -0
  329. package/docs/api/face-retouching.mdx +73 -0
  330. package/docs/api/material-render-state.mdx +132 -0
  331. package/docs/api/runtime-3d.mdx +311 -0
  332. package/docs/api/scene-object-store.mdx +213 -0
  333. package/docs/api/screen-image.mdx +41 -0
  334. package/docs/api/screen-shape.mdx +64 -0
  335. package/docs/api/screen-space-coordinates.mdx +41 -0
  336. package/docs/api/screen-text.mdx +39 -0
  337. package/docs/api/texture-sources.mdx +55 -0
  338. package/docs/api/trackers.mdx +46 -0
  339. package/docs/docs.json +70 -0
  340. package/docs/examples/scene-object-recipes.mdx +194 -0
  341. package/docs/guides/harness-debug-ui.mdx +139 -0
  342. package/docs/inspector/hierarchy-panel.mdx +51 -0
  343. package/docs/inspector/object-inspector-panel.mdx +51 -0
  344. package/docs/introduction.mdx +121 -0
  345. package/docs/scene-objects/overview.mdx +127 -0
  346. package/docs/scene-objects/render-groups.mdx +77 -0
  347. package/docs/scene-objects/runtime-rendering.mdx +75 -0
  348. package/docs/texture-api-consumer.md +58 -0
  349. package/package.json +55 -7
  350. package/dist/components/FaceRetouch/retouchRegions.d.ts +0 -23
  351. package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +0 -12
  352. package/dist/index-B5J4gzn2.cjs +0 -1
  353. package/dist/index-BVBVg96G.cjs +0 -1
  354. package/dist/index-DtwHElmG.js +0 -157
  355. package/dist/index-PtFmD6B8.cjs +0 -1
  356. package/dist/internal-DH5d1Xnq.cjs +0 -1
  357. package/dist/modules/XRClient/index.d.ts +0 -9
  358. package/dist/modules/index.d.ts +0 -1
  359. package/dist/services/ApiService.d.ts +0 -12
  360. package/dist/types/client.d.ts +0 -3
  361. package/dist/useFaceResults-cpsSmKKc.js +0 -81
  362. package/dist/useFaceResults-hVUJYSEY.cjs +0 -1
package/dist/main.js CHANGED
@@ -1,523 +1,483 @@
1
- var Q = Object.defineProperty;
2
- var ee = (r, e, t) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var R = (r, e, t) => ee(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { useState as W, useEffect as k, useRef as y, useMemo as I, Suspense as te, useCallback as F } from "react";
5
- import { X as re, R as ne } from "./index-CYMj26Ej.js";
6
- import { b as rt, a as nt } from "./index-CYMj26Ej.js";
7
- import { S as se, a as ie, u as oe } from "./index-DtwHElmG.js";
8
- import { X as it } from "./index-DtwHElmG.js";
9
- import { jsx as p, jsxs as P, Fragment as X } from "react/jsx-runtime";
10
- import { useThree as Y, useFrame as ae } from "@react-three/fiber";
11
- import * as K from "three";
12
- import { PerspectiveCamera as J, RepeatWrapping as q, LinearFilter as H } from "three";
13
- import { u as ce, a as le } from "./selectors-BHO6TnoC.js";
14
- import { useTexture as ue } from "@react-three/drei";
15
- const $ = 9, G = 16, Ae = ({ children: r }) => {
16
- const [e, t] = W({ width: 0, height: 0 });
17
- return k(() => {
18
- const n = () => {
19
- const i = document.documentElement.clientWidth, c = document.documentElement.clientHeight, o = i / c, a = $ / G;
20
- let s, u;
21
- o > a ? (u = c, s = u * $ / G) : (s = i, u = s * G / $), t({ width: s, height: u });
22
- };
23
- return n(), window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
24
- }, []), /* @__PURE__ */ p(
25
- "div",
26
- {
27
- style: {
28
- width: "100vw",
29
- height: `${window.innerHeight}px`,
30
- display: "flex",
31
- alignItems: "center",
32
- justifyContent: "center",
33
- backgroundColor: "#0d0d0d"
34
- },
35
- children: /* @__PURE__ */ p("div", { style: { width: e.width, height: e.height, position: "relative" }, children: r })
36
- }
37
- );
38
- }, de = "rgba(20,40,110,0.88)", he = 24, fe = 512;
39
- function _e({
40
- color: r = de,
1
+ var re = Object.defineProperty;
2
+ var ae = (t, e, s) => e in t ? re(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var _ = (t, e, s) => ae(t, typeof e != "symbol" ? e + "" : e, s);
4
+ import { X as ne, u as oe } from "./index-JygePOwo.js";
5
+ import { c as yt, d as gt } from "./index-JygePOwo.js";
6
+ import { S as ie } from "./contexts-Bk5zz_VR.js";
7
+ import { X as At } from "./contexts-Bk5zz_VR.js";
8
+ import { c as ce } from "./index-Di70KWuY.js";
9
+ import { L as xt, d as vt, R as Ct, e as Pt, a as Lt, S as Ut, b as Dt, f as Nt, T as bt, g as Ft, m as Ot, n as It, h as Gt, i as kt, j as zt, s as Wt, k as Xt, l as Vt, w as Ht } from "./index-Di70KWuY.js";
10
+ import { jsxs as N, jsx as f, Fragment as q } from "react/jsx-runtime";
11
+ import { useRef as A, useMemo as J, useEffect as U, useState as b, Suspense as ue, useCallback as w, forwardRef as le, useImperativeHandle as de } from "react";
12
+ import * as me from "three";
13
+ import { MathUtils as pe, Vector2 as he, Vector3 as fe, DoubleSide as k, RepeatWrapping as Y, LinearFilter as Z } from "three";
14
+ import { T as jt, U as qt, D as Yt, K as Zt, J as Kt, F as $t, N as Jt, O as Qt, V as es, W as ts, H as ss, M as rs, P as as, S as ns, E as os, B as is, L as cs, Q as us, R as ls, G as ds, X as ms, C as ps, I as hs, Y as fs } from "./renderPasses-CjgG_6kQ.js";
15
+ import { useThree as Ee, useFrame as Se } from "@react-three/fiber";
16
+ import { R as Te } from "./renderLayers-zrK2pv5O.js";
17
+ import { b as Me, c as Re } from "./selectors-Dw3C-gSk.js";
18
+ import { useTexture as ye } from "@react-three/drei";
19
+ import { a as ge } from "./index-CTHeBQOs.js";
20
+ import { D as Ss, b as Ts, M as Ms, n as Rs } from "./index-CTHeBQOs.js";
21
+ import { y as gs, w as ws, A as As, M as _s, S as xs, T as vs, z as Cs, x as Ps } from "./FaceMeshRenderer-6t8OsQhK.js";
22
+ import { d as Us, r as Ds } from "./drawNormalizedCrop-CRdIDyl1.js";
23
+ import { M as bs } from "./index-BgQAX8rs.js";
24
+ const I = (t, e, s, r) => pe.damp(t, e, Math.max(0, s), Math.max(0, r)), Je = (t, e, s, r, a = new he()) => a.set(
25
+ I(t.x, e.x, s, r),
26
+ I(t.y, e.y, s, r)
27
+ ), Qe = (t, e, s, r, a = new fe()) => a.set(
28
+ I(t.x, e.x, s, r),
29
+ I(t.y, e.y, s, r),
30
+ I(t.z, e.z, s, r)
31
+ ), we = "rgba(20,40,110,0.88)", Ae = 24, _e = 512;
32
+ function et({
33
+ color: t = we,
41
34
  borderColor: e,
42
- borderWidth: t = 0,
43
- borderRadius: n = he,
44
- resolution: i = fe,
45
- aspect: c = 1,
35
+ borderWidth: s = 0,
36
+ borderRadius: r = Ae,
37
+ resolution: a = _e,
38
+ aspect: i = 1,
46
39
  opacity: o = 1,
47
- name: a,
48
- overlay: s = !0,
40
+ name: c,
41
+ overlay: n = !0,
49
42
  position: u,
50
- rotation: g,
51
- scale: m,
52
- visible: l
43
+ rotation: S,
44
+ scale: d,
45
+ visible: m
53
46
  }) {
54
- const M = y(null), v = y(null), w = I(() => me({
55
- width: Math.round(i * Math.max(c, 0.05)),
56
- height: Math.round(i),
57
- color: r,
47
+ const h = A(null), l = A(null), T = J(() => xe({
48
+ width: Math.round(a * Math.max(i, 0.05)),
49
+ height: Math.round(a),
50
+ color: t,
58
51
  borderColor: e,
59
- borderWidth: t,
60
- borderRadius: n
61
- }), [r, e, t, n, i, c]);
62
- k(() => () => {
63
- w.dispose();
64
- }, [w]);
65
- const b = y(null), S = y(o);
66
- return S.current !== o && (S.current = o, b.current = null, v.current && (v.current.opacity = o)), k(() => {
67
- const d = M.current;
68
- if (d)
69
- return d.userData.setOpacity = (L) => {
70
- b.current = L, v.current && (v.current.opacity = L);
52
+ borderWidth: s,
53
+ borderRadius: r
54
+ }), [t, e, s, r, a, i]);
55
+ U(() => () => {
56
+ T.dispose();
57
+ }, [T]);
58
+ const g = A(null), E = A(o);
59
+ return E.current !== o && (E.current = o, g.current = null, l.current && (l.current.opacity = o)), U(() => {
60
+ const x = h.current;
61
+ if (x)
62
+ return x.userData.setOpacity = (P) => {
63
+ g.current = P, l.current && (l.current.opacity = P);
71
64
  }, () => {
72
- delete d.userData.setOpacity;
65
+ delete x.userData.setOpacity;
73
66
  };
74
- }, []), /* @__PURE__ */ P(
67
+ }, []), /* @__PURE__ */ N(
75
68
  "mesh",
76
69
  {
77
- ref: M,
78
- name: a,
70
+ ref: h,
71
+ name: c,
79
72
  position: u,
80
- rotation: g,
81
- scale: m,
82
- visible: l,
73
+ rotation: S,
74
+ scale: d,
75
+ visible: m,
83
76
  children: [
84
- /* @__PURE__ */ p("planeGeometry", { args: [1, 1] }),
85
- /* @__PURE__ */ p(
77
+ /* @__PURE__ */ f("planeGeometry", { args: [1, 1] }),
78
+ /* @__PURE__ */ f(
86
79
  "meshBasicMaterial",
87
80
  {
88
- ref: v,
89
- map: w,
81
+ ref: l,
82
+ map: T,
90
83
  transparent: !0,
91
84
  opacity: o,
92
- depthTest: !s,
93
- depthWrite: !s
94
- }
95
- )
96
- ]
97
- }
98
- );
99
- }
100
- function me(r) {
101
- const { width: e, height: t, color: n, borderColor: i, borderWidth: c, borderRadius: o } = r, a = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(e, t) : (() => {
102
- const m = document.createElement("canvas");
103
- return m.width = e, m.height = t, m;
104
- })(), s = a.getContext("2d");
105
- s.clearRect(0, 0, e, t);
106
- const u = Math.min(o, Math.min(e, t) / 2);
107
- s.beginPath(), s.moveTo(u, 0), s.lineTo(e - u, 0), s.quadraticCurveTo(e, 0, e, u), s.lineTo(e, t - u), s.quadraticCurveTo(e, t, e - u, t), s.lineTo(u, t), s.quadraticCurveTo(0, t, 0, t - u), s.lineTo(0, u), s.quadraticCurveTo(0, 0, u, 0), s.closePath(), s.fillStyle = n, s.fill(), i && c > 0 && (s.lineWidth = c, s.strokeStyle = i, s.stroke());
108
- const g = new K.CanvasTexture(a);
109
- return g.needsUpdate = !0, g;
110
- }
111
- const ze = ({ children: r, depth: e = 0 }) => {
112
- const { camera: t, size: n } = Y(), i = I(() => {
113
- if (!(t instanceof J))
114
- return { width: 10, height: 10 };
115
- const c = Math.abs(t.position.z - e), o = t.fov * Math.PI / 180, a = 2 * Math.tan(o / 2) * c;
116
- return { width: a * (n.width / n.height), height: a };
117
- }, [t, n, e]);
118
- return /* @__PURE__ */ p(se.Provider, { value: i, children: /* @__PURE__ */ p("group", { position: [0, 0, e], children: r }) });
119
- };
120
- function pe(r, e) {
121
- return !Number.isFinite(r) || !Number.isFinite(e) || r <= 0 || e <= 0 ? [1, 1, 1] : Math.abs(r - e) < 1e-6 ? [1, 1, 1] : r > e ? [e / r, 1, 1] : [1, r / e, 1];
122
- }
123
- const ge = { left: -1, right: 1, top: 1, bottom: -1 }, Me = (r, e, t) => {
124
- const n = r % e, i = Math.floor(r / e);
125
- return { x: n / e, y: (t - 1 - i) / t };
126
- }, ve = ({
127
- sheet: r,
128
- contentAspect: e,
129
- renderOrder: t,
130
- name: n
131
- }) => {
132
- const i = ue(r.url), c = y(0), o = y(-1), a = oe(), [s, u] = e != null ? pe(a, e) : [1, 1];
133
- return ae((g, m) => {
134
- i.wrapS = q, i.wrapT = q, i.magFilter = H, i.minFilter = H, i.generateMipmaps = !1, i.repeat.set(1 / r.cols, 1 / r.rows), c.current += m;
135
- const l = Math.floor(c.current * r.fps) % r.frames;
136
- if (l === o.current) return;
137
- o.current = l;
138
- const { x: M, y: v } = Me(l, r.cols, r.rows);
139
- i.offset.set(M, v);
140
- }), /* @__PURE__ */ P("mesh", { name: n, renderOrder: t, scale: [s, u, 1], children: [
141
- /* @__PURE__ */ p("planeGeometry", { args: [1, 1] }),
142
- /* @__PURE__ */ p("meshBasicMaterial", { map: i, transparent: !0, toneMapped: !1, depthWrite: !1 })
143
- ] });
144
- }, Be = ({
145
- sheet: r,
146
- anchors: e = ge,
147
- contentAspect: t,
148
- renderOrder: n = 10,
149
- name: i = "spriteAnimation"
150
- }) => /* @__PURE__ */ p(te, { fallback: null, children: /* @__PURE__ */ p(ie, { anchors: e, children: /* @__PURE__ */ p(ve, { sheet: r, contentAspect: t, renderOrder: n, name: i }) }) }), Te = {
151
- color: "#ffffff",
152
- fontWeight: "bold",
153
- fontFamily: "Arial, sans-serif",
154
- fontSize: 48,
155
- bgColor: "rgba(20,40,110,0.88)",
156
- borderWidth: 0,
157
- borderRadius: 24,
158
- padding: 32,
159
- aspect: 2.5,
160
- resolution: 512,
161
- opacity: 1
162
- };
163
- function Ie(r) {
164
- const e = { ...Te, ...r }, {
165
- text: t,
166
- color: n,
167
- fontWeight: i,
168
- fontFamily: c,
169
- fontSize: o,
170
- bgColor: a,
171
- borderColor: s,
172
- borderWidth: u,
173
- borderRadius: g,
174
- padding: m,
175
- aspect: l,
176
- resolution: M,
177
- opacity: v,
178
- name: w,
179
- overlay: b = !0,
180
- position: S,
181
- rotation: d,
182
- scale: L,
183
- visible: N
184
- } = e, [_, z] = W(null), [B, A] = W(null), h = y(t);
185
- h.current !== t && (h.current = t, _ !== null && z(null));
186
- const T = y(a);
187
- T.current !== a && (T.current = a, B !== null && A(null));
188
- const f = y(null), E = _ ?? t, D = B ?? a, O = I(
189
- () => ye({
190
- text: E,
191
- color: n,
192
- fontWeight: i,
193
- fontFamily: c,
194
- fontSize: o,
195
- bgColor: D,
196
- borderColor: s,
197
- borderWidth: u,
198
- borderRadius: g,
199
- padding: m,
200
- height: M,
201
- width: Math.round(M * Math.max(l, 0.1))
202
- }),
203
- [
204
- E,
205
- n,
206
- i,
207
- c,
208
- o,
209
- D,
210
- s,
211
- u,
212
- g,
213
- m,
214
- l,
215
- M
216
- ]
217
- );
218
- return k(() => {
219
- const x = f.current;
220
- if (x)
221
- return x.userData.setText = (U) => z(U), x.userData.setBgColor = (U) => A(U), () => {
222
- delete x.userData.setText, delete x.userData.setBgColor;
223
- };
224
- }, []), k(() => () => {
225
- O.dispose();
226
- }, [O]), /* @__PURE__ */ P(
227
- "mesh",
228
- {
229
- ref: f,
230
- name: w,
231
- position: S,
232
- rotation: d,
233
- scale: L,
234
- visible: N,
235
- children: [
236
- /* @__PURE__ */ p("planeGeometry", { args: [1, 1] }),
237
- /* @__PURE__ */ p(
238
- "meshBasicMaterial",
239
- {
240
- map: O,
241
- transparent: !0,
242
- opacity: v,
243
- depthTest: !b,
244
- depthWrite: !b
85
+ depthTest: !n,
86
+ depthWrite: !n
245
87
  }
246
88
  )
247
89
  ]
248
90
  }
249
91
  );
250
92
  }
251
- function ye(r) {
252
- const { width: e, height: t, text: n, color: i, fontFamily: c, fontWeight: o, padding: a } = r;
253
- let { fontSize: s, bgColor: u } = r, g;
254
- const m = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(e, t) : (() => {
93
+ function xe(t) {
94
+ const { width: e, height: s, color: r, borderColor: a, borderWidth: i, borderRadius: o } = t, c = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(e, s) : (() => {
255
95
  const d = document.createElement("canvas");
256
- return d.width = e, d.height = t, d;
257
- })(), l = m.getContext("2d");
258
- if (l.clearRect(0, 0, e, t), u !== "transparent") {
259
- const d = Math.min(r.borderRadius, Math.min(e, t) / 2);
260
- l.beginPath(), l.moveTo(d, 0), l.lineTo(e - d, 0), l.quadraticCurveTo(e, 0, e, d), l.lineTo(e, t - d), l.quadraticCurveTo(e, t, e - d, t), l.lineTo(d, t), l.quadraticCurveTo(0, t, 0, t - d), l.lineTo(0, d), l.quadraticCurveTo(0, 0, d, 0), l.closePath(), l.fillStyle = u, l.fill(), r.borderColor && r.borderWidth > 0 && (l.lineWidth = r.borderWidth, l.strokeStyle = r.borderColor, l.stroke());
261
- }
262
- l.fillStyle = i, l.textAlign = "center", l.textBaseline = "middle";
263
- const M = e - a * 2;
264
- let v = Z(l, n, M, o, s, c);
265
- const w = Math.max(1, Math.floor((t - a * 2) / (s * 1.3)));
266
- v.length > w && (s = Math.max(12, Math.round(s * 0.75)), v = Z(l, n, M, o, s, c)), l.font = `${o} ${s}px ${c}`;
267
- const b = s * 1.3, S = t / 2 - (v.length - 1) * b / 2;
268
- for (let d = 0; d < v.length; d++)
269
- l.fillText(v[d], e / 2, S + d * b);
270
- return g = new K.CanvasTexture(m), g.needsUpdate = !0, g;
271
- }
272
- function Z(r, e, t, n, i, c) {
273
- r.font = `${n} ${i}px ${c}`;
274
- const o = e.split(" "), a = [];
275
- let s = "";
276
- for (const u of o) {
277
- const g = s ? `${s} ${u}` : u;
278
- r.measureText(g).width > t && s ? (a.push(s), s = u) : s = g;
279
- }
280
- return s && a.push(s), a;
96
+ return d.width = e, d.height = s, d;
97
+ })(), n = c.getContext("2d");
98
+ n.clearRect(0, 0, e, s);
99
+ const u = Math.min(o, Math.min(e, s) / 2);
100
+ n.beginPath(), n.moveTo(u, 0), n.lineTo(e - u, 0), n.quadraticCurveTo(e, 0, e, u), n.lineTo(e, s - u), n.quadraticCurveTo(e, s, e - u, s), n.lineTo(u, s), n.quadraticCurveTo(0, s, 0, s - u), n.lineTo(0, u), n.quadraticCurveTo(0, 0, u, 0), n.closePath(), n.fillStyle = r, n.fill(), a && i > 0 && (n.lineWidth = i, n.strokeStyle = a, n.stroke());
101
+ const S = new me.CanvasTexture(c);
102
+ return S.needsUpdate = !0, S;
281
103
  }
282
- const Ne = ({
283
- segmentationMask: r,
104
+ const tt = ({
105
+ segmentationMask: t,
284
106
  segmentation: e,
285
- invert: t = !1,
286
- customBackground: n,
287
- renderOrder: i = ne.BACKGROUND
107
+ invert: s = !1,
108
+ customBackground: r,
109
+ renderOrder: a = Te.BACKGROUND
288
110
  }) => {
289
- const { camera: c, size: o } = Y(), a = ce(), s = le(re.BACKGROUND_SEGMENTATION), u = e ? s == null ? void 0 : s.backgroundSegmentationMask : void 0, g = y(!1);
290
- k(() => {
111
+ const { camera: i, size: o } = Ee(), c = Me(), n = Re(ne.BACKGROUND_SEGMENTATION), u = e ? n == null ? void 0 : n.backgroundSegmentationMask : void 0, S = A(!1);
112
+ U(() => {
291
113
  if (!e) {
292
- g.current = !1;
114
+ S.current = !1;
293
115
  return;
294
116
  }
295
- s === null && !g.current && (console.warn(
117
+ n === null && !S.current && (console.warn(
296
118
  `[VideoBackground] segmentation="${e}" set but no matching <Segmentation> component is mounted; rendering unmasked.`
297
- ), g.current = !0);
298
- }, [e, s]);
299
- const m = e ? u : r, l = I(() => {
300
- if (!(c instanceof J))
119
+ ), S.current = !0);
120
+ }, [e, n]);
121
+ const d = e ? u : t, m = J(() => {
122
+ if (!i.isPerspectiveCamera)
301
123
  return [10, 10];
302
- const w = (c.position.z || 5) - -1, b = c.fov * Math.PI / 180, S = 2 * Math.tan(b / 2) * w;
303
- return [S * (o.width / o.height), S];
304
- }, [c, o]);
305
- return a ? /* @__PURE__ */ p("group", { position: [0, 0, -1], children: t ? /* @__PURE__ */ P(X, { children: [
306
- /* @__PURE__ */ P("mesh", { position: [0, 0, -0.01], renderOrder: i - 1, children: [
307
- /* @__PURE__ */ p("planeGeometry", { args: l }),
308
- /* @__PURE__ */ p(
124
+ const h = i, g = (h.position.z || 5) - -1, E = h.fov * Math.PI / 180, x = 2 * Math.tan(E / 2) * g;
125
+ return [x * (o.width / o.height), x];
126
+ }, [i, o]);
127
+ return c ? /* @__PURE__ */ f("group", { position: [0, 0, -1], children: s ? /* @__PURE__ */ N(q, { children: [
128
+ /* @__PURE__ */ N("mesh", { position: [0, 0, -0.01], renderOrder: a - 1, children: [
129
+ /* @__PURE__ */ f("planeGeometry", { args: m }),
130
+ /* @__PURE__ */ f(
309
131
  "meshBasicMaterial",
310
132
  {
311
- map: a,
133
+ map: c,
312
134
  depthTest: !1,
313
135
  depthWrite: !1,
314
- toneMapped: !1
136
+ toneMapped: !1,
137
+ side: k
315
138
  }
316
139
  )
317
140
  ] }),
318
- n && m && /* @__PURE__ */ P("mesh", { position: [0, 0, 0], renderOrder: i, children: [
319
- /* @__PURE__ */ p("planeGeometry", { args: l }),
320
- /* @__PURE__ */ p(
141
+ r && d && /* @__PURE__ */ N("mesh", { position: [0, 0, 0], renderOrder: a, children: [
142
+ /* @__PURE__ */ f("planeGeometry", { args: m }),
143
+ /* @__PURE__ */ f(
321
144
  "meshBasicMaterial",
322
145
  {
323
- map: typeof n == "string" ? void 0 : n,
324
- color: typeof n == "string" ? n : void 0,
325
- alphaMap: m,
146
+ map: typeof r == "string" ? void 0 : r,
147
+ color: typeof r == "string" ? r : void 0,
148
+ alphaMap: d,
326
149
  transparent: !1,
327
150
  alphaTest: 0.5,
328
151
  depthTest: !1,
329
152
  depthWrite: !1,
330
- toneMapped: !1
153
+ toneMapped: !1,
154
+ side: k
331
155
  },
332
156
  "inverted-mask"
333
157
  )
334
158
  ] })
335
- ] }) : /* @__PURE__ */ P(X, { children: [
336
- n && m && /* @__PURE__ */ P("mesh", { position: [0, 0, -0.01], renderOrder: i - 1, children: [
337
- /* @__PURE__ */ p("planeGeometry", { args: l }),
338
- /* @__PURE__ */ p(
159
+ ] }) : /* @__PURE__ */ N(q, { children: [
160
+ r && d && /* @__PURE__ */ N("mesh", { position: [0, 0, -0.01], renderOrder: a - 1, children: [
161
+ /* @__PURE__ */ f("planeGeometry", { args: m }),
162
+ /* @__PURE__ */ f(
339
163
  "meshBasicMaterial",
340
164
  {
341
- map: typeof n == "string" ? void 0 : n,
342
- color: typeof n == "string" ? n : void 0,
165
+ map: typeof r == "string" ? void 0 : r,
166
+ color: typeof r == "string" ? r : void 0,
343
167
  depthTest: !1,
344
168
  depthWrite: !1,
345
- toneMapped: !1
169
+ toneMapped: !1,
170
+ side: k
346
171
  }
347
172
  )
348
173
  ] }),
349
- /* @__PURE__ */ P("mesh", { position: [0, 0, 0], renderOrder: i, children: [
350
- /* @__PURE__ */ p("planeGeometry", { args: l }),
351
- /* @__PURE__ */ p(
174
+ /* @__PURE__ */ N("mesh", { position: [0, 0, 0], renderOrder: a, children: [
175
+ /* @__PURE__ */ f("planeGeometry", { args: m }),
176
+ /* @__PURE__ */ f(
352
177
  "meshBasicMaterial",
353
178
  {
354
- map: a,
355
- alphaMap: m,
179
+ map: c,
180
+ alphaMap: d,
356
181
  transparent: !1,
357
- alphaTest: m ? 0.5 : void 0,
182
+ alphaTest: d ? 0.5 : void 0,
358
183
  depthTest: !1,
359
184
  depthWrite: !1,
360
- toneMapped: !1
185
+ toneMapped: !1,
186
+ side: k
361
187
  },
362
- m ? "with-mask" : "no-mask"
188
+ d ? "with-mask" : "no-mask"
363
189
  )
364
190
  ] })
365
191
  ] }) }) : null;
366
- }, we = [
192
+ }, V = 9, H = 16, st = ({ children: t }) => {
193
+ const [e, s] = b({ width: 0, height: 0 });
194
+ return U(() => {
195
+ const r = () => {
196
+ const a = document.documentElement.clientWidth, i = document.documentElement.clientHeight, o = a / i, c = V / H;
197
+ let n, u;
198
+ o > c ? (u = i, n = u * V / H) : (n = a, u = n * H / V), s({ width: n, height: u });
199
+ };
200
+ return r(), window.addEventListener("resize", r), () => window.removeEventListener("resize", r);
201
+ }, []), /* @__PURE__ */ f(
202
+ "div",
203
+ {
204
+ style: {
205
+ width: "100vw",
206
+ height: `${window.innerHeight}px`,
207
+ display: "flex",
208
+ alignItems: "center",
209
+ justifyContent: "center",
210
+ backgroundColor: "#0d0d0d"
211
+ },
212
+ children: /* @__PURE__ */ f("div", { style: { width: e.width, height: e.height, position: "relative" }, children: t })
213
+ }
214
+ );
215
+ }, rt = ({ size: t = 0.25, ...e }) => /* @__PURE__ */ f("axesHelper", { args: [t], ...e }), ve = { left: -1, right: 1, top: 1, bottom: -1 }, Ce = (t, e, s) => {
216
+ const r = t % e, a = Math.floor(t / e);
217
+ return { x: r / e, y: (s - 1 - a) / s };
218
+ }, Pe = ({
219
+ sheet: t,
220
+ contentAspect: e,
221
+ renderOrder: s,
222
+ name: r
223
+ }) => {
224
+ const a = ye(t.url), i = A(0), o = A(-1), c = ge(), [n, u] = e != null ? ce(c, e) : [1, 1];
225
+ return Se((S, d) => {
226
+ a.wrapS = Y, a.wrapT = Y, a.magFilter = Z, a.minFilter = Z, a.generateMipmaps = !1, a.repeat.set(1 / t.cols, 1 / t.rows), i.current += d;
227
+ const m = Math.floor(i.current * t.fps) % t.frames;
228
+ if (m === o.current) return;
229
+ o.current = m;
230
+ const { x: h, y: l } = Ce(m, t.cols, t.rows);
231
+ a.offset.set(h, l);
232
+ }), /* @__PURE__ */ N("mesh", { name: r, renderOrder: s, scale: [n, u, 1], children: [
233
+ /* @__PURE__ */ f("planeGeometry", { args: [1, 1] }),
234
+ /* @__PURE__ */ f("meshBasicMaterial", { map: a, transparent: !0, toneMapped: !1, depthWrite: !1 })
235
+ ] });
236
+ }, at = ({
237
+ sheet: t,
238
+ anchors: e = ve,
239
+ contentAspect: s,
240
+ renderOrder: r = 10,
241
+ name: a = "spriteAnimation"
242
+ }) => /* @__PURE__ */ f(ue, { fallback: null, children: /* @__PURE__ */ f(ie, { anchors: e, children: /* @__PURE__ */ f(Pe, { sheet: t, contentAspect: s, renderOrder: r, name: a }) }) }), D = (t) => {
243
+ switch (t) {
244
+ case "start":
245
+ return "starting";
246
+ case "started":
247
+ case "resume":
248
+ return "recording";
249
+ case "pause":
250
+ return "paused";
251
+ case "stop":
252
+ return "stopping";
253
+ case "complete":
254
+ return "completed";
255
+ case "fail":
256
+ return "error";
257
+ case "clear":
258
+ return "idle";
259
+ }
260
+ }, Le = [
367
261
  "video/mp4",
368
262
  "video/webm;codecs=vp9",
369
263
  "video/webm;codecs=vp8",
370
264
  "video/webm"
371
265
  ];
372
- function $e(r = {}) {
373
- const { audio: e = !1, mimeType: t, bitsPerSecond: n, onData: i, onStop: c, passThroughStream: o } = r, a = y(null), s = y(null), u = y([]), [g, m] = W(!1), [l, M] = W(!1), [v, w] = W(null), [b, S] = W(null), d = F(() => {
374
- var T;
375
- const h = [t, ...we].filter(Boolean);
376
- for (const f of h)
377
- if ((T = MediaRecorder.isTypeSupported) != null && T.call(MediaRecorder, f)) return f;
378
- }, [t]), L = F(
379
- async (h) => {
380
- const T = new MediaStream();
381
- if (h.getTracks().forEach((f) => T.addTrack(f)), e) {
382
- let f;
266
+ function nt(t = {}) {
267
+ const {
268
+ audio: e = !1,
269
+ mimeType: s,
270
+ bitsPerSecond: r,
271
+ onData: a,
272
+ onStop: i,
273
+ onRecordingStart: o,
274
+ onRecordingPause: c,
275
+ onRecordingResume: n,
276
+ onRecordingStop: u,
277
+ onRecordingComplete: S,
278
+ onError: d,
279
+ passThroughStream: m
280
+ } = t, h = A(null), l = A(null), T = A([]), [g, E] = b("idle"), [x, P] = b(null), [W, R] = b(null), L = w(() => {
281
+ var y;
282
+ const p = [s, ...Le].filter(Boolean);
283
+ for (const M of p)
284
+ if ((y = MediaRecorder.isTypeSupported) != null && y.call(MediaRecorder, M)) return M;
285
+ }, [s]), O = w(
286
+ async (p) => {
287
+ const y = new MediaStream();
288
+ if (p.getTracks().forEach((M) => y.addTrack(M)), e) {
289
+ let M;
383
290
  if (e instanceof MediaStream)
384
- f = e;
291
+ M = e;
385
292
  else {
386
- const E = typeof e == "object" ? { audio: e } : { audio: !0, video: !1 };
387
- f = await navigator.mediaDevices.getUserMedia(E);
293
+ const v = typeof e == "object" ? { audio: e } : { audio: !0, video: !1 };
294
+ M = await navigator.mediaDevices.getUserMedia(v);
388
295
  }
389
- f.getAudioTracks().forEach((E) => T.addTrack(E));
296
+ M.getAudioTracks().forEach((v) => y.addTrack(v));
390
297
  }
391
- if (!T.getTracks().length)
298
+ if (!y.getTracks().length)
392
299
  throw new Error("No tracks available in combined stream.");
393
- return s.current = T, T;
300
+ return l.current = y, y;
394
301
  },
395
302
  [e]
396
- ), N = F(
397
- async (h, T) => {
303
+ ), Q = w(
304
+ async (p, y) => {
305
+ E(D("start")), R(null), P(null);
398
306
  try {
399
- let f;
400
- o ? (f = h, s.current = f) : f = await L(h);
401
- const E = d(), D = {};
402
- E && (D.mimeType = E), n && (D.bitsPerSecond = n);
403
- const O = new MediaRecorder(f, D);
404
- O.ondataavailable = (x) => {
405
- var U;
406
- ((U = x.data) == null ? void 0 : U.size) > 0 && (u.current.push(x.data), i == null || i(x.data));
407
- }, O.onstop = () => {
408
- const x = new Blob(u.current, {
409
- type: E ?? "video/webm"
307
+ let M;
308
+ if (m)
309
+ M = m, l.current = M;
310
+ else {
311
+ if (!p) throw new Error("start(stream) requires a MediaStream.");
312
+ M = await O(p);
313
+ }
314
+ const v = L(), X = {};
315
+ v && (X.mimeType = v), r && (X.bitsPerSecond = r);
316
+ const G = new MediaRecorder(M, X);
317
+ G.ondataavailable = (F) => {
318
+ var j;
319
+ ((j = F.data) == null ? void 0 : j.size) > 0 && (T.current.push(F.data), a == null || a(F.data));
320
+ }, G.onstop = () => {
321
+ const F = new Blob(T.current, {
322
+ type: v ?? "video/webm"
410
323
  });
411
- w(x), c == null || c(x), u.current = [];
412
- }, a.current = O, O.start(T), m(!0), M(!1);
413
- } catch (f) {
414
- console.error("start(stream) failed", f), S(f instanceof Error ? f : new Error(String(f)));
324
+ P(F), i == null || i(F), S == null || S(F), T.current = [], E(D("complete"));
325
+ }, h.current = G, G.start(y), E(D("started")), o == null || o();
326
+ } catch (M) {
327
+ const v = M instanceof Error ? M : new Error(String(M));
328
+ console.error("start(stream) failed", v), R(v), E(D("fail")), d == null || d(v);
415
329
  }
416
330
  },
417
- [L, d, n, i, c, o]
418
- ), _ = F(() => {
419
- const h = a.current;
420
- h && h.state !== "inactive" && h.stop(), m(!1), M(!1);
421
- }, []), z = F(() => {
422
- const h = a.current;
423
- (h == null ? void 0 : h.state) === "recording" && (h.pause(), M(!0));
424
- }, []), B = F(() => {
425
- const h = a.current;
426
- (h == null ? void 0 : h.state) === "paused" && (h.resume(), M(!1));
427
- }, []), A = F(() => {
428
- var h, T;
331
+ [
332
+ O,
333
+ L,
334
+ r,
335
+ a,
336
+ i,
337
+ S,
338
+ o,
339
+ d,
340
+ m
341
+ ]
342
+ ), ee = w(() => {
343
+ const p = h.current;
344
+ !p || p.state === "inactive" || (E(D("stop")), p.stop(), u == null || u());
345
+ }, [u]), te = w(() => {
346
+ const p = h.current;
347
+ (p == null ? void 0 : p.state) === "recording" && (p.pause(), E(D("pause")), c == null || c());
348
+ }, [c]), se = w(() => {
349
+ const p = h.current;
350
+ (p == null ? void 0 : p.state) === "paused" && (p.resume(), E(D("resume")), n == null || n());
351
+ }, [n]), B = w(() => {
352
+ var p;
429
353
  try {
430
- (h = a.current) == null || h.stop(), a.current = null, (T = s.current) == null || T.getTracks().forEach((f) => f.stop()), s.current = null, w(null), m(!1), M(!1), u.current = [], S(null);
431
- } catch (f) {
432
- console.error("clear failed", f);
354
+ h.current && (h.current.onstop = null, h.current.state !== "inactive" && h.current.stop()), h.current = null, (p = l.current) == null || p.getTracks().forEach((y) => y.stop()), l.current = null, P(null), E(D("clear")), T.current = [], R(null);
355
+ } catch (y) {
356
+ console.error("clear failed", y);
433
357
  }
434
358
  }, []);
435
- return k(() => () => A(), []), {
436
- start: N,
437
- stop: _,
438
- pause: z,
439
- resume: B,
440
- clear: A,
441
- isRecording: g,
442
- isPaused: l,
443
- recordedBlob: v,
444
- error: b,
445
- getActiveStream: () => s.current
359
+ return U(() => () => B(), []), {
360
+ status: g,
361
+ start: Q,
362
+ stop: ee,
363
+ pause: te,
364
+ resume: se,
365
+ clear: B,
366
+ isRecording: g === "recording" || g === "paused",
367
+ isPaused: g === "paused",
368
+ recordedBlob: x,
369
+ error: W,
370
+ getActiveStream: () => l.current
446
371
  };
447
372
  }
448
- const Ge = (r, e) => {
449
- const t = r.split(","), n = t[0].match(/:(.*?);/), i = n ? n[1] : "application/octet-stream", c = atob(t[t.length - 1]);
450
- let o = c.length;
451
- const a = new Uint8Array(o);
373
+ const Ue = async (t, e = {}) => {
374
+ var s, r, a;
375
+ (s = e.onCaptureStart) == null || s.call(e), await Promise.resolve();
376
+ try {
377
+ const i = t();
378
+ return (r = e.onCaptureComplete) == null || r.call(e, i), i;
379
+ } catch (i) {
380
+ const o = i instanceof Error ? i : new Error(String(i));
381
+ throw (a = e.onError) == null || a.call(e, o), o;
382
+ }
383
+ }, ot = (t = {}) => {
384
+ const { session: e } = oe(), {
385
+ captureFrame: s = e.captureFrame,
386
+ onCaptureStart: r,
387
+ onCaptureComplete: a,
388
+ onError: i
389
+ } = t, [o, c] = b("idle"), [n, u] = b(null), [S, d] = b(null), m = w(async () => {
390
+ c("capturing"), u(null), d(null);
391
+ try {
392
+ const l = await Ue(s, {
393
+ onCaptureStart: r,
394
+ onCaptureComplete: a,
395
+ onError: i
396
+ });
397
+ return u(l), c("completed"), l;
398
+ } catch (l) {
399
+ const T = l instanceof Error ? l : new Error(String(l));
400
+ return d(T), c("error"), null;
401
+ }
402
+ }, [s, r, a, i]), h = w(() => {
403
+ c("idle"), u(null), d(null);
404
+ }, []);
405
+ return { status: o, capturePhoto: m, clear: h, dataUrl: n, error: S };
406
+ }, it = (t, e) => {
407
+ const s = t.split(","), r = s[0].match(/:(.*?);/), a = r ? r[1] : "application/octet-stream", i = atob(s[s.length - 1]);
408
+ let o = i.length;
409
+ const c = new Uint8Array(o);
452
410
  for (; o--; )
453
- a[o] = c.charCodeAt(o);
454
- return new File([a], e, { type: i });
455
- }, be = 4, Se = 50, xe = 5e3, j = (r) => new Promise((e) => {
456
- if (r.readyState >= 4) {
411
+ c[o] = i.charCodeAt(o);
412
+ return new File([c], e, { type: a });
413
+ }, De = 4, Ne = 50, be = 5e3, z = (t) => Math.min(1, Math.max(0, t)), K = (t) => new Promise((e) => {
414
+ if (t.readyState >= 4) {
457
415
  e();
458
416
  return;
459
417
  }
460
- let t = !1;
461
- const n = () => {
462
- t || (t = !0, e());
418
+ let s = !1;
419
+ const r = () => {
420
+ s || (s = !0, e());
463
421
  };
464
- r.addEventListener("canplaythrough", n, { once: !0 }), r.addEventListener("error", n, { once: !0 }), setTimeout(n, xe);
465
- }), V = (r, e) => {
466
- const t = document.createElement("audio");
467
- return t.src = r, t.loop = e, t.preload = "auto", t.setAttribute("playsinline", ""), t.setAttribute("webkit-playsinline", ""), t.load(), t;
468
- }, Ce = (r) => {
469
- r.muted = !0, r.play().then(() => {
470
- r.pause(), r.currentTime = 0, r.muted = !1;
422
+ t.addEventListener("canplaythrough", r, { once: !0 }), t.addEventListener("error", r, { once: !0 }), setTimeout(r, be);
423
+ }), $ = (t, e) => {
424
+ const s = document.createElement("audio");
425
+ return s.src = t, s.loop = e, s.preload = "auto", s.setAttribute("playsinline", ""), s.setAttribute("webkit-playsinline", ""), s.load(), s;
426
+ }, Fe = (t) => {
427
+ t.muted = !0, t.play().then(() => {
428
+ t.pause(), t.currentTime = 0, t.muted = !1;
471
429
  }).catch(() => {
472
- r.muted = !1;
430
+ t.muted = !1;
473
431
  });
474
432
  };
475
- class Ee {
433
+ class Oe {
476
434
  constructor(e = {}) {
477
- R(this, "sfxPoolSize");
478
- R(this, "coalesceMs");
479
- R(this, "muted", !0);
480
- R(this, "listeners", /* @__PURE__ */ new Set());
481
- R(this, "music", null);
482
- R(this, "musicWanted", null);
483
- R(this, "pools", /* @__PURE__ */ new Map());
435
+ _(this, "sfxPoolSize");
436
+ _(this, "coalesceMs");
437
+ _(this, "muted", !0);
438
+ _(this, "listeners", /* @__PURE__ */ new Set());
439
+ _(this, "music", null);
440
+ _(this, "musicUrl", null);
441
+ _(this, "musicReady", null);
442
+ _(this, "musicWanted", null);
443
+ _(this, "pools", /* @__PURE__ */ new Map());
484
444
  /** Last play time per SFX URL, for the coalesce window. */
485
- R(this, "lastPlayed", /* @__PURE__ */ new Map());
445
+ _(this, "lastPlayed", /* @__PURE__ */ new Map());
486
446
  /** Readiness promises so a loading gate can await decode/buffer. */
487
- R(this, "ready", /* @__PURE__ */ new Map());
488
- this.sfxPoolSize = e.sfxPoolSize ?? be, this.coalesceMs = e.coalesceMs ?? Se;
447
+ _(this, "ready", /* @__PURE__ */ new Map());
448
+ this.sfxPoolSize = e.sfxPoolSize ?? De, this.coalesceMs = e.coalesceMs ?? Ne;
489
449
  }
490
450
  /**
491
451
  * Create + buffer the looping music element. Await in the loading gate so the
492
452
  * unmute tap is instant. Idempotent per URL (re-requesting the same track is
493
453
  * a no-op that returns the in-flight promise).
494
454
  */
495
- prefetchMusic(e, t = 0.4) {
496
- this.musicWanted = { url: e, volume: t };
497
- const n = `music:${e}`, i = this.ready.get(n);
498
- if (i) return i;
499
- this.music = V(e, !0), this.music.volume = t;
500
- const c = j(this.music);
501
- return this.ready.set(n, c), c;
455
+ prefetchMusic(e, s = 0.4) {
456
+ const r = z(s);
457
+ if (this.musicWanted = { url: e, volume: r }, this.musicUrl === e && this.musicReady)
458
+ return this.music && (this.music.volume = r), this.musicReady;
459
+ this.music && (this.music.pause(), this.music.currentTime = 0, this.music.removeAttribute("src"), this.music.load()), this.music = $(e, !0), this.musicUrl = e, this.music.volume = r;
460
+ const a = K(this.music);
461
+ return this.musicReady = a, a;
502
462
  }
503
463
  /**
504
464
  * Create + buffer an SFX voice pool (round-robin so overlapping plays don't
505
465
  * cut each other off). Returns a promise that resolves when the first element
506
466
  * buffers. Idempotent per URL.
507
467
  */
508
- registerSound(e, t = 1) {
509
- const n = this.ready.get(e);
510
- if (n) return n;
511
- const i = [];
512
- for (let o = 0; o < this.sfxPoolSize; o += 1) {
513
- const a = V(e, !1);
514
- a.volume = t, a.addEventListener("ended", () => {
515
- a.currentTime = 0;
516
- }), i.push(a);
468
+ registerSound(e, s = 1) {
469
+ const r = this.ready.get(e);
470
+ if (r) return r;
471
+ const a = z(s), i = [];
472
+ for (let c = 0; c < this.sfxPoolSize; c += 1) {
473
+ const n = $(e, !1);
474
+ n.volume = a, n.addEventListener("ended", () => {
475
+ n.currentTime = 0;
476
+ }), i.push(n);
517
477
  }
518
- this.pools.set(e, { els: i, next: 0, volume: t });
519
- const c = j(i[0]);
520
- return this.ready.set(e, c), c;
478
+ this.pools.set(e, { els: i, next: 0, volume: a });
479
+ const o = K(i[0]);
480
+ return this.ready.set(e, o), o;
521
481
  }
522
482
  /** Subscribe to mute-state changes (for a toggle UI). Fires immediately with
523
483
  * the current state. Returns an unsubscribe. */
@@ -534,7 +494,7 @@ class Ee {
534
494
  * then start the music. All elements are already buffered, so this is instant.
535
495
  */
536
496
  setMuted(e) {
537
- e !== this.muted && (this.muted = e, this.muted || this.pools.forEach((t) => t.els.forEach(Ce)), this.applyMusic(), this.listeners.forEach((t) => t(this.muted)));
497
+ e !== this.muted && (this.muted = e, this.muted || this.pools.forEach((s) => s.els.forEach(Fe)), this.applyMusic(), this.listeners.forEach((s) => s(this.muted)));
538
498
  }
539
499
  toggleMuted() {
540
500
  this.setMuted(!this.muted);
@@ -545,29 +505,30 @@ class Ee {
545
505
  * same sound into one play, and does NO synchronous `currentTime` seek on a
546
506
  * ready element (the pool rewinds on `ended`, off the hot path).
547
507
  */
548
- playOneShot(e, t) {
508
+ playOneShot(e, s) {
549
509
  if (this.muted) return;
550
- const n = this.pools.get(e);
551
- if (!n) return;
552
- const i = performance.now();
553
- if (i - (this.lastPlayed.get(e) ?? -1 / 0) < this.coalesceMs) return;
554
- this.lastPlayed.set(e, i);
555
- const c = n.els.length;
510
+ const r = this.pools.get(e);
511
+ if (!r) return;
512
+ const a = performance.now();
513
+ if (a - (this.lastPlayed.get(e) ?? -1 / 0) < this.coalesceMs) return;
514
+ this.lastPlayed.set(e, a);
515
+ const i = r.els.length;
556
516
  let o;
557
- for (let a = 0; a < c; a += 1) {
558
- const s = n.els[(n.next + a) % c];
559
- if (s.paused) {
560
- o = s, n.next = (n.next + a + 1) % c;
517
+ for (let c = 0; c < i; c += 1) {
518
+ const n = r.els[(r.next + c) % i];
519
+ if (n.paused) {
520
+ o = n, r.next = (r.next + c + 1) % i;
561
521
  break;
562
522
  }
563
523
  }
564
- o || (o = n.els[n.next], n.next = (n.next + 1) % c), o.muted = !1, o.volume = t ?? n.volume, o.currentTime !== 0 && (o.currentTime = 0), o.play().catch(() => {
524
+ o || (o = r.els[r.next], r.next = (r.next + 1) % i), o.muted = !1, o.volume = z(s ?? r.volume), o.currentTime !== 0 && (o.currentTime = 0), o.play().catch(() => {
565
525
  });
566
526
  }
567
527
  /** Request the looping background track (buffer it with prefetchMusic, which
568
528
  * a loading gate awaits). Remembered while muted; starts on unmute. */
569
- startMusic(e, t = 0.4) {
570
- this.musicWanted = { url: e, volume: t }, this.applyMusic();
529
+ startMusic(e, s = 0.4) {
530
+ const r = z(s);
531
+ this.musicUrl !== e && this.prefetchMusic(e, r), this.musicWanted = { url: e, volume: r }, this.applyMusic();
571
532
  }
572
533
  stopMusic() {
573
534
  this.musicWanted = null, this.music && (this.music.pause(), this.music.currentTime = 0);
@@ -577,36 +538,176 @@ class Ee {
577
538
  }), this.muted && !this.music.paused && this.music.pause());
578
539
  }
579
540
  }
580
- const C = new Ee(), Xe = (r, e) => C.prefetchMusic(r, e), qe = (r, e) => C.registerSound(r, e), He = (r, e) => C.startMusic(r, e), Ze = () => C.stopMusic(), je = (r, e) => C.playOneShot(r, e), Ve = (r) => C.setMuted(r), Ye = () => C.toggleMuted(), Ke = () => C.isMuted(), Je = (r) => C.onMuteChange(r), Qe = () => {
581
- const [r, e] = W(C.isMuted());
582
- return k(() => C.onMuteChange(e), []), r;
541
+ const Ie = (t, e, s) => t === "infinite" || t === "loop" && e < Math.max(1, Math.floor(s)) ? "replay" : "ended", Ge = (t, e, s) => t && e !== s, ke = (t) => Math.min(100, Math.max(0, t)) / 100, ct = le(function({
542
+ src: e,
543
+ playMode: s = "once",
544
+ loopCount: r = 1,
545
+ autoplay: a = !1,
546
+ muted: i = !1,
547
+ volume: o = 100,
548
+ preload: c = "auto",
549
+ onReady: n,
550
+ onPlay: u,
551
+ onPause: S,
552
+ onEnded: d,
553
+ onError: m
554
+ }, h) {
555
+ const l = A(null), T = A(0), g = A(null), E = w(async () => {
556
+ const R = l.current;
557
+ if (R)
558
+ try {
559
+ await R.play();
560
+ } catch (L) {
561
+ const O = L instanceof Error ? L : new Error(String(L));
562
+ throw m == null || m(O), O;
563
+ }
564
+ }, [m]), x = w(() => {
565
+ var R;
566
+ return (R = l.current) == null ? void 0 : R.pause();
567
+ }, []), P = w(() => {
568
+ const R = l.current;
569
+ R && (R.pause(), R.currentTime = 0, T.current = 0);
570
+ }, []);
571
+ de(
572
+ h,
573
+ () => ({
574
+ play: E,
575
+ pause: x,
576
+ stop: P,
577
+ get current() {
578
+ return l.current;
579
+ }
580
+ }),
581
+ [x, E, P]
582
+ ), U(() => {
583
+ T.current = 0, g.current = null;
584
+ }, [e]), U(() => {
585
+ l.current && (l.current.volume = ke(o));
586
+ }, [o]), U(() => {
587
+ Ge(a, g.current, e) && (g.current = e, E().catch(() => {
588
+ }));
589
+ }, [a, e]);
590
+ const W = w(() => {
591
+ T.current += 1;
592
+ const R = Math.max(1, Math.floor(r));
593
+ if (Ie(s, T.current, R) === "replay") {
594
+ const L = l.current;
595
+ L && (L.currentTime = 0, E().catch(() => {
596
+ }));
597
+ return;
598
+ }
599
+ T.current = 0, d == null || d();
600
+ }, [r, d, E, s]);
601
+ return /* @__PURE__ */ f(
602
+ "audio",
603
+ {
604
+ ref: l,
605
+ src: e,
606
+ preload: c,
607
+ autoPlay: !1,
608
+ muted: i,
609
+ loop: !1,
610
+ playsInline: !0,
611
+ style: { display: "none" },
612
+ onCanPlayThrough: n,
613
+ onPlay: u,
614
+ onPause: S,
615
+ onEnded: W,
616
+ onError: () => m == null ? void 0 : m(new Error(`Unable to load audio: ${e}`))
617
+ }
618
+ );
619
+ }), C = new Oe(), ut = (t, e) => C.prefetchMusic(t, e), lt = (t, e) => C.registerSound(t, e), dt = (t, e) => C.startMusic(t, e), mt = () => C.stopMusic(), pt = (t, e) => C.playOneShot(t, e), ht = (t) => C.setMuted(t), ft = () => C.toggleMuted(), Et = () => C.isMuted(), St = (t) => C.onMuteChange(t), Tt = () => {
620
+ const [t, e] = b(C.isMuted());
621
+ return U(() => C.onMuteChange(e), []), t;
583
622
  };
584
623
  export {
585
- Ae as AspectRatioContainer,
586
- Ee as AudioEngine,
587
- _e as Panel,
588
- ze as ScreenSpaceUI,
624
+ st as AspectRatioContainer,
625
+ Oe as AudioEngine,
626
+ ct as AudioPlayer,
627
+ rt as Axes,
628
+ gs as DEFAULT_MATERIAL_FILL,
629
+ Ss as DEFAULT_MESH_RENDERER,
630
+ Ts as DEFAULT_MESH_RENDERER_RENDER_STATE,
631
+ jt as DEFAULT_PIXEL_SNAP_INCREMENT,
632
+ qt as DEFAULT_REFERENCE_PIXELS_PER_UNIT,
633
+ Yt as DEFAULT_SCREEN_GLASS,
634
+ ws as DEFAULT_SCREEN_GRADIENT,
635
+ Zt as DEFAULT_SCREEN_IMAGE_SCENE_SETTINGS,
636
+ Kt as DEFAULT_SCREEN_IMAGE_SETTINGS,
637
+ $t as DEFAULT_SCREEN_SHAPE_SETTINGS,
638
+ Jt as DEFAULT_SCREEN_TEXT_SCENE_SETTINGS,
639
+ Qt as DEFAULT_SCREEN_TEXT_SHADOW_LAYER,
640
+ es as DEFAULT_SCREEN_TRANSFORM_2D,
641
+ ts as DEFAULT_SCREEN_TRANSFORM_ROOT,
642
+ As as DEFAULT_TRANSFORM_3D,
643
+ ss as EXTERNAL_BACKGROUND_RENDER_LAYER,
644
+ xt as LightObject,
645
+ vt as LookAt,
646
+ rs as MAX_RENDER_GROUP_PASSES,
647
+ _s as MaterialFill,
648
+ bs as MeshMaterial,
649
+ Ms as MeshRenderer,
650
+ et as Panel,
651
+ as as PinToMesh,
652
+ Ct as RenderGroupLayer,
653
+ Pt as SceneObjectRenderer,
654
+ ns as ScreenGlassMaterial,
655
+ xs as ScreenGradientMaterial,
656
+ Lt as ScreenImage,
657
+ os as ScreenShape,
658
+ Ut as ScreenSpaceUI,
659
+ Dt as ScreenText,
589
660
  ie as ScreenTransform,
590
- Be as SpriteAnimation,
591
- Ie as TextLabel,
592
- Ne as VideoBackground,
593
- rt as XRMediaSource,
594
- re as XRModel,
595
- nt as XRProvider,
596
- it as XRScene,
661
+ Nt as SequentialRenderPasses,
662
+ at as SpriteAnimation,
663
+ bt as TextLabel,
664
+ vs as Transform3D,
665
+ tt as VideoBackground,
666
+ yt as XRMediaSource,
667
+ ne as XRModel,
668
+ gt as XRProvider,
669
+ At as XRScene,
597
670
  C as audio,
598
- pe as computeContainScale,
599
- Ge as dataURLtoFile,
600
- Ke as isMuted,
601
- Je as onMuteChange,
602
- je as playOneShot,
603
- Xe as prefetchMusic,
604
- qe as registerSound,
605
- Ve as setMuted,
606
- He as startMusic,
607
- Ze as stopMusic,
608
- Ye as toggleMuted,
609
- $e as useMediaRecorder,
610
- Qe as useMuted,
611
- oe as useScreenRectAspect
671
+ Ft as clientToScreenPixels,
672
+ ce as computeContainScale,
673
+ Cs as createTwoStopGradient,
674
+ it as dataURLtoFile,
675
+ Us as drawNormalizedCrop,
676
+ is as getRenderGroupLayer,
677
+ Et as isMuted,
678
+ cs as mapScreenImageSettingsToProps,
679
+ us as mapScreenTextInnerShadowToProps,
680
+ ls as mapScreenTextSettingsToProps,
681
+ Ot as mediaToScreenPixels,
682
+ ds as mergeScreenShapeSettings,
683
+ ms as mergeScreenTransform2D,
684
+ Rs as normalizeMeshRendererRenderState,
685
+ ps as normalizeScreenGlass,
686
+ Ps as normalizeScreenGradient,
687
+ It as normalizedToScreenPixels,
688
+ St as onMuteChange,
689
+ pt as playOneShot,
690
+ ut as prefetchMusic,
691
+ lt as registerSound,
692
+ hs as renderSequentialPasses,
693
+ Ds as resolveNormalizedCrop,
694
+ fs as resolveScreenTransform2D,
695
+ Gt as screenPixelsToClient,
696
+ kt as screenPixelsToMedia,
697
+ zt as screenPixelsToNormalized,
698
+ Wt as screenPixelsToUnits,
699
+ Xt as screenPointToRay,
700
+ Vt as screenUnitsToPixels,
701
+ ht as setMuted,
702
+ I as smoothNumber,
703
+ Je as smoothVector2,
704
+ Qe as smoothVector3,
705
+ dt as startMusic,
706
+ mt as stopMusic,
707
+ ft as toggleMuted,
708
+ ot as useFrameCapture,
709
+ nt as useMediaRecorder,
710
+ Tt as useMuted,
711
+ ge as useScreenRectAspect,
712
+ Ht as worldToScreenPixels
612
713
  };