@vincentt-xr/sdk 2.0.0-alpha.0 → 2.0.0-alpha.1

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 (106) hide show
  1. package/GROUNDING.md +232 -14
  2. package/dist/{DebuggerUI-CEfdddkZ.cjs → DebuggerUI-CatYc-RG.cjs} +1 -1
  3. package/dist/{DebuggerUI-Dgop6Q6o.js → DebuggerUI-gLMKiVwJ.js} +1 -1
  4. package/dist/MediaSourceSwitcher-C-xYg0nQ.js +317 -0
  5. package/dist/MediaSourceSwitcher-Cq3g4IKw.cjs +31 -0
  6. package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +6 -1
  7. package/dist/components/FaceMesh/material/defaults.d.ts +4 -0
  8. package/dist/components/FaceMesh/material/types.d.ts +2 -0
  9. package/dist/components/FaceRetouch/Background.d.ts +6 -1
  10. package/dist/components/FaceRetouch/defaults.d.ts +13 -0
  11. package/dist/components/FaceRetouch/index.d.ts +3 -1
  12. package/dist/components/FaceRetouch/landmarkMask.d.ts +4 -1
  13. package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +2 -1
  14. package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +15 -0
  15. package/dist/components/FaceWarp3D/defaults.d.ts +37 -0
  16. package/dist/components/FaceWarp3D/index.d.ts +3 -0
  17. package/dist/components/FaceWarp3D/warp.d.ts +13 -0
  18. package/dist/components/HandJoints2D/index.d.ts +6 -0
  19. package/dist/components/HandTracker/index.d.ts +2 -2
  20. package/dist/components/HandTracking2D/HandVisual.d.ts +12 -0
  21. package/dist/components/HandTracking2D/index.d.ts +5 -0
  22. package/dist/components/HandTracking2DController/index.d.ts +5 -0
  23. package/dist/components/HandTracking3D/index.d.ts +6 -0
  24. package/dist/components/ScreenImage/index.d.ts +87 -0
  25. package/dist/components/ScreenText/index.d.ts +20 -0
  26. package/dist/components/TextLabel/index.d.ts +99 -0
  27. package/dist/components/XRScene/index.d.ts +14 -3
  28. package/dist/components/XRViewport/index.d.ts +17 -0
  29. package/dist/components/index.d.ts +7 -0
  30. package/dist/debug-ui/default-setting/index.d.ts +37 -0
  31. package/dist/debug-ui/default-setting.cjs +21 -0
  32. package/dist/debug-ui/default-setting.js +777 -0
  33. package/dist/debug-ui/face-warp-3d/index.d.ts +6 -0
  34. package/dist/debug-ui/hand-joints-2d/index.d.ts +6 -0
  35. package/dist/debug-ui/hand-tracking-2d/index.d.ts +6 -0
  36. package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +6 -0
  37. package/dist/debug-ui/hand-tracking-3d/index.d.ts +6 -0
  38. package/dist/debug-ui/index.d.ts +23 -0
  39. package/dist/debug-ui/layer-panel/index.d.ts +17 -0
  40. package/dist/debug-ui/media-source/MediaSourceSwitcher.d.ts +10 -0
  41. package/dist/debug-ui/media-source/index.d.ts +4 -0
  42. package/dist/debug-ui/media-source/media-preset.d.ts +9 -0
  43. package/dist/debug-ui/media-source.cjs +1 -0
  44. package/dist/debug-ui/media-source.js +7 -0
  45. package/dist/debug-ui/screen-image-settings/index.d.ts +7 -0
  46. package/dist/debug-ui/screen-text-settings/index.d.ts +122 -0
  47. package/dist/debug-ui/settings-panel/index.d.ts +38 -0
  48. package/dist/debug-ui/shared/MaterialSection.d.ts +13 -0
  49. package/dist/debug-ui/shared/ScreenTransformSection.d.ts +29 -0
  50. package/dist/debug-ui.cjs +20 -0
  51. package/dist/debug-ui.js +6063 -0
  52. package/dist/defaults-BLpcN3pG.cjs +1 -0
  53. package/dist/defaults-LtY4M7dg.js +55 -0
  54. package/dist/entries/core.d.ts +5 -1
  55. package/dist/entries/face-effects.d.ts +2 -0
  56. package/dist/entries/low-level.d.ts +3 -0
  57. package/dist/face-effects.cjs +113 -23
  58. package/dist/face-effects.js +1566 -1399
  59. package/dist/handJoints2d.d.ts +49 -0
  60. package/dist/handTracking2d.d.ts +33 -0
  61. package/dist/handTracking2dController.d.ts +65 -0
  62. package/dist/handTracking3d.d.ts +52 -0
  63. package/dist/{index-BD-JWMjE.js → index-BGNbrc4C.js} +113 -137
  64. package/dist/index-BXyObVHF.cjs +1 -0
  65. package/dist/index-CY3bUAcW.js +12 -0
  66. package/dist/index-C_Duh13c.cjs +1 -0
  67. package/dist/index-D8fpPQkC.cjs +1 -0
  68. package/dist/index-DxshgBu0.cjs +1 -0
  69. package/dist/index-O-2crZ3M.js +1102 -0
  70. package/dist/{index-CYMj26Ej.js → index-safCs_af.js} +426 -416
  71. package/dist/{internal-DH5d1Xnq.cjs → internal-BjyhBP8i.cjs} +1 -1
  72. package/dist/{internal-KOKJDxCG.js → internal-Cae1ps15.js} +3 -3
  73. package/dist/internal.cjs +1 -1
  74. package/dist/internal.js +2 -2
  75. package/dist/layerStack.d.ts +29 -0
  76. package/dist/low-level.cjs +1 -1
  77. package/dist/low-level.js +74 -890
  78. package/dist/main.cjs +73 -1
  79. package/dist/main.js +1656 -407
  80. package/dist/models/Hand/HandTracking.d.ts +2 -0
  81. package/dist/screen2d/index.d.ts +4 -0
  82. package/dist/screen2d/material-runtime.d.ts +32 -0
  83. package/dist/screen2d/texture.d.ts +10 -0
  84. package/dist/screen2d/transform.d.ts +25 -0
  85. package/dist/screen2d/types.d.ts +90 -0
  86. package/dist/screenImagePresets.d.ts +13 -0
  87. package/dist/screenImageSettings-6NRg4cx9.js +39 -0
  88. package/dist/screenImageSettings-y_B4_767.cjs +1 -0
  89. package/dist/screenImageSettings.d.ts +50 -0
  90. package/dist/screenTextPresets.d.ts +6 -0
  91. package/dist/screenTextSettings.d.ts +131 -0
  92. package/dist/{selectors-Bub0o3qy.cjs → selectors-BLl2JUWW.cjs} +1 -1
  93. package/dist/{selectors-BHO6TnoC.js → selectors-CXd_x-6t.js} +6 -6
  94. package/dist/tracking.cjs +1 -1
  95. package/dist/tracking.js +193 -168
  96. package/dist/types/hand-tracking.d.ts +8 -0
  97. package/dist/types/nodes.d.ts +2 -0
  98. package/dist/useXRModel-3DcUa28n.cjs +1 -0
  99. package/dist/useXRModel-BMJE1hrk.js +28 -0
  100. package/dist/x-Co8jPhP0.js +127 -0
  101. package/dist/x-KC8E4Gaj.cjs +41 -0
  102. package/package.json +19 -1
  103. package/dist/index-B5J4gzn2.cjs +0 -1
  104. package/dist/index-BVBVg96G.cjs +0 -1
  105. package/dist/index-DtwHElmG.js +0 -157
  106. package/dist/index-PtFmD6B8.cjs +0 -1
