@ssafy-mhk/e-ver 1.0.5 → 1.0.7
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/README.md +15 -25
- package/dist/components/EverFittingScene.d.ts +2 -2
- package/dist/components/WebcamPlaneBackground.d.ts +2 -3
- package/dist/garment/trackedGarmentMotion.d.ts +2 -0
- package/dist/garment/trackedModelTransform.d.ts +5 -0
- package/dist/hooks/useWebcam.d.ts +2 -2
- package/dist/humanoid/numberedBoneAliases.d.ts +12 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +1103 -785
- package/dist/index.umd.js +1 -1
- package/dist/math.d.ts +8 -0
- package/dist/pose/detectionCadence.d.ts +21 -0
- package/dist/pose/frameSmoothing.d.ts +14 -0
- package/dist/pose/landmarkerFactory.d.ts +2 -1
- package/dist/pose/poseSolver.d.ts +2 -0
- package/dist/pose/poseSolver.test.d.ts +1 -0
- package/dist/pose/trackingConfidence.d.ts +6 -0
- package/dist/pose/trackingConfidence.test.d.ts +1 -0
- package/dist/pose/yawFreezeController.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -62,7 +62,21 @@ var w = ({ children: t, showEnvironment: n = !0, useDefaultLights: r = !0, enabl
|
|
|
62
62
|
}) : null
|
|
63
63
|
]
|
|
64
64
|
})
|
|
65
|
-
})
|
|
65
|
+
});
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/math.ts
|
|
68
|
+
function T(e, t, n) {
|
|
69
|
+
return Math.max(t, Math.min(n, e));
|
|
70
|
+
}
|
|
71
|
+
function E(e) {
|
|
72
|
+
let t = e;
|
|
73
|
+
for (; t <= -Math.PI;) t += Math.PI * 2;
|
|
74
|
+
for (; t > Math.PI;) t -= Math.PI * 2;
|
|
75
|
+
return t;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/measurement/garmentScaler.ts
|
|
79
|
+
var D = {
|
|
66
80
|
refShoulderWidthCm: 44,
|
|
67
81
|
refHeightCm: 170,
|
|
68
82
|
refArmLengthCm: 58,
|
|
@@ -78,37 +92,34 @@ var w = ({ children: t, showEnvironment: n = !0, useDefaultLights: r = !0, enabl
|
|
|
78
92
|
armEaseCm: 2,
|
|
79
93
|
fitEaseScale: 1.03
|
|
80
94
|
};
|
|
81
|
-
function
|
|
95
|
+
function O(e, t, n) {
|
|
82
96
|
return !e || t <= 0 ? 1 : (e + n) / t;
|
|
83
97
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
}
|
|
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);
|
|
98
|
+
function k(e, t = D) {
|
|
99
|
+
let n = O(e.shoulderWidthCm, t.refShoulderWidthCm, t.shoulderEaseCm), r = O(e.chestCircumferenceCm, t.refChestCircumferenceCm, t.chestEaseCm), i = O(e.waistCircumferenceCm, t.refWaistCircumferenceCm, t.waistEaseCm), a = O(e.hipWidthCm, t.refHipWidthCm, t.hipEaseCm), o = O(e.torsoLengthCm, t.refTorsoLengthCm, t.torsoEaseCm), s = t.refHeightCm > 0 ? e.heightCm / t.refHeightCm : 1, c = O(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);
|
|
89
100
|
return {
|
|
90
|
-
scaleX:
|
|
91
|
-
scaleY:
|
|
92
|
-
scaleZ:
|
|
93
|
-
sleeveScale:
|
|
94
|
-
fitEaseScale:
|
|
101
|
+
scaleX: T(l, .82, 1.85),
|
|
102
|
+
scaleY: T(d, .85, 1.55),
|
|
103
|
+
scaleZ: T(u, .84, 1.9),
|
|
104
|
+
sleeveScale: T(c, .8, 1.55),
|
|
105
|
+
fitEaseScale: T(t.fitEaseScale, 1, 1.2)
|
|
95
106
|
};
|
|
96
107
|
}
|
|
97
108
|
//#endregion
|
|
98
109
|
//#region src/fitting/bodyFirstFitting.ts
|
|
99
|
-
var
|
|
110
|
+
var A = .82, j = 2.1, M = .85, N = 1.8, P = .84, ee = 2.1, F = .8, I = 1.7, L = 1, te = 1.25, ne = {
|
|
100
111
|
scaleX: 1,
|
|
101
112
|
scaleY: 1,
|
|
102
113
|
scaleZ: 1,
|
|
103
114
|
sleeveScale: 1,
|
|
104
115
|
fitEaseScale: 1.02
|
|
105
|
-
},
|
|
116
|
+
}, re = {
|
|
106
117
|
scaleX: 1,
|
|
107
118
|
scaleY: 1,
|
|
108
119
|
scaleZ: 1,
|
|
109
120
|
sleeveScale: 1,
|
|
110
121
|
fitEaseScale: 1
|
|
111
|
-
},
|
|
122
|
+
}, ie = {
|
|
112
123
|
slim: {
|
|
113
124
|
x: .95,
|
|
114
125
|
y: .95,
|
|
@@ -127,7 +138,7 @@ var k = .82, A = 2.1, j = .85, M = 1.8, N = .84, P = 2.1, ee = .8, F = 1.7, te =
|
|
|
127
138
|
z: 1.02,
|
|
128
139
|
ease: 1.03
|
|
129
140
|
}
|
|
130
|
-
},
|
|
141
|
+
}, ae = {
|
|
131
142
|
narrow: {
|
|
132
143
|
width: .97,
|
|
133
144
|
shoulder: .97
|
|
@@ -140,7 +151,7 @@ var k = .82, A = 2.1, j = .85, M = 1.8, N = .84, P = 2.1, ee = .8, F = 1.7, te =
|
|
|
140
151
|
width: 1.03,
|
|
141
152
|
shoulder: 1.04
|
|
142
153
|
}
|
|
143
|
-
},
|
|
154
|
+
}, oe = {
|
|
144
155
|
tapered: {
|
|
145
156
|
depth: .98,
|
|
146
157
|
vertical: .995,
|
|
@@ -157,114 +168,111 @@ var k = .82, A = 2.1, j = .85, M = 1.8, N = .84, P = 2.1, ee = .8, F = 1.7, te =
|
|
|
157
168
|
hip: 1.03
|
|
158
169
|
}
|
|
159
170
|
};
|
|
160
|
-
function
|
|
161
|
-
return
|
|
171
|
+
function R(e, t, n, r) {
|
|
172
|
+
return !e || !t || t <= 0 ? 1 : T(e / t, n, r);
|
|
162
173
|
}
|
|
163
|
-
function
|
|
164
|
-
return !e ||
|
|
174
|
+
function z(e, t, n, r, i) {
|
|
175
|
+
return !e || t <= 0 ? 1 : T((e + n) / t, r, i);
|
|
165
176
|
}
|
|
166
|
-
function
|
|
167
|
-
return
|
|
177
|
+
function se(e) {
|
|
178
|
+
return ae[e?.taxonomy.upperBodySilhouette ?? "balanced"] ?? ae.balanced;
|
|
168
179
|
}
|
|
169
180
|
function ce(e) {
|
|
170
|
-
return oe[e?.taxonomy.
|
|
181
|
+
return oe[e?.taxonomy.torsoOrPelvisProfile ?? "balanced"] ?? oe.balanced;
|
|
171
182
|
}
|
|
172
183
|
function le(e) {
|
|
173
|
-
return se[e?.taxonomy.torsoOrPelvisProfile ?? "balanced"] ?? se.balanced;
|
|
174
|
-
}
|
|
175
|
-
function ue(e) {
|
|
176
184
|
if (!e) return !1;
|
|
177
185
|
let { metrics: t } = e;
|
|
178
186
|
return !!(t.heightCm || t.chestCm || t.waistCm || t.shoulderWidthCm || t.armLengthCm || t.torsoLengthCm || t.neckToHipCm);
|
|
179
187
|
}
|
|
180
|
-
function
|
|
181
|
-
let { metrics: n } = e, r =
|
|
188
|
+
function ue(e, t) {
|
|
189
|
+
let { metrics: n } = e, r = se(e), i = ce(e), a = Math.max(z(n.shoulderWidthCm, t.refShoulderWidthCm, t.shoulderEaseCm * .55, .88, 1.3), z(n.chestCm, t.refChestCircumferenceCm, t.chestEaseCm * .35, .9, 1.34), z(n.waistCm, t.refWaistCircumferenceCm, t.waistEaseCm * .3, .9, 1.3)) * r.width, o = Math.max(R(n.heightCm, t.refHeightCm, .9, 1.18), z(n.torsoLengthCm ?? n.neckToHipCm, t.refTorsoLengthCm, t.torsoEaseCm * .2, .9, 1.16)) * i.vertical, s = Math.max(z(n.chestCm, t.refChestCircumferenceCm, t.chestEaseCm * .15, .9, 1.34), z(n.waistCm, t.refWaistCircumferenceCm, t.waistEaseCm * .1, .9, 1.28)) * i.depth;
|
|
182
190
|
return {
|
|
183
|
-
scaleX:
|
|
184
|
-
scaleY:
|
|
185
|
-
scaleZ:
|
|
186
|
-
sleeveScale:
|
|
187
|
-
fitEaseScale:
|
|
191
|
+
scaleX: T(a, A, j),
|
|
192
|
+
scaleY: T(o, M, N),
|
|
193
|
+
scaleZ: T(s, P, ee),
|
|
194
|
+
sleeveScale: T(R(n.armLengthCm, t.refArmLengthCm, .9, 1.16), F, I),
|
|
195
|
+
fitEaseScale: T(t.fitEaseScale * (r.width * .5 + i.depth * .5), L, te)
|
|
188
196
|
};
|
|
189
197
|
}
|
|
190
|
-
function
|
|
191
|
-
let { metrics: n } = t, r =
|
|
198
|
+
function de(e, t) {
|
|
199
|
+
let { metrics: n } = t, r = se(t), i = ce(t), a = R(e.shoulderWidthCm, n.shoulderWidthCm, .9, 1.14) * r.shoulder, o = R(e.chestCircumferenceCm, n.chestCm, .9, 1.15), s = R(e.waistCircumferenceCm, n.waistCm, .9, 1.15);
|
|
192
200
|
return {
|
|
193
|
-
torsoScale:
|
|
201
|
+
torsoScale: R(e.torsoLengthCm, n.torsoLengthCm ?? n.neckToHipCm, .9, 1.14),
|
|
194
202
|
chestScale: o,
|
|
195
203
|
waistScale: s,
|
|
196
|
-
hipScale:
|
|
197
|
-
shoulderAdjust:
|
|
204
|
+
hipScale: T(s * .6 + i.hip * .4, .92, 1.14),
|
|
205
|
+
shoulderAdjust: T(a - 1, -.12, .12),
|
|
198
206
|
postureAdjust: "neutral"
|
|
199
207
|
};
|
|
200
208
|
}
|
|
201
|
-
function
|
|
202
|
-
let r =
|
|
209
|
+
function fe(e, t, n) {
|
|
210
|
+
let r = ce(t), i = T(1 + n.shoulderAdjust, .92, 1.14) * .3 + n.chestScale * .45 + n.waistScale * .25, a = n.chestScale * .45 + n.waistScale * .25 + n.hipScale * .3, o = R(e.armLengthCm, t.metrics.armLengthCm, .9, 1.16), s = Math.max(n.chestScale, n.waistScale, n.hipScale);
|
|
203
211
|
return {
|
|
204
|
-
scaleX:
|
|
205
|
-
scaleY:
|
|
206
|
-
scaleZ:
|
|
207
|
-
sleeveScale:
|
|
208
|
-
fitEaseScale:
|
|
212
|
+
scaleX: T(i, .92, 1.16),
|
|
213
|
+
scaleY: T(n.torsoScale * r.vertical, .92, 1.14),
|
|
214
|
+
scaleZ: T(a * r.depth, .92, 1.18),
|
|
215
|
+
sleeveScale: T(o, F, I),
|
|
216
|
+
fitEaseScale: T(1 + (s - 1) * .22, .99, 1.08)
|
|
209
217
|
};
|
|
210
218
|
}
|
|
211
|
-
function
|
|
219
|
+
function pe(e, t) {
|
|
212
220
|
if (!t || !Number.isFinite(t) || t <= 0) return e;
|
|
213
|
-
let n =
|
|
221
|
+
let n = T(t, .88, 1.2), r = 1 + (n - 1) * .35;
|
|
214
222
|
return {
|
|
215
|
-
scaleX:
|
|
216
|
-
scaleY:
|
|
217
|
-
scaleZ:
|
|
218
|
-
sleeveScale:
|
|
219
|
-
fitEaseScale:
|
|
223
|
+
scaleX: T(e.scaleX * n, A, j),
|
|
224
|
+
scaleY: T(e.scaleY * r, M, N),
|
|
225
|
+
scaleZ: T(e.scaleZ * n, P, ee),
|
|
226
|
+
sleeveScale: T(e.sleeveScale * r, F, I),
|
|
227
|
+
fitEaseScale: T(e.fitEaseScale * n, L, te)
|
|
220
228
|
};
|
|
221
229
|
}
|
|
222
|
-
function
|
|
223
|
-
let n =
|
|
230
|
+
function me(e, t) {
|
|
231
|
+
let n = ie[t];
|
|
224
232
|
return {
|
|
225
|
-
scaleX:
|
|
226
|
-
scaleY:
|
|
227
|
-
scaleZ:
|
|
233
|
+
scaleX: T(e.scaleX * n.x, A, j),
|
|
234
|
+
scaleY: T(e.scaleY * n.y, M, N),
|
|
235
|
+
scaleZ: T(e.scaleZ * n.z, P, ee),
|
|
228
236
|
sleeveScale: e.sleeveScale,
|
|
229
|
-
fitEaseScale:
|
|
237
|
+
fitEaseScale: T(e.fitEaseScale * n.ease, L, te)
|
|
230
238
|
};
|
|
231
239
|
}
|
|
232
|
-
function
|
|
240
|
+
function he(e, t) {
|
|
233
241
|
return {
|
|
234
|
-
scaleX:
|
|
235
|
-
scaleY:
|
|
236
|
-
scaleZ:
|
|
237
|
-
sleeveScale:
|
|
238
|
-
fitEaseScale:
|
|
242
|
+
scaleX: T(e.scaleX * t.scaleX, A, j),
|
|
243
|
+
scaleY: T(e.scaleY * t.scaleY, M, N),
|
|
244
|
+
scaleZ: T(e.scaleZ * t.scaleZ, P, ee),
|
|
245
|
+
sleeveScale: T(e.sleeveScale * t.sleeveScale, F, I),
|
|
246
|
+
fitEaseScale: T(e.fitEaseScale * t.fitEaseScale, L, te)
|
|
239
247
|
};
|
|
240
248
|
}
|
|
241
|
-
function
|
|
242
|
-
let o =
|
|
249
|
+
function ge({ measurements: e, measurementScale: t, presetSelection: n, fitType: r = "regular", garmentScaleHint: i = null, spec: a = D }) {
|
|
250
|
+
let o = le(n), s = o && n ? ue(n, a) : t ?? ne, c = o && n && e ? de(e, n) : null;
|
|
243
251
|
return {
|
|
244
|
-
scale:
|
|
252
|
+
scale: me(pe(he(s, e && n && c ? fe(e, n, c) : re), i), r),
|
|
245
253
|
morph: c
|
|
246
254
|
};
|
|
247
255
|
}
|
|
248
256
|
//#endregion
|
|
249
257
|
//#region src/api/EverClient.ts
|
|
250
|
-
var
|
|
251
|
-
function
|
|
258
|
+
var _e = "http://localhost:8000/api/v1";
|
|
259
|
+
function ve(e) {
|
|
252
260
|
return e.replace(/\/+$/, "");
|
|
253
261
|
}
|
|
254
|
-
function
|
|
262
|
+
function ye(e) {
|
|
255
263
|
try {
|
|
256
264
|
return new URL(e).origin;
|
|
257
265
|
} catch {
|
|
258
266
|
return "";
|
|
259
267
|
}
|
|
260
268
|
}
|
|
261
|
-
var
|
|
269
|
+
var be = class {
|
|
262
270
|
baseUrl;
|
|
263
271
|
apiOrigin;
|
|
264
272
|
apiKey;
|
|
265
273
|
constructor(e) {
|
|
266
|
-
let t = typeof e == "string" ? { baseUrl: e } : e ?? {}, n =
|
|
267
|
-
this.baseUrl = n, this.apiOrigin =
|
|
274
|
+
let t = typeof e == "string" ? { baseUrl: e } : e ?? {}, n = ve(t.baseUrl ?? "http://localhost:8000/api/v1");
|
|
275
|
+
this.baseUrl = n, this.apiOrigin = ye(n), this.apiKey = t.apiKey;
|
|
268
276
|
}
|
|
269
277
|
resolveAssetUrl(e) {
|
|
270
278
|
return e ? e.startsWith("http://") || e.startsWith("https://") ? e : e.startsWith("/") ? this.apiOrigin ? `${this.apiOrigin}${e}` : e : this.apiOrigin ? `${this.apiOrigin}/${e}` : `/${e}` : null;
|
|
@@ -391,32 +399,32 @@ var xe = class {
|
|
|
391
399
|
return `Request failed with status ${e.status}`;
|
|
392
400
|
}
|
|
393
401
|
}
|
|
394
|
-
},
|
|
395
|
-
function
|
|
402
|
+
}, xe = "M", Se = "male-m-balanced-balanced", Ce = "female-m-balanced-balanced", we = "rigged_avatar";
|
|
403
|
+
function Te(e, t) {
|
|
396
404
|
if (!t) return "";
|
|
397
405
|
if (/^https?:\/\//.test(t)) return t;
|
|
398
406
|
let n = t.startsWith("/") ? t : `/${t}`;
|
|
399
407
|
return n.startsWith("/assets/") || n.startsWith("/static/") ? n : e.resolveAssetUrl(n) ?? n;
|
|
400
408
|
}
|
|
401
|
-
function
|
|
409
|
+
function Ee(e) {
|
|
402
410
|
return e === "female" ? "female" : "male";
|
|
403
411
|
}
|
|
404
|
-
function
|
|
412
|
+
function De(e, t = {}) {
|
|
405
413
|
let n = t.renderMode ?? "rigged_avatar", r = t.legacyPresetId ?? "rigged_avatar", i = `/assets/body-presets/${r}.glb`;
|
|
406
414
|
return e === r || n !== "preset-native" ? i : `/assets/body-presets/archive/${e}.glb`;
|
|
407
415
|
}
|
|
408
|
-
function
|
|
409
|
-
return e === "female" ?
|
|
416
|
+
function Oe(e) {
|
|
417
|
+
return e === "female" ? Ce : Se;
|
|
410
418
|
}
|
|
411
|
-
function
|
|
419
|
+
function ke(e, t) {
|
|
412
420
|
return {
|
|
413
421
|
id: e.id,
|
|
414
422
|
presetId: e.preset_id,
|
|
415
|
-
baseGender:
|
|
423
|
+
baseGender: Ee(e.base_gender),
|
|
416
424
|
sizeBand: e.size_band,
|
|
417
425
|
upperBodySilhouette: e.upper_body_silhouette,
|
|
418
426
|
torsoOrPelvisProfile: e.torso_or_pelvis_profile,
|
|
419
|
-
modelUrl:
|
|
427
|
+
modelUrl: Te(t, e.model_url),
|
|
420
428
|
heightCm: e.height_cm ?? null,
|
|
421
429
|
chestCm: e.chest_cm ?? null,
|
|
422
430
|
waistCm: e.waist_cm ?? null,
|
|
@@ -428,26 +436,26 @@ function Ae(e, t) {
|
|
|
428
436
|
neckToHipCm: e.neck_to_hip_cm ?? null
|
|
429
437
|
};
|
|
430
438
|
}
|
|
431
|
-
function
|
|
439
|
+
function Ae(e, t = {}) {
|
|
432
440
|
return {
|
|
433
441
|
...e,
|
|
434
|
-
modelUrl: e.modelUrl ||
|
|
442
|
+
modelUrl: e.modelUrl || De(e.presetId, t)
|
|
435
443
|
};
|
|
436
444
|
}
|
|
437
|
-
function
|
|
438
|
-
return e.length === 0 ? null :
|
|
445
|
+
function je(e, t = {}) {
|
|
446
|
+
return e.length === 0 ? null : Ae(e.find((e) => e.sizeBand === xe) || e[Math.floor(e.length / 2)], t);
|
|
439
447
|
}
|
|
440
|
-
function
|
|
441
|
-
let n =
|
|
448
|
+
function Me(e, t = {}) {
|
|
449
|
+
let n = Oe(e);
|
|
442
450
|
return {
|
|
443
451
|
id: null,
|
|
444
452
|
presetId: n,
|
|
445
|
-
label: `${e === "female" ? "여성" : "남성"} 기본 ${
|
|
446
|
-
modelUrl:
|
|
453
|
+
label: `${e === "female" ? "여성" : "남성"} 기본 ${xe}`,
|
|
454
|
+
modelUrl: De(n, t),
|
|
447
455
|
gender: e,
|
|
448
456
|
source: "fallback",
|
|
449
457
|
taxonomy: {
|
|
450
|
-
sizeBand:
|
|
458
|
+
sizeBand: xe,
|
|
451
459
|
upperBodySilhouette: "balanced",
|
|
452
460
|
torsoOrPelvisProfile: "balanced"
|
|
453
461
|
},
|
|
@@ -464,8 +472,8 @@ function Ne(e, t = {}) {
|
|
|
464
472
|
}
|
|
465
473
|
};
|
|
466
474
|
}
|
|
467
|
-
function
|
|
468
|
-
let r =
|
|
475
|
+
function Ne(e, t, n = {}) {
|
|
476
|
+
let r = Ae(e, n);
|
|
469
477
|
return {
|
|
470
478
|
id: r.id,
|
|
471
479
|
presetId: r.presetId,
|
|
@@ -491,65 +499,69 @@ function Pe(e, t, n = {}) {
|
|
|
491
499
|
}
|
|
492
500
|
};
|
|
493
501
|
}
|
|
494
|
-
function
|
|
502
|
+
function Pe(e, t) {
|
|
495
503
|
let n = { gender: t };
|
|
496
504
|
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;
|
|
497
505
|
}
|
|
498
506
|
//#endregion
|
|
499
507
|
//#region src/hooks/useBodyPresetSelection.ts
|
|
500
|
-
var
|
|
501
|
-
function
|
|
508
|
+
var Fe = new be();
|
|
509
|
+
function Ie(e, t) {
|
|
502
510
|
return {
|
|
503
|
-
selection:
|
|
511
|
+
selection: Me(e, t),
|
|
504
512
|
loading: !0,
|
|
505
513
|
error: null
|
|
506
514
|
};
|
|
507
515
|
}
|
|
508
|
-
function
|
|
509
|
-
let
|
|
510
|
-
gender:
|
|
511
|
-
renderMode:
|
|
512
|
-
legacyPresetId:
|
|
513
|
-
}, [
|
|
516
|
+
function Le(e, t = {}) {
|
|
517
|
+
let i = Ee(t.gender), o = t.renderMode, s = t.legacyPresetId, c = r(() => ({
|
|
518
|
+
gender: i,
|
|
519
|
+
renderMode: o,
|
|
520
|
+
legacyPresetId: s
|
|
521
|
+
}), [
|
|
522
|
+
i,
|
|
523
|
+
s,
|
|
524
|
+
o
|
|
525
|
+
]), [l, u] = a(() => Ie(i, c));
|
|
514
526
|
return n(() => {
|
|
515
527
|
let t = new AbortController();
|
|
516
528
|
async function n() {
|
|
517
|
-
|
|
529
|
+
u((e) => ({
|
|
518
530
|
...e,
|
|
519
531
|
loading: !0,
|
|
520
532
|
error: null
|
|
521
533
|
}));
|
|
522
534
|
try {
|
|
523
535
|
if (e) {
|
|
524
|
-
let n =
|
|
536
|
+
let n = Ne(ke(await Fe.matchBodyPreset(Pe(e, c.gender)), Fe), "match", c);
|
|
525
537
|
if (t.signal.aborted) return;
|
|
526
|
-
|
|
538
|
+
u({
|
|
527
539
|
selection: n,
|
|
528
540
|
loading: !1,
|
|
529
541
|
error: null
|
|
530
542
|
});
|
|
531
543
|
return;
|
|
532
544
|
}
|
|
533
|
-
let n = (await
|
|
545
|
+
let n = (await Fe.listBodyPresets(c.gender)).map((e) => ke(e, Fe));
|
|
534
546
|
if (t.signal.aborted) return;
|
|
535
|
-
let
|
|
536
|
-
if (
|
|
537
|
-
|
|
538
|
-
selection:
|
|
547
|
+
let r = je(n, c);
|
|
548
|
+
if (r) {
|
|
549
|
+
u({
|
|
550
|
+
selection: Ne(r, "default", c),
|
|
539
551
|
loading: !1,
|
|
540
552
|
error: null
|
|
541
553
|
});
|
|
542
554
|
return;
|
|
543
555
|
}
|
|
544
|
-
|
|
545
|
-
selection:
|
|
556
|
+
u({
|
|
557
|
+
selection: Me(c.gender, c),
|
|
546
558
|
loading: !1,
|
|
547
559
|
error: "바디 프리셋 응답이 비어 있어 기본 프리셋으로 대체했습니다."
|
|
548
560
|
});
|
|
549
561
|
} catch (e) {
|
|
550
562
|
if (t.signal.aborted) return;
|
|
551
|
-
|
|
552
|
-
selection:
|
|
563
|
+
u({
|
|
564
|
+
selection: Me(c.gender, c),
|
|
553
565
|
loading: !1,
|
|
554
566
|
error: e instanceof Error ? e.message : "바디 프리셋을 불러오지 못해 기본 프리셋으로 대체했습니다."
|
|
555
567
|
});
|
|
@@ -558,16 +570,11 @@ function Re(e, t = {}) {
|
|
|
558
570
|
return n(), () => {
|
|
559
571
|
t.abort();
|
|
560
572
|
};
|
|
561
|
-
}, [
|
|
562
|
-
r,
|
|
563
|
-
o,
|
|
564
|
-
e,
|
|
565
|
-
i
|
|
566
|
-
]), c;
|
|
573
|
+
}, [e, c]), l;
|
|
567
574
|
}
|
|
568
575
|
//#endregion
|
|
569
576
|
//#region src/types/pose.ts
|
|
570
|
-
var
|
|
577
|
+
var B = {
|
|
571
578
|
NOSE: 0,
|
|
572
579
|
LEFT_EYE_INNER: 1,
|
|
573
580
|
LEFT_EYE: 2,
|
|
@@ -601,17 +608,17 @@ var z = {
|
|
|
601
608
|
RIGHT_HEEL: 30,
|
|
602
609
|
LEFT_FOOT_INDEX: 31,
|
|
603
610
|
RIGHT_FOOT_INDEX: 32
|
|
604
|
-
},
|
|
611
|
+
}, Re = {
|
|
605
612
|
positionAlpha: .7,
|
|
606
613
|
rotationAlpha: .6,
|
|
607
614
|
visibilityThreshold: .5
|
|
608
|
-
},
|
|
609
|
-
function
|
|
610
|
-
return e ? (e.visibility ?? 1) >=
|
|
615
|
+
}, ze = .5;
|
|
616
|
+
function Be(e) {
|
|
617
|
+
return e ? (e.visibility ?? 1) >= ze : !1;
|
|
611
618
|
}
|
|
612
619
|
function Ve(e, t) {
|
|
613
|
-
let n = e[
|
|
614
|
-
if (!
|
|
620
|
+
let n = e[B.NOSE], r = e[B.LEFT_EYE], i = e[B.LEFT_ANKLE], a = e[B.RIGHT_ANKLE];
|
|
621
|
+
if (!Be(n) || !Be(r) || !Be(i) || !Be(a)) return 0;
|
|
615
622
|
let o = n.y - (r.y - n.y) * 2, s = (Math.max(i.y, a.y) - o) * t;
|
|
616
623
|
return Number.isFinite(s) && s > 0 ? s : 0;
|
|
617
624
|
}
|
|
@@ -637,7 +644,7 @@ function Ue(e) {
|
|
|
637
644
|
return .88;
|
|
638
645
|
}
|
|
639
646
|
function V(e, t, n, r) {
|
|
640
|
-
if (!
|
|
647
|
+
if (!Be(e) || !Be(t)) return null;
|
|
641
648
|
let i = (e.x - t.x) * n, a = (e.y - t.y) * r, o = Math.hypot(i, a);
|
|
642
649
|
return Number.isFinite(o) && o > 0 ? o : null;
|
|
643
650
|
}
|
|
@@ -683,7 +690,7 @@ function Xe(e, t, n = null, r = null, i = 1280, a = 720) {
|
|
|
683
690
|
measurementMethod: s,
|
|
684
691
|
measuredAt: null
|
|
685
692
|
};
|
|
686
|
-
let c = V(e[
|
|
693
|
+
let c = V(e[B.LEFT_SHOULDER], e[B.RIGHT_SHOULDER], i, a), l = V(e[B.LEFT_HIP], e[B.RIGHT_HIP], i, a), u = V(e[B.LEFT_SHOULDER], e[B.LEFT_ELBOW], i, a), d = V(e[B.LEFT_ELBOW], e[B.LEFT_WRIST], i, a), f = V(e[B.RIGHT_SHOULDER], e[B.RIGHT_ELBOW], i, a), p = V(e[B.RIGHT_ELBOW], e[B.RIGHT_WRIST], i, a), m = u !== null && d !== null ? u + d : null, h = f !== null && p !== null ? f + p : null, g = V(e[B.LEFT_HIP], e[B.LEFT_KNEE], i, a), _ = V(e[B.LEFT_KNEE], e[B.LEFT_ANKLE], i, a), v = V(e[B.RIGHT_HIP], e[B.RIGHT_KNEE], i, a), y = V(e[B.RIGHT_KNEE], e[B.RIGHT_ANKLE], i, a), b = g !== null && _ !== null ? g + _ : null, x = v !== null && y !== null ? v + y : null, S = Ge([V(e[B.LEFT_SHOULDER], e[B.LEFT_HIP], i, a), V(e[B.RIGHT_SHOULDER], e[B.RIGHT_HIP], i, a)]), C = H(c === null ? null : c * o), w = H(l === null ? null : l * o), T = H(Ge([m === null ? null : m * o, h === null ? null : h * o])), E = H(Ge([b === null ? null : b * o, x === null ? null : x * o])), D = H(S === null ? null : S * o), O = C === null ? null : C * 2.2, k = w === null ? null : w * 2.1;
|
|
687
694
|
if (r) {
|
|
688
695
|
let e = r.shoulderWidthPx * o;
|
|
689
696
|
if (O = H(Ye(Math.max(r.chestWidthPx * o / 2, 0), Math.max(e * .28 / 2, 0))), k = H(Ye(Math.max(r.waistWidthPx * o / 2, 0), Math.max(r.hipWidthPx * o * .26 / 2, 0))), n !== null && n > 0) {
|
|
@@ -818,7 +825,7 @@ function nt() {
|
|
|
818
825
|
return;
|
|
819
826
|
}
|
|
820
827
|
if (p.current = tt(m.current, r) < e.motionThreshold ? p.current + 1 : 1, m.current = r, p.current < e.stableFrameCount) return;
|
|
821
|
-
let i = Xe(t, e.referenceHeightCm, e.weightKg, n.silhouetteWidths ?? null, n.imageWidth ?? 1280, n.imageHeight ?? 720), a = (/* @__PURE__ */ new Date()).toISOString(), s = Qe(i), l =
|
|
828
|
+
let i = Xe(t, e.referenceHeightCm, e.weightKg, n.silhouetteWidths ?? null, n.imageWidth ?? 1280, n.imageHeight ?? 720), a = (/* @__PURE__ */ new Date()).toISOString(), s = Qe(i), l = k(i);
|
|
822
829
|
o({
|
|
823
830
|
...i,
|
|
824
831
|
measuredAt: a
|
|
@@ -911,7 +918,7 @@ function st(e, t, n, r, i = at, a = ot) {
|
|
|
911
918
|
}
|
|
912
919
|
function ct(e, t, n, r) {
|
|
913
920
|
if (r.length < 33) return null;
|
|
914
|
-
let i = r[
|
|
921
|
+
let i = r[B.LEFT_SHOULDER], a = r[B.RIGHT_SHOULDER], o = r[B.LEFT_HIP], s = r[B.RIGHT_HIP], c = r[B.LEFT_KNEE], l = r[B.RIGHT_KNEE];
|
|
915
922
|
if (!i || !a || !o || !s) return null;
|
|
916
923
|
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 = st(e, t, n, u), h = st(e, t, n, f), g = st(e, t, n, d), _ = st(e, t, n, p);
|
|
917
924
|
return m === null || h === null || g === null || _ === null ? null : {
|
|
@@ -999,7 +1006,7 @@ function mt(e, t, n) {
|
|
|
999
1006
|
}
|
|
1000
1007
|
//#endregion
|
|
1001
1008
|
//#region src/pose/landmarkerFactory.ts
|
|
1002
|
-
var ht = "0.10.32", gt = `https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${ht}/wasm`, _t =
|
|
1009
|
+
var ht = "0.10.32", gt = `https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${ht}/wasm`, _t = 1, vt = 3, yt = .5, bt = {
|
|
1003
1010
|
lite: "https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/latest/pose_landmarker_lite.task",
|
|
1004
1011
|
full: "https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_full/float16/latest/pose_landmarker_full.task",
|
|
1005
1012
|
heavy: "https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_heavy/float16/latest/pose_landmarker_heavy.task"
|
|
@@ -1034,7 +1041,7 @@ async function xt(e, t, n, r, i = 3) {
|
|
|
1034
1041
|
}
|
|
1035
1042
|
//#endregion
|
|
1036
1043
|
//#region src/pose/landmarkPoseSolver.ts
|
|
1037
|
-
var St = new b.Vector3(), Ct = new b.Vector3(), wt = new b.Vector3(), Tt = new b.Quaternion(), Et = new b.Vector3(), Dt = new b.Vector3(), Ot = new b.Vector3(0, -1, 0), kt = new b.Vector3(1, 0, 0), At = new b.Vector3(-1, 0, 0), jt = new b.Vector3(0, 1, 0), Mt = [
|
|
1044
|
+
var St = new b.Vector3(), Ct = new b.Vector3(), wt = new b.Vector3(), Tt = new b.Quaternion(), Et = new b.Vector3(), Dt = new b.Vector3(), Ot = new b.Vector3(0, -1, 0), kt = new b.Vector3(1, 0, 0), At = new b.Vector3(-1, 0, 0), jt = new b.Vector3(0, 1, 0), Mt = [B.LEFT_SHOULDER, B.RIGHT_SHOULDER], Nt = [B.LEFT_HIP, B.RIGHT_HIP], Pt = [B.LEFT_EAR, B.RIGHT_EAR], Ft = [B.LEFT_INDEX, B.LEFT_PINKY], It = [B.RIGHT_INDEX, B.RIGHT_PINKY], Lt = {
|
|
1038
1045
|
Hips: {
|
|
1039
1046
|
from: Nt,
|
|
1040
1047
|
to: Mt,
|
|
@@ -1055,76 +1062,76 @@ var St = new b.Vector3(), Ct = new b.Vector3(), wt = new b.Vector3(), Tt = new b
|
|
|
1055
1062
|
},
|
|
1056
1063
|
LeftShoulder: {
|
|
1057
1064
|
from: Mt,
|
|
1058
|
-
to:
|
|
1065
|
+
to: B.LEFT_SHOULDER,
|
|
1059
1066
|
restDir: kt,
|
|
1060
1067
|
influence: .45
|
|
1061
1068
|
},
|
|
1062
1069
|
LeftUpperArm: {
|
|
1063
|
-
from:
|
|
1064
|
-
to:
|
|
1070
|
+
from: B.LEFT_SHOULDER,
|
|
1071
|
+
to: B.LEFT_ELBOW,
|
|
1065
1072
|
restDir: kt
|
|
1066
1073
|
},
|
|
1067
1074
|
LeftLowerArm: {
|
|
1068
|
-
from:
|
|
1069
|
-
to:
|
|
1075
|
+
from: B.LEFT_ELBOW,
|
|
1076
|
+
to: B.LEFT_WRIST,
|
|
1070
1077
|
restDir: kt
|
|
1071
1078
|
},
|
|
1072
1079
|
LeftHand: {
|
|
1073
|
-
from:
|
|
1080
|
+
from: B.LEFT_WRIST,
|
|
1074
1081
|
to: Ft,
|
|
1075
1082
|
restDir: kt,
|
|
1076
1083
|
influence: .65
|
|
1077
1084
|
},
|
|
1078
1085
|
RightShoulder: {
|
|
1079
1086
|
from: Mt,
|
|
1080
|
-
to:
|
|
1087
|
+
to: B.RIGHT_SHOULDER,
|
|
1081
1088
|
restDir: At,
|
|
1082
1089
|
influence: .45
|
|
1083
1090
|
},
|
|
1084
1091
|
RightUpperArm: {
|
|
1085
|
-
from:
|
|
1086
|
-
to:
|
|
1092
|
+
from: B.RIGHT_SHOULDER,
|
|
1093
|
+
to: B.RIGHT_ELBOW,
|
|
1087
1094
|
restDir: At
|
|
1088
1095
|
},
|
|
1089
1096
|
RightLowerArm: {
|
|
1090
|
-
from:
|
|
1091
|
-
to:
|
|
1097
|
+
from: B.RIGHT_ELBOW,
|
|
1098
|
+
to: B.RIGHT_WRIST,
|
|
1092
1099
|
restDir: At
|
|
1093
1100
|
},
|
|
1094
1101
|
RightHand: {
|
|
1095
|
-
from:
|
|
1102
|
+
from: B.RIGHT_WRIST,
|
|
1096
1103
|
to: It,
|
|
1097
1104
|
restDir: At,
|
|
1098
1105
|
influence: .65
|
|
1099
1106
|
},
|
|
1100
1107
|
LeftUpperLeg: {
|
|
1101
|
-
from:
|
|
1102
|
-
to:
|
|
1108
|
+
from: B.LEFT_HIP,
|
|
1109
|
+
to: B.LEFT_KNEE,
|
|
1103
1110
|
restDir: Ot
|
|
1104
1111
|
},
|
|
1105
1112
|
LeftLowerLeg: {
|
|
1106
|
-
from:
|
|
1107
|
-
to:
|
|
1113
|
+
from: B.LEFT_KNEE,
|
|
1114
|
+
to: B.LEFT_ANKLE,
|
|
1108
1115
|
restDir: Ot
|
|
1109
1116
|
},
|
|
1110
1117
|
LeftFoot: {
|
|
1111
|
-
from:
|
|
1112
|
-
to:
|
|
1118
|
+
from: B.LEFT_ANKLE,
|
|
1119
|
+
to: B.LEFT_FOOT_INDEX,
|
|
1113
1120
|
restDir: new b.Vector3(0, 0, 1)
|
|
1114
1121
|
},
|
|
1115
1122
|
RightUpperLeg: {
|
|
1116
|
-
from:
|
|
1117
|
-
to:
|
|
1123
|
+
from: B.RIGHT_HIP,
|
|
1124
|
+
to: B.RIGHT_KNEE,
|
|
1118
1125
|
restDir: Ot
|
|
1119
1126
|
},
|
|
1120
1127
|
RightLowerLeg: {
|
|
1121
|
-
from:
|
|
1122
|
-
to:
|
|
1128
|
+
from: B.RIGHT_KNEE,
|
|
1129
|
+
to: B.RIGHT_ANKLE,
|
|
1123
1130
|
restDir: Ot
|
|
1124
1131
|
},
|
|
1125
1132
|
RightFoot: {
|
|
1126
|
-
from:
|
|
1127
|
-
to:
|
|
1133
|
+
from: B.RIGHT_ANKLE,
|
|
1134
|
+
to: B.RIGHT_FOOT_INDEX,
|
|
1128
1135
|
restDir: new b.Vector3(0, 0, 1)
|
|
1129
1136
|
}
|
|
1130
1137
|
};
|
|
@@ -1161,66 +1168,69 @@ function Wt(e) {
|
|
|
1161
1168
|
}
|
|
1162
1169
|
//#endregion
|
|
1163
1170
|
//#region src/pose/poseSolver.ts
|
|
1164
|
-
var Gt = new b.Quaternion(), Kt = new b.Euler();
|
|
1165
|
-
function
|
|
1171
|
+
var Gt = new b.Quaternion(), Kt = new b.Euler(), qt = ["Hips", "Spine"];
|
|
1172
|
+
function Jt() {
|
|
1166
1173
|
return {
|
|
1167
1174
|
x: 0,
|
|
1168
1175
|
y: 0,
|
|
1169
1176
|
z: 0
|
|
1170
1177
|
};
|
|
1171
1178
|
}
|
|
1172
|
-
function
|
|
1179
|
+
function Yt(e) {
|
|
1173
1180
|
return Kt.setFromQuaternion(e, "XYZ"), {
|
|
1174
1181
|
x: Kt.x,
|
|
1175
1182
|
y: Kt.y,
|
|
1176
1183
|
z: Kt.z
|
|
1177
1184
|
};
|
|
1178
1185
|
}
|
|
1179
|
-
function
|
|
1180
|
-
return Ut(e, t, Gt, n) ?
|
|
1186
|
+
function Xt(e, t, n) {
|
|
1187
|
+
return Ut(e, t, Gt, n) ? Yt(Gt) : Jt();
|
|
1181
1188
|
}
|
|
1182
|
-
function
|
|
1183
|
-
if (Ut(e, t, Gt, n)) return
|
|
1189
|
+
function Zt(e, t, n) {
|
|
1190
|
+
if (Ut(e, t, Gt, n)) return Yt(Gt);
|
|
1184
1191
|
}
|
|
1185
|
-
function
|
|
1186
|
-
let t = e[
|
|
1192
|
+
function Qt(e) {
|
|
1193
|
+
let t = e[B.LEFT_HIP], n = e[B.RIGHT_HIP];
|
|
1187
1194
|
return {
|
|
1188
1195
|
x: ((t?.x ?? 0) + (n?.x ?? 0)) * .5,
|
|
1189
1196
|
y: ((t?.y ?? 0) + (n?.y ?? 0)) * .5,
|
|
1190
1197
|
z: ((t?.z ?? 0) + (n?.z ?? 0)) * .5
|
|
1191
1198
|
};
|
|
1192
1199
|
}
|
|
1193
|
-
function
|
|
1200
|
+
function $t(e, t = "normalized") {
|
|
1201
|
+
return e.length < 33 ? !1 : qt.every((n) => Ut(n, e, Gt, t));
|
|
1202
|
+
}
|
|
1203
|
+
function en(e, t) {
|
|
1194
1204
|
if (e.length < 33) return null;
|
|
1195
1205
|
let n = t && t.length >= 33 ? t : e, r = t && t.length >= 33 ? "world" : "normalized";
|
|
1196
|
-
return {
|
|
1206
|
+
return $t(n, r) ? {
|
|
1197
1207
|
hips: {
|
|
1198
|
-
position:
|
|
1199
|
-
rotation:
|
|
1208
|
+
position: Qt(e),
|
|
1209
|
+
rotation: Xt("Hips", n, r)
|
|
1200
1210
|
},
|
|
1201
|
-
spine:
|
|
1202
|
-
chest:
|
|
1203
|
-
leftUpperArm:
|
|
1204
|
-
leftLowerArm:
|
|
1205
|
-
rightUpperArm:
|
|
1206
|
-
rightLowerArm:
|
|
1207
|
-
leftUpperLeg:
|
|
1208
|
-
leftLowerLeg:
|
|
1209
|
-
rightUpperLeg:
|
|
1210
|
-
rightLowerLeg:
|
|
1211
|
-
};
|
|
1211
|
+
spine: Xt("Spine", n, r),
|
|
1212
|
+
chest: Xt("Chest", n, r),
|
|
1213
|
+
leftUpperArm: Xt("LeftUpperArm", n, r),
|
|
1214
|
+
leftLowerArm: Xt("LeftLowerArm", n, r),
|
|
1215
|
+
rightUpperArm: Xt("RightUpperArm", n, r),
|
|
1216
|
+
rightLowerArm: Xt("RightLowerArm", n, r),
|
|
1217
|
+
leftUpperLeg: Zt("LeftUpperLeg", n, r),
|
|
1218
|
+
leftLowerLeg: Zt("LeftLowerLeg", n, r),
|
|
1219
|
+
rightUpperLeg: Zt("RightUpperLeg", n, r),
|
|
1220
|
+
rightLowerLeg: Zt("RightLowerLeg", n, r)
|
|
1221
|
+
} : null;
|
|
1212
1222
|
}
|
|
1213
1223
|
//#endregion
|
|
1214
1224
|
//#region src/pose/segmentation.ts
|
|
1215
|
-
function
|
|
1225
|
+
function tn(e) {
|
|
1216
1226
|
if (!e || typeof e != "object") return null;
|
|
1217
1227
|
let t = e;
|
|
1218
1228
|
return typeof t.width != "number" || typeof t.height != "number" || typeof t.getAsFloat32Array != "function" ? null : t;
|
|
1219
1229
|
}
|
|
1220
|
-
function
|
|
1230
|
+
function nn(e) {
|
|
1221
1231
|
if (e) for (let t of e) t && typeof t == "object" && "close" in t && typeof t.close == "function" && t.close();
|
|
1222
1232
|
}
|
|
1223
|
-
function
|
|
1233
|
+
function rn(e, t, n) {
|
|
1224
1234
|
let r = t / n;
|
|
1225
1235
|
return {
|
|
1226
1236
|
shoulderWidthPx: e.shoulderWidthPx * r,
|
|
@@ -1230,48 +1240,80 @@ function en(e, t, n) {
|
|
|
1230
1240
|
};
|
|
1231
1241
|
}
|
|
1232
1242
|
//#endregion
|
|
1243
|
+
//#region src/pose/trackingConfidence.ts
|
|
1244
|
+
var an = [
|
|
1245
|
+
B.LEFT_SHOULDER,
|
|
1246
|
+
B.RIGHT_SHOULDER,
|
|
1247
|
+
B.LEFT_HIP,
|
|
1248
|
+
B.RIGHT_HIP
|
|
1249
|
+
], on = [
|
|
1250
|
+
B.NOSE,
|
|
1251
|
+
B.LEFT_EAR,
|
|
1252
|
+
B.RIGHT_EAR,
|
|
1253
|
+
B.LEFT_ELBOW,
|
|
1254
|
+
B.RIGHT_ELBOW,
|
|
1255
|
+
B.LEFT_WRIST,
|
|
1256
|
+
B.RIGHT_WRIST
|
|
1257
|
+
], sn = .35, cn = .05, ln = 2, un = .72, dn = .28;
|
|
1258
|
+
function fn(e) {
|
|
1259
|
+
return Number.isFinite(e) ? Math.max(0, Math.min(1, e)) : 0;
|
|
1260
|
+
}
|
|
1261
|
+
function pn(e, t, n) {
|
|
1262
|
+
let r = 0, i = 0;
|
|
1263
|
+
return t.forEach((t) => {
|
|
1264
|
+
let a = fn(e[t]?.visibility);
|
|
1265
|
+
a < n || (r += a, i += 1);
|
|
1266
|
+
}), i === 0 ? null : r / i;
|
|
1267
|
+
}
|
|
1268
|
+
function mn(e, t, n) {
|
|
1269
|
+
return t.reduce((t, r) => fn(e[r]?.visibility) >= n ? t + 1 : t, 0);
|
|
1270
|
+
}
|
|
1271
|
+
function hn(e) {
|
|
1272
|
+
if (!Array.isArray(e) || e.length < 33) return 0;
|
|
1273
|
+
let t = pn(e, an, 0);
|
|
1274
|
+
if (t === null) return 0;
|
|
1275
|
+
let n = pn(e, on, cn) ?? t, r = mn(e, an, sn), i = r >= ln ? 1 : r / ln;
|
|
1276
|
+
return (t * un + n * dn) * i;
|
|
1277
|
+
}
|
|
1278
|
+
//#endregion
|
|
1233
1279
|
//#region src/types/tracking.ts
|
|
1234
|
-
var
|
|
1280
|
+
var gn = "pose-0";
|
|
1235
1281
|
//#endregion
|
|
1236
1282
|
//#region src/pose/smoothing.ts
|
|
1237
|
-
function
|
|
1283
|
+
function _n(e) {
|
|
1238
1284
|
return typeof e == "number" ? e : 0;
|
|
1239
1285
|
}
|
|
1240
|
-
function
|
|
1286
|
+
function vn(e) {
|
|
1241
1287
|
return {
|
|
1242
1288
|
x: e.x,
|
|
1243
1289
|
y: e.y,
|
|
1244
1290
|
z: e.z,
|
|
1245
|
-
visibility:
|
|
1291
|
+
visibility: _n(e.visibility)
|
|
1246
1292
|
};
|
|
1247
1293
|
}
|
|
1248
|
-
function
|
|
1249
|
-
return e.map(
|
|
1250
|
-
}
|
|
1251
|
-
function on(e) {
|
|
1252
|
-
return rn(e);
|
|
1294
|
+
function yn(e) {
|
|
1295
|
+
return e.map(vn);
|
|
1253
1296
|
}
|
|
1254
|
-
function
|
|
1255
|
-
|
|
1256
|
-
return n < 0 && (n += t), n - Math.PI;
|
|
1297
|
+
function bn(e) {
|
|
1298
|
+
return vn(e);
|
|
1257
1299
|
}
|
|
1258
|
-
function
|
|
1259
|
-
return
|
|
1300
|
+
function xn(e, t, n) {
|
|
1301
|
+
return E(e + E(t - e) * n);
|
|
1260
1302
|
}
|
|
1261
|
-
var
|
|
1303
|
+
var Sn = class {
|
|
1262
1304
|
prev = null;
|
|
1263
1305
|
config;
|
|
1264
|
-
constructor(e =
|
|
1306
|
+
constructor(e = Re) {
|
|
1265
1307
|
this.config = e;
|
|
1266
1308
|
}
|
|
1267
1309
|
smooth(e) {
|
|
1268
1310
|
if (e.length === 0) return this.prev = null, [];
|
|
1269
|
-
let t =
|
|
1270
|
-
if (!this.prev || this.prev.length !== t.length) return this.prev = t.map(
|
|
1311
|
+
let t = yn(e);
|
|
1312
|
+
if (!this.prev || this.prev.length !== t.length) return this.prev = t.map(bn), t.map(bn);
|
|
1271
1313
|
let n = this.config.positionAlpha, r = t.map((e, t) => {
|
|
1272
1314
|
let r = this.prev[t];
|
|
1273
1315
|
return (e.visibility ?? 0) < this.config.visibilityThreshold ? {
|
|
1274
|
-
...
|
|
1316
|
+
...bn(r),
|
|
1275
1317
|
visibility: e.visibility
|
|
1276
1318
|
} : {
|
|
1277
1319
|
x: r.x + n * (e.x - r.x),
|
|
@@ -1280,23 +1322,23 @@ var ln = class {
|
|
|
1280
1322
|
visibility: e.visibility
|
|
1281
1323
|
};
|
|
1282
1324
|
});
|
|
1283
|
-
return this.prev = r.map(
|
|
1325
|
+
return this.prev = r.map(bn), r;
|
|
1284
1326
|
}
|
|
1285
1327
|
reset() {
|
|
1286
1328
|
this.prev = null;
|
|
1287
1329
|
}
|
|
1288
1330
|
};
|
|
1289
|
-
function
|
|
1331
|
+
function G(e, t, n) {
|
|
1290
1332
|
return {
|
|
1291
|
-
x:
|
|
1292
|
-
y:
|
|
1293
|
-
z:
|
|
1333
|
+
x: xn(e.x, t.x, n),
|
|
1334
|
+
y: xn(e.y, t.y, n),
|
|
1335
|
+
z: xn(e.z, t.z, n)
|
|
1294
1336
|
};
|
|
1295
1337
|
}
|
|
1296
|
-
function
|
|
1297
|
-
return t ? e ?
|
|
1338
|
+
function Cn(e, t, n) {
|
|
1339
|
+
return t ? e ? G(e, t, n) : t : e;
|
|
1298
1340
|
}
|
|
1299
|
-
function
|
|
1341
|
+
function wn(e, t, n = Re.rotationAlpha) {
|
|
1300
1342
|
return e ? {
|
|
1301
1343
|
hips: {
|
|
1302
1344
|
position: {
|
|
@@ -1304,29 +1346,29 @@ function dn(e, t, n = ze.rotationAlpha) {
|
|
|
1304
1346
|
y: e.hips.position.y + n * (t.hips.position.y - e.hips.position.y),
|
|
1305
1347
|
z: e.hips.position.z + n * (t.hips.position.z - e.hips.position.z)
|
|
1306
1348
|
},
|
|
1307
|
-
rotation:
|
|
1349
|
+
rotation: G(e.hips.rotation, t.hips.rotation, n)
|
|
1308
1350
|
},
|
|
1309
|
-
spine:
|
|
1310
|
-
chest:
|
|
1311
|
-
leftUpperArm:
|
|
1312
|
-
leftLowerArm:
|
|
1313
|
-
rightUpperArm:
|
|
1314
|
-
rightLowerArm:
|
|
1315
|
-
leftUpperLeg:
|
|
1316
|
-
leftLowerLeg:
|
|
1317
|
-
rightUpperLeg:
|
|
1318
|
-
rightLowerLeg:
|
|
1351
|
+
spine: G(e.spine, t.spine, n),
|
|
1352
|
+
chest: G(e.chest, t.chest, n),
|
|
1353
|
+
leftUpperArm: G(e.leftUpperArm, t.leftUpperArm, n),
|
|
1354
|
+
leftLowerArm: G(e.leftLowerArm, t.leftLowerArm, n),
|
|
1355
|
+
rightUpperArm: G(e.rightUpperArm, t.rightUpperArm, n),
|
|
1356
|
+
rightLowerArm: G(e.rightLowerArm, t.rightLowerArm, n),
|
|
1357
|
+
leftUpperLeg: Cn(e.leftUpperLeg, t.leftUpperLeg, n),
|
|
1358
|
+
leftLowerLeg: Cn(e.leftLowerLeg, t.leftLowerLeg, n),
|
|
1359
|
+
rightUpperLeg: Cn(e.rightUpperLeg, t.rightUpperLeg, n),
|
|
1360
|
+
rightLowerLeg: Cn(e.rightLowerLeg, t.rightLowerLeg, n)
|
|
1319
1361
|
} : t;
|
|
1320
1362
|
}
|
|
1321
1363
|
//#endregion
|
|
1322
1364
|
//#region src/tracking/personLock.ts
|
|
1323
|
-
var
|
|
1365
|
+
var Tn = .12, En = .35, Dn = .05, On = [
|
|
1324
1366
|
11,
|
|
1325
1367
|
12,
|
|
1326
1368
|
23,
|
|
1327
1369
|
24
|
|
1328
|
-
],
|
|
1329
|
-
function
|
|
1370
|
+
], kn = 2, An = .3;
|
|
1371
|
+
function jn(e) {
|
|
1330
1372
|
if (!e) return null;
|
|
1331
1373
|
let t = Math.max(0, Math.min(1, e.x)), n = Math.max(0, Math.min(1, e.y));
|
|
1332
1374
|
return {
|
|
@@ -1336,41 +1378,41 @@ function vn(e) {
|
|
|
1336
1378
|
h: Math.max(.01, Math.min(1 - n, e.h))
|
|
1337
1379
|
};
|
|
1338
1380
|
}
|
|
1339
|
-
function
|
|
1381
|
+
function Mn(e) {
|
|
1340
1382
|
if (!Array.isArray(e) || e.length === 0) return null;
|
|
1341
1383
|
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity, a = 0;
|
|
1342
1384
|
return e.forEach((e) => {
|
|
1343
|
-
!e || typeof e.x != "number" || typeof e.y != "number" || (e.visibility ?? 0) <
|
|
1344
|
-
}), a < 4 || !Number.isFinite(t) || !Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(i) ? null :
|
|
1385
|
+
!e || typeof e.x != "number" || typeof e.y != "number" || (e.visibility ?? 0) < En || (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);
|
|
1386
|
+
}), a < 4 || !Number.isFinite(t) || !Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(i) ? null : jn({
|
|
1345
1387
|
x: t,
|
|
1346
1388
|
y: n,
|
|
1347
1389
|
w: Math.max(.01, r - t),
|
|
1348
1390
|
h: Math.max(.01, i - n)
|
|
1349
1391
|
});
|
|
1350
1392
|
}
|
|
1351
|
-
function
|
|
1393
|
+
function Nn(e, t = Tn) {
|
|
1352
1394
|
if (!e) return null;
|
|
1353
1395
|
let n = e.w * t, r = e.h * t;
|
|
1354
|
-
return
|
|
1396
|
+
return jn({
|
|
1355
1397
|
x: e.x - n / 2,
|
|
1356
1398
|
y: e.y - r / 2,
|
|
1357
1399
|
w: e.w + n,
|
|
1358
1400
|
h: e.h + r
|
|
1359
1401
|
});
|
|
1360
1402
|
}
|
|
1361
|
-
function
|
|
1403
|
+
function Pn(e, t) {
|
|
1362
1404
|
if (!e || !t) return 0;
|
|
1363
1405
|
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);
|
|
1364
1406
|
if (o <= 0) return 0;
|
|
1365
1407
|
let s = e.w * e.h + t.w * t.h - o;
|
|
1366
1408
|
return s <= 0 ? 0 : o / s;
|
|
1367
1409
|
}
|
|
1368
|
-
function
|
|
1410
|
+
function Fn(e) {
|
|
1369
1411
|
return e.length === 0 ? 0 : e.reduce((e, t) => e + (t.visibility ?? 0), 0) / e.length;
|
|
1370
1412
|
}
|
|
1371
|
-
function
|
|
1413
|
+
function In(e, t = []) {
|
|
1372
1414
|
return e.flatMap((e, n) => {
|
|
1373
|
-
let r =
|
|
1415
|
+
let r = Mn(e), i = Nn(r);
|
|
1374
1416
|
return !r || !i ? [] : [{
|
|
1375
1417
|
poseIndex: n,
|
|
1376
1418
|
personId: `pose-${n}`,
|
|
@@ -1378,43 +1420,43 @@ function Cn(e, t = []) {
|
|
|
1378
1420
|
worldLandmarks: t[n] ?? null,
|
|
1379
1421
|
bounds: r,
|
|
1380
1422
|
expandedBounds: i,
|
|
1381
|
-
meanVisibility:
|
|
1423
|
+
meanVisibility: Fn(e),
|
|
1382
1424
|
area: i.w * i.h
|
|
1383
1425
|
}];
|
|
1384
1426
|
});
|
|
1385
1427
|
}
|
|
1386
|
-
function
|
|
1387
|
-
let n =
|
|
1428
|
+
function Ln(e, t) {
|
|
1429
|
+
let n = Pn(e.expandedBounds, t.expandedBounds);
|
|
1388
1430
|
return {
|
|
1389
1431
|
iou: n,
|
|
1390
1432
|
score: n * .75 + e.area * .25
|
|
1391
1433
|
};
|
|
1392
1434
|
}
|
|
1393
|
-
function
|
|
1435
|
+
function Rn(e, { previousCandidate: t, allowRelock: n = !1, minIouToKeep: r = Dn }) {
|
|
1394
1436
|
if (e.length === 0) return null;
|
|
1395
1437
|
let i = [...e].sort((e, t) => t.area * t.meanVisibility - e.area * e.meanVisibility);
|
|
1396
1438
|
if (!t) return i[0];
|
|
1397
1439
|
let a = null, o = -Infinity, s = 0;
|
|
1398
1440
|
return e.forEach((e) => {
|
|
1399
|
-
let { iou: n, score: r } =
|
|
1441
|
+
let { iou: n, score: r } = Ln(e, t);
|
|
1400
1442
|
r > o && (a = e, o = r, s = n);
|
|
1401
1443
|
}), a && s >= r ? a : n ? i[0] : null;
|
|
1402
1444
|
}
|
|
1403
|
-
function
|
|
1445
|
+
function zn(e, t) {
|
|
1404
1446
|
if (!t) return !0;
|
|
1405
1447
|
let n = 0, r = 0, i = 0;
|
|
1406
|
-
for (let t of
|
|
1448
|
+
for (let t of On) {
|
|
1407
1449
|
let a = e.landmarks[t];
|
|
1408
|
-
a && (a.visibility ?? 0) >
|
|
1450
|
+
a && (a.visibility ?? 0) > An && (n += a.x, r += a.y, i += 1);
|
|
1409
1451
|
}
|
|
1410
|
-
if (i <
|
|
1452
|
+
if (i < kn) return !0;
|
|
1411
1453
|
let a = n / i, o = r / i;
|
|
1412
1454
|
return a >= t.xMin && a <= t.xMax && o >= t.yMin && o <= t.yMax;
|
|
1413
1455
|
}
|
|
1414
|
-
function
|
|
1415
|
-
return t ? e.filter((e) =>
|
|
1456
|
+
function Bn(e, t) {
|
|
1457
|
+
return t ? e.filter((e) => zn(e, t)) : e;
|
|
1416
1458
|
}
|
|
1417
|
-
function
|
|
1459
|
+
function Vn(e) {
|
|
1418
1460
|
return e ? {
|
|
1419
1461
|
poseIndex: e.poseIndex,
|
|
1420
1462
|
personId: e.personId,
|
|
@@ -1424,18 +1466,18 @@ function On(e) {
|
|
|
1424
1466
|
}
|
|
1425
1467
|
//#endregion
|
|
1426
1468
|
//#region src/tracking/trackingState.ts
|
|
1427
|
-
var
|
|
1428
|
-
function
|
|
1469
|
+
var Hn = .55, Un = 640, Wn = 360;
|
|
1470
|
+
function Gn(e = null) {
|
|
1429
1471
|
return {
|
|
1430
1472
|
level: "idle",
|
|
1431
1473
|
reasons: ["no_person_detected"],
|
|
1432
1474
|
updatedAt: e
|
|
1433
1475
|
};
|
|
1434
1476
|
}
|
|
1435
|
-
function
|
|
1436
|
-
if (e < 1) return
|
|
1477
|
+
function Kn({ detectedPersonCount: e, isTracking: t, lockedPersonId: n = null, meanVisibility: r = null, frameWidth: i = 0, frameHeight: a = 0, updatedAt: o = Date.now() }) {
|
|
1478
|
+
if (e < 1) return Gn(o);
|
|
1437
1479
|
let s = [];
|
|
1438
|
-
return e > 1 && s.push("multi_person_detected"), i > 0 && a > 0 && (i <
|
|
1480
|
+
return e > 1 && s.push("multi_person_detected"), i > 0 && a > 0 && (i < Un || a < Wn) && s.push("resolution_too_low"), r !== null && r < Hn && s.push("low_visibility"), (!n || !t) && s.push("pose_not_locked"), s.length === 0 ? {
|
|
1439
1481
|
level: "good",
|
|
1440
1482
|
reasons: [],
|
|
1441
1483
|
updatedAt: o
|
|
@@ -1445,19 +1487,19 @@ function Nn({ detectedPersonCount: e, isTracking: t, lockedPersonId: n = null, m
|
|
|
1445
1487
|
updatedAt: o
|
|
1446
1488
|
};
|
|
1447
1489
|
}
|
|
1448
|
-
function
|
|
1490
|
+
function qn() {
|
|
1449
1491
|
return {
|
|
1450
1492
|
detectedPersonCount: 0,
|
|
1451
1493
|
lockedPersonId: null,
|
|
1452
|
-
trackingQuality:
|
|
1494
|
+
trackingQuality: Gn()
|
|
1453
1495
|
};
|
|
1454
1496
|
}
|
|
1455
|
-
function
|
|
1497
|
+
function Jn({ detectedPersonCount: e, isTracking: t, lockedPersonId: n, meanVisibility: r, frameWidth: i, frameHeight: a, updatedAt: o }) {
|
|
1456
1498
|
let s = n ?? (t && e > 0 ? "pose-0" : null);
|
|
1457
1499
|
return {
|
|
1458
1500
|
detectedPersonCount: e,
|
|
1459
1501
|
lockedPersonId: s,
|
|
1460
|
-
trackingQuality:
|
|
1502
|
+
trackingQuality: Kn({
|
|
1461
1503
|
detectedPersonCount: e,
|
|
1462
1504
|
isTracking: t,
|
|
1463
1505
|
lockedPersonId: s,
|
|
@@ -1470,17 +1512,17 @@ function Fn({ detectedPersonCount: e, isTracking: t, lockedPersonId: n, meanVisi
|
|
|
1470
1512
|
}
|
|
1471
1513
|
//#endregion
|
|
1472
1514
|
//#region src/tracking/trackingStability.ts
|
|
1473
|
-
var
|
|
1474
|
-
function
|
|
1515
|
+
var Yn = 180;
|
|
1516
|
+
function Xn(e, t, n = 180) {
|
|
1475
1517
|
return e === null ? !1 : t - e <= n;
|
|
1476
1518
|
}
|
|
1477
|
-
function
|
|
1519
|
+
function Zn(e) {
|
|
1478
1520
|
return !e || !e.isTracking || !e.landmarks || !e.poseRig ? null : {
|
|
1479
1521
|
...e,
|
|
1480
1522
|
isTracking: !0
|
|
1481
1523
|
};
|
|
1482
1524
|
}
|
|
1483
|
-
function
|
|
1525
|
+
function Qn(e, t, n = gn) {
|
|
1484
1526
|
return {
|
|
1485
1527
|
detectedPersonCount: e,
|
|
1486
1528
|
lockedPersonId: n,
|
|
@@ -1493,7 +1535,7 @@ function zn(e, t, n = tn) {
|
|
|
1493
1535
|
}
|
|
1494
1536
|
//#endregion
|
|
1495
1537
|
//#region src/hooks/usePoseTracker.ts
|
|
1496
|
-
function
|
|
1538
|
+
function $n() {
|
|
1497
1539
|
return {
|
|
1498
1540
|
landmarks: null,
|
|
1499
1541
|
worldLandmarks: null,
|
|
@@ -1503,20 +1545,20 @@ function Bn() {
|
|
|
1503
1545
|
isTracking: !1
|
|
1504
1546
|
};
|
|
1505
1547
|
}
|
|
1506
|
-
var
|
|
1507
|
-
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
|
|
1548
|
+
var er = (e, r = {}) => {
|
|
1549
|
+
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(Re)), g = i(null), v = i(null), b = i(null), x = i(-1), S = i({
|
|
1508
1550
|
width: 0,
|
|
1509
1551
|
height: 0
|
|
1510
|
-
}), C = i(0), w = i(null), T = i(null), E = i(null), D = i(null), O = i(null), k = i(
|
|
1552
|
+
}), C = i(0), w = i(null), T = i(null), E = i(null), D = i(null), O = i(null), k = i(qn()), A = i({
|
|
1511
1553
|
frames: 0,
|
|
1512
1554
|
lastMeasuredAt: 0
|
|
1513
1555
|
}), j = i(null), M = i({
|
|
1514
1556
|
width: 0,
|
|
1515
1557
|
height: 0
|
|
1516
|
-
}), [N, P] = a(!1), [ee, F] = a(
|
|
1558
|
+
}), [N, P] = a(!1), [ee, F] = a($n), [I, L] = a(null), [te, ne] = a({
|
|
1517
1559
|
width: 0,
|
|
1518
1560
|
height: 0
|
|
1519
|
-
}), [
|
|
1561
|
+
}), [re, ie] = a(qn()), ae = t((e, t = k.current) => {
|
|
1520
1562
|
v.current = e.landmarks, k.current = t, F((t) => ({
|
|
1521
1563
|
...t,
|
|
1522
1564
|
landmarks: e.landmarks,
|
|
@@ -1524,22 +1566,22 @@ var Vn = (e, r = {}) => {
|
|
|
1524
1566
|
poseRig: e.poseRig,
|
|
1525
1567
|
confidence: e.confidence,
|
|
1526
1568
|
isTracking: e.isTracking
|
|
1527
|
-
})),
|
|
1528
|
-
}, []),
|
|
1569
|
+
})), L(e.silhouetteWidths), ie(t);
|
|
1570
|
+
}, []), oe = t(() => {
|
|
1529
1571
|
h.current.reset(), g.current = null, v.current = null, x.current = -1, S.current = {
|
|
1530
1572
|
width: 0,
|
|
1531
1573
|
height: 0
|
|
1532
|
-
}, C.current = 0, w.current = null, T.current = null, E.current = null, D.current = null, O.current = null, k.current =
|
|
1574
|
+
}, C.current = 0, w.current = null, T.current = null, E.current = null, D.current = null, O.current = null, k.current = qn(), A.current = {
|
|
1533
1575
|
frames: 0,
|
|
1534
1576
|
lastMeasuredAt: 0
|
|
1535
|
-
}, F(
|
|
1577
|
+
}, F($n()), L(null), ne({
|
|
1536
1578
|
width: 0,
|
|
1537
1579
|
height: 0
|
|
1538
|
-
}),
|
|
1580
|
+
}), ie(qn());
|
|
1539
1581
|
}, []);
|
|
1540
1582
|
n(() => {
|
|
1541
1583
|
if (!o) {
|
|
1542
|
-
P(!1),
|
|
1584
|
+
P(!1), oe();
|
|
1543
1585
|
return;
|
|
1544
1586
|
}
|
|
1545
1587
|
let e = !1;
|
|
@@ -1556,7 +1598,7 @@ var Vn = (e, r = {}) => {
|
|
|
1556
1598
|
}
|
|
1557
1599
|
}
|
|
1558
1600
|
return t(), () => {
|
|
1559
|
-
e = !0, P(!1), b.current !== null && (cancelAnimationFrame(b.current), b.current = null), m.current?.close(), m.current = null,
|
|
1601
|
+
e = !0, P(!1), b.current !== null && (cancelAnimationFrame(b.current), b.current = null), m.current?.close(), m.current = null, oe();
|
|
1560
1602
|
};
|
|
1561
1603
|
}, [
|
|
1562
1604
|
o,
|
|
@@ -1565,7 +1607,7 @@ var Vn = (e, r = {}) => {
|
|
|
1565
1607
|
s,
|
|
1566
1608
|
c,
|
|
1567
1609
|
d,
|
|
1568
|
-
|
|
1610
|
+
oe
|
|
1569
1611
|
]), M.current = {
|
|
1570
1612
|
width: f,
|
|
1571
1613
|
height: p
|
|
@@ -1586,7 +1628,7 @@ var Vn = (e, r = {}) => {
|
|
|
1586
1628
|
(i !== S.current.width || a !== S.current.height) && (S.current = {
|
|
1587
1629
|
width: i,
|
|
1588
1630
|
height: a
|
|
1589
|
-
},
|
|
1631
|
+
}, ne({
|
|
1590
1632
|
width: i,
|
|
1591
1633
|
height: a
|
|
1592
1634
|
}));
|
|
@@ -1595,21 +1637,21 @@ var Vn = (e, r = {}) => {
|
|
|
1595
1637
|
let s = performance.now();
|
|
1596
1638
|
try {
|
|
1597
1639
|
let e = w.current === null || C.current === 0;
|
|
1598
|
-
if (C.current = (C.current + 1) %
|
|
1640
|
+
if (C.current = (C.current + 1) % 1, e) {
|
|
1599
1641
|
let e = r.detectForVideo(n, s);
|
|
1600
1642
|
try {
|
|
1601
|
-
let t =
|
|
1643
|
+
let t = Bn(In(e.landmarks, e.worldLandmarks), j.current), n = t.length, r = !Xn(D.current, s), o = Rn(t, {
|
|
1602
1644
|
previousCandidate: O.current,
|
|
1603
1645
|
allowRelock: r
|
|
1604
|
-
}), c = o?.landmarks ?? null, l = o?.worldLandmarks ?? null, f = o || O.current ?
|
|
1646
|
+
}), c = o?.landmarks ?? null, l = o?.worldLandmarks ?? null, f = o || O.current ? gn : null, p = pt(), m = Jn({
|
|
1605
1647
|
detectedPersonCount: n,
|
|
1606
1648
|
isTracking: !1,
|
|
1607
1649
|
lockedPersonId: f,
|
|
1608
1650
|
frameWidth: i,
|
|
1609
1651
|
frameHeight: a,
|
|
1610
1652
|
updatedAt: s
|
|
1611
|
-
}), _ =
|
|
1612
|
-
if (!c) _ ? (p = _, m =
|
|
1653
|
+
}), _ = Xn(D.current, s) ? Zn(E.current) : null;
|
|
1654
|
+
if (!c) _ ? (p = _, m = Qn(n, s, f)) : (h.current.reset(), g.current = null, E.current = null, D.current = null, O.current = null, m = Jn({
|
|
1613
1655
|
detectedPersonCount: n,
|
|
1614
1656
|
isTracking: !1,
|
|
1615
1657
|
lockedPersonId: null,
|
|
@@ -1619,12 +1661,12 @@ var Vn = (e, r = {}) => {
|
|
|
1619
1661
|
}));
|
|
1620
1662
|
else {
|
|
1621
1663
|
r && o && (h.current.reset(), g.current = null);
|
|
1622
|
-
let t = h.current.smooth(
|
|
1623
|
-
if (O.current = o ?
|
|
1624
|
-
let n =
|
|
1664
|
+
let t = h.current.smooth(c), v = l ? yn(l) : null, y = en(t, v), b = hn(t), x = b >= u && y ? wn(g.current, y, Re.rotationAlpha) : null, S = x !== null, C = null;
|
|
1665
|
+
if (O.current = o ? Vn(o) : O.current, d) {
|
|
1666
|
+
let n = tn(o ? e.segmentationMasks?.[o.poseIndex] : void 0);
|
|
1625
1667
|
if (n) {
|
|
1626
1668
|
let e = ct(new Float32Array(n.getAsFloat32Array()), n.width, n.height, t);
|
|
1627
|
-
e && (C =
|
|
1669
|
+
e && (C = rn(e, i, n.width));
|
|
1628
1670
|
}
|
|
1629
1671
|
}
|
|
1630
1672
|
S && x ? (g.current = x, p = {
|
|
@@ -1634,26 +1676,26 @@ var Vn = (e, r = {}) => {
|
|
|
1634
1676
|
confidence: b,
|
|
1635
1677
|
isTracking: S,
|
|
1636
1678
|
silhouetteWidths: C
|
|
1637
|
-
}, E.current = p, D.current = s, m =
|
|
1679
|
+
}, E.current = p, D.current = s, m = Jn({
|
|
1638
1680
|
detectedPersonCount: n,
|
|
1639
1681
|
isTracking: S,
|
|
1640
|
-
lockedPersonId:
|
|
1641
|
-
meanVisibility:
|
|
1682
|
+
lockedPersonId: gn,
|
|
1683
|
+
meanVisibility: b,
|
|
1642
1684
|
frameWidth: i,
|
|
1643
1685
|
frameHeight: a,
|
|
1644
1686
|
updatedAt: s
|
|
1645
|
-
})) : _ ? (p = _, m =
|
|
1687
|
+
})) : _ ? (p = _, m = Qn(n, s, f)) : (g.current = null, E.current = null, D.current = null, p = {
|
|
1646
1688
|
landmarks: t,
|
|
1647
1689
|
worldLandmarks: v,
|
|
1648
1690
|
poseRig: null,
|
|
1649
1691
|
confidence: b,
|
|
1650
1692
|
isTracking: !1,
|
|
1651
1693
|
silhouetteWidths: C
|
|
1652
|
-
}, m =
|
|
1694
|
+
}, m = Jn({
|
|
1653
1695
|
detectedPersonCount: n,
|
|
1654
1696
|
isTracking: !1,
|
|
1655
|
-
lockedPersonId: o ?
|
|
1656
|
-
meanVisibility:
|
|
1697
|
+
lockedPersonId: o ? gn : null,
|
|
1698
|
+
meanVisibility: b,
|
|
1657
1699
|
frameWidth: i,
|
|
1658
1700
|
frameHeight: a,
|
|
1659
1701
|
updatedAt: s
|
|
@@ -1662,11 +1704,14 @@ var Vn = (e, r = {}) => {
|
|
|
1662
1704
|
let v = w.current;
|
|
1663
1705
|
w.current = p, k.current = m;
|
|
1664
1706
|
let y = mt(v, p, yt);
|
|
1665
|
-
T.current = y,
|
|
1707
|
+
T.current = y, ae(y, m);
|
|
1666
1708
|
} finally {
|
|
1667
|
-
|
|
1709
|
+
nn(e.segmentationMasks);
|
|
1668
1710
|
}
|
|
1669
|
-
} else
|
|
1711
|
+
} else if (w.current && T.current) {
|
|
1712
|
+
let e = mt(T.current, w.current, yt);
|
|
1713
|
+
T.current = e, ae(e, k.current);
|
|
1714
|
+
}
|
|
1670
1715
|
} catch {}
|
|
1671
1716
|
let c = A.current;
|
|
1672
1717
|
if (c.frames += 1, c.lastMeasuredAt === 0 && (c.lastMeasuredAt = s), s - c.lastMeasuredAt >= 1e3) {
|
|
@@ -1686,16 +1731,16 @@ var Vn = (e, r = {}) => {
|
|
|
1686
1731
|
N,
|
|
1687
1732
|
u,
|
|
1688
1733
|
d,
|
|
1689
|
-
|
|
1734
|
+
ae,
|
|
1690
1735
|
e
|
|
1691
1736
|
]);
|
|
1692
|
-
let
|
|
1737
|
+
let R = t((t) => {
|
|
1693
1738
|
let n = e.current, r = t.getContext("2d");
|
|
1694
1739
|
if (!n || !r) return;
|
|
1695
1740
|
t.width = n.videoWidth || t.clientWidth || 1280, t.height = n.videoHeight || t.clientHeight || 720, r.clearRect(0, 0, t.width, t.height);
|
|
1696
1741
|
let i = v.current;
|
|
1697
1742
|
if (!i) return;
|
|
1698
|
-
let a =
|
|
1743
|
+
let a = yn(i), o = new _(r);
|
|
1699
1744
|
o.drawLandmarks(a, {
|
|
1700
1745
|
radius: 3,
|
|
1701
1746
|
color: "#00FF88",
|
|
@@ -1708,18 +1753,18 @@ var Vn = (e, r = {}) => {
|
|
|
1708
1753
|
return {
|
|
1709
1754
|
...ee,
|
|
1710
1755
|
isTrackerReady: N,
|
|
1711
|
-
drawLandmarks:
|
|
1712
|
-
silhouetteWidths:
|
|
1713
|
-
poseFrameWidth:
|
|
1714
|
-
poseFrameHeight:
|
|
1715
|
-
detectedPersonCount:
|
|
1716
|
-
lockedPersonId:
|
|
1717
|
-
trackingQuality:
|
|
1756
|
+
drawLandmarks: R,
|
|
1757
|
+
silhouetteWidths: I,
|
|
1758
|
+
poseFrameWidth: te.width,
|
|
1759
|
+
poseFrameHeight: te.height,
|
|
1760
|
+
detectedPersonCount: re.detectedPersonCount,
|
|
1761
|
+
lockedPersonId: re.lockedPersonId,
|
|
1762
|
+
trackingQuality: re.trackingQuality
|
|
1718
1763
|
};
|
|
1719
1764
|
};
|
|
1720
1765
|
//#endregion
|
|
1721
1766
|
//#region src/hooks/useWebcam.ts
|
|
1722
|
-
function
|
|
1767
|
+
function tr(e) {
|
|
1723
1768
|
if (!(e instanceof DOMException)) return "Failed to start the camera.";
|
|
1724
1769
|
switch (e.name) {
|
|
1725
1770
|
case "NotAllowedError": return "Camera permission was denied.";
|
|
@@ -1729,93 +1774,100 @@ function Hn(e) {
|
|
|
1729
1774
|
default: return "Failed to start the camera.";
|
|
1730
1775
|
}
|
|
1731
1776
|
}
|
|
1732
|
-
function
|
|
1733
|
-
let { width:
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1777
|
+
function nr(e = {}) {
|
|
1778
|
+
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(() => ({
|
|
1779
|
+
get current() {
|
|
1780
|
+
return m.current;
|
|
1781
|
+
},
|
|
1782
|
+
set current(e) {
|
|
1783
|
+
m.current = e, d && (d.current = e);
|
|
1784
|
+
}
|
|
1785
|
+
}), [d]), g = i(null), _ = i(!1), v = i(0), [y, b] = a(!1), [x, S] = a(null), C = t((e) => {
|
|
1786
|
+
b(e), f?.(e);
|
|
1787
|
+
}, [f]), w = t((e) => {
|
|
1788
|
+
S(e), p?.(e);
|
|
1789
|
+
}, [p]), T = t(() => {
|
|
1790
|
+
g.current &&= (g.current.getTracks().forEach((e) => e.stop()), null), h.current && (h.current.pause(), h.current.srcObject = null), C(!1);
|
|
1791
|
+
}, [C, h]), E = t(() => {
|
|
1792
|
+
v.current += 1, T();
|
|
1793
|
+
}, [T]), D = t(() => {
|
|
1794
|
+
if (h.current) return h.current;
|
|
1743
1795
|
let e = document.createElement("video");
|
|
1744
|
-
return e.playsInline = !0, e.autoplay = !0, e.muted = !0, e.setAttribute("playsinline", "true"),
|
|
1745
|
-
}, [
|
|
1746
|
-
let e =
|
|
1747
|
-
if (
|
|
1748
|
-
|
|
1796
|
+
return e.playsInline = !0, e.autoplay = !0, e.muted = !0, e.setAttribute("playsinline", "true"), h.current = e, e;
|
|
1797
|
+
}, [h]), O = t(async () => {
|
|
1798
|
+
let e = v.current + 1;
|
|
1799
|
+
if (v.current = e, T(), w(null), u) {
|
|
1800
|
+
D(), C(!0);
|
|
1749
1801
|
return;
|
|
1750
1802
|
}
|
|
1751
1803
|
if (!navigator.mediaDevices?.getUserMedia) {
|
|
1752
|
-
|
|
1804
|
+
w("This browser does not support camera access.");
|
|
1753
1805
|
return;
|
|
1754
1806
|
}
|
|
1755
1807
|
try {
|
|
1756
|
-
let t =
|
|
1808
|
+
let t = D(), n = await navigator.mediaDevices.getUserMedia({
|
|
1757
1809
|
video: {
|
|
1758
|
-
width:
|
|
1759
|
-
height:
|
|
1760
|
-
facingMode:
|
|
1810
|
+
width: o,
|
|
1811
|
+
height: s,
|
|
1812
|
+
facingMode: c
|
|
1761
1813
|
},
|
|
1762
1814
|
audio: !1
|
|
1763
1815
|
});
|
|
1764
|
-
if (!
|
|
1816
|
+
if (!_.current || v.current !== e) {
|
|
1765
1817
|
n.getTracks().forEach((e) => e.stop());
|
|
1766
1818
|
return;
|
|
1767
1819
|
}
|
|
1768
|
-
if (
|
|
1820
|
+
if (g.current = n, t.srcObject = n, await t.play(), !_.current || v.current !== e) {
|
|
1769
1821
|
n.getTracks().forEach((e) => e.stop());
|
|
1770
1822
|
return;
|
|
1771
1823
|
}
|
|
1772
|
-
|
|
1824
|
+
C(!0);
|
|
1773
1825
|
} catch (t) {
|
|
1774
|
-
if (
|
|
1775
|
-
|
|
1826
|
+
if (v.current !== e) return;
|
|
1827
|
+
T(), w(tr(t));
|
|
1776
1828
|
}
|
|
1777
1829
|
}, [
|
|
1778
|
-
|
|
1830
|
+
D,
|
|
1831
|
+
c,
|
|
1779
1832
|
s,
|
|
1780
|
-
|
|
1781
|
-
l,
|
|
1782
|
-
C,
|
|
1783
|
-
S,
|
|
1833
|
+
u,
|
|
1784
1834
|
w,
|
|
1785
|
-
|
|
1835
|
+
C,
|
|
1836
|
+
T,
|
|
1837
|
+
o
|
|
1786
1838
|
]);
|
|
1787
|
-
return n(() => (
|
|
1788
|
-
|
|
1789
|
-
}), [
|
|
1790
|
-
if (
|
|
1791
|
-
if (!
|
|
1792
|
-
|
|
1839
|
+
return n(() => (_.current = !0, () => {
|
|
1840
|
+
_.current = !1, E();
|
|
1841
|
+
}), [E]), n(() => {
|
|
1842
|
+
if (_.current) {
|
|
1843
|
+
if (!l) {
|
|
1844
|
+
E();
|
|
1793
1845
|
return;
|
|
1794
1846
|
}
|
|
1795
|
-
|
|
1847
|
+
O();
|
|
1796
1848
|
}
|
|
1797
1849
|
}, [
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1850
|
+
l,
|
|
1851
|
+
O,
|
|
1852
|
+
E
|
|
1801
1853
|
]), {
|
|
1802
|
-
videoRef:
|
|
1803
|
-
isReady:
|
|
1804
|
-
error:
|
|
1805
|
-
start:
|
|
1806
|
-
stop:
|
|
1854
|
+
videoRef: h,
|
|
1855
|
+
isReady: y,
|
|
1856
|
+
error: x,
|
|
1857
|
+
start: O,
|
|
1858
|
+
stop: E
|
|
1807
1859
|
};
|
|
1808
1860
|
}
|
|
1809
1861
|
//#endregion
|
|
1810
1862
|
//#region src/hooks/useEverFitting.ts
|
|
1811
|
-
function
|
|
1812
|
-
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 =
|
|
1863
|
+
function rr(e = {}) {
|
|
1864
|
+
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 = nr({
|
|
1813
1865
|
width: t,
|
|
1814
1866
|
height: i,
|
|
1815
1867
|
facingMode: a,
|
|
1816
1868
|
enabled: o,
|
|
1817
1869
|
mockMode: s
|
|
1818
|
-
}), S =
|
|
1870
|
+
}), S = er(x.videoRef, {
|
|
1819
1871
|
enabled: o,
|
|
1820
1872
|
modelComplexity: c,
|
|
1821
1873
|
numPoses: l,
|
|
@@ -1824,7 +1876,7 @@ function Wn(e = {}) {
|
|
|
1824
1876
|
outputSegmentationMasks: f,
|
|
1825
1877
|
viewportWidth: p,
|
|
1826
1878
|
viewportHeight: m
|
|
1827
|
-
}), { config: C, measurements: w, sizeRecommendation: T, garmentScale: E, isMeasuring: D, measure: O, startMeasurement: k, updateConfig: A } = nt(), j = o && x.isReady && S.isTracking, M =
|
|
1879
|
+
}), { config: C, measurements: w, sizeRecommendation: T, garmentScale: E, isMeasuring: D, measure: O, startMeasurement: k, updateConfig: A } = nt(), j = o && x.isReady && S.isTracking, M = Le(w, v), N = r(() => ge({
|
|
1828
1880
|
measurements: w,
|
|
1829
1881
|
measurementScale: E,
|
|
1830
1882
|
presetSelection: M.selection,
|
|
@@ -1934,7 +1986,7 @@ function Wn(e = {}) {
|
|
|
1934
1986
|
}
|
|
1935
1987
|
//#endregion
|
|
1936
1988
|
//#region src/garment/garmentFitProfile.ts
|
|
1937
|
-
function
|
|
1989
|
+
function ir(e) {
|
|
1938
1990
|
let t = new b.Vector3(), n = new b.Quaternion(), r = new b.Quaternion();
|
|
1939
1991
|
return e.updateWorldMatrix(!0, !1), e.getWorldPosition(t), e.getWorldQuaternion(n), e.parent ? e.parent.getWorldQuaternion(r) : r.identity(), {
|
|
1940
1992
|
bone: e,
|
|
@@ -1945,7 +1997,7 @@ function Gn(e) {
|
|
|
1945
1997
|
restParentWorldQuaternion: r
|
|
1946
1998
|
};
|
|
1947
1999
|
}
|
|
1948
|
-
function
|
|
2000
|
+
function ar(e) {
|
|
1949
2001
|
let t = new b.Box3(), n = { current: !1 }, r = new b.Vector3(), i = new b.Box3();
|
|
1950
2002
|
return e.updateMatrixWorld(!0), e.traverse((e) => {
|
|
1951
2003
|
if (!(e instanceof b.Mesh) || e.name.startsWith("Collision") || !e.visible) return;
|
|
@@ -2008,23 +2060,23 @@ function Kn(e) {
|
|
|
2008
2060
|
});
|
|
2009
2061
|
}), n.current || t.makeEmpty(), t;
|
|
2010
2062
|
}
|
|
2011
|
-
function
|
|
2063
|
+
function or(e) {
|
|
2012
2064
|
if (!e || e.length === 0) return null;
|
|
2013
2065
|
let t = new b.Vector3(), n = new b.Vector3();
|
|
2014
2066
|
return e.forEach(({ bone: e }) => {
|
|
2015
2067
|
e.getWorldPosition(n), t.add(n);
|
|
2016
2068
|
}), t.multiplyScalar(1 / e.length);
|
|
2017
2069
|
}
|
|
2018
|
-
function
|
|
2070
|
+
function sr(e, t) {
|
|
2019
2071
|
for (let n = 0; n < t.length; n += 1) {
|
|
2020
|
-
let r =
|
|
2072
|
+
let r = or(e.get(t[n]));
|
|
2021
2073
|
if (r) return r;
|
|
2022
2074
|
}
|
|
2023
2075
|
return null;
|
|
2024
2076
|
}
|
|
2025
|
-
function
|
|
2077
|
+
function cr(e, t, n = 1) {
|
|
2026
2078
|
e.updateMatrixWorld(!0);
|
|
2027
|
-
let r =
|
|
2079
|
+
let r = ar(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 = sr(t, ["LeftUpperArm", "LeftShoulder"]), l = sr(t, ["RightUpperArm", "RightShoulder"]), u = sr(t, ["Hips"]), d = sr(t, ["LeftUpperLeg"]), f = sr(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();
|
|
2028
2080
|
if (y) {
|
|
2029
2081
|
let e = Math.min(g.y, _.y), t = Math.max(g.y, _.y);
|
|
2030
2082
|
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);
|
|
@@ -2042,47 +2094,47 @@ function Yn(e, t, n = 1) {
|
|
|
2042
2094
|
hasBoneAnchors: y
|
|
2043
2095
|
};
|
|
2044
2096
|
}
|
|
2045
|
-
function
|
|
2097
|
+
function lr(e) {
|
|
2046
2098
|
for (let t of e.values()) t.forEach(({ bone: e, restQuaternion: t, restScale: n }) => {
|
|
2047
2099
|
e.quaternion.copy(t), e.scale.copy(n);
|
|
2048
2100
|
});
|
|
2049
2101
|
}
|
|
2050
2102
|
//#endregion
|
|
2051
2103
|
//#region src/avatar/avatarLoader.ts
|
|
2052
|
-
var
|
|
2053
|
-
function
|
|
2104
|
+
var ur = "__nativeVRMPrepared";
|
|
2105
|
+
function dr(e) {
|
|
2054
2106
|
try {
|
|
2055
2107
|
return new URL(e, "https://avatar.local").pathname;
|
|
2056
2108
|
} catch {
|
|
2057
2109
|
return e;
|
|
2058
2110
|
}
|
|
2059
2111
|
}
|
|
2060
|
-
function
|
|
2061
|
-
return
|
|
2112
|
+
function fr(e) {
|
|
2113
|
+
return dr(e).toLowerCase().endsWith(".vrm");
|
|
2062
2114
|
}
|
|
2063
|
-
function
|
|
2064
|
-
return
|
|
2115
|
+
function pr(e) {
|
|
2116
|
+
return fr(e) ? "vrm" : "gltf";
|
|
2065
2117
|
}
|
|
2066
|
-
function
|
|
2067
|
-
|
|
2118
|
+
function mr(e, t) {
|
|
2119
|
+
fr(t) && e.register((e) => new S(e));
|
|
2068
2120
|
}
|
|
2069
|
-
function
|
|
2070
|
-
if (
|
|
2071
|
-
|
|
2121
|
+
function hr(e) {
|
|
2122
|
+
if (fr(e)) return (t) => {
|
|
2123
|
+
mr(t, e);
|
|
2072
2124
|
};
|
|
2073
2125
|
}
|
|
2074
|
-
function
|
|
2126
|
+
function gr(e) {
|
|
2075
2127
|
e.traverse((e) => {
|
|
2076
2128
|
e.frustumCulled = !1;
|
|
2077
2129
|
});
|
|
2078
2130
|
}
|
|
2079
|
-
function
|
|
2131
|
+
function _r(e) {
|
|
2080
2132
|
let t = e.scene.userData;
|
|
2081
|
-
t[
|
|
2133
|
+
t[ur] || (C.rotateVRM0(e), t[ur] = !0), gr(e.scene);
|
|
2082
2134
|
}
|
|
2083
2135
|
//#endregion
|
|
2084
2136
|
//#region src/avatar/humanoidBindings.ts
|
|
2085
|
-
var
|
|
2137
|
+
var vr = {
|
|
2086
2138
|
Hips: ["hips"],
|
|
2087
2139
|
Spine: ["spine"],
|
|
2088
2140
|
Chest: ["chest", "upperChest"],
|
|
@@ -2103,146 +2155,36 @@ var ar = {
|
|
|
2103
2155
|
RightLowerLeg: ["rightLowerLeg"],
|
|
2104
2156
|
RightFoot: ["rightFoot"]
|
|
2105
2157
|
};
|
|
2106
|
-
function
|
|
2158
|
+
function yr(e) {
|
|
2107
2159
|
let t = /* @__PURE__ */ new Map();
|
|
2108
|
-
return Object.entries(
|
|
2160
|
+
return Object.entries(vr).forEach(([n, r]) => {
|
|
2109
2161
|
for (let i = 0; i < r.length; i += 1) {
|
|
2110
2162
|
let a = e.getNormalizedBoneNode(r[i]);
|
|
2111
2163
|
if (a) {
|
|
2112
|
-
t.set(n, [
|
|
2164
|
+
t.set(n, [ir(a)]);
|
|
2113
2165
|
break;
|
|
2114
2166
|
}
|
|
2115
2167
|
}
|
|
2116
2168
|
}), t;
|
|
2117
2169
|
}
|
|
2118
2170
|
//#endregion
|
|
2119
|
-
//#region src/avatar/VRMCompat.ts
|
|
2120
|
-
var sr = {
|
|
2121
|
-
root: "hips",
|
|
2122
|
-
c_spine0: "spine",
|
|
2123
|
-
c_spine1: "spine",
|
|
2124
|
-
c_spine2: "chest",
|
|
2125
|
-
c_spine3: "upperChest",
|
|
2126
|
-
c_neck: "neck",
|
|
2127
|
-
c_head: "head",
|
|
2128
|
-
l_clavicle: "leftShoulder",
|
|
2129
|
-
l_uparm: "leftUpperArm",
|
|
2130
|
-
l_lowarm: "leftLowerArm",
|
|
2131
|
-
l_wrist: "leftHand",
|
|
2132
|
-
r_clavicle: "rightShoulder",
|
|
2133
|
-
r_uparm: "rightUpperArm",
|
|
2134
|
-
r_lowarm: "rightLowerArm",
|
|
2135
|
-
r_wrist: "rightHand",
|
|
2136
|
-
l_upleg: "leftUpperLeg",
|
|
2137
|
-
l_lowleg: "leftLowerLeg",
|
|
2138
|
-
l_foot: "leftFoot",
|
|
2139
|
-
r_upleg: "rightUpperLeg",
|
|
2140
|
-
r_lowleg: "rightLowerLeg",
|
|
2141
|
-
r_foot: "rightFoot"
|
|
2142
|
-
}, cr = {
|
|
2143
|
-
bone_0: "hips",
|
|
2144
|
-
bone_1: "spine",
|
|
2145
|
-
bone_2: "chest",
|
|
2146
|
-
bone_3: "upperChest",
|
|
2147
|
-
bone_4: "neck",
|
|
2148
|
-
bone_5: "head",
|
|
2149
|
-
bone_6: "leftShoulder",
|
|
2150
|
-
bone_7: "leftUpperArm",
|
|
2151
|
-
bone_8: "leftLowerArm",
|
|
2152
|
-
bone_9: "leftHand",
|
|
2153
|
-
bone_25: "rightShoulder",
|
|
2154
|
-
bone_26: "rightUpperArm",
|
|
2155
|
-
bone_27: "rightLowerArm",
|
|
2156
|
-
bone_28: "rightHand",
|
|
2157
|
-
bone_44: "leftUpperLeg",
|
|
2158
|
-
bone_45: "leftLowerLeg",
|
|
2159
|
-
bone_46: "leftFoot",
|
|
2160
|
-
bone_48: "rightUpperLeg",
|
|
2161
|
-
bone_49: "rightLowerLeg",
|
|
2162
|
-
bone_50: "rightFoot"
|
|
2163
|
-
}, lr = {
|
|
2164
|
-
Root: "hips",
|
|
2165
|
-
Hips: "hips",
|
|
2166
|
-
Spine: "spine",
|
|
2167
|
-
Chest: "chest",
|
|
2168
|
-
Neck: "neck",
|
|
2169
|
-
Head: "head",
|
|
2170
|
-
LeftShoulder: "leftShoulder",
|
|
2171
|
-
LeftUpperArm: "leftUpperArm",
|
|
2172
|
-
LeftLowerArm: "leftLowerArm",
|
|
2173
|
-
LeftHand: "leftHand",
|
|
2174
|
-
RightShoulder: "rightShoulder",
|
|
2175
|
-
RightUpperArm: "rightUpperArm",
|
|
2176
|
-
RightLowerArm: "rightLowerArm",
|
|
2177
|
-
RightHand: "rightHand",
|
|
2178
|
-
LeftUpperLeg: "leftUpperLeg",
|
|
2179
|
-
LeftLowerLeg: "leftLowerLeg",
|
|
2180
|
-
LeftFoot: "leftFoot",
|
|
2181
|
-
RightUpperLeg: "rightUpperLeg",
|
|
2182
|
-
RightLowerLeg: "rightLowerLeg",
|
|
2183
|
-
RightFoot: "rightFoot"
|
|
2184
|
-
};
|
|
2185
|
-
function ur(e, t) {
|
|
2186
|
-
if (t?.humanoid) return {
|
|
2187
|
-
getNormalizedBoneNode: (e) => t.humanoid.getNormalizedBoneNode(e) ?? null,
|
|
2188
|
-
update: (e) => t.update(e),
|
|
2189
|
-
vrm: t
|
|
2190
|
-
};
|
|
2191
|
-
let n = /* @__PURE__ */ new Map();
|
|
2192
|
-
return e.traverse((e) => {
|
|
2193
|
-
if (!(e instanceof b.Bone)) return;
|
|
2194
|
-
let t = e.name, r = sr[t];
|
|
2195
|
-
r && !n.has(r) && n.set(r, e);
|
|
2196
|
-
let i = lr[t];
|
|
2197
|
-
i && !n.has(i) && n.set(i, e);
|
|
2198
|
-
let a = cr[t];
|
|
2199
|
-
a && !n.has(a) && n.set(a, e);
|
|
2200
|
-
}), {
|
|
2201
|
-
getNormalizedBoneNode: (e) => n.get(e) ?? null,
|
|
2202
|
-
update: () => {},
|
|
2203
|
-
vrm: null
|
|
2204
|
-
};
|
|
2205
|
-
}
|
|
2206
|
-
//#endregion
|
|
2207
|
-
//#region src/hooks/useAvatarVariant.ts
|
|
2208
|
-
function dr(e) {
|
|
2209
|
-
let t = x(e);
|
|
2210
|
-
return rr(t), t.traverse((e) => {
|
|
2211
|
-
if (e instanceof b.Mesh) {
|
|
2212
|
-
if (Array.isArray(e.material)) {
|
|
2213
|
-
e.material = e.material.map((e) => e.clone());
|
|
2214
|
-
return;
|
|
2215
|
-
}
|
|
2216
|
-
e.material = e.material.clone();
|
|
2217
|
-
}
|
|
2218
|
-
}), t;
|
|
2219
|
-
}
|
|
2220
|
-
function fr({ url: e }) {
|
|
2221
|
-
let t = p(e, "/draco/", !0, r(() => nr(e), [e])), n = t.userData?.vrm ?? null, i = r(() => n ? (ir(n), n.scene) : dr(t.scene), [t.scene, n]), a = r(() => ur(i, n), [i, n]);
|
|
2222
|
-
return {
|
|
2223
|
-
scene: i,
|
|
2224
|
-
humanoid: a,
|
|
2225
|
-
bones: r(() => or(a), [a])
|
|
2226
|
-
};
|
|
2227
|
-
}
|
|
2228
|
-
//#endregion
|
|
2229
2171
|
//#region src/pose/boneMapping.ts
|
|
2230
|
-
var
|
|
2231
|
-
min: -70 *
|
|
2232
|
-
max: 70 *
|
|
2233
|
-
},
|
|
2234
|
-
min: -45 *
|
|
2235
|
-
max: 45 *
|
|
2236
|
-
},
|
|
2237
|
-
min: -150 *
|
|
2238
|
-
max: 150 *
|
|
2239
|
-
},
|
|
2240
|
-
min: -90 *
|
|
2241
|
-
max: 90 *
|
|
2242
|
-
},
|
|
2172
|
+
var K = Math.PI / 180, br = {
|
|
2173
|
+
min: -70 * K,
|
|
2174
|
+
max: 70 * K
|
|
2175
|
+
}, xr = {
|
|
2176
|
+
min: -45 * K,
|
|
2177
|
+
max: 45 * K
|
|
2178
|
+
}, Sr = {
|
|
2179
|
+
min: -150 * K,
|
|
2180
|
+
max: 150 * K
|
|
2181
|
+
}, Cr = {
|
|
2182
|
+
min: -90 * K,
|
|
2183
|
+
max: 90 * K
|
|
2184
|
+
}, wr = {
|
|
2243
2185
|
min: 0,
|
|
2244
|
-
max: 150 *
|
|
2245
|
-
},
|
|
2186
|
+
max: 150 * K
|
|
2187
|
+
}, Tr = {
|
|
2246
2188
|
Hips: {
|
|
2247
2189
|
rigKey: "hips",
|
|
2248
2190
|
rotationScale: {
|
|
@@ -2273,22 +2215,22 @@ var q = Math.PI / 180, pr = {
|
|
|
2273
2215
|
rigKey: "leftUpperArm",
|
|
2274
2216
|
rotationScale: .45,
|
|
2275
2217
|
rotationLimits: {
|
|
2276
|
-
x:
|
|
2277
|
-
z:
|
|
2218
|
+
x: br,
|
|
2219
|
+
z: xr
|
|
2278
2220
|
}
|
|
2279
2221
|
},
|
|
2280
2222
|
LeftUpperArm: {
|
|
2281
2223
|
rigKey: "leftUpperArm",
|
|
2282
2224
|
rotationScale: 1,
|
|
2283
2225
|
rotationLimits: {
|
|
2284
|
-
x:
|
|
2285
|
-
z:
|
|
2226
|
+
x: Sr,
|
|
2227
|
+
z: Cr
|
|
2286
2228
|
}
|
|
2287
2229
|
},
|
|
2288
2230
|
LeftLowerArm: {
|
|
2289
2231
|
rigKey: "leftLowerArm",
|
|
2290
2232
|
rotationScale: 1,
|
|
2291
|
-
rotationLimits: { x:
|
|
2233
|
+
rotationLimits: { x: wr }
|
|
2292
2234
|
},
|
|
2293
2235
|
LeftHand: {
|
|
2294
2236
|
rigKey: "leftLowerArm",
|
|
@@ -2298,22 +2240,22 @@ var q = Math.PI / 180, pr = {
|
|
|
2298
2240
|
rigKey: "rightUpperArm",
|
|
2299
2241
|
rotationScale: .45,
|
|
2300
2242
|
rotationLimits: {
|
|
2301
|
-
x:
|
|
2302
|
-
z:
|
|
2243
|
+
x: br,
|
|
2244
|
+
z: xr
|
|
2303
2245
|
}
|
|
2304
2246
|
},
|
|
2305
2247
|
RightUpperArm: {
|
|
2306
2248
|
rigKey: "rightUpperArm",
|
|
2307
2249
|
rotationScale: 1,
|
|
2308
2250
|
rotationLimits: {
|
|
2309
|
-
x:
|
|
2310
|
-
z:
|
|
2251
|
+
x: Sr,
|
|
2252
|
+
z: Cr
|
|
2311
2253
|
}
|
|
2312
2254
|
},
|
|
2313
2255
|
RightLowerArm: {
|
|
2314
2256
|
rigKey: "rightLowerArm",
|
|
2315
2257
|
rotationScale: 1,
|
|
2316
|
-
rotationLimits: { x:
|
|
2258
|
+
rotationLimits: { x: wr }
|
|
2317
2259
|
},
|
|
2318
2260
|
RightHand: {
|
|
2319
2261
|
rigKey: "rightLowerArm",
|
|
@@ -2337,7 +2279,7 @@ var q = Math.PI / 180, pr = {
|
|
|
2337
2279
|
rotationScale: .9
|
|
2338
2280
|
},
|
|
2339
2281
|
RightFoot: { rigKey: null }
|
|
2340
|
-
},
|
|
2282
|
+
}, Er = {
|
|
2341
2283
|
Root: "Hips",
|
|
2342
2284
|
root: "Hips",
|
|
2343
2285
|
c_spine0: "Spine",
|
|
@@ -2380,22 +2322,22 @@ var q = Math.PI / 180, pr = {
|
|
|
2380
2322
|
mixamorig_RightLeg: "RightLowerLeg",
|
|
2381
2323
|
mixamorig_RightFoot: "RightFoot"
|
|
2382
2324
|
};
|
|
2383
|
-
function
|
|
2384
|
-
return
|
|
2325
|
+
function Dr(e) {
|
|
2326
|
+
return Tr[e] ? e : Er[e] ?? e;
|
|
2385
2327
|
}
|
|
2386
|
-
function
|
|
2387
|
-
let n =
|
|
2328
|
+
function Or(e, t) {
|
|
2329
|
+
let n = Tr[Dr(e)];
|
|
2388
2330
|
if (!n || !n.rigKey) return null;
|
|
2389
2331
|
let r = t[n.rigKey];
|
|
2390
2332
|
if (!r) return null;
|
|
2391
|
-
let i =
|
|
2333
|
+
let i = kr(n.rigKey === "hips" && "rotation" in r ? r.rotation : r, n.rotationScale);
|
|
2392
2334
|
return {
|
|
2393
|
-
x:
|
|
2394
|
-
y:
|
|
2395
|
-
z:
|
|
2335
|
+
x: Ar(i.x, n.rotationLimits?.x),
|
|
2336
|
+
y: Ar(i.y, n.rotationLimits?.y),
|
|
2337
|
+
z: Ar(i.z, n.rotationLimits?.z)
|
|
2396
2338
|
};
|
|
2397
2339
|
}
|
|
2398
|
-
function
|
|
2340
|
+
function kr(e, t = 1) {
|
|
2399
2341
|
return typeof t == "number" ? {
|
|
2400
2342
|
x: e.x * t,
|
|
2401
2343
|
y: e.y * t,
|
|
@@ -2406,12 +2348,241 @@ function Sr(e, t = 1) {
|
|
|
2406
2348
|
z: e.z * (t.z ?? 1)
|
|
2407
2349
|
};
|
|
2408
2350
|
}
|
|
2409
|
-
function
|
|
2351
|
+
function Ar(e, t) {
|
|
2410
2352
|
return t ? Math.min(t.max, Math.max(t.min, e)) : e;
|
|
2411
2353
|
}
|
|
2412
2354
|
//#endregion
|
|
2355
|
+
//#region src/humanoid/numberedBoneAliases.ts
|
|
2356
|
+
var jr = /^bone_\d+$/, Mr = 1e-4, Nr = 12, Pr = 8;
|
|
2357
|
+
function q(e, t) {
|
|
2358
|
+
return e.children.filter((e) => e instanceof b.Bone && t.has(e));
|
|
2359
|
+
}
|
|
2360
|
+
function J(e, t) {
|
|
2361
|
+
let n = t.get(e);
|
|
2362
|
+
if (n) return n;
|
|
2363
|
+
let r = new b.Vector3();
|
|
2364
|
+
return e.getWorldPosition(r), t.set(e, r), r;
|
|
2365
|
+
}
|
|
2366
|
+
function Fr(e, t, n) {
|
|
2367
|
+
let r = n.get(e);
|
|
2368
|
+
if (r !== void 0) return r;
|
|
2369
|
+
let i = q(e, t).reduce((e, r) => e + 1 + Fr(r, t, n), 0);
|
|
2370
|
+
return n.set(e, i), i;
|
|
2371
|
+
}
|
|
2372
|
+
function Y(e, t, n) {
|
|
2373
|
+
!t || e.has(t) || e.set(t, n);
|
|
2374
|
+
}
|
|
2375
|
+
function Ir(e, t, n, r, i) {
|
|
2376
|
+
let a = J(e, r), o = null, s = -Infinity;
|
|
2377
|
+
return q(e, n).forEach((e) => {
|
|
2378
|
+
let c = J(e, r).clone().sub(a), l = Fr(e, n, i) * .4;
|
|
2379
|
+
t === "up" ? l += c.y * 6 - Math.abs(c.x) * 1.5 - Math.abs(c.z) * .8 : t === "positiveX" ? l += c.x * 5 - Math.max(c.y, 0) * .5 - Math.abs(c.z) * .5 : l += -c.x * 5 - Math.max(c.y, 0) * .5 - Math.abs(c.z) * .5, !(l <= s) && (o = e, s = l);
|
|
2380
|
+
}), o;
|
|
2381
|
+
}
|
|
2382
|
+
function Lr(e, t, n, r) {
|
|
2383
|
+
let i = null, a = -Infinity;
|
|
2384
|
+
return e.bones.forEach((e) => {
|
|
2385
|
+
let o = J(e, n), s = q(e, t);
|
|
2386
|
+
if (s.length < 2) return;
|
|
2387
|
+
let c = 0, l = 0, u = 0, d = 0;
|
|
2388
|
+
s.forEach((e) => {
|
|
2389
|
+
let t = J(e, n).clone().sub(o);
|
|
2390
|
+
t.y > Mr && (c += 1), t.y < -Mr && (d += 1), t.x > Mr && (u += 1), t.x < -Mr && (l += 1);
|
|
2391
|
+
});
|
|
2392
|
+
let f = e.parent instanceof b.Bone && t.has(e.parent) ? 0 : 2.5, p = (c > 0 ? 6 : 0) + (d >= 2 ? 6 : 0) + (l > 0 ? 2 : 0) + (u > 0 ? 2 : 0) + s.length * .6 + Fr(e, t, r) * .12 + f;
|
|
2393
|
+
p <= a || (i = e, a = p);
|
|
2394
|
+
}), i;
|
|
2395
|
+
}
|
|
2396
|
+
function Rr(e, t, n) {
|
|
2397
|
+
if (!e) return [];
|
|
2398
|
+
let r = [e];
|
|
2399
|
+
for (; r.length < Pr;) {
|
|
2400
|
+
let e = r[r.length - 1], i = q(e, t);
|
|
2401
|
+
if (i.length !== 1) break;
|
|
2402
|
+
let a = i[0], o = J(e, n);
|
|
2403
|
+
if (J(a, n).y <= o.y + Mr) break;
|
|
2404
|
+
r.push(a);
|
|
2405
|
+
}
|
|
2406
|
+
return r;
|
|
2407
|
+
}
|
|
2408
|
+
function zr(e, t, n, r) {
|
|
2409
|
+
if (!e) return null;
|
|
2410
|
+
let i = J(e, r), a = null, o = -Infinity;
|
|
2411
|
+
return q(e, n).forEach((e) => {
|
|
2412
|
+
if (t.has(e)) return;
|
|
2413
|
+
let n = J(e, r).clone().sub(i), s = n.y * 3 - Math.abs(n.x) * 12 - Math.abs(n.z) * 4;
|
|
2414
|
+
s <= o || (a = e, o = s);
|
|
2415
|
+
}), a;
|
|
2416
|
+
}
|
|
2417
|
+
function Br(e, t, n, r, i, a) {
|
|
2418
|
+
if (!e) return null;
|
|
2419
|
+
let o = J(e, i), s = null, c = -Infinity, l = t === "Left" ? 1 : -1;
|
|
2420
|
+
return q(e, r).forEach((e) => {
|
|
2421
|
+
if (n.has(e)) return;
|
|
2422
|
+
let t = J(e, i).clone().sub(o), u = Fr(e, r, a), d = t.x * l * 6 + Math.max(t.y, 0) * 1.5 - Math.abs(t.z) * .8 + u * .25;
|
|
2423
|
+
d <= c || (s = e, c = d);
|
|
2424
|
+
}), s;
|
|
2425
|
+
}
|
|
2426
|
+
function Vr(e, t, n, r, i) {
|
|
2427
|
+
let a = q(e, n);
|
|
2428
|
+
if (a.length === 0 || a.length >= 3) return null;
|
|
2429
|
+
let o = J(e, r), s = null, c = -Infinity;
|
|
2430
|
+
return a.forEach((e) => {
|
|
2431
|
+
let a = J(e, r).clone().sub(o), l = Fr(e, n, i) * 12;
|
|
2432
|
+
t === "positiveX" ? l += a.x * 5 - Math.abs(a.y) * .8 - Math.abs(a.z) * .8 : t === "negativeX" ? l += -a.x * 5 - Math.abs(a.y) * .8 - Math.abs(a.z) * .8 : t === "up" ? l += a.y * 6 - Math.abs(a.x) * 1.2 - Math.abs(a.z) * .8 : l += -a.y * 6 + Math.abs(a.x) * .8 - Math.abs(a.z) * .8, !(l <= c) && (s = e, c = l);
|
|
2433
|
+
}), s;
|
|
2434
|
+
}
|
|
2435
|
+
function Hr(e, t, n, r, i) {
|
|
2436
|
+
if (!e) return [];
|
|
2437
|
+
let a = [e], o = new Set(a);
|
|
2438
|
+
for (; a.length < Pr;) {
|
|
2439
|
+
let e = a[a.length - 1], s = Vr(e, t, n, r, i);
|
|
2440
|
+
if (!s || o.has(s)) break;
|
|
2441
|
+
a.push(s), o.add(s);
|
|
2442
|
+
}
|
|
2443
|
+
return a;
|
|
2444
|
+
}
|
|
2445
|
+
function Ur(e, t, n, r, i, a) {
|
|
2446
|
+
if (!e) return null;
|
|
2447
|
+
let o = J(e, i), s = null, c = -Infinity, l = t === "Left" ? 1 : -1;
|
|
2448
|
+
return q(e, r).forEach((e) => {
|
|
2449
|
+
if (n.has(e)) return;
|
|
2450
|
+
let t = J(e, i).clone().sub(o), u = Fr(e, r, a), d = -t.y * 6 + t.x * l * 4 - Math.abs(t.z) * .6 + u * .2;
|
|
2451
|
+
d <= c || (s = e, c = d);
|
|
2452
|
+
}), s;
|
|
2453
|
+
}
|
|
2454
|
+
function Wr(e, t, n) {
|
|
2455
|
+
if (t.length === 0) return;
|
|
2456
|
+
let r = `${n}Shoulder`, i = `${n}UpperArm`, a = `${n}LowerArm`, o = `${n}Hand`;
|
|
2457
|
+
if (t.length >= 4) {
|
|
2458
|
+
Y(e, t[0], r), Y(e, t[1], i), Y(e, t[2], a), Y(e, t[3], o);
|
|
2459
|
+
return;
|
|
2460
|
+
}
|
|
2461
|
+
if (t.length === 3) {
|
|
2462
|
+
Y(e, t[0], i), Y(e, t[1], a), Y(e, t[2], o);
|
|
2463
|
+
return;
|
|
2464
|
+
}
|
|
2465
|
+
if (t.length === 2) {
|
|
2466
|
+
Y(e, t[0], i), Y(e, t[1], a);
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2469
|
+
Y(e, t[0], i);
|
|
2470
|
+
}
|
|
2471
|
+
function Gr(e, t, n) {
|
|
2472
|
+
t.length !== 0 && (Y(e, t[0], `${n}UpperLeg`), t.length >= 2 && Y(e, t[1], `${n}LowerLeg`), t.length >= 3 && Y(e, t[2], `${n}Foot`));
|
|
2473
|
+
}
|
|
2474
|
+
function Kr(e) {
|
|
2475
|
+
let t = e.bones.reduce((e, t) => jr.test(t.name) ? e + 1 : e, 0);
|
|
2476
|
+
return t >= Nr && t / Math.max(e.bones.length, 1) >= .6;
|
|
2477
|
+
}
|
|
2478
|
+
function qr(e) {
|
|
2479
|
+
if (!Kr(e)) return /* @__PURE__ */ new Map();
|
|
2480
|
+
let t = /* @__PURE__ */ new Map(), n = new Set(e.bones), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = Lr(e, n, r, i), o = a ? Ir(a, "up", n, r, i) : null, s = Rr(o, n, r), c = s[s.length - 1] ?? null, l = /* @__PURE__ */ new Set(), u = zr(c, l, n, r);
|
|
2481
|
+
u && l.add(u);
|
|
2482
|
+
let d = Br(c, "Left", l, n, r, i);
|
|
2483
|
+
d && l.add(d);
|
|
2484
|
+
let f = Br(c, "Right", l, n, r, i), p = Hr(u, "up", n, r, i), m = Hr(d, "positiveX", n, r, i), h = Hr(f, "negativeX", n, r, i), g = /* @__PURE__ */ new Set();
|
|
2485
|
+
o && g.add(o);
|
|
2486
|
+
let _ = Ur(a, "Left", g, n, r, i);
|
|
2487
|
+
_ && g.add(_);
|
|
2488
|
+
let v = Ur(a, "Right", g, n, r, i), y = Hr(_, "down", n, r, i), b = Hr(v, "down", n, r, i);
|
|
2489
|
+
return Y(t, a, "Hips"), s.length >= 2 ? (Y(t, s[0], "Spine"), Y(t, c, "Chest")) : s.length === 1 && Y(t, c, "Chest"), p.length >= 1 && Y(t, p[0], "Neck"), p.length >= 2 && Y(t, p[1], "Head"), Wr(t, m, "Left"), Wr(t, h, "Right"), Gr(t, y, "Left"), Gr(t, b, "Right"), t;
|
|
2490
|
+
}
|
|
2491
|
+
//#endregion
|
|
2492
|
+
//#region src/avatar/VRMCompat.ts
|
|
2493
|
+
var Jr = {
|
|
2494
|
+
root: "hips",
|
|
2495
|
+
c_spine0: "spine",
|
|
2496
|
+
c_spine1: "spine",
|
|
2497
|
+
c_spine2: "chest",
|
|
2498
|
+
c_spine3: "upperChest",
|
|
2499
|
+
c_neck: "neck",
|
|
2500
|
+
c_head: "head",
|
|
2501
|
+
l_clavicle: "leftShoulder",
|
|
2502
|
+
l_uparm: "leftUpperArm",
|
|
2503
|
+
l_lowarm: "leftLowerArm",
|
|
2504
|
+
l_wrist: "leftHand",
|
|
2505
|
+
r_clavicle: "rightShoulder",
|
|
2506
|
+
r_uparm: "rightUpperArm",
|
|
2507
|
+
r_lowarm: "rightLowerArm",
|
|
2508
|
+
r_wrist: "rightHand",
|
|
2509
|
+
l_upleg: "leftUpperLeg",
|
|
2510
|
+
l_lowleg: "leftLowerLeg",
|
|
2511
|
+
l_foot: "leftFoot",
|
|
2512
|
+
r_upleg: "rightUpperLeg",
|
|
2513
|
+
r_lowleg: "rightLowerLeg",
|
|
2514
|
+
r_foot: "rightFoot"
|
|
2515
|
+
}, Yr = {
|
|
2516
|
+
Root: "hips",
|
|
2517
|
+
Hips: "hips",
|
|
2518
|
+
Spine: "spine",
|
|
2519
|
+
Chest: "chest",
|
|
2520
|
+
Neck: "neck",
|
|
2521
|
+
Head: "head",
|
|
2522
|
+
LeftShoulder: "leftShoulder",
|
|
2523
|
+
LeftUpperArm: "leftUpperArm",
|
|
2524
|
+
LeftLowerArm: "leftLowerArm",
|
|
2525
|
+
LeftHand: "leftHand",
|
|
2526
|
+
RightShoulder: "rightShoulder",
|
|
2527
|
+
RightUpperArm: "rightUpperArm",
|
|
2528
|
+
RightLowerArm: "rightLowerArm",
|
|
2529
|
+
RightHand: "rightHand",
|
|
2530
|
+
LeftUpperLeg: "leftUpperLeg",
|
|
2531
|
+
LeftLowerLeg: "leftLowerLeg",
|
|
2532
|
+
LeftFoot: "leftFoot",
|
|
2533
|
+
RightUpperLeg: "rightUpperLeg",
|
|
2534
|
+
RightLowerLeg: "rightLowerLeg",
|
|
2535
|
+
RightFoot: "rightFoot"
|
|
2536
|
+
};
|
|
2537
|
+
function Xr(e, t) {
|
|
2538
|
+
if (t?.humanoid) return {
|
|
2539
|
+
getNormalizedBoneNode: (e) => t.humanoid.getNormalizedBoneNode(e) ?? null,
|
|
2540
|
+
update: (e) => t.update(e),
|
|
2541
|
+
vrm: t
|
|
2542
|
+
};
|
|
2543
|
+
let n = /* @__PURE__ */ new Map(), r = [];
|
|
2544
|
+
return e.traverse((e) => {
|
|
2545
|
+
if (e instanceof b.SkinnedMesh && r.push(e.skeleton), !(e instanceof b.Bone)) return;
|
|
2546
|
+
let t = e.name, i = Jr[t];
|
|
2547
|
+
i && !n.has(i) && n.set(i, e);
|
|
2548
|
+
let a = Yr[t];
|
|
2549
|
+
a && !n.has(a) && n.set(a, e);
|
|
2550
|
+
}), r.forEach((e) => {
|
|
2551
|
+
qr(e).forEach((e, t) => {
|
|
2552
|
+
let r = Yr[e];
|
|
2553
|
+
r && !n.has(r) && n.set(r, t);
|
|
2554
|
+
});
|
|
2555
|
+
}), {
|
|
2556
|
+
getNormalizedBoneNode: (e) => n.get(e) ?? null,
|
|
2557
|
+
update: () => {},
|
|
2558
|
+
vrm: null
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
//#endregion
|
|
2562
|
+
//#region src/hooks/useAvatarVariant.ts
|
|
2563
|
+
function Zr(e) {
|
|
2564
|
+
let t = x(e);
|
|
2565
|
+
return gr(t), t.traverse((e) => {
|
|
2566
|
+
if (e instanceof b.Mesh) {
|
|
2567
|
+
if (Array.isArray(e.material)) {
|
|
2568
|
+
e.material = e.material.map((e) => e.clone());
|
|
2569
|
+
return;
|
|
2570
|
+
}
|
|
2571
|
+
e.material = e.material.clone();
|
|
2572
|
+
}
|
|
2573
|
+
}), t;
|
|
2574
|
+
}
|
|
2575
|
+
function Qr({ url: e }) {
|
|
2576
|
+
let t = p(e, "/draco/", !0, r(() => hr(e), [e])), n = t.userData?.vrm ?? null, i = r(() => n ? (_r(n), n.scene) : Zr(t.scene), [t.scene, n]), a = r(() => Xr(i, n), [i, n]);
|
|
2577
|
+
return {
|
|
2578
|
+
scene: i,
|
|
2579
|
+
humanoid: a,
|
|
2580
|
+
bones: r(() => yr(a), [a])
|
|
2581
|
+
};
|
|
2582
|
+
}
|
|
2583
|
+
//#endregion
|
|
2413
2584
|
//#region src/garment/poseApplication.ts
|
|
2414
|
-
var
|
|
2585
|
+
var $r = 12, ei = new b.Quaternion(), X = new b.Quaternion(), ti = new b.Quaternion(), ni = new b.Vector3(), ri = new b.Vector3(), ii = new b.Vector3(), ai = new b.Vector3(), oi = new b.Vector3(), si = new b.Vector3(), ci = new b.Vector3(), li = new b.Vector3(), ui = new b.Vector3(), di = new b.Quaternion(), fi = new b.Quaternion(), pi = new b.Quaternion(), mi = new b.Quaternion(), hi = {
|
|
2415
2586
|
Hips: [
|
|
2416
2587
|
"Spine",
|
|
2417
2588
|
"Chest",
|
|
@@ -2430,7 +2601,7 @@ var wr = 12, Tr = new b.Quaternion(), J = new b.Quaternion(), Er = new b.Quatern
|
|
|
2430
2601
|
LeftLowerLeg: ["LeftFoot"],
|
|
2431
2602
|
RightUpperLeg: ["RightLowerLeg"],
|
|
2432
2603
|
RightLowerLeg: ["RightFoot"]
|
|
2433
|
-
},
|
|
2604
|
+
}, gi = {
|
|
2434
2605
|
Hips: [
|
|
2435
2606
|
["LeftUpperLeg", "RightUpperLeg"],
|
|
2436
2607
|
["LeftShoulder", "RightShoulder"],
|
|
@@ -2446,104 +2617,116 @@ var wr = 12, Tr = new b.Quaternion(), J = new b.Quaternion(), Er = new b.Quatern
|
|
|
2446
2617
|
["LeftUpperArm", "RightUpperArm"],
|
|
2447
2618
|
["LeftUpperLeg", "RightUpperLeg"]
|
|
2448
2619
|
]
|
|
2449
|
-
},
|
|
2450
|
-
Hips: [
|
|
2451
|
-
Spine: [
|
|
2452
|
-
Chest: [
|
|
2620
|
+
}, _i = {
|
|
2621
|
+
Hips: [B.RIGHT_HIP, B.LEFT_HIP],
|
|
2622
|
+
Spine: [B.RIGHT_SHOULDER, B.LEFT_SHOULDER],
|
|
2623
|
+
Chest: [B.RIGHT_SHOULDER, B.LEFT_SHOULDER]
|
|
2453
2624
|
};
|
|
2454
|
-
function
|
|
2625
|
+
function vi(e) {
|
|
2455
2626
|
return e.startsWith("Left") ? `Right${e.slice(4)}` : e.startsWith("Right") ? `Left${e.slice(5)}` : e;
|
|
2456
2627
|
}
|
|
2457
|
-
function
|
|
2458
|
-
let i =
|
|
2628
|
+
function yi(e, t, n, r) {
|
|
2629
|
+
let i = hi[e];
|
|
2459
2630
|
if (!i) return !1;
|
|
2460
2631
|
for (let e = 0; e < i.length; e += 1) {
|
|
2461
2632
|
let a = n.get(i[e])?.[0];
|
|
2462
|
-
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(
|
|
2633
|
+
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(di.copy(t.restParentWorldQuaternion).invert()).normalize(), !0;
|
|
2463
2634
|
}
|
|
2464
2635
|
return !1;
|
|
2465
2636
|
}
|
|
2466
|
-
function
|
|
2467
|
-
return e in
|
|
2637
|
+
function bi(e) {
|
|
2638
|
+
return e in gi;
|
|
2468
2639
|
}
|
|
2469
|
-
function
|
|
2470
|
-
let i =
|
|
2640
|
+
function xi(e, t, n, r) {
|
|
2641
|
+
let i = gi[e];
|
|
2471
2642
|
if (!i || !t.restParentWorldQuaternion) return !1;
|
|
2472
2643
|
for (let e = 0; e < i.length; e += 1) {
|
|
2473
2644
|
let [a, o] = i[e], s = n.get(a)?.[0], c = n.get(o)?.[0];
|
|
2474
|
-
if (!(!s?.restWorldPosition || !c?.restWorldPosition) && (r.copy(c.restWorldPosition).sub(s.restWorldPosition).applyQuaternion(
|
|
2645
|
+
if (!(!s?.restWorldPosition || !c?.restWorldPosition) && (r.copy(c.restWorldPosition).sub(s.restWorldPosition).applyQuaternion(di.copy(t.restParentWorldQuaternion).invert()), !(r.lengthSq() < 1e-6))) return r.normalize(), !0;
|
|
2475
2646
|
}
|
|
2476
2647
|
return !1;
|
|
2477
2648
|
}
|
|
2478
|
-
function
|
|
2479
|
-
let a =
|
|
2480
|
-
return !a || !Bt(a[0], a[1], t, i, n) ? !1 : (i.applyQuaternion(
|
|
2649
|
+
function Si(e, t, n, r, i) {
|
|
2650
|
+
let a = _i[e];
|
|
2651
|
+
return !a || !Bt(a[0], a[1], t, i, n) ? !1 : (i.applyQuaternion(pi.copy(r).invert()).normalize(), i.lengthSq() >= 1e-6);
|
|
2481
2652
|
}
|
|
2482
|
-
function
|
|
2483
|
-
if (!
|
|
2484
|
-
|
|
2485
|
-
let c = Math.atan2(
|
|
2486
|
-
return
|
|
2653
|
+
function Ci(e, t, n, r, i, a, o, s) {
|
|
2654
|
+
if (!xi(e, t, n, ai) || !Si(e, r, i, a, oi) || (si.copy(ai).applyQuaternion(X), ci.copy(si).projectOnPlane(ii).normalize(), li.copy(oi).projectOnPlane(ii).normalize(), ci.lengthSq() < 1e-6 || li.lengthSq() < 1e-6)) return s.copy(X), !1;
|
|
2655
|
+
ui.crossVectors(ci, li);
|
|
2656
|
+
let c = Math.atan2(ii.dot(ui), ci.dot(li));
|
|
2657
|
+
return mi.setFromAxisAngle(ii, c), s.copy(mi).multiply(X), o !== void 0 && s.slerp(ti, 1 - o), !0;
|
|
2487
2658
|
}
|
|
2488
|
-
function
|
|
2659
|
+
function wi() {
|
|
2489
2660
|
let e = i(new b.Timer()), t = i(/* @__PURE__ */ new Map());
|
|
2490
2661
|
return r(() => ({
|
|
2491
2662
|
clockRef: e,
|
|
2492
2663
|
prevRotationsRef: t
|
|
2493
2664
|
}), []);
|
|
2494
2665
|
}
|
|
2495
|
-
function
|
|
2666
|
+
function Ti(e, t, n, r = {}) {
|
|
2496
2667
|
if (t.size === 0) return;
|
|
2497
2668
|
let { coordinateSpace: i = "normalized", excludeBones: a } = r;
|
|
2498
2669
|
n.clockRef.current.update();
|
|
2499
|
-
let o = n.clockRef.current.getDelta(), s = Math.min(1, o *
|
|
2670
|
+
let o = n.clockRef.current.getDelta(), s = Math.min(1, o * $r);
|
|
2500
2671
|
for (let [n, r] of t) {
|
|
2501
|
-
let o =
|
|
2672
|
+
let o = Dr(n);
|
|
2502
2673
|
if (a?.has(o)) continue;
|
|
2503
|
-
let c =
|
|
2674
|
+
let c = vi(o);
|
|
2504
2675
|
if (o !== n && t.has(o)) continue;
|
|
2505
2676
|
let l = Wt(c);
|
|
2506
2677
|
if (!l) continue;
|
|
2507
|
-
let u = l && Vt(c, e,
|
|
2678
|
+
let u = l && Vt(c, e, ni, i);
|
|
2508
2679
|
if (!u) continue;
|
|
2509
2680
|
let d = !1, f = Ht(c);
|
|
2510
2681
|
for (let n of r) {
|
|
2511
2682
|
let { bone: r, restQuaternion: a } = n;
|
|
2512
|
-
if (u &&
|
|
2683
|
+
if (u && yi(o, n, t, ri)) r.parent ? (r.parent.updateWorldMatrix(!0, !1), r.parent.getWorldQuaternion(fi)) : (r.updateWorldMatrix(!0, !1), fi.identity()), ii.copy(ni).applyQuaternion(pi.copy(fi).invert()).normalize(), X.setFromUnitVectors(ri, ii), bi(o) && Ci(o, n, t, e, i, fi, f, X) || f !== void 0 && X.slerp(ti, 1 - f), ei.copy(X).multiply(a);
|
|
2513
2684
|
else {
|
|
2514
|
-
if (d ||= Ut(c, e,
|
|
2515
|
-
|
|
2685
|
+
if (d ||= Ut(c, e, X, i), !d) continue;
|
|
2686
|
+
ei.copy(a).multiply(X);
|
|
2516
2687
|
}
|
|
2517
|
-
r.quaternion.slerp(
|
|
2688
|
+
r.quaternion.slerp(ei, s), r.updateWorldMatrix(!1, !0);
|
|
2518
2689
|
}
|
|
2519
2690
|
}
|
|
2520
2691
|
}
|
|
2521
|
-
function
|
|
2522
|
-
|
|
2692
|
+
function Ei(e, t) {
|
|
2693
|
+
lr(e), t.prevRotationsRef.current.clear();
|
|
2523
2694
|
}
|
|
2524
|
-
function
|
|
2525
|
-
let i = Math.min(1, n *
|
|
2695
|
+
function Di(e, t, n, r) {
|
|
2696
|
+
let i = Math.min(1, n * $r);
|
|
2526
2697
|
for (let [n, a] of e) {
|
|
2527
|
-
let e =
|
|
2698
|
+
let e = Dr(n);
|
|
2528
2699
|
if (!(r && !r.has(e))) for (let { bone: e, restQuaternion: n } of a) e.quaternion.slerp(n, t * i);
|
|
2529
2700
|
}
|
|
2530
2701
|
}
|
|
2531
2702
|
//#endregion
|
|
2703
|
+
//#region src/pose/frameSmoothing.ts
|
|
2704
|
+
var Oi = 1 / 60, ki = 1 / 240, Ai = 1 / 12;
|
|
2705
|
+
function ji(e) {
|
|
2706
|
+
return Number.isFinite(e) ? T(e, ki, Ai) : Oi;
|
|
2707
|
+
}
|
|
2708
|
+
function Z(e, t) {
|
|
2709
|
+
let n = T(e, 0, 1);
|
|
2710
|
+
if (n === 0 || n === 1) return n;
|
|
2711
|
+
let r = ji(t) / Oi;
|
|
2712
|
+
return 1 - (1 - n) ** r;
|
|
2713
|
+
}
|
|
2714
|
+
//#endregion
|
|
2532
2715
|
//#region src/pose/yawDirectionStabilizer.ts
|
|
2533
|
-
var
|
|
2534
|
-
function
|
|
2535
|
-
return Math.abs(e) <
|
|
2716
|
+
var Mi = 50 * Math.PI / 180, Ni = 30 * Math.PI / 180, Pi = 3;
|
|
2717
|
+
function Fi(e) {
|
|
2718
|
+
return Math.abs(e) < Mi ? "unknown" : e >= 0 ? "positive" : "negative";
|
|
2536
2719
|
}
|
|
2537
|
-
function
|
|
2720
|
+
function Ii(e) {
|
|
2538
2721
|
return e === "positive" ? 1 : e === "negative" ? -1 : 0;
|
|
2539
2722
|
}
|
|
2540
|
-
var
|
|
2723
|
+
var Li = class {
|
|
2541
2724
|
_committedYawDirection = "unknown";
|
|
2542
2725
|
_pendingYawDirection = "unknown";
|
|
2543
2726
|
_pendingCount = 0;
|
|
2544
2727
|
update(e, t) {
|
|
2545
|
-
let n = Math.abs(t), r =
|
|
2546
|
-
return e === "back" || n <
|
|
2728
|
+
let n = Math.abs(t), r = Fi(t);
|
|
2729
|
+
return e === "back" || n < Ni ? (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 >= Pi ? (this._committedYawDirection = this._pendingYawDirection, this._clearPending(), this._buildState(r, this._committedYawDirection, n * Ii(this._committedYawDirection))) : this._buildState(r, r, t)) : this._buildState(r, this._committedYawDirection, n * Ii(this._committedYawDirection));
|
|
2547
2730
|
}
|
|
2548
2731
|
reset() {
|
|
2549
2732
|
this._committedYawDirection = "unknown", this._clearPending();
|
|
@@ -2561,41 +2744,41 @@ var ri = class {
|
|
|
2561
2744
|
_clearPending() {
|
|
2562
2745
|
this._pendingYawDirection = "unknown", this._pendingCount = 0;
|
|
2563
2746
|
}
|
|
2564
|
-
},
|
|
2565
|
-
function
|
|
2747
|
+
}, Ri = 80 * Math.PI / 180, zi = 100 * Math.PI / 180, Bi = 25 * Math.PI / 180, Vi = 8, Hi = 5, Ui = 5, Wi = 5, Gi = .5, Ki = .3, qi = .2, Ji = 5, Yi = 8;
|
|
2748
|
+
function Xi(e) {
|
|
2566
2749
|
return e?.visibility ?? 0;
|
|
2567
2750
|
}
|
|
2568
|
-
function
|
|
2751
|
+
function Zi(e) {
|
|
2569
2752
|
if (!e || e.length < 33) return {
|
|
2570
2753
|
shoulderOrder: !1,
|
|
2571
2754
|
noseVisible: !1,
|
|
2572
2755
|
earSymmetry: !1
|
|
2573
2756
|
};
|
|
2574
|
-
let t = e[
|
|
2757
|
+
let t = e[B.LEFT_SHOULDER], n = e[B.RIGHT_SHOULDER], r = e[B.NOSE], i = e[B.LEFT_EAR], a = e[B.RIGHT_EAR], o = t.x < n.x, s = Xi(r) > Gi, c = Xi(i), l = Xi(a);
|
|
2575
2758
|
return {
|
|
2576
2759
|
shoulderOrder: o,
|
|
2577
2760
|
noseVisible: s,
|
|
2578
|
-
earSymmetry: Math.abs(c - l) <
|
|
2761
|
+
earSymmetry: Math.abs(c - l) < Ki && Math.max(c, l) > qi
|
|
2579
2762
|
};
|
|
2580
2763
|
}
|
|
2581
|
-
function
|
|
2764
|
+
function Qi(e) {
|
|
2582
2765
|
let t = 0;
|
|
2583
2766
|
return e.shoulderOrder && (t += 1), e.noseVisible && (t += 1), e.earSymmetry && (t += 1), t >= 2;
|
|
2584
2767
|
}
|
|
2585
|
-
function
|
|
2586
|
-
return e <
|
|
2768
|
+
function $i(e) {
|
|
2769
|
+
return e < Ri ? "front" : e < zi ? "side" : "back";
|
|
2587
2770
|
}
|
|
2588
|
-
var
|
|
2771
|
+
var ea = class {
|
|
2589
2772
|
_zone = "front";
|
|
2590
2773
|
_consecutiveCount = 0;
|
|
2591
2774
|
_lastRawZone = "front";
|
|
2592
2775
|
_2dFrontCount = 0;
|
|
2593
2776
|
_2dBackCount = 0;
|
|
2594
2777
|
_2dIsFront = !0;
|
|
2595
|
-
_yawDirectionStabilizer = new
|
|
2778
|
+
_yawDirectionStabilizer = new Li();
|
|
2596
2779
|
update(e, t, n) {
|
|
2597
|
-
let r = t ?? 0, i = n ?? 0, a = Math.abs(i) >
|
|
2598
|
-
t === void 0 ? o = this._resolve2dFallback(e) : (o =
|
|
2780
|
+
let r = t ?? 0, i = n ?? 0, a = Math.abs(i) > Bi, o;
|
|
2781
|
+
t === void 0 ? o = this._resolve2dFallback(e) : (o = $i(Math.abs(t)), o === "front" && this._zone !== "front" && (Qi(Zi(e)) || (o = "back"))), this._applyHysteresis(o);
|
|
2599
2782
|
let s = t === void 0 ? null : this._yawDirectionStabilizer.update(this._zone, r);
|
|
2600
2783
|
return t === void 0 && this._yawDirectionStabilizer.reset(), {
|
|
2601
2784
|
zone: this._zone,
|
|
@@ -2613,7 +2796,7 @@ var bi = class {
|
|
|
2613
2796
|
this._zone = "front", this._consecutiveCount = 0, this._lastRawZone = "front", this._2dFrontCount = 0, this._2dBackCount = 0, this._2dIsFront = !0, this._yawDirectionStabilizer.reset();
|
|
2614
2797
|
}
|
|
2615
2798
|
_resolve2dFallback(e) {
|
|
2616
|
-
return
|
|
2799
|
+
return Qi(Zi(e)) ? (this._2dFrontCount += 1, this._2dBackCount = 0) : (this._2dBackCount += 1, this._2dFrontCount = 0), this._2dIsFront ? this._2dBackCount >= Ji && (this._2dIsFront = !1) : this._2dFrontCount >= Yi && (this._2dIsFront = !0), this._2dIsFront ? "front" : "back";
|
|
2617
2800
|
}
|
|
2618
2801
|
_applyHysteresis(e) {
|
|
2619
2802
|
e === this._lastRawZone ? this._consecutiveCount += 1 : (this._lastRawZone = e, this._consecutiveCount = 1);
|
|
@@ -2621,18 +2804,18 @@ var bi = class {
|
|
|
2621
2804
|
t !== null && this._consecutiveCount >= t && (this._zone = e);
|
|
2622
2805
|
}
|
|
2623
2806
|
_getTransitionThreshold(e, t) {
|
|
2624
|
-
return e === t ? null : e === "front" && t === "side" || e === "front" && t === "back" ?
|
|
2807
|
+
return e === t ? null : e === "front" && t === "side" || e === "front" && t === "back" ? Vi : e === "side" && t === "back" ? Hi : e === "back" && t === "side" ? Ui : e === "side" && t === "front" ? Wi : e === "back" && t === "front" ? Ui : Vi;
|
|
2625
2808
|
}
|
|
2626
|
-
},
|
|
2627
|
-
function
|
|
2628
|
-
return e >= 0 ?
|
|
2809
|
+
}, ta = Math.PI / 2;
|
|
2810
|
+
function na(e) {
|
|
2811
|
+
return e >= 0 ? ta : -ta;
|
|
2629
2812
|
}
|
|
2630
|
-
var
|
|
2813
|
+
var ra = class {
|
|
2631
2814
|
_isFrozen = !1;
|
|
2632
2815
|
_frozenYaw = null;
|
|
2633
|
-
update(e, t
|
|
2634
|
-
let
|
|
2635
|
-
return this._isFrozen ? e !== "back" &&
|
|
2816
|
+
update(e, t) {
|
|
2817
|
+
let n = Math.abs(t);
|
|
2818
|
+
return this._isFrozen ? e !== "back" && n < ta && this.reset() : e !== "front" && n >= ta && (this._isFrozen = !0, this._frozenYaw = na(t)), {
|
|
2636
2819
|
isFrozen: this._isFrozen,
|
|
2637
2820
|
frozenYaw: this._frozenYaw
|
|
2638
2821
|
};
|
|
@@ -2643,7 +2826,7 @@ var Ci = class {
|
|
|
2643
2826
|
};
|
|
2644
2827
|
//#endregion
|
|
2645
2828
|
//#region src/pose/coordinateTransform.ts
|
|
2646
|
-
function
|
|
2829
|
+
function ia(e, t) {
|
|
2647
2830
|
return typeof e == "boolean" ? {
|
|
2648
2831
|
mirrorX: e,
|
|
2649
2832
|
sourceWidth: 0,
|
|
@@ -2656,83 +2839,77 @@ function wi(e, t) {
|
|
|
2656
2839
|
target: e.target ?? t ?? new b.Vector3()
|
|
2657
2840
|
};
|
|
2658
2841
|
}
|
|
2659
|
-
function
|
|
2660
|
-
let a =
|
|
2842
|
+
function Q(e, t, n, r = !1, i) {
|
|
2843
|
+
let a = ia(r, i), o = rt(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;
|
|
2661
2844
|
return a.target.set(u, d, f);
|
|
2662
2845
|
}
|
|
2663
|
-
function
|
|
2664
|
-
return
|
|
2846
|
+
function aa(e, t, n, r, i = !1, a) {
|
|
2847
|
+
return Q({
|
|
2665
2848
|
x: (e.x + t.x) / 2,
|
|
2666
2849
|
y: (e.y + t.y) / 2,
|
|
2667
2850
|
z: ((e.z ?? 0) + (t.z ?? 0)) / 2,
|
|
2668
2851
|
visibility: Math.min(e.visibility ?? 0, t.visibility ?? 0)
|
|
2669
2852
|
}, n, r, i, a);
|
|
2670
2853
|
}
|
|
2671
|
-
function
|
|
2854
|
+
function oa(e, t, n, r) {
|
|
2672
2855
|
let i = (e.x - t.x) * n, a = (e.y - t.y) * r;
|
|
2673
2856
|
return Math.sqrt(i * i + a * a);
|
|
2674
2857
|
}
|
|
2675
2858
|
//#endregion
|
|
2676
2859
|
//#region src/garment/fitMotion.ts
|
|
2677
|
-
var
|
|
2678
|
-
function
|
|
2679
|
-
let r = Math.min(Math.abs(n),
|
|
2860
|
+
var sa = .45, ca = .72, la = 1.02, ua = 1.1, da = Math.PI / 6, fa = 1e-4, pa = fa * fa, ma = .35, ha = .6, ga = new b.Vector3(), _a = new b.Vector3(), va = new b.Vector3(), ya = new b.Vector3(), ba = new b.Vector3(), xa = new b.Vector3(), Sa = new b.Matrix4();
|
|
2861
|
+
function Ca(e, t, n) {
|
|
2862
|
+
let r = Math.min(Math.abs(n), ua), i = 1 / Math.max(Math.cos(r), sa) * e, a = t * ca;
|
|
2680
2863
|
return Math.max(i, a, e);
|
|
2681
2864
|
}
|
|
2682
|
-
function
|
|
2683
|
-
let i =
|
|
2865
|
+
function wa({ projectedShoulderWidth: e, projectedTorsoHeight: t, bodyYaw: n, worldLandmarks: r }) {
|
|
2866
|
+
let i = Ca(e, t, n), a = Oa(t, r);
|
|
2684
2867
|
if (!a) return i;
|
|
2685
|
-
let o =
|
|
2868
|
+
let o = T((Math.abs(n) - ma) / ha, 0, 1);
|
|
2686
2869
|
return i + (Math.max(i, a) - i) * o;
|
|
2687
2870
|
}
|
|
2688
|
-
function
|
|
2689
|
-
return e ?
|
|
2871
|
+
function Ta(e) {
|
|
2872
|
+
return e ? T(e.hips.rotation.y * .85 + e.chest.y * .15, -ua, ua) : 0;
|
|
2690
2873
|
}
|
|
2691
|
-
function
|
|
2874
|
+
function Ea(e, t, n) {
|
|
2692
2875
|
let r = e.x <= t.x ? e : t, i = e.x <= t.x ? t : e, a = i.x - r.x;
|
|
2693
|
-
if (a <=
|
|
2876
|
+
if (a <= fa) return 0;
|
|
2694
2877
|
let o = -(i.y - r.y);
|
|
2695
|
-
return
|
|
2878
|
+
return T(Math.atan2(o, a) * T(1 - Math.abs(n) / ua, 0, 1), -da, da);
|
|
2696
2879
|
}
|
|
2697
|
-
function
|
|
2698
|
-
return
|
|
2880
|
+
function Da({ leftShoulder: e, rightShoulder: t, leftHip: n, rightHip: r }, i = new b.Quaternion()) {
|
|
2881
|
+
return ga.copy(e).add(t).multiplyScalar(.5), _a.copy(n).add(r).multiplyScalar(.5), va.copy(t).sub(e), va.lengthSq() <= pa || (va.normalize(), ya.copy(ga).sub(_a), ba.copy(va).multiplyScalar(ya.dot(va)), ya.sub(ba), ya.lengthSq() <= pa) || (ya.normalize(), xa.crossVectors(va, ya), xa.lengthSq() <= pa) ? null : (xa.normalize(), ya.crossVectors(xa, va).normalize(), Sa.makeBasis(va, ya, xa), i.setFromRotationMatrix(Sa));
|
|
2699
2882
|
}
|
|
2700
|
-
function
|
|
2701
|
-
if (!t || t.length <=
|
|
2702
|
-
let n = t[
|
|
2883
|
+
function Oa(e, t) {
|
|
2884
|
+
if (!t || t.length <= B.RIGHT_HIP || e <= fa) return null;
|
|
2885
|
+
let n = t[B.LEFT_SHOULDER], r = t[B.RIGHT_SHOULDER], i = t[B.LEFT_HIP], a = t[B.RIGHT_HIP];
|
|
2703
2886
|
if (!n || !r || !i || !a) return null;
|
|
2704
|
-
let o =
|
|
2705
|
-
return o <=
|
|
2887
|
+
let o = Aa(n, r), s = Aa(ka(n, r), ka(i, a));
|
|
2888
|
+
return o <= fa || s <= fa ? null : e * T(o / s, ca, la);
|
|
2706
2889
|
}
|
|
2707
|
-
function
|
|
2890
|
+
function ka(e, t) {
|
|
2708
2891
|
return {
|
|
2709
2892
|
x: (e.x + t.x) * .5,
|
|
2710
2893
|
y: (e.y + t.y) * .5,
|
|
2711
2894
|
z: ((e.z ?? 0) + (t.z ?? 0)) * .5
|
|
2712
2895
|
};
|
|
2713
2896
|
}
|
|
2714
|
-
function
|
|
2897
|
+
function Aa(e, t) {
|
|
2715
2898
|
let n = e.x - t.x, r = e.y - t.y, i = (e.z ?? 0) - (t.z ?? 0);
|
|
2716
2899
|
return Math.sqrt(n * n + r * r + i * i);
|
|
2717
2900
|
}
|
|
2718
|
-
function Ji(e, t, n) {
|
|
2719
|
-
return Math.max(t, Math.min(n, e));
|
|
2720
|
-
}
|
|
2721
2901
|
//#endregion
|
|
2722
2902
|
//#region src/garment/trackedModelTransform.ts
|
|
2723
|
-
var
|
|
2724
|
-
[
|
|
2725
|
-
|
|
2726
|
-
[
|
|
2727
|
-
],
|
|
2728
|
-
[
|
|
2729
|
-
[
|
|
2730
|
-
[
|
|
2903
|
+
var $ = 1e-4, ja = .15, Ma = 8, Na = 1e-4, Pa = 1.45, Fa = .35, Ia = 10, La = .08, Ra = .42, za = .82, Ba = Math.PI / 4, Va = .76, Ha = .88, Ua = 1.32, Wa = .2, Ga = 1.3, Ka = .08, qa = .14, Ja = .55, Ya = .2, Xa = .18, Za = .55, Qa = 6, $a = .3, eo = .08, to = .05, no = 1.35, ro = .7, io = new b.Vector3(0, 1, 0), ao = new b.Quaternion(), oo = new b.Vector3(), so = new b.Quaternion(), co = new b.Euler(0, 0, 0, "YXZ"), lo = [
|
|
2904
|
+
[B.LEFT_EAR, B.RIGHT_EAR],
|
|
2905
|
+
B.NOSE,
|
|
2906
|
+
[B.LEFT_SHOULDER, B.RIGHT_SHOULDER]
|
|
2907
|
+
], uo = [
|
|
2908
|
+
[B.LEFT_ANKLE, B.RIGHT_ANKLE],
|
|
2909
|
+
[B.LEFT_HEEL, B.RIGHT_HEEL],
|
|
2910
|
+
[B.LEFT_FOOT_INDEX, B.RIGHT_FOOT_INDEX]
|
|
2731
2911
|
];
|
|
2732
|
-
function
|
|
2733
|
-
return Math.max(t, Math.min(n, e));
|
|
2734
|
-
}
|
|
2735
|
-
function ha() {
|
|
2912
|
+
function fo() {
|
|
2736
2913
|
return {
|
|
2737
2914
|
leftShoulder: new b.Vector3(),
|
|
2738
2915
|
rightShoulder: new b.Vector3(),
|
|
@@ -2746,8 +2923,12 @@ function ha() {
|
|
|
2746
2923
|
scaledAnchor: new b.Vector3(),
|
|
2747
2924
|
position: new b.Vector3(),
|
|
2748
2925
|
scale: new b.Vector3(1, 1, 1),
|
|
2926
|
+
rootQuaternion: new b.Quaternion(),
|
|
2927
|
+
bodyPitch: 0,
|
|
2928
|
+
bodyRoll: 0,
|
|
2749
2929
|
stabilizedBodyHeightScale: null,
|
|
2750
2930
|
missingBodyHeightFrames: 0,
|
|
2931
|
+
stableTorsoHeightToShoulderRatio: null,
|
|
2751
2932
|
smoothedGlobalScale: 1,
|
|
2752
2933
|
hasSmoothedGlobalScale: !1,
|
|
2753
2934
|
effectiveYaw: 0,
|
|
@@ -2758,84 +2939,128 @@ function ha() {
|
|
|
2758
2939
|
hasSmoothedAnchor: !1
|
|
2759
2940
|
};
|
|
2760
2941
|
}
|
|
2761
|
-
function
|
|
2942
|
+
function po(e, t, n, r, i, a = {}) {
|
|
2762
2943
|
if (t.length < 33) return !1;
|
|
2763
|
-
|
|
2944
|
+
let o = a.deltaSeconds;
|
|
2945
|
+
Q(t[B.LEFT_SHOULDER], n, r, {
|
|
2764
2946
|
mirrorX: !0,
|
|
2765
2947
|
sourceWidth: a.sourceWidth,
|
|
2766
2948
|
sourceHeight: a.sourceHeight,
|
|
2767
2949
|
target: i.leftShoulder
|
|
2768
|
-
}),
|
|
2950
|
+
}), Q(t[B.RIGHT_SHOULDER], n, r, {
|
|
2769
2951
|
mirrorX: !0,
|
|
2770
2952
|
sourceWidth: a.sourceWidth,
|
|
2771
2953
|
sourceHeight: a.sourceHeight,
|
|
2772
2954
|
target: i.rightShoulder
|
|
2773
|
-
}),
|
|
2955
|
+
}), Q(t[B.LEFT_HIP], n, r, {
|
|
2774
2956
|
mirrorX: !0,
|
|
2775
2957
|
sourceWidth: a.sourceWidth,
|
|
2776
2958
|
sourceHeight: a.sourceHeight,
|
|
2777
2959
|
target: i.leftHip
|
|
2778
|
-
}),
|
|
2960
|
+
}), Q(t[B.RIGHT_HIP], n, r, {
|
|
2779
2961
|
mirrorX: !0,
|
|
2780
2962
|
sourceWidth: a.sourceWidth,
|
|
2781
2963
|
sourceHeight: a.sourceHeight,
|
|
2782
2964
|
target: i.rightHip
|
|
2783
2965
|
}), i.shoulderCenter.copy(i.leftShoulder).add(i.rightShoulder).multiplyScalar(.5), i.hipCenter.copy(i.leftHip).add(i.rightHip).multiplyScalar(.5);
|
|
2784
|
-
let
|
|
2966
|
+
let s = Da({
|
|
2785
2967
|
leftShoulder: i.rightShoulder,
|
|
2786
2968
|
rightShoulder: i.leftShoulder,
|
|
2787
2969
|
leftHip: i.rightHip,
|
|
2788
2970
|
rightHip: i.leftHip
|
|
2789
|
-
},
|
|
2790
|
-
i.effectiveYaw =
|
|
2791
|
-
let
|
|
2792
|
-
projectedShoulderWidth:
|
|
2793
|
-
projectedTorsoHeight:
|
|
2794
|
-
bodyYaw:
|
|
2971
|
+
}, ao), c = s ? ho(s) : 0, l = wo(a.bodyYaw, c);
|
|
2972
|
+
s ? (i.rootQuaternion.copy(s), go(i.rootQuaternion, i)) : (i.rootQuaternion.identity(), i.bodyPitch = 0, i.bodyRoll = 0), i.effectiveYaw = l;
|
|
2973
|
+
let u = Eo(i.leftShoulder, i.rightShoulder), d = bo(Eo(i.shoulderCenter, i.hipCenter), i.shoulderCenter.distanceTo(i.hipCenter), i.bodyPitch), f = wa({
|
|
2974
|
+
projectedShoulderWidth: u,
|
|
2975
|
+
projectedTorsoHeight: d,
|
|
2976
|
+
bodyYaw: l,
|
|
2795
2977
|
worldLandmarks: a.worldLandmarks
|
|
2796
|
-
}), f =
|
|
2797
|
-
|
|
2978
|
+
}), { torsoHeight: p, leanInfluence: m } = xo(d, f, e, i, o), h = p / Math.max(e.referenceTorsoHeight, $), g = To(t, n, r, p, i, a), _ = So(g === null ? null : g / Math.max(e.trackingHeight, $), i, o), v = _ !== null && h > $ ? T(_, h * ro, h * no) : _, y = v === null ? 1 : T(Ja + m * Ya, Ja, Ja + Ya), x = 1 - y, S = Co(T(v === null ? h : h * y + v * x, ja, Ma) * (a.scaleMultiplier ?? 1), i, p, o), C = .1, w = e.referenceWidth / Math.max(e.referenceTorsoHeight, $), E = p > $ ? f / p : w, D = T(w > $ ? E / w : 1, 1 - C, 1 + C), O = Z(.35, o);
|
|
2979
|
+
i.smoothedXDeviation = b.MathUtils.lerp(i.smoothedXDeviation, D, O), i.scale.set(S * i.smoothedXDeviation * (a.scaleX ?? 1), S * (a.scaleY ?? 1), S * (a.scaleZ ?? 1)), i.anchor.copy(i.shoulderCenter).add(i.hipCenter).multiplyScalar(.5);
|
|
2980
|
+
let k = Z(.4, o);
|
|
2981
|
+
return i.hasSmoothedAnchor ? i.smoothedAnchor.lerp(i.anchor, k) : (i.smoothedAnchor.copy(i.anchor), i.hasSmoothedAnchor = !0), i.scaledAnchor.set(e.anchor.x * S, e.anchor.y * S, e.anchor.z * S), i.position.copy(i.smoothedAnchor).sub(i.scaledAnchor), i.position.z += a.depthOffset ?? 0, !0;
|
|
2798
2982
|
}
|
|
2799
|
-
function
|
|
2983
|
+
function mo(e, t) {
|
|
2800
2984
|
e.position.copy(t.position), e.scale.copy(t.scale);
|
|
2801
2985
|
}
|
|
2802
|
-
function
|
|
2803
|
-
return
|
|
2986
|
+
function ho(e) {
|
|
2987
|
+
return oo.set(0, 0, 1).applyQuaternion(e), oo.y = 0, oo.lengthSq() <= Na ? 0 : (oo.normalize(), Math.atan2(oo.x, oo.z));
|
|
2988
|
+
}
|
|
2989
|
+
function go(e, t) {
|
|
2990
|
+
so.copy(e).premultiply(ao.setFromAxisAngle(io, -Math.PI)), co.setFromQuaternion(so, "YXZ"), t.bodyPitch = -E(co.x), t.bodyRoll = -E(co.z);
|
|
2991
|
+
}
|
|
2992
|
+
function _o(e, t) {
|
|
2993
|
+
if (e <= $) return e;
|
|
2994
|
+
let n = Math.min(Math.abs(t), Ba), r = vo(n);
|
|
2995
|
+
if (r <= 0) return e;
|
|
2996
|
+
let i = 1 / Math.max(Math.cos(n), Va);
|
|
2997
|
+
return e * b.MathUtils.lerp(1, i, r * za);
|
|
2998
|
+
}
|
|
2999
|
+
function vo(e) {
|
|
3000
|
+
return T((e - La) / Ra, 0, 1);
|
|
3001
|
+
}
|
|
3002
|
+
function yo(e, t) {
|
|
3003
|
+
if (e <= $ || !Number.isFinite(t) || t <= e) return e;
|
|
3004
|
+
let n = T(t, e, e * Ua);
|
|
3005
|
+
return b.MathUtils.lerp(e, n, Ha);
|
|
3006
|
+
}
|
|
3007
|
+
function bo(e, t, n) {
|
|
3008
|
+
return Math.max(e, _o(e, n), yo(e, t));
|
|
3009
|
+
}
|
|
3010
|
+
function xo(e, t, n, r, i) {
|
|
3011
|
+
if (e <= $ || t <= $) return {
|
|
3012
|
+
torsoHeight: e,
|
|
3013
|
+
leanInfluence: 0
|
|
3014
|
+
};
|
|
3015
|
+
let a = n.referenceWidth > $ ? n.referenceTorsoHeight / n.referenceWidth : 1, o = e / t, s = vo(Math.abs(r.bodyPitch));
|
|
3016
|
+
r.stableTorsoHeightToShoulderRatio === null && (r.stableTorsoHeightToShoulderRatio = a);
|
|
3017
|
+
let c = Z(Wa, i), l = s > .18 ? Math.max(r.stableTorsoHeightToShoulderRatio, o) : o;
|
|
3018
|
+
r.stableTorsoHeightToShoulderRatio = b.MathUtils.lerp(r.stableTorsoHeightToShoulderRatio, l, c);
|
|
3019
|
+
let u = T(t * r.stableTorsoHeightToShoulderRatio, e, e * Ga), d = T((u / Math.max(e, $) - 1 - Ka) / qa, 0, 1), f = Math.max(s, d);
|
|
3020
|
+
return {
|
|
3021
|
+
torsoHeight: b.MathUtils.lerp(e, u, f),
|
|
3022
|
+
leanInfluence: f
|
|
3023
|
+
};
|
|
2804
3024
|
}
|
|
2805
|
-
function
|
|
2806
|
-
|
|
3025
|
+
function So(e, t, n) {
|
|
3026
|
+
if (e !== null) {
|
|
3027
|
+
t.missingBodyHeightFrames = 0;
|
|
3028
|
+
let r = Z(Fa, n);
|
|
3029
|
+
return t.stabilizedBodyHeightScale = t.stabilizedBodyHeightScale === null ? e : b.MathUtils.lerp(t.stabilizedBodyHeightScale, e, r), t.stabilizedBodyHeightScale;
|
|
3030
|
+
}
|
|
3031
|
+
return t.stabilizedBodyHeightScale === null ? (t.missingBodyHeightFrames = 0, null) : (t.missingBodyHeightFrames += 1, t.missingBodyHeightFrames > Ia ? (t.stabilizedBodyHeightScale = null, null) : t.stabilizedBodyHeightScale);
|
|
2807
3032
|
}
|
|
2808
|
-
function
|
|
3033
|
+
function Co(e, t, n, r) {
|
|
2809
3034
|
if (!t.hasSmoothedGlobalScale) return t.smoothedGlobalScale = e, t.previousDepthProxy = n, t.scaleVelocity = 0, t.hasSmoothedGlobalScale = !0, e;
|
|
2810
|
-
let
|
|
2811
|
-
|
|
2812
|
-
let
|
|
2813
|
-
t.scaleVelocity = b.MathUtils.lerp(t.scaleVelocity,
|
|
2814
|
-
let
|
|
2815
|
-
return t.smoothedGlobalScale = b.MathUtils.lerp(
|
|
2816
|
-
}
|
|
2817
|
-
function
|
|
3035
|
+
let i = t.previousDepthProxy, a = 1;
|
|
3036
|
+
i > to && n > to && (a = T(n / i, 1 - eo, 1 + eo)), t.previousDepthProxy = n;
|
|
3037
|
+
let o = t.smoothedGlobalScale * a, s = o > 0 ? Math.abs(e - o) / o : 0, c = Z($a, r);
|
|
3038
|
+
t.scaleVelocity = b.MathUtils.lerp(t.scaleVelocity, s, c);
|
|
3039
|
+
let l = Z(T(Xa + t.scaleVelocity * Qa, Xa, Za), r);
|
|
3040
|
+
return t.smoothedGlobalScale = b.MathUtils.lerp(o, e, l), t.smoothedGlobalScale;
|
|
3041
|
+
}
|
|
3042
|
+
function wo(e, t) {
|
|
2818
3043
|
let n = e ?? 0;
|
|
2819
3044
|
return Math.abs(n) >= Math.abs(t) ? n : t;
|
|
2820
3045
|
}
|
|
2821
|
-
function
|
|
2822
|
-
let o =
|
|
3046
|
+
function To(e, t, n, r, i, a) {
|
|
3047
|
+
let o = Do(lo, e, t, n, i.bodyTop, a), s = Do(uo, e, t, n, i.bodyBottom, a);
|
|
2823
3048
|
if (!o || !s) return null;
|
|
2824
|
-
let c =
|
|
2825
|
-
return c <= r *
|
|
3049
|
+
let c = bo(Eo(i.bodyTop, i.bodyBottom), i.bodyTop.distanceTo(i.bodyBottom), i.bodyPitch);
|
|
3050
|
+
return c <= r * Pa ? null : c;
|
|
2826
3051
|
}
|
|
2827
|
-
function
|
|
3052
|
+
function Eo(e, t) {
|
|
2828
3053
|
let n = e.x - t.x, r = e.y - t.y;
|
|
2829
3054
|
return Math.sqrt(n * n + r * r);
|
|
2830
3055
|
}
|
|
2831
|
-
function
|
|
2832
|
-
for (let o = 0; o < e.length; o += 1) if (
|
|
3056
|
+
function Do(e, t, n, r, i, a) {
|
|
3057
|
+
for (let o = 0; o < e.length; o += 1) if (Oo(e[o], t, n, r, i, a)) return !0;
|
|
2833
3058
|
return !1;
|
|
2834
3059
|
}
|
|
2835
|
-
function
|
|
3060
|
+
function Oo(e, t, n, r, i, a) {
|
|
2836
3061
|
if (typeof e == "number") {
|
|
2837
3062
|
let o = t[e];
|
|
2838
|
-
return !o || (o.visibility ?? 0) < .4 ? !1 : (
|
|
3063
|
+
return !o || (o.visibility ?? 0) < .4 ? !1 : (Q(o, n, r, {
|
|
2839
3064
|
mirrorX: !0,
|
|
2840
3065
|
sourceWidth: a.sourceWidth,
|
|
2841
3066
|
sourceHeight: a.sourceHeight,
|
|
@@ -2844,13 +3069,13 @@ function Ta(e, t, n, r, i, a) {
|
|
|
2844
3069
|
}
|
|
2845
3070
|
let o = t[e[0]], s = t[e[1]];
|
|
2846
3071
|
if (!o || !s || (o.visibility ?? 0) < .4 || (s.visibility ?? 0) < .4) return !1;
|
|
2847
|
-
|
|
3072
|
+
Q(o, n, r, {
|
|
2848
3073
|
mirrorX: !0,
|
|
2849
3074
|
sourceWidth: a.sourceWidth,
|
|
2850
3075
|
sourceHeight: a.sourceHeight,
|
|
2851
3076
|
target: i
|
|
2852
3077
|
});
|
|
2853
|
-
let c =
|
|
3078
|
+
let c = Q(s, n, r, {
|
|
2854
3079
|
mirrorX: !0,
|
|
2855
3080
|
sourceWidth: a.sourceWidth,
|
|
2856
3081
|
sourceHeight: a.sourceHeight
|
|
@@ -2859,62 +3084,64 @@ function Ta(e, t, n, r, i, a) {
|
|
|
2859
3084
|
}
|
|
2860
3085
|
//#endregion
|
|
2861
3086
|
//#region src/garment/trackedGarmentMotion.ts
|
|
2862
|
-
var
|
|
3087
|
+
var ko = new Set(["LeftHand", "RightHand"]), Ao = new Set([
|
|
2863
3088
|
"Hips",
|
|
2864
3089
|
"Spine",
|
|
2865
3090
|
"Chest"
|
|
2866
|
-
]),
|
|
2867
|
-
function
|
|
2868
|
-
|
|
3091
|
+
]), jo = 20, Mo = .436, No = .175, Po = 1.396, Fo = .349, Io = .28, Lo = .55, Ro = .7, zo = 24 * Math.PI / 180, Bo = 22 * Math.PI / 180, Vo = .35, Ho = new b.Euler(0, 0, 0, "YXZ");
|
|
3092
|
+
function Uo(e, t, n) {
|
|
3093
|
+
let r = E(t - e);
|
|
3094
|
+
return E(Math.abs(r) <= n ? t : e + Math.sign(r) * n);
|
|
2869
3095
|
}
|
|
2870
|
-
function
|
|
2871
|
-
let t = e;
|
|
2872
|
-
for (; t <= -Math.PI;) t += Math.PI * 2;
|
|
2873
|
-
for (; t > Math.PI;) t -= Math.PI * 2;
|
|
2874
|
-
return t;
|
|
2875
|
-
}
|
|
2876
|
-
function La(e, t, n) {
|
|
2877
|
-
let r = Ia(t - e);
|
|
2878
|
-
return Ia(Math.abs(r) <= n ? t : e + Math.sign(r) * n);
|
|
2879
|
-
}
|
|
2880
|
-
function Ra() {
|
|
3096
|
+
function Wo() {
|
|
2881
3097
|
return {
|
|
2882
|
-
transformScratch:
|
|
2883
|
-
facingDetector: new
|
|
2884
|
-
yawFreezeController: new
|
|
3098
|
+
transformScratch: fo(),
|
|
3099
|
+
facingDetector: new ea(),
|
|
3100
|
+
yawFreezeController: new ra(),
|
|
2885
3101
|
displayYaw: null,
|
|
3102
|
+
displayPitch: null,
|
|
3103
|
+
displayRoll: null,
|
|
2886
3104
|
lastFacingState: null,
|
|
2887
3105
|
hasInitialPosition: !1
|
|
2888
3106
|
};
|
|
2889
3107
|
}
|
|
2890
|
-
function
|
|
2891
|
-
e.transformScratch =
|
|
3108
|
+
function Go(e) {
|
|
3109
|
+
e.transformScratch = fo(), e.facingDetector.reset(), e.yawFreezeController.reset(), e.displayYaw = null, e.displayPitch = null, e.displayRoll = null, e.lastFacingState = null, e.hasInitialPosition = !1;
|
|
2892
3110
|
}
|
|
2893
|
-
function
|
|
3111
|
+
function Ko({ 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 }) {
|
|
2894
3112
|
if (!a || a.length < 33) return null;
|
|
2895
3113
|
let f = i.transformScratch;
|
|
2896
|
-
|
|
3114
|
+
po(e, a, s, c, f, {
|
|
2897
3115
|
sourceWidth: l,
|
|
2898
3116
|
sourceHeight: u,
|
|
2899
|
-
worldLandmarks: o
|
|
3117
|
+
worldLandmarks: o,
|
|
3118
|
+
deltaSeconds: d
|
|
2900
3119
|
});
|
|
2901
|
-
let p = f.shoulderCenter.y - f.hipCenter.y, m = f.shoulderCenter.distanceTo(f.hipCenter), h = Math.acos(
|
|
2902
|
-
|
|
3120
|
+
let p = f.shoulderCenter.y - f.hipCenter.y, m = f.shoulderCenter.distanceTo(f.hipCenter), h = Math.acos(T(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, x = i.displayYaw === null ? y : Uo(i.displayYaw, y, jo * d), S = i.yawFreezeController.update(v.zone, y), C = S.isFrozen, w = C ? S.frozenYaw ?? x : x, E = v.zone === "side" ? .6 : 1, D = T(f.bodyPitch * Lo, -zo, zo), O = T(f.bodyRoll * Ro * E, -Bo, Bo);
|
|
3121
|
+
if (i.displayYaw = w, i.lastFacingState = v, v.zone !== "back") {
|
|
3122
|
+
if (!C) {
|
|
3123
|
+
t.scale.copy(f.scale), i.hasInitialPosition ? t.position.lerp(f.position, Z(Vo, d)) : (t.position.copy(f.position), i.hasInitialPosition = !0);
|
|
3124
|
+
let e = Z(Io, d);
|
|
3125
|
+
i.displayPitch = i.displayPitch === null ? D : b.MathUtils.lerp(i.displayPitch, D, e), i.displayRoll = i.displayRoll === null ? O : b.MathUtils.lerp(i.displayRoll, O, e);
|
|
3126
|
+
}
|
|
3127
|
+
t.quaternion.setFromEuler(Ho.set(i.displayPitch ?? 0, w, i.displayRoll ?? 0));
|
|
3128
|
+
}
|
|
3129
|
+
return v.zone === "front" && !C ? (Ti(a, n, r, {
|
|
2903
3130
|
coordinateSpace: "normalized",
|
|
2904
|
-
excludeBones:
|
|
2905
|
-
}), v.pitchClamped &&
|
|
3131
|
+
excludeBones: ko
|
|
3132
|
+
}), v.pitchClamped && Di(n, T((Math.abs(h) - Mo) / No, 0, 1), d, Ao)) : v.zone === "side" && !C && (Ti(a, n, r, {
|
|
2906
3133
|
coordinateSpace: "normalized",
|
|
2907
|
-
excludeBones:
|
|
2908
|
-
}),
|
|
3134
|
+
excludeBones: ko
|
|
3135
|
+
}), Di(n, T((Math.abs(y) - Po) / Fo, 0, 1), d)), v;
|
|
2909
3136
|
}
|
|
2910
3137
|
//#endregion
|
|
2911
3138
|
//#region src/components/TrackedGarmentPoseDriver.tsx
|
|
2912
|
-
function
|
|
2913
|
-
let { viewport: d } = c(), f =
|
|
3139
|
+
function qo({ garmentRootRef: e, boneBindingMap: t, fitProfile: r, landmarks: a, worldLandmarks: o, poseFrameWidth: l, poseFrameHeight: u }) {
|
|
3140
|
+
let { viewport: d } = c(), f = wi(), p = i(Wo());
|
|
2914
3141
|
return n(() => {
|
|
2915
3142
|
let n = e.current, r = p.current;
|
|
2916
|
-
return n && (n.position.set(0, 0, 0), n.scale.set(1, 1, 1), n.quaternion.identity()),
|
|
2917
|
-
|
|
3143
|
+
return n && (n.position.set(0, 0, 0), n.scale.set(1, 1, 1), n.quaternion.identity()), Ei(t, f), Go(r), () => {
|
|
3144
|
+
Ei(t, f), Go(r);
|
|
2918
3145
|
};
|
|
2919
3146
|
}, [
|
|
2920
3147
|
t,
|
|
@@ -2923,7 +3150,7 @@ function Va({ garmentRootRef: e, boneBindingMap: t, fitProfile: r, landmarks: a,
|
|
|
2923
3150
|
f
|
|
2924
3151
|
]), s((n, i) => {
|
|
2925
3152
|
let s = e.current;
|
|
2926
|
-
!s || !r ||
|
|
3153
|
+
!s || !r || Ko({
|
|
2927
3154
|
fitProfile: r,
|
|
2928
3155
|
garmentRoot: s,
|
|
2929
3156
|
boneBindingMap: t,
|
|
@@ -2941,7 +3168,7 @@ function Va({ garmentRootRef: e, boneBindingMap: t, fitProfile: r, landmarks: a,
|
|
|
2941
3168
|
}
|
|
2942
3169
|
//#endregion
|
|
2943
3170
|
//#region src/components/EverTrackedGarment.tsx
|
|
2944
|
-
function
|
|
3171
|
+
function Jo(e) {
|
|
2945
3172
|
return e ? e.map((e) => ({
|
|
2946
3173
|
x: e.x,
|
|
2947
3174
|
y: e.y,
|
|
@@ -2949,8 +3176,8 @@ function Ha(e) {
|
|
|
2949
3176
|
visibility: typeof e.visibility == "number" ? e.visibility : 0
|
|
2950
3177
|
})) : null;
|
|
2951
3178
|
}
|
|
2952
|
-
function
|
|
2953
|
-
let u = i(null), { scene: d, bones: f } =
|
|
3179
|
+
function Yo({ url: e, landmarks: t, worldLandmarks: a, poseFrameWidth: o, poseFrameHeight: s, debugMaterials: c = !1, onLoadStateChange: l }) {
|
|
3180
|
+
let u = i(null), { scene: d, bones: f } = Qr({ url: e }), p = r(() => Jo(t), [t]), m = r(() => Jo(a), [a]), _ = r(() => (d.updateMatrixWorld(!0), cr(d, f, 1)), [f, d]);
|
|
2954
3181
|
return n(() => {
|
|
2955
3182
|
d.traverse((e) => {
|
|
2956
3183
|
if (e instanceof b.Mesh) {
|
|
@@ -2973,7 +3200,7 @@ function Ua({ url: e, landmarks: t, worldLandmarks: a, poseFrameWidth: o, poseFr
|
|
|
2973
3200
|
});
|
|
2974
3201
|
}), [l, e]), /* @__PURE__ */ g("group", {
|
|
2975
3202
|
ref: u,
|
|
2976
|
-
children: [/* @__PURE__ */ h("primitive", { object: d }), /* @__PURE__ */ h(
|
|
3203
|
+
children: [/* @__PURE__ */ h("primitive", { object: d }), /* @__PURE__ */ h(qo, {
|
|
2977
3204
|
garmentRootRef: u,
|
|
2978
3205
|
boneBindingMap: f,
|
|
2979
3206
|
fitProfile: _,
|
|
@@ -2986,20 +3213,20 @@ function Ua({ url: e, landmarks: t, worldLandmarks: a, poseFrameWidth: o, poseFr
|
|
|
2986
3213
|
}
|
|
2987
3214
|
//#endregion
|
|
2988
3215
|
//#region src/components/WebcamPlaneBackground.tsx
|
|
2989
|
-
var
|
|
2990
|
-
function
|
|
3216
|
+
var Xo = 1;
|
|
3217
|
+
function Zo(e) {
|
|
2991
3218
|
let t = new b.VideoTexture(e);
|
|
2992
3219
|
return t.minFilter = b.NearestFilter, t.magFilter = b.NearestFilter, t.generateMipmaps = !1, t.colorSpace = b.SRGBColorSpace, t.needsUpdate = !0, t;
|
|
2993
3220
|
}
|
|
2994
|
-
function
|
|
3221
|
+
function Qo(e, t, n) {
|
|
2995
3222
|
if (!n || n.width === 0 || n.height === 0) return [e, t];
|
|
2996
3223
|
let r = e / t, i = n.width / n.height;
|
|
2997
3224
|
return r > i ? [e, e / i] : [t * i, t];
|
|
2998
3225
|
}
|
|
2999
|
-
function
|
|
3226
|
+
function $o({ videoElement: e, webcamReady: t }) {
|
|
3000
3227
|
let { viewport: o } = c(), [l, u] = a(null), [d, f] = a(null), p = i(null), m = i(null), _ = i(0);
|
|
3001
3228
|
n(() => {
|
|
3002
|
-
let n = e
|
|
3229
|
+
let n = e;
|
|
3003
3230
|
if (!t || !n) {
|
|
3004
3231
|
m.current !== null && (clearTimeout(m.current), m.current = null), _.current = 0;
|
|
3005
3232
|
return;
|
|
@@ -3010,7 +3237,7 @@ function qa({ videoRef: e, webcamReady: t }) {
|
|
|
3010
3237
|
m.current = setTimeout(i, 100);
|
|
3011
3238
|
return;
|
|
3012
3239
|
}
|
|
3013
|
-
let e =
|
|
3240
|
+
let e = Zo(n);
|
|
3014
3241
|
p.current = e, _.current = 0, f({
|
|
3015
3242
|
width: n.videoWidth,
|
|
3016
3243
|
height: n.videoHeight
|
|
@@ -3020,9 +3247,9 @@ function qa({ videoRef: e, webcamReady: t }) {
|
|
|
3020
3247
|
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);
|
|
3021
3248
|
};
|
|
3022
3249
|
}, [e, t]), s(() => {
|
|
3023
|
-
!p.current || !p.current.image || (_.current = (_.current + 1) %
|
|
3250
|
+
!p.current || !p.current.image || (_.current = (_.current + 1) % Xo, _.current === 0 && (p.current.needsUpdate = !0));
|
|
3024
3251
|
});
|
|
3025
|
-
let [v, y] = r(() =>
|
|
3252
|
+
let [v, y] = r(() => Qo(o.width, o.height, d), [
|
|
3026
3253
|
d,
|
|
3027
3254
|
o.height,
|
|
3028
3255
|
o.width
|
|
@@ -3049,57 +3276,130 @@ function qa({ videoRef: e, webcamReady: t }) {
|
|
|
3049
3276
|
}
|
|
3050
3277
|
//#endregion
|
|
3051
3278
|
//#region src/components/EverFittingScene.tsx
|
|
3052
|
-
function
|
|
3279
|
+
function es({ onReady: e }) {
|
|
3053
3280
|
return n(() => (e?.(!0), () => {
|
|
3054
3281
|
e?.(!1);
|
|
3055
3282
|
}), [e]), null;
|
|
3056
3283
|
}
|
|
3057
|
-
function
|
|
3284
|
+
function ts() {
|
|
3058
3285
|
return /* @__PURE__ */ h("color", {
|
|
3059
3286
|
attach: "background",
|
|
3060
3287
|
args: ["#000000"]
|
|
3061
3288
|
});
|
|
3062
3289
|
}
|
|
3063
|
-
function
|
|
3064
|
-
let
|
|
3065
|
-
enabled:
|
|
3066
|
-
width:
|
|
3067
|
-
height:
|
|
3068
|
-
facingMode:
|
|
3069
|
-
mockMode:
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3290
|
+
function ns({ garmentUrl: e, enabled: i = !0, width: o = 1280, height: s = 720, facingMode: c = "user", mockMode: l = !1, modelComplexity: u, numPoses: p, minDetectionConfidence: m, minTrackingConfidence: _, outputSegmentationMasks: v, viewportWidth: y = 0, viewportHeight: b = 0, measurementEnabled: x = !0, autoStartMeasurement: S = !1, measurementConfig: C, fitType: T = "regular", garmentScaleHint: E = null, bodyPresetOptions: D, className: O, style: k, debugMaterials: A = !1, showEnvironment: j = !1, showStats: M = !1, showWebcamBackground: N = !0, onCanvasReadyChange: P, onRuntimeStateChange: ee, onGarmentLoadStateChange: F }) {
|
|
3291
|
+
let { videoRef: I, webcamReady: L, webcamError: te, startWebcam: ne, stopWebcam: re, isTrackerReady: ie, landmarks: ae, worldLandmarks: oe, poseRig: R, confidence: z, fps: se, isTracking: ce, drawLandmarks: le, silhouetteWidths: ue, poseFrameWidth: de, poseFrameHeight: fe, detectedPersonCount: pe, lockedPersonId: me, trackingQuality: he, config: ge, measurements: _e, sizeRecommendation: ve, garmentScale: ye, finalGarmentScale: be, bodyMorphResult: xe, isMeasuring: Se, canMeasure: Ce, startMeasurement: we, updateConfig: Te, bodyPresetSelection: Ee, bodyPresetLoading: De, bodyPresetError: Oe } = rr({
|
|
3292
|
+
enabled: i,
|
|
3293
|
+
width: o,
|
|
3294
|
+
height: s,
|
|
3295
|
+
facingMode: c,
|
|
3296
|
+
mockMode: l,
|
|
3297
|
+
modelComplexity: u,
|
|
3298
|
+
numPoses: p,
|
|
3299
|
+
minDetectionConfidence: m,
|
|
3300
|
+
minTrackingConfidence: _,
|
|
3301
|
+
outputSegmentationMasks: v,
|
|
3302
|
+
viewportWidth: y,
|
|
3303
|
+
viewportHeight: b,
|
|
3304
|
+
measurementEnabled: x,
|
|
3305
|
+
autoStartMeasurement: S,
|
|
3306
|
+
measurementConfig: C,
|
|
3307
|
+
bodyPresetOptions: D,
|
|
3308
|
+
fitType: T,
|
|
3309
|
+
garmentScaleHint: E
|
|
3310
|
+
}), [ke, Ae] = a(null), je = t((e) => {
|
|
3311
|
+
I.current = e, Ae(e);
|
|
3312
|
+
}, [I]), Me = r(() => ({
|
|
3313
|
+
videoRef: I,
|
|
3314
|
+
webcamReady: L,
|
|
3315
|
+
webcamError: te,
|
|
3316
|
+
startWebcam: ne,
|
|
3317
|
+
stopWebcam: re,
|
|
3318
|
+
isTrackerReady: ie,
|
|
3319
|
+
landmarks: ae,
|
|
3320
|
+
worldLandmarks: oe,
|
|
3321
|
+
poseRig: R,
|
|
3322
|
+
confidence: z,
|
|
3323
|
+
fps: se,
|
|
3324
|
+
isTracking: ce,
|
|
3325
|
+
drawLandmarks: le,
|
|
3326
|
+
silhouetteWidths: ue,
|
|
3327
|
+
poseFrameWidth: de,
|
|
3328
|
+
poseFrameHeight: fe,
|
|
3329
|
+
detectedPersonCount: pe,
|
|
3330
|
+
lockedPersonId: me,
|
|
3331
|
+
trackingQuality: he,
|
|
3332
|
+
config: ge,
|
|
3333
|
+
measurements: _e,
|
|
3334
|
+
sizeRecommendation: ve,
|
|
3335
|
+
garmentScale: ye,
|
|
3336
|
+
finalGarmentScale: be,
|
|
3337
|
+
bodyMorphResult: xe,
|
|
3338
|
+
isMeasuring: Se,
|
|
3339
|
+
canMeasure: Ce,
|
|
3340
|
+
startMeasurement: we,
|
|
3341
|
+
updateConfig: Te,
|
|
3342
|
+
bodyPresetSelection: Ee,
|
|
3343
|
+
bodyPresetLoading: De,
|
|
3344
|
+
bodyPresetError: Oe
|
|
3345
|
+
}), [
|
|
3346
|
+
I,
|
|
3347
|
+
L,
|
|
3348
|
+
te,
|
|
3349
|
+
ne,
|
|
3350
|
+
re,
|
|
3351
|
+
ie,
|
|
3352
|
+
ae,
|
|
3353
|
+
oe,
|
|
3354
|
+
R,
|
|
3355
|
+
z,
|
|
3356
|
+
se,
|
|
3357
|
+
ce,
|
|
3358
|
+
le,
|
|
3359
|
+
ue,
|
|
3360
|
+
de,
|
|
3361
|
+
fe,
|
|
3362
|
+
pe,
|
|
3363
|
+
me,
|
|
3364
|
+
he,
|
|
3365
|
+
ge,
|
|
3366
|
+
_e,
|
|
3367
|
+
ve,
|
|
3368
|
+
ye,
|
|
3369
|
+
be,
|
|
3370
|
+
xe,
|
|
3371
|
+
Se,
|
|
3372
|
+
Ce,
|
|
3373
|
+
we,
|
|
3374
|
+
Te,
|
|
3375
|
+
Ee,
|
|
3376
|
+
De,
|
|
3377
|
+
Oe
|
|
3378
|
+
]);
|
|
3079
3379
|
return n(() => {
|
|
3080
|
-
|
|
3081
|
-
}, [
|
|
3082
|
-
className:
|
|
3380
|
+
ee?.(Me);
|
|
3381
|
+
}, [ee, Me]), /* @__PURE__ */ g("div", {
|
|
3382
|
+
className: O,
|
|
3083
3383
|
style: {
|
|
3084
3384
|
position: "relative",
|
|
3085
3385
|
width: "100%",
|
|
3086
3386
|
height: "100%",
|
|
3087
3387
|
overflow: "hidden",
|
|
3088
|
-
...
|
|
3388
|
+
...k
|
|
3089
3389
|
},
|
|
3090
3390
|
children: [/* @__PURE__ */ h("video", {
|
|
3091
|
-
ref:
|
|
3391
|
+
ref: je,
|
|
3092
3392
|
autoPlay: !0,
|
|
3093
3393
|
playsInline: !0,
|
|
3094
3394
|
muted: !0,
|
|
3095
3395
|
style: { display: "none" }
|
|
3096
3396
|
}), /* @__PURE__ */ g(w, {
|
|
3097
|
-
showEnvironment:
|
|
3397
|
+
showEnvironment: j,
|
|
3098
3398
|
useDefaultLights: !1,
|
|
3099
3399
|
enableOrbitControls: !1,
|
|
3100
3400
|
children: [
|
|
3101
|
-
/* @__PURE__ */ h(
|
|
3102
|
-
/* @__PURE__ */ h(
|
|
3401
|
+
/* @__PURE__ */ h(es, { onReady: P }),
|
|
3402
|
+
/* @__PURE__ */ h(ts, {}),
|
|
3103
3403
|
/* @__PURE__ */ h(d, {
|
|
3104
3404
|
makeDefault: !0,
|
|
3105
3405
|
position: [
|
|
@@ -3133,44 +3433,44 @@ function Xa({ garmentUrl: e, enabled: t = !0, width: r = 1280, height: i = 720,
|
|
|
3133
3433
|
"#7d8aa6",
|
|
3134
3434
|
.35
|
|
3135
3435
|
] }),
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
webcamReady:
|
|
3436
|
+
N ? /* @__PURE__ */ h($o, {
|
|
3437
|
+
videoElement: ke,
|
|
3438
|
+
webcamReady: L
|
|
3139
3439
|
}) : null,
|
|
3140
|
-
|
|
3440
|
+
i && e ? /* @__PURE__ */ h(Yo, {
|
|
3141
3441
|
url: e,
|
|
3142
|
-
landmarks:
|
|
3143
|
-
worldLandmarks:
|
|
3144
|
-
poseFrameWidth:
|
|
3145
|
-
poseFrameHeight:
|
|
3146
|
-
debugMaterials:
|
|
3147
|
-
onLoadStateChange:
|
|
3442
|
+
landmarks: ae,
|
|
3443
|
+
worldLandmarks: oe,
|
|
3444
|
+
poseFrameWidth: de,
|
|
3445
|
+
poseFrameHeight: fe,
|
|
3446
|
+
debugMaterials: A,
|
|
3447
|
+
onLoadStateChange: F
|
|
3148
3448
|
}) : null,
|
|
3149
|
-
|
|
3449
|
+
M ? /* @__PURE__ */ h(f, {}) : null
|
|
3150
3450
|
]
|
|
3151
3451
|
})]
|
|
3152
3452
|
});
|
|
3153
3453
|
}
|
|
3154
3454
|
//#endregion
|
|
3155
3455
|
//#region src/hooks/useEverGeneration.ts
|
|
3156
|
-
var
|
|
3157
|
-
function
|
|
3456
|
+
var rs = { gender: "female" };
|
|
3457
|
+
function is(e, t) {
|
|
3158
3458
|
return e instanceof Error && e.message ? e.message : t;
|
|
3159
3459
|
}
|
|
3160
|
-
function
|
|
3161
|
-
let n = r(() => new
|
|
3460
|
+
function as(e) {
|
|
3461
|
+
let n = r(() => new be(e), [e]), [i, o] = a("idle"), [s, c] = a(null), [l, u] = a(null);
|
|
3162
3462
|
return {
|
|
3163
3463
|
status: i,
|
|
3164
3464
|
resultUrl: s,
|
|
3165
3465
|
error: l,
|
|
3166
|
-
generateAvatar: t(async (e =
|
|
3466
|
+
generateAvatar: t(async (e = rs) => {
|
|
3167
3467
|
o("processing"), u(null);
|
|
3168
3468
|
try {
|
|
3169
|
-
let t = e instanceof Blob ?
|
|
3469
|
+
let t = e instanceof Blob ? rs : e, r = await n.matchBodyPreset(t);
|
|
3170
3470
|
if (!r.model_url) throw Error("Matched body preset does not have a 3D model URL.");
|
|
3171
3471
|
return c(r.model_url), o("ready"), r.model_url;
|
|
3172
3472
|
} catch (e) {
|
|
3173
|
-
throw u(
|
|
3473
|
+
throw u(is(e, "Failed to load avatar model")), o("error"), e;
|
|
3174
3474
|
}
|
|
3175
3475
|
}, [n]),
|
|
3176
3476
|
createGarment: t(async (e, t, r, i) => {
|
|
@@ -3185,7 +3485,7 @@ function $a(e) {
|
|
|
3185
3485
|
if (!l) throw Error("Backend did not return a garment 3D model URL.");
|
|
3186
3486
|
return c(l), o("ready"), l;
|
|
3187
3487
|
} catch (e) {
|
|
3188
|
-
throw u(
|
|
3488
|
+
throw u(is(e, "Failed to generate garment")), o("error"), e;
|
|
3189
3489
|
}
|
|
3190
3490
|
}, [n]),
|
|
3191
3491
|
reset: () => {
|
|
@@ -3195,25 +3495,43 @@ function $a(e) {
|
|
|
3195
3495
|
}
|
|
3196
3496
|
//#endregion
|
|
3197
3497
|
//#region src/garment/constants.ts
|
|
3198
|
-
var
|
|
3199
|
-
Hips: [
|
|
3498
|
+
var os = {
|
|
3499
|
+
Hips: [B.LEFT_HIP, B.RIGHT_HIP],
|
|
3200
3500
|
Spine: [
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3501
|
+
B.LEFT_SHOULDER,
|
|
3502
|
+
B.RIGHT_SHOULDER,
|
|
3503
|
+
B.LEFT_HIP,
|
|
3504
|
+
B.RIGHT_HIP
|
|
3205
3505
|
],
|
|
3206
|
-
Chest: [
|
|
3207
|
-
LeftShoulder: [
|
|
3208
|
-
LeftUpperArm: [
|
|
3209
|
-
LeftLowerArm: [
|
|
3210
|
-
RightShoulder: [
|
|
3211
|
-
RightUpperArm: [
|
|
3212
|
-
RightLowerArm: [
|
|
3213
|
-
LeftUpperLeg: [
|
|
3214
|
-
LeftLowerLeg: [
|
|
3215
|
-
RightUpperLeg: [
|
|
3216
|
-
RightLowerLeg: [
|
|
3217
|
-
};
|
|
3506
|
+
Chest: [B.LEFT_SHOULDER, B.RIGHT_SHOULDER],
|
|
3507
|
+
LeftShoulder: [B.LEFT_SHOULDER, B.LEFT_ELBOW],
|
|
3508
|
+
LeftUpperArm: [B.LEFT_SHOULDER, B.LEFT_ELBOW],
|
|
3509
|
+
LeftLowerArm: [B.LEFT_ELBOW, B.LEFT_WRIST],
|
|
3510
|
+
RightShoulder: [B.RIGHT_SHOULDER, B.RIGHT_ELBOW],
|
|
3511
|
+
RightUpperArm: [B.RIGHT_SHOULDER, B.RIGHT_ELBOW],
|
|
3512
|
+
RightLowerArm: [B.RIGHT_ELBOW, B.RIGHT_WRIST],
|
|
3513
|
+
LeftUpperLeg: [B.LEFT_HIP, B.LEFT_KNEE],
|
|
3514
|
+
LeftLowerLeg: [B.LEFT_KNEE, B.LEFT_ANKLE],
|
|
3515
|
+
RightUpperLeg: [B.RIGHT_HIP, B.RIGHT_KNEE],
|
|
3516
|
+
RightLowerLeg: [B.RIGHT_KNEE, B.RIGHT_ANKLE]
|
|
3517
|
+
}, ss = 2, cs = .2, ls = 26, us = 18;
|
|
3518
|
+
function ds(e) {
|
|
3519
|
+
return {
|
|
3520
|
+
interval: Math.max(1, e),
|
|
3521
|
+
averageDetectionDurationMs: 0,
|
|
3522
|
+
framesUntilNextDetection: 0
|
|
3523
|
+
};
|
|
3524
|
+
}
|
|
3525
|
+
function fs(e, t) {
|
|
3526
|
+
return !t || e.framesUntilNextDetection <= 0 ? (e.framesUntilNextDetection = Math.max(e.interval - 1, 0), !0) : (--e.framesUntilNextDetection, !1);
|
|
3527
|
+
}
|
|
3528
|
+
function ps(e, t, n, r = 2) {
|
|
3529
|
+
let i = Math.max(1, n), a = Math.max(i, r), o = Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
3530
|
+
if (e.averageDetectionDurationMs = e.averageDetectionDurationMs === 0 ? o : e.averageDetectionDurationMs + (o - e.averageDetectionDurationMs) * cs, e.averageDetectionDurationMs >= ls) {
|
|
3531
|
+
e.interval = a, e.framesUntilNextDetection = Math.min(e.framesUntilNextDetection, Math.max(e.interval - 1, 0));
|
|
3532
|
+
return;
|
|
3533
|
+
}
|
|
3534
|
+
e.averageDetectionDurationMs <= us && (e.interval = i, e.framesUntilNextDetection = Math.min(e.framesUntilNextDetection, Math.max(e.interval - 1, 0)));
|
|
3535
|
+
}
|
|
3218
3536
|
//#endregion
|
|
3219
|
-
export {
|
|
3537
|
+
export { Tr as BONE_MAPPING, os as BONE_VISIBILITY_MAP, _e as DEFAULT_EVER_API_BASE_URL, Ce as DEFAULT_FEMALE_BODY_PRESET_ID, D as DEFAULT_GARMENT_SPEC, gn as DEFAULT_LOCKED_PERSON_ID, Se as DEFAULT_MALE_BODY_PRESET_ID, $e as DEFAULT_MEASUREMENT_CONFIG, vt as DEFAULT_NUM_POSES, Re as DEFAULT_SMOOTHING, w as EverCanvas, be as EverClient, ns as EverFittingScene, Yo as EverTrackedGarment, ea as FacingDetector, yt as INTERPOLATION_ALPHA, B as LANDMARK, we as LEGACY_RIGGED_BODY_PRESET_ID, Sn as LandmarkSmoother, ht as MEDIAPIPE_TASKS_VISION_VERSION, bt as MODEL_ASSET_PATHS, _t as POSE_DETECTION_INTERVAL, ss as POSE_DETECTION_INTERVAL_FALLBACK, Yn as TRACKING_SNAPSHOT_HOLD_MS, qo as TrackedGarmentPoseDriver, gt as WASM_FILES_URL, $o as WebcamPlaneBackground, Li as YawDirectionStabilizer, ra as YawFreezeController, Ti as applyLandmarkPoseToGarment, mo as applyTrackedModelTransform, Di as blendBonesToRest, De as buildBodyPresetAssetUrl, Pe as buildBodyPresetMatchRequest, Pn as calcRectIoU, $t as canSolvePoseTorso, ir as captureBoneBinding, jn as clampNormalizedRect, nn as closeSegmentationMasks, Ue as computeBmiCorrectionFactor, ge as computeBodyFirstFitting, Vt as computeBoneDirectionFromLandmarks, Ut as computeBoneRotationFromLandmarks, rt as computeCoverRect, Ca as computeFacingAwareShoulderWidth, Z as computeFrameRateIndependentBlendFactor, cr as computeGarmentFitProfile, Ea as computeGarmentGroupRoll, Ta as computeGarmentGroupYaw, Da as computeGarmentRootQuaternion, k as computeGarmentScale, Mn as computeLandmarkBoundsNormalized, Bt as computeLandmarkSegmentDirection, He as computeScale, wa as computeStableShoulderWidth, it as computeVisibleNormalizedRegion, mr as configureAvatarLoader, hr as createAvatarLoaderExtension, Me as createFallbackBodyPresetSelection, Zn as createHeldTrackingSnapshot, yr as createHumanoidBoneBindings, Gn as createIdleTrackingQuality, pt as createInitialPoseSnapshot, qn as createInitialTrackingRuntimeState, In as createPoseCandidates, ds as createPoseDetectionCadenceState, xt as createPoseLandmarker, Wo as createTrackedGarmentMotionState, fo as createTrackedModelTransformScratch, Qn as createTrackingLostRuntimeState, Kn as createTrackingQuality, Jn as createTrackingRuntimeState, Xr as createVRMCompat, de as deriveBodyMorphResult, Ae as ensureBodyPresetModelUrl, Nn as expandNormalizedRect, Zi as extractFacingSignals, ct as extractSilhouetteWidths, Bn as filterCandidatesByVisibleRegion, pr as getAvatarAssetKind, Ht as getBoneLandmarkInfluence, Or as getBoneRotation, Oe as getDefaultBodyPresetId, tn as getSegmentationMaskData, Wt as hasLandmarkMapping, qr as inferNumberedHumanoidBoneAliases, lt as interpolateLandmarks, dt as interpolatePoseRig, mt as interpolatePoseSnapshot, ft as interpolateSilhouetteWidths, zn as isCandidateInVisibleRegion, Kr as isLikelyNumberedHumanoidSkeleton, Qi as isRawFrontFacing, fr as isVRMAssetUrl, oa as landmarkDistance, Q as landmarkToThreePosition, G as lerpRotation, U as lerpValue, Xe as measureBody, aa as midpointToThree, Ee as normalizeBodyPresetGender, Dr as normalizeBoneName, vn as normalizeLandmark, yn as normalizeLandmarks, je as pickDefaultBodyPreset, gr as prepareAvatarScene, _r as prepareNativeVRM, Qe as recommendSize, lr as resetBoneRotations, Ei as resetPoseState, Go as resetTrackedGarmentMotionState, hn as resolvePoseTrackingConfidence, ji as resolveSmoothingDeltaSeconds, rn as scaleSilhouetteWidths, Rn as selectLockedPoseCandidate, Xn as shouldHoldTrackingSnapshot, fs as shouldRunPoseDetection, wn as smoothPoseRig, en as solvePose, Ne as toBodyPresetSelection, ke as toBodyPresetSummary, Vn as toLockedPoseCandidate, ps as updatePoseDetectionCadence, Ko as updateTrackedGarmentMotion, po as updateTrackedModelTransform, Qr as useAvatarVariant, Le as useBodyPresetSelection, rr as useEverFitting, as as useEverGeneration, nt as useMeasurement, wi as usePoseApplicationRefs, er as usePoseTracker, nr as useWebcam };
|