@ssafy-mhk/e-ver 1.0.4 → 1.0.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.
- package/dist/components/WebcamPlaneBackground.d.ts +2 -3
- package/dist/garment/fitMotion.d.ts +3 -0
- package/dist/garment/trackedModelTransform.d.ts +1 -0
- package/dist/hooks/useWebcam.d.ts +2 -2
- package/dist/index.d.ts +0 -8
- package/dist/index.es.js +1101 -1131
- package/dist/index.umd.js +1 -1
- package/dist/pose/coordinateTransform.d.ts +2 -0
- package/dist/pose/yawFreezeController.d.ts +1 -1
- package/package.json +4 -4
- package/dist/components/AvatarModel.d.ts +0 -11
- package/dist/components/CameraView.d.ts +0 -15
- package/dist/components/EverProvider.d.ts +0 -9
- package/dist/components/GarmentModel.d.ts +0 -10
- package/dist/components/ever-context.d.ts +0 -9
- package/dist/hooks/useBodyMeasurer.d.ts +0 -20
- package/dist/hooks/useBodyMeasurer.test.d.ts +0 -1
- package/dist/hooks/usePoseMapper.d.ts +0 -8
- package/dist/hooks/usePoseMapper.test.d.ts +0 -1
- package/dist/store/useEverStore.d.ts +0 -22
- package/dist/store/useEverStore.test.d.ts +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,49 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//#region src/store/useEverStore.ts
|
|
12
|
-
var O = e((e) => ({
|
|
13
|
-
isWebcamActive: !1,
|
|
14
|
-
activeGarmentUrl: null,
|
|
15
|
-
landmarks: null,
|
|
16
|
-
worldLandmarks: null,
|
|
17
|
-
fitResult: null,
|
|
18
|
-
setWebcamActive: (t) => e({ isWebcamActive: t }),
|
|
19
|
-
setActiveGarmentUrl: (t) => e({ activeGarmentUrl: t }),
|
|
20
|
-
setLandmarks: (t, n) => e({
|
|
21
|
-
landmarks: t,
|
|
22
|
-
worldLandmarks: n
|
|
23
|
-
}),
|
|
24
|
-
setFitResult: (t) => e({ fitResult: t })
|
|
25
|
-
})), k = n(void 0);
|
|
26
|
-
function A() {
|
|
27
|
-
let e = i(k);
|
|
28
|
-
if (!e) throw Error("useEver must be used within an EverProvider");
|
|
29
|
-
return e;
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/components/EverProvider.tsx
|
|
33
|
-
var j = ({ children: e }) => {
|
|
34
|
-
let t = s(null), [n, i] = c(null), a = {
|
|
35
|
-
videoRef: t,
|
|
36
|
-
avatarBones: n,
|
|
37
|
-
setAvatarBones: r((e) => {
|
|
38
|
-
i(e);
|
|
39
|
-
}, []),
|
|
40
|
-
isProviderReady: !0
|
|
41
|
-
};
|
|
42
|
-
return /* @__PURE__ */ f(k.Provider, {
|
|
43
|
-
value: a,
|
|
44
|
-
children: e
|
|
45
|
-
});
|
|
46
|
-
}, M = ({ children: e, showEnvironment: n = !0, useDefaultLights: r = !0, enableOrbitControls: i = !0 }) => /* @__PURE__ */ f(j, { children: /* @__PURE__ */ f(m, {
|
|
1
|
+
import { Suspense as e, useCallback as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
|
|
2
|
+
import { Canvas as o, useFrame as s, useThree as c } from "@react-three/fiber";
|
|
3
|
+
import { Environment as l, OrbitControls as u, OrthographicCamera as d, Stats as f, useGLTF as p } from "@react-three/drei";
|
|
4
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
import { DrawingUtils as _, FilesetResolver as v, PoseLandmarker as y } from "@mediapipe/tasks-vision";
|
|
6
|
+
import * as b from "three";
|
|
7
|
+
import { clone as x } from "three/examples/jsm/utils/SkeletonUtils.js";
|
|
8
|
+
import { VRMLoaderPlugin as S, VRMUtils as C } from "@pixiv/three-vrm";
|
|
9
|
+
//#region src/components/EverCanvas.tsx
|
|
10
|
+
var w = ({ children: t, showEnvironment: n = !0, useDefaultLights: r = !0, enableOrbitControls: i = !0 }) => /* @__PURE__ */ h(o, {
|
|
47
11
|
camera: {
|
|
48
12
|
position: [
|
|
49
13
|
0,
|
|
@@ -64,12 +28,12 @@ var j = ({ children: e }) => {
|
|
|
64
28
|
antialias: !0,
|
|
65
29
|
preserveDrawingBuffer: !0
|
|
66
30
|
},
|
|
67
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ g(e, {
|
|
68
32
|
fallback: null,
|
|
69
33
|
children: [
|
|
70
|
-
r ? /* @__PURE__ */
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
34
|
+
r ? /* @__PURE__ */ g(m, { children: [
|
|
35
|
+
/* @__PURE__ */ h("ambientLight", { intensity: .7 }),
|
|
36
|
+
/* @__PURE__ */ h("directionalLight", {
|
|
73
37
|
position: [
|
|
74
38
|
2,
|
|
75
39
|
5,
|
|
@@ -78,7 +42,7 @@ var j = ({ children: e }) => {
|
|
|
78
42
|
intensity: 1.5,
|
|
79
43
|
castShadow: !0
|
|
80
44
|
}),
|
|
81
|
-
/* @__PURE__ */
|
|
45
|
+
/* @__PURE__ */ h("directionalLight", {
|
|
82
46
|
position: [
|
|
83
47
|
-2,
|
|
84
48
|
5,
|
|
@@ -87,9 +51,9 @@ var j = ({ children: e }) => {
|
|
|
87
51
|
intensity: .5
|
|
88
52
|
})
|
|
89
53
|
] }) : null,
|
|
90
|
-
n && /* @__PURE__ */
|
|
91
|
-
|
|
92
|
-
i ? /* @__PURE__ */
|
|
54
|
+
n && /* @__PURE__ */ h(l, { preset: "city" }),
|
|
55
|
+
t,
|
|
56
|
+
i ? /* @__PURE__ */ h(u, {
|
|
93
57
|
enablePan: !1,
|
|
94
58
|
minPolarAngle: Math.PI / 4,
|
|
95
59
|
maxPolarAngle: Math.PI / 1.5,
|
|
@@ -98,7 +62,7 @@ var j = ({ children: e }) => {
|
|
|
98
62
|
}) : null
|
|
99
63
|
]
|
|
100
64
|
})
|
|
101
|
-
})
|
|
65
|
+
}), T = {
|
|
102
66
|
refShoulderWidthCm: 44,
|
|
103
67
|
refHeightCm: 170,
|
|
104
68
|
refArmLengthCm: 58,
|
|
@@ -114,37 +78,37 @@ var j = ({ children: e }) => {
|
|
|
114
78
|
armEaseCm: 2,
|
|
115
79
|
fitEaseScale: 1.03
|
|
116
80
|
};
|
|
117
|
-
function
|
|
81
|
+
function E(e, t, n) {
|
|
118
82
|
return !e || t <= 0 ? 1 : (e + n) / t;
|
|
119
83
|
}
|
|
120
|
-
function
|
|
84
|
+
function D(e, t, n) {
|
|
121
85
|
return Math.max(t, Math.min(n, e));
|
|
122
86
|
}
|
|
123
|
-
function
|
|
124
|
-
let n =
|
|
87
|
+
function O(e, t = T) {
|
|
88
|
+
let n = E(e.shoulderWidthCm, t.refShoulderWidthCm, t.shoulderEaseCm), r = E(e.chestCircumferenceCm, t.refChestCircumferenceCm, t.chestEaseCm), i = E(e.waistCircumferenceCm, t.refWaistCircumferenceCm, t.waistEaseCm), a = E(e.hipWidthCm, t.refHipWidthCm, t.hipEaseCm), o = E(e.torsoLengthCm, t.refTorsoLengthCm, t.torsoEaseCm), s = t.refHeightCm > 0 ? e.heightCm / t.refHeightCm : 1, c = E(e.armLengthCm, t.refArmLengthCm, t.armEaseCm), l = Math.max(n, r, a), u = Math.max(r, i, a * .98), d = Math.max(s, o, l * .94);
|
|
125
89
|
return {
|
|
126
|
-
scaleX:
|
|
127
|
-
scaleY:
|
|
128
|
-
scaleZ:
|
|
129
|
-
sleeveScale:
|
|
130
|
-
fitEaseScale:
|
|
90
|
+
scaleX: D(l, .82, 1.85),
|
|
91
|
+
scaleY: D(d, .85, 1.55),
|
|
92
|
+
scaleZ: D(u, .84, 1.9),
|
|
93
|
+
sleeveScale: D(c, .8, 1.55),
|
|
94
|
+
fitEaseScale: D(t.fitEaseScale, 1, 1.2)
|
|
131
95
|
};
|
|
132
96
|
}
|
|
133
97
|
//#endregion
|
|
134
98
|
//#region src/fitting/bodyFirstFitting.ts
|
|
135
|
-
var
|
|
99
|
+
var k = .82, A = 2.1, j = .85, M = 1.8, N = .84, P = 2.1, F = .8, I = 1.7, L = 1, R = 1.25, ee = {
|
|
136
100
|
scaleX: 1,
|
|
137
101
|
scaleY: 1,
|
|
138
102
|
scaleZ: 1,
|
|
139
103
|
sleeveScale: 1,
|
|
140
104
|
fitEaseScale: 1.02
|
|
141
|
-
},
|
|
105
|
+
}, te = {
|
|
142
106
|
scaleX: 1,
|
|
143
107
|
scaleY: 1,
|
|
144
108
|
scaleZ: 1,
|
|
145
109
|
sleeveScale: 1,
|
|
146
110
|
fitEaseScale: 1
|
|
147
|
-
},
|
|
111
|
+
}, ne = {
|
|
148
112
|
slim: {
|
|
149
113
|
x: .95,
|
|
150
114
|
y: .95,
|
|
@@ -163,7 +127,7 @@ var ne = .82, re = 2.1, ie = .85, ae = 1.8, F = .84, oe = 2.1, I = .8, L = 1.7,
|
|
|
163
127
|
z: 1.02,
|
|
164
128
|
ease: 1.03
|
|
165
129
|
}
|
|
166
|
-
},
|
|
130
|
+
}, re = {
|
|
167
131
|
narrow: {
|
|
168
132
|
width: .97,
|
|
169
133
|
shoulder: .97
|
|
@@ -176,7 +140,7 @@ var ne = .82, re = 2.1, ie = .85, ae = 1.8, F = .84, oe = 2.1, I = .8, L = 1.7,
|
|
|
176
140
|
width: 1.03,
|
|
177
141
|
shoulder: 1.04
|
|
178
142
|
}
|
|
179
|
-
},
|
|
143
|
+
}, z = {
|
|
180
144
|
tapered: {
|
|
181
145
|
depth: .98,
|
|
182
146
|
vertical: .995,
|
|
@@ -193,114 +157,114 @@ var ne = .82, re = 2.1, ie = .85, ae = 1.8, F = .84, oe = 2.1, I = .8, L = 1.7,
|
|
|
193
157
|
hip: 1.03
|
|
194
158
|
}
|
|
195
159
|
};
|
|
196
|
-
function
|
|
160
|
+
function B(e, t, n) {
|
|
197
161
|
return Math.max(t, Math.min(n, e));
|
|
198
162
|
}
|
|
199
|
-
function
|
|
200
|
-
return !e || !t || t <= 0 ? 1 :
|
|
163
|
+
function V(e, t, n, r) {
|
|
164
|
+
return !e || !t || t <= 0 ? 1 : B(e / t, n, r);
|
|
201
165
|
}
|
|
202
|
-
function
|
|
203
|
-
return !e || t <= 0 ? 1 :
|
|
166
|
+
function H(e, t, n, r, i) {
|
|
167
|
+
return !e || t <= 0 ? 1 : B((e + n) / t, r, i);
|
|
204
168
|
}
|
|
205
|
-
function
|
|
206
|
-
return
|
|
169
|
+
function ie(e) {
|
|
170
|
+
return re[e?.taxonomy.upperBodySilhouette ?? "balanced"] ?? re.balanced;
|
|
207
171
|
}
|
|
208
|
-
function
|
|
209
|
-
return
|
|
172
|
+
function ae(e) {
|
|
173
|
+
return z[e?.taxonomy.torsoOrPelvisProfile ?? "balanced"] ?? z.balanced;
|
|
210
174
|
}
|
|
211
|
-
function
|
|
175
|
+
function oe(e) {
|
|
212
176
|
if (!e) return !1;
|
|
213
177
|
let { metrics: t } = e;
|
|
214
178
|
return !!(t.heightCm || t.chestCm || t.waistCm || t.shoulderWidthCm || t.armLengthCm || t.torsoLengthCm || t.neckToHipCm);
|
|
215
179
|
}
|
|
216
|
-
function
|
|
217
|
-
let { metrics: n } = e, r =
|
|
180
|
+
function se(e, t) {
|
|
181
|
+
let { metrics: n } = e, r = ie(e), i = ae(e), a = Math.max(H(n.shoulderWidthCm, t.refShoulderWidthCm, t.shoulderEaseCm * .55, .88, 1.3), H(n.chestCm, t.refChestCircumferenceCm, t.chestEaseCm * .35, .9, 1.34), H(n.waistCm, t.refWaistCircumferenceCm, t.waistEaseCm * .3, .9, 1.3)) * r.width, o = Math.max(V(n.heightCm, t.refHeightCm, .9, 1.18), H(n.torsoLengthCm ?? n.neckToHipCm, t.refTorsoLengthCm, t.torsoEaseCm * .2, .9, 1.16)) * i.vertical, s = Math.max(H(n.chestCm, t.refChestCircumferenceCm, t.chestEaseCm * .15, .9, 1.34), H(n.waistCm, t.refWaistCircumferenceCm, t.waistEaseCm * .1, .9, 1.28)) * i.depth;
|
|
218
182
|
return {
|
|
219
|
-
scaleX:
|
|
220
|
-
scaleY:
|
|
221
|
-
scaleZ:
|
|
222
|
-
sleeveScale:
|
|
223
|
-
fitEaseScale:
|
|
183
|
+
scaleX: B(a, k, A),
|
|
184
|
+
scaleY: B(o, j, M),
|
|
185
|
+
scaleZ: B(s, N, P),
|
|
186
|
+
sleeveScale: B(V(n.armLengthCm, t.refArmLengthCm, .9, 1.16), F, I),
|
|
187
|
+
fitEaseScale: B(t.fitEaseScale * (r.width * .5 + i.depth * .5), L, R)
|
|
224
188
|
};
|
|
225
189
|
}
|
|
226
|
-
function
|
|
227
|
-
let { metrics: n } = t, r =
|
|
190
|
+
function ce(e, t) {
|
|
191
|
+
let { metrics: n } = t, r = ie(t), i = ae(t), a = V(e.shoulderWidthCm, n.shoulderWidthCm, .9, 1.14) * r.shoulder, o = V(e.chestCircumferenceCm, n.chestCm, .9, 1.15), s = V(e.waistCircumferenceCm, n.waistCm, .9, 1.15);
|
|
228
192
|
return {
|
|
229
|
-
torsoScale:
|
|
193
|
+
torsoScale: V(e.torsoLengthCm, n.torsoLengthCm ?? n.neckToHipCm, .9, 1.14),
|
|
230
194
|
chestScale: o,
|
|
231
195
|
waistScale: s,
|
|
232
|
-
hipScale:
|
|
233
|
-
shoulderAdjust:
|
|
196
|
+
hipScale: B(s * .6 + i.hip * .4, .92, 1.14),
|
|
197
|
+
shoulderAdjust: B(a - 1, -.12, .12),
|
|
234
198
|
postureAdjust: "neutral"
|
|
235
199
|
};
|
|
236
200
|
}
|
|
237
|
-
function
|
|
238
|
-
let r =
|
|
201
|
+
function le(e, t, n) {
|
|
202
|
+
let r = ae(t), i = B(1 + n.shoulderAdjust, .92, 1.14) * .3 + n.chestScale * .45 + n.waistScale * .25, a = n.chestScale * .45 + n.waistScale * .25 + n.hipScale * .3, o = V(e.armLengthCm, t.metrics.armLengthCm, .9, 1.16), s = Math.max(n.chestScale, n.waistScale, n.hipScale);
|
|
239
203
|
return {
|
|
240
|
-
scaleX:
|
|
241
|
-
scaleY:
|
|
242
|
-
scaleZ:
|
|
243
|
-
sleeveScale:
|
|
244
|
-
fitEaseScale:
|
|
204
|
+
scaleX: B(i, .92, 1.16),
|
|
205
|
+
scaleY: B(n.torsoScale * r.vertical, .92, 1.14),
|
|
206
|
+
scaleZ: B(a * r.depth, .92, 1.18),
|
|
207
|
+
sleeveScale: B(o, F, I),
|
|
208
|
+
fitEaseScale: B(1 + (s - 1) * .22, .99, 1.08)
|
|
245
209
|
};
|
|
246
210
|
}
|
|
247
|
-
function
|
|
211
|
+
function ue(e, t) {
|
|
248
212
|
if (!t || !Number.isFinite(t) || t <= 0) return e;
|
|
249
|
-
let n =
|
|
213
|
+
let n = B(t, .88, 1.2), r = 1 + (n - 1) * .35;
|
|
250
214
|
return {
|
|
251
|
-
scaleX:
|
|
252
|
-
scaleY:
|
|
253
|
-
scaleZ:
|
|
254
|
-
sleeveScale:
|
|
255
|
-
fitEaseScale:
|
|
215
|
+
scaleX: B(e.scaleX * n, k, A),
|
|
216
|
+
scaleY: B(e.scaleY * r, j, M),
|
|
217
|
+
scaleZ: B(e.scaleZ * n, N, P),
|
|
218
|
+
sleeveScale: B(e.sleeveScale * r, F, I),
|
|
219
|
+
fitEaseScale: B(e.fitEaseScale * n, L, R)
|
|
256
220
|
};
|
|
257
221
|
}
|
|
258
|
-
function
|
|
259
|
-
let n =
|
|
222
|
+
function de(e, t) {
|
|
223
|
+
let n = ne[t];
|
|
260
224
|
return {
|
|
261
|
-
scaleX:
|
|
262
|
-
scaleY:
|
|
263
|
-
scaleZ:
|
|
225
|
+
scaleX: B(e.scaleX * n.x, k, A),
|
|
226
|
+
scaleY: B(e.scaleY * n.y, j, M),
|
|
227
|
+
scaleZ: B(e.scaleZ * n.z, N, P),
|
|
264
228
|
sleeveScale: e.sleeveScale,
|
|
265
|
-
fitEaseScale:
|
|
229
|
+
fitEaseScale: B(e.fitEaseScale * n.ease, L, R)
|
|
266
230
|
};
|
|
267
231
|
}
|
|
268
|
-
function
|
|
232
|
+
function fe(e, t) {
|
|
269
233
|
return {
|
|
270
|
-
scaleX:
|
|
271
|
-
scaleY:
|
|
272
|
-
scaleZ:
|
|
273
|
-
sleeveScale:
|
|
274
|
-
fitEaseScale:
|
|
234
|
+
scaleX: B(e.scaleX * t.scaleX, k, A),
|
|
235
|
+
scaleY: B(e.scaleY * t.scaleY, j, M),
|
|
236
|
+
scaleZ: B(e.scaleZ * t.scaleZ, N, P),
|
|
237
|
+
sleeveScale: B(e.sleeveScale * t.sleeveScale, F, I),
|
|
238
|
+
fitEaseScale: B(e.fitEaseScale * t.fitEaseScale, L, R)
|
|
275
239
|
};
|
|
276
240
|
}
|
|
277
|
-
function
|
|
278
|
-
let o =
|
|
241
|
+
function pe({ measurements: e, measurementScale: t, presetSelection: n, fitType: r = "regular", garmentScaleHint: i = null, spec: a = T }) {
|
|
242
|
+
let o = oe(n), s = o && n ? se(n, a) : t ?? ee, c = o && n && e ? ce(e, n) : null;
|
|
279
243
|
return {
|
|
280
|
-
scale:
|
|
244
|
+
scale: de(ue(fe(s, e && n && c ? le(e, n, c) : te), i), r),
|
|
281
245
|
morph: c
|
|
282
246
|
};
|
|
283
247
|
}
|
|
284
248
|
//#endregion
|
|
285
249
|
//#region src/api/EverClient.ts
|
|
286
|
-
var
|
|
287
|
-
function
|
|
250
|
+
var me = "http://localhost:8000/api/v1";
|
|
251
|
+
function he(e) {
|
|
288
252
|
return e.replace(/\/+$/, "");
|
|
289
253
|
}
|
|
290
|
-
function
|
|
254
|
+
function ge(e) {
|
|
291
255
|
try {
|
|
292
256
|
return new URL(e).origin;
|
|
293
257
|
} catch {
|
|
294
258
|
return "";
|
|
295
259
|
}
|
|
296
260
|
}
|
|
297
|
-
var
|
|
261
|
+
var _e = class {
|
|
298
262
|
baseUrl;
|
|
299
263
|
apiOrigin;
|
|
300
264
|
apiKey;
|
|
301
265
|
constructor(e) {
|
|
302
|
-
let t = typeof e == "string" ? { baseUrl: e } : e ?? {}, n =
|
|
303
|
-
this.baseUrl = n, this.apiOrigin =
|
|
266
|
+
let t = typeof e == "string" ? { baseUrl: e } : e ?? {}, n = he(t.baseUrl ?? "http://localhost:8000/api/v1");
|
|
267
|
+
this.baseUrl = n, this.apiOrigin = ge(n), this.apiKey = t.apiKey;
|
|
304
268
|
}
|
|
305
269
|
resolveAssetUrl(e) {
|
|
306
270
|
return e ? e.startsWith("http://") || e.startsWith("https://") ? e : e.startsWith("/") ? this.apiOrigin ? `${this.apiOrigin}${e}` : e : this.apiOrigin ? `${this.apiOrigin}/${e}` : `/${e}` : null;
|
|
@@ -427,32 +391,32 @@ var Oe = class {
|
|
|
427
391
|
return `Request failed with status ${e.status}`;
|
|
428
392
|
}
|
|
429
393
|
}
|
|
430
|
-
},
|
|
431
|
-
function
|
|
394
|
+
}, ve = "M", ye = "male-m-balanced-balanced", be = "female-m-balanced-balanced", xe = "rigged_avatar";
|
|
395
|
+
function Se(e, t) {
|
|
432
396
|
if (!t) return "";
|
|
433
397
|
if (/^https?:\/\//.test(t)) return t;
|
|
434
398
|
let n = t.startsWith("/") ? t : `/${t}`;
|
|
435
399
|
return n.startsWith("/assets/") || n.startsWith("/static/") ? n : e.resolveAssetUrl(n) ?? n;
|
|
436
400
|
}
|
|
437
|
-
function
|
|
401
|
+
function Ce(e) {
|
|
438
402
|
return e === "female" ? "female" : "male";
|
|
439
403
|
}
|
|
440
|
-
function
|
|
404
|
+
function we(e, t = {}) {
|
|
441
405
|
let n = t.renderMode ?? "rigged_avatar", r = t.legacyPresetId ?? "rigged_avatar", i = `/assets/body-presets/${r}.glb`;
|
|
442
406
|
return e === r || n !== "preset-native" ? i : `/assets/body-presets/archive/${e}.glb`;
|
|
443
407
|
}
|
|
444
|
-
function
|
|
445
|
-
return e === "female" ?
|
|
408
|
+
function Te(e) {
|
|
409
|
+
return e === "female" ? be : ye;
|
|
446
410
|
}
|
|
447
|
-
function
|
|
411
|
+
function Ee(e, t) {
|
|
448
412
|
return {
|
|
449
413
|
id: e.id,
|
|
450
414
|
presetId: e.preset_id,
|
|
451
|
-
baseGender:
|
|
415
|
+
baseGender: Ce(e.base_gender),
|
|
452
416
|
sizeBand: e.size_band,
|
|
453
417
|
upperBodySilhouette: e.upper_body_silhouette,
|
|
454
418
|
torsoOrPelvisProfile: e.torso_or_pelvis_profile,
|
|
455
|
-
modelUrl:
|
|
419
|
+
modelUrl: Se(t, e.model_url),
|
|
456
420
|
heightCm: e.height_cm ?? null,
|
|
457
421
|
chestCm: e.chest_cm ?? null,
|
|
458
422
|
waistCm: e.waist_cm ?? null,
|
|
@@ -464,26 +428,26 @@ function Le(e, t) {
|
|
|
464
428
|
neckToHipCm: e.neck_to_hip_cm ?? null
|
|
465
429
|
};
|
|
466
430
|
}
|
|
467
|
-
function
|
|
431
|
+
function De(e, t = {}) {
|
|
468
432
|
return {
|
|
469
433
|
...e,
|
|
470
|
-
modelUrl: e.modelUrl ||
|
|
434
|
+
modelUrl: e.modelUrl || we(e.presetId, t)
|
|
471
435
|
};
|
|
472
436
|
}
|
|
473
|
-
function
|
|
474
|
-
return e.length === 0 ? null :
|
|
437
|
+
function Oe(e, t = {}) {
|
|
438
|
+
return e.length === 0 ? null : De(e.find((e) => e.sizeBand === ve) || e[Math.floor(e.length / 2)], t);
|
|
475
439
|
}
|
|
476
|
-
function
|
|
477
|
-
let n =
|
|
440
|
+
function ke(e, t = {}) {
|
|
441
|
+
let n = Te(e);
|
|
478
442
|
return {
|
|
479
443
|
id: null,
|
|
480
444
|
presetId: n,
|
|
481
|
-
label: `${e === "female" ? "여성" : "남성"} 기본 ${
|
|
482
|
-
modelUrl:
|
|
445
|
+
label: `${e === "female" ? "여성" : "남성"} 기본 ${ve}`,
|
|
446
|
+
modelUrl: we(n, t),
|
|
483
447
|
gender: e,
|
|
484
448
|
source: "fallback",
|
|
485
449
|
taxonomy: {
|
|
486
|
-
sizeBand:
|
|
450
|
+
sizeBand: ve,
|
|
487
451
|
upperBodySilhouette: "balanced",
|
|
488
452
|
torsoOrPelvisProfile: "balanced"
|
|
489
453
|
},
|
|
@@ -500,8 +464,8 @@ function Be(e, t = {}) {
|
|
|
500
464
|
}
|
|
501
465
|
};
|
|
502
466
|
}
|
|
503
|
-
function
|
|
504
|
-
let r =
|
|
467
|
+
function Ae(e, t, n = {}) {
|
|
468
|
+
let r = De(e, n);
|
|
505
469
|
return {
|
|
506
470
|
id: r.id,
|
|
507
471
|
presetId: r.presetId,
|
|
@@ -527,83 +491,82 @@ function Ve(e, t, n = {}) {
|
|
|
527
491
|
}
|
|
528
492
|
};
|
|
529
493
|
}
|
|
530
|
-
function
|
|
494
|
+
function je(e, t) {
|
|
531
495
|
let n = { gender: t };
|
|
532
496
|
return Number.isFinite(e.heightCm) && (n.height_cm = e.heightCm), e.chestCircumferenceCm !== null && (n.chest_cm = e.chestCircumferenceCm), e.waistCircumferenceCm !== null && (n.waist_cm = e.waistCircumferenceCm), e.shoulderWidthCm !== null && (n.shoulder_width_cm = e.shoulderWidthCm), n;
|
|
533
497
|
}
|
|
534
498
|
//#endregion
|
|
535
499
|
//#region src/hooks/useBodyPresetSelection.ts
|
|
536
|
-
var
|
|
537
|
-
function
|
|
500
|
+
var Me = new _e();
|
|
501
|
+
function Ne(e, t) {
|
|
538
502
|
return {
|
|
539
|
-
selection:
|
|
503
|
+
selection: ke(e, t),
|
|
540
504
|
loading: !0,
|
|
541
505
|
error: null
|
|
542
506
|
};
|
|
543
507
|
}
|
|
544
|
-
function
|
|
545
|
-
let
|
|
546
|
-
gender:
|
|
547
|
-
renderMode:
|
|
548
|
-
legacyPresetId:
|
|
549
|
-
}, [
|
|
550
|
-
|
|
508
|
+
function Pe(e, t = {}) {
|
|
509
|
+
let i = Ce(t.gender), o = t.renderMode, s = t.legacyPresetId, c = r(() => ({
|
|
510
|
+
gender: i,
|
|
511
|
+
renderMode: o,
|
|
512
|
+
legacyPresetId: s
|
|
513
|
+
}), [
|
|
514
|
+
i,
|
|
515
|
+
s,
|
|
516
|
+
o
|
|
517
|
+
]), [l, u] = a(() => Ne(i, c));
|
|
518
|
+
return n(() => {
|
|
551
519
|
let t = new AbortController();
|
|
552
|
-
async function
|
|
553
|
-
|
|
520
|
+
async function n() {
|
|
521
|
+
u((e) => ({
|
|
554
522
|
...e,
|
|
555
523
|
loading: !0,
|
|
556
524
|
error: null
|
|
557
525
|
}));
|
|
558
526
|
try {
|
|
559
527
|
if (e) {
|
|
560
|
-
let
|
|
528
|
+
let n = Ae(Ee(await Me.matchBodyPreset(je(e, c.gender)), Me), "match", c);
|
|
561
529
|
if (t.signal.aborted) return;
|
|
562
|
-
|
|
563
|
-
selection:
|
|
530
|
+
u({
|
|
531
|
+
selection: n,
|
|
564
532
|
loading: !1,
|
|
565
533
|
error: null
|
|
566
534
|
});
|
|
567
535
|
return;
|
|
568
536
|
}
|
|
569
|
-
let
|
|
537
|
+
let n = (await Me.listBodyPresets(c.gender)).map((e) => Ee(e, Me));
|
|
570
538
|
if (t.signal.aborted) return;
|
|
571
|
-
let
|
|
572
|
-
if (
|
|
573
|
-
|
|
574
|
-
selection:
|
|
539
|
+
let r = Oe(n, c);
|
|
540
|
+
if (r) {
|
|
541
|
+
u({
|
|
542
|
+
selection: Ae(r, "default", c),
|
|
575
543
|
loading: !1,
|
|
576
544
|
error: null
|
|
577
545
|
});
|
|
578
546
|
return;
|
|
579
547
|
}
|
|
580
|
-
|
|
581
|
-
selection:
|
|
548
|
+
u({
|
|
549
|
+
selection: ke(c.gender, c),
|
|
582
550
|
loading: !1,
|
|
583
551
|
error: "바디 프리셋 응답이 비어 있어 기본 프리셋으로 대체했습니다."
|
|
584
552
|
});
|
|
585
553
|
} catch (e) {
|
|
586
554
|
if (t.signal.aborted) return;
|
|
587
|
-
|
|
588
|
-
selection:
|
|
555
|
+
u({
|
|
556
|
+
selection: ke(c.gender, c),
|
|
589
557
|
loading: !1,
|
|
590
558
|
error: e instanceof Error ? e.message : "바디 프리셋을 불러오지 못해 기본 프리셋으로 대체했습니다."
|
|
591
559
|
});
|
|
592
560
|
}
|
|
593
561
|
}
|
|
594
|
-
return
|
|
562
|
+
return n(), () => {
|
|
595
563
|
t.abort();
|
|
596
564
|
};
|
|
597
|
-
}, [
|
|
598
|
-
n,
|
|
599
|
-
i,
|
|
600
|
-
e,
|
|
601
|
-
r
|
|
602
|
-
]), s;
|
|
565
|
+
}, [e, c]), l;
|
|
603
566
|
}
|
|
604
567
|
//#endregion
|
|
605
568
|
//#region src/types/pose.ts
|
|
606
|
-
var
|
|
569
|
+
var U = {
|
|
607
570
|
NOSE: 0,
|
|
608
571
|
LEFT_EYE_INNER: 1,
|
|
609
572
|
LEFT_EYE: 2,
|
|
@@ -637,25 +600,25 @@ var B = {
|
|
|
637
600
|
RIGHT_HEEL: 30,
|
|
638
601
|
LEFT_FOOT_INDEX: 31,
|
|
639
602
|
RIGHT_FOOT_INDEX: 32
|
|
640
|
-
},
|
|
603
|
+
}, Fe = {
|
|
641
604
|
positionAlpha: .7,
|
|
642
605
|
rotationAlpha: .6,
|
|
643
606
|
visibilityThreshold: .5
|
|
644
|
-
},
|
|
645
|
-
function
|
|
646
|
-
return e ? (e.visibility ?? 1) >=
|
|
607
|
+
}, Ie = .5;
|
|
608
|
+
function Le(e) {
|
|
609
|
+
return e ? (e.visibility ?? 1) >= Ie : !1;
|
|
647
610
|
}
|
|
648
|
-
function
|
|
649
|
-
let n = e[
|
|
650
|
-
if (!
|
|
611
|
+
function Re(e, t) {
|
|
612
|
+
let n = e[U.NOSE], r = e[U.LEFT_EYE], i = e[U.LEFT_ANKLE], a = e[U.RIGHT_ANKLE];
|
|
613
|
+
if (!Le(n) || !Le(r) || !Le(i) || !Le(a)) return 0;
|
|
651
614
|
let o = n.y - (r.y - n.y) * 2, s = (Math.max(i.y, a.y) - o) * t;
|
|
652
615
|
return Number.isFinite(s) && s > 0 ? s : 0;
|
|
653
616
|
}
|
|
654
|
-
function
|
|
655
|
-
let r =
|
|
617
|
+
function ze(e, t, n = 720) {
|
|
618
|
+
let r = Re(e, n);
|
|
656
619
|
return r <= 0 || t <= 0 ? 0 : t / r;
|
|
657
620
|
}
|
|
658
|
-
function
|
|
621
|
+
function Be(e) {
|
|
659
622
|
let t = [
|
|
660
623
|
[15, .8],
|
|
661
624
|
[18.5, .84],
|
|
@@ -672,39 +635,39 @@ function Ze(e) {
|
|
|
672
635
|
}
|
|
673
636
|
return .88;
|
|
674
637
|
}
|
|
675
|
-
function
|
|
676
|
-
if (!
|
|
638
|
+
function W(e, t, n, r) {
|
|
639
|
+
if (!Le(e) || !Le(t)) return null;
|
|
677
640
|
let i = (e.x - t.x) * n, a = (e.y - t.y) * r, o = Math.hypot(i, a);
|
|
678
641
|
return Number.isFinite(o) && o > 0 ? o : null;
|
|
679
642
|
}
|
|
680
|
-
function
|
|
643
|
+
function Ve(e) {
|
|
681
644
|
return Math.round(e * 10) / 10;
|
|
682
645
|
}
|
|
683
|
-
function
|
|
684
|
-
return e === null || !Number.isFinite(e) || e <= 0 ? null :
|
|
646
|
+
function G(e) {
|
|
647
|
+
return e === null || !Number.isFinite(e) || e <= 0 ? null : Ve(e);
|
|
685
648
|
}
|
|
686
|
-
function
|
|
649
|
+
function He(e) {
|
|
687
650
|
let t = e.filter((e) => e !== null);
|
|
688
651
|
return t.length === 0 ? null : t.reduce((e, t) => e + t, 0) / t.length;
|
|
689
652
|
}
|
|
690
|
-
function
|
|
653
|
+
function Ue(e, t) {
|
|
691
654
|
return e && t !== null && t > 0 ? "silhouette_bmi" : "keypoint";
|
|
692
655
|
}
|
|
693
|
-
function
|
|
656
|
+
function We(e, t, n) {
|
|
694
657
|
return n && t > 0 && e / t >= .85 ? "standard" : "estimate";
|
|
695
658
|
}
|
|
696
|
-
function
|
|
659
|
+
function Ge(e, t, n, r) {
|
|
697
660
|
if (t <= 0 || e <= 0) return 0;
|
|
698
661
|
let i = e / t * .8, a = n ? .15 : 0, o = r !== null && r > 0 ? .05 : 0;
|
|
699
|
-
return Math.min(.99,
|
|
662
|
+
return Math.min(.99, Ve((i + a + o) * 10) / 10);
|
|
700
663
|
}
|
|
701
|
-
function
|
|
664
|
+
function Ke(e, t) {
|
|
702
665
|
if (e <= 0 || t <= 0) return 0;
|
|
703
666
|
let n = (e - t) ** 2 / (e + t) ** 2;
|
|
704
667
|
return Math.PI * (e + t) * (1 + 3 * n / (10 + Math.sqrt(4 - 3 * n)));
|
|
705
668
|
}
|
|
706
|
-
function
|
|
707
|
-
let o =
|
|
669
|
+
function qe(e, t, n = null, r = null, i = 1280, a = 720) {
|
|
670
|
+
let o = ze(e, t, a), s = Ue(r, n);
|
|
708
671
|
if (o <= 0) return {
|
|
709
672
|
heightCm: t,
|
|
710
673
|
shoulderWidthCm: null,
|
|
@@ -719,14 +682,14 @@ function it(e, t, n = null, r = null, i = 1280, a = 720) {
|
|
|
719
682
|
measurementMethod: s,
|
|
720
683
|
measuredAt: null
|
|
721
684
|
};
|
|
722
|
-
let c =
|
|
685
|
+
let c = W(e[U.LEFT_SHOULDER], e[U.RIGHT_SHOULDER], i, a), l = W(e[U.LEFT_HIP], e[U.RIGHT_HIP], i, a), u = W(e[U.LEFT_SHOULDER], e[U.LEFT_ELBOW], i, a), d = W(e[U.LEFT_ELBOW], e[U.LEFT_WRIST], i, a), f = W(e[U.RIGHT_SHOULDER], e[U.RIGHT_ELBOW], i, a), p = W(e[U.RIGHT_ELBOW], e[U.RIGHT_WRIST], i, a), m = u !== null && d !== null ? u + d : null, h = f !== null && p !== null ? f + p : null, g = W(e[U.LEFT_HIP], e[U.LEFT_KNEE], i, a), _ = W(e[U.LEFT_KNEE], e[U.LEFT_ANKLE], i, a), v = W(e[U.RIGHT_HIP], e[U.RIGHT_KNEE], i, a), y = W(e[U.RIGHT_KNEE], e[U.RIGHT_ANKLE], i, a), b = g !== null && _ !== null ? g + _ : null, x = v !== null && y !== null ? v + y : null, S = He([W(e[U.LEFT_SHOULDER], e[U.LEFT_HIP], i, a), W(e[U.RIGHT_SHOULDER], e[U.RIGHT_HIP], i, a)]), C = G(c === null ? null : c * o), w = G(l === null ? null : l * o), T = G(He([m === null ? null : m * o, h === null ? null : h * o])), E = G(He([b === null ? null : b * o, x === null ? null : x * o])), D = G(S === null ? null : S * o), O = C === null ? null : C * 2.2, k = w === null ? null : w * 2.1;
|
|
723
686
|
if (r) {
|
|
724
687
|
let e = r.shoulderWidthPx * o;
|
|
725
|
-
if (O =
|
|
726
|
-
let e =
|
|
727
|
-
O =
|
|
688
|
+
if (O = G(Ke(Math.max(r.chestWidthPx * o / 2, 0), Math.max(e * .28 / 2, 0))), k = G(Ke(Math.max(r.waistWidthPx * o / 2, 0), Math.max(r.hipWidthPx * o * .26 / 2, 0))), n !== null && n > 0) {
|
|
689
|
+
let e = Be(n / (t / 100) ** 2);
|
|
690
|
+
O = G(O === null ? null : O / e), k = G(k === null ? null : k / e);
|
|
728
691
|
}
|
|
729
|
-
} else O =
|
|
692
|
+
} else O = G(O), k = G(k);
|
|
730
693
|
let A = [
|
|
731
694
|
C,
|
|
732
695
|
O,
|
|
@@ -737,7 +700,7 @@ function it(e, t, n = null, r = null, i = 1280, a = 720) {
|
|
|
737
700
|
D
|
|
738
701
|
].filter((e) => e !== null).length;
|
|
739
702
|
return {
|
|
740
|
-
heightCm:
|
|
703
|
+
heightCm: Ve(t),
|
|
741
704
|
shoulderWidthCm: C,
|
|
742
705
|
chestCircumferenceCm: O,
|
|
743
706
|
waistCircumferenceCm: k,
|
|
@@ -745,15 +708,15 @@ function it(e, t, n = null, r = null, i = 1280, a = 720) {
|
|
|
745
708
|
armLengthCm: T,
|
|
746
709
|
legLengthCm: E,
|
|
747
710
|
torsoLengthCm: D,
|
|
748
|
-
accuracyGrade:
|
|
749
|
-
confidenceScore:
|
|
711
|
+
accuracyGrade: We(A, 7, r),
|
|
712
|
+
confidenceScore: Ge(A, 7, r, n),
|
|
750
713
|
measurementMethod: s,
|
|
751
714
|
measuredAt: null
|
|
752
715
|
};
|
|
753
716
|
}
|
|
754
717
|
//#endregion
|
|
755
718
|
//#region src/measurement/sizeRecommender.ts
|
|
756
|
-
var
|
|
719
|
+
var Je = {
|
|
757
720
|
S: {
|
|
758
721
|
shoulder: [40, 42],
|
|
759
722
|
chest: [86, 92],
|
|
@@ -780,7 +743,7 @@ var at = {
|
|
|
780
743
|
waist: [96, 104]
|
|
781
744
|
}
|
|
782
745
|
};
|
|
783
|
-
function
|
|
746
|
+
function Ye(e) {
|
|
784
747
|
let t = [
|
|
785
748
|
"S",
|
|
786
749
|
"M",
|
|
@@ -789,7 +752,7 @@ function ot(e) {
|
|
|
789
752
|
"2XL"
|
|
790
753
|
], n = "M", r = -Infinity, i = !1;
|
|
791
754
|
for (let a of t) {
|
|
792
|
-
let t =
|
|
755
|
+
let t = Je[a], o = 0, s = 0;
|
|
793
756
|
if (e.shoulderWidthCm !== null) {
|
|
794
757
|
let n = (t.shoulder[0] + t.shoulder[1]) / 2;
|
|
795
758
|
o -= Math.abs(e.shoulderWidthCm - n), s += 1, i = !0;
|
|
@@ -805,7 +768,7 @@ function ot(e) {
|
|
|
805
768
|
s > 0 && (o /= s), o > r && (r = o, n = a);
|
|
806
769
|
}
|
|
807
770
|
if (!i) return null;
|
|
808
|
-
let a =
|
|
771
|
+
let a = Je[n], o = "true-to-size";
|
|
809
772
|
if (e.chestCircumferenceCm !== null) {
|
|
810
773
|
let t = (a.chest[0] + a.chest[1]) / 2;
|
|
811
774
|
e.chestCircumferenceCm > t + 3 ? o = "slim" : e.chestCircumferenceCm < t - 3 && (o = "relaxed");
|
|
@@ -818,7 +781,7 @@ function ot(e) {
|
|
|
818
781
|
}
|
|
819
782
|
//#endregion
|
|
820
783
|
//#region src/types/measurement.ts
|
|
821
|
-
var
|
|
784
|
+
var Xe = {
|
|
822
785
|
referenceHeightCm: 170,
|
|
823
786
|
weightKg: null,
|
|
824
787
|
stableFrameCount: 15,
|
|
@@ -826,10 +789,10 @@ var st = {
|
|
|
826
789
|
};
|
|
827
790
|
//#endregion
|
|
828
791
|
//#region src/hooks/useMeasurement.ts
|
|
829
|
-
function
|
|
792
|
+
function Ze(e) {
|
|
830
793
|
return e.map((e) => ({ ...e }));
|
|
831
794
|
}
|
|
832
|
-
function
|
|
795
|
+
function Qe(e, t) {
|
|
833
796
|
let n = 0;
|
|
834
797
|
for (let r = 0; r < 33; r += 1) {
|
|
835
798
|
let i = e[r], a = t[r];
|
|
@@ -837,40 +800,40 @@ function lt(e, t) {
|
|
|
837
800
|
}
|
|
838
801
|
return n / 33;
|
|
839
802
|
}
|
|
840
|
-
function
|
|
841
|
-
let [e,
|
|
803
|
+
function $e() {
|
|
804
|
+
let [e, n] = a(Xe), [r, o] = a(null), [s, c] = a(null), [l, u] = a(null), [d, f] = a(!1), p = i(0), m = i(null), h = t(() => {
|
|
842
805
|
p.current = 0, m.current = null;
|
|
843
|
-
}, []), g =
|
|
844
|
-
|
|
845
|
-
}, []), _ =
|
|
806
|
+
}, []), g = t(() => {
|
|
807
|
+
o(null), c(null), u(null);
|
|
808
|
+
}, []), _ = t(() => {
|
|
846
809
|
h(), g(), f(!0);
|
|
847
810
|
}, [g, h]);
|
|
848
811
|
return {
|
|
849
|
-
measure:
|
|
812
|
+
measure: t((t, n = {}) => {
|
|
850
813
|
if (!d || t.length < 33) return;
|
|
851
|
-
let r =
|
|
814
|
+
let r = Ze(t);
|
|
852
815
|
if (!m.current) {
|
|
853
816
|
m.current = r, p.current = 1;
|
|
854
817
|
return;
|
|
855
818
|
}
|
|
856
|
-
if (p.current =
|
|
857
|
-
let
|
|
858
|
-
|
|
859
|
-
...
|
|
860
|
-
measuredAt:
|
|
861
|
-
}),
|
|
819
|
+
if (p.current = Qe(m.current, r) < e.motionThreshold ? p.current + 1 : 1, m.current = r, p.current < e.stableFrameCount) return;
|
|
820
|
+
let i = qe(t, e.referenceHeightCm, e.weightKg, n.silhouetteWidths ?? null, n.imageWidth ?? 1280, n.imageHeight ?? 720), a = (/* @__PURE__ */ new Date()).toISOString(), s = Ye(i), l = O(i);
|
|
821
|
+
o({
|
|
822
|
+
...i,
|
|
823
|
+
measuredAt: a
|
|
824
|
+
}), c(s), u(l), f(!1), h();
|
|
862
825
|
}, [
|
|
863
826
|
e,
|
|
864
827
|
d,
|
|
865
828
|
h
|
|
866
829
|
]),
|
|
867
830
|
startMeasurement: _,
|
|
868
|
-
measurements:
|
|
869
|
-
sizeRecommendation:
|
|
831
|
+
measurements: r,
|
|
832
|
+
sizeRecommendation: s,
|
|
870
833
|
garmentScale: l,
|
|
871
834
|
isMeasuring: d,
|
|
872
|
-
updateConfig:
|
|
873
|
-
|
|
835
|
+
updateConfig: t((e) => {
|
|
836
|
+
n((t) => ({
|
|
874
837
|
...t,
|
|
875
838
|
...e
|
|
876
839
|
})), h(), g(), f(!1);
|
|
@@ -880,7 +843,7 @@ function ut() {
|
|
|
880
843
|
}
|
|
881
844
|
//#endregion
|
|
882
845
|
//#region src/compositing/videoCover.ts
|
|
883
|
-
function
|
|
846
|
+
function et(e, t, n, r) {
|
|
884
847
|
if (e <= 0 || t <= 0 || n <= 0 || r <= 0) return {
|
|
885
848
|
x: 0,
|
|
886
849
|
y: 0,
|
|
@@ -905,7 +868,7 @@ function dt(e, t, n, r) {
|
|
|
905
868
|
height: o
|
|
906
869
|
};
|
|
907
870
|
}
|
|
908
|
-
function
|
|
871
|
+
function tt(e, t, n, r) {
|
|
909
872
|
if (e <= 0 || t <= 0 || n <= 0 || r <= 0) return {
|
|
910
873
|
xMin: 0,
|
|
911
874
|
xMax: 1,
|
|
@@ -932,8 +895,8 @@ function ft(e, t, n, r) {
|
|
|
932
895
|
}
|
|
933
896
|
//#endregion
|
|
934
897
|
//#region src/measurement/silhouetteExtractor.ts
|
|
935
|
-
var
|
|
936
|
-
function
|
|
898
|
+
var nt = 5, rt = .5;
|
|
899
|
+
function it(e, t, n, r, i = nt, a = rt) {
|
|
937
900
|
if (t <= 0 || n <= 0 || e.length !== t * n) return null;
|
|
938
901
|
let o = Math.round(r), s = Math.floor(i / 2), c = Math.max(0, o - s), l = Math.min(n - 1, o + s), u = 0, d = 0, f = 0;
|
|
939
902
|
for (let n = c; n <= l; n += 1) {
|
|
@@ -945,11 +908,11 @@ function ht(e, t, n, r, i = pt, a = mt) {
|
|
|
945
908
|
let p = u / f;
|
|
946
909
|
return d / f - p;
|
|
947
910
|
}
|
|
948
|
-
function
|
|
911
|
+
function at(e, t, n, r) {
|
|
949
912
|
if (r.length < 33) return null;
|
|
950
|
-
let i = r[
|
|
913
|
+
let i = r[U.LEFT_SHOULDER], a = r[U.RIGHT_SHOULDER], o = r[U.LEFT_HIP], s = r[U.RIGHT_HIP], c = r[U.LEFT_KNEE], l = r[U.RIGHT_KNEE];
|
|
951
914
|
if (!i || !a || !o || !s) return null;
|
|
952
|
-
let u = (i.y + a.y) / 2 * n, d = (o.y + s.y) / 2 * n, f = u + (d - u) * .4, p = c && l ? d + ((c.y + l.y) / 2 * n - d) * .2 : d, m =
|
|
915
|
+
let u = (i.y + a.y) / 2 * n, d = (o.y + s.y) / 2 * n, f = u + (d - u) * .4, p = c && l ? d + ((c.y + l.y) / 2 * n - d) * .2 : d, m = it(e, t, n, u), h = it(e, t, n, f), g = it(e, t, n, d), _ = it(e, t, n, p);
|
|
953
916
|
return m === null || h === null || g === null || _ === null ? null : {
|
|
954
917
|
shoulderWidthPx: m,
|
|
955
918
|
chestWidthPx: h,
|
|
@@ -959,61 +922,61 @@ function gt(e, t, n, r) {
|
|
|
959
922
|
}
|
|
960
923
|
//#endregion
|
|
961
924
|
//#region src/pose/interpolation.ts
|
|
962
|
-
function
|
|
925
|
+
function K(e, t, n) {
|
|
963
926
|
return e + (t - e) * n;
|
|
964
927
|
}
|
|
965
|
-
function
|
|
928
|
+
function ot(e, t, n) {
|
|
966
929
|
return t ? !e || e.length !== t.length ? t : e.map((e, r) => {
|
|
967
930
|
let i = t[r];
|
|
968
931
|
return {
|
|
969
|
-
x:
|
|
970
|
-
y:
|
|
971
|
-
z:
|
|
972
|
-
visibility:
|
|
932
|
+
x: K(e.x, i.x, n),
|
|
933
|
+
y: K(e.y, i.y, n),
|
|
934
|
+
z: K(e.z ?? 0, i.z ?? 0, n),
|
|
935
|
+
visibility: K(e.visibility ?? 0, i.visibility ?? 0, n)
|
|
973
936
|
};
|
|
974
937
|
}) : null;
|
|
975
938
|
}
|
|
976
|
-
function
|
|
939
|
+
function q(e, t, n) {
|
|
977
940
|
return {
|
|
978
|
-
x:
|
|
979
|
-
y:
|
|
980
|
-
z:
|
|
941
|
+
x: K(e.x, t.x, n),
|
|
942
|
+
y: K(e.y, t.y, n),
|
|
943
|
+
z: K(e.z, t.z, n)
|
|
981
944
|
};
|
|
982
945
|
}
|
|
983
|
-
function
|
|
984
|
-
return !e || !t ? t ?? e :
|
|
946
|
+
function st(e, t, n) {
|
|
947
|
+
return !e || !t ? t ?? e : q(e, t, n);
|
|
985
948
|
}
|
|
986
|
-
function
|
|
949
|
+
function ct(e, t, n) {
|
|
987
950
|
return t ? e ? {
|
|
988
951
|
hips: {
|
|
989
952
|
position: {
|
|
990
|
-
x:
|
|
991
|
-
y:
|
|
992
|
-
z:
|
|
953
|
+
x: K(e.hips.position.x, t.hips.position.x, n),
|
|
954
|
+
y: K(e.hips.position.y, t.hips.position.y, n),
|
|
955
|
+
z: K(e.hips.position.z, t.hips.position.z, n)
|
|
993
956
|
},
|
|
994
|
-
rotation:
|
|
957
|
+
rotation: q(e.hips.rotation, t.hips.rotation, n)
|
|
995
958
|
},
|
|
996
|
-
spine:
|
|
997
|
-
chest:
|
|
998
|
-
leftUpperArm:
|
|
999
|
-
leftLowerArm:
|
|
1000
|
-
rightUpperArm:
|
|
1001
|
-
rightLowerArm:
|
|
1002
|
-
leftUpperLeg:
|
|
1003
|
-
leftLowerLeg:
|
|
1004
|
-
rightUpperLeg:
|
|
1005
|
-
rightLowerLeg:
|
|
959
|
+
spine: q(e.spine, t.spine, n),
|
|
960
|
+
chest: q(e.chest, t.chest, n),
|
|
961
|
+
leftUpperArm: q(e.leftUpperArm, t.leftUpperArm, n),
|
|
962
|
+
leftLowerArm: q(e.leftLowerArm, t.leftLowerArm, n),
|
|
963
|
+
rightUpperArm: q(e.rightUpperArm, t.rightUpperArm, n),
|
|
964
|
+
rightLowerArm: q(e.rightLowerArm, t.rightLowerArm, n),
|
|
965
|
+
leftUpperLeg: st(e.leftUpperLeg, t.leftUpperLeg, n),
|
|
966
|
+
leftLowerLeg: st(e.leftLowerLeg, t.leftLowerLeg, n),
|
|
967
|
+
rightUpperLeg: st(e.rightUpperLeg, t.rightUpperLeg, n),
|
|
968
|
+
rightLowerLeg: st(e.rightLowerLeg, t.rightLowerLeg, n)
|
|
1006
969
|
} : t : null;
|
|
1007
970
|
}
|
|
1008
|
-
function
|
|
971
|
+
function lt(e, t, n) {
|
|
1009
972
|
return t ? e ? {
|
|
1010
|
-
shoulderWidthPx:
|
|
1011
|
-
chestWidthPx:
|
|
1012
|
-
waistWidthPx:
|
|
1013
|
-
hipWidthPx:
|
|
973
|
+
shoulderWidthPx: K(e.shoulderWidthPx, t.shoulderWidthPx, n),
|
|
974
|
+
chestWidthPx: K(e.chestWidthPx, t.chestWidthPx, n),
|
|
975
|
+
waistWidthPx: K(e.waistWidthPx, t.waistWidthPx, n),
|
|
976
|
+
hipWidthPx: K(e.hipWidthPx, t.hipWidthPx, n)
|
|
1014
977
|
} : t : null;
|
|
1015
978
|
}
|
|
1016
|
-
function
|
|
979
|
+
function ut() {
|
|
1017
980
|
return {
|
|
1018
981
|
landmarks: null,
|
|
1019
982
|
worldLandmarks: null,
|
|
@@ -1023,25 +986,25 @@ function xt() {
|
|
|
1023
986
|
silhouetteWidths: null
|
|
1024
987
|
};
|
|
1025
988
|
}
|
|
1026
|
-
function
|
|
989
|
+
function dt(e, t, n) {
|
|
1027
990
|
return !e || !e.isTracking || !t.isTracking || !t.landmarks ? t : {
|
|
1028
|
-
landmarks:
|
|
1029
|
-
worldLandmarks:
|
|
1030
|
-
poseRig:
|
|
1031
|
-
confidence:
|
|
991
|
+
landmarks: ot(e.landmarks, t.landmarks, n),
|
|
992
|
+
worldLandmarks: ot(e.worldLandmarks, t.worldLandmarks, n),
|
|
993
|
+
poseRig: ct(e.poseRig, t.poseRig, n),
|
|
994
|
+
confidence: K(e.confidence, t.confidence, n),
|
|
1032
995
|
isTracking: t.isTracking,
|
|
1033
|
-
silhouetteWidths:
|
|
996
|
+
silhouetteWidths: lt(e.silhouetteWidths, t.silhouetteWidths, n)
|
|
1034
997
|
};
|
|
1035
998
|
}
|
|
1036
999
|
//#endregion
|
|
1037
1000
|
//#region src/pose/landmarkerFactory.ts
|
|
1038
|
-
var
|
|
1001
|
+
var ft = "0.10.32", pt = `https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${ft}/wasm`, mt = 2, ht = 3, gt = .5, _t = {
|
|
1039
1002
|
lite: "https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/latest/pose_landmarker_lite.task",
|
|
1040
1003
|
full: "https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_full/float16/latest/pose_landmarker_full.task",
|
|
1041
1004
|
heavy: "https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_heavy/float16/latest/pose_landmarker_heavy.task"
|
|
1042
1005
|
};
|
|
1043
|
-
async function
|
|
1044
|
-
let a = await
|
|
1006
|
+
async function vt(e, t, n, r, i = 3) {
|
|
1007
|
+
let a = await v.forVisionTasks(pt), o = {
|
|
1045
1008
|
baseOptions: { modelAssetPath: e },
|
|
1046
1009
|
runningMode: "VIDEO",
|
|
1047
1010
|
numPoses: i,
|
|
@@ -1051,7 +1014,7 @@ async function kt(e, t, n, r, i = 3) {
|
|
|
1051
1014
|
minTrackingConfidence: n
|
|
1052
1015
|
};
|
|
1053
1016
|
try {
|
|
1054
|
-
return await
|
|
1017
|
+
return await y.createFromOptions(a, {
|
|
1055
1018
|
...o,
|
|
1056
1019
|
baseOptions: {
|
|
1057
1020
|
...o.baseOptions,
|
|
@@ -1059,7 +1022,7 @@ async function kt(e, t, n, r, i = 3) {
|
|
|
1059
1022
|
}
|
|
1060
1023
|
});
|
|
1061
1024
|
} catch {
|
|
1062
|
-
return
|
|
1025
|
+
return y.createFromOptions(a, {
|
|
1063
1026
|
...o,
|
|
1064
1027
|
baseOptions: {
|
|
1065
1028
|
...o.baseOptions,
|
|
@@ -1070,193 +1033,193 @@ async function kt(e, t, n, r, i = 3) {
|
|
|
1070
1033
|
}
|
|
1071
1034
|
//#endregion
|
|
1072
1035
|
//#region src/pose/landmarkPoseSolver.ts
|
|
1073
|
-
var
|
|
1036
|
+
var yt = new b.Vector3(), bt = new b.Vector3(), xt = new b.Vector3(), St = new b.Quaternion(), Ct = new b.Vector3(), wt = new b.Vector3(), Tt = new b.Vector3(0, -1, 0), Et = new b.Vector3(1, 0, 0), Dt = new b.Vector3(-1, 0, 0), Ot = new b.Vector3(0, 1, 0), kt = [U.LEFT_SHOULDER, U.RIGHT_SHOULDER], At = [U.LEFT_HIP, U.RIGHT_HIP], jt = [U.LEFT_EAR, U.RIGHT_EAR], Mt = [U.LEFT_INDEX, U.LEFT_PINKY], Nt = [U.RIGHT_INDEX, U.RIGHT_PINKY], Pt = {
|
|
1074
1037
|
Hips: {
|
|
1075
|
-
from:
|
|
1076
|
-
to:
|
|
1077
|
-
restDir:
|
|
1038
|
+
from: At,
|
|
1039
|
+
to: kt,
|
|
1040
|
+
restDir: Ot,
|
|
1078
1041
|
influence: .35
|
|
1079
1042
|
},
|
|
1080
1043
|
Spine: {
|
|
1081
|
-
from:
|
|
1082
|
-
to:
|
|
1083
|
-
restDir:
|
|
1044
|
+
from: At,
|
|
1045
|
+
to: kt,
|
|
1046
|
+
restDir: Ot,
|
|
1084
1047
|
influence: .55
|
|
1085
1048
|
},
|
|
1086
1049
|
Chest: {
|
|
1087
|
-
from:
|
|
1088
|
-
to:
|
|
1089
|
-
restDir:
|
|
1050
|
+
from: kt,
|
|
1051
|
+
to: jt,
|
|
1052
|
+
restDir: Ot,
|
|
1090
1053
|
influence: .7
|
|
1091
1054
|
},
|
|
1092
1055
|
LeftShoulder: {
|
|
1093
|
-
from:
|
|
1094
|
-
to:
|
|
1095
|
-
restDir:
|
|
1056
|
+
from: kt,
|
|
1057
|
+
to: U.LEFT_SHOULDER,
|
|
1058
|
+
restDir: Et,
|
|
1096
1059
|
influence: .45
|
|
1097
1060
|
},
|
|
1098
1061
|
LeftUpperArm: {
|
|
1099
|
-
from:
|
|
1100
|
-
to:
|
|
1101
|
-
restDir:
|
|
1062
|
+
from: U.LEFT_SHOULDER,
|
|
1063
|
+
to: U.LEFT_ELBOW,
|
|
1064
|
+
restDir: Et
|
|
1102
1065
|
},
|
|
1103
1066
|
LeftLowerArm: {
|
|
1104
|
-
from:
|
|
1105
|
-
to:
|
|
1106
|
-
restDir:
|
|
1067
|
+
from: U.LEFT_ELBOW,
|
|
1068
|
+
to: U.LEFT_WRIST,
|
|
1069
|
+
restDir: Et
|
|
1107
1070
|
},
|
|
1108
1071
|
LeftHand: {
|
|
1109
|
-
from:
|
|
1110
|
-
to:
|
|
1111
|
-
restDir:
|
|
1072
|
+
from: U.LEFT_WRIST,
|
|
1073
|
+
to: Mt,
|
|
1074
|
+
restDir: Et,
|
|
1112
1075
|
influence: .65
|
|
1113
1076
|
},
|
|
1114
1077
|
RightShoulder: {
|
|
1115
|
-
from:
|
|
1116
|
-
to:
|
|
1117
|
-
restDir:
|
|
1078
|
+
from: kt,
|
|
1079
|
+
to: U.RIGHT_SHOULDER,
|
|
1080
|
+
restDir: Dt,
|
|
1118
1081
|
influence: .45
|
|
1119
1082
|
},
|
|
1120
1083
|
RightUpperArm: {
|
|
1121
|
-
from:
|
|
1122
|
-
to:
|
|
1123
|
-
restDir:
|
|
1084
|
+
from: U.RIGHT_SHOULDER,
|
|
1085
|
+
to: U.RIGHT_ELBOW,
|
|
1086
|
+
restDir: Dt
|
|
1124
1087
|
},
|
|
1125
1088
|
RightLowerArm: {
|
|
1126
|
-
from:
|
|
1127
|
-
to:
|
|
1128
|
-
restDir:
|
|
1089
|
+
from: U.RIGHT_ELBOW,
|
|
1090
|
+
to: U.RIGHT_WRIST,
|
|
1091
|
+
restDir: Dt
|
|
1129
1092
|
},
|
|
1130
1093
|
RightHand: {
|
|
1131
|
-
from:
|
|
1132
|
-
to:
|
|
1133
|
-
restDir:
|
|
1094
|
+
from: U.RIGHT_WRIST,
|
|
1095
|
+
to: Nt,
|
|
1096
|
+
restDir: Dt,
|
|
1134
1097
|
influence: .65
|
|
1135
1098
|
},
|
|
1136
1099
|
LeftUpperLeg: {
|
|
1137
|
-
from:
|
|
1138
|
-
to:
|
|
1139
|
-
restDir:
|
|
1100
|
+
from: U.LEFT_HIP,
|
|
1101
|
+
to: U.LEFT_KNEE,
|
|
1102
|
+
restDir: Tt
|
|
1140
1103
|
},
|
|
1141
1104
|
LeftLowerLeg: {
|
|
1142
|
-
from:
|
|
1143
|
-
to:
|
|
1144
|
-
restDir:
|
|
1105
|
+
from: U.LEFT_KNEE,
|
|
1106
|
+
to: U.LEFT_ANKLE,
|
|
1107
|
+
restDir: Tt
|
|
1145
1108
|
},
|
|
1146
1109
|
LeftFoot: {
|
|
1147
|
-
from:
|
|
1148
|
-
to:
|
|
1149
|
-
restDir: new
|
|
1110
|
+
from: U.LEFT_ANKLE,
|
|
1111
|
+
to: U.LEFT_FOOT_INDEX,
|
|
1112
|
+
restDir: new b.Vector3(0, 0, 1)
|
|
1150
1113
|
},
|
|
1151
1114
|
RightUpperLeg: {
|
|
1152
|
-
from:
|
|
1153
|
-
to:
|
|
1154
|
-
restDir:
|
|
1115
|
+
from: U.RIGHT_HIP,
|
|
1116
|
+
to: U.RIGHT_KNEE,
|
|
1117
|
+
restDir: Tt
|
|
1155
1118
|
},
|
|
1156
1119
|
RightLowerLeg: {
|
|
1157
|
-
from:
|
|
1158
|
-
to:
|
|
1159
|
-
restDir:
|
|
1120
|
+
from: U.RIGHT_KNEE,
|
|
1121
|
+
to: U.RIGHT_ANKLE,
|
|
1122
|
+
restDir: Tt
|
|
1160
1123
|
},
|
|
1161
1124
|
RightFoot: {
|
|
1162
|
-
from:
|
|
1163
|
-
to:
|
|
1164
|
-
restDir: new
|
|
1125
|
+
from: U.RIGHT_ANKLE,
|
|
1126
|
+
to: U.RIGHT_FOOT_INDEX,
|
|
1127
|
+
restDir: new b.Vector3(0, 0, 1)
|
|
1165
1128
|
}
|
|
1166
1129
|
};
|
|
1167
|
-
function
|
|
1130
|
+
function Ft(e, t, n) {
|
|
1168
1131
|
return n === "world" ? (t.set(-e.x, -e.y, -(e.z ?? 0)), t) : (t.set(-(e.x - .5), -(e.y - .5), -(e.z ?? 0) * .5), t);
|
|
1169
1132
|
}
|
|
1170
|
-
function
|
|
1133
|
+
function It(e, t, n, r) {
|
|
1171
1134
|
if (typeof e == "number") {
|
|
1172
1135
|
let i = t[e];
|
|
1173
|
-
return !i || (i.visibility ?? 0) < .4 ? !1 : (
|
|
1136
|
+
return !i || (i.visibility ?? 0) < .4 ? !1 : (Ft(i, n, r), !0);
|
|
1174
1137
|
}
|
|
1175
1138
|
let i = t[e[0]], a = t[e[1]];
|
|
1176
|
-
return !i || !a || (i.visibility ?? 0) < .4 || (a.visibility ?? 0) < .4 ? !1 : (
|
|
1139
|
+
return !i || !a || (i.visibility ?? 0) < .4 || (a.visibility ?? 0) < .4 ? !1 : (Ft(i, Ct, r), Ft(a, wt, r), n.copy(Ct).add(wt).multiplyScalar(.5), !0);
|
|
1177
1140
|
}
|
|
1178
|
-
function
|
|
1179
|
-
if (!
|
|
1180
|
-
r.subVectors(
|
|
1141
|
+
function Lt(e, t, n, r, i = "normalized") {
|
|
1142
|
+
if (!It(e, n, yt, i) || !It(t, n, bt, i)) return !1;
|
|
1143
|
+
r.subVectors(bt, yt);
|
|
1181
1144
|
let a = r.length();
|
|
1182
1145
|
return a < .001 ? !1 : (r.divideScalar(a), !0);
|
|
1183
1146
|
}
|
|
1184
|
-
function
|
|
1185
|
-
let i =
|
|
1186
|
-
return i ?
|
|
1147
|
+
function Rt(e, t, n, r = "normalized") {
|
|
1148
|
+
let i = Pt[e];
|
|
1149
|
+
return i ? Lt(i.from, i.to, t, n, r) : !1;
|
|
1187
1150
|
}
|
|
1188
|
-
function
|
|
1189
|
-
return
|
|
1151
|
+
function zt(e) {
|
|
1152
|
+
return Pt[e]?.influence;
|
|
1190
1153
|
}
|
|
1191
|
-
function
|
|
1192
|
-
let i =
|
|
1193
|
-
return !i || !
|
|
1154
|
+
function Bt(e, t, n, r = "normalized") {
|
|
1155
|
+
let i = Pt[e];
|
|
1156
|
+
return !i || !Rt(e, t, xt, r) ? !1 : (n.setFromUnitVectors(i.restDir, xt), i.influence !== void 0 && n.slerp(St.identity(), 1 - i.influence), !0);
|
|
1194
1157
|
}
|
|
1195
|
-
function
|
|
1196
|
-
return e in
|
|
1158
|
+
function Vt(e) {
|
|
1159
|
+
return e in Pt;
|
|
1197
1160
|
}
|
|
1198
1161
|
//#endregion
|
|
1199
1162
|
//#region src/pose/poseSolver.ts
|
|
1200
|
-
var
|
|
1201
|
-
function
|
|
1163
|
+
var Ht = new b.Quaternion(), Ut = new b.Euler();
|
|
1164
|
+
function Wt() {
|
|
1202
1165
|
return {
|
|
1203
1166
|
x: 0,
|
|
1204
1167
|
y: 0,
|
|
1205
1168
|
z: 0
|
|
1206
1169
|
};
|
|
1207
1170
|
}
|
|
1208
|
-
function
|
|
1209
|
-
return
|
|
1210
|
-
x:
|
|
1211
|
-
y:
|
|
1212
|
-
z:
|
|
1171
|
+
function Gt(e) {
|
|
1172
|
+
return Ut.setFromQuaternion(e, "XYZ"), {
|
|
1173
|
+
x: Ut.x,
|
|
1174
|
+
y: Ut.y,
|
|
1175
|
+
z: Ut.z
|
|
1213
1176
|
};
|
|
1214
1177
|
}
|
|
1215
|
-
function
|
|
1216
|
-
return
|
|
1178
|
+
function Kt(e, t, n) {
|
|
1179
|
+
return Bt(e, t, Ht, n) ? Gt(Ht) : Wt();
|
|
1217
1180
|
}
|
|
1218
|
-
function
|
|
1219
|
-
if (
|
|
1181
|
+
function qt(e, t, n) {
|
|
1182
|
+
if (Bt(e, t, Ht, n)) return Gt(Ht);
|
|
1220
1183
|
}
|
|
1221
|
-
function
|
|
1222
|
-
let t = e[
|
|
1184
|
+
function Jt(e) {
|
|
1185
|
+
let t = e[U.LEFT_HIP], n = e[U.RIGHT_HIP];
|
|
1223
1186
|
return {
|
|
1224
1187
|
x: ((t?.x ?? 0) + (n?.x ?? 0)) * .5,
|
|
1225
1188
|
y: ((t?.y ?? 0) + (n?.y ?? 0)) * .5,
|
|
1226
1189
|
z: ((t?.z ?? 0) + (n?.z ?? 0)) * .5
|
|
1227
1190
|
};
|
|
1228
1191
|
}
|
|
1229
|
-
function
|
|
1192
|
+
function Yt(e, t) {
|
|
1230
1193
|
if (e.length < 33) return null;
|
|
1231
1194
|
let n = t && t.length >= 33 ? t : e, r = t && t.length >= 33 ? "world" : "normalized";
|
|
1232
1195
|
return {
|
|
1233
1196
|
hips: {
|
|
1234
|
-
position:
|
|
1235
|
-
rotation:
|
|
1197
|
+
position: Jt(e),
|
|
1198
|
+
rotation: Kt("Hips", n, r)
|
|
1236
1199
|
},
|
|
1237
|
-
spine:
|
|
1238
|
-
chest:
|
|
1239
|
-
leftUpperArm:
|
|
1240
|
-
leftLowerArm:
|
|
1241
|
-
rightUpperArm:
|
|
1242
|
-
rightLowerArm:
|
|
1243
|
-
leftUpperLeg:
|
|
1244
|
-
leftLowerLeg:
|
|
1245
|
-
rightUpperLeg:
|
|
1246
|
-
rightLowerLeg:
|
|
1200
|
+
spine: Kt("Spine", n, r),
|
|
1201
|
+
chest: Kt("Chest", n, r),
|
|
1202
|
+
leftUpperArm: Kt("LeftUpperArm", n, r),
|
|
1203
|
+
leftLowerArm: Kt("LeftLowerArm", n, r),
|
|
1204
|
+
rightUpperArm: Kt("RightUpperArm", n, r),
|
|
1205
|
+
rightLowerArm: Kt("RightLowerArm", n, r),
|
|
1206
|
+
leftUpperLeg: qt("LeftUpperLeg", n, r),
|
|
1207
|
+
leftLowerLeg: qt("LeftLowerLeg", n, r),
|
|
1208
|
+
rightUpperLeg: qt("RightUpperLeg", n, r),
|
|
1209
|
+
rightLowerLeg: qt("RightLowerLeg", n, r)
|
|
1247
1210
|
};
|
|
1248
1211
|
}
|
|
1249
1212
|
//#endregion
|
|
1250
1213
|
//#region src/pose/segmentation.ts
|
|
1251
|
-
function
|
|
1214
|
+
function Xt(e) {
|
|
1252
1215
|
if (!e || typeof e != "object") return null;
|
|
1253
1216
|
let t = e;
|
|
1254
1217
|
return typeof t.width != "number" || typeof t.height != "number" || typeof t.getAsFloat32Array != "function" ? null : t;
|
|
1255
1218
|
}
|
|
1256
|
-
function
|
|
1219
|
+
function Zt(e) {
|
|
1257
1220
|
if (e) for (let t of e) t && typeof t == "object" && "close" in t && typeof t.close == "function" && t.close();
|
|
1258
1221
|
}
|
|
1259
|
-
function
|
|
1222
|
+
function Qt(e, t, n) {
|
|
1260
1223
|
let r = t / n;
|
|
1261
1224
|
return {
|
|
1262
1225
|
shoulderWidthPx: e.shoulderWidthPx * r,
|
|
@@ -1267,47 +1230,47 @@ function ln(e, t, n) {
|
|
|
1267
1230
|
}
|
|
1268
1231
|
//#endregion
|
|
1269
1232
|
//#region src/types/tracking.ts
|
|
1270
|
-
var
|
|
1233
|
+
var $t = "pose-0";
|
|
1271
1234
|
//#endregion
|
|
1272
1235
|
//#region src/pose/smoothing.ts
|
|
1273
|
-
function
|
|
1236
|
+
function en(e) {
|
|
1274
1237
|
return typeof e == "number" ? e : 0;
|
|
1275
1238
|
}
|
|
1276
|
-
function
|
|
1239
|
+
function tn(e) {
|
|
1277
1240
|
return {
|
|
1278
1241
|
x: e.x,
|
|
1279
1242
|
y: e.y,
|
|
1280
1243
|
z: e.z,
|
|
1281
|
-
visibility:
|
|
1244
|
+
visibility: en(e.visibility)
|
|
1282
1245
|
};
|
|
1283
1246
|
}
|
|
1284
|
-
function
|
|
1285
|
-
return e.map(
|
|
1247
|
+
function nn(e) {
|
|
1248
|
+
return e.map(tn);
|
|
1286
1249
|
}
|
|
1287
|
-
function
|
|
1288
|
-
return
|
|
1250
|
+
function rn(e) {
|
|
1251
|
+
return tn(e);
|
|
1289
1252
|
}
|
|
1290
|
-
function
|
|
1253
|
+
function an(e) {
|
|
1291
1254
|
let t = Math.PI * 2, n = (e + Math.PI) % t;
|
|
1292
1255
|
return n < 0 && (n += t), n - Math.PI;
|
|
1293
1256
|
}
|
|
1294
|
-
function
|
|
1295
|
-
return
|
|
1257
|
+
function on(e, t, n) {
|
|
1258
|
+
return an(e + an(t - e) * n);
|
|
1296
1259
|
}
|
|
1297
|
-
var
|
|
1260
|
+
var sn = class {
|
|
1298
1261
|
prev = null;
|
|
1299
1262
|
config;
|
|
1300
|
-
constructor(e =
|
|
1263
|
+
constructor(e = Fe) {
|
|
1301
1264
|
this.config = e;
|
|
1302
1265
|
}
|
|
1303
1266
|
smooth(e) {
|
|
1304
1267
|
if (e.length === 0) return this.prev = null, [];
|
|
1305
|
-
let t =
|
|
1306
|
-
if (!this.prev || this.prev.length !== t.length) return this.prev = t.map(
|
|
1268
|
+
let t = nn(e);
|
|
1269
|
+
if (!this.prev || this.prev.length !== t.length) return this.prev = t.map(rn), t.map(rn);
|
|
1307
1270
|
let n = this.config.positionAlpha, r = t.map((e, t) => {
|
|
1308
1271
|
let r = this.prev[t];
|
|
1309
1272
|
return (e.visibility ?? 0) < this.config.visibilityThreshold ? {
|
|
1310
|
-
...
|
|
1273
|
+
...rn(r),
|
|
1311
1274
|
visibility: e.visibility
|
|
1312
1275
|
} : {
|
|
1313
1276
|
x: r.x + n * (e.x - r.x),
|
|
@@ -1316,23 +1279,23 @@ var _n = class {
|
|
|
1316
1279
|
visibility: e.visibility
|
|
1317
1280
|
};
|
|
1318
1281
|
});
|
|
1319
|
-
return this.prev = r.map(
|
|
1282
|
+
return this.prev = r.map(rn), r;
|
|
1320
1283
|
}
|
|
1321
1284
|
reset() {
|
|
1322
1285
|
this.prev = null;
|
|
1323
1286
|
}
|
|
1324
1287
|
};
|
|
1325
|
-
function
|
|
1288
|
+
function J(e, t, n) {
|
|
1326
1289
|
return {
|
|
1327
|
-
x:
|
|
1328
|
-
y:
|
|
1329
|
-
z:
|
|
1290
|
+
x: on(e.x, t.x, n),
|
|
1291
|
+
y: on(e.y, t.y, n),
|
|
1292
|
+
z: on(e.z, t.z, n)
|
|
1330
1293
|
};
|
|
1331
1294
|
}
|
|
1332
|
-
function
|
|
1333
|
-
return t ? e ?
|
|
1295
|
+
function cn(e, t, n) {
|
|
1296
|
+
return t ? e ? J(e, t, n) : t : e;
|
|
1334
1297
|
}
|
|
1335
|
-
function
|
|
1298
|
+
function ln(e, t, n = Fe.rotationAlpha) {
|
|
1336
1299
|
return e ? {
|
|
1337
1300
|
hips: {
|
|
1338
1301
|
position: {
|
|
@@ -1340,29 +1303,29 @@ function yn(e, t, n = Ke.rotationAlpha) {
|
|
|
1340
1303
|
y: e.hips.position.y + n * (t.hips.position.y - e.hips.position.y),
|
|
1341
1304
|
z: e.hips.position.z + n * (t.hips.position.z - e.hips.position.z)
|
|
1342
1305
|
},
|
|
1343
|
-
rotation:
|
|
1306
|
+
rotation: J(e.hips.rotation, t.hips.rotation, n)
|
|
1344
1307
|
},
|
|
1345
|
-
spine:
|
|
1346
|
-
chest:
|
|
1347
|
-
leftUpperArm:
|
|
1348
|
-
leftLowerArm:
|
|
1349
|
-
rightUpperArm:
|
|
1350
|
-
rightLowerArm:
|
|
1351
|
-
leftUpperLeg:
|
|
1352
|
-
leftLowerLeg:
|
|
1353
|
-
rightUpperLeg:
|
|
1354
|
-
rightLowerLeg:
|
|
1308
|
+
spine: J(e.spine, t.spine, n),
|
|
1309
|
+
chest: J(e.chest, t.chest, n),
|
|
1310
|
+
leftUpperArm: J(e.leftUpperArm, t.leftUpperArm, n),
|
|
1311
|
+
leftLowerArm: J(e.leftLowerArm, t.leftLowerArm, n),
|
|
1312
|
+
rightUpperArm: J(e.rightUpperArm, t.rightUpperArm, n),
|
|
1313
|
+
rightLowerArm: J(e.rightLowerArm, t.rightLowerArm, n),
|
|
1314
|
+
leftUpperLeg: cn(e.leftUpperLeg, t.leftUpperLeg, n),
|
|
1315
|
+
leftLowerLeg: cn(e.leftLowerLeg, t.leftLowerLeg, n),
|
|
1316
|
+
rightUpperLeg: cn(e.rightUpperLeg, t.rightUpperLeg, n),
|
|
1317
|
+
rightLowerLeg: cn(e.rightLowerLeg, t.rightLowerLeg, n)
|
|
1355
1318
|
} : t;
|
|
1356
1319
|
}
|
|
1357
1320
|
//#endregion
|
|
1358
1321
|
//#region src/tracking/personLock.ts
|
|
1359
|
-
var
|
|
1322
|
+
var un = .12, dn = .35, fn = .05, pn = [
|
|
1360
1323
|
11,
|
|
1361
1324
|
12,
|
|
1362
1325
|
23,
|
|
1363
1326
|
24
|
|
1364
|
-
],
|
|
1365
|
-
function
|
|
1327
|
+
], mn = 2, hn = .3;
|
|
1328
|
+
function gn(e) {
|
|
1366
1329
|
if (!e) return null;
|
|
1367
1330
|
let t = Math.max(0, Math.min(1, e.x)), n = Math.max(0, Math.min(1, e.y));
|
|
1368
1331
|
return {
|
|
@@ -1372,41 +1335,41 @@ function En(e) {
|
|
|
1372
1335
|
h: Math.max(.01, Math.min(1 - n, e.h))
|
|
1373
1336
|
};
|
|
1374
1337
|
}
|
|
1375
|
-
function
|
|
1338
|
+
function _n(e) {
|
|
1376
1339
|
if (!Array.isArray(e) || e.length === 0) return null;
|
|
1377
1340
|
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity, a = 0;
|
|
1378
1341
|
return e.forEach((e) => {
|
|
1379
|
-
!e || typeof e.x != "number" || typeof e.y != "number" || (e.visibility ?? 0) <
|
|
1380
|
-
}), a < 4 || !Number.isFinite(t) || !Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(i) ? null :
|
|
1342
|
+
!e || typeof e.x != "number" || typeof e.y != "number" || (e.visibility ?? 0) < dn || (t = Math.min(t, e.x), n = Math.min(n, e.y), r = Math.max(r, e.x), i = Math.max(i, e.y), a += 1);
|
|
1343
|
+
}), a < 4 || !Number.isFinite(t) || !Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(i) ? null : gn({
|
|
1381
1344
|
x: t,
|
|
1382
1345
|
y: n,
|
|
1383
1346
|
w: Math.max(.01, r - t),
|
|
1384
1347
|
h: Math.max(.01, i - n)
|
|
1385
1348
|
});
|
|
1386
1349
|
}
|
|
1387
|
-
function
|
|
1350
|
+
function vn(e, t = un) {
|
|
1388
1351
|
if (!e) return null;
|
|
1389
1352
|
let n = e.w * t, r = e.h * t;
|
|
1390
|
-
return
|
|
1353
|
+
return gn({
|
|
1391
1354
|
x: e.x - n / 2,
|
|
1392
1355
|
y: e.y - r / 2,
|
|
1393
1356
|
w: e.w + n,
|
|
1394
1357
|
h: e.h + r
|
|
1395
1358
|
});
|
|
1396
1359
|
}
|
|
1397
|
-
function
|
|
1360
|
+
function yn(e, t) {
|
|
1398
1361
|
if (!e || !t) return 0;
|
|
1399
1362
|
let n = Math.max(e.x, t.x), r = Math.max(e.y, t.y), i = Math.min(e.x + e.w, t.x + t.w), a = Math.min(e.y + e.h, t.y + t.h), o = Math.max(0, i - n) * Math.max(0, a - r);
|
|
1400
1363
|
if (o <= 0) return 0;
|
|
1401
1364
|
let s = e.w * e.h + t.w * t.h - o;
|
|
1402
1365
|
return s <= 0 ? 0 : o / s;
|
|
1403
1366
|
}
|
|
1404
|
-
function
|
|
1367
|
+
function bn(e) {
|
|
1405
1368
|
return e.length === 0 ? 0 : e.reduce((e, t) => e + (t.visibility ?? 0), 0) / e.length;
|
|
1406
1369
|
}
|
|
1407
|
-
function
|
|
1370
|
+
function xn(e, t = []) {
|
|
1408
1371
|
return e.flatMap((e, n) => {
|
|
1409
|
-
let r =
|
|
1372
|
+
let r = _n(e), i = vn(r);
|
|
1410
1373
|
return !r || !i ? [] : [{
|
|
1411
1374
|
poseIndex: n,
|
|
1412
1375
|
personId: `pose-${n}`,
|
|
@@ -1414,43 +1377,43 @@ function jn(e, t = []) {
|
|
|
1414
1377
|
worldLandmarks: t[n] ?? null,
|
|
1415
1378
|
bounds: r,
|
|
1416
1379
|
expandedBounds: i,
|
|
1417
|
-
meanVisibility:
|
|
1380
|
+
meanVisibility: bn(e),
|
|
1418
1381
|
area: i.w * i.h
|
|
1419
1382
|
}];
|
|
1420
1383
|
});
|
|
1421
1384
|
}
|
|
1422
|
-
function
|
|
1423
|
-
let n =
|
|
1385
|
+
function Sn(e, t) {
|
|
1386
|
+
let n = yn(e.expandedBounds, t.expandedBounds);
|
|
1424
1387
|
return {
|
|
1425
1388
|
iou: n,
|
|
1426
1389
|
score: n * .75 + e.area * .25
|
|
1427
1390
|
};
|
|
1428
1391
|
}
|
|
1429
|
-
function
|
|
1392
|
+
function Cn(e, { previousCandidate: t, allowRelock: n = !1, minIouToKeep: r = fn }) {
|
|
1430
1393
|
if (e.length === 0) return null;
|
|
1431
1394
|
let i = [...e].sort((e, t) => t.area * t.meanVisibility - e.area * e.meanVisibility);
|
|
1432
1395
|
if (!t) return i[0];
|
|
1433
1396
|
let a = null, o = -Infinity, s = 0;
|
|
1434
1397
|
return e.forEach((e) => {
|
|
1435
|
-
let { iou: n, score: r } =
|
|
1398
|
+
let { iou: n, score: r } = Sn(e, t);
|
|
1436
1399
|
r > o && (a = e, o = r, s = n);
|
|
1437
1400
|
}), a && s >= r ? a : n ? i[0] : null;
|
|
1438
1401
|
}
|
|
1439
|
-
function
|
|
1402
|
+
function wn(e, t) {
|
|
1440
1403
|
if (!t) return !0;
|
|
1441
1404
|
let n = 0, r = 0, i = 0;
|
|
1442
|
-
for (let t of
|
|
1405
|
+
for (let t of pn) {
|
|
1443
1406
|
let a = e.landmarks[t];
|
|
1444
|
-
a && (a.visibility ?? 0) >
|
|
1407
|
+
a && (a.visibility ?? 0) > hn && (n += a.x, r += a.y, i += 1);
|
|
1445
1408
|
}
|
|
1446
|
-
if (i <
|
|
1409
|
+
if (i < mn) return !0;
|
|
1447
1410
|
let a = n / i, o = r / i;
|
|
1448
1411
|
return a >= t.xMin && a <= t.xMax && o >= t.yMin && o <= t.yMax;
|
|
1449
1412
|
}
|
|
1450
|
-
function
|
|
1451
|
-
return t ? e.filter((e) =>
|
|
1413
|
+
function Tn(e, t) {
|
|
1414
|
+
return t ? e.filter((e) => wn(e, t)) : e;
|
|
1452
1415
|
}
|
|
1453
|
-
function
|
|
1416
|
+
function En(e) {
|
|
1454
1417
|
return e ? {
|
|
1455
1418
|
poseIndex: e.poseIndex,
|
|
1456
1419
|
personId: e.personId,
|
|
@@ -1460,18 +1423,18 @@ function In(e) {
|
|
|
1460
1423
|
}
|
|
1461
1424
|
//#endregion
|
|
1462
1425
|
//#region src/tracking/trackingState.ts
|
|
1463
|
-
var
|
|
1464
|
-
function
|
|
1426
|
+
var Dn = .55, On = 640, kn = 360;
|
|
1427
|
+
function An(e = null) {
|
|
1465
1428
|
return {
|
|
1466
1429
|
level: "idle",
|
|
1467
1430
|
reasons: ["no_person_detected"],
|
|
1468
1431
|
updatedAt: e
|
|
1469
1432
|
};
|
|
1470
1433
|
}
|
|
1471
|
-
function
|
|
1472
|
-
if (e < 1) return
|
|
1434
|
+
function jn({ detectedPersonCount: e, isTracking: t, lockedPersonId: n = null, meanVisibility: r = null, frameWidth: i = 0, frameHeight: a = 0, updatedAt: o = Date.now() }) {
|
|
1435
|
+
if (e < 1) return An(o);
|
|
1473
1436
|
let s = [];
|
|
1474
|
-
return e > 1 && s.push("multi_person_detected"), i > 0 && a > 0 && (i <
|
|
1437
|
+
return e > 1 && s.push("multi_person_detected"), i > 0 && a > 0 && (i < On || a < kn) && s.push("resolution_too_low"), r !== null && r < Dn && s.push("low_visibility"), (!n || !t) && s.push("pose_not_locked"), s.length === 0 ? {
|
|
1475
1438
|
level: "good",
|
|
1476
1439
|
reasons: [],
|
|
1477
1440
|
updatedAt: o
|
|
@@ -1481,19 +1444,19 @@ function Vn({ detectedPersonCount: e, isTracking: t, lockedPersonId: n = null, m
|
|
|
1481
1444
|
updatedAt: o
|
|
1482
1445
|
};
|
|
1483
1446
|
}
|
|
1484
|
-
function
|
|
1447
|
+
function Mn() {
|
|
1485
1448
|
return {
|
|
1486
1449
|
detectedPersonCount: 0,
|
|
1487
1450
|
lockedPersonId: null,
|
|
1488
|
-
trackingQuality:
|
|
1451
|
+
trackingQuality: An()
|
|
1489
1452
|
};
|
|
1490
1453
|
}
|
|
1491
|
-
function
|
|
1454
|
+
function Nn({ detectedPersonCount: e, isTracking: t, lockedPersonId: n, meanVisibility: r, frameWidth: i, frameHeight: a, updatedAt: o }) {
|
|
1492
1455
|
let s = n ?? (t && e > 0 ? "pose-0" : null);
|
|
1493
1456
|
return {
|
|
1494
1457
|
detectedPersonCount: e,
|
|
1495
1458
|
lockedPersonId: s,
|
|
1496
|
-
trackingQuality:
|
|
1459
|
+
trackingQuality: jn({
|
|
1497
1460
|
detectedPersonCount: e,
|
|
1498
1461
|
isTracking: t,
|
|
1499
1462
|
lockedPersonId: s,
|
|
@@ -1506,17 +1469,17 @@ function Un({ detectedPersonCount: e, isTracking: t, lockedPersonId: n, meanVisi
|
|
|
1506
1469
|
}
|
|
1507
1470
|
//#endregion
|
|
1508
1471
|
//#region src/tracking/trackingStability.ts
|
|
1509
|
-
var
|
|
1510
|
-
function
|
|
1472
|
+
var Pn = 180;
|
|
1473
|
+
function Fn(e, t, n = 180) {
|
|
1511
1474
|
return e === null ? !1 : t - e <= n;
|
|
1512
1475
|
}
|
|
1513
|
-
function
|
|
1476
|
+
function In(e) {
|
|
1514
1477
|
return !e || !e.isTracking || !e.landmarks || !e.poseRig ? null : {
|
|
1515
1478
|
...e,
|
|
1516
1479
|
isTracking: !0
|
|
1517
1480
|
};
|
|
1518
1481
|
}
|
|
1519
|
-
function
|
|
1482
|
+
function Ln(e, t, n = $t) {
|
|
1520
1483
|
return {
|
|
1521
1484
|
detectedPersonCount: e,
|
|
1522
1485
|
lockedPersonId: n,
|
|
@@ -1529,7 +1492,7 @@ function qn(e, t, n = un) {
|
|
|
1529
1492
|
}
|
|
1530
1493
|
//#endregion
|
|
1531
1494
|
//#region src/hooks/usePoseTracker.ts
|
|
1532
|
-
function
|
|
1495
|
+
function Rn() {
|
|
1533
1496
|
return {
|
|
1534
1497
|
landmarks: null,
|
|
1535
1498
|
worldLandmarks: null,
|
|
@@ -1539,49 +1502,49 @@ function Jn() {
|
|
|
1539
1502
|
isTracking: !1
|
|
1540
1503
|
};
|
|
1541
1504
|
}
|
|
1542
|
-
var
|
|
1543
|
-
let { enabled:
|
|
1505
|
+
var zn = (e, r = {}) => {
|
|
1506
|
+
let { enabled: o = !0, modelComplexity: s = "lite", numPoses: c = 3, minDetectionConfidence: l = .5, minTrackingConfidence: u = .5, outputSegmentationMasks: d = !1, viewportWidth: f = 0, viewportHeight: p = 0 } = r, m = i(null), h = i(new sn(Fe)), g = i(null), v = i(null), b = i(null), x = i(-1), S = i({
|
|
1544
1507
|
width: 0,
|
|
1545
1508
|
height: 0
|
|
1546
|
-
}),
|
|
1509
|
+
}), C = i(0), w = i(null), T = i(null), E = i(null), D = i(null), O = i(null), k = i(Mn()), A = i({
|
|
1547
1510
|
frames: 0,
|
|
1548
1511
|
lastMeasuredAt: 0
|
|
1549
|
-
}), j =
|
|
1512
|
+
}), j = i(null), M = i({
|
|
1550
1513
|
width: 0,
|
|
1551
1514
|
height: 0
|
|
1552
|
-
}), [N, P] =
|
|
1515
|
+
}), [N, P] = a(!1), [F, I] = a(Rn), [L, R] = a(null), [ee, te] = a({
|
|
1553
1516
|
width: 0,
|
|
1554
1517
|
height: 0
|
|
1555
|
-
}), [
|
|
1556
|
-
|
|
1518
|
+
}), [ne, re] = a(Mn()), z = t((e, t = k.current) => {
|
|
1519
|
+
v.current = e.landmarks, k.current = t, I((t) => ({
|
|
1557
1520
|
...t,
|
|
1558
1521
|
landmarks: e.landmarks,
|
|
1559
1522
|
worldLandmarks: e.worldLandmarks,
|
|
1560
1523
|
poseRig: e.poseRig,
|
|
1561
1524
|
confidence: e.confidence,
|
|
1562
1525
|
isTracking: e.isTracking
|
|
1563
|
-
})),
|
|
1564
|
-
}, []),
|
|
1565
|
-
h.current.reset(), g.current = null,
|
|
1526
|
+
})), R(e.silhouetteWidths), re(t);
|
|
1527
|
+
}, []), B = t(() => {
|
|
1528
|
+
h.current.reset(), g.current = null, v.current = null, x.current = -1, S.current = {
|
|
1566
1529
|
width: 0,
|
|
1567
1530
|
height: 0
|
|
1568
|
-
},
|
|
1531
|
+
}, C.current = 0, w.current = null, T.current = null, E.current = null, D.current = null, O.current = null, k.current = Mn(), A.current = {
|
|
1569
1532
|
frames: 0,
|
|
1570
1533
|
lastMeasuredAt: 0
|
|
1571
|
-
},
|
|
1534
|
+
}, I(Rn()), R(null), te({
|
|
1572
1535
|
width: 0,
|
|
1573
1536
|
height: 0
|
|
1574
|
-
}),
|
|
1537
|
+
}), re(Mn());
|
|
1575
1538
|
}, []);
|
|
1576
|
-
|
|
1577
|
-
if (!
|
|
1578
|
-
P(!1),
|
|
1539
|
+
n(() => {
|
|
1540
|
+
if (!o) {
|
|
1541
|
+
P(!1), B();
|
|
1579
1542
|
return;
|
|
1580
1543
|
}
|
|
1581
1544
|
let e = !1;
|
|
1582
1545
|
async function t() {
|
|
1583
1546
|
try {
|
|
1584
|
-
let t = await
|
|
1547
|
+
let t = await vt(_t[s], l, u, d, c);
|
|
1585
1548
|
if (e) {
|
|
1586
1549
|
t.close();
|
|
1587
1550
|
return;
|
|
@@ -1592,60 +1555,60 @@ var Yn = (e, t = {}) => {
|
|
|
1592
1555
|
}
|
|
1593
1556
|
}
|
|
1594
1557
|
return t(), () => {
|
|
1595
|
-
e = !0, P(!1),
|
|
1558
|
+
e = !0, P(!1), b.current !== null && (cancelAnimationFrame(b.current), b.current = null), m.current?.close(), m.current = null, B();
|
|
1596
1559
|
};
|
|
1597
1560
|
}, [
|
|
1598
|
-
|
|
1561
|
+
o,
|
|
1599
1562
|
l,
|
|
1600
1563
|
u,
|
|
1601
|
-
|
|
1602
|
-
|
|
1564
|
+
s,
|
|
1565
|
+
c,
|
|
1603
1566
|
d,
|
|
1604
|
-
|
|
1567
|
+
B
|
|
1605
1568
|
]), M.current = {
|
|
1606
1569
|
width: f,
|
|
1607
1570
|
height: p
|
|
1608
|
-
},
|
|
1609
|
-
if (!
|
|
1571
|
+
}, n(() => {
|
|
1572
|
+
if (!o || !N) return;
|
|
1610
1573
|
let t = () => {
|
|
1611
1574
|
let n = e.current, r = m.current;
|
|
1612
1575
|
if (!n || !r || n.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1613
|
-
|
|
1576
|
+
b.current = requestAnimationFrame(t);
|
|
1614
1577
|
return;
|
|
1615
1578
|
}
|
|
1616
|
-
if (n.currentTime ===
|
|
1617
|
-
|
|
1579
|
+
if (n.currentTime === x.current) {
|
|
1580
|
+
b.current = requestAnimationFrame(t);
|
|
1618
1581
|
return;
|
|
1619
1582
|
}
|
|
1620
|
-
|
|
1583
|
+
x.current = n.currentTime;
|
|
1621
1584
|
let i = n.videoWidth || n.clientWidth || 1280, a = n.videoHeight || n.clientHeight || 720;
|
|
1622
|
-
(i !==
|
|
1585
|
+
(i !== S.current.width || a !== S.current.height) && (S.current = {
|
|
1623
1586
|
width: i,
|
|
1624
1587
|
height: a
|
|
1625
|
-
},
|
|
1588
|
+
}, te({
|
|
1626
1589
|
width: i,
|
|
1627
1590
|
height: a
|
|
1628
1591
|
}));
|
|
1629
1592
|
let o = M.current;
|
|
1630
|
-
j.current = o.width > 0 && o.height > 0 ?
|
|
1593
|
+
j.current = o.width > 0 && o.height > 0 ? tt(o.width, o.height, i, a) : null;
|
|
1631
1594
|
let s = performance.now();
|
|
1632
1595
|
try {
|
|
1633
|
-
let e =
|
|
1634
|
-
if (
|
|
1596
|
+
let e = w.current === null || C.current === 0;
|
|
1597
|
+
if (C.current = (C.current + 1) % 2, e) {
|
|
1635
1598
|
let e = r.detectForVideo(n, s);
|
|
1636
1599
|
try {
|
|
1637
|
-
let t =
|
|
1600
|
+
let t = Tn(xn(e.landmarks, e.worldLandmarks), j.current), n = t.length, r = !Fn(D.current, s), o = Cn(t, {
|
|
1638
1601
|
previousCandidate: O.current,
|
|
1639
1602
|
allowRelock: r
|
|
1640
|
-
}), c = o?.landmarks ?? null, l = o?.worldLandmarks ?? null, f = o || O.current ?
|
|
1603
|
+
}), c = o?.landmarks ?? null, l = o?.worldLandmarks ?? null, f = o || O.current ? $t : null, p = ut(), m = Nn({
|
|
1641
1604
|
detectedPersonCount: n,
|
|
1642
1605
|
isTracking: !1,
|
|
1643
1606
|
lockedPersonId: f,
|
|
1644
1607
|
frameWidth: i,
|
|
1645
1608
|
frameHeight: a,
|
|
1646
1609
|
updatedAt: s
|
|
1647
|
-
}), _ =
|
|
1648
|
-
if (!c) _ ? (p = _, m =
|
|
1610
|
+
}), _ = Fn(D.current, s) ? In(E.current) : null;
|
|
1611
|
+
if (!c) _ ? (p = _, m = Ln(n, s, f)) : (h.current.reset(), g.current = null, E.current = null, D.current = null, O.current = null, m = Nn({
|
|
1649
1612
|
detectedPersonCount: n,
|
|
1650
1613
|
isTracking: !1,
|
|
1651
1614
|
lockedPersonId: null,
|
|
@@ -1655,12 +1618,12 @@ var Yn = (e, t = {}) => {
|
|
|
1655
1618
|
}));
|
|
1656
1619
|
else {
|
|
1657
1620
|
r && o && (h.current.reset(), g.current = null);
|
|
1658
|
-
let t = h.current.smooth(
|
|
1659
|
-
if (O.current = o ?
|
|
1660
|
-
let n =
|
|
1621
|
+
let t = h.current.smooth(nn(c)), v = l ? nn(l) : null, y = Yt(t, v), b = t.reduce((e, t) => e + (t.visibility ?? 0), 0) / t.length, x = b >= u ? y ? ln(g.current, y, Fe.rotationAlpha) : g.current : null, S = x !== null, C = null;
|
|
1622
|
+
if (O.current = o ? En(o) : O.current, d) {
|
|
1623
|
+
let n = Xt(o ? e.segmentationMasks?.[o.poseIndex] : void 0);
|
|
1661
1624
|
if (n) {
|
|
1662
|
-
let e =
|
|
1663
|
-
e && (C =
|
|
1625
|
+
let e = at(new Float32Array(n.getAsFloat32Array()), n.width, n.height, t);
|
|
1626
|
+
e && (C = Qt(e, i, n.width));
|
|
1664
1627
|
}
|
|
1665
1628
|
}
|
|
1666
1629
|
S && x ? (g.current = x, p = {
|
|
@@ -1670,92 +1633,92 @@ var Yn = (e, t = {}) => {
|
|
|
1670
1633
|
confidence: b,
|
|
1671
1634
|
isTracking: S,
|
|
1672
1635
|
silhouetteWidths: C
|
|
1673
|
-
}, E.current = p, D.current = s, m =
|
|
1636
|
+
}, E.current = p, D.current = s, m = Nn({
|
|
1674
1637
|
detectedPersonCount: n,
|
|
1675
1638
|
isTracking: S,
|
|
1676
|
-
lockedPersonId:
|
|
1639
|
+
lockedPersonId: $t,
|
|
1677
1640
|
meanVisibility: o?.meanVisibility ?? b,
|
|
1678
1641
|
frameWidth: i,
|
|
1679
1642
|
frameHeight: a,
|
|
1680
1643
|
updatedAt: s
|
|
1681
|
-
})) : _ ? (p = _, m =
|
|
1644
|
+
})) : _ ? (p = _, m = Ln(n, s, f)) : (g.current = null, E.current = null, D.current = null, p = {
|
|
1682
1645
|
landmarks: t,
|
|
1683
1646
|
worldLandmarks: v,
|
|
1684
1647
|
poseRig: null,
|
|
1685
1648
|
confidence: b,
|
|
1686
1649
|
isTracking: !1,
|
|
1687
1650
|
silhouetteWidths: C
|
|
1688
|
-
}, m =
|
|
1651
|
+
}, m = Nn({
|
|
1689
1652
|
detectedPersonCount: n,
|
|
1690
1653
|
isTracking: !1,
|
|
1691
|
-
lockedPersonId: o ?
|
|
1654
|
+
lockedPersonId: o ? $t : null,
|
|
1692
1655
|
meanVisibility: o?.meanVisibility ?? b,
|
|
1693
1656
|
frameWidth: i,
|
|
1694
1657
|
frameHeight: a,
|
|
1695
1658
|
updatedAt: s
|
|
1696
1659
|
}));
|
|
1697
1660
|
}
|
|
1698
|
-
let v =
|
|
1699
|
-
|
|
1700
|
-
let y =
|
|
1701
|
-
T.current = y,
|
|
1661
|
+
let v = w.current;
|
|
1662
|
+
w.current = p, k.current = m;
|
|
1663
|
+
let y = dt(v, p, gt);
|
|
1664
|
+
T.current = y, z(y, m);
|
|
1702
1665
|
} finally {
|
|
1703
|
-
|
|
1666
|
+
Zt(e.segmentationMasks);
|
|
1704
1667
|
}
|
|
1705
|
-
} else T.current &&
|
|
1668
|
+
} else T.current && z(T.current, k.current);
|
|
1706
1669
|
} catch {}
|
|
1707
1670
|
let c = A.current;
|
|
1708
1671
|
if (c.frames += 1, c.lastMeasuredAt === 0 && (c.lastMeasuredAt = s), s - c.lastMeasuredAt >= 1e3) {
|
|
1709
1672
|
let e = c.frames;
|
|
1710
|
-
c.frames = 0, c.lastMeasuredAt = s,
|
|
1673
|
+
c.frames = 0, c.lastMeasuredAt = s, I((t) => ({
|
|
1711
1674
|
...t,
|
|
1712
1675
|
fps: e
|
|
1713
1676
|
}));
|
|
1714
1677
|
}
|
|
1715
|
-
|
|
1678
|
+
b.current = requestAnimationFrame(t);
|
|
1716
1679
|
};
|
|
1717
|
-
return
|
|
1718
|
-
|
|
1680
|
+
return b.current = requestAnimationFrame(t), () => {
|
|
1681
|
+
b.current !== null && (cancelAnimationFrame(b.current), b.current = null);
|
|
1719
1682
|
};
|
|
1720
1683
|
}, [
|
|
1721
|
-
|
|
1684
|
+
o,
|
|
1722
1685
|
N,
|
|
1723
1686
|
u,
|
|
1724
1687
|
d,
|
|
1725
|
-
|
|
1688
|
+
z,
|
|
1726
1689
|
e
|
|
1727
1690
|
]);
|
|
1728
|
-
let
|
|
1691
|
+
let V = t((t) => {
|
|
1729
1692
|
let n = e.current, r = t.getContext("2d");
|
|
1730
1693
|
if (!n || !r) return;
|
|
1731
1694
|
t.width = n.videoWidth || t.clientWidth || 1280, t.height = n.videoHeight || t.clientHeight || 720, r.clearRect(0, 0, t.width, t.height);
|
|
1732
|
-
let i =
|
|
1695
|
+
let i = v.current;
|
|
1733
1696
|
if (!i) return;
|
|
1734
|
-
let a =
|
|
1697
|
+
let a = nn(i), o = new _(r);
|
|
1735
1698
|
o.drawLandmarks(a, {
|
|
1736
1699
|
radius: 3,
|
|
1737
1700
|
color: "#00FF88",
|
|
1738
1701
|
fillColor: "#00FF88"
|
|
1739
|
-
}), o.drawConnectors(a,
|
|
1702
|
+
}), o.drawConnectors(a, y.POSE_CONNECTIONS, {
|
|
1740
1703
|
color: "#00C8FF",
|
|
1741
1704
|
lineWidth: 2
|
|
1742
1705
|
});
|
|
1743
1706
|
}, [e]);
|
|
1744
1707
|
return {
|
|
1745
|
-
...
|
|
1708
|
+
...F,
|
|
1746
1709
|
isTrackerReady: N,
|
|
1747
|
-
drawLandmarks:
|
|
1748
|
-
silhouetteWidths:
|
|
1749
|
-
poseFrameWidth:
|
|
1750
|
-
poseFrameHeight:
|
|
1751
|
-
detectedPersonCount:
|
|
1752
|
-
lockedPersonId:
|
|
1753
|
-
trackingQuality:
|
|
1710
|
+
drawLandmarks: V,
|
|
1711
|
+
silhouetteWidths: L,
|
|
1712
|
+
poseFrameWidth: ee.width,
|
|
1713
|
+
poseFrameHeight: ee.height,
|
|
1714
|
+
detectedPersonCount: ne.detectedPersonCount,
|
|
1715
|
+
lockedPersonId: ne.lockedPersonId,
|
|
1716
|
+
trackingQuality: ne.trackingQuality
|
|
1754
1717
|
};
|
|
1755
1718
|
};
|
|
1756
1719
|
//#endregion
|
|
1757
1720
|
//#region src/hooks/useWebcam.ts
|
|
1758
|
-
function
|
|
1721
|
+
function Bn(e) {
|
|
1759
1722
|
if (!(e instanceof DOMException)) return "Failed to start the camera.";
|
|
1760
1723
|
switch (e.name) {
|
|
1761
1724
|
case "NotAllowedError": return "Camera permission was denied.";
|
|
@@ -1765,94 +1728,101 @@ function Xn(e) {
|
|
|
1765
1728
|
default: return "Failed to start the camera.";
|
|
1766
1729
|
}
|
|
1767
1730
|
}
|
|
1768
|
-
function
|
|
1769
|
-
let { width:
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1731
|
+
function Vn(e = {}) {
|
|
1732
|
+
let { width: o = 1280, height: s = 720, facingMode: c = "user", enabled: l = !0, mockMode: u = !1, videoRef: d, onReadyChange: f, onErrorChange: p } = e, m = i(null), h = r(() => ({
|
|
1733
|
+
get current() {
|
|
1734
|
+
return m.current;
|
|
1735
|
+
},
|
|
1736
|
+
set current(e) {
|
|
1737
|
+
m.current = e, d && (d.current = e);
|
|
1738
|
+
}
|
|
1739
|
+
}), [d]), g = i(null), _ = i(!1), v = i(0), [y, b] = a(!1), [x, S] = a(null), C = t((e) => {
|
|
1740
|
+
b(e), f?.(e);
|
|
1741
|
+
}, [f]), w = t((e) => {
|
|
1742
|
+
S(e), p?.(e);
|
|
1743
|
+
}, [p]), T = t(() => {
|
|
1744
|
+
g.current &&= (g.current.getTracks().forEach((e) => e.stop()), null), h.current && (h.current.pause(), h.current.srcObject = null), C(!1);
|
|
1745
|
+
}, [C, h]), E = t(() => {
|
|
1746
|
+
v.current += 1, T();
|
|
1747
|
+
}, [T]), D = t(() => {
|
|
1748
|
+
if (h.current) return h.current;
|
|
1779
1749
|
let e = document.createElement("video");
|
|
1780
|
-
return e.playsInline = !0, e.autoplay = !0, e.muted = !0, e.setAttribute("playsinline", "true"),
|
|
1781
|
-
}, [
|
|
1782
|
-
let e =
|
|
1783
|
-
if (
|
|
1784
|
-
|
|
1750
|
+
return e.playsInline = !0, e.autoplay = !0, e.muted = !0, e.setAttribute("playsinline", "true"), h.current = e, e;
|
|
1751
|
+
}, [h]), O = t(async () => {
|
|
1752
|
+
let e = v.current + 1;
|
|
1753
|
+
if (v.current = e, T(), w(null), u) {
|
|
1754
|
+
D(), C(!0);
|
|
1785
1755
|
return;
|
|
1786
1756
|
}
|
|
1787
1757
|
if (!navigator.mediaDevices?.getUserMedia) {
|
|
1788
|
-
|
|
1758
|
+
w("This browser does not support camera access.");
|
|
1789
1759
|
return;
|
|
1790
1760
|
}
|
|
1791
1761
|
try {
|
|
1792
|
-
let
|
|
1762
|
+
let t = D(), n = await navigator.mediaDevices.getUserMedia({
|
|
1793
1763
|
video: {
|
|
1794
|
-
width:
|
|
1795
|
-
height:
|
|
1796
|
-
facingMode:
|
|
1764
|
+
width: o,
|
|
1765
|
+
height: s,
|
|
1766
|
+
facingMode: c
|
|
1797
1767
|
},
|
|
1798
1768
|
audio: !1
|
|
1799
1769
|
});
|
|
1800
|
-
if (!
|
|
1801
|
-
|
|
1770
|
+
if (!_.current || v.current !== e) {
|
|
1771
|
+
n.getTracks().forEach((e) => e.stop());
|
|
1802
1772
|
return;
|
|
1803
1773
|
}
|
|
1804
|
-
if (
|
|
1805
|
-
|
|
1774
|
+
if (g.current = n, t.srcObject = n, await t.play(), !_.current || v.current !== e) {
|
|
1775
|
+
n.getTracks().forEach((e) => e.stop());
|
|
1806
1776
|
return;
|
|
1807
1777
|
}
|
|
1808
|
-
|
|
1778
|
+
C(!0);
|
|
1809
1779
|
} catch (t) {
|
|
1810
|
-
if (
|
|
1811
|
-
|
|
1780
|
+
if (v.current !== e) return;
|
|
1781
|
+
T(), w(Bn(t));
|
|
1812
1782
|
}
|
|
1813
1783
|
}, [
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
C,
|
|
1819
|
-
S,
|
|
1784
|
+
D,
|
|
1785
|
+
c,
|
|
1786
|
+
s,
|
|
1787
|
+
u,
|
|
1820
1788
|
w,
|
|
1821
|
-
|
|
1789
|
+
C,
|
|
1790
|
+
T,
|
|
1791
|
+
o
|
|
1822
1792
|
]);
|
|
1823
|
-
return
|
|
1824
|
-
|
|
1825
|
-
}), [
|
|
1826
|
-
if (
|
|
1827
|
-
if (!
|
|
1828
|
-
|
|
1793
|
+
return n(() => (_.current = !0, () => {
|
|
1794
|
+
_.current = !1, E();
|
|
1795
|
+
}), [E]), n(() => {
|
|
1796
|
+
if (_.current) {
|
|
1797
|
+
if (!l) {
|
|
1798
|
+
E();
|
|
1829
1799
|
return;
|
|
1830
1800
|
}
|
|
1831
|
-
|
|
1801
|
+
O();
|
|
1832
1802
|
}
|
|
1833
1803
|
}, [
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1804
|
+
l,
|
|
1805
|
+
O,
|
|
1806
|
+
E
|
|
1837
1807
|
]), {
|
|
1838
|
-
videoRef:
|
|
1839
|
-
isReady:
|
|
1840
|
-
error:
|
|
1841
|
-
start:
|
|
1842
|
-
stop:
|
|
1808
|
+
videoRef: h,
|
|
1809
|
+
isReady: y,
|
|
1810
|
+
error: x,
|
|
1811
|
+
start: O,
|
|
1812
|
+
stop: E
|
|
1843
1813
|
};
|
|
1844
1814
|
}
|
|
1845
1815
|
//#endregion
|
|
1846
1816
|
//#region src/hooks/useEverFitting.ts
|
|
1847
|
-
function
|
|
1848
|
-
let { width: t = 1280, height:
|
|
1817
|
+
function Hn(e = {}) {
|
|
1818
|
+
let { width: t = 1280, height: i = 720, facingMode: a = "user", enabled: o = !0, mockMode: s = !1, modelComplexity: c = "lite", numPoses: l, minDetectionConfidence: u, minTrackingConfidence: d, outputSegmentationMasks: f = !0, viewportWidth: p = 0, viewportHeight: m = 0, measurementEnabled: h = !0, autoStartMeasurement: g = !1, measurementConfig: _, bodyPresetOptions: v, fitType: y = "regular", garmentScaleHint: b = null } = e, x = Vn({
|
|
1849
1819
|
width: t,
|
|
1850
|
-
height:
|
|
1851
|
-
facingMode:
|
|
1852
|
-
enabled:
|
|
1820
|
+
height: i,
|
|
1821
|
+
facingMode: a,
|
|
1822
|
+
enabled: o,
|
|
1853
1823
|
mockMode: s
|
|
1854
|
-
}), S =
|
|
1855
|
-
enabled:
|
|
1824
|
+
}), S = zn(x.videoRef, {
|
|
1825
|
+
enabled: o,
|
|
1856
1826
|
modelComplexity: c,
|
|
1857
1827
|
numPoses: l,
|
|
1858
1828
|
minDetectionConfidence: u,
|
|
@@ -1860,7 +1830,7 @@ function Qn(e = {}) {
|
|
|
1860
1830
|
outputSegmentationMasks: f,
|
|
1861
1831
|
viewportWidth: p,
|
|
1862
1832
|
viewportHeight: m
|
|
1863
|
-
}), { config: C, measurements: w, sizeRecommendation: T, garmentScale: E, isMeasuring: D, measure: O, startMeasurement: k, updateConfig: A } =
|
|
1833
|
+
}), { config: C, measurements: w, sizeRecommendation: T, garmentScale: E, isMeasuring: D, measure: O, startMeasurement: k, updateConfig: A } = $e(), j = o && x.isReady && S.isTracking, M = Pe(w, v), N = r(() => pe({
|
|
1864
1834
|
measurements: w,
|
|
1865
1835
|
measurementScale: E,
|
|
1866
1836
|
presetSelection: M.selection,
|
|
@@ -1873,9 +1843,9 @@ function Qn(e = {}) {
|
|
|
1873
1843
|
b,
|
|
1874
1844
|
w
|
|
1875
1845
|
]);
|
|
1876
|
-
return
|
|
1846
|
+
return n(() => {
|
|
1877
1847
|
_ && A(_);
|
|
1878
|
-
}, [_, A]),
|
|
1848
|
+
}, [_, A]), n(() => {
|
|
1879
1849
|
!h || !g || !j || w || D || k();
|
|
1880
1850
|
}, [
|
|
1881
1851
|
g,
|
|
@@ -1884,14 +1854,14 @@ function Qn(e = {}) {
|
|
|
1884
1854
|
w,
|
|
1885
1855
|
D,
|
|
1886
1856
|
k
|
|
1887
|
-
]),
|
|
1857
|
+
]), n(() => {
|
|
1888
1858
|
!h || !D || !S.landmarks || O(S.landmarks, {
|
|
1889
1859
|
silhouetteWidths: S.silhouetteWidths,
|
|
1890
1860
|
imageWidth: S.poseFrameWidth || t,
|
|
1891
|
-
imageHeight: S.poseFrameHeight ||
|
|
1861
|
+
imageHeight: S.poseFrameHeight || i
|
|
1892
1862
|
});
|
|
1893
1863
|
}, [
|
|
1894
|
-
|
|
1864
|
+
i,
|
|
1895
1865
|
h,
|
|
1896
1866
|
D,
|
|
1897
1867
|
O,
|
|
@@ -1900,7 +1870,7 @@ function Qn(e = {}) {
|
|
|
1900
1870
|
S.poseFrameWidth,
|
|
1901
1871
|
S.silhouetteWidths,
|
|
1902
1872
|
t
|
|
1903
|
-
]), {
|
|
1873
|
+
]), r(() => ({
|
|
1904
1874
|
videoRef: x.videoRef,
|
|
1905
1875
|
webcamReady: x.isReady,
|
|
1906
1876
|
webcamError: x.error,
|
|
@@ -1933,12 +1903,45 @@ function Qn(e = {}) {
|
|
|
1933
1903
|
bodyPresetSelection: M.selection,
|
|
1934
1904
|
bodyPresetLoading: M.loading,
|
|
1935
1905
|
bodyPresetError: M.error
|
|
1936
|
-
}
|
|
1906
|
+
}), [
|
|
1907
|
+
N.morph,
|
|
1908
|
+
N.scale,
|
|
1909
|
+
M.error,
|
|
1910
|
+
M.loading,
|
|
1911
|
+
M.selection,
|
|
1912
|
+
j,
|
|
1913
|
+
C,
|
|
1914
|
+
E,
|
|
1915
|
+
D,
|
|
1916
|
+
w,
|
|
1917
|
+
T,
|
|
1918
|
+
k,
|
|
1919
|
+
S.confidence,
|
|
1920
|
+
S.detectedPersonCount,
|
|
1921
|
+
S.drawLandmarks,
|
|
1922
|
+
S.fps,
|
|
1923
|
+
S.isTrackerReady,
|
|
1924
|
+
S.isTracking,
|
|
1925
|
+
S.landmarks,
|
|
1926
|
+
S.lockedPersonId,
|
|
1927
|
+
S.poseFrameHeight,
|
|
1928
|
+
S.poseFrameWidth,
|
|
1929
|
+
S.poseRig,
|
|
1930
|
+
S.silhouetteWidths,
|
|
1931
|
+
S.trackingQuality,
|
|
1932
|
+
S.worldLandmarks,
|
|
1933
|
+
A,
|
|
1934
|
+
x.error,
|
|
1935
|
+
x.isReady,
|
|
1936
|
+
x.start,
|
|
1937
|
+
x.stop,
|
|
1938
|
+
x.videoRef
|
|
1939
|
+
]);
|
|
1937
1940
|
}
|
|
1938
1941
|
//#endregion
|
|
1939
1942
|
//#region src/garment/garmentFitProfile.ts
|
|
1940
|
-
function
|
|
1941
|
-
let t = new
|
|
1943
|
+
function Un(e) {
|
|
1944
|
+
let t = new b.Vector3(), n = new b.Quaternion(), r = new b.Quaternion();
|
|
1942
1945
|
return e.updateWorldMatrix(!0, !1), e.getWorldPosition(t), e.getWorldQuaternion(n), e.parent ? e.parent.getWorldQuaternion(r) : r.identity(), {
|
|
1943
1946
|
bone: e,
|
|
1944
1947
|
restQuaternion: e.quaternion.clone(),
|
|
@@ -1948,12 +1951,12 @@ function $n(e) {
|
|
|
1948
1951
|
restParentWorldQuaternion: r
|
|
1949
1952
|
};
|
|
1950
1953
|
}
|
|
1951
|
-
function
|
|
1952
|
-
let t = new
|
|
1954
|
+
function Wn(e) {
|
|
1955
|
+
let t = new b.Box3(), n = { current: !1 }, r = new b.Vector3(), i = new b.Box3();
|
|
1953
1956
|
return e.updateMatrixWorld(!0), e.traverse((e) => {
|
|
1954
|
-
if (!(e instanceof
|
|
1957
|
+
if (!(e instanceof b.Mesh) || e.name.startsWith("Collision") || !e.visible) return;
|
|
1955
1958
|
let a = e.geometry.getAttribute("skinIndex") && e.geometry.getAttribute("skinWeight");
|
|
1956
|
-
if (e instanceof
|
|
1959
|
+
if (e instanceof b.SkinnedMesh && a) {
|
|
1957
1960
|
if (e.computeBoundingBox(), !e.boundingBox) return;
|
|
1958
1961
|
i.copy(e.boundingBox);
|
|
1959
1962
|
} else {
|
|
@@ -2011,81 +2014,81 @@ function er(e) {
|
|
|
2011
2014
|
});
|
|
2012
2015
|
}), n.current || t.makeEmpty(), t;
|
|
2013
2016
|
}
|
|
2014
|
-
function
|
|
2017
|
+
function Gn(e) {
|
|
2015
2018
|
if (!e || e.length === 0) return null;
|
|
2016
|
-
let t = new
|
|
2019
|
+
let t = new b.Vector3(), n = new b.Vector3();
|
|
2017
2020
|
return e.forEach(({ bone: e }) => {
|
|
2018
2021
|
e.getWorldPosition(n), t.add(n);
|
|
2019
2022
|
}), t.multiplyScalar(1 / e.length);
|
|
2020
2023
|
}
|
|
2021
|
-
function
|
|
2024
|
+
function Kn(e, t) {
|
|
2022
2025
|
for (let n = 0; n < t.length; n += 1) {
|
|
2023
|
-
let r =
|
|
2026
|
+
let r = Gn(e.get(t[n]));
|
|
2024
2027
|
if (r) return r;
|
|
2025
2028
|
}
|
|
2026
2029
|
return null;
|
|
2027
2030
|
}
|
|
2028
|
-
function
|
|
2031
|
+
function qn(e, t, n = 1) {
|
|
2029
2032
|
e.updateMatrixWorld(!0);
|
|
2030
|
-
let r =
|
|
2031
|
-
if (
|
|
2032
|
-
let e = Math.min(
|
|
2033
|
+
let r = Wn(e), i = r.getCenter(new b.Vector3()), a = r.getSize(new b.Vector3()), o = new b.Vector3(i.x, r.min.y + a.y * .74, i.z), s = new b.Vector3(i.x, r.min.y + a.y * .42, i.z), c = Kn(t, ["LeftUpperArm", "LeftShoulder"]), l = Kn(t, ["RightUpperArm", "RightShoulder"]), u = Kn(t, ["Hips"]), d = Kn(t, ["LeftUpperLeg"]), f = Kn(t, ["RightUpperLeg"]), p = c ?? o.clone().setX(i.x + a.x * .18), m = l ?? o.clone().setX(i.x - a.x * .18), h = u ?? s, g = p.clone().add(m).multiplyScalar(.5), _ = d && f ? d.clone().add(f).multiplyScalar(.5) : h.clone(), v = !!(c && l), y = v && !!(u || d && f), x = p.distanceTo(m), S = g.distanceTo(_), C = v ? Math.max(x, 1e-4) : Math.max(x, a.x * .3, n), w = y ? Math.max(S, 1e-4) : Math.max(S, a.y * .28, 1e-4), T = y ? g.clone().add(_).multiplyScalar(.5) : i.clone(), E = r.clone();
|
|
2034
|
+
if (y) {
|
|
2035
|
+
let e = Math.min(g.y, _.y), t = Math.max(g.y, _.y);
|
|
2033
2036
|
E.min.y = Math.max(E.min.y, e), E.max.y = Math.min(E.max.y, t), E.max.y <= E.min.y && E.copy(r);
|
|
2034
2037
|
}
|
|
2035
|
-
let D = E.getCenter(new
|
|
2038
|
+
let D = E.getCenter(new b.Vector3()), O = E.getSize(new b.Vector3());
|
|
2036
2039
|
return {
|
|
2037
2040
|
anchor: T,
|
|
2038
|
-
shoulderCenter:
|
|
2039
|
-
hipCenter:
|
|
2041
|
+
shoulderCenter: g,
|
|
2042
|
+
hipCenter: _,
|
|
2040
2043
|
referenceWidth: C,
|
|
2041
2044
|
referenceTorsoHeight: w,
|
|
2042
2045
|
trackingHeight: Math.max(a.y, w, 1e-4),
|
|
2043
2046
|
boundsCenter: D,
|
|
2044
2047
|
boundsSize: O,
|
|
2045
|
-
hasBoneAnchors:
|
|
2048
|
+
hasBoneAnchors: y
|
|
2046
2049
|
};
|
|
2047
2050
|
}
|
|
2048
|
-
function
|
|
2051
|
+
function Jn(e) {
|
|
2049
2052
|
for (let t of e.values()) t.forEach(({ bone: e, restQuaternion: t, restScale: n }) => {
|
|
2050
2053
|
e.quaternion.copy(t), e.scale.copy(n);
|
|
2051
2054
|
});
|
|
2052
2055
|
}
|
|
2053
2056
|
//#endregion
|
|
2054
2057
|
//#region src/avatar/avatarLoader.ts
|
|
2055
|
-
var
|
|
2056
|
-
function
|
|
2058
|
+
var Yn = "__nativeVRMPrepared";
|
|
2059
|
+
function Xn(e) {
|
|
2057
2060
|
try {
|
|
2058
2061
|
return new URL(e, "https://avatar.local").pathname;
|
|
2059
2062
|
} catch {
|
|
2060
2063
|
return e;
|
|
2061
2064
|
}
|
|
2062
2065
|
}
|
|
2063
|
-
function
|
|
2064
|
-
return
|
|
2066
|
+
function Zn(e) {
|
|
2067
|
+
return Xn(e).toLowerCase().endsWith(".vrm");
|
|
2065
2068
|
}
|
|
2066
|
-
function
|
|
2067
|
-
return
|
|
2069
|
+
function Qn(e) {
|
|
2070
|
+
return Zn(e) ? "vrm" : "gltf";
|
|
2068
2071
|
}
|
|
2069
|
-
function
|
|
2070
|
-
|
|
2072
|
+
function $n(e, t) {
|
|
2073
|
+
Zn(t) && e.register((e) => new S(e));
|
|
2071
2074
|
}
|
|
2072
|
-
function
|
|
2073
|
-
if (
|
|
2074
|
-
|
|
2075
|
+
function er(e) {
|
|
2076
|
+
if (Zn(e)) return (t) => {
|
|
2077
|
+
$n(t, e);
|
|
2075
2078
|
};
|
|
2076
2079
|
}
|
|
2077
|
-
function
|
|
2080
|
+
function tr(e) {
|
|
2078
2081
|
e.traverse((e) => {
|
|
2079
2082
|
e.frustumCulled = !1;
|
|
2080
2083
|
});
|
|
2081
2084
|
}
|
|
2082
|
-
function
|
|
2085
|
+
function nr(e) {
|
|
2083
2086
|
let t = e.scene.userData;
|
|
2084
|
-
t[
|
|
2087
|
+
t[Yn] || (C.rotateVRM0(e), t[Yn] = !0), tr(e.scene);
|
|
2085
2088
|
}
|
|
2086
2089
|
//#endregion
|
|
2087
2090
|
//#region src/avatar/humanoidBindings.ts
|
|
2088
|
-
var
|
|
2091
|
+
var rr = {
|
|
2089
2092
|
Hips: ["hips"],
|
|
2090
2093
|
Spine: ["spine"],
|
|
2091
2094
|
Chest: ["chest", "upperChest"],
|
|
@@ -2106,13 +2109,13 @@ var pr = {
|
|
|
2106
2109
|
RightLowerLeg: ["rightLowerLeg"],
|
|
2107
2110
|
RightFoot: ["rightFoot"]
|
|
2108
2111
|
};
|
|
2109
|
-
function
|
|
2112
|
+
function ir(e) {
|
|
2110
2113
|
let t = /* @__PURE__ */ new Map();
|
|
2111
|
-
return Object.entries(
|
|
2114
|
+
return Object.entries(rr).forEach(([n, r]) => {
|
|
2112
2115
|
for (let i = 0; i < r.length; i += 1) {
|
|
2113
2116
|
let a = e.getNormalizedBoneNode(r[i]);
|
|
2114
2117
|
if (a) {
|
|
2115
|
-
t.set(n, [
|
|
2118
|
+
t.set(n, [Un(a)]);
|
|
2116
2119
|
break;
|
|
2117
2120
|
}
|
|
2118
2121
|
}
|
|
@@ -2120,7 +2123,7 @@ function mr(e) {
|
|
|
2120
2123
|
}
|
|
2121
2124
|
//#endregion
|
|
2122
2125
|
//#region src/avatar/VRMCompat.ts
|
|
2123
|
-
var
|
|
2126
|
+
var ar = {
|
|
2124
2127
|
root: "hips",
|
|
2125
2128
|
c_spine0: "spine",
|
|
2126
2129
|
c_spine1: "spine",
|
|
@@ -2142,7 +2145,7 @@ var hr = {
|
|
|
2142
2145
|
r_upleg: "rightUpperLeg",
|
|
2143
2146
|
r_lowleg: "rightLowerLeg",
|
|
2144
2147
|
r_foot: "rightFoot"
|
|
2145
|
-
},
|
|
2148
|
+
}, or = {
|
|
2146
2149
|
bone_0: "hips",
|
|
2147
2150
|
bone_1: "spine",
|
|
2148
2151
|
bone_2: "chest",
|
|
@@ -2163,7 +2166,7 @@ var hr = {
|
|
|
2163
2166
|
bone_48: "rightUpperLeg",
|
|
2164
2167
|
bone_49: "rightLowerLeg",
|
|
2165
2168
|
bone_50: "rightFoot"
|
|
2166
|
-
},
|
|
2169
|
+
}, sr = {
|
|
2167
2170
|
Root: "hips",
|
|
2168
2171
|
Hips: "hips",
|
|
2169
2172
|
Spine: "spine",
|
|
@@ -2185,7 +2188,7 @@ var hr = {
|
|
|
2185
2188
|
RightLowerLeg: "rightLowerLeg",
|
|
2186
2189
|
RightFoot: "rightFoot"
|
|
2187
2190
|
};
|
|
2188
|
-
function
|
|
2191
|
+
function cr(e, t) {
|
|
2189
2192
|
if (t?.humanoid) return {
|
|
2190
2193
|
getNormalizedBoneNode: (e) => t.humanoid.getNormalizedBoneNode(e) ?? null,
|
|
2191
2194
|
update: (e) => t.update(e),
|
|
@@ -2193,12 +2196,12 @@ function vr(e, t) {
|
|
|
2193
2196
|
};
|
|
2194
2197
|
let n = /* @__PURE__ */ new Map();
|
|
2195
2198
|
return e.traverse((e) => {
|
|
2196
|
-
if (!(e instanceof
|
|
2197
|
-
let t = e.name, r =
|
|
2199
|
+
if (!(e instanceof b.Bone)) return;
|
|
2200
|
+
let t = e.name, r = ar[t];
|
|
2198
2201
|
r && !n.has(r) && n.set(r, e);
|
|
2199
|
-
let i =
|
|
2202
|
+
let i = sr[t];
|
|
2200
2203
|
i && !n.has(i) && n.set(i, e);
|
|
2201
|
-
let a =
|
|
2204
|
+
let a = or[t];
|
|
2202
2205
|
a && !n.has(a) && n.set(a, e);
|
|
2203
2206
|
}), {
|
|
2204
2207
|
getNormalizedBoneNode: (e) => n.get(e) ?? null,
|
|
@@ -2208,10 +2211,10 @@ function vr(e, t) {
|
|
|
2208
2211
|
}
|
|
2209
2212
|
//#endregion
|
|
2210
2213
|
//#region src/hooks/useAvatarVariant.ts
|
|
2211
|
-
function
|
|
2212
|
-
let t =
|
|
2213
|
-
return
|
|
2214
|
-
if (e instanceof
|
|
2214
|
+
function lr(e) {
|
|
2215
|
+
let t = x(e);
|
|
2216
|
+
return tr(t), t.traverse((e) => {
|
|
2217
|
+
if (e instanceof b.Mesh) {
|
|
2215
2218
|
if (Array.isArray(e.material)) {
|
|
2216
2219
|
e.material = e.material.map((e) => e.clone());
|
|
2217
2220
|
return;
|
|
@@ -2220,32 +2223,32 @@ function yr(e) {
|
|
|
2220
2223
|
}
|
|
2221
2224
|
}), t;
|
|
2222
2225
|
}
|
|
2223
|
-
function
|
|
2224
|
-
let t =
|
|
2226
|
+
function ur({ url: e }) {
|
|
2227
|
+
let t = p(e, "/draco/", !0, r(() => er(e), [e])), n = t.userData?.vrm ?? null, i = r(() => n ? (nr(n), n.scene) : lr(t.scene), [t.scene, n]), a = r(() => cr(i, n), [i, n]);
|
|
2225
2228
|
return {
|
|
2226
|
-
scene:
|
|
2227
|
-
humanoid:
|
|
2228
|
-
bones:
|
|
2229
|
+
scene: i,
|
|
2230
|
+
humanoid: a,
|
|
2231
|
+
bones: r(() => ir(a), [a])
|
|
2229
2232
|
};
|
|
2230
2233
|
}
|
|
2231
2234
|
//#endregion
|
|
2232
2235
|
//#region src/pose/boneMapping.ts
|
|
2233
|
-
var
|
|
2234
|
-
min: -70 *
|
|
2235
|
-
max: 70 *
|
|
2236
|
-
},
|
|
2237
|
-
min: -45 *
|
|
2238
|
-
max: 45 *
|
|
2239
|
-
},
|
|
2240
|
-
min: -150 *
|
|
2241
|
-
max: 150 *
|
|
2242
|
-
},
|
|
2243
|
-
min: -90 *
|
|
2244
|
-
max: 90 *
|
|
2245
|
-
},
|
|
2236
|
+
var Y = Math.PI / 180, dr = {
|
|
2237
|
+
min: -70 * Y,
|
|
2238
|
+
max: 70 * Y
|
|
2239
|
+
}, fr = {
|
|
2240
|
+
min: -45 * Y,
|
|
2241
|
+
max: 45 * Y
|
|
2242
|
+
}, pr = {
|
|
2243
|
+
min: -150 * Y,
|
|
2244
|
+
max: 150 * Y
|
|
2245
|
+
}, mr = {
|
|
2246
|
+
min: -90 * Y,
|
|
2247
|
+
max: 90 * Y
|
|
2248
|
+
}, hr = {
|
|
2246
2249
|
min: 0,
|
|
2247
|
-
max: 150 *
|
|
2248
|
-
},
|
|
2250
|
+
max: 150 * Y
|
|
2251
|
+
}, gr = {
|
|
2249
2252
|
Hips: {
|
|
2250
2253
|
rigKey: "hips",
|
|
2251
2254
|
rotationScale: {
|
|
@@ -2276,22 +2279,22 @@ var q = Math.PI / 180, xr = {
|
|
|
2276
2279
|
rigKey: "leftUpperArm",
|
|
2277
2280
|
rotationScale: .45,
|
|
2278
2281
|
rotationLimits: {
|
|
2279
|
-
x:
|
|
2280
|
-
z:
|
|
2282
|
+
x: dr,
|
|
2283
|
+
z: fr
|
|
2281
2284
|
}
|
|
2282
2285
|
},
|
|
2283
2286
|
LeftUpperArm: {
|
|
2284
2287
|
rigKey: "leftUpperArm",
|
|
2285
2288
|
rotationScale: 1,
|
|
2286
2289
|
rotationLimits: {
|
|
2287
|
-
x:
|
|
2288
|
-
z:
|
|
2290
|
+
x: pr,
|
|
2291
|
+
z: mr
|
|
2289
2292
|
}
|
|
2290
2293
|
},
|
|
2291
2294
|
LeftLowerArm: {
|
|
2292
2295
|
rigKey: "leftLowerArm",
|
|
2293
2296
|
rotationScale: 1,
|
|
2294
|
-
rotationLimits: { x:
|
|
2297
|
+
rotationLimits: { x: hr }
|
|
2295
2298
|
},
|
|
2296
2299
|
LeftHand: {
|
|
2297
2300
|
rigKey: "leftLowerArm",
|
|
@@ -2301,22 +2304,22 @@ var q = Math.PI / 180, xr = {
|
|
|
2301
2304
|
rigKey: "rightUpperArm",
|
|
2302
2305
|
rotationScale: .45,
|
|
2303
2306
|
rotationLimits: {
|
|
2304
|
-
x:
|
|
2305
|
-
z:
|
|
2307
|
+
x: dr,
|
|
2308
|
+
z: fr
|
|
2306
2309
|
}
|
|
2307
2310
|
},
|
|
2308
2311
|
RightUpperArm: {
|
|
2309
2312
|
rigKey: "rightUpperArm",
|
|
2310
2313
|
rotationScale: 1,
|
|
2311
2314
|
rotationLimits: {
|
|
2312
|
-
x:
|
|
2313
|
-
z:
|
|
2315
|
+
x: pr,
|
|
2316
|
+
z: mr
|
|
2314
2317
|
}
|
|
2315
2318
|
},
|
|
2316
2319
|
RightLowerArm: {
|
|
2317
2320
|
rigKey: "rightLowerArm",
|
|
2318
2321
|
rotationScale: 1,
|
|
2319
|
-
rotationLimits: { x:
|
|
2322
|
+
rotationLimits: { x: hr }
|
|
2320
2323
|
},
|
|
2321
2324
|
RightHand: {
|
|
2322
2325
|
rigKey: "rightLowerArm",
|
|
@@ -2340,7 +2343,7 @@ var q = Math.PI / 180, xr = {
|
|
|
2340
2343
|
rotationScale: .9
|
|
2341
2344
|
},
|
|
2342
2345
|
RightFoot: { rigKey: null }
|
|
2343
|
-
},
|
|
2346
|
+
}, _r = {
|
|
2344
2347
|
Root: "Hips",
|
|
2345
2348
|
root: "Hips",
|
|
2346
2349
|
c_spine0: "Spine",
|
|
@@ -2383,22 +2386,22 @@ var q = Math.PI / 180, xr = {
|
|
|
2383
2386
|
mixamorig_RightLeg: "RightLowerLeg",
|
|
2384
2387
|
mixamorig_RightFoot: "RightFoot"
|
|
2385
2388
|
};
|
|
2386
|
-
function
|
|
2387
|
-
return
|
|
2389
|
+
function vr(e) {
|
|
2390
|
+
return gr[e] ? e : _r[e] ?? e;
|
|
2388
2391
|
}
|
|
2389
|
-
function
|
|
2390
|
-
let n =
|
|
2392
|
+
function yr(e, t) {
|
|
2393
|
+
let n = gr[vr(e)];
|
|
2391
2394
|
if (!n || !n.rigKey) return null;
|
|
2392
2395
|
let r = t[n.rigKey];
|
|
2393
2396
|
if (!r) return null;
|
|
2394
|
-
let i =
|
|
2397
|
+
let i = br(n.rigKey === "hips" && "rotation" in r ? r.rotation : r, n.rotationScale);
|
|
2395
2398
|
return {
|
|
2396
|
-
x:
|
|
2397
|
-
y:
|
|
2398
|
-
z:
|
|
2399
|
+
x: xr(i.x, n.rotationLimits?.x),
|
|
2400
|
+
y: xr(i.y, n.rotationLimits?.y),
|
|
2401
|
+
z: xr(i.z, n.rotationLimits?.z)
|
|
2399
2402
|
};
|
|
2400
2403
|
}
|
|
2401
|
-
function
|
|
2404
|
+
function br(e, t = 1) {
|
|
2402
2405
|
return typeof t == "number" ? {
|
|
2403
2406
|
x: e.x * t,
|
|
2404
2407
|
y: e.y * t,
|
|
@@ -2409,12 +2412,12 @@ function Ar(e, t = 1) {
|
|
|
2409
2412
|
z: e.z * (t.z ?? 1)
|
|
2410
2413
|
};
|
|
2411
2414
|
}
|
|
2412
|
-
function
|
|
2415
|
+
function xr(e, t) {
|
|
2413
2416
|
return t ? Math.min(t.max, Math.max(t.min, e)) : e;
|
|
2414
2417
|
}
|
|
2415
2418
|
//#endregion
|
|
2416
2419
|
//#region src/garment/poseApplication.ts
|
|
2417
|
-
var
|
|
2420
|
+
var Sr = 12, Cr = new b.Quaternion(), X = new b.Quaternion(), wr = new b.Quaternion(), Tr = new b.Vector3(), Er = new b.Vector3(), Dr = new b.Vector3(), Or = new b.Vector3(), kr = new b.Vector3(), Ar = new b.Vector3(), jr = new b.Vector3(), Mr = new b.Vector3(), Nr = new b.Vector3(), Pr = new b.Quaternion(), Fr = new b.Quaternion(), Ir = new b.Quaternion(), Lr = new b.Quaternion(), Rr = {
|
|
2418
2421
|
Hips: [
|
|
2419
2422
|
"Spine",
|
|
2420
2423
|
"Chest",
|
|
@@ -2433,7 +2436,7 @@ var Mr = 12, Nr = new l.Quaternion(), J = new l.Quaternion(), Pr = new l.Quatern
|
|
|
2433
2436
|
LeftLowerLeg: ["LeftFoot"],
|
|
2434
2437
|
RightUpperLeg: ["RightLowerLeg"],
|
|
2435
2438
|
RightLowerLeg: ["RightFoot"]
|
|
2436
|
-
},
|
|
2439
|
+
}, zr = {
|
|
2437
2440
|
Hips: [
|
|
2438
2441
|
["LeftUpperLeg", "RightUpperLeg"],
|
|
2439
2442
|
["LeftShoulder", "RightShoulder"],
|
|
@@ -2449,104 +2452,104 @@ var Mr = 12, Nr = new l.Quaternion(), J = new l.Quaternion(), Pr = new l.Quatern
|
|
|
2449
2452
|
["LeftUpperArm", "RightUpperArm"],
|
|
2450
2453
|
["LeftUpperLeg", "RightUpperLeg"]
|
|
2451
2454
|
]
|
|
2452
|
-
},
|
|
2453
|
-
Hips: [
|
|
2454
|
-
Spine: [
|
|
2455
|
-
Chest: [
|
|
2455
|
+
}, Br = {
|
|
2456
|
+
Hips: [U.RIGHT_HIP, U.LEFT_HIP],
|
|
2457
|
+
Spine: [U.RIGHT_SHOULDER, U.LEFT_SHOULDER],
|
|
2458
|
+
Chest: [U.RIGHT_SHOULDER, U.LEFT_SHOULDER]
|
|
2456
2459
|
};
|
|
2457
|
-
function
|
|
2460
|
+
function Vr(e) {
|
|
2458
2461
|
return e.startsWith("Left") ? `Right${e.slice(4)}` : e.startsWith("Right") ? `Left${e.slice(5)}` : e;
|
|
2459
2462
|
}
|
|
2460
|
-
function
|
|
2461
|
-
let i =
|
|
2463
|
+
function Hr(e, t, n, r) {
|
|
2464
|
+
let i = Rr[e];
|
|
2462
2465
|
if (!i) return !1;
|
|
2463
2466
|
for (let e = 0; e < i.length; e += 1) {
|
|
2464
2467
|
let a = n.get(i[e])?.[0];
|
|
2465
|
-
if (!(!a || a.bone === t.bone || !t.restWorldPosition || !t.restParentWorldQuaternion || !a.restWorldPosition) && (r.copy(a.restWorldPosition).sub(t.restWorldPosition), !(r.lengthSq() < 1e-6))) return r.applyQuaternion(
|
|
2468
|
+
if (!(!a || a.bone === t.bone || !t.restWorldPosition || !t.restParentWorldQuaternion || !a.restWorldPosition) && (r.copy(a.restWorldPosition).sub(t.restWorldPosition), !(r.lengthSq() < 1e-6))) return r.applyQuaternion(Pr.copy(t.restParentWorldQuaternion).invert()).normalize(), !0;
|
|
2466
2469
|
}
|
|
2467
2470
|
return !1;
|
|
2468
2471
|
}
|
|
2469
|
-
function
|
|
2470
|
-
return e in
|
|
2472
|
+
function Ur(e) {
|
|
2473
|
+
return e in zr;
|
|
2471
2474
|
}
|
|
2472
|
-
function
|
|
2473
|
-
let i =
|
|
2475
|
+
function Wr(e, t, n, r) {
|
|
2476
|
+
let i = zr[e];
|
|
2474
2477
|
if (!i || !t.restParentWorldQuaternion) return !1;
|
|
2475
2478
|
for (let e = 0; e < i.length; e += 1) {
|
|
2476
2479
|
let [a, o] = i[e], s = n.get(a)?.[0], c = n.get(o)?.[0];
|
|
2477
|
-
if (!(!s?.restWorldPosition || !c?.restWorldPosition) && (r.copy(c.restWorldPosition).sub(s.restWorldPosition).applyQuaternion(
|
|
2480
|
+
if (!(!s?.restWorldPosition || !c?.restWorldPosition) && (r.copy(c.restWorldPosition).sub(s.restWorldPosition).applyQuaternion(Pr.copy(t.restParentWorldQuaternion).invert()), !(r.lengthSq() < 1e-6))) return r.normalize(), !0;
|
|
2478
2481
|
}
|
|
2479
2482
|
return !1;
|
|
2480
2483
|
}
|
|
2481
|
-
function
|
|
2482
|
-
let a =
|
|
2483
|
-
return !a || !
|
|
2484
|
+
function Gr(e, t, n, r, i) {
|
|
2485
|
+
let a = Br[e];
|
|
2486
|
+
return !a || !Lt(a[0], a[1], t, i, n) ? !1 : (i.applyQuaternion(Ir.copy(r).invert()).normalize(), i.lengthSq() >= 1e-6);
|
|
2484
2487
|
}
|
|
2485
|
-
function
|
|
2486
|
-
if (!
|
|
2487
|
-
|
|
2488
|
-
let c = Math.atan2(
|
|
2489
|
-
return
|
|
2488
|
+
function Kr(e, t, n, r, i, a, o, s) {
|
|
2489
|
+
if (!Wr(e, t, n, Or) || !Gr(e, r, i, a, kr) || (Ar.copy(Or).applyQuaternion(X), jr.copy(Ar).projectOnPlane(Dr).normalize(), Mr.copy(kr).projectOnPlane(Dr).normalize(), jr.lengthSq() < 1e-6 || Mr.lengthSq() < 1e-6)) return s.copy(X), !1;
|
|
2490
|
+
Nr.crossVectors(jr, Mr);
|
|
2491
|
+
let c = Math.atan2(Dr.dot(Nr), jr.dot(Mr));
|
|
2492
|
+
return Lr.setFromAxisAngle(Dr, c), s.copy(Lr).multiply(X), o !== void 0 && s.slerp(wr, 1 - o), !0;
|
|
2490
2493
|
}
|
|
2491
|
-
function
|
|
2492
|
-
let e =
|
|
2493
|
-
return
|
|
2494
|
+
function qr() {
|
|
2495
|
+
let e = i(new b.Timer()), t = i(/* @__PURE__ */ new Map());
|
|
2496
|
+
return r(() => ({
|
|
2494
2497
|
clockRef: e,
|
|
2495
2498
|
prevRotationsRef: t
|
|
2496
2499
|
}), []);
|
|
2497
2500
|
}
|
|
2498
|
-
function
|
|
2501
|
+
function Jr(e, t, n, r = {}) {
|
|
2499
2502
|
if (t.size === 0) return;
|
|
2500
2503
|
let { coordinateSpace: i = "normalized", excludeBones: a } = r;
|
|
2501
2504
|
n.clockRef.current.update();
|
|
2502
|
-
let o = n.clockRef.current.getDelta(), s = Math.min(1, o *
|
|
2505
|
+
let o = n.clockRef.current.getDelta(), s = Math.min(1, o * Sr);
|
|
2503
2506
|
for (let [n, r] of t) {
|
|
2504
|
-
let o =
|
|
2507
|
+
let o = vr(n);
|
|
2505
2508
|
if (a?.has(o)) continue;
|
|
2506
|
-
let c =
|
|
2509
|
+
let c = Vr(o);
|
|
2507
2510
|
if (o !== n && t.has(o)) continue;
|
|
2508
|
-
let l =
|
|
2511
|
+
let l = Vt(c);
|
|
2509
2512
|
if (!l) continue;
|
|
2510
|
-
let u = l &&
|
|
2513
|
+
let u = l && Rt(c, e, Tr, i);
|
|
2511
2514
|
if (!u) continue;
|
|
2512
|
-
let d = !1, f =
|
|
2515
|
+
let d = !1, f = zt(c);
|
|
2513
2516
|
for (let n of r) {
|
|
2514
2517
|
let { bone: r, restQuaternion: a } = n;
|
|
2515
|
-
if (u &&
|
|
2518
|
+
if (u && Hr(o, n, t, Er)) r.parent ? (r.parent.updateWorldMatrix(!0, !1), r.parent.getWorldQuaternion(Fr)) : (r.updateWorldMatrix(!0, !1), Fr.identity()), Dr.copy(Tr).applyQuaternion(Ir.copy(Fr).invert()).normalize(), X.setFromUnitVectors(Er, Dr), Ur(o) && Kr(o, n, t, e, i, Fr, f, X) || f !== void 0 && X.slerp(wr, 1 - f), Cr.copy(X).multiply(a);
|
|
2516
2519
|
else {
|
|
2517
|
-
if (d ||=
|
|
2518
|
-
|
|
2520
|
+
if (d ||= Bt(c, e, X, i), !d) continue;
|
|
2521
|
+
Cr.copy(a).multiply(X);
|
|
2519
2522
|
}
|
|
2520
|
-
r.quaternion.slerp(
|
|
2523
|
+
r.quaternion.slerp(Cr, s), r.updateWorldMatrix(!1, !0);
|
|
2521
2524
|
}
|
|
2522
2525
|
}
|
|
2523
2526
|
}
|
|
2524
|
-
function
|
|
2525
|
-
|
|
2527
|
+
function Yr(e, t) {
|
|
2528
|
+
Jn(e), t.prevRotationsRef.current.clear();
|
|
2526
2529
|
}
|
|
2527
|
-
function
|
|
2528
|
-
let i = Math.min(1, n *
|
|
2530
|
+
function Xr(e, t, n, r) {
|
|
2531
|
+
let i = Math.min(1, n * Sr);
|
|
2529
2532
|
for (let [n, a] of e) {
|
|
2530
|
-
let e =
|
|
2533
|
+
let e = vr(n);
|
|
2531
2534
|
if (!(r && !r.has(e))) for (let { bone: e, restQuaternion: n } of a) e.quaternion.slerp(n, t * i);
|
|
2532
2535
|
}
|
|
2533
2536
|
}
|
|
2534
2537
|
//#endregion
|
|
2535
2538
|
//#region src/pose/yawDirectionStabilizer.ts
|
|
2536
|
-
var
|
|
2537
|
-
function
|
|
2538
|
-
return Math.abs(e) <
|
|
2539
|
+
var Zr = 50 * Math.PI / 180, Qr = 30 * Math.PI / 180, $r = 3;
|
|
2540
|
+
function ei(e) {
|
|
2541
|
+
return Math.abs(e) < Zr ? "unknown" : e >= 0 ? "positive" : "negative";
|
|
2539
2542
|
}
|
|
2540
|
-
function
|
|
2543
|
+
function ti(e) {
|
|
2541
2544
|
return e === "positive" ? 1 : e === "negative" ? -1 : 0;
|
|
2542
2545
|
}
|
|
2543
|
-
var
|
|
2546
|
+
var ni = class {
|
|
2544
2547
|
_committedYawDirection = "unknown";
|
|
2545
2548
|
_pendingYawDirection = "unknown";
|
|
2546
2549
|
_pendingCount = 0;
|
|
2547
2550
|
update(e, t) {
|
|
2548
|
-
let n = Math.abs(t), r =
|
|
2549
|
-
return e === "back" || n <
|
|
2551
|
+
let n = Math.abs(t), r = ei(t);
|
|
2552
|
+
return e === "back" || n < Qr ? (this.reset(), this._buildState(r, "unknown", t)) : this._committedYawDirection === "unknown" ? r === "unknown" ? (this._clearPending(), this._buildState(r, "unknown", t)) : (this._pendingYawDirection === r ? this._pendingCount += 1 : (this._pendingYawDirection = r, this._pendingCount = 1), this._pendingCount >= $r ? (this._committedYawDirection = this._pendingYawDirection, this._clearPending(), this._buildState(r, this._committedYawDirection, n * ti(this._committedYawDirection))) : this._buildState(r, r, t)) : this._buildState(r, this._committedYawDirection, n * ti(this._committedYawDirection));
|
|
2550
2553
|
}
|
|
2551
2554
|
reset() {
|
|
2552
2555
|
this._committedYawDirection = "unknown", this._clearPending();
|
|
@@ -2564,41 +2567,41 @@ var fi = class {
|
|
|
2564
2567
|
_clearPending() {
|
|
2565
2568
|
this._pendingYawDirection = "unknown", this._pendingCount = 0;
|
|
2566
2569
|
}
|
|
2567
|
-
},
|
|
2568
|
-
function
|
|
2570
|
+
}, ri = 80 * Math.PI / 180, ii = 100 * Math.PI / 180, ai = 25 * Math.PI / 180, oi = 8, si = 5, ci = 5, li = 5, ui = .5, di = .3, fi = .2, pi = 5, mi = 8;
|
|
2571
|
+
function hi(e) {
|
|
2569
2572
|
return e?.visibility ?? 0;
|
|
2570
2573
|
}
|
|
2571
|
-
function
|
|
2574
|
+
function gi(e) {
|
|
2572
2575
|
if (!e || e.length < 33) return {
|
|
2573
2576
|
shoulderOrder: !1,
|
|
2574
2577
|
noseVisible: !1,
|
|
2575
2578
|
earSymmetry: !1
|
|
2576
2579
|
};
|
|
2577
|
-
let t = e[
|
|
2580
|
+
let t = e[U.LEFT_SHOULDER], n = e[U.RIGHT_SHOULDER], r = e[U.NOSE], i = e[U.LEFT_EAR], a = e[U.RIGHT_EAR], o = t.x < n.x, s = hi(r) > ui, c = hi(i), l = hi(a);
|
|
2578
2581
|
return {
|
|
2579
2582
|
shoulderOrder: o,
|
|
2580
2583
|
noseVisible: s,
|
|
2581
|
-
earSymmetry: Math.abs(c - l) <
|
|
2584
|
+
earSymmetry: Math.abs(c - l) < di && Math.max(c, l) > fi
|
|
2582
2585
|
};
|
|
2583
2586
|
}
|
|
2584
|
-
function
|
|
2587
|
+
function _i(e) {
|
|
2585
2588
|
let t = 0;
|
|
2586
2589
|
return e.shoulderOrder && (t += 1), e.noseVisible && (t += 1), e.earSymmetry && (t += 1), t >= 2;
|
|
2587
2590
|
}
|
|
2588
|
-
function
|
|
2589
|
-
return e <
|
|
2591
|
+
function vi(e) {
|
|
2592
|
+
return e < ri ? "front" : e < ii ? "side" : "back";
|
|
2590
2593
|
}
|
|
2591
|
-
var
|
|
2594
|
+
var yi = class {
|
|
2592
2595
|
_zone = "front";
|
|
2593
2596
|
_consecutiveCount = 0;
|
|
2594
2597
|
_lastRawZone = "front";
|
|
2595
2598
|
_2dFrontCount = 0;
|
|
2596
2599
|
_2dBackCount = 0;
|
|
2597
2600
|
_2dIsFront = !0;
|
|
2598
|
-
_yawDirectionStabilizer = new
|
|
2601
|
+
_yawDirectionStabilizer = new ni();
|
|
2599
2602
|
update(e, t, n) {
|
|
2600
|
-
let r = t ?? 0, i = n ?? 0, a = Math.abs(i) >
|
|
2601
|
-
t === void 0 ? o = this._resolve2dFallback(e) : (o =
|
|
2603
|
+
let r = t ?? 0, i = n ?? 0, a = Math.abs(i) > ai, o;
|
|
2604
|
+
t === void 0 ? o = this._resolve2dFallback(e) : (o = vi(Math.abs(t)), o === "front" && this._zone !== "front" && (_i(gi(e)) || (o = "back"))), this._applyHysteresis(o);
|
|
2602
2605
|
let s = t === void 0 ? null : this._yawDirectionStabilizer.update(this._zone, r);
|
|
2603
2606
|
return t === void 0 && this._yawDirectionStabilizer.reset(), {
|
|
2604
2607
|
zone: this._zone,
|
|
@@ -2616,7 +2619,7 @@ var ki = class {
|
|
|
2616
2619
|
this._zone = "front", this._consecutiveCount = 0, this._lastRawZone = "front", this._2dFrontCount = 0, this._2dBackCount = 0, this._2dIsFront = !0, this._yawDirectionStabilizer.reset();
|
|
2617
2620
|
}
|
|
2618
2621
|
_resolve2dFallback(e) {
|
|
2619
|
-
return
|
|
2622
|
+
return _i(gi(e)) ? (this._2dFrontCount += 1, this._2dBackCount = 0) : (this._2dBackCount += 1, this._2dFrontCount = 0), this._2dIsFront ? this._2dBackCount >= pi && (this._2dIsFront = !1) : this._2dFrontCount >= mi && (this._2dIsFront = !0), this._2dIsFront ? "front" : "back";
|
|
2620
2623
|
}
|
|
2621
2624
|
_applyHysteresis(e) {
|
|
2622
2625
|
e === this._lastRawZone ? this._consecutiveCount += 1 : (this._lastRawZone = e, this._consecutiveCount = 1);
|
|
@@ -2624,18 +2627,18 @@ var ki = class {
|
|
|
2624
2627
|
t !== null && this._consecutiveCount >= t && (this._zone = e);
|
|
2625
2628
|
}
|
|
2626
2629
|
_getTransitionThreshold(e, t) {
|
|
2627
|
-
return e === t ? null : e === "front" && t === "side" || e === "front" && t === "back" ?
|
|
2630
|
+
return e === t ? null : e === "front" && t === "side" || e === "front" && t === "back" ? oi : e === "side" && t === "back" ? si : e === "back" && t === "side" ? ci : e === "side" && t === "front" ? li : e === "back" && t === "front" ? ci : oi;
|
|
2628
2631
|
}
|
|
2629
|
-
},
|
|
2630
|
-
function
|
|
2631
|
-
return e >= 0 ?
|
|
2632
|
+
}, bi = Math.PI / 2;
|
|
2633
|
+
function xi(e) {
|
|
2634
|
+
return e >= 0 ? bi : -bi;
|
|
2632
2635
|
}
|
|
2633
|
-
var
|
|
2636
|
+
var Si = class {
|
|
2634
2637
|
_isFrozen = !1;
|
|
2635
2638
|
_frozenYaw = null;
|
|
2636
|
-
update(e, t
|
|
2637
|
-
let
|
|
2638
|
-
return this._isFrozen ? e !== "back" &&
|
|
2639
|
+
update(e, t) {
|
|
2640
|
+
let n = Math.abs(t);
|
|
2641
|
+
return this._isFrozen ? e !== "back" && n < bi && this.reset() : e !== "front" && n >= bi && (this._isFrozen = !0, this._frozenYaw = xi(t)), {
|
|
2639
2642
|
isFrozen: this._isFrozen,
|
|
2640
2643
|
frozenYaw: this._frozenYaw
|
|
2641
2644
|
};
|
|
@@ -2646,88 +2649,109 @@ var Mi = class {
|
|
|
2646
2649
|
};
|
|
2647
2650
|
//#endregion
|
|
2648
2651
|
//#region src/pose/coordinateTransform.ts
|
|
2649
|
-
function
|
|
2652
|
+
function Ci(e, t) {
|
|
2650
2653
|
return typeof e == "boolean" ? {
|
|
2651
2654
|
mirrorX: e,
|
|
2652
2655
|
sourceWidth: 0,
|
|
2653
2656
|
sourceHeight: 0,
|
|
2654
|
-
target: t ?? new
|
|
2657
|
+
target: t ?? new b.Vector3()
|
|
2655
2658
|
} : {
|
|
2656
2659
|
mirrorX: e.mirrorX ?? !1,
|
|
2657
2660
|
sourceWidth: e.sourceWidth ?? 0,
|
|
2658
2661
|
sourceHeight: e.sourceHeight ?? 0,
|
|
2659
|
-
target: e.target ?? t ?? new
|
|
2662
|
+
target: e.target ?? t ?? new b.Vector3()
|
|
2660
2663
|
};
|
|
2661
2664
|
}
|
|
2662
|
-
function
|
|
2663
|
-
let a =
|
|
2665
|
+
function Z(e, t, n, r = !1, i) {
|
|
2666
|
+
let a = Ci(r, i), o = et(t, n, a.sourceWidth || t, a.sourceHeight || n), s = a.mirrorX ? 1 - e.x : e.x, c = o.x + s * o.width, l = o.y + e.y * o.height, u = c - t * .5, d = n * .5 - l, f = -(e.z ?? 0) * o.width * .5;
|
|
2664
2667
|
return a.target.set(u, d, f);
|
|
2665
2668
|
}
|
|
2669
|
+
function wi(e, t, n, r, i = !1, a) {
|
|
2670
|
+
return Z({
|
|
2671
|
+
x: (e.x + t.x) / 2,
|
|
2672
|
+
y: (e.y + t.y) / 2,
|
|
2673
|
+
z: ((e.z ?? 0) + (t.z ?? 0)) / 2,
|
|
2674
|
+
visibility: Math.min(e.visibility ?? 0, t.visibility ?? 0)
|
|
2675
|
+
}, n, r, i, a);
|
|
2676
|
+
}
|
|
2677
|
+
function Ti(e, t, n, r) {
|
|
2678
|
+
let i = (e.x - t.x) * n, a = (e.y - t.y) * r;
|
|
2679
|
+
return Math.sqrt(i * i + a * a);
|
|
2680
|
+
}
|
|
2666
2681
|
//#endregion
|
|
2667
2682
|
//#region src/garment/fitMotion.ts
|
|
2668
|
-
var
|
|
2669
|
-
function
|
|
2670
|
-
let r = Math.min(Math.abs(n),
|
|
2683
|
+
var Ei = .45, Di = .72, Oi = 1.02, ki = 1.1, Ai = Math.PI / 6, ji = 1e-4, Mi = ji * ji, Ni = .35, Pi = .6, Fi = new b.Vector3(), Ii = new b.Vector3(), Q = new b.Vector3(), $ = new b.Vector3(), Li = new b.Vector3(), Ri = new b.Vector3(), zi = new b.Matrix4();
|
|
2684
|
+
function Bi(e, t, n) {
|
|
2685
|
+
let r = Math.min(Math.abs(n), ki), i = 1 / Math.max(Math.cos(r), Ei) * e, a = t * Di;
|
|
2671
2686
|
return Math.max(i, a, e);
|
|
2672
2687
|
}
|
|
2673
|
-
function
|
|
2674
|
-
let i =
|
|
2688
|
+
function Vi({ projectedShoulderWidth: e, projectedTorsoHeight: t, bodyYaw: n, worldLandmarks: r }) {
|
|
2689
|
+
let i = Bi(e, t, n), a = Gi(t, r);
|
|
2675
2690
|
if (!a) return i;
|
|
2676
|
-
let o =
|
|
2691
|
+
let o = Ji((Math.abs(n) - Ni) / Pi, 0, 1);
|
|
2677
2692
|
return i + (Math.max(i, a) - i) * o;
|
|
2678
2693
|
}
|
|
2679
|
-
function
|
|
2680
|
-
return
|
|
2694
|
+
function Hi(e) {
|
|
2695
|
+
return e ? Ji(e.hips.rotation.y * .85 + e.chest.y * .15, -ki, ki) : 0;
|
|
2696
|
+
}
|
|
2697
|
+
function Ui(e, t, n) {
|
|
2698
|
+
let r = e.x <= t.x ? e : t, i = e.x <= t.x ? t : e, a = i.x - r.x;
|
|
2699
|
+
if (a <= ji) return 0;
|
|
2700
|
+
let o = -(i.y - r.y);
|
|
2701
|
+
return Ji(Math.atan2(o, a) * Ji(1 - Math.abs(n) / ki, 0, 1), -Ai, Ai);
|
|
2702
|
+
}
|
|
2703
|
+
function Wi({ leftShoulder: e, rightShoulder: t, leftHip: n, rightHip: r }, i = new b.Quaternion()) {
|
|
2704
|
+
return Fi.copy(e).add(t).multiplyScalar(.5), Ii.copy(n).add(r).multiplyScalar(.5), Q.copy(t).sub(e), Q.lengthSq() <= Mi || (Q.normalize(), $.copy(Fi).sub(Ii), Li.copy(Q).multiplyScalar($.dot(Q)), $.sub(Li), $.lengthSq() <= Mi) || ($.normalize(), Ri.crossVectors(Q, $), Ri.lengthSq() <= Mi) ? null : (Ri.normalize(), $.crossVectors(Ri, Q).normalize(), zi.makeBasis(Q, $, Ri), i.setFromRotationMatrix(zi));
|
|
2681
2705
|
}
|
|
2682
|
-
function
|
|
2683
|
-
if (!t || t.length <=
|
|
2684
|
-
let n = t[
|
|
2706
|
+
function Gi(e, t) {
|
|
2707
|
+
if (!t || t.length <= U.RIGHT_HIP || e <= ji) return null;
|
|
2708
|
+
let n = t[U.LEFT_SHOULDER], r = t[U.RIGHT_SHOULDER], i = t[U.LEFT_HIP], a = t[U.RIGHT_HIP];
|
|
2685
2709
|
if (!n || !r || !i || !a) return null;
|
|
2686
|
-
let o =
|
|
2687
|
-
return o <=
|
|
2710
|
+
let o = qi(n, r), s = qi(Ki(n, r), Ki(i, a));
|
|
2711
|
+
return o <= ji || s <= ji ? null : e * Ji(o / s, Di, Oi);
|
|
2688
2712
|
}
|
|
2689
|
-
function
|
|
2713
|
+
function Ki(e, t) {
|
|
2690
2714
|
return {
|
|
2691
2715
|
x: (e.x + t.x) * .5,
|
|
2692
2716
|
y: (e.y + t.y) * .5,
|
|
2693
2717
|
z: ((e.z ?? 0) + (t.z ?? 0)) * .5
|
|
2694
2718
|
};
|
|
2695
2719
|
}
|
|
2696
|
-
function
|
|
2720
|
+
function qi(e, t) {
|
|
2697
2721
|
let n = e.x - t.x, r = e.y - t.y, i = (e.z ?? 0) - (t.z ?? 0);
|
|
2698
2722
|
return Math.sqrt(n * n + r * r + i * i);
|
|
2699
2723
|
}
|
|
2700
|
-
function
|
|
2724
|
+
function Ji(e, t, n) {
|
|
2701
2725
|
return Math.max(t, Math.min(n, e));
|
|
2702
2726
|
}
|
|
2703
2727
|
//#endregion
|
|
2704
2728
|
//#region src/garment/trackedModelTransform.ts
|
|
2705
|
-
var
|
|
2706
|
-
[
|
|
2707
|
-
|
|
2708
|
-
[
|
|
2709
|
-
],
|
|
2710
|
-
[
|
|
2711
|
-
[
|
|
2712
|
-
[
|
|
2729
|
+
var Yi = 1e-4, Xi = .15, Zi = 8, Qi = 1e-4, $i = 1.45, ea = .35, ta = 10, na = .18, ra = .55, ia = 6, aa = .3, oa = .08, sa = .05, ca = 1.35, la = .7, ua = new b.Quaternion(), da = new b.Vector3(), fa = [
|
|
2730
|
+
[U.LEFT_EAR, U.RIGHT_EAR],
|
|
2731
|
+
U.NOSE,
|
|
2732
|
+
[U.LEFT_SHOULDER, U.RIGHT_SHOULDER]
|
|
2733
|
+
], pa = [
|
|
2734
|
+
[U.LEFT_ANKLE, U.RIGHT_ANKLE],
|
|
2735
|
+
[U.LEFT_HEEL, U.RIGHT_HEEL],
|
|
2736
|
+
[U.LEFT_FOOT_INDEX, U.RIGHT_FOOT_INDEX]
|
|
2713
2737
|
];
|
|
2714
|
-
function
|
|
2738
|
+
function ma(e, t, n) {
|
|
2715
2739
|
return Math.max(t, Math.min(n, e));
|
|
2716
2740
|
}
|
|
2717
|
-
function
|
|
2741
|
+
function ha() {
|
|
2718
2742
|
return {
|
|
2719
|
-
leftShoulder: new
|
|
2720
|
-
rightShoulder: new
|
|
2721
|
-
leftHip: new
|
|
2722
|
-
rightHip: new
|
|
2723
|
-
shoulderCenter: new
|
|
2724
|
-
hipCenter: new
|
|
2725
|
-
bodyTop: new
|
|
2726
|
-
bodyBottom: new
|
|
2727
|
-
anchor: new
|
|
2728
|
-
scaledAnchor: new
|
|
2729
|
-
position: new
|
|
2730
|
-
scale: new
|
|
2743
|
+
leftShoulder: new b.Vector3(),
|
|
2744
|
+
rightShoulder: new b.Vector3(),
|
|
2745
|
+
leftHip: new b.Vector3(),
|
|
2746
|
+
rightHip: new b.Vector3(),
|
|
2747
|
+
shoulderCenter: new b.Vector3(),
|
|
2748
|
+
hipCenter: new b.Vector3(),
|
|
2749
|
+
bodyTop: new b.Vector3(),
|
|
2750
|
+
bodyBottom: new b.Vector3(),
|
|
2751
|
+
anchor: new b.Vector3(),
|
|
2752
|
+
scaledAnchor: new b.Vector3(),
|
|
2753
|
+
position: new b.Vector3(),
|
|
2754
|
+
scale: new b.Vector3(1, 1, 1),
|
|
2731
2755
|
stabilizedBodyHeightScale: null,
|
|
2732
2756
|
missingBodyHeightFrames: 0,
|
|
2733
2757
|
smoothedGlobalScale: 1,
|
|
@@ -2736,85 +2760,88 @@ function va() {
|
|
|
2736
2760
|
previousDepthProxy: 0,
|
|
2737
2761
|
scaleVelocity: 0,
|
|
2738
2762
|
smoothedXDeviation: 1,
|
|
2739
|
-
smoothedAnchor: new
|
|
2763
|
+
smoothedAnchor: new b.Vector3(),
|
|
2740
2764
|
hasSmoothedAnchor: !1
|
|
2741
2765
|
};
|
|
2742
2766
|
}
|
|
2743
|
-
function
|
|
2767
|
+
function ga(e, t, n, r, i, a = {}) {
|
|
2744
2768
|
if (t.length < 33) return !1;
|
|
2745
|
-
|
|
2769
|
+
Z(t[U.LEFT_SHOULDER], n, r, {
|
|
2746
2770
|
mirrorX: !0,
|
|
2747
2771
|
sourceWidth: a.sourceWidth,
|
|
2748
2772
|
sourceHeight: a.sourceHeight,
|
|
2749
2773
|
target: i.leftShoulder
|
|
2750
|
-
}),
|
|
2774
|
+
}), Z(t[U.RIGHT_SHOULDER], n, r, {
|
|
2751
2775
|
mirrorX: !0,
|
|
2752
2776
|
sourceWidth: a.sourceWidth,
|
|
2753
2777
|
sourceHeight: a.sourceHeight,
|
|
2754
2778
|
target: i.rightShoulder
|
|
2755
|
-
}),
|
|
2779
|
+
}), Z(t[U.LEFT_HIP], n, r, {
|
|
2756
2780
|
mirrorX: !0,
|
|
2757
2781
|
sourceWidth: a.sourceWidth,
|
|
2758
2782
|
sourceHeight: a.sourceHeight,
|
|
2759
2783
|
target: i.leftHip
|
|
2760
|
-
}),
|
|
2784
|
+
}), Z(t[U.RIGHT_HIP], n, r, {
|
|
2761
2785
|
mirrorX: !0,
|
|
2762
2786
|
sourceWidth: a.sourceWidth,
|
|
2763
2787
|
sourceHeight: a.sourceHeight,
|
|
2764
2788
|
target: i.rightHip
|
|
2765
2789
|
}), i.shoulderCenter.copy(i.leftShoulder).add(i.rightShoulder).multiplyScalar(.5), i.hipCenter.copy(i.leftHip).add(i.rightHip).multiplyScalar(.5);
|
|
2766
|
-
let o =
|
|
2790
|
+
let o = Wi({
|
|
2767
2791
|
leftShoulder: i.rightShoulder,
|
|
2768
2792
|
rightShoulder: i.leftShoulder,
|
|
2769
2793
|
leftHip: i.rightHip,
|
|
2770
2794
|
rightHip: i.leftHip
|
|
2771
|
-
},
|
|
2795
|
+
}, ua), s = o ? va(o) : 0, c = xa(a.bodyYaw, s);
|
|
2772
2796
|
i.effectiveYaw = c;
|
|
2773
|
-
let
|
|
2774
|
-
projectedShoulderWidth:
|
|
2775
|
-
projectedTorsoHeight:
|
|
2797
|
+
let l = Ca(i.leftShoulder, i.rightShoulder), u = Ca(i.shoulderCenter, i.hipCenter), d = Vi({
|
|
2798
|
+
projectedShoulderWidth: l,
|
|
2799
|
+
projectedTorsoHeight: u,
|
|
2776
2800
|
bodyYaw: c,
|
|
2777
2801
|
worldLandmarks: a.worldLandmarks
|
|
2778
|
-
}),
|
|
2779
|
-
return i.smoothedXDeviation =
|
|
2802
|
+
}), f = u / Math.max(e.referenceTorsoHeight, Yi), p = Sa(t, n, r, u, i, a), m = ya(p === null ? null : p / Math.max(e.trackingHeight, Yi), i), h = m !== null && f > Yi ? ma(m, f * la, f * ca) : m, g = ba(ma(h === null ? f : f * .55 + h * .45, Xi, Zi) * (a.scaleMultiplier ?? 1), i, u), _ = .1, v = e.referenceWidth / Math.max(e.referenceTorsoHeight, Yi), y = u > Yi ? d / u : v, x = ma(v > Yi ? y / v : 1, 1 - _, 1 + _);
|
|
2803
|
+
return i.smoothedXDeviation = b.MathUtils.lerp(i.smoothedXDeviation, x, .35), i.scale.set(g * i.smoothedXDeviation * (a.scaleX ?? 1), g * (a.scaleY ?? 1), g * (a.scaleZ ?? 1)), i.anchor.copy(i.shoulderCenter).add(i.hipCenter).multiplyScalar(.5), i.hasSmoothedAnchor ? i.smoothedAnchor.lerp(i.anchor, .4) : (i.smoothedAnchor.copy(i.anchor), i.hasSmoothedAnchor = !0), i.scaledAnchor.set(e.anchor.x * g, e.anchor.y * g, e.anchor.z * g), i.position.copy(i.smoothedAnchor).sub(i.scaledAnchor), i.position.z += a.depthOffset ?? 0, !0;
|
|
2780
2804
|
}
|
|
2781
|
-
function
|
|
2782
|
-
|
|
2805
|
+
function _a(e, t) {
|
|
2806
|
+
e.position.copy(t.position), e.scale.copy(t.scale);
|
|
2783
2807
|
}
|
|
2784
|
-
function
|
|
2785
|
-
return
|
|
2808
|
+
function va(e) {
|
|
2809
|
+
return da.set(0, 0, 1).applyQuaternion(e), da.y = 0, da.lengthSq() <= Qi ? 0 : (da.normalize(), Math.atan2(da.x, da.z));
|
|
2810
|
+
}
|
|
2811
|
+
function ya(e, t) {
|
|
2812
|
+
return e === null ? t.stabilizedBodyHeightScale === null ? (t.missingBodyHeightFrames = 0, null) : (t.missingBodyHeightFrames += 1, t.missingBodyHeightFrames > ta ? (t.stabilizedBodyHeightScale = null, null) : t.stabilizedBodyHeightScale) : (t.missingBodyHeightFrames = 0, t.stabilizedBodyHeightScale = t.stabilizedBodyHeightScale === null ? e : b.MathUtils.lerp(t.stabilizedBodyHeightScale, e, ea), t.stabilizedBodyHeightScale);
|
|
2786
2813
|
}
|
|
2787
|
-
function
|
|
2814
|
+
function ba(e, t, n) {
|
|
2788
2815
|
if (!t.hasSmoothedGlobalScale) return t.smoothedGlobalScale = e, t.previousDepthProxy = n, t.scaleVelocity = 0, t.hasSmoothedGlobalScale = !0, e;
|
|
2789
2816
|
let r = t.previousDepthProxy, i = 1;
|
|
2790
|
-
r >
|
|
2817
|
+
r > sa && n > sa && (i = ma(n / r, 1 - oa, 1 + oa)), t.previousDepthProxy = n;
|
|
2791
2818
|
let a = t.smoothedGlobalScale * i, o = a > 0 ? Math.abs(e - a) / a : 0;
|
|
2792
|
-
t.scaleVelocity =
|
|
2793
|
-
let s =
|
|
2794
|
-
return t.smoothedGlobalScale =
|
|
2819
|
+
t.scaleVelocity = b.MathUtils.lerp(t.scaleVelocity, o, aa);
|
|
2820
|
+
let s = ma(na + t.scaleVelocity * ia, na, ra);
|
|
2821
|
+
return t.smoothedGlobalScale = b.MathUtils.lerp(a, e, s), t.smoothedGlobalScale;
|
|
2795
2822
|
}
|
|
2796
|
-
function
|
|
2823
|
+
function xa(e, t) {
|
|
2797
2824
|
let n = e ?? 0;
|
|
2798
2825
|
return Math.abs(n) >= Math.abs(t) ? n : t;
|
|
2799
2826
|
}
|
|
2800
|
-
function
|
|
2801
|
-
let o =
|
|
2827
|
+
function Sa(e, t, n, r, i, a) {
|
|
2828
|
+
let o = wa(fa, e, t, n, i.bodyTop, a), s = wa(pa, e, t, n, i.bodyBottom, a);
|
|
2802
2829
|
if (!o || !s) return null;
|
|
2803
|
-
let c =
|
|
2804
|
-
return c <= r *
|
|
2830
|
+
let c = Ca(i.bodyTop, i.bodyBottom);
|
|
2831
|
+
return c <= r * $i ? null : c;
|
|
2805
2832
|
}
|
|
2806
|
-
function
|
|
2833
|
+
function Ca(e, t) {
|
|
2807
2834
|
let n = e.x - t.x, r = e.y - t.y;
|
|
2808
2835
|
return Math.sqrt(n * n + r * r);
|
|
2809
2836
|
}
|
|
2810
|
-
function
|
|
2811
|
-
for (let o = 0; o < e.length; o += 1) if (
|
|
2837
|
+
function wa(e, t, n, r, i, a) {
|
|
2838
|
+
for (let o = 0; o < e.length; o += 1) if (Ta(e[o], t, n, r, i, a)) return !0;
|
|
2812
2839
|
return !1;
|
|
2813
2840
|
}
|
|
2814
|
-
function
|
|
2841
|
+
function Ta(e, t, n, r, i, a) {
|
|
2815
2842
|
if (typeof e == "number") {
|
|
2816
2843
|
let o = t[e];
|
|
2817
|
-
return !o || (o.visibility ?? 0) < .4 ? !1 : (
|
|
2844
|
+
return !o || (o.visibility ?? 0) < .4 ? !1 : (Z(o, n, r, {
|
|
2818
2845
|
mirrorX: !0,
|
|
2819
2846
|
sourceWidth: a.sourceWidth,
|
|
2820
2847
|
sourceHeight: a.sourceHeight,
|
|
@@ -2823,13 +2850,13 @@ function Da(e, t, n, r, i, a) {
|
|
|
2823
2850
|
}
|
|
2824
2851
|
let o = t[e[0]], s = t[e[1]];
|
|
2825
2852
|
if (!o || !s || (o.visibility ?? 0) < .4 || (s.visibility ?? 0) < .4) return !1;
|
|
2826
|
-
|
|
2853
|
+
Z(o, n, r, {
|
|
2827
2854
|
mirrorX: !0,
|
|
2828
2855
|
sourceWidth: a.sourceWidth,
|
|
2829
2856
|
sourceHeight: a.sourceHeight,
|
|
2830
2857
|
target: i
|
|
2831
2858
|
});
|
|
2832
|
-
let c =
|
|
2859
|
+
let c = Z(s, n, r, {
|
|
2833
2860
|
mirrorX: !0,
|
|
2834
2861
|
sourceWidth: a.sourceWidth,
|
|
2835
2862
|
sourceHeight: a.sourceHeight
|
|
@@ -2838,89 +2865,89 @@ function Da(e, t, n, r, i, a) {
|
|
|
2838
2865
|
}
|
|
2839
2866
|
//#endregion
|
|
2840
2867
|
//#region src/garment/trackedGarmentMotion.ts
|
|
2841
|
-
var
|
|
2868
|
+
var Ea = new b.Vector3(0, 1, 0), Da = new Set(["LeftHand", "RightHand"]), Oa = new Set([
|
|
2842
2869
|
"Hips",
|
|
2843
2870
|
"Spine",
|
|
2844
2871
|
"Chest"
|
|
2845
|
-
]),
|
|
2846
|
-
function
|
|
2872
|
+
]), ka = 20, Aa = .436, ja = .175, Ma = 1.396, Na = .349, Pa = .35;
|
|
2873
|
+
function Fa(e, t, n) {
|
|
2847
2874
|
return Math.max(t, Math.min(n, e));
|
|
2848
2875
|
}
|
|
2849
|
-
function
|
|
2876
|
+
function Ia(e) {
|
|
2850
2877
|
let t = e;
|
|
2851
2878
|
for (; t <= -Math.PI;) t += Math.PI * 2;
|
|
2852
2879
|
for (; t > Math.PI;) t -= Math.PI * 2;
|
|
2853
2880
|
return t;
|
|
2854
2881
|
}
|
|
2855
|
-
function
|
|
2856
|
-
let r =
|
|
2857
|
-
return
|
|
2882
|
+
function La(e, t, n) {
|
|
2883
|
+
let r = Ia(t - e);
|
|
2884
|
+
return Ia(Math.abs(r) <= n ? t : e + Math.sign(r) * n);
|
|
2858
2885
|
}
|
|
2859
|
-
function
|
|
2886
|
+
function Ra() {
|
|
2860
2887
|
return {
|
|
2861
|
-
transformScratch:
|
|
2862
|
-
facingDetector: new
|
|
2863
|
-
yawFreezeController: new
|
|
2888
|
+
transformScratch: ha(),
|
|
2889
|
+
facingDetector: new yi(),
|
|
2890
|
+
yawFreezeController: new Si(),
|
|
2864
2891
|
displayYaw: null,
|
|
2865
2892
|
lastFacingState: null,
|
|
2866
2893
|
hasInitialPosition: !1
|
|
2867
2894
|
};
|
|
2868
2895
|
}
|
|
2869
|
-
function
|
|
2870
|
-
e.transformScratch =
|
|
2896
|
+
function za(e) {
|
|
2897
|
+
e.transformScratch = ha(), e.facingDetector.reset(), e.yawFreezeController.reset(), e.displayYaw = null, e.lastFacingState = null, e.hasInitialPosition = !1;
|
|
2871
2898
|
}
|
|
2872
|
-
function
|
|
2899
|
+
function Ba({ fitProfile: e, garmentRoot: t, boneBindingMap: n, poseRefs: r, motionState: i, landmarks: a, worldLandmarks: o = null, viewportWidth: s, viewportHeight: c, poseFrameWidth: l, poseFrameHeight: u, delta: d }) {
|
|
2873
2900
|
if (!a || a.length < 33) return null;
|
|
2874
2901
|
let f = i.transformScratch;
|
|
2875
|
-
|
|
2902
|
+
ga(e, a, s, c, f, {
|
|
2876
2903
|
sourceWidth: l,
|
|
2877
2904
|
sourceHeight: u,
|
|
2878
2905
|
worldLandmarks: o
|
|
2879
2906
|
});
|
|
2880
|
-
let p = f.shoulderCenter.y - f.hipCenter.y, m = f.shoulderCenter.distanceTo(f.hipCenter), h = Math.acos(
|
|
2881
|
-
return i.displayYaw = C, i.lastFacingState = v, v.zone !== "back" && (S || (t.scale.copy(f.scale), i.hasInitialPosition ? t.position.lerp(f.position,
|
|
2907
|
+
let p = f.shoulderCenter.y - f.hipCenter.y, m = f.shoulderCenter.distanceTo(f.hipCenter), h = Math.acos(Fa(Math.abs(p) / Math.max(m, .001), 0, 1)), g = f.effectiveYaw, _ = g > 0 ? g - Math.PI : g + Math.PI, v = i.facingDetector.update(a, _, h), y = v.bodyYaw, b = i.displayYaw === null ? y : La(i.displayYaw, y, ka * d), x = i.yawFreezeController.update(v.zone, y), S = x.isFrozen, C = S ? x.frozenYaw ?? b : b;
|
|
2908
|
+
return i.displayYaw = C, i.lastFacingState = v, v.zone !== "back" && (S || (t.scale.copy(f.scale), i.hasInitialPosition ? t.position.lerp(f.position, Pa) : (t.position.copy(f.position), i.hasInitialPosition = !0)), t.quaternion.setFromAxisAngle(Ea, C)), v.zone === "front" && !S ? (Jr(a, n, r, {
|
|
2882
2909
|
coordinateSpace: "normalized",
|
|
2883
|
-
excludeBones:
|
|
2884
|
-
}), v.pitchClamped &&
|
|
2910
|
+
excludeBones: Da
|
|
2911
|
+
}), v.pitchClamped && Xr(n, Fa((Math.abs(h) - Aa) / ja, 0, 1), d, Oa)) : v.zone === "side" && !S && (Jr(a, n, r, {
|
|
2885
2912
|
coordinateSpace: "normalized",
|
|
2886
|
-
excludeBones:
|
|
2887
|
-
}),
|
|
2913
|
+
excludeBones: Da
|
|
2914
|
+
}), Xr(n, Fa((Math.abs(y) - Ma) / Na, 0, 1), d)), v;
|
|
2888
2915
|
}
|
|
2889
2916
|
//#endregion
|
|
2890
2917
|
//#region src/components/TrackedGarmentPoseDriver.tsx
|
|
2891
|
-
function
|
|
2892
|
-
let { viewport:
|
|
2893
|
-
return
|
|
2894
|
-
let n = e.current, r =
|
|
2895
|
-
return n && (n.position.set(0, 0, 0), n.scale.set(1, 1, 1), n.quaternion.identity()),
|
|
2896
|
-
|
|
2918
|
+
function Va({ garmentRootRef: e, boneBindingMap: t, fitProfile: r, landmarks: a, worldLandmarks: o, poseFrameWidth: l, poseFrameHeight: u }) {
|
|
2919
|
+
let { viewport: d } = c(), f = qr(), p = i(Ra());
|
|
2920
|
+
return n(() => {
|
|
2921
|
+
let n = e.current, r = p.current;
|
|
2922
|
+
return n && (n.position.set(0, 0, 0), n.scale.set(1, 1, 1), n.quaternion.identity()), Yr(t, f), za(r), () => {
|
|
2923
|
+
Yr(t, f), za(r);
|
|
2897
2924
|
};
|
|
2898
2925
|
}, [
|
|
2899
2926
|
t,
|
|
2900
|
-
|
|
2927
|
+
r,
|
|
2901
2928
|
e,
|
|
2902
|
-
|
|
2903
|
-
]),
|
|
2904
|
-
let
|
|
2905
|
-
!
|
|
2906
|
-
fitProfile:
|
|
2907
|
-
garmentRoot:
|
|
2929
|
+
f
|
|
2930
|
+
]), s((n, i) => {
|
|
2931
|
+
let s = e.current;
|
|
2932
|
+
!s || !r || Ba({
|
|
2933
|
+
fitProfile: r,
|
|
2934
|
+
garmentRoot: s,
|
|
2908
2935
|
boneBindingMap: t,
|
|
2909
|
-
poseRefs:
|
|
2910
|
-
motionState:
|
|
2911
|
-
landmarks:
|
|
2912
|
-
worldLandmarks:
|
|
2913
|
-
viewportWidth:
|
|
2914
|
-
viewportHeight:
|
|
2915
|
-
poseFrameWidth:
|
|
2916
|
-
poseFrameHeight:
|
|
2917
|
-
delta:
|
|
2936
|
+
poseRefs: f,
|
|
2937
|
+
motionState: p.current,
|
|
2938
|
+
landmarks: a,
|
|
2939
|
+
worldLandmarks: o,
|
|
2940
|
+
viewportWidth: d.width,
|
|
2941
|
+
viewportHeight: d.height,
|
|
2942
|
+
poseFrameWidth: l,
|
|
2943
|
+
poseFrameHeight: u,
|
|
2944
|
+
delta: i
|
|
2918
2945
|
});
|
|
2919
2946
|
}), null;
|
|
2920
2947
|
}
|
|
2921
2948
|
//#endregion
|
|
2922
2949
|
//#region src/components/EverTrackedGarment.tsx
|
|
2923
|
-
function
|
|
2950
|
+
function Ha(e) {
|
|
2924
2951
|
return e ? e.map((e) => ({
|
|
2925
2952
|
x: e.x,
|
|
2926
2953
|
y: e.y,
|
|
@@ -2928,85 +2955,85 @@ function Wa(e) {
|
|
|
2928
2955
|
visibility: typeof e.visibility == "number" ? e.visibility : 0
|
|
2929
2956
|
})) : null;
|
|
2930
2957
|
}
|
|
2931
|
-
function
|
|
2932
|
-
let
|
|
2933
|
-
return
|
|
2934
|
-
|
|
2935
|
-
if (e instanceof
|
|
2958
|
+
function Ua({ url: e, landmarks: t, worldLandmarks: a, poseFrameWidth: o, poseFrameHeight: s, debugMaterials: c = !1, onLoadStateChange: l }) {
|
|
2959
|
+
let u = i(null), { scene: d, bones: f } = ur({ url: e }), p = r(() => Ha(t), [t]), m = r(() => Ha(a), [a]), _ = r(() => (d.updateMatrixWorld(!0), qn(d, f, 1)), [f, d]);
|
|
2960
|
+
return n(() => {
|
|
2961
|
+
d.traverse((e) => {
|
|
2962
|
+
if (e instanceof b.Mesh) {
|
|
2936
2963
|
if (e.name.startsWith("Collision")) {
|
|
2937
2964
|
e.visible = !1;
|
|
2938
2965
|
return;
|
|
2939
2966
|
}
|
|
2940
2967
|
e.visible = !0, (Array.isArray(e.material) ? e.material : [e.material]).forEach((e) => {
|
|
2941
|
-
"opacity" in e && (c ? (e.transparent = !0, e.opacity = .34, e.depthWrite = !1, e.side =
|
|
2968
|
+
"opacity" in e && (c ? (e.transparent = !0, e.opacity = .34, e.depthWrite = !1, e.side = b.DoubleSide) : (e.transparent = !1, e.opacity = 1, e.depthWrite = !0, e.side = b.FrontSide), e.needsUpdate = !0);
|
|
2942
2969
|
});
|
|
2943
2970
|
}
|
|
2944
2971
|
});
|
|
2945
|
-
}, [
|
|
2972
|
+
}, [d, c]), n(() => (l?.({
|
|
2946
2973
|
loaded: !0,
|
|
2947
2974
|
error: null
|
|
2948
2975
|
}), () => {
|
|
2949
|
-
|
|
2976
|
+
l?.({
|
|
2950
2977
|
loaded: !1,
|
|
2951
2978
|
error: null
|
|
2952
2979
|
});
|
|
2953
|
-
}), [
|
|
2954
|
-
ref:
|
|
2955
|
-
children: [/* @__PURE__ */
|
|
2956
|
-
garmentRootRef:
|
|
2957
|
-
boneBindingMap:
|
|
2958
|
-
fitProfile:
|
|
2959
|
-
landmarks:
|
|
2960
|
-
worldLandmarks:
|
|
2961
|
-
poseFrameWidth:
|
|
2962
|
-
poseFrameHeight:
|
|
2980
|
+
}), [l, e]), /* @__PURE__ */ g("group", {
|
|
2981
|
+
ref: u,
|
|
2982
|
+
children: [/* @__PURE__ */ h("primitive", { object: d }), /* @__PURE__ */ h(Va, {
|
|
2983
|
+
garmentRootRef: u,
|
|
2984
|
+
boneBindingMap: f,
|
|
2985
|
+
fitProfile: _,
|
|
2986
|
+
landmarks: p,
|
|
2987
|
+
worldLandmarks: m,
|
|
2988
|
+
poseFrameWidth: o,
|
|
2989
|
+
poseFrameHeight: s
|
|
2963
2990
|
})]
|
|
2964
2991
|
});
|
|
2965
2992
|
}
|
|
2966
2993
|
//#endregion
|
|
2967
2994
|
//#region src/components/WebcamPlaneBackground.tsx
|
|
2968
|
-
var
|
|
2969
|
-
function
|
|
2970
|
-
let t = new
|
|
2971
|
-
return t.minFilter =
|
|
2995
|
+
var Wa = 1;
|
|
2996
|
+
function Ga(e) {
|
|
2997
|
+
let t = new b.VideoTexture(e);
|
|
2998
|
+
return t.minFilter = b.NearestFilter, t.magFilter = b.NearestFilter, t.generateMipmaps = !1, t.colorSpace = b.SRGBColorSpace, t.needsUpdate = !0, t;
|
|
2972
2999
|
}
|
|
2973
|
-
function
|
|
3000
|
+
function Ka(e, t, n) {
|
|
2974
3001
|
if (!n || n.width === 0 || n.height === 0) return [e, t];
|
|
2975
3002
|
let r = e / t, i = n.width / n.height;
|
|
2976
3003
|
return r > i ? [e, e / i] : [t * i, t];
|
|
2977
3004
|
}
|
|
2978
|
-
function
|
|
2979
|
-
let { viewport:
|
|
2980
|
-
|
|
2981
|
-
let n = e
|
|
3005
|
+
function qa({ videoElement: e, webcamReady: t }) {
|
|
3006
|
+
let { viewport: o } = c(), [l, u] = a(null), [d, f] = a(null), p = i(null), m = i(null), _ = i(0);
|
|
3007
|
+
n(() => {
|
|
3008
|
+
let n = e;
|
|
2982
3009
|
if (!t || !n) {
|
|
2983
3010
|
m.current !== null && (clearTimeout(m.current), m.current = null), _.current = 0;
|
|
2984
3011
|
return;
|
|
2985
3012
|
}
|
|
2986
|
-
let r = !1,
|
|
2987
|
-
if (r ||
|
|
3013
|
+
let r = !1, i = () => {
|
|
3014
|
+
if (r || p.current) return;
|
|
2988
3015
|
if (n.videoWidth === 0 || n.videoHeight === 0) {
|
|
2989
|
-
m.current = setTimeout(
|
|
3016
|
+
m.current = setTimeout(i, 100);
|
|
2990
3017
|
return;
|
|
2991
3018
|
}
|
|
2992
|
-
let e =
|
|
2993
|
-
|
|
3019
|
+
let e = Ga(n);
|
|
3020
|
+
p.current = e, _.current = 0, f({
|
|
2994
3021
|
width: n.videoWidth,
|
|
2995
3022
|
height: n.videoHeight
|
|
2996
|
-
}),
|
|
3023
|
+
}), u(e);
|
|
2997
3024
|
};
|
|
2998
|
-
return n.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA && n.videoWidth > 0 && n.videoHeight > 0 ?
|
|
2999
|
-
r = !0, m.current !== null && (clearTimeout(m.current), m.current = null), n.removeEventListener("loadeddata",
|
|
3025
|
+
return n.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA && n.videoWidth > 0 && n.videoHeight > 0 ? i() : (n.addEventListener("loadeddata", i), n.addEventListener("loadedmetadata", i), n.addEventListener("playing", i), m.current = setTimeout(i, 200)), () => {
|
|
3026
|
+
r = !0, m.current !== null && (clearTimeout(m.current), m.current = null), n.removeEventListener("loadeddata", i), n.removeEventListener("loadedmetadata", i), n.removeEventListener("playing", i), p.current &&= (p.current.dispose(), null), _.current = 0, u(null), f(null);
|
|
3000
3027
|
};
|
|
3001
|
-
}, [e, t]),
|
|
3002
|
-
!
|
|
3028
|
+
}, [e, t]), s(() => {
|
|
3029
|
+
!p.current || !p.current.image || (_.current = (_.current + 1) % Wa, _.current === 0 && (p.current.needsUpdate = !0));
|
|
3003
3030
|
});
|
|
3004
|
-
let [v, y] =
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3031
|
+
let [v, y] = r(() => Ka(o.width, o.height, d), [
|
|
3032
|
+
d,
|
|
3033
|
+
o.height,
|
|
3034
|
+
o.width
|
|
3008
3035
|
]);
|
|
3009
|
-
return !t || !
|
|
3036
|
+
return !t || !l ? null : /* @__PURE__ */ g("mesh", {
|
|
3010
3037
|
position: [
|
|
3011
3038
|
0,
|
|
3012
3039
|
0,
|
|
@@ -3018,8 +3045,8 @@ function Ya({ videoRef: e, webcamReady: t }) {
|
|
|
3018
3045
|
1,
|
|
3019
3046
|
1
|
|
3020
3047
|
],
|
|
3021
|
-
children: [/* @__PURE__ */
|
|
3022
|
-
map:
|
|
3048
|
+
children: [/* @__PURE__ */ h("planeGeometry", { args: [v, y] }), /* @__PURE__ */ h("meshBasicMaterial", {
|
|
3049
|
+
map: l,
|
|
3023
3050
|
depthTest: !1,
|
|
3024
3051
|
depthWrite: !1,
|
|
3025
3052
|
toneMapped: !1
|
|
@@ -3028,58 +3055,126 @@ function Ya({ videoRef: e, webcamReady: t }) {
|
|
|
3028
3055
|
}
|
|
3029
3056
|
//#endregion
|
|
3030
3057
|
//#region src/components/EverFittingScene.tsx
|
|
3031
|
-
function
|
|
3032
|
-
return
|
|
3058
|
+
function Ja({ onReady: e }) {
|
|
3059
|
+
return n(() => (e?.(!0), () => {
|
|
3033
3060
|
e?.(!1);
|
|
3034
3061
|
}), [e]), null;
|
|
3035
3062
|
}
|
|
3036
|
-
function
|
|
3037
|
-
return /* @__PURE__ */
|
|
3063
|
+
function Ya() {
|
|
3064
|
+
return /* @__PURE__ */ h("color", {
|
|
3038
3065
|
attach: "background",
|
|
3039
3066
|
args: ["#000000"]
|
|
3040
3067
|
});
|
|
3041
3068
|
}
|
|
3042
|
-
function
|
|
3043
|
-
let
|
|
3044
|
-
enabled:
|
|
3045
|
-
width:
|
|
3046
|
-
height:
|
|
3047
|
-
facingMode:
|
|
3048
|
-
mockMode:
|
|
3049
|
-
viewportWidth:
|
|
3050
|
-
viewportHeight:
|
|
3051
|
-
measurementEnabled:
|
|
3052
|
-
autoStartMeasurement:
|
|
3053
|
-
measurementConfig:
|
|
3054
|
-
bodyPresetOptions:
|
|
3055
|
-
fitType:
|
|
3056
|
-
garmentScaleHint:
|
|
3057
|
-
})
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3069
|
+
function Xa({ garmentUrl: e, enabled: i = !0, width: o = 1280, height: s = 720, facingMode: c = "user", mockMode: l = !1, viewportWidth: u = 0, viewportHeight: p = 0, measurementEnabled: m = !0, autoStartMeasurement: _ = !1, measurementConfig: v, fitType: y = "regular", garmentScaleHint: b = null, bodyPresetOptions: x, className: S, style: C, debugMaterials: T = !1, showEnvironment: E = !1, showStats: D = !1, showWebcamBackground: O = !0, onCanvasReadyChange: k, onRuntimeStateChange: A, onGarmentLoadStateChange: j }) {
|
|
3070
|
+
let { videoRef: M, webcamReady: N, webcamError: P, startWebcam: F, stopWebcam: I, isTrackerReady: L, landmarks: R, worldLandmarks: ee, poseRig: te, confidence: ne, fps: re, isTracking: z, drawLandmarks: B, silhouetteWidths: V, poseFrameWidth: H, poseFrameHeight: ie, detectedPersonCount: ae, lockedPersonId: oe, trackingQuality: se, config: ce, measurements: le, sizeRecommendation: ue, garmentScale: de, finalGarmentScale: fe, bodyMorphResult: pe, isMeasuring: me, canMeasure: he, startMeasurement: ge, updateConfig: _e, bodyPresetSelection: ve, bodyPresetLoading: ye, bodyPresetError: be } = Hn({
|
|
3071
|
+
enabled: i,
|
|
3072
|
+
width: o,
|
|
3073
|
+
height: s,
|
|
3074
|
+
facingMode: c,
|
|
3075
|
+
mockMode: l,
|
|
3076
|
+
viewportWidth: u,
|
|
3077
|
+
viewportHeight: p,
|
|
3078
|
+
measurementEnabled: m,
|
|
3079
|
+
autoStartMeasurement: _,
|
|
3080
|
+
measurementConfig: v,
|
|
3081
|
+
bodyPresetOptions: x,
|
|
3082
|
+
fitType: y,
|
|
3083
|
+
garmentScaleHint: b
|
|
3084
|
+
}), [xe, Se] = a(null), Ce = t((e) => {
|
|
3085
|
+
M.current = e, Se(e);
|
|
3086
|
+
}, [M]), we = r(() => ({
|
|
3087
|
+
videoRef: M,
|
|
3088
|
+
webcamReady: N,
|
|
3089
|
+
webcamError: P,
|
|
3090
|
+
startWebcam: F,
|
|
3091
|
+
stopWebcam: I,
|
|
3092
|
+
isTrackerReady: L,
|
|
3093
|
+
landmarks: R,
|
|
3094
|
+
worldLandmarks: ee,
|
|
3095
|
+
poseRig: te,
|
|
3096
|
+
confidence: ne,
|
|
3097
|
+
fps: re,
|
|
3098
|
+
isTracking: z,
|
|
3099
|
+
drawLandmarks: B,
|
|
3100
|
+
silhouetteWidths: V,
|
|
3101
|
+
poseFrameWidth: H,
|
|
3102
|
+
poseFrameHeight: ie,
|
|
3103
|
+
detectedPersonCount: ae,
|
|
3104
|
+
lockedPersonId: oe,
|
|
3105
|
+
trackingQuality: se,
|
|
3106
|
+
config: ce,
|
|
3107
|
+
measurements: le,
|
|
3108
|
+
sizeRecommendation: ue,
|
|
3109
|
+
garmentScale: de,
|
|
3110
|
+
finalGarmentScale: fe,
|
|
3111
|
+
bodyMorphResult: pe,
|
|
3112
|
+
isMeasuring: me,
|
|
3113
|
+
canMeasure: he,
|
|
3114
|
+
startMeasurement: ge,
|
|
3115
|
+
updateConfig: _e,
|
|
3116
|
+
bodyPresetSelection: ve,
|
|
3117
|
+
bodyPresetLoading: ye,
|
|
3118
|
+
bodyPresetError: be
|
|
3119
|
+
}), [
|
|
3120
|
+
M,
|
|
3121
|
+
N,
|
|
3122
|
+
P,
|
|
3123
|
+
F,
|
|
3124
|
+
I,
|
|
3125
|
+
L,
|
|
3126
|
+
R,
|
|
3127
|
+
ee,
|
|
3128
|
+
te,
|
|
3129
|
+
ne,
|
|
3130
|
+
re,
|
|
3131
|
+
z,
|
|
3132
|
+
B,
|
|
3133
|
+
V,
|
|
3134
|
+
H,
|
|
3135
|
+
ie,
|
|
3136
|
+
ae,
|
|
3137
|
+
oe,
|
|
3138
|
+
se,
|
|
3139
|
+
ce,
|
|
3140
|
+
le,
|
|
3141
|
+
ue,
|
|
3142
|
+
de,
|
|
3143
|
+
fe,
|
|
3144
|
+
pe,
|
|
3145
|
+
me,
|
|
3146
|
+
he,
|
|
3147
|
+
ge,
|
|
3148
|
+
_e,
|
|
3149
|
+
ve,
|
|
3150
|
+
ye,
|
|
3151
|
+
be
|
|
3152
|
+
]);
|
|
3153
|
+
return n(() => {
|
|
3154
|
+
A?.(we);
|
|
3155
|
+
}, [A, we]), /* @__PURE__ */ g("div", {
|
|
3156
|
+
className: S,
|
|
3062
3157
|
style: {
|
|
3063
3158
|
position: "relative",
|
|
3064
3159
|
width: "100%",
|
|
3065
3160
|
height: "100%",
|
|
3066
3161
|
overflow: "hidden",
|
|
3067
|
-
...
|
|
3162
|
+
...C
|
|
3068
3163
|
},
|
|
3069
|
-
children: [/* @__PURE__ */
|
|
3070
|
-
ref:
|
|
3164
|
+
children: [/* @__PURE__ */ h("video", {
|
|
3165
|
+
ref: Ce,
|
|
3071
3166
|
autoPlay: !0,
|
|
3072
3167
|
playsInline: !0,
|
|
3073
3168
|
muted: !0,
|
|
3074
3169
|
style: { display: "none" }
|
|
3075
|
-
}), /* @__PURE__ */
|
|
3076
|
-
showEnvironment:
|
|
3170
|
+
}), /* @__PURE__ */ g(w, {
|
|
3171
|
+
showEnvironment: E,
|
|
3077
3172
|
useDefaultLights: !1,
|
|
3078
3173
|
enableOrbitControls: !1,
|
|
3079
3174
|
children: [
|
|
3080
|
-
/* @__PURE__ */
|
|
3081
|
-
/* @__PURE__ */
|
|
3082
|
-
/* @__PURE__ */
|
|
3175
|
+
/* @__PURE__ */ h(Ja, { onReady: k }),
|
|
3176
|
+
/* @__PURE__ */ h(Ya, {}),
|
|
3177
|
+
/* @__PURE__ */ h(d, {
|
|
3083
3178
|
makeDefault: !0,
|
|
3084
3179
|
position: [
|
|
3085
3180
|
0,
|
|
@@ -3090,8 +3185,8 @@ function Qa({ garmentUrl: e, enabled: t = !0, width: n = 1280, height: r = 720,
|
|
|
3090
3185
|
near: .1,
|
|
3091
3186
|
far: 1e3
|
|
3092
3187
|
}),
|
|
3093
|
-
/* @__PURE__ */
|
|
3094
|
-
/* @__PURE__ */
|
|
3188
|
+
/* @__PURE__ */ h("ambientLight", { intensity: .95 }),
|
|
3189
|
+
/* @__PURE__ */ h("directionalLight", {
|
|
3095
3190
|
position: [
|
|
3096
3191
|
4,
|
|
3097
3192
|
6,
|
|
@@ -3099,7 +3194,7 @@ function Qa({ garmentUrl: e, enabled: t = !0, width: n = 1280, height: r = 720,
|
|
|
3099
3194
|
],
|
|
3100
3195
|
intensity: 1.15
|
|
3101
3196
|
}),
|
|
3102
|
-
/* @__PURE__ */
|
|
3197
|
+
/* @__PURE__ */ h("directionalLight", {
|
|
3103
3198
|
position: [
|
|
3104
3199
|
-5,
|
|
3105
3200
|
4,
|
|
@@ -3107,217 +3202,92 @@ function Qa({ garmentUrl: e, enabled: t = !0, width: n = 1280, height: r = 720,
|
|
|
3107
3202
|
],
|
|
3108
3203
|
intensity: .45
|
|
3109
3204
|
}),
|
|
3110
|
-
/* @__PURE__ */
|
|
3205
|
+
/* @__PURE__ */ h("hemisphereLight", { args: [
|
|
3111
3206
|
"#ffffff",
|
|
3112
3207
|
"#7d8aa6",
|
|
3113
3208
|
.35
|
|
3114
3209
|
] }),
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
webcamReady:
|
|
3210
|
+
O ? /* @__PURE__ */ h(qa, {
|
|
3211
|
+
videoElement: xe,
|
|
3212
|
+
webcamReady: N
|
|
3118
3213
|
}) : null,
|
|
3119
|
-
|
|
3214
|
+
i && e ? /* @__PURE__ */ h(Ua, {
|
|
3120
3215
|
url: e,
|
|
3121
|
-
landmarks:
|
|
3122
|
-
worldLandmarks:
|
|
3123
|
-
poseFrameWidth:
|
|
3124
|
-
poseFrameHeight:
|
|
3125
|
-
debugMaterials:
|
|
3126
|
-
onLoadStateChange:
|
|
3216
|
+
landmarks: R,
|
|
3217
|
+
worldLandmarks: ee,
|
|
3218
|
+
poseFrameWidth: H,
|
|
3219
|
+
poseFrameHeight: ie,
|
|
3220
|
+
debugMaterials: T,
|
|
3221
|
+
onLoadStateChange: j
|
|
3127
3222
|
}) : null,
|
|
3128
|
-
|
|
3223
|
+
D ? /* @__PURE__ */ h(f, {}) : null
|
|
3129
3224
|
]
|
|
3130
3225
|
})]
|
|
3131
3226
|
});
|
|
3132
3227
|
}
|
|
3133
3228
|
//#endregion
|
|
3134
|
-
//#region src/
|
|
3135
|
-
var
|
|
3136
|
-
|
|
3137
|
-
width: n,
|
|
3138
|
-
height: r,
|
|
3139
|
-
facingMode: i,
|
|
3140
|
-
enabled: o,
|
|
3141
|
-
mockMode: s,
|
|
3142
|
-
videoRef: c,
|
|
3143
|
-
onReadyChange: u
|
|
3144
|
-
});
|
|
3145
|
-
return a(() => {
|
|
3146
|
-
!o && l && u(!1);
|
|
3147
|
-
}, [
|
|
3148
|
-
o,
|
|
3149
|
-
l,
|
|
3150
|
-
u
|
|
3151
|
-
]), /* @__PURE__ */ f("div", {
|
|
3152
|
-
className: `camera-view-container ${e || ""}`,
|
|
3153
|
-
style: {
|
|
3154
|
-
position: "absolute",
|
|
3155
|
-
inset: 0,
|
|
3156
|
-
zIndex: 0,
|
|
3157
|
-
...t
|
|
3158
|
-
},
|
|
3159
|
-
children: /* @__PURE__ */ f("video", {
|
|
3160
|
-
ref: c,
|
|
3161
|
-
autoPlay: !0,
|
|
3162
|
-
playsInline: !0,
|
|
3163
|
-
muted: !0,
|
|
3164
|
-
className: "w-full h-full object-cover",
|
|
3165
|
-
style: { display: o && (d || l) ? "block" : "none" }
|
|
3166
|
-
})
|
|
3167
|
-
});
|
|
3168
|
-
}, eo = ({ url: e, onBonesReady: t }) => e ? /* @__PURE__ */ f(no, {
|
|
3169
|
-
url: e,
|
|
3170
|
-
onBonesReady: t
|
|
3171
|
-
}) : null;
|
|
3172
|
-
function to(e) {
|
|
3173
|
-
return "isBone" in e && e.isBone === !0;
|
|
3174
|
-
}
|
|
3175
|
-
var no = ({ url: e, onBonesReady: t }) => {
|
|
3176
|
-
let { scene: n } = x(e), r = s(null), { setAvatarBones: i } = A();
|
|
3177
|
-
return a(() => {
|
|
3178
|
-
if (!n) return;
|
|
3179
|
-
let e = {};
|
|
3180
|
-
return n.traverse((t) => {
|
|
3181
|
-
to(t) && (e[t.name] = t);
|
|
3182
|
-
}), i(e), t && t(e), () => i(null);
|
|
3183
|
-
}, [
|
|
3184
|
-
n,
|
|
3185
|
-
t,
|
|
3186
|
-
i
|
|
3187
|
-
]), /* @__PURE__ */ f("group", {
|
|
3188
|
-
ref: r,
|
|
3189
|
-
dispose: null,
|
|
3190
|
-
children: /* @__PURE__ */ f("primitive", { object: n })
|
|
3191
|
-
});
|
|
3192
|
-
}, ro = ({ url: e, targetAvatarBones: t }) => e ? /* @__PURE__ */ f(ao, {
|
|
3193
|
-
url: e,
|
|
3194
|
-
targetAvatarBones: t
|
|
3195
|
-
}) : null;
|
|
3196
|
-
function io(e) {
|
|
3197
|
-
return "isSkinnedMesh" in e && e.isSkinnedMesh === !0;
|
|
3198
|
-
}
|
|
3199
|
-
var ao = ({ url: e, targetAvatarBones: t }) => {
|
|
3200
|
-
let { scene: n } = x(e), r = s(null), { avatarBones: i } = A(), o = t || i;
|
|
3201
|
-
return a(() => {
|
|
3202
|
-
!n || !o || n.traverse((e) => {
|
|
3203
|
-
if (io(e)) {
|
|
3204
|
-
let t = e, n = [];
|
|
3205
|
-
t.skeleton.bones.forEach((e) => {
|
|
3206
|
-
o[e.name] ? n.push(o[e.name]) : n.push(e);
|
|
3207
|
-
}), t.bind(new u(n), t.bindMatrix);
|
|
3208
|
-
}
|
|
3209
|
-
});
|
|
3210
|
-
}, [n, o]), /* @__PURE__ */ f("group", {
|
|
3211
|
-
ref: r,
|
|
3212
|
-
dispose: null,
|
|
3213
|
-
children: /* @__PURE__ */ f("primitive", { object: n })
|
|
3214
|
-
});
|
|
3215
|
-
}, oo = () => ({ mapPoseToBones: r((e, t) => {
|
|
3216
|
-
if (!e || e.length === 0 || !t) return;
|
|
3217
|
-
for (let n of [
|
|
3218
|
-
"Hips",
|
|
3219
|
-
"Spine",
|
|
3220
|
-
"Chest",
|
|
3221
|
-
"LeftUpperArm",
|
|
3222
|
-
"LeftLowerArm",
|
|
3223
|
-
"RightUpperArm",
|
|
3224
|
-
"RightLowerArm",
|
|
3225
|
-
"LeftUpperLeg",
|
|
3226
|
-
"LeftLowerLeg",
|
|
3227
|
-
"RightUpperLeg",
|
|
3228
|
-
"RightLowerLeg"
|
|
3229
|
-
]) {
|
|
3230
|
-
let r = t[n];
|
|
3231
|
-
r && Zt(n, e, r.quaternion) && r.quaternion.normalize();
|
|
3232
|
-
}
|
|
3233
|
-
let n = e[B.LEFT_HIP], r = e[B.RIGHT_HIP], i = t.Hips;
|
|
3234
|
-
i && n && r && i.position.set((n.x + r.x) * .5, -((n.y + r.y) * .5) + 1, ((n.z ?? 0) + (r.z ?? 0)) * .5);
|
|
3235
|
-
}, []) }), so = (e) => {
|
|
3236
|
-
let [t, n] = c(null), { landmarks: r, setFitResult: i } = O();
|
|
3237
|
-
return a(() => {
|
|
3238
|
-
let t = e?.referenceHeightCm ?? 170, a = e?.weightKg ?? null, o = e?.measurementIntervalMs ?? 1e3, s = setInterval(() => {
|
|
3239
|
-
if (!r || r.length < 33) return;
|
|
3240
|
-
let e = it(r, t, a), o = ot(e);
|
|
3241
|
-
if (te(e), n({
|
|
3242
|
-
shoulder: e.shoulderWidthCm,
|
|
3243
|
-
chest: e.chestCircumferenceCm,
|
|
3244
|
-
waist: e.waistCircumferenceCm
|
|
3245
|
-
}), !o) {
|
|
3246
|
-
i(null);
|
|
3247
|
-
return;
|
|
3248
|
-
}
|
|
3249
|
-
i({
|
|
3250
|
-
type: o.fitDescription === "slim" ? "slim" : o.fitDescription === "relaxed" ? "oversize" : "regular",
|
|
3251
|
-
suitability: Math.round(o.confidence * 100)
|
|
3252
|
-
});
|
|
3253
|
-
}, o);
|
|
3254
|
-
return () => clearInterval(s);
|
|
3255
|
-
}, [
|
|
3256
|
-
r,
|
|
3257
|
-
i,
|
|
3258
|
-
e
|
|
3259
|
-
]), { dimensions: t };
|
|
3260
|
-
}, co = { gender: "female" };
|
|
3261
|
-
function lo(e, t) {
|
|
3229
|
+
//#region src/hooks/useEverGeneration.ts
|
|
3230
|
+
var Za = { gender: "female" };
|
|
3231
|
+
function Qa(e, t) {
|
|
3262
3232
|
return e instanceof Error && e.message ? e.message : t;
|
|
3263
3233
|
}
|
|
3264
|
-
function
|
|
3265
|
-
let
|
|
3234
|
+
function $a(e) {
|
|
3235
|
+
let n = r(() => new _e(e), [e]), [i, o] = a("idle"), [s, c] = a(null), [l, u] = a(null);
|
|
3266
3236
|
return {
|
|
3267
|
-
status:
|
|
3268
|
-
resultUrl:
|
|
3237
|
+
status: i,
|
|
3238
|
+
resultUrl: s,
|
|
3269
3239
|
error: l,
|
|
3270
|
-
generateAvatar:
|
|
3271
|
-
|
|
3240
|
+
generateAvatar: t(async (e = Za) => {
|
|
3241
|
+
o("processing"), u(null);
|
|
3272
3242
|
try {
|
|
3273
|
-
let
|
|
3243
|
+
let t = e instanceof Blob ? Za : e, r = await n.matchBodyPreset(t);
|
|
3274
3244
|
if (!r.model_url) throw Error("Matched body preset does not have a 3D model URL.");
|
|
3275
|
-
return
|
|
3245
|
+
return c(r.model_url), o("ready"), r.model_url;
|
|
3276
3246
|
} catch (e) {
|
|
3277
|
-
throw u(
|
|
3247
|
+
throw u(Qa(e, "Failed to load avatar model")), o("error"), e;
|
|
3278
3248
|
}
|
|
3279
|
-
}, [
|
|
3280
|
-
createGarment:
|
|
3281
|
-
|
|
3249
|
+
}, [n]),
|
|
3250
|
+
createGarment: t(async (e, t, r, i) => {
|
|
3251
|
+
o("uploading"), u(null);
|
|
3282
3252
|
try {
|
|
3283
|
-
let
|
|
3284
|
-
await
|
|
3285
|
-
include_measurements: !!
|
|
3253
|
+
let a = await n.createGarment(e);
|
|
3254
|
+
await n.uploadGarmentImage(a.id, t, "front"), r && await n.uploadGarmentImage(a.id, r, "back"), o("processing"), await n.generateGarment3D(a.id, {
|
|
3255
|
+
include_measurements: !!i,
|
|
3286
3256
|
target_fit_types: ["regular"]
|
|
3287
3257
|
});
|
|
3288
|
-
let
|
|
3258
|
+
let s = await n.waitForGarmentModel(a.id), l = n.pickGarmentModelUrl(s);
|
|
3289
3259
|
if (!l) throw Error("Backend did not return a garment 3D model URL.");
|
|
3290
|
-
return
|
|
3260
|
+
return c(l), o("ready"), l;
|
|
3291
3261
|
} catch (e) {
|
|
3292
|
-
throw u(
|
|
3262
|
+
throw u(Qa(e, "Failed to generate garment")), o("error"), e;
|
|
3293
3263
|
}
|
|
3294
|
-
}, [
|
|
3264
|
+
}, [n]),
|
|
3295
3265
|
reset: () => {
|
|
3296
|
-
|
|
3266
|
+
o("idle"), c(null), u(null);
|
|
3297
3267
|
}
|
|
3298
3268
|
};
|
|
3299
3269
|
}
|
|
3300
3270
|
//#endregion
|
|
3301
3271
|
//#region src/garment/constants.ts
|
|
3302
|
-
var
|
|
3303
|
-
Hips: [
|
|
3272
|
+
var eo = {
|
|
3273
|
+
Hips: [U.LEFT_HIP, U.RIGHT_HIP],
|
|
3304
3274
|
Spine: [
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3275
|
+
U.LEFT_SHOULDER,
|
|
3276
|
+
U.RIGHT_SHOULDER,
|
|
3277
|
+
U.LEFT_HIP,
|
|
3278
|
+
U.RIGHT_HIP
|
|
3309
3279
|
],
|
|
3310
|
-
Chest: [
|
|
3311
|
-
LeftShoulder: [
|
|
3312
|
-
LeftUpperArm: [
|
|
3313
|
-
LeftLowerArm: [
|
|
3314
|
-
RightShoulder: [
|
|
3315
|
-
RightUpperArm: [
|
|
3316
|
-
RightLowerArm: [
|
|
3317
|
-
LeftUpperLeg: [
|
|
3318
|
-
LeftLowerLeg: [
|
|
3319
|
-
RightUpperLeg: [
|
|
3320
|
-
RightLowerLeg: [
|
|
3280
|
+
Chest: [U.LEFT_SHOULDER, U.RIGHT_SHOULDER],
|
|
3281
|
+
LeftShoulder: [U.LEFT_SHOULDER, U.LEFT_ELBOW],
|
|
3282
|
+
LeftUpperArm: [U.LEFT_SHOULDER, U.LEFT_ELBOW],
|
|
3283
|
+
LeftLowerArm: [U.LEFT_ELBOW, U.LEFT_WRIST],
|
|
3284
|
+
RightShoulder: [U.RIGHT_SHOULDER, U.RIGHT_ELBOW],
|
|
3285
|
+
RightUpperArm: [U.RIGHT_SHOULDER, U.RIGHT_ELBOW],
|
|
3286
|
+
RightLowerArm: [U.RIGHT_ELBOW, U.RIGHT_WRIST],
|
|
3287
|
+
LeftUpperLeg: [U.LEFT_HIP, U.LEFT_KNEE],
|
|
3288
|
+
LeftLowerLeg: [U.LEFT_KNEE, U.LEFT_ANKLE],
|
|
3289
|
+
RightUpperLeg: [U.RIGHT_HIP, U.RIGHT_KNEE],
|
|
3290
|
+
RightLowerLeg: [U.RIGHT_KNEE, U.RIGHT_ANKLE]
|
|
3321
3291
|
};
|
|
3322
3292
|
//#endregion
|
|
3323
|
-
export {
|
|
3293
|
+
export { gr as BONE_MAPPING, eo as BONE_VISIBILITY_MAP, me as DEFAULT_EVER_API_BASE_URL, be as DEFAULT_FEMALE_BODY_PRESET_ID, T as DEFAULT_GARMENT_SPEC, $t as DEFAULT_LOCKED_PERSON_ID, ye as DEFAULT_MALE_BODY_PRESET_ID, Xe as DEFAULT_MEASUREMENT_CONFIG, ht as DEFAULT_NUM_POSES, Fe as DEFAULT_SMOOTHING, w as EverCanvas, _e as EverClient, Xa as EverFittingScene, Ua as EverTrackedGarment, yi as FacingDetector, gt as INTERPOLATION_ALPHA, U as LANDMARK, xe as LEGACY_RIGGED_BODY_PRESET_ID, sn as LandmarkSmoother, ft as MEDIAPIPE_TASKS_VISION_VERSION, _t as MODEL_ASSET_PATHS, mt as POSE_DETECTION_INTERVAL, Pn as TRACKING_SNAPSHOT_HOLD_MS, Va as TrackedGarmentPoseDriver, pt as WASM_FILES_URL, qa as WebcamPlaneBackground, ni as YawDirectionStabilizer, Si as YawFreezeController, Jr as applyLandmarkPoseToGarment, _a as applyTrackedModelTransform, Xr as blendBonesToRest, we as buildBodyPresetAssetUrl, je as buildBodyPresetMatchRequest, yn as calcRectIoU, Un as captureBoneBinding, gn as clampNormalizedRect, Zt as closeSegmentationMasks, Be as computeBmiCorrectionFactor, pe as computeBodyFirstFitting, Rt as computeBoneDirectionFromLandmarks, Bt as computeBoneRotationFromLandmarks, et as computeCoverRect, Bi as computeFacingAwareShoulderWidth, qn as computeGarmentFitProfile, Ui as computeGarmentGroupRoll, Hi as computeGarmentGroupYaw, Wi as computeGarmentRootQuaternion, O as computeGarmentScale, _n as computeLandmarkBoundsNormalized, Lt as computeLandmarkSegmentDirection, ze as computeScale, Vi as computeStableShoulderWidth, tt as computeVisibleNormalizedRegion, $n as configureAvatarLoader, er as createAvatarLoaderExtension, ke as createFallbackBodyPresetSelection, In as createHeldTrackingSnapshot, ir as createHumanoidBoneBindings, An as createIdleTrackingQuality, ut as createInitialPoseSnapshot, Mn as createInitialTrackingRuntimeState, xn as createPoseCandidates, vt as createPoseLandmarker, Ra as createTrackedGarmentMotionState, ha as createTrackedModelTransformScratch, Ln as createTrackingLostRuntimeState, jn as createTrackingQuality, Nn as createTrackingRuntimeState, cr as createVRMCompat, ce as deriveBodyMorphResult, De as ensureBodyPresetModelUrl, vn as expandNormalizedRect, gi as extractFacingSignals, at as extractSilhouetteWidths, Tn as filterCandidatesByVisibleRegion, Qn as getAvatarAssetKind, zt as getBoneLandmarkInfluence, yr as getBoneRotation, Te as getDefaultBodyPresetId, Xt as getSegmentationMaskData, Vt as hasLandmarkMapping, ot as interpolateLandmarks, ct as interpolatePoseRig, dt as interpolatePoseSnapshot, lt as interpolateSilhouetteWidths, wn as isCandidateInVisibleRegion, _i as isRawFrontFacing, Zn as isVRMAssetUrl, Ti as landmarkDistance, Z as landmarkToThreePosition, J as lerpRotation, K as lerpValue, qe as measureBody, wi as midpointToThree, Ce as normalizeBodyPresetGender, vr as normalizeBoneName, tn as normalizeLandmark, nn as normalizeLandmarks, Oe as pickDefaultBodyPreset, tr as prepareAvatarScene, nr as prepareNativeVRM, Ye as recommendSize, Jn as resetBoneRotations, Yr as resetPoseState, za as resetTrackedGarmentMotionState, Qt as scaleSilhouetteWidths, Cn as selectLockedPoseCandidate, Fn as shouldHoldTrackingSnapshot, ln as smoothPoseRig, Yt as solvePose, Ae as toBodyPresetSelection, Ee as toBodyPresetSummary, En as toLockedPoseCandidate, Ba as updateTrackedGarmentMotion, ga as updateTrackedModelTransform, ur as useAvatarVariant, Pe as useBodyPresetSelection, Hn as useEverFitting, $a as useEverGeneration, $e as useMeasurement, qr as usePoseApplicationRefs, zn as usePoseTracker, Vn as useWebcam };
|