@vincentt-xr/sdk 2.0.0-alpha.7 → 2.0.0-alpha.8

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 (275) hide show
  1. package/GROUNDING.md +1109 -13
  2. package/dist/{DebuggerUI-BjOMr8q_.js → DebuggerUI-C-ldiozL.js} +1 -1
  3. package/dist/{DebuggerUI-B6bP6P9r.cjs → DebuggerUI-CWX5EtQv.cjs} +1 -1
  4. package/dist/FaceMeshRenderer-BEEXZwS6.cjs +158 -0
  5. package/dist/FaceMeshRenderer-UuH5sTXG.js +1322 -0
  6. package/dist/FaceRetouch-C7h7x9kd.js +683 -0
  7. package/dist/FaceRetouch-DqftT26Y.cjs +134 -0
  8. package/dist/GLTFLoader-C5q63sKO.js +1633 -0
  9. package/dist/GLTFLoader-Cb_CRwmG.cjs +1 -0
  10. package/dist/SegmentationOverlay-DQuW3dsc.js +133 -0
  11. package/dist/SegmentationOverlay-aWVod8Kl.cjs +1 -0
  12. package/dist/assets/cache.d.ts +99 -0
  13. package/dist/assets/estimate.d.ts +11 -0
  14. package/dist/assets/index.d.ts +7 -0
  15. package/dist/assets/loaders.d.ts +28 -0
  16. package/dist/assets/react.d.ts +33 -0
  17. package/dist/calibration/calibration.d.ts +70 -0
  18. package/dist/calibration/index.d.ts +6 -0
  19. package/dist/calibration/storage.d.ts +13 -0
  20. package/dist/calibration/types.d.ts +53 -0
  21. package/dist/calibration/useXRCalibration.d.ts +46 -0
  22. package/dist/camera/CameraPermissionGate.d.ts +26 -0
  23. package/dist/camera/devices.d.ts +26 -0
  24. package/dist/camera/index.d.ts +8 -0
  25. package/dist/camera/permission.d.ts +86 -0
  26. package/dist/camera/useCameraPermission.d.ts +35 -0
  27. package/dist/capabilities/detect.d.ts +45 -0
  28. package/dist/capabilities/index.d.ts +5 -0
  29. package/dist/capabilities/types.d.ts +120 -0
  30. package/dist/capabilities/useXRCapabilities.d.ts +18 -0
  31. package/dist/compat/environment.d.ts +5 -0
  32. package/dist/compat/index.d.ts +4 -0
  33. package/dist/compat/run.d.ts +18 -0
  34. package/dist/compat/scenarios.d.ts +10 -0
  35. package/dist/compat/types.d.ts +101 -0
  36. package/dist/components/BodyTracker/index.d.ts +9 -0
  37. package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +33 -3
  38. package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +12 -0
  39. package/dist/components/FaceMesh/canonical/shaders.d.ts +1 -1
  40. package/dist/components/FaceMesh/index.d.ts +1 -1
  41. package/dist/components/GestureListener/index.d.ts +11 -0
  42. package/dist/components/HandTracker/index.d.ts +10 -0
  43. package/dist/components/HolisticTracker/index.d.ts +69 -0
  44. package/dist/components/HolisticTracker/settings.d.ts +58 -0
  45. package/dist/components/HolisticTracker/signals.d.ts +49 -0
  46. package/dist/components/IrisEffect/IrisMaterial.d.ts +73 -0
  47. package/dist/components/IrisEffect/index.d.ts +51 -0
  48. package/dist/components/IrisEffect/settings.d.ts +117 -0
  49. package/dist/components/LipEffect/LipEffect.d.ts +7 -1
  50. package/dist/components/LipEffect/LipEffectMaterial.d.ts +43 -7
  51. package/dist/components/LipEffect/LipEffects.d.ts +9 -0
  52. package/dist/components/LipEffect/defaults.d.ts +27 -4
  53. package/dist/components/LipEffect/index.d.ts +11 -3
  54. package/dist/components/LipEffect/settings.d.ts +271 -0
  55. package/dist/components/LipEffect/types.d.ts +56 -9
  56. package/dist/components/LipEffect/useLipDesignTextures.d.ts +11 -0
  57. package/dist/components/LipEffect/uvGuide.d.ts +59 -0
  58. package/dist/components/PersonCutout/index.d.ts +50 -0
  59. package/dist/components/PersonCutout/personCutout.d.ts +16 -0
  60. package/dist/components/ScreenImage/components/ScreenImageBody.d.ts +1 -1
  61. package/dist/components/ScreenImage/index.d.ts +3 -1
  62. package/dist/components/ScreenImage/materials/ScreenImageBlendMaterial.d.ts +1 -1
  63. package/dist/components/ScreenImage/materials/ScreenImageMaskMaterial.d.ts +11 -0
  64. package/dist/components/ScreenImage/source.d.ts +6 -0
  65. package/dist/components/ScreenImage/types.d.ts +18 -0
  66. package/dist/components/SegmentationOverlay/SegmentationOverlay.d.ts +37 -0
  67. package/dist/components/SegmentationOverlay/SegmentationOverlayMaterial.d.ts +31 -0
  68. package/dist/components/SegmentationOverlay/index.d.ts +9 -0
  69. package/dist/components/SegmentationOverlay/maskTexture.d.ts +23 -0
  70. package/dist/components/SegmentationOverlay/providers.d.ts +72 -0
  71. package/dist/components/SegmentationOverlay/settings.d.ts +65 -0
  72. package/dist/components/XRProvider/index.d.ts +16 -2
  73. package/dist/components/XRViewport/hooks/useViewportExternalFaces.d.ts +1 -1
  74. package/dist/components/XRViewport/hooks/useViewportMediaSource.d.ts +1 -1
  75. package/dist/components/XRViewport/hooks/useViewportPipeline.d.ts +1 -1
  76. package/dist/components/index.d.ts +3 -0
  77. package/dist/constants/index.d.ts +4 -1
  78. package/dist/contexts-CO0sd4JQ.cjs +1 -0
  79. package/dist/{contexts-ByhzppYl.js → contexts-FzlnnMYD.js} +252 -246
  80. package/dist/coordinates/feed.d.ts +52 -0
  81. package/dist/coordinates/index.d.ts +5 -0
  82. package/dist/coordinates/spaces.d.ts +49 -0
  83. package/dist/coordinates/viewport.d.ts +22 -0
  84. package/dist/coordinates/world.d.ts +15 -0
  85. package/dist/debug-ui/gesture-settings/index.d.ts +14 -0
  86. package/dist/debug-ui/holistic-tracker-settings/index.d.ts +16 -0
  87. package/dist/debug-ui/index.d.ts +14 -0
  88. package/dist/debug-ui/iris-effect-settings/index.d.ts +12 -0
  89. package/dist/debug-ui/lip-effect-settings/index.d.ts +15 -0
  90. package/dist/debug-ui/media-source.cjs +1 -1
  91. package/dist/debug-ui/media-source.js +1 -1
  92. package/dist/debug-ui/product-hotspots/index.d.ts +24 -0
  93. package/dist/debug-ui/segmentation-overlay-settings/index.d.ts +12 -0
  94. package/dist/debug-ui/xr-diagnostics/index.d.ts +25 -0
  95. package/dist/debug-ui.cjs +3 -3
  96. package/dist/debug-ui.js +2057 -1687
  97. package/dist/detector-K8aej4MB.js +59 -0
  98. package/dist/detector-ijypGtse.cjs +1 -0
  99. package/dist/entries/core.d.ts +18 -1
  100. package/dist/entries/face-effects.d.ts +11 -3
  101. package/dist/entries/low-level.d.ts +22 -3
  102. package/dist/entries/product.d.ts +11 -0
  103. package/dist/entries/tracking.d.ts +24 -1
  104. package/dist/face-effects.cjs +155 -1
  105. package/dist/face-effects.js +1134 -2197
  106. package/dist/gestures/definitions.d.ts +85 -0
  107. package/dist/gestures/detector.d.ts +87 -0
  108. package/dist/gestures/index.d.ts +8 -0
  109. package/dist/gestures/measures.d.ts +101 -0
  110. package/dist/gestures/settings.d.ts +49 -0
  111. package/dist/{getFaceInfo-C4QpCQIY.js → getFaceInfo-BkZfaQs-.js} +5 -5
  112. package/dist/{getFaceInfo-fA1bFBub.cjs → getFaceInfo-ahPxQFGu.cjs} +1 -1
  113. package/dist/hooks/selectors.d.ts +68 -1
  114. package/dist/hooks/useCalibrationFaceTracker.d.ts +1 -1
  115. package/dist/hooks/useFaceInfo.d.ts +13 -1
  116. package/dist/hooks/useFaceInfos.d.ts +1 -1
  117. package/dist/hooks/useGesture.d.ts +32 -0
  118. package/dist/hooks/useIrisTracking.d.ts +45 -0
  119. package/dist/hooks/useXRDiagnostics.d.ts +81 -0
  120. package/dist/hooks/useXRModel.d.ts +7 -0
  121. package/dist/hooks/useXRSession/facade.d.ts +42 -2
  122. package/dist/hooks/useXRSession/index.d.ts +2 -2
  123. package/dist/hooks/useXRSession/reason.d.ts +3 -1
  124. package/dist/hooks/useXRSession/registry.d.ts +14 -0
  125. package/dist/hooks/useXRSession/store.d.ts +52 -3
  126. package/dist/index--RgGzZ6X.cjs +47 -0
  127. package/dist/{index-VJ0SJwmG.js → index-CHVbH0hz.js} +4 -4
  128. package/dist/index-CeVkgsag.cjs +1 -0
  129. package/dist/index-CnGox6Xr.js +3054 -0
  130. package/dist/{index-ByoNj0QP.js → index-CsUdQ-pn.js} +113 -111
  131. package/dist/{index-BjmTe9eM.cjs → index-DKBAh6hV.cjs} +1 -1
  132. package/dist/index-DsZwTfG0.cjs +1 -0
  133. package/dist/index-Dw6tj2Mi.js +144 -0
  134. package/dist/index-OCPjOaeP.cjs +1 -0
  135. package/dist/{index-DXT3WccE.js → index-s9pF4zkG.js} +1065 -1101
  136. package/dist/internal-BYza1h8_.cjs +1 -0
  137. package/dist/{internal-Dmk1cTXq.js → internal-vsfNQycj.js} +15 -16
  138. package/dist/internal.cjs +1 -1
  139. package/dist/internal.js +2 -2
  140. package/dist/iris/compute.d.ts +25 -0
  141. package/dist/iris/index.d.ts +4 -0
  142. package/dist/iris/lead.d.ts +19 -0
  143. package/dist/iris/types.d.ts +87 -0
  144. package/dist/landmarkMask-CbTFzBYG.js +224 -0
  145. package/dist/landmarkMask-u7es2k4X.cjs +1 -0
  146. package/dist/low-level.cjs +1 -1
  147. package/dist/low-level.js +1085 -634
  148. package/dist/main.cjs +1 -1
  149. package/dist/main.js +1519 -465
  150. package/dist/measures-9dQPdw96.js +154 -0
  151. package/dist/measures-KfJzpvod.cjs +1 -0
  152. package/dist/models/Base/index.d.ts +49 -0
  153. package/dist/models/Body/index.d.ts +1 -1
  154. package/dist/models/Face/index.d.ts +1 -1
  155. package/dist/models/Hand/GestureTracking.d.ts +1 -1
  156. package/dist/models/Hand/HandTracking.d.ts +1 -1
  157. package/dist/models/Holistic/index.d.ts +49 -0
  158. package/dist/models/Holistic/result.d.ts +68 -0
  159. package/dist/models/SemanticSegmentation/index.d.ts +31 -0
  160. package/dist/models/SemanticSegmentation/presets.d.ts +28 -0
  161. package/dist/models/index.d.ts +2 -0
  162. package/dist/product/ProductDimensions.d.ts +16 -0
  163. package/dist/product/ProductHotspot.d.ts +16 -0
  164. package/dist/product/ProductViewer.d.ts +9 -0
  165. package/dist/product/details.d.ts +53 -0
  166. package/dist/product/index.d.ts +14 -0
  167. package/dist/product/loadModelViewer.d.ts +4 -0
  168. package/dist/product/types.d.ts +71 -0
  169. package/dist/product/useProductAr.d.ts +37 -0
  170. package/dist/product/useProductDetails.d.ts +60 -0
  171. package/dist/product.cjs +1 -0
  172. package/dist/product.js +414 -0
  173. package/dist/providers-C0Dlhh9Z.js +365 -0
  174. package/dist/providers-YNwkmNeK.cjs +62 -0
  175. package/dist/quality/XRQualityController.d.ts +25 -0
  176. package/dist/quality/controller.d.ts +33 -0
  177. package/dist/quality/index.d.ts +6 -0
  178. package/dist/quality/types.d.ts +100 -0
  179. package/dist/quality/useXRQuality.d.ts +28 -0
  180. package/dist/{renderGroups-KZk6eRiY.js → renderGroups-CN1cGFUo.js} +1 -1
  181. package/dist/{renderGroups-80H3DpTl.cjs → renderGroups-O4KmaMl9.cjs} +1 -1
  182. package/dist/renderPasses-Cg-zqmEz.cjs +21 -0
  183. package/dist/renderPasses-NnKZVfBy.js +1460 -0
  184. package/dist/scene-object.cjs +1 -1
  185. package/dist/scene-object.js +2 -2
  186. package/dist/screenTransform-BenfCtZt.js +44 -0
  187. package/dist/screenTransform-BiXdpVf0.cjs +1 -0
  188. package/dist/segmentation-9PhSvc-R.cjs +1 -0
  189. package/dist/segmentation-CeOTKemr.js +5 -0
  190. package/dist/segmentation2d/faceMemory.d.ts +28 -0
  191. package/dist/segmentation2d/faceRegions.d.ts +24 -0
  192. package/dist/segmentation2d/index.d.ts +9 -0
  193. package/dist/segmentation2d/maskUv.d.ts +23 -0
  194. package/dist/segmentation2d/rasterize.d.ts +14 -0
  195. package/dist/segmentation2d/types.d.ts +46 -0
  196. package/dist/selectors-C5G1PMYL.js +195 -0
  197. package/dist/selectors-Du_PsVnW.cjs +1 -0
  198. package/dist/{session-CpkiK5YA.cjs → session-BBr0yN8h.cjs} +7 -7
  199. package/dist/{session-DLFN_VII.js → session-Cy0m7l7-.js} +76 -76
  200. package/dist/settings-DRR7-snV.cjs +1 -0
  201. package/dist/settings-aQk845NJ.js +73 -0
  202. package/dist/subjects/index.d.ts +2 -0
  203. package/dist/subjects/select.d.ts +62 -0
  204. package/dist/subjects/types.d.ts +55 -0
  205. package/dist/tracking-config/apply.d.ts +57 -0
  206. package/dist/tracking-config/index.d.ts +7 -0
  207. package/dist/tracking-config/resolve.d.ts +25 -0
  208. package/dist/tracking-config/storage.d.ts +8 -0
  209. package/dist/tracking-config/types.d.ts +106 -0
  210. package/dist/tracking-config/useXRTrackingConfig.d.ts +38 -0
  211. package/dist/tracking.cjs +1 -1
  212. package/dist/tracking.js +1056 -383
  213. package/dist/types/compositor.d.ts +21 -0
  214. package/dist/types/holistic.d.ts +121 -0
  215. package/dist/types/index.d.ts +1 -0
  216. package/dist/types/model.d.ts +22 -2
  217. package/dist/types/nodes.d.ts +27 -2
  218. package/dist/types/segmentation.d.ts +19 -0
  219. package/dist/types/session.d.ts +41 -3
  220. package/dist/useFaceInfo-Blf7FCu3.js +303 -0
  221. package/dist/useFaceInfo-C5mO8NQY.cjs +1 -0
  222. package/dist/useXRCapabilities-B1R2ghy-.cjs +1 -0
  223. package/dist/useXRCapabilities-C68v__wB.js +30 -0
  224. package/dist/utils/fns.d.ts +6 -3
  225. package/dist/utils/integrity.d.ts +4 -1
  226. package/dist/utils/updateThrottle.d.ts +2 -0
  227. package/dist/utils/useStableUniforms.d.ts +18 -0
  228. package/docs/api/adaptive-quality.mdx +104 -0
  229. package/docs/api/asset-lifecycle.mdx +78 -0
  230. package/docs/api/camera-permission.mdx +142 -0
  231. package/docs/api/coordinate-spaces.mdx +165 -0
  232. package/docs/api/cross-camera.mdx +88 -0
  233. package/docs/api/diagnostics-calibration.mdx +97 -0
  234. package/docs/api/face-effects.mdx +6 -0
  235. package/docs/api/face-mesh.mdx +4 -2
  236. package/docs/api/gestures.mdx +173 -0
  237. package/docs/api/holistic-tracker.mdx +159 -0
  238. package/docs/api/iris-tracking.mdx +242 -0
  239. package/docs/api/multi-subject.mdx +95 -0
  240. package/docs/api/person-cutout.mdx +136 -0
  241. package/docs/api/product-ar.mdx +111 -0
  242. package/docs/api/product-details.mdx +78 -0
  243. package/docs/api/screen-space-coordinates.mdx +4 -1
  244. package/docs/api/segmentation-overlay.mdx +301 -0
  245. package/docs/api/session-lifecycle.mdx +136 -0
  246. package/docs/api/trackers.mdx +5 -0
  247. package/docs/api/tracking-config.mdx +108 -0
  248. package/docs/docs.json +23 -1
  249. package/docs/examples/lip-shaders.mdx +224 -0
  250. package/docs/guides/lip-effect-textures.mdx +292 -0
  251. package/docs/guides/lip-uv-template.png +0 -0
  252. package/docs/guides/lip-uv-template.svg +1 -0
  253. package/package.json +13 -1
  254. package/dist/FaceMeshRenderer-C5l6VLdO.cjs +0 -155
  255. package/dist/FaceMeshRenderer-wjAHrJzP.js +0 -1270
  256. package/dist/FaceRetouch-BkJzoA79.cjs +0 -134
  257. package/dist/FaceRetouch-DwbKQJAN.js +0 -551
  258. package/dist/contexts-Dr62It_K.cjs +0 -1
  259. package/dist/index-9dlAQAhy.js +0 -1462
  260. package/dist/index-BpEf2BBb.cjs +0 -1
  261. package/dist/index-CyUUurQT.cjs +0 -1
  262. package/dist/index-DCiMbxC3.cjs +0 -1
  263. package/dist/index-DpI-qo5X.cjs +0 -17
  264. package/dist/index-DyVF4vEW.js +0 -111
  265. package/dist/internal-Cq-TEQ5Y.cjs +0 -1
  266. package/dist/renderLayers-lDtL0_43.cjs +0 -1
  267. package/dist/renderLayers-zrK2pv5O.js +0 -13
  268. package/dist/renderPasses-BOoBSr8z.cjs +0 -21
  269. package/dist/renderPasses-BcquyVtu.js +0 -1500
  270. package/dist/selectors-B8H97CKA.js +0 -59
  271. package/dist/selectors-CZLKT2Iv.cjs +0 -1
  272. package/dist/useFaceInfo-BJ8-_MOs.cjs +0 -1
  273. package/dist/useFaceInfo-Dk426LTu.js +0 -62
  274. package/dist/useFaceResults-CtetsO9M.js +0 -19
  275. package/dist/useFaceResults-wBJF3zyp.cjs +0 -1
