@vincentt-xr/sdk 2.0.0-alpha.4 → 2.0.0-alpha.6

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 (67) hide show
  1. package/GROUNDING.md +11 -4
  2. package/README.md +85 -52
  3. package/dist/{DebuggerUI-DhKTXTY2.js → DebuggerUI-C_rbLdkh.js} +1 -1
  4. package/dist/{DebuggerUI-bnGHSSOb.cjs → DebuggerUI-DYT_dk1E.cjs} +1 -1
  5. package/dist/FaceMeshRenderer-D1WsrTLA.cjs +155 -0
  6. package/dist/FaceMeshRenderer-DSCd1H55.js +1264 -0
  7. package/dist/{FaceRetouch-Bg-OBU4n.js → FaceRetouch-CMJbGThL.js} +30 -30
  8. package/dist/{FaceRetouch-TZeBGIqW.cjs → FaceRetouch-DsE0Dbw-.cjs} +1 -1
  9. package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +11 -1
  10. package/dist/components/FaceMesh/canonical/geometryGroups.d.ts +1 -1
  11. package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +1 -0
  12. package/dist/components/LipEffect/LipEffect.d.ts +2 -0
  13. package/dist/components/LipEffect/LipEffectMaterial.d.ts +10 -0
  14. package/dist/components/LipEffect/defaults.d.ts +9 -0
  15. package/dist/components/LipEffect/index.d.ts +4 -0
  16. package/dist/components/LipEffect/types.d.ts +22 -0
  17. package/dist/{contexts-B2_NsTnk.js → contexts-DvQI4PqI.js} +6 -3
  18. package/dist/contexts-h-9TRH0r.cjs +1 -0
  19. package/dist/debug-ui/media-source.cjs +1 -1
  20. package/dist/debug-ui/media-source.js +1 -1
  21. package/dist/debug-ui.cjs +1 -1
  22. package/dist/debug-ui.js +10 -10
  23. package/dist/entries/face-effects.d.ts +2 -0
  24. package/dist/face-effects.cjs +1 -1
  25. package/dist/face-effects.js +621 -508
  26. package/dist/{getFaceInfo-4DhcPZDJ.js → getFaceInfo-B43Cwq4n.js} +1 -1
  27. package/dist/{getFaceInfo-QOQ_dc-W.cjs → getFaceInfo-DEzcL_Ub.cjs} +1 -1
  28. package/dist/{index-D1kj6uc-.js → index-B-s4YbWu.js} +1 -1
  29. package/dist/index-C0-fg1Hk.cjs +1 -0
  30. package/dist/{index-C9yQVzAh.cjs → index-CY7Z8cHV.cjs} +1 -1
  31. package/dist/{index-ZaDEzDtR.cjs → index-CxMEeCRP.cjs} +1 -1
  32. package/dist/{index-WPPnlFO1.cjs → index-D67hHm44.cjs} +1 -1
  33. package/dist/{index-CNGzE49z.cjs → index-DPPpU5By.cjs} +1 -1
  34. package/dist/{index-g250Tqme.js → index-DYfY9ljy.js} +1 -1
  35. package/dist/{index-Cj3fGDtZ.js → index-G_5h_FJQ.js} +8 -8
  36. package/dist/{index-BMeBJ0dV.js → index-I4eF5TKT.js} +227 -191
  37. package/dist/{index-72Wb15Ca.js → index-uE3sKczj.js} +1 -1
  38. package/dist/{internal-Dtvo4WYo.cjs → internal-MvKrz0Nt.cjs} +1 -1
  39. package/dist/{internal-34pb7djs.js → internal-ldPYiUF0.js} +3 -3
  40. package/dist/internal.cjs +1 -1
  41. package/dist/internal.js +1 -1
  42. package/dist/low-level.cjs +1 -1
  43. package/dist/low-level.js +11 -11
  44. package/dist/main.cjs +1 -1
  45. package/dist/main.js +12 -12
  46. package/dist/{renderGroups-jSUOY1Oq.cjs → renderGroups-BJsx32q5.cjs} +1 -1
  47. package/dist/{renderGroups-CPWUX6z9.js → renderGroups-CFt1yYLB.js} +1 -1
  48. package/dist/{renderPasses-CLlYRdMk.js → renderPasses-C72MbZ-a.js} +4 -4
  49. package/dist/{renderPasses-KUJUSevp.cjs → renderPasses-D-Krl6D0.cjs} +1 -1
  50. package/dist/scene-object.cjs +1 -1
  51. package/dist/scene-object.js +2 -2
  52. package/dist/{selectors-DLxL8Q66.js → selectors-ByKNTXeA.js} +1 -1
  53. package/dist/{selectors-S8g25ke9.cjs → selectors-CAwmL9VW.cjs} +1 -1
  54. package/dist/{session-DP8AF7Rg.cjs → session-CANvoLD6.cjs} +1 -1
  55. package/dist/{session-CbtvwiaD.js → session-Dhi0OqZo.js} +1 -1
  56. package/dist/tracking.cjs +1 -1
  57. package/dist/tracking.js +9 -9
  58. package/dist/{useFaceInfo-BvZeUBsL.cjs → useFaceInfo-BSZq7AO1.cjs} +1 -1
  59. package/dist/{useFaceInfo-C06EyScd.js → useFaceInfo-FVQBBNdY.js} +3 -3
  60. package/dist/{useFaceResults-CCNiH7VZ.cjs → useFaceResults-C3oZkn2Z.cjs} +1 -1
  61. package/dist/{useFaceResults-C1Ppc8rS.js → useFaceResults-D62STzT1.js} +1 -1
  62. package/dist/utils/visionWasm.d.ts +18 -0
  63. package/package.json +2 -2
  64. package/dist/FaceMeshRenderer-B2i2NW71.js +0 -1195
  65. package/dist/FaceMeshRenderer-BSOq1OnG.cjs +0 -155
  66. package/dist/contexts-BgWfyxre.cjs +0 -1
  67. package/dist/index-Da7uycur.cjs +0 -1