package/dist/tracking.js CHANGED
@@ -1,11 +1,12 @@
1
- import { u as pr } from "./useFaceResults-cpsSmKKc.js";
2
- import { u as g, T as z, a as K } from "./index-BD-JWMjE.js";
3
- import { b as yr, F as mr } from "./index-BD-JWMjE.js";
4
- import { jsx as E, Fragment as G } from "react/jsx-runtime";
5
- import { useThree as N, useFrame as v } from "@react-three/fiber";
6
- import { useRef as T, useCallback as C, useMemo as k, useEffect as x } from "react";
7
- import * as R from "three";
8
- import { X as S, R as w } from "./index-CYMj26Ej.js";
1
+ import { u as yr } from "./useFaceResults-cpsSmKKc.js";
2
+ import { T as z, u as K } from "./index-BGNbrc4C.js";
3
+ import { a as Tr, F as br } from "./index-BGNbrc4C.js";
4
+ import { jsx as g, Fragment as G } from "react/jsx-runtime";
5
+ import { useThree as N, useFrame as k } from "@react-three/fiber";
6
+ import { useRef as T, useCallback as C, useMemo as A, useEffect as x } from "react";
7
+ import * as E from "three";
8
+ import { X as v, R as w } from "./index-safCs_af.js";
9
+ import { u as S } from "./useXRModel-BMJE1hrk.js";
9
10
  const L = {
10
11
  "body.head": 0,
11
12
  "body.leftShoulder": 11,
@@ -20,55 +21,55 @@ const L = {
20
21
  "body.rightKnee": 26,
21
22
  "body.leftAnkle": 27,
22
23
  "body.rightAnkle": 28
23
- }, er = ({ bodyIndex: r = 0, active: n = !0, children: t }) => {
24
- const e = T(null), { ready: o, node: a } = g(
25
- S.BODY_TRACKER,
24
+ }, or = ({ bodyIndex: r = 0, active: n = !0, children: t }) => {
25
+ const e = T(null), { ready: o, node: i } = S(
26
+ v.BODY_TRACKER,
26
27
  void 0,
27
28
  n
28
- ), { camera: s } = N(), d = T(s);
29
- d.current !== s && (d.current = s);
30
- const i = T(null);
31
- v(() => {
32
- if (!o || !a || !e.current) return;
33
- const f = a;
34
- i.current = f;
35
- const c = f.getLandmarks2D(r), u = c == null ? void 0 : c[0];
36
- if (!u) {
29
+ ), { camera: s } = N(), p = T(s);
30
+ p.current !== s && (p.current = s);
31
+ const c = T(null);
32
+ k(() => {
33
+ if (!o || !i || !e.current) return;
34
+ const d = i;
35
+ c.current = d;
36
+ const u = d.getLandmarks2D(r), y = u == null ? void 0 : u[0];
37
+ if (!y) {
37
38
  e.current.visible = !1;
38
39
  return;
39
40
  }
40
- const p = D(u, d.current);
41
- e.current.visible = !0, e.current.position.copy(p);
41
+ const l = D(y, p.current);
42
+ e.current.visible = !0, e.current.position.copy(l);
42
43
  });
43
- const l = C(
44
- (f) => {
45
- const c = i.current;
46
- if (!c) return null;
47
- const u = c.getLandmarks2D(r);
44
+ const a = C(
45
+ (d) => {
46
+ const u = c.current;
48
47
  if (!u) return null;
49
- if (f === "body.neck") {
50
- const h = u[11], b = u[12];
51
- if (!h || !b) return null;
52
- const A = {
53
- x: (h.x + b.x) / 2,
54
- y: (h.y + b.y) / 2,
55
- z: (h.z + b.z) / 2
48
+ const y = u.getLandmarks2D(r);
49
+ if (!y) return null;
50
+ if (d === "body.neck") {
51
+ const f = y[11], b = y[12];
52
+ if (!f || !b) return null;
53
+ const R = {
54
+ x: (f.x + b.x) / 2,
55
+ y: (f.y + b.y) / 2,
56
+ z: (f.z + b.z) / 2
56
57
  };
57
- return { position: D(A, d.current) };
58
+ return { position: D(R, p.current) };
58
59
  }
59
- const p = L[f];
60
- if (p === void 0) return null;
61
- const m = u[p];
62
- return m ? { position: D(m, d.current) } : null;
60
+ const l = L[d];
61
+ if (l === void 0) return null;
62
+ const m = y[l];
63
+ return m ? { position: D(m, p.current) } : null;
63
64
  },
64
65
  [r]
65
- ), y = k(
66
- () => ({ type: "body", resolveLandmark: l }),
67
- [l]
66
+ ), h = A(
67
+ () => ({ type: "body", resolveLandmark: a }),
68
+ [a]
68
69
  );
69
- return /* @__PURE__ */ E(z.Provider, { value: y, children: /* @__PURE__ */ E("group", { ref: e, renderOrder: w.TRACKED, children: t }) });
70
+ return /* @__PURE__ */ g(z.Provider, { value: h, children: /* @__PURE__ */ g("group", { ref: e, renderOrder: w.TRACKED, children: t }) });
70
71
  }, D = (r, n) => {
71
- const t = new R.Vector3(r.x, r.y, r.z);
72
+ const t = new E.Vector3(r.x, r.y, r.z);
72
73
  t.unproject(n);
73
74
  const e = t.sub(n.position).normalize(), o = -n.position.z / e.z;
74
75
  return n.position.clone().add(e.multiplyScalar(o));
@@ -83,42 +84,42 @@ const L = {
83
84
  "hand.middleBase": 9,
84
85
  "hand.ringBase": 13,
85
86
  "hand.pinkyBase": 17
86
- }, tr = ({ children: r, targetFps: n, active: t = !0 }) => {
87
- const e = T(null), o = k(
87
+ }, ir = ({ children: r, targetFps: n, active: t = !0 }) => {
88
+ const e = T(null), o = A(
88
89
  () => n === void 0 ? void 0 : { targetFps: n },
89
90
  [n]
90
- ), { ready: a, node: s } = g(
91
- S.GESTURE_TRACKER,
91
+ ), { ready: i, node: s } = S(
92
+ v.GESTURE_TRACKER,
92
93
  o,
93
94
  t
94
- ), { camera: d } = N(), i = T(d);
95
- i.current !== d && (i.current = d);
96
- const l = T(null);
97
- v(() => {
98
- var p;
99
- if (!a || !s || !e.current) return;
100
- l.current = s;
101
- const c = (p = s == null ? void 0 : s.coordinates) == null ? void 0 : p[0];
102
- if (!c) {
95
+ ), { camera: p } = N(), c = T(p);
96
+ c.current !== p && (c.current = p);
97
+ const a = T(null);
98
+ k(() => {
99
+ var l;
100
+ if (!i || !s || !e.current) return;
101
+ a.current = s;
102
+ const u = (l = s == null ? void 0 : s.coordinates) == null ? void 0 : l[0];
103
+ if (!u) {
103
104
  e.current.visible = !1;
104
105
  return;
105
106
  }
106
- const u = _(c, i.current);
107
- e.current.visible = !0, e.current.position.copy(u);
107
+ const y = _(u, c.current);
108
+ e.current.visible = !0, e.current.position.copy(y);
108
109
  });
109
- const y = C((c) => {
110
- var m, h;
111
- const u = W[c];
112
- if (u === void 0) return null;
113
- const p = (h = (m = l.current) == null ? void 0 : m.coordinates) == null ? void 0 : h[u];
114
- return p ? { position: _(p, i.current) } : null;
115
- }, []), f = k(
116
- () => ({ type: "hand", resolveLandmark: y }),
117
- [y]
110
+ const h = C((u) => {
111
+ var m, f;
112
+ const y = W[u];
113
+ if (y === void 0) return null;
114
+ const l = (f = (m = a.current) == null ? void 0 : m.coordinates) == null ? void 0 : f[y];
115
+ return l ? { position: _(l, c.current) } : null;
116
+ }, []), d = A(
117
+ () => ({ type: "hand", resolveLandmark: h }),
118
+ [h]
118
119
  );
119
- return /* @__PURE__ */ E(z.Provider, { value: f, children: /* @__PURE__ */ E("group", { ref: e, renderOrder: w.TRACKED, children: r }) });
120
+ return /* @__PURE__ */ g(z.Provider, { value: d, children: /* @__PURE__ */ g("group", { ref: e, renderOrder: w.TRACKED, children: r }) });
120
121
  }, _ = (r, n) => {
121
- const t = new R.Vector3(r.x, r.y, r.z);
122
+ const t = new E.Vector3(r.x, r.y, r.z);
122
123
  t.unproject(n);
123
124
  const e = t.sub(n.position).normalize(), o = -n.position.z / e.z;
124
125
  return n.position.clone().add(e.multiplyScalar(o));
@@ -132,7 +133,7 @@ const L = {
132
133
  gesture: t,
133
134
  now: e,
134
135
  mode: o,
135
- debounceMs: a,
136
+ debounceMs: i,
136
137
  holdMs: s
137
138
  }) => {
138
139
  if (r.fired) return null;
@@ -144,7 +145,7 @@ const L = {
144
145
  r.holdStart = null;
145
146
  return null;
146
147
  }
147
- return r.armed ? n && t ? (r.fired = !0, t) : null : (n ? r.armStart = null : (r.armStart === null && (r.armStart = e), e - r.armStart >= a && (r.armed = !0)), null);
148
+ return r.armed ? n && t ? (r.fired = !0, t) : null : (n ? r.armStart = null : (r.armStart === null && (r.armStart = e), e - r.armStart >= i && (r.armed = !0)), null);
148
149
  };
149
150
  function F({
150
151
  gestures: r,
@@ -152,31 +153,31 @@ function F({
152
153
  debounceMs: t = P,
153
154
  holdMs: e = V,
154
155
  onTrigger: o,
155
- enabled: a = !0
156
+ enabled: i = !0
156
157
  }) {
157
- const { ready: s, node: d } = g(S.GESTURE_TRACKER), i = T(o);
158
+ const { ready: s, node: p } = S(v.GESTURE_TRACKER), c = T(o);
158
159
  x(() => {
159
- i.current = o;
160
+ c.current = o;
160
161
  }, [o]);
161
- const l = T(/* @__PURE__ */ new Set());
162
+ const a = T(/* @__PURE__ */ new Set());
162
163
  x(() => {
163
- l.current = new Set(Array.isArray(r) ? r : [r]);
164
+ a.current = new Set(Array.isArray(r) ? r : [r]);
164
165
  }, [r]);
165
- const y = T($());
166
- v(() => {
167
- if (!a || !s || !d) return;
168
- const f = d.gesture, c = !!(f && l.current.has(f)), u = j(y.current, {
169
- isTrigger: c,
170
- gesture: f,
166
+ const h = T($());
167
+ k(() => {
168
+ if (!i || !s || !p) return;
169
+ const d = p.gesture, u = !!(d && a.current.has(d)), y = j(h.current, {
170
+ isTrigger: u,
171
+ gesture: d,
171
172
  now: performance.now(),
172
173
  mode: n,
173
174
  debounceMs: t,
174
175
  holdMs: e
175
176
  });
176
- u && i.current(u);
177
+ y && c.current(y);
177
178
  });
178
179
  }
179
- const or = (r) => (F(r), null), q = {
180
+ const cr = (r) => (F(r), null), q = {
180
181
  "hand.wrist": 0,
181
182
  "hand.thumbTip": 4,
182
183
  "hand.indexTip": 8,
@@ -187,51 +188,75 @@ const or = (r) => (F(r), null), q = {
187
188
  "hand.middleBase": 9,
188
189
  "hand.ringBase": 13,
189
190
  "hand.pinkyBase": 17
190
- }, ir = ({ children: r, targetFps: n, active: t = !0 }) => {
191
- const e = T(null), o = k(
192
- () => n === void 0 ? void 0 : { targetFps: n },
193
- [n]
194
- ), { ready: a, node: s } = g(
195
- S.HAND_TRACKER,
196
- o,
197
- t
198
- ), { camera: d } = N(), i = T(d);
199
- i.current !== d && (i.current = d);
200
- const l = T(null);
201
- v(() => {
202
- var m;
203
- if (!a || !s || !e.current) return;
204
- const c = s;
205
- l.current = c;
206
- const u = (m = c == null ? void 0 : c.coordinates) == null ? void 0 : m[0];
207
- if (!u) {
208
- e.current.visible = !1;
191
+ };
192
+ function U(r, n, t = 0) {
193
+ var o;
194
+ const e = (o = r == null ? void 0 : r.hands) != null && o.length ? r.hands : r != null && r.coordinates ? [
195
+ {
196
+ coordinates: r.coordinates,
197
+ gesture: r.gesture,
198
+ handedness: r.handedness
199
+ }
200
+ ] : [];
201
+ if (e.length) {
202
+ if (n) {
203
+ const i = e.find((s) => s.handedness === n);
204
+ if (i) return i;
205
+ }
206
+ return e[t] ?? e[0];
207
+ }
208
+ }
209
+ const sr = ({
210
+ children: r,
211
+ hand: n,
212
+ handIndex: t = 0,
213
+ targetFps: e,
214
+ active: o = !0
215
+ }) => {
216
+ const i = T(null), s = A(
217
+ () => e === void 0 ? void 0 : { targetFps: e },
218
+ [e]
219
+ ), { ready: p, node: c } = S(
220
+ v.HAND_TRACKER,
221
+ s,
222
+ o
223
+ ), { camera: a } = N(), h = T(a);
224
+ h.current !== a && (h.current = a);
225
+ const d = T(null);
226
+ k(() => {
227
+ var b;
228
+ if (!p || !c || !i.current) return;
229
+ const l = U(c, n, t);
230
+ d.current = l ?? null;
231
+ const m = (b = l == null ? void 0 : l.coordinates) == null ? void 0 : b[0];
232
+ if (!m) {
233
+ i.current.visible = !1;
209
234
  return;
210
235
  }
211
- const p = B(u, i.current);
212
- e.current.visible = !0, e.current.position.copy(p);
236
+ const f = B(m, h.current);
237
+ i.current.visible = !0, i.current.position.copy(f);
213
238
  });
214
- const y = C((c) => {
215
- var m, h;
216
- const u = q[c];
217
- if (u === void 0) return null;
218
- const p = (h = (m = l.current) == null ? void 0 : m.coordinates) == null ? void 0 : h[u];
219
- return p ? { position: B(p, i.current) } : null;
220
- }, []), f = k(
221
- () => ({ type: "hand", resolveLandmark: y }),
222
- [y]
239
+ const u = C((l) => {
240
+ var b, R;
241
+ const m = q[l];
242
+ if (m === void 0) return null;
243
+ const f = (R = (b = d.current) == null ? void 0 : b.coordinates) == null ? void 0 : R[m];
244
+ return f ? { position: B(f, h.current) } : null;
245
+ }, []), y = A(
246
+ () => ({ type: "hand", resolveLandmark: u }),
247
+ [u]
223
248
  );
224
- return /* @__PURE__ */ E(z.Provider, { value: f, children: /* @__PURE__ */ E("group", { ref: e, renderOrder: w.TRACKED, children: r }) });
249
+ return /* @__PURE__ */ g(z.Provider, { value: y, children: /* @__PURE__ */ g("group", { ref: i, renderOrder: w.TRACKED, children: r }) });
225
250
  }, B = (r, n) => {
226
- const t = new R.Vector3(r.x, r.y, r.z);
251
+ const t = new E.Vector3(r.x, r.y, r.z);
227
252
  t.unproject(n);
228
253
  const e = t.sub(n.position).normalize(), o = -n.position.z / e.z;
229
254
  return n.position.clone().add(e.multiplyScalar(o));
230
- }, H = ["portrait"], cr = ({ type: r, active: n = !0, children: t }) => (g(S.BACKGROUND_SEGMENTATION, { type: r }, n), x(() => {
255
+ }, H = ["portrait"], ur = ({ type: r, active: n = !0, children: t }) => (S(v.BACKGROUND_SEGMENTATION, { type: r }, n), x(() => {
231
256
  H.includes(r) || console.warn(
232
257
  `[Segmentation] unsupported type "${r}"; valid values: ${H.join(", ")}`
233
258
  );
234
- }, [r]), /* @__PURE__ */ E(G, { children: t })), sr = [
259
+ }, [r]), /* @__PURE__ */ g(G, { children: t })), ar = [
235
260
  "face.forehead",
236
261
  "face.noseTip",
237
262
  "face.chin",
@@ -240,7 +265,7 @@ const or = (r) => (F(r), null), q = {
240
265
  "face.leftCheek",
241
266
  "face.rightCheek",
242
267
  "face.mouthCenter"
243
- ], ur = [
268
+ ], dr = [
244
269
  "hand.wrist",
245
270
  "hand.thumbTip",
246
271
  "hand.indexTip",
@@ -251,7 +276,7 @@ const or = (r) => (F(r), null), q = {
251
276
  "hand.middleBase",
252
277
  "hand.ringBase",
253
278
  "hand.pinkyBase"
254
- ], ar = [
279
+ ], lr = [
255
280
  "body.head",
256
281
  "body.neck",
257
282
  "body.leftShoulder",
@@ -266,79 +291,79 @@ const or = (r) => (F(r), null), q = {
266
291
  "body.rightKnee",
267
292
  "body.leftAnkle",
268
293
  "body.rightAnkle"
269
- ], U = (r) => r.startsWith("face.") ? "face" : r.startsWith("hand.") ? "hand" : r.startsWith("body.") ? "body" : null, M = (r, n, t) => n + t * (r - n), O = (r, n) => 1 / (1 + 1 / (2 * Math.PI * r) / n), X = (r, n, t, e, o, a) => {
294
+ ], X = (r) => r.startsWith("face.") ? "face" : r.startsWith("hand.") ? "hand" : r.startsWith("body.") ? "body" : null, M = (r, n, t) => n + t * (r - n), O = (r, n) => 1 / (1 + 1 / (2 * Math.PI * r) / n), Y = (r, n, t, e, o, i) => {
270
295
  if (!r.initialized || t <= 0)
271
296
  return r.pos.copy(n), r.prevRaw.copy(n), r.dxHat.set(0, 0, 0), r.initialized = !0, r;
272
- const s = O(a, t), d = ["x", "y", "z"];
273
- for (const i of d) {
274
- const l = (n[i] - r.prevRaw[i]) / t, y = M(l, r.dxHat[i], s);
275
- r.dxHat[i] = y;
276
- const f = e + o * Math.abs(y), c = O(f, t);
277
- r.pos[i] = M(n[i], r.pos[i], c), r.prevRaw[i] = n[i];
297
+ const s = O(i, t), p = ["x", "y", "z"];
298
+ for (const c of p) {
299
+ const a = (n[c] - r.prevRaw[c]) / t, h = M(a, r.dxHat[c], s);
300
+ r.dxHat[c] = h;
301
+ const d = e + o * Math.abs(h), u = O(d, t);
302
+ r.pos[c] = M(n[c], r.pos[c], u), r.prevRaw[c] = n[c];
278
303
  }
279
304
  return r;
280
- }, dr = ({
305
+ }, fr = ({
281
306
  target: r,
282
307
  offset: n,
283
308
  smoothing: t = 0,
284
309
  children: e
285
310
  }) => {
286
- const o = K(), a = T(null), s = T(!1), d = T(new R.Vector3()), i = T({
287
- pos: new R.Vector3(),
288
- prevRaw: new R.Vector3(),
289
- dxHat: new R.Vector3(),
311
+ const o = K(), i = T(null), s = T(!1), p = T(new E.Vector3()), c = T({
312
+ pos: new E.Vector3(),
313
+ prevRaw: new E.Vector3(),
314
+ dxHat: new E.Vector3(),
290
315
  initialized: !1
291
- }), l = U(r), y = o !== null && l !== null && o.type !== l, f = o === null, c = f || y || l === null;
316
+ }), a = X(r), h = o !== null && a !== null && o.type !== a, d = o === null, u = d || h || a === null;
292
317
  return x(() => {
293
- f ? console.warn(
318
+ d ? console.warn(
294
319
  `[TrackingAnchor] target "${r}" requires a FaceTracker / HandTracker / BodyTracker ancestor; rendering null.`
295
- ) : y ? console.warn(
320
+ ) : h ? console.warn(
296
321
  `[TrackingAnchor] target "${r}" namespace does not match parent tracker type "${o == null ? void 0 : o.type}"; rendering null.`
297
- ) : l === null && console.warn(
322
+ ) : a === null && console.warn(
298
323
  `[TrackingAnchor] target "${r}" is not a recognized face/hand/body landmark; rendering null.`
299
324
  );
300
- }, [r, l, f, y, o == null ? void 0 : o.type]), v((u, p) => {
301
- if (c || !a.current || !o) return;
325
+ }, [r, a, d, h, o == null ? void 0 : o.type]), k((y, l) => {
326
+ if (u || !i.current || !o) return;
302
327
  const m = o.resolveLandmark(r);
303
328
  if (!m) {
304
- a.current.visible = !1, s.current = !1, i.current.initialized = !1;
329
+ i.current.visible = !1, s.current = !1, c.current.initialized = !1;
305
330
  return;
306
331
  }
307
- a.current.visible = !0;
308
- const h = d.current.copy(m.position), b = a.current.parent;
332
+ i.current.visible = !0;
333
+ const f = p.current.copy(m.position), b = i.current.parent;
309
334
  if (b) {
310
335
  b.updateMatrixWorld();
311
- const A = new R.Matrix4().copy(b.matrixWorld).invert();
312
- h.applyMatrix4(A);
336
+ const R = new E.Matrix4().copy(b.matrixWorld).invert();
337
+ f.applyMatrix4(R);
313
338
  }
314
- if (n && (h.x += n[0], h.y += n[1], h.z += n[2]), t > 0) {
315
- const A = t * 0.1;
316
- X(
317
- i.current,
318
- h,
319
- s.current ? p : 0,
320
- A,
339
+ if (n && (f.x += n[0], f.y += n[1], f.z += n[2]), t > 0) {
340
+ const R = t * 0.1;
341
+ Y(
342
+ c.current,
343
+ f,
344
+ s.current ? l : 0,
345
+ R,
321
346
  0.5,
322
347
  1
323
- ), a.current.position.copy(i.current.pos);
348
+ ), i.current.position.copy(c.current.pos);
324
349
  } else
325
- a.current.position.copy(h);
326
- s.current = !0, m.quaternion && a.current.quaternion.copy(m.quaternion);
327
- }), c ? null : /* @__PURE__ */ E("group", { ref: a, renderOrder: w.TRACKED, children: e });
350
+ i.current.position.copy(f);
351
+ s.current = !0, m.quaternion && i.current.quaternion.copy(m.quaternion);
352
+ }), u ? null : /* @__PURE__ */ g("group", { ref: i, renderOrder: w.TRACKED, children: e });
328
353
  };
329
354
  export {
330
- ar as BODY_TARGETS,
331
- er as BodyTracker,
332
- sr as FACE_TARGETS,
333
- yr as FaceMesh,
334
- mr as FaceTracker,
335
- tr as GestureTracker,
336
- or as GestureTrigger,
337
- ur as HAND_TARGETS,
338
- ir as HandTracker,
355
+ lr as BODY_TARGETS,
356
+ or as BodyTracker,
357
+ ar as FACE_TARGETS,
358
+ Tr as FaceMesh,
359
+ br as FaceTracker,
360
+ ir as GestureTracker,
361
+ cr as GestureTrigger,
362
+ dr as HAND_TARGETS,
363
+ sr as HandTracker,
339
364
  H as SEGMENTATION_TYPES,
340
- cr as Segmentation,
341
- dr as TrackingAnchor,
342
- U as getTargetNamespace,
343
- pr as useFaceResults
365
+ ur as Segmentation,
366
+ fr as TrackingAnchor,
367
+ X as getTargetNamespace,
368
+ yr as useFaceResults
344
369
  };
@@ -1,5 +1,13 @@
1
1
  import { Coordinate } from './common';
2
+ export type Handedness = "left" | "right";
2
3
  export type HandData = {
3
4
  coordinates?: Coordinate[];
4
5
  gesture?: "closed_fist" | "open_palm";
6
+ handedness?: Handedness;
7
+ };
8
+ export type HandTrackingData = {
9
+ hands?: HandData[];
10
+ coordinates?: Coordinate[];
11
+ gesture?: HandData["gesture"];
12
+ handedness?: Handedness;
5
13
  };
@@ -20,8 +20,10 @@ export type XRModelNodeBodyTracking = {
20
20
  getLandmarks2D: (bodyIndex?: number) => Coordinate[] | undefined;
21
21
  };
22
22
  export type XRModelNodeHandTracking = {
23
+ hands?: HandData[];
23
24
  coordinates?: HandData["coordinates"];
24
25
  gesture?: HandData["gesture"];
26
+ handedness?: HandData["handedness"];
25
27
  };
26
28
  export type XRModelNodeGestureTracking = {
27
29
  coordinates?: GestureData["coordinates"];
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react"),E=require("./index-DxshgBu0.cjs");function S(t,o,l=!0){const{session:r}=E.useXRContext(),s=e.useId(),[i,f]=e.useState(null),y=e.useMemo(()=>JSON.stringify(o??{}),[o]);e.useEffect(()=>{let u=!1;return f(null),r.registry.acquire(t,s,o).catch(c=>{u||f(c instanceof Error?c:new Error(String(c)))}),()=>{u=!0,r.registry.release(t,s)}},[r,t,s,y]),e.useEffect(()=>{r.registry.setActive(t,s,l)},[r,t,s,l]);const g=r.store,n=e.useSyncExternalStore(u=>g.subscribe(u),()=>g.getSnapshot().pipeline.get(t)??null,()=>null),d=e.useMemo(()=>n?n.getModelNode():null,[n]);return{ready:n!==null&&i===null,node:d,error:i}}exports.useXRModel=S;
@@ -0,0 +1,28 @@
1
+ import { useId as p, useState as E, useMemo as g, useEffect as y, useSyncExternalStore as d } from "react";
2
+ import { u as x } from "./index-safCs_af.js";
3
+ function h(e, o, l = !0) {
4
+ const { session: r } = x(), t = p(), [c, i] = E(null), a = g(() => JSON.stringify(o ?? {}), [o]);
5
+ y(() => {
6
+ let s = !1;
7
+ return i(null), r.registry.acquire(e, t, o).catch((u) => {
8
+ s || i(u instanceof Error ? u : new Error(String(u)));
9
+ }), () => {
10
+ s = !0, r.registry.release(e, t);
11
+ };
12
+ }, [r, e, t, a]), y(() => {
13
+ r.registry.setActive(e, t, l);
14
+ }, [r, e, t, l]);
15
+ const f = r.store, n = d(
16
+ (s) => f.subscribe(s),
17
+ () => f.getSnapshot().pipeline.get(e) ?? null,
18
+ () => null
19
+ ), S = g(() => n ? n.getModelNode() : null, [n]);
20
+ return {
21
+ ready: n !== null && c === null,
22
+ node: S,
23
+ error: c
24
+ };
25
+ }
26
+ export {
27
+ h as u
28
+ };