@@ -1,1270 +0,0 @@
1
- import { jsx as g, jsxs as Fe, Fragment as Ye } from "react/jsx-runtime";
2
- import { useLoader as de, useThree as Bt, useFrame as Vt } from "@react-three/fiber";
3
- import { useMemo as Z, useRef as l, useState as $e, useCallback as He, useEffect as Ce } from "react";
4
- import * as m from "three";
5
- import { MathUtils as Ke, Color as Wt, Vector2 as Be } from "three";
6
- import { l as re, f as Xt, X as jt } from "./index-9dlAQAhy.js";
7
- import { c as Yt, u as $t } from "./selectors-B8H97CKA.js";
8
- import { t as Kt, p as Qt, b as qt } from "./index-ByoNj0QP.js";
9
- import { TransformControls as Zt } from "@react-three/drei";
10
- const _e = 8, K = {
11
- type: "linear",
12
- stops: [
13
- { offset: 0, color: "#38bdf8" },
14
- { offset: 1, color: "#a78bfa" }
15
- ],
16
- angle: 0,
17
- center: { x: 0.5, y: 0.5 },
18
- radius: 0.5
19
- }, Jt = (e) => {
20
- const n = e.slice(0, _e).map((t) => ({ ...t, offset: Ke.clamp(t.offset, 0, 1) })).sort((t, r) => t.offset - r.offset);
21
- return n.length >= 2 ? n : K.stops.map((t) => ({ ...t }));
22
- }, en = (e) => ({
23
- ...K,
24
- ...e,
25
- center: { ...K.center, ...e == null ? void 0 : e.center },
26
- radius: Math.max(0.01, (e == null ? void 0 : e.radius) ?? K.radius),
27
- stops: Jt((e == null ? void 0 : e.stops) ?? K.stops)
28
- }), tn = `
29
- varying vec2 vPosition;
30
- void main() {
31
- vPosition = position.xy;
32
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
33
- }
34
- `, nn = `
35
- #define MAX_STOPS 8
36
- uniform vec3 stopColors[MAX_STOPS];
37
- uniform float stopOffsets[MAX_STOPS];
38
- uniform int stopCount;
39
- uniform int gradientType;
40
- uniform vec2 direction;
41
- uniform vec2 center;
42
- uniform float radius;
43
- uniform float angleOffset;
44
- uniform float opacity;
45
- varying vec2 vPosition;
46
-
47
- vec3 sampleGradient(float amount) {
48
- vec3 color = stopColors[0];
49
- for (int index = 1; index < MAX_STOPS; index++) {
50
- if (index >= stopCount) break;
51
- if (amount <= stopOffsets[index]) {
52
- float width = max(0.0001, stopOffsets[index] - stopOffsets[index - 1]);
53
- return mix(stopColors[index - 1], stopColors[index], clamp((amount - stopOffsets[index - 1]) / width, 0.0, 1.0));
54
- }
55
- color = stopColors[index];
56
- }
57
- return color;
58
- }
59
-
60
- void main() {
61
- vec2 delta = vPosition - center;
62
- float amount;
63
- if (gradientType == 1) {
64
- amount = clamp(length(delta) / radius, 0.0, 1.0);
65
- } else if (gradientType == 2) {
66
- amount = fract(atan(delta.y, delta.x) / 6.28318530718 + 0.5 + angleOffset);
67
- } else {
68
- amount = clamp(dot(delta, direction) + 0.5, 0.0, 1.0);
69
- }
70
- gl_FragColor = vec4(sampleGradient(amount), opacity);
71
- }
72
- `, rn = { linear: 0, radial: 1, angular: 2 }, an = ({ opacity: e = 1, value: n }) => {
73
- const t = Z(() => {
74
- const r = en(n), a = Ke.degToRad(r.angle), o = r.stops.map((s) => new Wt(s.color)), i = r.stops.map((s) => s.offset);
75
- for (; o.length < _e; ) o.push(o[o.length - 1]);
76
- for (; i.length < _e; ) i.push(1);
77
- return {
78
- stopColors: { value: o },
79
- stopOffsets: { value: i },
80
- stopCount: { value: r.stops.length },
81
- gradientType: { value: rn[r.type] },
82
- direction: { value: new Be(Math.cos(a), Math.sin(a)) },
83
- center: { value: new Be(r.center.x - 0.5, 0.5 - r.center.y) },
84
- radius: { value: r.radius },
85
- angleOffset: { value: r.angle / 360 },
86
- opacity: { value: e }
87
- };
88
- }, [e, n]);
89
- return /* @__PURE__ */ g(
90
- "shaderMaterial",
91
- {
92
- uniforms: t,
93
- vertexShader: tn,
94
- fragmentShader: nn,
95
- transparent: e < 1,
96
- depthTest: !1,
97
- depthWrite: !1,
98
- toneMapped: !1
99
- }
100
- );
101
- }, on = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO2YpZcAAAAASUVORK5CYII=", Yn = {
102
- source: "solid",
103
- color: "#ffffff",
104
- opacity: 1,
105
- textureUrl: "",
106
- gradient: K
107
- }, Qe = (e) => ({
108
- ...K,
109
- stops: [
110
- { offset: 0, color: "#ffffff" },
111
- { offset: 1, color: e }
112
- ]
113
- }), sn = ({
114
- depthTest: e,
115
- depthWrite: n,
116
- settings: t,
117
- side: r,
118
- toneMapped: a
119
- }) => {
120
- const o = de(
121
- m.TextureLoader,
122
- t.textureUrl || on
123
- );
124
- return /* @__PURE__ */ g(
125
- "meshBasicMaterial",
126
- {
127
- color: t.color,
128
- map: o,
129
- transparent: !0,
130
- opacity: t.opacity,
131
- side: r,
132
- depthWrite: n,
133
- depthTest: e,
134
- toneMapped: a
135
- }
136
- );
137
- }, cn = ({
138
- depthTest: e = !1,
139
- depthWrite: n = !1,
140
- settings: t,
141
- side: r,
142
- toneMapped: a = !1
143
- }) => {
144
- const o = Z(
145
- () => t.gradient ?? Qe(t.color),
146
- [t.color, t.gradient]
147
- );
148
- return t.source === "gradient" ? /* @__PURE__ */ g(an, { value: o, opacity: t.opacity }) : t.source === "texture" ? /* @__PURE__ */ g(
149
- sn,
150
- {
151
- settings: t,
152
- side: r,
153
- depthTest: e,
154
- depthWrite: n,
155
- toneMapped: a
156
- }
157
- ) : /* @__PURE__ */ g(
158
- "meshBasicMaterial",
159
- {
160
- color: t.color,
161
- transparent: !0,
162
- opacity: t.opacity,
163
- side: r,
164
- depthWrite: n,
165
- depthTest: e,
166
- toneMapped: a
167
- }
168
- );
169
- }, Me = Math.PI / 180, xe = 180 / Math.PI, V = (e) => Number(e.toFixed(6)), Ve = {
170
- enabled: !0,
171
- linked: {
172
- position: !1,
173
- rotation: !1,
174
- scale: !1
175
- },
176
- showTransformControls: !1,
177
- transformControlMode: "translate",
178
- transformControlSpace: "local",
179
- position: { x: 0, y: 0, z: 0 },
180
- rotation: { x: 0, y: 0, z: 0 },
181
- scale: { x: 1, y: 1, z: 1 },
182
- visible: !0
183
- }, $n = ({ children: e, objectRef: n, onChange: t, value: r }) => {
184
- const a = l(null), o = l(n);
185
- o.current = n;
186
- const [i, s] = $e(null), f = He((c) => {
187
- var v;
188
- a.current = c, s(c), (v = o.current) == null || v.call(o, c);
189
- }, []), u = He(() => {
190
- const c = a.current;
191
- !c || !t || t({
192
- ...r,
193
- position: {
194
- x: V(c.position.x),
195
- y: V(c.position.y),
196
- z: V(c.position.z)
197
- },
198
- rotation: {
199
- x: V(c.rotation.x * xe),
200
- y: V(c.rotation.y * xe),
201
- z: V(c.rotation.z * xe)
202
- },
203
- scale: {
204
- x: V(c.scale.x),
205
- y: V(c.scale.y),
206
- z: V(c.scale.z)
207
- }
208
- });
209
- }, [t, r]);
210
- return r.enabled ? /* @__PURE__ */ Fe(Ye, { children: [
211
- /* @__PURE__ */ g(
212
- "group",
213
- {
214
- ref: f,
215
- position: [r.position.x, r.position.y, r.position.z],
216
- rotation: [
217
- r.rotation.x * Me,
218
- r.rotation.y * Me,
219
- r.rotation.z * Me
220
- ],
221
- scale: [r.scale.x, r.scale.y, r.scale.z],
222
- visible: r.visible,
223
- children: e
224
- }
225
- ),
226
- i && r.showTransformControls && /* @__PURE__ */ g(
227
- Zt,
228
- {
229
- object: i,
230
- mode: r.transformControlMode,
231
- space: r.transformControlSpace,
232
- size: 0.85,
233
- onMouseUp: u,
234
- onObjectChange: u
235
- }
236
- )
237
- ] }) : null;
238
- }, te = (e) => Math.min(1, Math.max(0, e)), L = (e, n, t) => te(1 - Math.abs(e - n) / t), ln = (e) => {
239
- let n = 1 / 0, t = -1 / 0, r = 1 / 0, a = -1 / 0;
240
- for (const s of e)
241
- n = Math.min(n, s.x), t = Math.max(t, s.x), r = Math.min(r, s.y), a = Math.max(a, s.y);
242
- const o = Math.max(t - n, 1e-3), i = Math.max(a - r, 1e-3);
243
- return {
244
- centerX: n + o * 0.5,
245
- centerY: r + i * 0.5,
246
- width: o,
247
- height: i
248
- };
249
- }, dn = (e) => e != null && e.enabled ? (e.strength ?? 1) !== 0 && Object.entries(e).some(
250
- ([n, t]) => n !== "enabled" && n !== "strength" && typeof t == "number" && t !== 0
251
- ) : !1, fn = (e, n, t, r) => {
252
- const a = t.enabled ? t.strength ?? 1 : 0;
253
- if (a === 0)
254
- return r.x = e.x, r.y = e.y, r.z = e.z, r;
255
- const o = (e.x - n.centerX) / n.width, i = (e.y - n.centerY) / n.height, s = Math.abs(o), f = te((-i + 0.42) / 0.55), u = L(i, -0.02, 0.34), c = L(i, -0.24, 0.16) * te((s - 0.05) / 0.28), v = L(i, 0.02, 0.26) * L(s, 0, 0.18), R = L(i, 0.29, 0.18) * L(s, 0, 0.36), D = te((i - 0.16) / 0.36), _ = u * L(s, 0.34, 0.22), F = f * L(s, 0, 0.48), S = L(i, -0.19, 0.1) * te((s - 0.05) / 0.3), Y = L(i, 0.48, 0.2) * L(s, 0, 0.26);
256
- let M = e.x, p = e.y, U = e.z;
257
- const y = (T, h = 1) => {
258
- M += o * n.width * T * a * h;
259
- }, d = (T, h = 1) => {
260
- p += i * n.height * T * a * h;
261
- };
262
- y(t.faceWidth ?? 0), d(t.faceHeight ?? 0), y(t.faceRoundness ?? 0, u * (1 - s)), p -= n.height * (t.midfaceHeight ?? 0) * a * u * 0.25, d(-(t.foreheadHeight ?? 0), F), y(t.foreheadWidth ?? 0, F), y(
263
- t.cheekboneWidth ?? 0,
264
- L(i, -0.06, 0.16) * L(s, 0.34, 0.2)
265
- ), y(t.cheekWidth ?? 0, _), y(t.jawWidth ?? 0, D), d(t.chinHeight ?? 0, Y), p -= n.height * (t.scalpHeight ?? 0) * a * f * 0.3, U -= (t.midfaceDepth ?? 0) * a * u * 0.08, U += (t.cheekHollowness ?? 0) * a * _ * 0.06, U -= (t.browDepth ?? 0) * a * S * 0.05, p -= n.height * (t.browHeight ?? 0) * a * S * 0.2, M += Math.sign(o || 1) * n.width * (t.browDistance ?? 0) * a * S * 0.16;
266
- const k = (t.headCurve ?? 0) * a * (i + 0.1);
267
- U -= k * k * 0.04 * Math.sign(t.headCurve ?? 0), M += n.width * (t.faceTwist ?? 0) * a * i * 0.18;
268
- const N = (t.faceSwirl ?? 0) * a * 0.22;
269
- M += -i * n.width * N, p += o * n.height * N;
270
- const I = o < 0 ? t.leftEyeSize ?? 0 : t.rightEyeSize ?? 0, x = ((t.eyeSize ?? 0) + I) * a * c;
271
- M += o * n.width * x * 0.45, p += (i + 0.24) * n.height * x * 0.7, M += Math.sign(o || 1) * n.width * (t.eyeDistance ?? 0) * a * c * 0.2, M += n.width * (o < 0 ? t.leftEyeX ?? 0 : t.rightEyeX ?? 0) * a * c * 0.15, p += n.height * (o < 0 ? t.leftEyeY ?? 0 : t.rightEyeY ?? 0) * a * c * 0.15;
272
- const E = (t.noseSize ?? 0) * a * v;
273
- return M += o * n.width * E * 0.7, p += (i - 0.02) * n.height * E * 0.5, p += n.height * (t.noseLength ?? 0) * a * v * Math.max(i + 0.08, 0) * 0.4, U -= (t.noseSize ?? 0) * a * v * 0.08, M += o * n.width * (t.mouthWidth ?? 0) * a * R, p += (i - 0.29) * n.height * (t.mouthHeight ?? 0) * a * R, r.x = M, r.y = p, r.z = U, r;
274
- }, Ae = /* @__PURE__ */ new Set([
275
- 61,
276
- 146,
277
- 91,
278
- 181,
279
- 84,
280
- 17,
281
- 314,
282
- 405,
283
- 321,
284
- 375,
285
- 291,
286
- 78,
287
- 95,
288
- 88,
289
- 178,
290
- 87,
291
- 14,
292
- 317,
293
- 402,
294
- 318,
295
- 324,
296
- 308,
297
- 191,
298
- 80,
299
- 81,
300
- 82,
301
- 13,
302
- 312,
303
- 311,
304
- 310,
305
- 415
306
- ]), We = [
307
- 61,
308
- 146,
309
- 91,
310
- 181,
311
- 84,
312
- 17,
313
- 314,
314
- 405,
315
- 321,
316
- 375,
317
- 291,
318
- 409,
319
- 270,
320
- 269,
321
- 267,
322
- 0,
323
- 37,
324
- 39,
325
- 40,
326
- 185
327
- ], ve = /* @__PURE__ */ new Set([
328
- 33,
329
- 7,
330
- 163,
331
- 144,
332
- 145,
333
- 153,
334
- 154,
335
- 155,
336
- 133,
337
- 173,
338
- 157,
339
- 158,
340
- 159,
341
- 160,
342
- 161,
343
- 246
344
- ]), Ee = /* @__PURE__ */ new Set([
345
- 362,
346
- 382,
347
- 381,
348
- 380,
349
- 374,
350
- 373,
351
- 390,
352
- 249,
353
- 263,
354
- 466,
355
- 388,
356
- 387,
357
- 386,
358
- 385,
359
- 384,
360
- 398
361
- ]), un = /* @__PURE__ */ new Set([814, 815, 816, 817, 818, 819, 830, 831, 832, 833]), hn = (e, n, t) => {
362
- const r = Ae.has(e) && Ae.has(n) && Ae.has(t), a = ve.has(e) && ve.has(n) && ve.has(t), o = Ee.has(e) && Ee.has(n) && Ee.has(t);
363
- return r ? "mouth" : a ? "leftEye" : o ? "rightEye" : "base";
364
- }, mn = (e) => {
365
- const n = /* @__PURE__ */ new Map();
366
- for (let s = 0; s < e.length; s += 3) {
367
- const f = [e[s], e[s + 1], e[s + 2]];
368
- for (let u = 0; u < 3; u += 1) {
369
- const c = f[u], v = f[(u + 1) % 3], R = c < v ? `${c}:${v}` : `${v}:${c}`, D = n.get(R);
370
- D ? D.count += 1 : n.set(R, { a: c, b: v, count: 1 });
371
- }
372
- }
373
- const t = /* @__PURE__ */ new Map();
374
- n.forEach(({ a: s, b: f, count: u }) => {
375
- u === 1 && (t.set(s, [...t.get(s) ?? [], f]), t.set(f, [...t.get(f) ?? [], s]));
376
- });
377
- const r = [...t.keys()].sort((s, f) => s - f)[0];
378
- if (r === void 0) return [];
379
- const a = [r];
380
- let o = -1, i = r;
381
- for (; a.length <= t.size + 1; ) {
382
- const s = (t.get(i) ?? []).find((f) => f !== o);
383
- if (s === void 0 || s === r) break;
384
- a.push(s), o = i, i = s;
385
- }
386
- return a;
387
- }, pn = (e) => {
388
- const n = [], t = [], r = [], a = [], o = [], i = [], s = [], f = [];
389
- let u = 0, c = 0;
390
- e.split(`
391
- `).forEach((y) => {
392
- const d = y.trim();
393
- if (!d) return;
394
- if (d.startsWith("v ")) {
395
- const [, x, E, T] = d.split(/\s+/);
396
- s.push([Number(x), Number(E), Number(T)]), u += 1;
397
- return;
398
- }
399
- if (d.startsWith("vt ")) {
400
- const [, x, E] = d.split(/\s+/);
401
- i.push([Number(x), Number(E)]);
402
- return;
403
- }
404
- if (!d.startsWith("f ")) return;
405
- const k = c;
406
- c += 1;
407
- const [, ...N] = d.split(/\s+/), I = N.map((x) => {
408
- const [E, T] = x.split("/"), h = Number(E) - 1, z = Number(T) - 1;
409
- return z >= 0 && i[z] && !f[h] && (f[h] = i[z]), h;
410
- });
411
- if (!(I.length < 3))
412
- for (let x = 1; x < I.length - 1; x += 1) {
413
- const E = I[0], T = I[x], h = I[x + 1], z = hn(E, T, h);
414
- un.has(k) ? o.push(E, T, h) : z === "mouth" ? t.push(E, T, h) : z === "leftEye" ? r.push(E, T, h) : z === "rightEye" ? a.push(E, T, h) : n.push(E, T, h);
415
- }
416
- });
417
- const v = [];
418
- for (let y = 0; y < u; y += 1) {
419
- const [d, k] = f[y] ?? [0, 0];
420
- v.push(d, k);
421
- }
422
- const R = new Uint16Array(r), D = new Uint16Array(a), _ = new Uint16Array(r.length + a.length);
423
- _.set(R), _.set(D, R.length);
424
- const F = We.map((y) => {
425
- const [d, k] = s[y] ?? [0, 0];
426
- return new m.Vector2(d, k);
427
- }), S = mn(t), Y = S.map((y) => {
428
- const [d, k] = s[y] ?? [0, 0];
429
- return new m.Vector2(d, k);
430
- }), M = m.ShapeUtils.triangulateShape(F, [Y]), p = [...We, ...S], U = new Uint16Array(
431
- S.length > 2 ? M.flatMap((y) => y.map((d) => p[d])) : []
432
- );
433
- return {
434
- baseIndices: new Uint16Array(n),
435
- mouthIndices: new Uint16Array(t),
436
- lipIndices: U,
437
- leftEyeIndices: R,
438
- rightEyeIndices: D,
439
- eyeIndices: _,
440
- noseIndices: new Uint16Array(o),
441
- uvs: new Float32Array(v),
442
- vertexCount: u
443
- };
444
- }, yn = "canonical_face_model.obj", bn = new TextDecoder("utf-8"), Se = /* @__PURE__ */ new Map(), gn = (e) => {
445
- const n = Se.get(e);
446
- if (n) return n;
447
- const t = Xt(e).then((r) => pn(bn.decode(r))).catch((r) => {
448
- throw Se.delete(e), r;
449
- });
450
- return Se.set(e, t), t;
451
- }, Mn = (e) => {
452
- const { mesh: n, url: t } = e ?? {}, r = t ?? `${re.sdkAssetsBaseUrl}/${yn}`, [a, o] = $e(n ?? null);
453
- return Ce(() => {
454
- if (n) {
455
- o(n);
456
- return;
457
- }
458
- let i = !1;
459
- return gn(r).then((s) => {
460
- i || o(s);
461
- }).catch((s) => {
462
- i || console.error(`${re.loggerPrefix} canonical face mesh load failed`, s);
463
- }), () => {
464
- i = !0;
465
- };
466
- }, [n, r]), a;
467
- }, C = {
468
- basic: "basic",
469
- standard: "standard",
470
- physical: "physical",
471
- toon: "toon",
472
- normal: "normal",
473
- matcap: "matcap",
474
- wireframe: "wireframe",
475
- shader: "shader"
476
- }, X = {
477
- originalFace: "originalFace",
478
- composite: "composite"
479
- }, j = {
480
- none: "none",
481
- canonical: "canonical",
482
- style2: "style2"
483
- }, J = {
484
- none: "none",
485
- canonical: "canonical"
486
- }, ae = {
487
- solid: "solid",
488
- gradient: "gradient",
489
- imageUrl: "imageUrl",
490
- mediaUrl: "mediaUrl"
491
- }, ne = {
492
- front: "front",
493
- back: "back",
494
- double: "double"
495
- }, qe = {
496
- normal: "normal",
497
- add: "add",
498
- subtract: "subtract",
499
- multiply: "multiply",
500
- screen: "screen",
501
- overlay: "overlay",
502
- softLight: "softLight",
503
- hardLight: "hardLight",
504
- lighten: "lighten",
505
- darken: "darken",
506
- difference: "difference",
507
- exclusion: "exclusion"
508
- }, xn = {
509
- textureMap: j.canonical,
510
- alphaMap: J.canonical,
511
- alphaOpacity: 1
512
- }, Xe = {
513
- ...xn,
514
- blendMode: qe.hardLight,
515
- blendOpacity: 0.85,
516
- baseColor: "#ffffff",
517
- opacity: 1,
518
- compositeShading: !0
519
- }, G = {
520
- materialType: C.basic,
521
- shaderPreset: X.originalFace,
522
- textureMap: j.none,
523
- alphaMap: J.none,
524
- alphaOpacity: 1,
525
- side: ne.front,
526
- blendMode: qe.normal,
527
- blendOpacity: 1,
528
- baseColor: "#38bdf8",
529
- opacity: 0.45,
530
- compositeShading: !1
531
- };
532
- C.shader, X.composite, ne.front;
533
- const Te = {
534
- mouth: !0,
535
- eyes: !0,
536
- nose: !0
537
- }, ee = {
538
- textureSource: ae.solid,
539
- color: "#111111",
540
- opacity: 0.5
541
- }, An = 24, Ze = 10, we = (e, n, t) => e !== C.shader ? "none" : n === X.originalFace ? "originalFace" : n === X.composite ? t === j.none ? "originalFace" : "composite" : "none", Kn = (e, n) => e === C.basic || e === C.standard || e === C.physical || e === C.toon || e === C.shader && n === X.composite, Qn = (e, n, t = j.canonical) => we(e, n, t) === "composite", vn = (e, n, t) => we(e, n, t) === "originalFace", ke = (e) => e === ae.imageUrl || e === ae.mediaUrl, En = (e) => e === ae.solid || e === ae.gradient, je = {
542
- normal: 0,
543
- add: 1,
544
- subtract: 2,
545
- multiply: 3,
546
- screen: 4,
547
- overlay: 5,
548
- softLight: 6,
549
- hardLight: 7,
550
- lighten: 8,
551
- darken: 9,
552
- difference: 10,
553
- exclusion: 11
554
- }, Re = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO2YpZcAAAAASUVORK5CYII=", Sn = () => {
555
- const e = new Uint8Array([
556
- 32,
557
- 32,
558
- 32,
559
- 255,
560
- 96,
561
- 96,
562
- 96,
563
- 255,
564
- 176,
565
- 176,
566
- 176,
567
- 255,
568
- 255,
569
- 255,
570
- 255,
571
- 255
572
- ]), n = new m.DataTexture(e, 4, 1, m.RGBAFormat);
573
- return n.minFilter = m.NearestFilter, n.magFilter = m.NearestFilter, n.generateMipmaps = !1, n.needsUpdate = !0, n;
574
- }, Tn = () => {
575
- const e = document.createElement("canvas");
576
- e.width = 256, e.height = 256;
577
- const n = e.getContext("2d");
578
- if (!n)
579
- return new m.CanvasTexture(e);
580
- const t = n.createRadialGradient(96, 80, 10, 128, 128, 128);
581
- t.addColorStop(0, "#ffffff"), t.addColorStop(0.18, "#f7d794"), t.addColorStop(0.45, "#d97706"), t.addColorStop(0.72, "#78350f"), t.addColorStop(1, "#120701"), n.fillStyle = t, n.fillRect(0, 0, e.width, e.height);
582
- const r = new m.CanvasTexture(e);
583
- return r.needsUpdate = !0, r;
584
- }, Rn = `
585
- attribute vec2 faceUv;
586
- varying vec2 vUv;
587
- varying vec2 vFaceUv;
588
- varying vec3 vNormal;
589
-
590
- void main() {
591
- vUv = uv;
592
- vFaceUv = faceUv;
593
- vNormal = normalize(normalMatrix * normal);
594
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
595
- }
596
- `, Cn = `
597
- uniform sampler2D cameraTexture;
598
- uniform sampler2D canonicalTexture;
599
- uniform sampler2D alphaMask;
600
- uniform vec3 textureTint;
601
- uniform float opacity;
602
- uniform int blendMode;
603
- uniform float blendOpacity;
604
- uniform float useCanonicalTexture;
605
- uniform float useAlphaMask;
606
- uniform float alphaOpacity;
607
- uniform float compositeShading;
608
- uniform vec3 lightDirection;
609
- uniform float ambientStrength;
610
- uniform float directionalStrength;
611
- varying vec2 vUv;
612
- varying vec2 vFaceUv;
613
- varying vec3 vNormal;
614
-
615
- vec3 linearToSrgb(vec3 value) {
616
- vec3 low = value * 12.92;
617
- vec3 high = 1.055 * pow(max(value, vec3(0.0)), vec3(1.0 / 2.4)) - 0.055;
618
- return mix(high, low, step(value, vec3(0.0031308)));
619
- }
620
-
621
- vec3 srgbToLinear(vec3 value) {
622
- vec3 low = value / 12.92;
623
- vec3 high = pow(max((value + 0.055) / 1.055, vec3(0.0)), vec3(2.4));
624
- return mix(high, low, step(value, vec3(0.04045)));
625
- }
626
-
627
- float overlayChannel(float base, float blend) {
628
- return base < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
629
- }
630
-
631
- float hardLightChannel(float base, float blend) {
632
- return blend < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
633
- }
634
-
635
- float softLightChannel(float base, float blend) {
636
- if (blend <= 0.5) {
637
- return base - (1.0 - 2.0 * blend) * base * (1.0 - base);
638
- }
639
-
640
- float d = base <= 0.25
641
- ? ((16.0 * base - 12.0) * base + 4.0) * base
642
- : sqrt(base);
643
-
644
- return base + (2.0 * blend - 1.0) * (d - base);
645
- }
646
-
647
- vec3 applyBlendMode(vec3 base, vec3 blend, int mode) {
648
- if (mode == 0) return blend;
649
- if (mode == 1) return min(base + blend, 1.0);
650
- if (mode == 2) return max(base - blend, 0.0);
651
- if (mode == 3) return base * blend;
652
- if (mode == 4) return 1.0 - (1.0 - base) * (1.0 - blend);
653
- if (mode == 5) {
654
- return vec3(
655
- overlayChannel(base.r, blend.r),
656
- overlayChannel(base.g, blend.g),
657
- overlayChannel(base.b, blend.b)
658
- );
659
- }
660
- if (mode == 6) {
661
- return vec3(
662
- softLightChannel(base.r, blend.r),
663
- softLightChannel(base.g, blend.g),
664
- softLightChannel(base.b, blend.b)
665
- );
666
- }
667
- if (mode == 7) {
668
- return vec3(
669
- hardLightChannel(base.r, blend.r),
670
- hardLightChannel(base.g, blend.g),
671
- hardLightChannel(base.b, blend.b)
672
- );
673
- }
674
- if (mode == 8) return max(base, blend);
675
- if (mode == 9) return min(base, blend);
676
- if (mode == 10) return abs(base - blend);
677
- return base + blend - 2.0 * base * blend;
678
- }
679
-
680
- void main() {
681
- vec3 base = linearToSrgb(texture2D(cameraTexture, vFaceUv).rgb);
682
- vec4 textureSample = texture2D(canonicalTexture, vUv);
683
- vec3 blend = linearToSrgb(textureSample.rgb) * textureTint;
684
- float light = ambientStrength + max(dot(normalize(vNormal), normalize(lightDirection)), 0.0) * directionalStrength;
685
- blend *= mix(1.0, clamp(light, 0.35, 1.35), compositeShading);
686
- float maskSample = texture2D(alphaMask, vUv).r;
687
- float mask = useAlphaMask > 0.5 ? mix(1.0, maskSample, alphaOpacity) : 1.0;
688
- float textureAlpha = useCanonicalTexture > 0.5 ? textureSample.a : 1.0;
689
- vec3 blended = applyBlendMode(base, blend, blendMode);
690
- vec3 color = useCanonicalTexture > 0.5 ? mix(base, blended, blendOpacity) : base;
691
- gl_FragColor = vec4(srgbToLinear(color), opacity * mask * textureAlpha);
692
- }
693
- `, _n = ({
694
- alphaMap: e,
695
- alphaOpacity: n,
696
- blendMode: t,
697
- blendOpacity: r,
698
- cameraTexture: a,
699
- color: o,
700
- compositeShading: i,
701
- faceAlphaMaskUrl: s,
702
- faceTextureStyle2Url: f,
703
- faceTextureUrl: u,
704
- masked: c = !1,
705
- maskColor: v,
706
- maskOpacity: R,
707
- maskSourceUrl: D,
708
- maskTextureSource: _,
709
- materialType: F,
710
- opacity: S,
711
- shaderPreset: Y,
712
- side: M,
713
- textureMap: p
714
- }) => {
715
- const U = de(
716
- m.TextureLoader,
717
- u || Re
718
- ), y = de(
719
- m.TextureLoader,
720
- f || u || Re
721
- ), d = de(
722
- m.TextureLoader,
723
- s || Re
724
- ), k = Z(() => Sn(), []), N = Z(() => Tn(), []);
725
- Ce(
726
- () => () => {
727
- k.dispose(), N.dispose();
728
- },
729
- [N, k]
730
- );
731
- const I = p === j.style2 ? y : U, x = p !== j.none, E = we(F, Y, p), T = [
732
- "composite-material",
733
- p,
734
- e,
735
- n,
736
- t,
737
- r,
738
- i ? "lit" : "flat",
739
- o,
740
- S,
741
- u,
742
- f,
743
- s
744
- ].join("|"), h = {
745
- side: M,
746
- transparent: !0,
747
- opacity: S,
748
- wireframe: !1
749
- }, z = Z(
750
- () => ({
751
- source: ke(_) ? "texture" : _,
752
- color: En(_) ? v : "#ffffff",
753
- opacity: R,
754
- textureUrl: ke(_) ? D : "",
755
- gradient: Qe(v)
756
- }),
757
- [v, R, D, _]
758
- ), w = Z(
759
- () => ({
760
- cameraTexture: { value: null },
761
- canonicalTexture: { value: null },
762
- alphaMask: { value: null },
763
- textureTint: { value: new m.Color(o) },
764
- opacity: { value: S },
765
- blendMode: { value: je[t] },
766
- blendOpacity: { value: r },
767
- useCanonicalTexture: { value: x ? 1 : 0 },
768
- useAlphaMask: { value: e === J.canonical ? 1 : 0 },
769
- alphaOpacity: { value: n },
770
- compositeShading: { value: i ? 1 : 0 },
771
- lightDirection: { value: new m.Vector3(0.3, 0.65, 0.7).normalize() },
772
- ambientStrength: { value: 0.78 },
773
- directionalStrength: { value: 0.38 }
774
- }),
775
- [
776
- e,
777
- n,
778
- t,
779
- r,
780
- o,
781
- i,
782
- x,
783
- S
784
- ]
785
- );
786
- if (Ce(() => {
787
- w.cameraTexture.value = a ?? U, w.canonicalTexture.value = I, w.alphaMask.value = d, w.textureTint.value.set(o), w.opacity.value = S, w.blendMode.value = je[t], w.blendOpacity.value = r, w.useCanonicalTexture.value = x ? 1 : 0, w.useAlphaMask.value = e === J.canonical ? 1 : 0, w.alphaOpacity.value = n, w.compositeShading.value = i ? 1 : 0;
788
- }, [
789
- e,
790
- d,
791
- n,
792
- t,
793
- r,
794
- a,
795
- o,
796
- i,
797
- w,
798
- U,
799
- x,
800
- S,
801
- I
802
- ]), c)
803
- return /* @__PURE__ */ g(
804
- cn,
805
- {
806
- settings: z,
807
- side: M
808
- },
809
- `masked-${_}-material`
810
- );
811
- if (F === C.wireframe)
812
- return /* @__PURE__ */ g(
813
- "meshBasicMaterial",
814
- {
815
- color: o,
816
- transparent: !0,
817
- opacity: S,
818
- side: M,
819
- depthWrite: !1,
820
- depthTest: !1,
821
- wireframe: !0,
822
- toneMapped: !1
823
- },
824
- "wireframe-material"
825
- );
826
- if (E === "originalFace" && a)
827
- return /* @__PURE__ */ g(
828
- "meshBasicMaterial",
829
- {
830
- map: a,
831
- alphaMap: d,
832
- transparent: !0,
833
- opacity: S,
834
- side: M,
835
- depthWrite: !1,
836
- depthTest: !0,
837
- toneMapped: !1
838
- },
839
- "use-original-face-material"
840
- );
841
- if (E === "composite" && a)
842
- return /* @__PURE__ */ g(
843
- "shaderMaterial",
844
- {
845
- uniforms: w,
846
- vertexShader: Rn,
847
- fragmentShader: Cn,
848
- transparent: !0,
849
- side: M,
850
- depthWrite: !1,
851
- depthTest: !0,
852
- toneMapped: !1
853
- },
854
- T
855
- );
856
- const Q = x ? I : null, $ = e === J.canonical && n > 0 ? d : null, W = `${F}-${p}-${e}-${n > 0 ? "alpha-on" : "alpha-off"}`;
857
- return F === C.standard ? /* @__PURE__ */ g(
858
- "meshStandardMaterial",
859
- {
860
- ...h,
861
- color: o,
862
- map: Q ?? void 0,
863
- alphaMap: $ ?? void 0,
864
- depthWrite: !0,
865
- depthTest: !0,
866
- metalness: 0.05,
867
- roughness: 0.72
868
- },
869
- W
870
- ) : F === C.physical ? /* @__PURE__ */ g(
871
- "meshPhysicalMaterial",
872
- {
873
- ...h,
874
- color: o,
875
- map: Q ?? void 0,
876
- alphaMap: $ ?? void 0,
877
- depthWrite: !0,
878
- depthTest: !0,
879
- roughness: 0.58,
880
- metalness: 0.08,
881
- clearcoat: 0.35,
882
- clearcoatRoughness: 0.4
883
- },
884
- W
885
- ) : F === C.toon ? /* @__PURE__ */ g(
886
- "meshToonMaterial",
887
- {
888
- ...h,
889
- color: o,
890
- map: Q ?? void 0,
891
- alphaMap: $ ?? void 0,
892
- gradientMap: k,
893
- depthWrite: !0,
894
- depthTest: !0
895
- },
896
- W
897
- ) : F === C.normal ? /* @__PURE__ */ g(
898
- "meshNormalMaterial",
899
- {
900
- ...h,
901
- depthWrite: !0,
902
- depthTest: !0,
903
- flatShading: !1
904
- },
905
- "normal-material"
906
- ) : F === C.matcap ? /* @__PURE__ */ g(
907
- "meshMatcapMaterial",
908
- {
909
- ...h,
910
- color: o,
911
- matcap: N,
912
- depthWrite: !0,
913
- depthTest: !0
914
- },
915
- "matcap-material"
916
- ) : /* @__PURE__ */ g(
917
- "meshBasicMaterial",
918
- {
919
- ...h,
920
- color: o,
921
- map: Q ?? void 0,
922
- alphaMap: $ ?? void 0,
923
- depthWrite: !1,
924
- depthTest: p !== j.none || e !== J.none,
925
- toneMapped: !1
926
- },
927
- W
928
- );
929
- }, kn = [
930
- {
931
- key: "base",
932
- getIndices: (e) => e.baseIndices,
933
- masked: !1,
934
- renderOrderOffset: 0
935
- },
936
- {
937
- key: "mouth",
938
- getIndices: (e) => e.mouthIndices,
939
- masked: !1,
940
- renderOrderOffset: 2
941
- },
942
- {
943
- key: "lips",
944
- getIndices: (e) => e.lipIndices,
945
- masked: !1,
946
- renderOrderOffset: 3
947
- },
948
- {
949
- key: "left-eye",
950
- getIndices: (e) => e.leftEyeIndices,
951
- masked: !1,
952
- renderOrderOffset: 2
953
- },
954
- {
955
- key: "right-eye",
956
- getIndices: (e) => e.rightEyeIndices,
957
- masked: !1,
958
- renderOrderOffset: 2
959
- },
960
- {
961
- key: "nose",
962
- getIndices: (e) => e.noseIndices,
963
- masked: !1,
964
- renderOrderOffset: 2
965
- },
966
- {
967
- key: "mouth-mask",
968
- getIndices: (e) => e.mouthIndices,
969
- masked: !0,
970
- renderOrderOffset: 3
971
- },
972
- {
973
- key: "left-eye-mask",
974
- getIndices: (e) => e.leftEyeIndices,
975
- masked: !0,
976
- renderOrderOffset: 3
977
- },
978
- {
979
- key: "right-eye-mask",
980
- getIndices: (e) => e.rightEyeIndices,
981
- masked: !0,
982
- renderOrderOffset: 3
983
- },
984
- {
985
- key: "nose-mask",
986
- getIndices: (e) => e.noseIndices,
987
- masked: !0,
988
- renderOrderOffset: 3
989
- }
990
- ], Fn = {
991
- [ne.front]: m.FrontSide,
992
- [ne.back]: m.BackSide,
993
- [ne.double]: m.DoubleSide
994
- }, wn = (e, n, t) => {
995
- e.setAttribute("position", n.position), e.setAttribute("uv", n.uv), e.setAttribute("faceUv", n.faceUv), e.setIndex(new m.BufferAttribute(t, 1));
996
- }, Un = ({
997
- faceIndex: e = 0,
998
- baseColor: n,
999
- color: t = G.baseColor,
1000
- opacity: r = G.opacity,
1001
- materialType: a = G.materialType,
1002
- shaderPreset: o = G.shaderPreset,
1003
- textureMap: i = G.textureMap,
1004
- alphaMap: s = G.alphaMap,
1005
- alphaOpacity: f = G.alphaOpacity,
1006
- side: u = G.side,
1007
- blendMode: c = G.blendMode,
1008
- blendOpacity: v = G.blendOpacity,
1009
- showOverlayMask: R = !1,
1010
- showMouthMask: D = Te.mouth,
1011
- showEyeMask: _ = Te.eyes,
1012
- showLeftEyeMask: F,
1013
- showRightEyeMask: S,
1014
- showNoseMask: Y = Te.nose,
1015
- showEyeGeometry: M = !0,
1016
- showLeftEyeGeometry: p,
1017
- showRightEyeGeometry: U,
1018
- showMouthGeometry: y = !0,
1019
- // The lips mesh is an effect-only overlay. Rendering it with the base face
1020
- // mesh duplicates an incomplete triangulation over the mouth.
1021
- showLipsGeometry: d = !1,
1022
- showBaseGeometry: k = !0,
1023
- showNoseGeometry: N = !0,
1024
- maskTextureSource: I = ee.textureSource,
1025
- maskSourceUrl: x = "",
1026
- maskColor: E = ee.color,
1027
- maskOpacity: T = ee.opacity,
1028
- faceTextureUrl: h = "",
1029
- faceTextureStyle2Url: z = "",
1030
- faceAlphaMaskUrl: w = "",
1031
- compositeShading: Q = !1,
1032
- faceWarp3D: $,
1033
- transform: W,
1034
- renderOrder: Je = Ze,
1035
- externalScale: fe = 1,
1036
- mesh: et,
1037
- meshUrl: tt,
1038
- materialOverride: oe
1039
- }) => {
1040
- const ue = Yt(jt.FACE_TRACKER), Ue = $t(), { camera: nt } = Bt(), H = Mn({ mesh: et, url: tt }), Ie = l(null), rt = l(null), at = l(null), ot = l(null), st = l(null), it = l(null), ct = l(null), lt = l(null), dt = l(null), ft = l(null), ut = l(null), ht = l(null), mt = l(null), pt = l(null), yt = l(null), bt = l(null), gt = l(null), Mt = l(null), xt = l(null), At = l(null), he = l(null), me = l(null), pe = l(null), Oe = l(null), vt = l(new m.Vector3()), Et = l({ x: 0, y: 0, z: 0 }), St = l({ x: 0, y: 0, z: 0 }), Tt = l({ x: 0, y: 0, z: 0 }), se = l(!1), Rt = Fn[u], Ct = n ?? t, _t = p ?? M, kt = U ?? M, Ft = R || (F ?? _), wt = R || (S ?? _), Ut = R || D, It = R || Y, Ot = {
1041
- base: Ie,
1042
- mouth: rt,
1043
- lips: at,
1044
- "left-eye": ot,
1045
- "right-eye": st,
1046
- nose: it,
1047
- "mouth-mask": ct,
1048
- "left-eye-mask": lt,
1049
- "right-eye-mask": dt,
1050
- "nose-mask": ft
1051
- }, Lt = {
1052
- base: ut,
1053
- mouth: ht,
1054
- lips: mt,
1055
- "left-eye": pt,
1056
- "right-eye": yt,
1057
- nose: bt,
1058
- "mouth-mask": gt,
1059
- "left-eye-mask": Mt,
1060
- "right-eye-mask": xt,
1061
- "nose-mask": At
1062
- }, Dt = {
1063
- base: k,
1064
- mouth: y,
1065
- lips: d,
1066
- "left-eye": _t,
1067
- "right-eye": kt,
1068
- nose: N,
1069
- "mouth-mask": Ut,
1070
- "left-eye-mask": Ft,
1071
- "right-eye-mask": wt,
1072
- "nose-mask": It
1073
- }, Pt = (A) => /* @__PURE__ */ g(
1074
- _n,
1075
- {
1076
- alphaMap: s,
1077
- alphaOpacity: f,
1078
- blendMode: c,
1079
- blendOpacity: v,
1080
- cameraTexture: Ue,
1081
- color: Ct,
1082
- compositeShading: Q,
1083
- faceAlphaMaskUrl: w,
1084
- faceTextureStyle2Url: z,
1085
- faceTextureUrl: h,
1086
- masked: A,
1087
- maskColor: E,
1088
- maskOpacity: T,
1089
- maskSourceUrl: x,
1090
- maskTextureSource: I,
1091
- materialType: a,
1092
- opacity: r,
1093
- shaderPreset: o,
1094
- side: Rt,
1095
- textureMap: i
1096
- }
1097
- ), q = kn.map(
1098
- (A) => ({
1099
- ...A,
1100
- geometryRef: Ot[A.key],
1101
- meshRef: Lt[A.key],
1102
- visible: Dt[A.key]
1103
- })
1104
- ), zt = (A) => Qt(A, nt, vt.current);
1105
- return Vt(() => {
1106
- var ze, Ge;
1107
- const A = Ie.current, B = (Ge = (ze = ue == null ? void 0 : ue.detectionResults) == null ? void 0 : ze.faceLandmarks) == null ? void 0 : Ge[e], Gt = q.every(
1108
- (b) => b.geometryRef.current && b.meshRef.current
1109
- );
1110
- if (!H || !A || !Gt) return;
1111
- if (!B || B.length < H.vertexCount) {
1112
- q.forEach((b) => {
1113
- b.meshRef.current.visible = !1;
1114
- });
1115
- return;
1116
- }
1117
- if (Oe.current !== H) {
1118
- he.current = new Float32Array(H.vertexCount * 3), me.current = new Float32Array(H.uvs), pe.current = new Float32Array(H.vertexCount * 2);
1119
- const b = {
1120
- position: new m.BufferAttribute(he.current, 3),
1121
- uv: new m.BufferAttribute(me.current, 2),
1122
- faceUv: new m.BufferAttribute(pe.current, 2)
1123
- };
1124
- q.forEach((O) => {
1125
- wn(O.geometryRef.current, b, O.getIndices(H));
1126
- }), b.uv.needsUpdate = !0, Oe.current = H, se.current = !1;
1127
- }
1128
- const ie = he.current, ye = pe.current, ce = me.current;
1129
- if (!ie || !ye || !ce) return;
1130
- const Le = vn(a, o, i), De = dn($), Pe = De ? ln(B) : null, P = W ? Tt.current : null;
1131
- if (P) {
1132
- P.x = 0, P.y = 0, P.z = 0;
1133
- for (let b = 0; b < B.length; b++) {
1134
- const O = B[b];
1135
- P.x += O.x, P.y += O.y, P.z += O.z;
1136
- }
1137
- P.x /= B.length, P.y /= B.length, P.z /= B.length;
1138
- }
1139
- const Nt = Math.min(B.length, H.vertexCount);
1140
- for (let b = 0; b < Nt; b++) {
1141
- const O = B[b], Ne = De && Pe ? fn(O, Pe, $, Et.current) : O, Ht = W && P ? Kt(
1142
- Ne,
1143
- P,
1144
- W,
1145
- St.current
1146
- ) : Ne, be = b * 3, le = b * 2, ge = zt(Ht);
1147
- ie[be] = ge.x, ie[be + 1] = ge.y, ie[be + 2] = ge.z, ye[le] = O.x, ye[le + 1] = 1 - O.y, Le && (ce[le] = O.x, ce[le + 1] = 1 - O.y);
1148
- }
1149
- Le ? (A.attributes.uv.needsUpdate = !0, se.current = !0) : se.current && (ce.set(H.uvs), A.attributes.uv.needsUpdate = !0, se.current = !1), q.forEach((b) => {
1150
- b.meshRef.current.visible = b.visible;
1151
- }), A.attributes.position.needsUpdate = !0, A.attributes.faceUv.needsUpdate = !0, q.forEach((b) => {
1152
- b.geometryRef.current.computeVertexNormals();
1153
- });
1154
- }), /* @__PURE__ */ g("group", { scale: [fe, fe, fe], children: q.map((A) => /* @__PURE__ */ Fe(
1155
- "mesh",
1156
- {
1157
- ref: A.meshRef,
1158
- renderOrder: Je + A.renderOrderOffset,
1159
- frustumCulled: !1,
1160
- children: [
1161
- /* @__PURE__ */ g("bufferGeometry", { ref: A.geometryRef }),
1162
- oe ? typeof oe == "function" ? oe({ cameraTexture: Ue ?? null, geometryKey: A.key }) : oe : Pt(A.masked)
1163
- ]
1164
- },
1165
- A.key
1166
- )) });
1167
- }, In = `${re.sdkAssetsBaseUrl}/Canonical_Face_Color.png`, On = `${re.sdkAssetsBaseUrl}/Canonical_Face_Color_style_2.png`, Ln = `${re.sdkAssetsBaseUrl}/Canonical_Face_Color_Mask.png`, Dn = {
1168
- ...Ve,
1169
- position: { ...Ve.position, y: 1e-3 }
1170
- }, qn = {
1171
- enabled: !0,
1172
- faceIndex: 0,
1173
- targetFps: An,
1174
- ...G,
1175
- showLeftEyeGeometry: !0,
1176
- showRightEyeGeometry: !0,
1177
- showMouthGeometry: !0,
1178
- showNoseGeometry: !0,
1179
- externalScale: 1,
1180
- showOverlayMask: !1,
1181
- showMouthMask: !1,
1182
- showLeftEyeMask: !1,
1183
- showRightEyeMask: !1,
1184
- showNoseMask: !1,
1185
- maskTextureSource: ee.textureSource,
1186
- maskSourceUrl: "",
1187
- maskColor: ee.color,
1188
- maskOpacity: ee.opacity,
1189
- faceTextureUrl: In,
1190
- faceTextureStyle2Url: On,
1191
- faceAlphaMaskUrl: Ln,
1192
- renderOrder: Ze
1193
- }, Pn = (e) => {
1194
- const { externalMeshUrl: n, ...t } = e;
1195
- return { ...t, color: t.baseColor, meshUrl: n };
1196
- }, zn = ({
1197
- materialOverride: e,
1198
- value: n
1199
- }) => ({
1200
- ...Pn(n),
1201
- materialOverride: e
1202
- }), Zn = (e, n) => {
1203
- const t = { ...e, ...n };
1204
- return n.maskTextureSource && !ke(n.maskTextureSource) && (t.maskSourceUrl = ""), t.materialType === C.shader && n.shaderPreset === X.composite ? {
1205
- ...t,
1206
- ...Xe,
1207
- materialType: C.shader,
1208
- shaderPreset: X.composite
1209
- } : t.materialType === C.shader && t.shaderPreset === X.composite && t.textureMap === j.none ? {
1210
- ...t,
1211
- textureMap: Xe.textureMap
1212
- } : t;
1213
- }, Jn = ({ transform: e, value: n, materialOverride: t }) => n.enabled ? /* @__PURE__ */ Fe(Ye, { children: [
1214
- /* @__PURE__ */ g(
1215
- qt,
1216
- {
1217
- active: n.enabled,
1218
- faceIndex: n.faceIndex,
1219
- numFaces: n.faceIndex + 1,
1220
- targetFps: n.targetFps
1221
- }
1222
- ),
1223
- /* @__PURE__ */ g(
1224
- Un,
1225
- {
1226
- ...zn({ value: n, materialOverride: t }),
1227
- transform: e ?? Dn
1228
- }
1229
- )
1230
- ] }) : null;
1231
- export {
1232
- Yn as A,
1233
- Qe as B,
1234
- Un as C,
1235
- G as D,
1236
- Ve as E,
1237
- C as F,
1238
- _e as G,
1239
- En as H,
1240
- ke as I,
1241
- cn as M,
1242
- an as S,
1243
- Re as T,
1244
- X as a,
1245
- ne as b,
1246
- j as c,
1247
- J as d,
1248
- qe as e,
1249
- ae as f,
1250
- je as g,
1251
- qn as h,
1252
- Dn as i,
1253
- Te as j,
1254
- Qn as k,
1255
- _n as l,
1256
- Jn as m,
1257
- Ln as n,
1258
- On as o,
1259
- In as p,
1260
- kn as q,
1261
- zn as r,
1262
- Kn as s,
1263
- Pn as t,
1264
- Zn as u,
1265
- Mn as v,
1266
- pn as w,
1267
- K as x,
1268
- en as y,
1269
- $n as z
1270
- };