@@ -0,0 +1,1264 @@
1
+ import { jsx as g, jsxs as we, 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-I4eF5TKT.js";
7
+ import { c as Yt, u as $t } from "./selectors-ByKNTXeA.js";
8
+ import { t as Kt, p as Qt, b as qt } from "./index-B-s4YbWu.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=", jn = {
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
+ }, Yn = ({ 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), u = He((c) => {
187
+ var v;
188
+ a.current = c, s(c), (v = o.current) == null || v.call(o, c);
189
+ }, []), f = 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__ */ we(Ye, { children: [
211
+ /* @__PURE__ */ g(
212
+ "group",
213
+ {
214
+ ref: u,
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: f,
234
+ onObjectChange: f
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, un = (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), u = te((-i + 0.42) / 0.55), f = 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), _ = f * L(s, 0.34, 0.22), w = u * 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, f * (1 - s)), p -= n.height * (t.midfaceHeight ?? 0) * a * f * 0.25, d(-(t.foreheadHeight ?? 0), w), y(t.foreheadWidth ?? 0, w), 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 * u * 0.3, U -= (t.midfaceDepth ?? 0) * a * f * 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
+ ]), fn = /* @__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 u = [e[s], e[s + 1], e[s + 2]];
368
+ for (let f = 0; f < 3; f += 1) {
369
+ const c = u[f], v = u[(f + 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: u, count: f }) => {
375
+ f === 1 && (t.set(s, [...t.get(s) ?? [], u]), t.set(u, [...t.get(u) ?? [], s]));
376
+ });
377
+ const r = [...t.keys()].sort((s, u) => s - u)[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((u) => u !== 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 = [], u = [];
389
+ let f = 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)]), f += 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] && !u[h] && (u[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
+ fn.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 < f; y += 1) {
419
+ const [d, k] = u[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 w = 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(w, [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: f
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, Fe = (e, n, t) => e !== C.shader ? "none" : n === X.originalFace ? "originalFace" : n === X.composite ? t === j.none ? "originalFace" : "composite" : "none", $n = (e, n) => e === C.basic || e === C.standard || e === C.physical || e === C.toon || e === C.shader && n === X.composite, Kn = (e, n, t = j.canonical) => Fe(e, n, t) === "composite", vn = (e, n, t) => Fe(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: u,
703
+ faceTextureUrl: f,
704
+ masked: c = !1,
705
+ maskColor: v,
706
+ maskOpacity: R,
707
+ maskSourceUrl: D,
708
+ maskTextureSource: _,
709
+ materialType: w,
710
+ opacity: S,
711
+ shaderPreset: Y,
712
+ side: M,
713
+ textureMap: p
714
+ }) => {
715
+ const U = de(
716
+ m.TextureLoader,
717
+ f || Re
718
+ ), y = de(
719
+ m.TextureLoader,
720
+ u || f || 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 = Fe(w, 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
+ f,
742
+ u,
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
+ ), F = 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
+ F.cameraTexture.value = a ?? U, F.canonicalTexture.value = I, F.alphaMask.value = d, F.textureTint.value.set(o), F.opacity.value = S, F.blendMode.value = je[t], F.blendOpacity.value = r, F.useCanonicalTexture.value = x ? 1 : 0, F.useAlphaMask.value = e === J.canonical ? 1 : 0, F.alphaOpacity.value = n, F.compositeShading.value = i ? 1 : 0;
788
+ }, [
789
+ e,
790
+ d,
791
+ n,
792
+ t,
793
+ r,
794
+ a,
795
+ o,
796
+ i,
797
+ F,
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 (w === 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: F,
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 = `${w}-${p}-${e}-${n > 0 ? "alpha-on" : "alpha-off"}`;
857
+ return w === 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
+ ) : w === 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
+ ) : w === 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
+ ) : w === C.normal ? /* @__PURE__ */ g(
898
+ "meshNormalMaterial",
899
+ {
900
+ ...h,
901
+ depthWrite: !0,
902
+ depthTest: !0,
903
+ flatShading: !1
904
+ },
905
+ "normal-material"
906
+ ) : w === 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
+ ], wn = {
991
+ [ne.front]: m.FrontSide,
992
+ [ne.back]: m.BackSide,
993
+ [ne.double]: m.DoubleSide
994
+ }, Fn = (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: u = G.alphaOpacity,
1006
+ side: f = 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: w,
1013
+ showRightEyeMask: S,
1014
+ showNoseMask: Y = Te.nose,
1015
+ showEyeGeometry: M = !0,
1016
+ showLeftEyeGeometry: p,
1017
+ showRightEyeGeometry: U,
1018
+ showMouthGeometry: y = !0,
1019
+ showLipsGeometry: d = !0,
1020
+ showBaseGeometry: k = !0,
1021
+ showNoseGeometry: N = !0,
1022
+ maskTextureSource: I = ee.textureSource,
1023
+ maskSourceUrl: x = "",
1024
+ maskColor: E = ee.color,
1025
+ maskOpacity: T = ee.opacity,
1026
+ faceTextureUrl: h = "",
1027
+ faceTextureStyle2Url: z = "",
1028
+ faceAlphaMaskUrl: F = "",
1029
+ compositeShading: Q = !1,
1030
+ faceWarp3D: $,
1031
+ transform: W,
1032
+ renderOrder: Je = Ze,
1033
+ externalScale: ue = 1,
1034
+ mesh: et,
1035
+ meshUrl: tt,
1036
+ materialOverride: oe
1037
+ }) => {
1038
+ const fe = 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), ut = l(null), ft = 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 = wn[f], Ct = n ?? t, _t = p ?? M, kt = U ?? M, wt = R || (w ?? _), Ft = R || (S ?? _), Ut = R || D, It = R || Y, Ot = {
1039
+ base: Ie,
1040
+ mouth: rt,
1041
+ lips: at,
1042
+ "left-eye": ot,
1043
+ "right-eye": st,
1044
+ nose: it,
1045
+ "mouth-mask": ct,
1046
+ "left-eye-mask": lt,
1047
+ "right-eye-mask": dt,
1048
+ "nose-mask": ut
1049
+ }, Lt = {
1050
+ base: ft,
1051
+ mouth: ht,
1052
+ lips: mt,
1053
+ "left-eye": pt,
1054
+ "right-eye": yt,
1055
+ nose: bt,
1056
+ "mouth-mask": gt,
1057
+ "left-eye-mask": Mt,
1058
+ "right-eye-mask": xt,
1059
+ "nose-mask": At
1060
+ }, Dt = {
1061
+ base: k,
1062
+ mouth: y,
1063
+ lips: d,
1064
+ "left-eye": _t,
1065
+ "right-eye": kt,
1066
+ nose: N,
1067
+ "mouth-mask": Ut,
1068
+ "left-eye-mask": wt,
1069
+ "right-eye-mask": Ft,
1070
+ "nose-mask": It
1071
+ }, Pt = (A) => /* @__PURE__ */ g(
1072
+ _n,
1073
+ {
1074
+ alphaMap: s,
1075
+ alphaOpacity: u,
1076
+ blendMode: c,
1077
+ blendOpacity: v,
1078
+ cameraTexture: Ue,
1079
+ color: Ct,
1080
+ compositeShading: Q,
1081
+ faceAlphaMaskUrl: F,
1082
+ faceTextureStyle2Url: z,
1083
+ faceTextureUrl: h,
1084
+ masked: A,
1085
+ maskColor: E,
1086
+ maskOpacity: T,
1087
+ maskSourceUrl: x,
1088
+ maskTextureSource: I,
1089
+ materialType: a,
1090
+ opacity: r,
1091
+ shaderPreset: o,
1092
+ side: Rt,
1093
+ textureMap: i
1094
+ }
1095
+ ), q = kn.map(
1096
+ (A) => ({
1097
+ ...A,
1098
+ geometryRef: Ot[A.key],
1099
+ meshRef: Lt[A.key],
1100
+ visible: Dt[A.key]
1101
+ })
1102
+ ), zt = (A) => Qt(A, nt, vt.current);
1103
+ return Vt(() => {
1104
+ var ze, Ge;
1105
+ const A = Ie.current, B = (Ge = (ze = fe == null ? void 0 : fe.detectionResults) == null ? void 0 : ze.faceLandmarks) == null ? void 0 : Ge[e], Gt = q.every(
1106
+ (b) => b.geometryRef.current && b.meshRef.current
1107
+ );
1108
+ if (!H || !A || !Gt) return;
1109
+ if (!B || B.length < H.vertexCount) {
1110
+ q.forEach((b) => {
1111
+ b.meshRef.current.visible = !1;
1112
+ });
1113
+ return;
1114
+ }
1115
+ if (Oe.current !== H) {
1116
+ he.current = new Float32Array(H.vertexCount * 3), me.current = new Float32Array(H.uvs), pe.current = new Float32Array(H.vertexCount * 2);
1117
+ const b = {
1118
+ position: new m.BufferAttribute(he.current, 3),
1119
+ uv: new m.BufferAttribute(me.current, 2),
1120
+ faceUv: new m.BufferAttribute(pe.current, 2)
1121
+ };
1122
+ q.forEach((O) => {
1123
+ Fn(O.geometryRef.current, b, O.getIndices(H));
1124
+ }), b.uv.needsUpdate = !0, Oe.current = H, se.current = !1;
1125
+ }
1126
+ const ie = he.current, ye = pe.current, ce = me.current;
1127
+ if (!ie || !ye || !ce) return;
1128
+ const Le = vn(a, o, i), De = dn($), Pe = De ? ln(B) : null, P = W ? Tt.current : null;
1129
+ if (P) {
1130
+ P.x = 0, P.y = 0, P.z = 0;
1131
+ for (let b = 0; b < B.length; b++) {
1132
+ const O = B[b];
1133
+ P.x += O.x, P.y += O.y, P.z += O.z;
1134
+ }
1135
+ P.x /= B.length, P.y /= B.length, P.z /= B.length;
1136
+ }
1137
+ const Nt = Math.min(B.length, H.vertexCount);
1138
+ for (let b = 0; b < Nt; b++) {
1139
+ const O = B[b], Ne = De && Pe ? un(O, Pe, $, Et.current) : O, Ht = W && P ? Kt(
1140
+ Ne,
1141
+ P,
1142
+ W,
1143
+ St.current
1144
+ ) : Ne, be = b * 3, le = b * 2, ge = zt(Ht);
1145
+ 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);
1146
+ }
1147
+ 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) => {
1148
+ b.meshRef.current.visible = b.visible;
1149
+ }), A.attributes.position.needsUpdate = !0, A.attributes.faceUv.needsUpdate = !0, q.forEach((b) => {
1150
+ b.geometryRef.current.computeVertexNormals();
1151
+ });
1152
+ }), /* @__PURE__ */ g("group", { scale: [ue, ue, ue], children: q.map((A) => /* @__PURE__ */ we(
1153
+ "mesh",
1154
+ {
1155
+ ref: A.meshRef,
1156
+ renderOrder: Je + A.renderOrderOffset,
1157
+ frustumCulled: !1,
1158
+ children: [
1159
+ /* @__PURE__ */ g("bufferGeometry", { ref: A.geometryRef }),
1160
+ oe ? typeof oe == "function" ? oe({ cameraTexture: Ue ?? null, geometryKey: A.key }) : oe : Pt(A.masked)
1161
+ ]
1162
+ },
1163
+ A.key
1164
+ )) });
1165
+ }, 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 = {
1166
+ ...Ve,
1167
+ position: { ...Ve.position, y: 1e-3 }
1168
+ }, Qn = {
1169
+ enabled: !0,
1170
+ faceIndex: 0,
1171
+ targetFps: An,
1172
+ ...G,
1173
+ showLeftEyeGeometry: !0,
1174
+ showRightEyeGeometry: !0,
1175
+ showMouthGeometry: !0,
1176
+ showNoseGeometry: !0,
1177
+ externalScale: 1,
1178
+ showOverlayMask: !1,
1179
+ showMouthMask: !1,
1180
+ showLeftEyeMask: !1,
1181
+ showRightEyeMask: !1,
1182
+ showNoseMask: !1,
1183
+ maskTextureSource: ee.textureSource,
1184
+ maskSourceUrl: "",
1185
+ maskColor: ee.color,
1186
+ maskOpacity: ee.opacity,
1187
+ faceTextureUrl: In,
1188
+ faceTextureStyle2Url: On,
1189
+ faceAlphaMaskUrl: Ln,
1190
+ renderOrder: Ze
1191
+ }, Pn = (e) => {
1192
+ const { externalMeshUrl: n, ...t } = e;
1193
+ return { ...t, color: t.baseColor, meshUrl: n };
1194
+ }, qn = (e, n) => {
1195
+ const t = { ...e, ...n };
1196
+ return n.maskTextureSource && !ke(n.maskTextureSource) && (t.maskSourceUrl = ""), t.materialType === C.shader && n.shaderPreset === X.composite ? {
1197
+ ...t,
1198
+ ...Xe,
1199
+ materialType: C.shader,
1200
+ shaderPreset: X.composite
1201
+ } : t.materialType === C.shader && t.shaderPreset === X.composite && t.textureMap === j.none ? {
1202
+ ...t,
1203
+ textureMap: Xe.textureMap
1204
+ } : t;
1205
+ }, Zn = ({
1206
+ transform: e,
1207
+ value: n
1208
+ }) => n.enabled ? /* @__PURE__ */ we(Ye, { children: [
1209
+ /* @__PURE__ */ g(
1210
+ qt,
1211
+ {
1212
+ active: n.enabled,
1213
+ faceIndex: n.faceIndex,
1214
+ numFaces: n.faceIndex + 1,
1215
+ targetFps: n.targetFps
1216
+ }
1217
+ ),
1218
+ /* @__PURE__ */ g(
1219
+ Un,
1220
+ {
1221
+ ...Pn(n),
1222
+ transform: e ?? Dn
1223
+ }
1224
+ )
1225
+ ] }) : null;
1226
+ export {
1227
+ Qe as A,
1228
+ Ve as B,
1229
+ Un as C,
1230
+ G as D,
1231
+ _e as E,
1232
+ C as F,
1233
+ En as G,
1234
+ ke as H,
1235
+ cn as M,
1236
+ an as S,
1237
+ Re as T,
1238
+ X as a,
1239
+ ne as b,
1240
+ j as c,
1241
+ J as d,
1242
+ qe as e,
1243
+ ae as f,
1244
+ je as g,
1245
+ Qn as h,
1246
+ Dn as i,
1247
+ Te as j,
1248
+ Kn as k,
1249
+ _n as l,
1250
+ Zn as m,
1251
+ Ln as n,
1252
+ On as o,
1253
+ In as p,
1254
+ kn as q,
1255
+ Pn as r,
1256
+ $n as s,
1257
+ qn as t,
1258
+ Mn as u,
1259
+ pn as v,
1260
+ K as w,
1261
+ en as x,
1262
+ Yn as y,
1263
+ jn as z
1264
+ };