@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.
- package/GROUNDING.md +232 -14
- package/dist/{DebuggerUI-CEfdddkZ.cjs → DebuggerUI-CatYc-RG.cjs} +1 -1
- package/dist/{DebuggerUI-Dgop6Q6o.js → DebuggerUI-gLMKiVwJ.js} +1 -1
- package/dist/MediaSourceSwitcher-C-xYg0nQ.js +317 -0
- package/dist/MediaSourceSwitcher-Cq3g4IKw.cjs +31 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +6 -1
- package/dist/components/FaceMesh/material/defaults.d.ts +4 -0
- package/dist/components/FaceMesh/material/types.d.ts +2 -0
- package/dist/components/FaceRetouch/Background.d.ts +6 -1
- package/dist/components/FaceRetouch/defaults.d.ts +13 -0
- package/dist/components/FaceRetouch/index.d.ts +3 -1
- package/dist/components/FaceRetouch/landmarkMask.d.ts +4 -1
- package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +2 -1
- package/dist/components/FaceWarp3D/FaceWarp3DHead.d.ts +15 -0
- package/dist/components/FaceWarp3D/defaults.d.ts +37 -0
- package/dist/components/FaceWarp3D/index.d.ts +3 -0
- package/dist/components/FaceWarp3D/warp.d.ts +13 -0
- package/dist/components/HandJoints2D/index.d.ts +6 -0
- package/dist/components/HandTracker/index.d.ts +2 -2
- package/dist/components/HandTracking2D/HandVisual.d.ts +12 -0
- package/dist/components/HandTracking2D/index.d.ts +5 -0
- package/dist/components/HandTracking2DController/index.d.ts +5 -0
- package/dist/components/HandTracking3D/index.d.ts +6 -0
- package/dist/components/ScreenImage/index.d.ts +87 -0
- package/dist/components/ScreenText/index.d.ts +20 -0
- package/dist/components/TextLabel/index.d.ts +99 -0
- package/dist/components/XRScene/index.d.ts +14 -3
- package/dist/components/XRViewport/index.d.ts +17 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/debug-ui/default-setting/index.d.ts +37 -0
- package/dist/debug-ui/default-setting.cjs +21 -0
- package/dist/debug-ui/default-setting.js +777 -0
- package/dist/debug-ui/face-warp-3d/index.d.ts +6 -0
- package/dist/debug-ui/hand-joints-2d/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-2d/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-2d-controller/index.d.ts +6 -0
- package/dist/debug-ui/hand-tracking-3d/index.d.ts +6 -0
- package/dist/debug-ui/index.d.ts +23 -0
- package/dist/debug-ui/layer-panel/index.d.ts +17 -0
- package/dist/debug-ui/media-source/MediaSourceSwitcher.d.ts +10 -0
- package/dist/debug-ui/media-source/index.d.ts +4 -0
- package/dist/debug-ui/media-source/media-preset.d.ts +9 -0
- package/dist/debug-ui/media-source.cjs +1 -0
- package/dist/debug-ui/media-source.js +7 -0
- package/dist/debug-ui/screen-image-settings/index.d.ts +7 -0
- package/dist/debug-ui/screen-text-settings/index.d.ts +122 -0
- package/dist/debug-ui/settings-panel/index.d.ts +38 -0
- package/dist/debug-ui/shared/MaterialSection.d.ts +13 -0
- package/dist/debug-ui/shared/ScreenTransformSection.d.ts +29 -0
- package/dist/debug-ui.cjs +20 -0
- package/dist/debug-ui.js +6063 -0
- package/dist/defaults-BLpcN3pG.cjs +1 -0
- package/dist/defaults-LtY4M7dg.js +55 -0
- package/dist/entries/core.d.ts +5 -1
- package/dist/entries/face-effects.d.ts +2 -0
- package/dist/entries/low-level.d.ts +3 -0
- package/dist/face-effects.cjs +113 -23
- package/dist/face-effects.js +1566 -1399
- package/dist/handJoints2d.d.ts +49 -0
- package/dist/handTracking2d.d.ts +33 -0
- package/dist/handTracking2dController.d.ts +65 -0
- package/dist/handTracking3d.d.ts +52 -0
- package/dist/{index-BD-JWMjE.js → index-BGNbrc4C.js} +113 -137
- package/dist/index-BXyObVHF.cjs +1 -0
- package/dist/index-CY3bUAcW.js +12 -0
- package/dist/index-C_Duh13c.cjs +1 -0
- package/dist/index-D8fpPQkC.cjs +1 -0
- package/dist/index-DxshgBu0.cjs +1 -0
- package/dist/index-O-2crZ3M.js +1102 -0
- package/dist/{index-CYMj26Ej.js → index-safCs_af.js} +426 -416
- package/dist/{internal-DH5d1Xnq.cjs → internal-BjyhBP8i.cjs} +1 -1
- package/dist/{internal-KOKJDxCG.js → internal-Cae1ps15.js} +3 -3
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +2 -2
- package/dist/layerStack.d.ts +29 -0
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +74 -890
- package/dist/main.cjs +73 -1
- package/dist/main.js +1656 -407
- package/dist/models/Hand/HandTracking.d.ts +2 -0
- package/dist/screen2d/index.d.ts +4 -0
- package/dist/screen2d/material-runtime.d.ts +32 -0
- package/dist/screen2d/texture.d.ts +10 -0
- package/dist/screen2d/transform.d.ts +25 -0
- package/dist/screen2d/types.d.ts +90 -0
- package/dist/screenImagePresets.d.ts +13 -0
- package/dist/screenImageSettings-6NRg4cx9.js +39 -0
- package/dist/screenImageSettings-y_B4_767.cjs +1 -0
- package/dist/screenImageSettings.d.ts +50 -0
- package/dist/screenTextPresets.d.ts +6 -0
- package/dist/screenTextSettings.d.ts +131 -0
- package/dist/{selectors-Bub0o3qy.cjs → selectors-BLl2JUWW.cjs} +1 -1
- package/dist/{selectors-BHO6TnoC.js → selectors-CXd_x-6t.js} +6 -6
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +193 -168
- package/dist/types/hand-tracking.d.ts +8 -0
- package/dist/types/nodes.d.ts +2 -0
- package/dist/useXRModel-3DcUa28n.cjs +1 -0
- package/dist/useXRModel-BMJE1hrk.js +28 -0
- package/dist/x-Co8jPhP0.js +127 -0
- package/dist/x-KC8E4Gaj.cjs +41 -0
- package/package.json +19 -1
- package/dist/index-B5J4gzn2.cjs +0 -1
- package/dist/index-BVBVg96G.cjs +0 -1
- package/dist/index-DtwHElmG.js +0 -157
- package/dist/index-PtFmD6B8.cjs +0 -1
package/dist/tracking.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useThree as N, useFrame as
|
|
6
|
-
import { useRef as T, useCallback as C, useMemo as
|
|
7
|
-
import * as
|
|
8
|
-
import { X as
|
|
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
|
-
},
|
|
24
|
-
const e = T(null), { ready: o, node:
|
|
25
|
-
|
|
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(),
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
if (!o || !
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
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
|
|
41
|
-
e.current.visible = !0, e.current.position.copy(
|
|
41
|
+
const l = D(y, p.current);
|
|
42
|
+
e.current.visible = !0, e.current.position.copy(l);
|
|
42
43
|
});
|
|
43
|
-
const
|
|
44
|
-
(
|
|
45
|
-
const
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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(
|
|
58
|
+
return { position: D(R, p.current) };
|
|
58
59
|
}
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
const m =
|
|
62
|
-
return m ? { position: D(m,
|
|
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
|
-
),
|
|
66
|
-
() => ({ type: "body", resolveLandmark:
|
|
67
|
-
[
|
|
66
|
+
), h = A(
|
|
67
|
+
() => ({ type: "body", resolveLandmark: a }),
|
|
68
|
+
[a]
|
|
68
69
|
);
|
|
69
|
-
return /* @__PURE__ */
|
|
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
|
|
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
|
-
},
|
|
87
|
-
const e = T(null), o =
|
|
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:
|
|
91
|
-
|
|
91
|
+
), { ready: i, node: s } = S(
|
|
92
|
+
v.GESTURE_TRACKER,
|
|
92
93
|
o,
|
|
93
94
|
t
|
|
94
|
-
), { camera:
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
if (!
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
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
|
|
107
|
-
e.current.visible = !0, e.current.position.copy(
|
|
107
|
+
const y = _(u, c.current);
|
|
108
|
+
e.current.visible = !0, e.current.position.copy(y);
|
|
108
109
|
});
|
|
109
|
-
const
|
|
110
|
-
var m,
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
return
|
|
115
|
-
}, []),
|
|
116
|
-
() => ({ type: "hand", resolveLandmark:
|
|
117
|
-
[
|
|
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__ */
|
|
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
|
|
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:
|
|
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 >=
|
|
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:
|
|
156
|
+
enabled: i = !0
|
|
156
157
|
}) {
|
|
157
|
-
const { ready: s, node:
|
|
158
|
+
const { ready: s, node: p } = S(v.GESTURE_TRACKER), c = T(o);
|
|
158
159
|
x(() => {
|
|
159
|
-
|
|
160
|
+
c.current = o;
|
|
160
161
|
}, [o]);
|
|
161
|
-
const
|
|
162
|
+
const a = T(/* @__PURE__ */ new Set());
|
|
162
163
|
x(() => {
|
|
163
|
-
|
|
164
|
+
a.current = new Set(Array.isArray(r) ? r : [r]);
|
|
164
165
|
}, [r]);
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
if (!
|
|
168
|
-
const
|
|
169
|
-
isTrigger:
|
|
170
|
-
gesture:
|
|
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
|
-
|
|
177
|
+
y && c.current(y);
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
|
-
const
|
|
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
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
|
212
|
-
|
|
236
|
+
const f = B(m, h.current);
|
|
237
|
+
i.current.visible = !0, i.current.position.copy(f);
|
|
213
238
|
});
|
|
214
|
-
const
|
|
215
|
-
var
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
const
|
|
219
|
-
return
|
|
220
|
-
}, []),
|
|
221
|
-
() => ({ type: "hand", resolveLandmark:
|
|
222
|
-
[
|
|
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__ */
|
|
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
|
|
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"],
|
|
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__ */
|
|
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
|
-
],
|
|
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
|
-
],
|
|
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
|
-
],
|
|
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(
|
|
273
|
-
for (const
|
|
274
|
-
const
|
|
275
|
-
r.dxHat[
|
|
276
|
-
const
|
|
277
|
-
r.pos[
|
|
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
|
-
},
|
|
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(),
|
|
287
|
-
pos: new
|
|
288
|
-
prevRaw: new
|
|
289
|
-
dxHat: new
|
|
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
|
-
}),
|
|
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
|
-
|
|
318
|
+
d ? console.warn(
|
|
294
319
|
`[TrackingAnchor] target "${r}" requires a FaceTracker / HandTracker / BodyTracker ancestor; rendering null.`
|
|
295
|
-
) :
|
|
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
|
-
) :
|
|
322
|
+
) : a === null && console.warn(
|
|
298
323
|
`[TrackingAnchor] target "${r}" is not a recognized face/hand/body landmark; rendering null.`
|
|
299
324
|
);
|
|
300
|
-
}, [r,
|
|
301
|
-
if (
|
|
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
|
-
|
|
329
|
+
i.current.visible = !1, s.current = !1, c.current.initialized = !1;
|
|
305
330
|
return;
|
|
306
331
|
}
|
|
307
|
-
|
|
308
|
-
const
|
|
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
|
|
312
|
-
|
|
336
|
+
const R = new E.Matrix4().copy(b.matrixWorld).invert();
|
|
337
|
+
f.applyMatrix4(R);
|
|
313
338
|
}
|
|
314
|
-
if (n && (
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
s.current ?
|
|
320
|
-
|
|
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
|
-
),
|
|
348
|
+
), i.current.position.copy(c.current.pos);
|
|
324
349
|
} else
|
|
325
|
-
|
|
326
|
-
s.current = !0, m.quaternion &&
|
|
327
|
-
}),
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
};
|
package/dist/types/nodes.d.ts
CHANGED
|
@@ -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
|
+
};
|