@algorisys/tinyfly 0.109.0 → 0.110.0
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 +6 -6
- package/docs/character-appearance.md +5 -2
- package/docs/cricket.md +58 -4
- package/docs/editor-guide.md +1 -1
- package/docs/examples.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +22 -1
- package/docs/maps.md +2 -2
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +1175 -1173
- package/lib/addons/{cricket-camera-BWByoNgz.js → cricket-camera-tMg3Ag3F.js} +624 -608
- package/lib/addons/sports.js +328 -273
- package/lib/browser/tinyfly.iife.js +12 -12
- package/lib/browser/tinyfly.js +5199 -5128
- package/lib/browser/tinyfly.umd.js +12 -12
- package/lib/types/characters/capabilities.d.ts +3 -1
- package/lib/types/sports/cricket/cricket-camera.d.ts +2 -0
- package/lib/types/sports/cricket/cricket-motion.d.ts +7 -0
- package/lib/types/sports/cricket/cricket-types.d.ts +15 -1
- package/lib/types/sports/cricket/index.d.ts +1 -1
- package/llms-full.txt +96 -16
- package/llms.txt +30 -30
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +22 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRandom as
|
|
1
|
+
import { createRandom as ws, hashSeed as Mo, unknownName as Ms, TrackPlayer as Pn } from "@algorisys/tinyfly";
|
|
2
2
|
import { c as ks, s as An } from "./sketch-CYPUbk3Q.js";
|
|
3
3
|
import { c as vs, b as Es } from "./shots-DR_ViiAC.js";
|
|
4
4
|
const ht = (t) => ({ description: t, unit: "degrees" }), st = (t, e = 0, n = 1) => ({ description: t, unit: `${e}..${n}`, min: e, max: n }), Ss = {
|
|
@@ -102,7 +102,7 @@ function tn(t, e, n, s, o, r = 0, i = 1, a = 40) {
|
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
function pn(t, e) {
|
|
105
|
-
return e.look === "pencil" ?
|
|
105
|
+
return e.look === "pencil" ? Ws(t, e) : vo(t, e.ink, e.look);
|
|
106
106
|
}
|
|
107
107
|
function Oe(t, e, n = !1) {
|
|
108
108
|
t.beginPath(), t.moveTo(e[0].x, e[0].y);
|
|
@@ -153,7 +153,7 @@ function Is(t, e) {
|
|
|
153
153
|
const o = t[t.length - 1], r = n[n.length - 1];
|
|
154
154
|
return Math.hypot(o.x - r.x, o.y - r.y) > e * 0.25 ? n.push(o) : n[n.length - 1] = o, n;
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function Ts(t, e) {
|
|
157
157
|
const n = t.length;
|
|
158
158
|
return t.map((s, o) => {
|
|
159
159
|
const r = t[Math.max(0, o - 1)], i = t[Math.min(n - 1, o + 1)], a = Math.hypot(i.x - r.x, i.y - r.y) || 1, l = e(n === 1 ? 0 : o / (n - 1));
|
|
@@ -168,20 +168,20 @@ function On(t) {
|
|
|
168
168
|
})), n = e.reduce((s, o) => s + o.amount, 0);
|
|
169
169
|
return (s) => e.reduce((o, r) => o + r.amount * Math.sin(Math.PI * 2 * r.frequency * s + r.phase), 0) / n;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function Ws(t, e) {
|
|
172
172
|
const n = e.pencil ?? {}, s = e.ink, o = n.roughness ?? Math.max(1, e.lineWidth * 0.12), r = Math.max(1, Math.round(n.passes ?? 2)), i = Math.min(1, Math.max(0, n.pressure ?? 0.25)), a = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), l = ks(e.time, n.boil ?? 8);
|
|
173
173
|
let c = 0;
|
|
174
|
-
const h = (g, m, d = !1) =>
|
|
174
|
+
const h = (g, m, d = !1) => ws(Mo(`${e.seed}:${d ? "paper" : l}:${g}:${m}`)), f = (g, m, d, x, w, M = 0) => {
|
|
175
175
|
if (g.length < 2) return;
|
|
176
|
-
const v = g.slice(1).reduce((
|
|
176
|
+
const v = g.slice(1).reduce((B, b, E) => B + Math.hypot(b.x - g[E].x, b.y - g[E].y), 0);
|
|
177
177
|
let P = Is(g, Math.max(1.5, Math.min(e.lineWidth * 0.8, v / 24)));
|
|
178
|
-
if (
|
|
179
|
-
const [
|
|
180
|
-
P = [...P, { x:
|
|
178
|
+
if (M > 0 && P.length >= 2) {
|
|
179
|
+
const [B, b] = [P[P.length - 2], P[P.length - 1]], E = Math.hypot(b.x - B.x, b.y - B.y) || 1;
|
|
180
|
+
P = [...P, { x: b.x + (b.x - B.x) / E * M, y: b.y + (b.y - B.y) / E * M }];
|
|
181
181
|
}
|
|
182
182
|
const R = On(d), O = On(d), $ = P.length, A = [], z = [];
|
|
183
|
-
P.forEach((
|
|
184
|
-
const E = $ === 1 ? 0 :
|
|
183
|
+
P.forEach((B, b) => {
|
|
184
|
+
const E = $ === 1 ? 0 : b / ($ - 1), H = P[Math.max(0, b - 1)], N = P[Math.min($ - 1, b + 1)], D = Math.hypot(N.x - H.x, N.y - H.y) || 1, X = -(N.y - H.y) / D, K = (N.x - H.x) / D, q = R(E) * w, J = Math.min(1, E / 0.08, (1 - E) / 0.08), j = (0.55 + 0.45 * Math.sqrt(Math.max(0, J))) * (1 + i * O(E)), Q = Math.max(0.3, m(E) * j / 2), nt = B.x + X * q, lt = B.y + K * q;
|
|
185
185
|
A.push({ x: nt + X * Q, y: lt + K * Q }), z.push({ x: nt - X * Q, y: lt - K * Q });
|
|
186
186
|
}), t.save(), t.globalAlpha *= x, t.fillStyle = s, Oe(t, [...A, ...z.reverse()], !0), t.fill(), t.restore();
|
|
187
187
|
}, y = (g, m) => {
|
|
@@ -190,17 +190,17 @@ function Ts(t, e) {
|
|
|
190
190
|
const P = (x.next() * 2 - 1) * e.lineWidth * 1.4, R = (x.next() * 2 - 1) * e.lineWidth * 1.4, O = g.map(($) => ({ x: $.x + P, y: $.y + R }));
|
|
191
191
|
f(O, ($) => m($) * 1.8, h(d, 98, !0), 0.035, o), f(O, ($) => m($) * 0.45, h(d, 97, !0), 0.12, o * 1.5);
|
|
192
192
|
}
|
|
193
|
-
const
|
|
193
|
+
const w = g.slice(1).reduce((P, R, O) => P + Math.hypot(R.x - g[O].x, R.y - g[O].y), 0), M = m(0.5) > 4 && w > m(0.5) * 6, v = M ? [-0.3, 0.3, 0] : [0];
|
|
194
194
|
for (let P = 0; P < r; P++) {
|
|
195
195
|
const R = P === 0;
|
|
196
196
|
v.forEach((O, $) => {
|
|
197
|
-
const A = h(d, P * 10 + $), z = O === 0 ? g :
|
|
198
|
-
f(z, (
|
|
197
|
+
const A = h(d, P * 10 + $), z = O === 0 ? g : Ts(g, (b) => m(b) * O * Math.sqrt(Math.sin(Math.PI * b))), B = !R && O === 0 ? e.lineWidth * (0.3 + A.next() * 0.8) : 0;
|
|
198
|
+
f(z, (b) => m(b) * (M ? 0.5 : 1) * (R ? 1 : 0.6), A, R ? 0.85 : 0.45, o * (R ? 0.6 : 1), B);
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
}, u = (g, m, d, x,
|
|
201
|
+
}, u = (g, m, d, x, w, M) => {
|
|
202
202
|
const P = h(c, 50).next() * Math.PI * 2;
|
|
203
|
-
y(tn(g, m, d, x,
|
|
203
|
+
y(tn(g, m, d, x, w, P, 1.08, 48), () => M);
|
|
204
204
|
};
|
|
205
205
|
return {
|
|
206
206
|
look: "pencil",
|
|
@@ -214,8 +214,8 @@ function Ts(t, e) {
|
|
|
214
214
|
shape(g, m, d) {
|
|
215
215
|
m !== null && (t.save(), t.globalAlpha *= 0.88, t.fillStyle = m, Oe(t, g, !0), t.fill(), t.restore()), d > 0 && y([...g, g[0]], () => d);
|
|
216
216
|
},
|
|
217
|
-
ellipse(g, m, d, x,
|
|
218
|
-
|
|
217
|
+
ellipse(g, m, d, x, w, M, v) {
|
|
218
|
+
M !== null && (t.save(), t.globalAlpha *= 0.9, t.fillStyle = M, t.beginPath(), t.ellipse(g, m, d, x, w, 0, Math.PI * 2), t.fill(), t.restore()), u(g, m, d, x, w, v);
|
|
219
219
|
},
|
|
220
220
|
dot(g, m, d) {
|
|
221
221
|
t.save(), t.globalAlpha *= 0.9, t.fillStyle = s, t.beginPath(), t.arc(g, m, d, 0, Math.PI * 2), t.fill(), t.restore();
|
|
@@ -225,9 +225,9 @@ function Ts(t, e) {
|
|
|
225
225
|
const m = c++;
|
|
226
226
|
f(g, () => Math.max(0.6, e.lineWidth * 0.18), h(m, 0), 0.28, o * 1.2, e.lineWidth);
|
|
227
227
|
},
|
|
228
|
-
guideEllipse(g, m, d, x,
|
|
228
|
+
guideEllipse(g, m, d, x, w) {
|
|
229
229
|
if (n.construction === !1) return;
|
|
230
|
-
const
|
|
230
|
+
const M = c++, v = h(M, 0), P = tn(g, m, d, x, w, v.next() * Math.PI * 2, 1.12, 48);
|
|
231
231
|
f(P, () => Math.max(0.6, e.lineWidth * 0.18), v, 0.28, o * 1.5);
|
|
232
232
|
}
|
|
233
233
|
};
|
|
@@ -245,10 +245,10 @@ const Hs = ["thumb", "index", "middle", "ring", "pinky"], Ot = {
|
|
|
245
245
|
tilt: 0,
|
|
246
246
|
roll: 0
|
|
247
247
|
};
|
|
248
|
-
function
|
|
248
|
+
function bt(t = {}) {
|
|
249
249
|
return { ...Ot, ...t };
|
|
250
250
|
}
|
|
251
|
-
const
|
|
251
|
+
const wt = (t, e, n, s, o) => ({
|
|
252
252
|
"thumb.curl": t,
|
|
253
253
|
"index.curl": e,
|
|
254
254
|
"middle.curl": n,
|
|
@@ -256,22 +256,22 @@ const bt = (t, e, n, s, o) => ({
|
|
|
256
256
|
"pinky.curl": o
|
|
257
257
|
}), La = {
|
|
258
258
|
relaxed: Ot,
|
|
259
|
-
open:
|
|
260
|
-
spread:
|
|
261
|
-
flat:
|
|
262
|
-
fist:
|
|
263
|
-
point:
|
|
259
|
+
open: bt({ ...wt(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
|
|
260
|
+
spread: bt({ ...wt(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
|
|
261
|
+
flat: bt({ ...wt(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
|
|
262
|
+
fist: bt({ ...wt(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
|
|
263
|
+
point: bt({ ...wt(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
|
|
264
264
|
/** The fist on its side, knuckles toward the viewer, the thumb up */
|
|
265
|
-
thumbsUp:
|
|
266
|
-
peace:
|
|
267
|
-
ok:
|
|
268
|
-
pinch:
|
|
269
|
-
cupped:
|
|
270
|
-
wave:
|
|
265
|
+
thumbsUp: bt({ ...wt(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
|
|
266
|
+
peace: bt({ ...wt(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
|
|
267
|
+
ok: bt({ ...wt(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
|
|
268
|
+
pinch: bt({ ...wt(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
|
|
269
|
+
cupped: bt({ ...wt(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
|
|
270
|
+
wave: bt({ ...wt(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
|
|
271
271
|
/** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
|
|
272
|
-
pencilGrip:
|
|
272
|
+
pencilGrip: bt({ ...wt(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
|
|
273
273
|
/** Holding a handle, a cup or a bar: every finger wrapped round it */
|
|
274
|
-
hold:
|
|
274
|
+
hold: bt({ ...wt(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
|
|
275
275
|
};
|
|
276
276
|
function $s(t, e, n) {
|
|
277
277
|
const s = { ...t };
|
|
@@ -290,14 +290,14 @@ const _s = {
|
|
|
290
290
|
index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
|
|
291
291
|
middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
|
|
292
292
|
pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
|
|
293
|
-
},
|
|
293
|
+
}, Wt = {
|
|
294
294
|
base: [-0.11, 0.1, -0.05],
|
|
295
295
|
bones: [0.2, 0.15, 0.12],
|
|
296
296
|
widths: [0.2, 0.145, 0.135],
|
|
297
297
|
/** Where the thumb points with `across` 0 and 1 */
|
|
298
298
|
out: [-0.7, 0.68, -0.22],
|
|
299
299
|
across: [0.35, 0.5, -0.8]
|
|
300
|
-
},
|
|
300
|
+
}, Cs = [82, 100, 62], Rs = [48, 72], Bs = 3, Fs = 13, Ns = 0.035, Ys = -0.075, zs = [
|
|
301
301
|
[-0.17, 0],
|
|
302
302
|
[-0.215, 0.12],
|
|
303
303
|
[-0.235, 0.26],
|
|
@@ -322,47 +322,47 @@ function Dt(t, e, n) {
|
|
|
322
322
|
t[2] * s + r[2] * o + e[2] * i * (1 - s)
|
|
323
323
|
];
|
|
324
324
|
}
|
|
325
|
-
const In = [1, 0, 0],
|
|
325
|
+
const In = [1, 0, 0], Tn = [0, 1, 0], ae = [0, 0, 1];
|
|
326
326
|
function Ds(t, e, n) {
|
|
327
|
-
const s = Rt(t.fan * (
|
|
327
|
+
const s = Rt(t.fan * (Bs + Fs * n)), o = [Math.sin(s), Math.cos(s), 0], r = [Math.cos(s), -Math.sin(s), 0], i = [t.knuckle];
|
|
328
328
|
let a = 0;
|
|
329
329
|
t.bones.forEach((h, f) => {
|
|
330
|
-
a += Rt(
|
|
330
|
+
a += Rt(Cs[f] * e), i.push(en(i[f], Se(Dt(o, r, -a), h)));
|
|
331
331
|
});
|
|
332
332
|
const l = Dt(ae, r, -a), c = i.map((h, f) => t.width * (1 - 0.14 * (f / (i.length - 1))));
|
|
333
333
|
return { joints: i, back: l, widths: c };
|
|
334
334
|
}
|
|
335
335
|
function qs(t, e, n = 1, s = 1) {
|
|
336
|
-
const o = Math.min(1, Math.max(0, e)), r = re(en(Se(re(
|
|
336
|
+
const o = Math.min(1, Math.max(0, e)), r = re(en(Se(re(Wt.out), 1 - o), Se(re(Wt.across), o))), i = re(nn(ae, r)), a = re(nn(r, i)), l = [[Wt.base[0] * s, Wt.base[1], Wt.base[2]]];
|
|
337
337
|
let c = 0;
|
|
338
|
-
|
|
338
|
+
Wt.bones.forEach((y, u) => {
|
|
339
339
|
u > 0 && (c += Rt(Rs[u - 1] * t)), l.push(en(l[u], Se(Dt(r, i, c), y)));
|
|
340
340
|
});
|
|
341
|
-
const h = Dt(a, i, c), f = [...
|
|
341
|
+
const h = Dt(a, i, c), f = [...Wt.widths, Wt.widths[Wt.widths.length - 1] * 0.92].map((y) => y * n);
|
|
342
342
|
return { joints: l, back: h, widths: f };
|
|
343
343
|
}
|
|
344
344
|
function Us(t, e = {}) {
|
|
345
|
-
const n = { ...Ot, ...t }, s = e.size ?? 100, o = e.side ?? "right", r = o === "left" ? -1 : 1, i = Rt(e.angle ?? 0), a = e.fingers === 4, l = Math.max(0.5, e.plump ?? 1), c = 1 + (l - 1) * 0.7, h = (
|
|
346
|
-
...
|
|
347
|
-
knuckle: [
|
|
348
|
-
width:
|
|
349
|
-
}), f = Rt(n.bend ?? 0), y = Rt(n.tilt ?? 0), u = Rt(90 * (n.turn ?? 0)), g = (
|
|
350
|
-
const E =
|
|
345
|
+
const n = { ...Ot, ...t }, s = e.size ?? 100, o = e.side ?? "right", r = o === "left" ? -1 : 1, i = Rt(e.angle ?? 0), a = e.fingers === 4, l = Math.max(0.5, e.plump ?? 1), c = 1 + (l - 1) * 0.7, h = (b) => ({
|
|
346
|
+
...b,
|
|
347
|
+
knuckle: [b.knuckle[0] * c, b.knuckle[1], b.knuckle[2]],
|
|
348
|
+
width: b.width * l
|
|
349
|
+
}), f = Rt(n.bend ?? 0), y = Rt(n.tilt ?? 0), u = Rt(90 * (n.turn ?? 0)), g = (b) => Dt(Dt(Dt(b, In, -f), ae, -y), Tn, u), m = Math.cos(i), d = Math.sin(i), x = Rt(n.roll ?? 0), w = Math.cos(x), M = Math.sin(x), v = (b) => {
|
|
350
|
+
const E = b[0] * s, H = -b[1] * s, N = (E * w - H * M) * r, D = E * M + H * w;
|
|
351
351
|
return { x: N * m - D * d, y: N * d + D * m };
|
|
352
|
-
}, P = (
|
|
353
|
-
const E = v(
|
|
352
|
+
}, P = (b) => {
|
|
353
|
+
const E = v(b), H = Math.hypot(E.x, E.y);
|
|
354
354
|
return H > 1e-6 * s ? { x: E.x / H, y: E.y / H } : { x: 0, y: 0 };
|
|
355
355
|
}, R = {
|
|
356
356
|
thumb: qs(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, l, c)
|
|
357
357
|
}, O = a ? Ls : _s;
|
|
358
|
-
for (const
|
|
359
|
-
const E = O[
|
|
360
|
-
E && (R[
|
|
358
|
+
for (const b of Hs) {
|
|
359
|
+
const E = O[b];
|
|
360
|
+
E && (R[b] = Ds(h(E), n[`${b}.curl`] ?? 0, n.spread ?? 0));
|
|
361
361
|
}
|
|
362
362
|
const $ = {};
|
|
363
|
-
for (const [
|
|
363
|
+
for (const [b, E] of Object.entries(R)) {
|
|
364
364
|
const H = E.joints.map(g), N = g(E.back);
|
|
365
|
-
$[
|
|
365
|
+
$[b] = {
|
|
366
366
|
points: H.map(v),
|
|
367
367
|
depths: H.map((D) => D[2] * s),
|
|
368
368
|
widths: E.widths.map((D) => D * s),
|
|
@@ -370,17 +370,17 @@ function Us(t, e = {}) {
|
|
|
370
370
|
back: P(N)
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
|
-
const A = zs.flatMap(([
|
|
373
|
+
const A = zs.flatMap(([b, E]) => [g([b * c, E, Ns]), g([b * c, E, Ys])]), z = Gs(A.map(v)), B = A.reduce((b, E) => b + E[2], 0) / A.length * s;
|
|
374
374
|
return {
|
|
375
375
|
size: s,
|
|
376
376
|
side: o,
|
|
377
377
|
wrist: { x: 0, y: 0 },
|
|
378
378
|
palm: z,
|
|
379
|
-
palmDepth:
|
|
379
|
+
palmDepth: B,
|
|
380
380
|
palmFacing: -g(ae)[2],
|
|
381
381
|
fingers: $,
|
|
382
|
-
axes: { up: P(g(
|
|
383
|
-
curls: Object.fromEntries(Object.keys($).map((
|
|
382
|
+
axes: { up: P(g(Tn)), across: P(g(In)), out: P(g(ae)) },
|
|
383
|
+
curls: Object.fromEntries(Object.keys($).map((b) => [b, n[`${b}.curl`] ?? 0]))
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
386
|
function Xs(t, e) {
|
|
@@ -492,11 +492,11 @@ function Zs(t, e, n, s, o, r) {
|
|
|
492
492
|
t.moveTo(l.x + m, l.y), t.arc(l.x, l.y, m, 0, Math.PI * 2), t.clip("evenodd");
|
|
493
493
|
}
|
|
494
494
|
if (s === "none") {
|
|
495
|
-
const m = ut(a, h, f), d = a[a.length - 2], x = Math.atan2(c.y - d.y, c.x - d.x),
|
|
495
|
+
const m = ut(a, h, f), d = a[a.length - 2], x = Math.atan2(c.y - d.y, c.x - d.x), w = Array.from({ length: 13 }, (M, v) => {
|
|
496
496
|
const P = x + Math.PI / 2 - v * Math.PI / 12;
|
|
497
497
|
return { x: c.x + Math.cos(P) * f / 2, y: c.y + Math.sin(P) * f / 2 };
|
|
498
498
|
});
|
|
499
|
-
e.shape([...m.slice(0, a.length), ...
|
|
499
|
+
e.shape([...m.slice(0, a.length), ...w.slice(1), ...m.slice(a.length)], null, o);
|
|
500
500
|
} else e.limb(a, h + 2 * o, f + 2 * o);
|
|
501
501
|
if (t.restore(), s !== "none" && e.look !== "silhouette" && (t.fillStyle = s, mn(t, a, h, f)), s === "none" || e.look === "silhouette" || !r || n.nail < 0.25) return;
|
|
502
502
|
const y = a[a.length - 2], u = js({ x: c.x - y.x, y: c.y - y.y }) ?? {
|
|
@@ -534,13 +534,13 @@ const js = (t) => {
|
|
|
534
534
|
run: { swing: 40, knee: 95, arm: 45, elbow: 0, forearm: 90, lean: 16, bend: 6, bounce: 0.05, squash: 0.06 },
|
|
535
535
|
shove: { swing: 18, knee: 28, arm: 0, elbow: 0, lean: 0 }
|
|
536
536
|
}, tr = 40;
|
|
537
|
-
function
|
|
537
|
+
function Ce(t) {
|
|
538
538
|
return t === void 0 ? le.walk : typeof t == "string" ? le[t] ?? le.walk : t;
|
|
539
539
|
}
|
|
540
540
|
function er(t, e, n = Gt, s = 1) {
|
|
541
|
-
const o =
|
|
541
|
+
const o = Ce(t);
|
|
542
542
|
if (o === le.walk) return rr(e, n, s);
|
|
543
|
-
const r = e * Math.PI * 2, i = Math.sin(r) * s, a = Math.cos(r) * s, l = (x) => Math.abs(x) <= tr, c = o.shoulder ?? 0, h = (x,
|
|
543
|
+
const r = e * Math.PI * 2, i = Math.sin(r) * s, a = Math.cos(r) * s, l = (x) => Math.abs(x) <= tr, c = o.shoulder ?? 0, h = (x, w) => l(x) ? w * c + o.arm * i : x, f = o.forearm ?? 0, y = l(n.leftShoulder) ? n.leftElbow - f - o.elbow * Math.max(0, -i) : n.leftElbow, u = l(n.rightShoulder) ? n.rightElbow + f + o.elbow * Math.max(0, i) : n.rightElbow, g = o.bounces ?? 1, m = (1 + Math.cos(r * 2 * g)) / 2, d = o.crouch ?? 0;
|
|
544
544
|
return {
|
|
545
545
|
...n,
|
|
546
546
|
lean: n.lean + o.lean * s + (o.sway ?? 0) * Math.sin(r) * (1 - (n.turn ?? 0)),
|
|
@@ -563,8 +563,8 @@ function er(t, e, n = Gt, s = 1) {
|
|
|
563
563
|
stretch: n.stretch * (1 + (o.squash ?? 0) * (m - 0.5))
|
|
564
564
|
};
|
|
565
565
|
}
|
|
566
|
-
function
|
|
567
|
-
const s =
|
|
566
|
+
function Ca(t, e, n = 1) {
|
|
567
|
+
const s = Ce(t), o = le.walk.swing, r = (i) => Math.sin(i * Math.PI / 180);
|
|
568
568
|
return ir(e, n) * r(s.swing * n) / r(o * n);
|
|
569
569
|
}
|
|
570
570
|
const Gt = {
|
|
@@ -666,7 +666,7 @@ const or = {
|
|
|
666
666
|
// Front split, in profile: the left leg forward (+x), the right leg back.
|
|
667
667
|
frontSplit: ft({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...kt.happy })
|
|
668
668
|
}, Ao = Object.keys(Gt);
|
|
669
|
-
function
|
|
669
|
+
function Wn(t, e, n) {
|
|
670
670
|
const s = { ...t };
|
|
671
671
|
for (const o of Ao) s[o] = t[o] + (e[o] - t[o]) * n;
|
|
672
672
|
return s;
|
|
@@ -700,33 +700,33 @@ function ar(t) {
|
|
|
700
700
|
const e = Math.abs(Math.sin(t / 65)), n = 0.55 + 0.45 * Math.sin(t / 310);
|
|
701
701
|
return e * n;
|
|
702
702
|
}
|
|
703
|
-
const Oo = 0.12, _n = 0.46, lr = 1 - 2 * Oo, hr = 0.1, cr = 0.21, fr = 0.19, sn = 0.24, Ie = 0.22, Io = 0.12, ur = 0.14,
|
|
703
|
+
const Oo = 0.12, _n = 0.46, lr = 1 - 2 * Oo, hr = 0.1, cr = 0.21, fr = 0.19, sn = 0.24, Ie = 0.22, Io = 0.12, ur = 0.14, To = 0.33, Ln = 0.7, Cn = 0.3, dr = 0.35, gr = [1.7, 1.05], yr = [1.3, 0.75], Rn = [1.45, 0.85], mr = [1.15, 0.75], Bn = 0.06, pr = 0.7, xr = 0.65, Wo = 0.075, br = 0.3, wr = 0.02, Mr = 0.012, kr = 12, vr = 0.25, xe = 90, Er = 0.25, Sr = 0.04, Ho = 0.01, zt = (t) => Math.min(1, Math.max(0, t ?? 0));
|
|
704
704
|
function Ra(t, e = 1) {
|
|
705
705
|
return Ie * t * e;
|
|
706
706
|
}
|
|
707
707
|
const rn = -0.12, $o = 0.4, St = (t) => t * Math.PI / 180, Pr = (t, e) => ({ x: e * Math.sin(St(t)), y: Math.cos(St(t)) }), _o = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), Lo = (t, e, n, s) => t - 0.3 * e - n * 0.14 * e - Math.max(0, s - 1) * 0.12 * e;
|
|
708
708
|
function Ar(t, e, n, s, o, r) {
|
|
709
|
-
const i = Math.max(1, Math.min(r * 0.6, ur * n)), a = zt(e.turn), l = (Io +
|
|
709
|
+
const i = Math.max(1, Math.min(r * 0.6, ur * n)), a = zt(e.turn), l = (Io + To * a) * n, c = s + rn * n, h = l + e.lookX * 0.08 * n, f = e.lookY * 0.07 * n, y = [
|
|
710
710
|
// The left eye is on the far side; turning closes it up more than the near one.
|
|
711
711
|
{ x: -0.34 * n * (1 - Ln * a), squeeze: 1 - Ln * a, open: e.leftEye, brow: e.leftBrow, side: -1 },
|
|
712
|
-
{ x: 0.34 * n * (1 -
|
|
712
|
+
{ x: 0.34 * n * (1 - Cn * a), squeeze: 1 - Cn * a, open: e.rightEye, brow: e.rightBrow, side: 1 }
|
|
713
713
|
];
|
|
714
714
|
t.fillStyle = o, t.strokeStyle = o, t.lineWidth = i;
|
|
715
715
|
for (const x of y) {
|
|
716
|
-
const
|
|
717
|
-
if (
|
|
716
|
+
const w = _o(x.open, e.blink);
|
|
717
|
+
if (w < 0.2) {
|
|
718
718
|
const R = e.smile > 0.5 ? -0.12 * n : 0.06 * n;
|
|
719
719
|
t.beginPath(), t.moveTo(x.x + l - 0.12 * n, c), t.quadraticCurveTo(x.x + l, c + R, x.x + l + 0.12 * n, c), t.stroke();
|
|
720
720
|
} else {
|
|
721
|
-
if (
|
|
722
|
-
const O = 0.13 * n *
|
|
721
|
+
if (w > 1.2) {
|
|
722
|
+
const O = 0.13 * n * w;
|
|
723
723
|
t.beginPath(), t.ellipse(x.x + l, c, O * 0.85, O, 0, 0, Math.PI * 2), t.fillStyle = "#ffffff", t.fill(), t.stroke(), t.fillStyle = o;
|
|
724
724
|
}
|
|
725
|
-
const R =
|
|
726
|
-
t.beginPath(), t.ellipse(x.x + h, c + f, R, R * 1.1 * Math.min(
|
|
725
|
+
const R = w > 1.2 ? 0.075 * n : 0.1 * n;
|
|
726
|
+
t.beginPath(), t.ellipse(x.x + h, c + f, R, R * 1.1 * Math.min(w, 1), 0, 0, Math.PI * 2), t.fill();
|
|
727
727
|
}
|
|
728
|
-
const
|
|
729
|
-
t.beginPath(), t.moveTo(P,
|
|
728
|
+
const M = Lo(c, n, x.brow, w), v = x.x + l - x.side * 0.13 * n * x.squeeze, P = x.x + l + x.side * 0.13 * n * x.squeeze;
|
|
729
|
+
t.beginPath(), t.moveTo(P, M), t.lineTo(v, M - e.browTilt * 0.1 * n), t.stroke();
|
|
730
730
|
}
|
|
731
731
|
const u = s + $o * n, g = 0.25 * n * Math.max(0.3, e.mouthWidth) * (1 - dr * a), m = Math.min(1, Math.max(0, e.mouth));
|
|
732
732
|
if (t.beginPath(), m <= 0.05) {
|
|
@@ -736,22 +736,22 @@ function Ar(t, e, n, s, o, r) {
|
|
|
736
736
|
const d = 0.3 * n * m;
|
|
737
737
|
e.smile > 0.3 ? (t.moveTo(l - g, u - 0.05 * n), t.lineTo(l + g, u - 0.05 * n), t.quadraticCurveTo(l, u + d * 2, l - g, u - 0.05 * n)) : e.smile < -0.3 ? (t.moveTo(l - g, u + d * 0.6), t.lineTo(l + g, u + d * 0.6), t.quadraticCurveTo(l, u - d * 1.4, l - g, u + d * 0.6)) : t.ellipse(l, u, g * 0.8, d, 0, 0, Math.PI * 2), t.fill();
|
|
738
738
|
}
|
|
739
|
-
function
|
|
739
|
+
function Co(t, e) {
|
|
740
740
|
const n = e.height ?? 300, s = Math.min(3, Math.max(0.3, t.stretch ?? 1)), o = Math.sqrt(s), r = e.armLength ?? 1;
|
|
741
741
|
if (!Number.isFinite(r) || r <= 0) throw new Error("stick figure: armLength must be a positive finite multiplier");
|
|
742
742
|
const i = (e.headSize ?? 2 * Oo) / 2, a = e.headSize === void 0 ? lr : 1 - 2 * i, l = i * n, c = zt(t.sit), h = t.leftHip + (-xe - t.leftHip) * c, f = t.leftKnee + (-xe - t.leftKnee) * c, y = t.rightHip + (xe - t.rightHip) * c, u = t.rightKnee + (xe - t.rightKnee) * c, g = e.classic === !0, m = zt(t.turn), d = (q, J, j, Q, nt) => {
|
|
743
743
|
const lt = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(St(J - j) / 2) + St(Q))), xt = Math.max(-1, Math.min(1, pr + nt)), p = m + (1 - m) * q * xt;
|
|
744
|
-
return g ? { x: 0, y: 0 } : { x: Math.cos(lt) *
|
|
745
|
-
}, x = { left: t.leftAnkle ?? 0, right: t.rightAnkle ?? 0 },
|
|
746
|
-
let
|
|
744
|
+
return g ? { x: 0, y: 0 } : { x: Math.cos(lt) * Bn * p, y: Math.sin(lt) * Bn };
|
|
745
|
+
}, x = { left: t.leftAnkle ?? 0, right: t.rightAnkle ?? 0 }, w = { left: t.leftFootOut ?? 0, right: t.rightFootOut ?? 0 };
|
|
746
|
+
let M = 0;
|
|
747
747
|
if (c > 0 || !g) {
|
|
748
|
-
const q = (nt, lt, xt, p,
|
|
749
|
-
q(-1, h, f, x.left,
|
|
750
|
-
q(1, y, u, x.right,
|
|
748
|
+
const q = (nt, lt, xt, p, k) => sn * Math.cos(St(lt)) + Ie * Math.cos(St(lt - xt)) + Math.max(0, d(nt, lt, xt, p, k).y), J = Math.max(
|
|
749
|
+
q(-1, h, f, x.left, w.left),
|
|
750
|
+
q(1, y, u, x.right, w.right)
|
|
751
751
|
), j = 1 - zt((t.rise ?? 0) / Sr), Q = (g ? Math.min(1, c / Er) : 1) * j;
|
|
752
|
-
|
|
752
|
+
M = (_n - J) * Q * n * s;
|
|
753
753
|
}
|
|
754
|
-
const v = -_n * n * s +
|
|
754
|
+
const v = -_n * n * s + M, P = -a * n * s + M, R = g ? 0 : (wr * zt(t.turn) + Mr * c) * n * s, O = St(t.bend ?? 0), $ = { end: Nn(v, P, O, 1), bend: O };
|
|
755
755
|
let A;
|
|
756
756
|
if (O !== 0) {
|
|
757
757
|
A = [];
|
|
@@ -761,19 +761,19 @@ function Bo(t, e) {
|
|
|
761
761
|
}
|
|
762
762
|
} else
|
|
763
763
|
A = R === 0 ? [{ x: 0, y: v }, { x: 0, y: P }] : ne({ x: 0, y: v }, { x: -R, y: (v + P) / 2 }, { x: 0, y: P }, 1, 8);
|
|
764
|
-
const z = P + hr * n * s,
|
|
764
|
+
const z = P + hr * n * s, B = (e.shoulderWidth ?? 0) * n * Math.cos(m * Math.PI / 2), b = (q, J, j, Q, nt) => {
|
|
765
765
|
const lt = Pr(j, Q);
|
|
766
766
|
return { x: q + lt.x * nt * n, y: J + lt.y * nt * n };
|
|
767
767
|
}, E = (q, J, j) => {
|
|
768
|
-
const Q =
|
|
769
|
-
return { root: { x: 0, y: v }, joint: Q, end:
|
|
768
|
+
const Q = b(0, v, J, q, sn * s);
|
|
769
|
+
return { root: { x: 0, y: v }, joint: Q, end: b(Q.x, Q.y, J - j, q, Ie * s) };
|
|
770
770
|
}, H = (q, J, j) => {
|
|
771
|
-
const Q = { x: q *
|
|
772
|
-
return { root: Q, joint: nt, end:
|
|
771
|
+
const Q = { x: q * B, y: z }, nt = b(Q.x, Q.y, J, q, cr * o * r);
|
|
772
|
+
return { root: Q, joint: nt, end: b(nt.x, nt.y, J + j, q, fr * o * r) };
|
|
773
773
|
}, N = { left: E(-1, h, f), right: E(1, y, u) }, D = (q, J, j, Q, nt, lt) => {
|
|
774
774
|
const xt = d(q, j, Q, nt, lt);
|
|
775
775
|
return { x: J.end.x + xt.x * n * s, y: J.end.y + xt.y * n * s };
|
|
776
|
-
}, X = (q, J, j, Q, nt) =>
|
|
776
|
+
}, X = (q, J, j, Q, nt) => b(J.end.x, J.end.y, j + Q + nt, q, Wo * o), K = {
|
|
777
777
|
left: H(-1, t.leftShoulder, t.leftElbow),
|
|
778
778
|
right: H(1, t.rightShoulder, t.rightElbow)
|
|
779
779
|
};
|
|
@@ -782,20 +782,20 @@ function Bo(t, e) {
|
|
|
782
782
|
facing: (e.facing ?? 1) < 0 ? -1 : 1,
|
|
783
783
|
stretch: s,
|
|
784
784
|
lineWidth: e.lineWidth ?? n * 0.025,
|
|
785
|
-
rubber: Math.min(1, Math.max(g ? 0 :
|
|
785
|
+
rubber: Math.min(1, Math.max(g ? 0 : br, e.rubber ?? 0)),
|
|
786
786
|
r: l,
|
|
787
787
|
// The head keeps its area: taller and narrower when stretched.
|
|
788
788
|
headRx: l / Math.sqrt(s),
|
|
789
789
|
headRy: l * Math.sqrt(s),
|
|
790
790
|
hipY: v,
|
|
791
791
|
neckY: P,
|
|
792
|
-
drop:
|
|
792
|
+
drop: M,
|
|
793
793
|
lean: g ? t.lean : t.lean + kr * Math.sin(Math.PI * c),
|
|
794
794
|
classic: g,
|
|
795
795
|
legs: N,
|
|
796
796
|
toes: {
|
|
797
|
-
left: D(-1, N.left, h, f, x.left,
|
|
798
|
-
right: D(1, N.right, y, u, x.right,
|
|
797
|
+
left: D(-1, N.left, h, f, x.left, w.left),
|
|
798
|
+
right: D(1, N.right, y, u, x.right, w.right)
|
|
799
799
|
},
|
|
800
800
|
spine: A,
|
|
801
801
|
chest: $,
|
|
@@ -824,14 +824,14 @@ function ce(t, e, n) {
|
|
|
824
824
|
return { x: e.x + r * s - i * o, y: e.y + r * o + i * s };
|
|
825
825
|
}
|
|
826
826
|
function Ro(t, e, n = !0) {
|
|
827
|
-
const s =
|
|
827
|
+
const s = Tr(t, e), o = e.spin ?? 0, r = e.rise ?? 0;
|
|
828
828
|
return n && (o !== 0 || r !== 0) ? Ir(s, t, o, r) : s;
|
|
829
829
|
}
|
|
830
|
-
function
|
|
830
|
+
function Bo(t, e, n) {
|
|
831
831
|
return { pivot: { x: 0, y: t.hipY }, angle: t.facing * St(e), lift: n * t.height };
|
|
832
832
|
}
|
|
833
833
|
function Ir(t, e, n, s) {
|
|
834
|
-
const { pivot: o, angle: r, lift: i } =
|
|
834
|
+
const { pivot: o, angle: r, lift: i } = Bo(e, n, s), a = (y) => {
|
|
835
835
|
const u = ce(y, o, r);
|
|
836
836
|
return { x: u.x, y: u.y - i };
|
|
837
837
|
}, l = (y) => ({ left: a(y.left), right: a(y.right) }), c = { left: Math.max(a(t.feet.left).y, a(t.toes.left).y), right: Math.max(a(t.feet.right).y, a(t.toes.right).y) }, h = Math.max(c.left, c.right), f = Ho * e.height;
|
|
@@ -859,7 +859,7 @@ function Ir(t, e, n, s) {
|
|
|
859
859
|
head: { ...t.head, center: a(t.head.center), angle: t.head.angle + r }
|
|
860
860
|
};
|
|
861
861
|
}
|
|
862
|
-
function
|
|
862
|
+
function Tr(t, e) {
|
|
863
863
|
const n = St(t.lean), s = St(e.headTilt), o = { x: 0, y: t.hipY }, r = (v) => ({ x: t.facing * v.x, y: v.y }), i = (v) => r(ce(v, o, n)), a = (v) => i(Or(t, v)), l = (v) => a(ce({ x: v.x, y: v.y + t.neckY }, { x: 0, y: t.neckY }, s)), c = ie(t.arms.left, t.rubber).map(a), h = ie(t.arms.right, t.rubber).map(a), f = (v, P) => Math.atan2(P.y - v.y, P.x - v.x), y = { left: a(t.handTips.left), right: a(t.handTips.right) }, u = (v, P) => {
|
|
864
864
|
const [R, O] = v.slice(-2), $ = t.arms[P], A = f(a($.end), y[P]) - f(a($.joint), a($.end));
|
|
865
865
|
return f(R, O) + A;
|
|
@@ -872,7 +872,7 @@ function Wr(t, e) {
|
|
|
872
872
|
const R = Lo(rn, 1, v, _o(P, e.blink));
|
|
873
873
|
g = Math.min(g, R, R - e.browTilt * 0.1);
|
|
874
874
|
}
|
|
875
|
-
const m = { left: r(t.legs.left.end), right: r(t.legs.right.end) }, d = { left: r(t.toes.left), right: r(t.toes.right) }, x = { left: Math.max(m.left.y, d.left.y), right: Math.max(m.right.y, d.right.y) },
|
|
875
|
+
const m = { left: r(t.legs.left.end), right: r(t.legs.right.end) }, d = { left: r(t.toes.left), right: r(t.toes.right) }, x = { left: Math.max(m.left.y, d.left.y), right: Math.max(m.right.y, d.right.y) }, w = Math.max(x.left, x.right), M = Ho * t.height;
|
|
876
876
|
return {
|
|
877
877
|
facing: t.facing,
|
|
878
878
|
height: t.height,
|
|
@@ -886,8 +886,8 @@ function Wr(t, e) {
|
|
|
886
886
|
knees: { left: r(t.legs.left.joint), right: r(t.legs.right.joint) },
|
|
887
887
|
feet: m,
|
|
888
888
|
toes: d,
|
|
889
|
-
feetY:
|
|
890
|
-
grounded: { left: x.left >=
|
|
889
|
+
feetY: w,
|
|
890
|
+
grounded: { left: x.left >= w - M, right: x.right >= w - M },
|
|
891
891
|
fingertips: y,
|
|
892
892
|
handAngle: { left: u(c, "left"), right: u(h, "right") },
|
|
893
893
|
limbs: {
|
|
@@ -906,14 +906,14 @@ function Wr(t, e) {
|
|
|
906
906
|
eyeY: rn,
|
|
907
907
|
browTopY: g,
|
|
908
908
|
mouthY: $o,
|
|
909
|
-
faceX: t.facing * (Io +
|
|
909
|
+
faceX: t.facing * (Io + To * zt(e.turn))
|
|
910
910
|
}
|
|
911
911
|
};
|
|
912
912
|
}
|
|
913
|
-
function
|
|
914
|
-
return Ro(
|
|
913
|
+
function Wr(t, e = {}) {
|
|
914
|
+
return Ro(Co(t, e), t);
|
|
915
915
|
}
|
|
916
|
-
function
|
|
916
|
+
function Ba(t, e, n) {
|
|
917
917
|
return ce({ x: t.center.x + e * t.rx, y: t.center.y + n * t.ry }, t.center, t.angle);
|
|
918
918
|
}
|
|
919
919
|
function Hr(t, e, n) {
|
|
@@ -943,7 +943,7 @@ function Hr(t, e, n) {
|
|
|
943
943
|
};
|
|
944
944
|
}
|
|
945
945
|
function $r(t, e, n = {}, s = 0) {
|
|
946
|
-
const o =
|
|
946
|
+
const o = Co(e, n), r = n.color ?? "#1e293b", i = n.layers ?? {}, a = n.layers ? Ro(o, e, !1) : void 0, l = n.sketch ? An(t, n.sketch, s) : void 0, c = n.sketch && n.layers ? An(t, n.sketch, s) : void 0, h = (O) => {
|
|
947
947
|
t.save(), O(), t.restore();
|
|
948
948
|
}, f = (O) => {
|
|
949
949
|
O && a && h(() => O(t, a, s, c));
|
|
@@ -962,23 +962,23 @@ function $r(t, e, n = {}, s = 0) {
|
|
|
962
962
|
mn(t, O, A[0] * o.lineWidth, A[1] * o.lineWidth);
|
|
963
963
|
}, d = (O, $) => m(ie(O, o.rubber), o.rubber > 0, $), x = (O) => {
|
|
964
964
|
o.classic || m([o.legs[O].end, o.toes[O]], !1, mr);
|
|
965
|
-
},
|
|
965
|
+
}, w = (O) => {
|
|
966
966
|
if (n.hands && !o.classic) return v(O);
|
|
967
967
|
if (o.classic || l) return;
|
|
968
968
|
const $ = o.arms[O].end;
|
|
969
969
|
t.beginPath(), t.arc($.x, $.y, xr * o.lineWidth, 0, Math.PI * 2), t.fill();
|
|
970
970
|
};
|
|
971
971
|
t.save(), t.strokeStyle = r, t.fillStyle = r, t.lineWidth = o.lineWidth, t.lineCap = "round", t.lineJoin = "round";
|
|
972
|
-
const
|
|
973
|
-
(
|
|
972
|
+
const M = Bo(o, e.spin ?? 0, e.rise ?? 0);
|
|
973
|
+
(M.angle !== 0 || M.lift !== 0) && (t.translate(0, -M.lift), t.translate(M.pivot.x, M.pivot.y), t.rotate(M.angle), t.translate(-M.pivot.x, -M.pivot.y));
|
|
974
974
|
function v(O) {
|
|
975
|
-
const $ = n.hands ?? {}, A = o.arms[O].end, z = o.handTips[O],
|
|
975
|
+
const $ = n.hands ?? {}, A = o.arms[O].end, z = o.handTips[O], B = n.headFill ?? "#ffffff";
|
|
976
976
|
So(t, A, $[O] ?? Ot, {
|
|
977
977
|
side: O,
|
|
978
978
|
// Degrees clockwise from straight up, in the frame the hand is drawn in.
|
|
979
979
|
angle: Math.atan2(z.x - A.x, A.y - z.y) * 180 / Math.PI,
|
|
980
|
-
size: ($.size ??
|
|
981
|
-
skin: $.skin ?? (
|
|
980
|
+
size: ($.size ?? Wo) * o.height * Math.sqrt(o.stretch),
|
|
981
|
+
skin: $.skin ?? (B === "none" ? void 0 : B),
|
|
982
982
|
ink: r,
|
|
983
983
|
lineWidth: o.lineWidth * 0.45,
|
|
984
984
|
fingers: $.fingers,
|
|
@@ -989,7 +989,7 @@ function $r(t, e, n = {}, s = 0) {
|
|
|
989
989
|
}
|
|
990
990
|
const P = (O) => {
|
|
991
991
|
h(() => {
|
|
992
|
-
g(), d(o.arms[O], yr),
|
|
992
|
+
g(), d(o.arms[O], yr), w(O);
|
|
993
993
|
});
|
|
994
994
|
const $ = i.sleeve;
|
|
995
995
|
$ && a && h(() => $(t, a, O, s, c));
|
|
@@ -1023,11 +1023,11 @@ function $r(t, e, n = {}, s = 0) {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
function Fo(t, e, n, s) {
|
|
1025
1025
|
const o = { ...t }, r = t.gait && s?.[t.gait] || t.gait;
|
|
1026
|
-
let i = t.walking > 0 ?
|
|
1026
|
+
let i = t.walking > 0 ? Wn(o, er(r, t.walk, o), t.walking) : o, a = Lr(t);
|
|
1027
1027
|
const l = t.dancing ?? 0;
|
|
1028
1028
|
if (n && l > 0) {
|
|
1029
1029
|
const c = n(t.beat ?? 0);
|
|
1030
|
-
if (i =
|
|
1030
|
+
if (i = Wn(i, c.pose, l), c.hands) {
|
|
1031
1031
|
const h = (f, y) => y ? $s(f ?? Ot, y, l) : f;
|
|
1032
1032
|
a = { left: h(a?.left, c.hands.left), right: h(a?.right, c.hands.right) };
|
|
1033
1033
|
}
|
|
@@ -1045,7 +1045,7 @@ function Lr(t) {
|
|
|
1045
1045
|
}, n = e("left"), s = e("right");
|
|
1046
1046
|
return n || s ? { left: n, right: s } : void 0;
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1048
|
+
function Cr(t, e) {
|
|
1049
1049
|
return !e || !t.hands ? t : { ...t, hands: { ...t.hands, left: e.left ?? t.hands.left, right: e.right ?? t.hands.right } };
|
|
1050
1050
|
}
|
|
1051
1051
|
function Fa(t) {
|
|
@@ -1068,7 +1068,7 @@ function Fa(t) {
|
|
|
1068
1068
|
figureGaits: t.cast?.gaits,
|
|
1069
1069
|
draw(i, a, l) {
|
|
1070
1070
|
const c = a.props, h = Fo(c, l, t.dance, t.cast?.gaits);
|
|
1071
|
-
i.translate(s / 2, n), $r(i, h.pose,
|
|
1071
|
+
i.translate(s / 2, n), $r(i, h.pose, Cr({ ...e, rubber: c.rubber, facing: No(c, e) }, h.hands), l);
|
|
1072
1072
|
}
|
|
1073
1073
|
};
|
|
1074
1074
|
}
|
|
@@ -1095,10 +1095,10 @@ function Na(t, e, n) {
|
|
|
1095
1095
|
let r = 0, i = 0;
|
|
1096
1096
|
for (const [c, h] of e.state?.values.get(n) ?? [])
|
|
1097
1097
|
c === "gait" && typeof h == "string" && (o.gait = h), typeof h == "number" && (c === "x" || c === "motionPathX" ? r = h : c === "y" || c === "motionPathY" ? i = h : c in o && (o[c] = h));
|
|
1098
|
-
const a = _r(o, e.time, t.figureDance, t.figureGaits), l =
|
|
1098
|
+
const a = _r(o, e.time, t.figureDance, t.figureGaits), l = Wr(a, { ...s, rubber: o.rubber, facing: No(o, s) });
|
|
1099
1099
|
return { pose: a, joints: Hr(l, t.x + r + t.width / 2, t.y + i + t.height) };
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function Br(t) {
|
|
1102
1102
|
const e = [];
|
|
1103
1103
|
return t.forEach((n, s) => {
|
|
1104
1104
|
const o = s === 0 ? Gt : e[s - 1], r = typeof n.pose == "string" ? or[n.pose] : { ...o, ...n.pose };
|
|
@@ -1106,7 +1106,7 @@ function Cr(t) {
|
|
|
1106
1106
|
}), e;
|
|
1107
1107
|
}
|
|
1108
1108
|
function Ya(t, e) {
|
|
1109
|
-
const n =
|
|
1109
|
+
const n = Br(e);
|
|
1110
1110
|
return Ao.filter((s) => n.some((o) => o[s] !== Gt[s])).map((s) => ({
|
|
1111
1111
|
id: `${t}-${s}`,
|
|
1112
1112
|
target: t,
|
|
@@ -1304,14 +1304,14 @@ function Jr(t = {}) {
|
|
|
1304
1304
|
],
|
|
1305
1305
|
angles(f, y) {
|
|
1306
1306
|
if (y.id === "spine") {
|
|
1307
|
-
const
|
|
1307
|
+
const w = -h(f, "lean") / 2, M = h(f, "side") / 2, v = -h(f, "bend");
|
|
1308
1308
|
return [
|
|
1309
|
-
{ swing:
|
|
1310
|
-
{ swing:
|
|
1309
|
+
{ swing: w + v * Dr, spread: M },
|
|
1310
|
+
{ swing: w + v * qr, spread: M }
|
|
1311
1311
|
];
|
|
1312
1312
|
}
|
|
1313
1313
|
if (y.id === "neck") return [{ swing: -h(f, "bend") * Ur, spread: 0 }];
|
|
1314
|
-
const [u, g] = y.id.split("."), m = (
|
|
1314
|
+
const [u, g] = y.id.split("."), m = (w) => h(f, `${u}.${g}.${w}`);
|
|
1315
1315
|
if (u === "arm")
|
|
1316
1316
|
return [
|
|
1317
1317
|
{ swing: m("swing"), spread: m("spread") },
|
|
@@ -1467,8 +1467,8 @@ function Pt([t, e, n], s) {
|
|
|
1467
1467
|
const o = Math.cos(s), r = Math.sin(s);
|
|
1468
1468
|
return [t * o + n * r, e, -t * r + n * o];
|
|
1469
1469
|
}
|
|
1470
|
-
const _t = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]],
|
|
1471
|
-
function
|
|
1470
|
+
const _t = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]], Te = (t, e) => [t[0] * e, t[1] * e, t[2] * e], Pe = (t, e) => Re(Yo(t, e.swing), e.spread);
|
|
1471
|
+
function be(t, e) {
|
|
1472
1472
|
const n = Pt(t, e);
|
|
1473
1473
|
return { point: { x: n[0], y: -n[1] }, depth: n[2] };
|
|
1474
1474
|
}
|
|
@@ -1477,46 +1477,46 @@ function xn(t, e, n) {
|
|
|
1477
1477
|
for (const m of t.chains) {
|
|
1478
1478
|
const d = m.parent ? i[m.parent] : void 0;
|
|
1479
1479
|
if (m.parent && !d) throw new Error(`body plan ${t.id}: chain ${m.id} comes before its parent ${m.parent}`);
|
|
1480
|
-
const x = m.at ?? (d ? d.joints3.length - 1 : 0),
|
|
1481
|
-
let z =
|
|
1482
|
-
m.bones.forEach((
|
|
1480
|
+
const x = m.at ?? (d ? d.joints3.length - 1 : 0), w = d ? d.joints3[x] : r, M = d ? d.frames[Math.max(0, x - 1)] : { swing: 0, spread: 0 }, v = m.offset ? _t(w, Pe(Te(m.offset, s), M)) : w, P = m.side ?? 1, R = t.boneScale?.(e, m) ?? 1, O = t.angles(e, m), $ = [v], A = [];
|
|
1481
|
+
let z = M.swing, B = M.spread;
|
|
1482
|
+
m.bones.forEach((b, E) => {
|
|
1483
1483
|
const H = O[E] ?? { swing: 0, spread: 0 };
|
|
1484
|
-
z += Et(H.swing),
|
|
1485
|
-
const N = Pt(Pe(m.rest, { swing: z, spread:
|
|
1486
|
-
$.push(_t($[E],
|
|
1484
|
+
z += Et(H.swing), B += Et(H.spread) * P, A.push({ swing: z, spread: B });
|
|
1485
|
+
const N = Pt(Pe(m.rest, { swing: z, spread: B }), Et(H.yaw ?? 0));
|
|
1486
|
+
$.push(_t($[E], Te(N, b.length * s * R)));
|
|
1487
1487
|
}), i[m.id] = { joints3: $, frames: A };
|
|
1488
1488
|
}
|
|
1489
1489
|
const a = i[t.head.on], l = t.headPose?.(e) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, c = a.frames[a.frames.length - 1], h = t.head.size / 2 * s, f = h * l.sx, y = h * l.sy, u = (m) => Pe(Pt(Yo(Re(m, -Et(l.tilt)), -Et(l.nod)), Et(l.yaw)), c), g = _t(a.joints3[a.joints3.length - 1], u([0, y, 0]));
|
|
1490
1490
|
return { height: s, root: r, chains: i, head: { center: g, rx: f, ry: y, toBody: u } };
|
|
1491
1491
|
}
|
|
1492
|
-
function
|
|
1492
|
+
function bn(t, e, n) {
|
|
1493
1493
|
const s = n.height, o = Et(90 * (e.turn ?? 0)), r = xn(t, e, s), { root: i } = r, a = r.chains, { rx: l, ry: c } = r.head, h = r.head.toBody, f = r.head.center, y = {};
|
|
1494
1494
|
for (const A of t.chains) {
|
|
1495
|
-
const { joints3: z, frames:
|
|
1495
|
+
const { joints3: z, frames: B } = a[A.id], b = z.map((E) => be(E, o));
|
|
1496
1496
|
y[A.id] = {
|
|
1497
1497
|
id: A.id,
|
|
1498
1498
|
joints3: z,
|
|
1499
|
-
frames:
|
|
1500
|
-
points:
|
|
1501
|
-
depths:
|
|
1499
|
+
frames: B,
|
|
1500
|
+
points: b.map((E) => E.point),
|
|
1501
|
+
depths: b.map((E) => E.depth)
|
|
1502
1502
|
};
|
|
1503
1503
|
}
|
|
1504
|
-
const u =
|
|
1505
|
-
const z = A.x - m.x,
|
|
1506
|
-
return { x: m.x + z * Math.cos(d) -
|
|
1507
|
-
},
|
|
1504
|
+
const u = be(f, o), g = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((A) => Pt(h(A), o)), m = be(i, o).point, d = Et(e.roll ?? 0), x = (A) => {
|
|
1505
|
+
const z = A.x - m.x, B = A.y - m.y;
|
|
1506
|
+
return { x: m.x + z * Math.cos(d) - B * Math.sin(d), y: m.y + z * Math.sin(d) + B * Math.cos(d) };
|
|
1507
|
+
}, w = ([A, z, B]) => [A * Math.cos(d) + z * Math.sin(d), -A * Math.sin(d) + z * Math.cos(d), B];
|
|
1508
1508
|
for (const A of Object.values(y)) A.points = A.points.map(x);
|
|
1509
|
-
const
|
|
1509
|
+
const M = {
|
|
1510
1510
|
center: x(u.point),
|
|
1511
1511
|
depth: u.depth,
|
|
1512
1512
|
rx: l,
|
|
1513
1513
|
ry: c,
|
|
1514
1514
|
angle: 0,
|
|
1515
|
-
axes: g.map(
|
|
1516
|
-
}, v =
|
|
1517
|
-
|
|
1515
|
+
axes: g.map(w)
|
|
1516
|
+
}, v = M.axes[1];
|
|
1517
|
+
M.angle = Math.atan2(v[0], v[1]);
|
|
1518
1518
|
const P = (A) => {
|
|
1519
|
-
if ("head" in A) return { x:
|
|
1519
|
+
if ("head" in A) return { x: M.center.x + v[0] * c, y: M.center.y - v[1] * c };
|
|
1520
1520
|
const z = y[A.chain];
|
|
1521
1521
|
return z.points[Math.min(A.joint, z.points.length - 1)];
|
|
1522
1522
|
};
|
|
@@ -1524,28 +1524,28 @@ function wn(t, e, n) {
|
|
|
1524
1524
|
(n.contact ?? "ground") === "ground" && (R = -Math.max(...t.contacts.map((A) => P(A).y))), R -= (e.lift ?? 0) * s;
|
|
1525
1525
|
const O = (A) => ({ x: A.x, y: A.y + R });
|
|
1526
1526
|
for (const A of Object.values(y)) A.points = A.points.map(O);
|
|
1527
|
-
|
|
1527
|
+
M.center = O(M.center);
|
|
1528
1528
|
const $ = t.contacts.map((A) => ({ spec: A, point: P(A) }));
|
|
1529
1529
|
return {
|
|
1530
1530
|
height: s,
|
|
1531
1531
|
view: o,
|
|
1532
1532
|
chains: y,
|
|
1533
|
-
head:
|
|
1533
|
+
head: M,
|
|
1534
1534
|
hip: O(x(m)),
|
|
1535
|
-
hipDepth:
|
|
1535
|
+
hipDepth: be(i, o).depth,
|
|
1536
1536
|
contacts: $,
|
|
1537
1537
|
groundY: Math.max(...$.map((A) => A.point.y))
|
|
1538
1538
|
};
|
|
1539
1539
|
}
|
|
1540
|
-
const
|
|
1540
|
+
const We = (t, e) => [t[0] - e[0], t[1] - e[1], t[2] - e[2]], ln = (t) => {
|
|
1541
1541
|
const e = Math.hypot(t[0], t[1], t[2]) || 1;
|
|
1542
1542
|
return [t[0] / e, t[1] / e, t[2] / e];
|
|
1543
1543
|
};
|
|
1544
1544
|
function ti(t, e, n) {
|
|
1545
|
-
const s = n.height, o = Et(90 * (e.turn ?? 0)), r = Et(e.roll ?? 0), i = xn(t, e, s), a = Pt(i.root, o), l = (d) => _t(Re(
|
|
1545
|
+
const s = n.height, o = Et(90 * (e.turn ?? 0)), r = Et(e.roll ?? 0), i = xn(t, e, s), a = Pt(i.root, o), l = (d) => _t(Re(We(Pt(d, o), a), -r), a), c = {};
|
|
1546
1546
|
for (const d of t.chains) c[d.id] = i.chains[d.id].joints3.map(l);
|
|
1547
|
-
const h = l(i.head.center), f = (d) => ln(
|
|
1548
|
-
if ("head" in d) return _t(h,
|
|
1547
|
+
const h = l(i.head.center), f = (d) => ln(We(l(_t(i.head.center, i.head.toBody(d))), h)), y = [f([1, 0, 0]), f([0, 1, 0]), f([0, 0, 1])], u = (d) => {
|
|
1548
|
+
if ("head" in d) return _t(h, Te(y[1], i.head.ry));
|
|
1549
1549
|
const x = c[d.chain];
|
|
1550
1550
|
return x[Math.min(d.joint, x.length - 1)];
|
|
1551
1551
|
};
|
|
@@ -1559,43 +1559,43 @@ function ti(t, e, n) {
|
|
|
1559
1559
|
head: { center: m(h), rx: i.head.rx, ry: i.head.ry, axes: y }
|
|
1560
1560
|
};
|
|
1561
1561
|
}
|
|
1562
|
-
function
|
|
1563
|
-
const o = n.height, r = Et(90 * (e.turn ?? 0)), i = xn(t, e, o), a = ti(t, e, n), l = a.hip, c = a.chains, h = a.head.center, f = (
|
|
1564
|
-
if ("head" in
|
|
1565
|
-
const
|
|
1566
|
-
return
|
|
1567
|
-
}, y = s.toView(l), u = Re(Pt([0, 0, 1], r), -Et(e.roll ?? 0)), g = ln(
|
|
1568
|
-
const
|
|
1569
|
-
return { point: s.toScreen(
|
|
1570
|
-
},
|
|
1571
|
-
for (const
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1574
|
-
id:
|
|
1575
|
-
joints3: i.chains[
|
|
1576
|
-
frames: i.chains[
|
|
1577
|
-
points:
|
|
1578
|
-
depths:
|
|
1562
|
+
function wn(t, e, n, s) {
|
|
1563
|
+
const o = n.height, r = Et(90 * (e.turn ?? 0)), i = xn(t, e, o), a = ti(t, e, n), l = a.hip, c = a.chains, h = a.head.center, f = (B) => {
|
|
1564
|
+
if ("head" in B) return _t(h, Te(a.head.axes[1], a.head.ry));
|
|
1565
|
+
const b = c[B.chain];
|
|
1566
|
+
return b[Math.min(B.joint, b.length - 1)];
|
|
1567
|
+
}, y = s.toView(l), u = Re(Pt([0, 0, 1], r), -Et(e.roll ?? 0)), g = ln(We(s.toView(_t(l, u)), y)), m = s.toScreen(y), d = s.toScreen([y[0] + 1, y[1], y[2]]), x = Math.hypot(d.x - m.x, d.y - m.y), w = (B) => {
|
|
1568
|
+
const b = s.toView(B);
|
|
1569
|
+
return { point: s.toScreen(b), depth: b[2] * x };
|
|
1570
|
+
}, M = {};
|
|
1571
|
+
for (const B of t.chains) {
|
|
1572
|
+
const b = c[B.id].map(w);
|
|
1573
|
+
M[B.id] = {
|
|
1574
|
+
id: B.id,
|
|
1575
|
+
joints3: i.chains[B.id].joints3,
|
|
1576
|
+
frames: i.chains[B.id].frames,
|
|
1577
|
+
points: b.map((E) => E.point),
|
|
1578
|
+
depths: b.map((E) => E.depth)
|
|
1579
1579
|
};
|
|
1580
1580
|
}
|
|
1581
|
-
const v = s.toView(h), P = s.toScreen(v), R = s.toScreen([v[0] + 1, v[1], v[2]]), O = Math.hypot(R.x - P.x, R.y - P.y), $ = a.head.axes.map((
|
|
1581
|
+
const v = s.toView(h), P = s.toScreen(v), R = s.toScreen([v[0] + 1, v[1], v[2]]), O = Math.hypot(R.x - P.x, R.y - P.y), $ = a.head.axes.map((B) => ln(We(s.toView(_t(h, B)), v))), A = {
|
|
1582
1582
|
center: P,
|
|
1583
1583
|
depth: v[2] * x,
|
|
1584
1584
|
rx: i.head.rx * O,
|
|
1585
1585
|
ry: i.head.ry * O,
|
|
1586
1586
|
angle: Math.atan2($[1][0], $[1][1]),
|
|
1587
1587
|
axes: $
|
|
1588
|
-
}, z = t.contacts.map((
|
|
1588
|
+
}, z = t.contacts.map((B) => ({ spec: B, point: w(f(B)).point }));
|
|
1589
1589
|
return {
|
|
1590
1590
|
height: o * x,
|
|
1591
1591
|
view: r,
|
|
1592
1592
|
bodyForward: g,
|
|
1593
|
-
chains:
|
|
1593
|
+
chains: M,
|
|
1594
1594
|
head: A,
|
|
1595
1595
|
hip: m,
|
|
1596
1596
|
hipDepth: y[2] * x,
|
|
1597
1597
|
contacts: z,
|
|
1598
|
-
groundY: Math.max(...z.map((
|
|
1598
|
+
groundY: Math.max(...z.map((B) => B.point.y))
|
|
1599
1599
|
};
|
|
1600
1600
|
}
|
|
1601
1601
|
function oe(t, [e, n, s]) {
|
|
@@ -1606,7 +1606,7 @@ function oe(t, [e, n, s]) {
|
|
|
1606
1606
|
], l = Math.hypot(e, n, s) || 1, c = (o[2] * e + r[2] * n + i[2] * s) / l;
|
|
1607
1607
|
return { point: { x: t.center.x + a[0], y: t.center.y - a[1] }, depth: t.depth + a[2], facing: c };
|
|
1608
1608
|
}
|
|
1609
|
-
const
|
|
1609
|
+
const we = (t) => t * 180 / Math.PI, Nt = (t, e) => [t[0] - e[0], t[1] - e[1], t[2] - e[2]], Xe = (t, e) => t[0] * e[0] + t[1] * e[1] + t[2] * e[2], Qt = (t) => Math.hypot(t[0], t[1], t[2]), hn = (t) => {
|
|
1610
1610
|
const e = Qt(t) || 1;
|
|
1611
1611
|
return [t[0] / e, t[1] / e, t[2] / e];
|
|
1612
1612
|
}, Me = (t) => Math.atan2(Math.sin(t), Math.cos(t));
|
|
@@ -1615,24 +1615,24 @@ function Dn(t) {
|
|
|
1615
1615
|
return { swing: Math.asin(Math.max(-1, Math.min(1, s))), spread: Math.atan2(e, -n) };
|
|
1616
1616
|
}
|
|
1617
1617
|
function ei(t, e, n, s, o) {
|
|
1618
|
-
const r = t.chains.find((
|
|
1618
|
+
const r = t.chains.find((b) => b.id === n);
|
|
1619
1619
|
if (!r) throw new Error(`reach: no chain ${n} in ${t.id}`);
|
|
1620
1620
|
if (r.bones.length < 2 || r.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
|
|
1621
1621
|
if (!t.withAngles) throw new Error(`reach: the ${t.id} plan cannot set angles`);
|
|
1622
|
-
const i =
|
|
1622
|
+
const i = bn(t, { ...e, turn: 0, roll: 0, lift: 0 }, { height: o.height, contact: "none" }), a = i.chains[n];
|
|
1623
1623
|
if (Qt(Nt(s, a.joints3[2])) < o.height * 1e-12) return e;
|
|
1624
|
-
const l = a.joints3[0], c = Qt(Nt(a.joints3[1], a.joints3[0])), h = Qt(Nt(a.joints3[2], a.joints3[1])), f = r.parent ? i.chains[r.parent].frames[Math.max(0, (r.at ?? i.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, y = Nt(s, l), u = t.angles(e, r), g = (
|
|
1625
|
-
let
|
|
1626
|
-
Qt(
|
|
1624
|
+
const l = a.joints3[0], c = Qt(Nt(a.joints3[1], a.joints3[0])), h = Qt(Nt(a.joints3[2], a.joints3[1])), f = r.parent ? i.chains[r.parent].frames[Math.max(0, (r.at ?? i.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, y = Nt(s, l), u = t.angles(e, r), g = (b) => (u[b]?.yaw ?? 0) * Math.PI / 180, m = Math.min(c + h - 1e-6, Math.max(Math.abs(c - h) + 1e-6, Qt(y))), d = hn(y), x = r.parent !== null, w = Pt(Pe(r.pole ?? (x ? [0, -0.35, -1] : [0, 0, 1]), f), g(0));
|
|
1625
|
+
let M = Nt(w, [d[0] * Xe(w, d), d[1] * Xe(w, d), d[2] * Xe(w, d)]);
|
|
1626
|
+
Qt(M) < 1e-6 && (M = Pt([1, 0, 0], g(0))), M = hn(M);
|
|
1627
1627
|
const v = (c * c + m * m - h * h) / (2 * c * m), P = Math.sqrt(Math.max(0, 1 - v * v)), R = [
|
|
1628
|
-
l[0] + c * (v * d[0] + P *
|
|
1629
|
-
l[1] + c * (v * d[1] + P *
|
|
1630
|
-
l[2] + c * (v * d[2] + P *
|
|
1631
|
-
], O = [l[0] + d[0] * m, l[1] + d[1] * m, l[2] + d[2] * m], $ = r.side ?? 1, A = Dn(Pt(Nt(R, l), -g(0))), z = Dn(Pt(Nt(O, R), -g(1))),
|
|
1632
|
-
{ swing:
|
|
1633
|
-
{ swing:
|
|
1628
|
+
l[0] + c * (v * d[0] + P * M[0]),
|
|
1629
|
+
l[1] + c * (v * d[1] + P * M[1]),
|
|
1630
|
+
l[2] + c * (v * d[2] + P * M[2])
|
|
1631
|
+
], O = [l[0] + d[0] * m, l[1] + d[1] * m, l[2] + d[2] * m], $ = r.side ?? 1, A = Dn(Pt(Nt(R, l), -g(0))), z = Dn(Pt(Nt(O, R), -g(1))), B = [
|
|
1632
|
+
{ swing: we(Me(A.swing - f.swing)), spread: we(Me(A.spread - f.spread)) * $ },
|
|
1633
|
+
{ swing: we(Me(z.swing - A.swing)), spread: we(Me(z.spread - A.spread)) * $ }
|
|
1634
1634
|
];
|
|
1635
|
-
return t.withAngles(e, r,
|
|
1635
|
+
return t.withAngles(e, r, B);
|
|
1636
1636
|
}
|
|
1637
1637
|
function jt(t, e, n, s) {
|
|
1638
1638
|
if (!Number.isFinite(t) || t < n || t > s) throw new Error(`organic body: ${e} must be ${n}..${s}`);
|
|
@@ -1719,7 +1719,7 @@ function Ee(t, e, n, s = 1, o = 1) {
|
|
|
1719
1719
|
const y = t[Math.max(0, f - 1)], u = t[Math.min(t.length - 1, f + 1)];
|
|
1720
1720
|
let g = Yt(y, u);
|
|
1721
1721
|
Math.hypot(g.x, g.y) < 1e-6 && (g = { x: 0, y: 1 });
|
|
1722
|
-
const m = { x: -g.y, y: g.x }, d = f / Math.max(1, t.length - 1), x = oi(e, d) * n * s,
|
|
1722
|
+
const m = { x: -g.y, y: g.x }, d = f / Math.max(1, t.length - 1), x = oi(e, d) * n * s, w = Yt(y, h), M = Yt(h, u), v = w.x * M.y - w.y * M.x, P = Math.acos(Math.min(1, Math.max(-1, w.x * M.x + w.y * M.y))), R = (Math.hypot(h.x - y.x, h.y - y.y) + Math.hypot(u.x - h.x, u.y - h.y)) / (2 * Math.max(1e-6, P)), O = Math.min(x, Math.max(x * 0.2, R * 0.8));
|
|
1723
1723
|
return { center: h, width: x, at: d, left: He(h, m, v > 0 ? O : x), right: He(h, m, v < 0 ? -O : -x) };
|
|
1724
1724
|
}), i = [], a = [], l = (h, f) => {
|
|
1725
1725
|
i.push(h), a.push(f);
|
|
@@ -1852,8 +1852,8 @@ function qo(t, e) {
|
|
|
1852
1852
|
}), h = Math.max(0, i.x * a - Math.max(...c));
|
|
1853
1853
|
return !Number.isFinite(h) || h === 0 ? n : n.flatMap((f, y) => {
|
|
1854
1854
|
const u = n[(y + 1) % n.length], g = r(f), m = r(u), d = Math.max(1, Math.ceil(Math.hypot(m.x - g.x, m.y - g.y) / 0.025));
|
|
1855
|
-
return Array.from({ length: d }, (x,
|
|
1856
|
-
const
|
|
1855
|
+
return Array.from({ length: d }, (x, w) => {
|
|
1856
|
+
const M = w / d, v = { x: f.x + (u.x - f.x) * M, y: f.y + (u.y - f.y) * M }, P = r(v), R = (P.y - l + 0.115) / 0.23;
|
|
1857
1857
|
if (P.x * a < 0.5 || R <= 0 || R >= 1) return v;
|
|
1858
1858
|
const O = Math.sin(R * Math.PI) ** 2 * h * t.rx * a;
|
|
1859
1859
|
return { x: v.x + O * s, y: v.y + O * o };
|
|
@@ -1916,8 +1916,8 @@ function et(t, e, n, s = "cartoon") {
|
|
|
1916
1916
|
if (s === "volume") {
|
|
1917
1917
|
const u = oe(t, [n.x, n.y, o(n) * Gn]).point, g = Math.abs(n.x) > 0.1 ? Math.min(1, Math.max(0, r) / 0.25) : 1, m = Math.max(n.x * i[0] > 0 ? 0.2 : 0.5, l);
|
|
1918
1918
|
return { facing: r, points: e.map((d) => {
|
|
1919
|
-
const x = (d.x - n.x) * m * t.rx * g,
|
|
1920
|
-
return { x: u.x + x * f +
|
|
1919
|
+
const x = (d.x - n.x) * m * t.rx * g, w = (d.y - n.y + i[1] * (o(d) - o(n)) * Gn) * t.ry * g;
|
|
1920
|
+
return { x: u.x + x * f + w * y, y: u.y + x * y - w * f };
|
|
1921
1921
|
}) };
|
|
1922
1922
|
}
|
|
1923
1923
|
return {
|
|
@@ -1928,7 +1928,7 @@ function et(t, e, n, s = "cartoon") {
|
|
|
1928
1928
|
})
|
|
1929
1929
|
};
|
|
1930
1930
|
}
|
|
1931
|
-
const
|
|
1931
|
+
const Bt = (t, e, n, s = 12) => Array.from({ length: s + 1 }, (o, r) => {
|
|
1932
1932
|
const i = r / s, a = 1 - i;
|
|
1933
1933
|
return { x: a * a * t.x + 2 * a * i * e.x + i * i * n.x, y: a * a * t.y + 2 * a * i * e.y + i * i * n.y };
|
|
1934
1934
|
}), he = (t, e, n, s) => {
|
|
@@ -1939,86 +1939,86 @@ const Ct = (t, e, n, s = 12) => Array.from({ length: s + 1 }, (o, r) => {
|
|
|
1939
1939
|
return { x: t + Math.cos(a) * n, y: e + Math.sin(a) * s };
|
|
1940
1940
|
}), qt = 0.05, gi = 0.3, yi = "#e06b7d";
|
|
1941
1941
|
function mi(t, e, n, s, o = {}, r) {
|
|
1942
|
-
const i = Math.max(1, Math.min(s * 0.6, 0.14 * e.rx)), a = (
|
|
1943
|
-
for (const
|
|
1944
|
-
const E =
|
|
1942
|
+
const i = Math.max(1, Math.min(s * 0.6, 0.14 * e.rx)), a = (b, E) => et(e, b, E, o.projection).points, l = (b, E) => et(e, [], { x: b, y: E }, o.projection).facing, c = gt(n, "smile", 0), h = gt(n, "blink", 0), f = gt(n, "lookX", 0), y = gt(n, "lookY", 0), u = gt(n, "browTilt", 0), g = Math.max(0.2, gt(n, "pupil", 1)), m = Math.min(1, Math.max(0, gt(n, "lid", 0))), d = Math.min(1, Math.max(0, gt(n, "bulge", 0)));
|
|
1943
|
+
for (const b of [1, -1]) {
|
|
1944
|
+
const E = b === 1 ? "left" : "right", H = Xo * b;
|
|
1945
1945
|
if (l(H, yt) < qt) continue;
|
|
1946
1946
|
const N = { x: H, y: yt }, D = ci(gt(n, `eye.${E}`, 1), h);
|
|
1947
1947
|
if (D < 0.2 || o.style === "anime" && m >= 0.98) {
|
|
1948
1948
|
const J = c > 0.5 ? 0.12 : -0.06;
|
|
1949
|
-
t.line(a(
|
|
1949
|
+
t.line(a(Bt({ x: H - 0.12, y: yt }, { x: H, y: yt + J }, { x: H + 0.12, y: yt }), N), i);
|
|
1950
1950
|
} else if (o.style === "anime")
|
|
1951
|
-
pi(t, e, N,
|
|
1951
|
+
pi(t, e, N, b, D, m, d, g, f, y, i, o, r);
|
|
1952
1952
|
else {
|
|
1953
1953
|
const J = D > 1.2 || d > 0.02, j = 0.13 * Math.max(D, 1) * (1 + d * 0.7);
|
|
1954
1954
|
J && t.shape(a($t(H, yt, j * 0.85, j), N), "#ffffff", i);
|
|
1955
1955
|
const Q = (D > 1.2 ? 0.075 : 0.1) * g * (1 + d * 0.3), nt = H + f * 0.08, lt = yt - y * 0.07, xt = $t(nt, lt, Q, Q * 1.1 * Math.min(D, 1));
|
|
1956
1956
|
if (t.shape(a(xt, N), t.ink, 0), o.inPupil && r) {
|
|
1957
|
-
const [p] = a([{ x: nt, y: lt }], N),
|
|
1957
|
+
const [p] = a([{ x: nt, y: lt }], N), k = a(xt, N), I = Math.min(...k.map((T) => Math.hypot(T.x - p.x, T.y - p.y)));
|
|
1958
1958
|
I > 0.5 && (r.save(), r.beginPath(), r.arc(p.x, p.y, I, 0, Math.PI * 2), r.clip(), o.inPupil(r, { x: p.x, y: p.y, r: I, side: E }), r.restore());
|
|
1959
1959
|
}
|
|
1960
1960
|
if (m > 0.02) {
|
|
1961
|
-
const p = J ? j * 1.15 : Q * 1.4,
|
|
1962
|
-
t.shape(a([{ x: H -
|
|
1961
|
+
const p = J ? j * 1.15 : Q * 1.4, k = yt + p, I = k - p * 2 * m, T = p * 1.1;
|
|
1962
|
+
t.shape(a([{ x: H - T, y: k + 0.02 }, { x: H + T, y: k + 0.02 }, { x: H + T, y: I }, { x: H - T, y: I }], N), o.skin ?? "#ffffff", 0), t.line(a([{ x: H - T, y: I }, { x: H + T, y: I }], N), i);
|
|
1963
1963
|
}
|
|
1964
1964
|
}
|
|
1965
|
-
const X = yt + (o.style === "anime" ? 0.38 : 0.3) + gt(n, `brow.${E}`, 0) * 0.14 + Math.max(0, D - 1) * 0.12, K = { x: H +
|
|
1965
|
+
const X = yt + (o.style === "anime" ? 0.38 : 0.3) + gt(n, `brow.${E}`, 0) * 0.14 + Math.max(0, D - 1) * 0.12, K = { x: H + b * 0.13, y: X }, q = { x: H - b * 0.13, y: X + u * 0.1 };
|
|
1966
1966
|
t.line(a([K, { x: (K.x + q.x) / 2, y: (K.y + q.y) / 2 }, q], { x: H, y: X }), i);
|
|
1967
1967
|
}
|
|
1968
|
-
|
|
1968
|
+
bi(t, e, n, i, o.projection), xi(t, e, o.ageLines ?? 0, i, o.projection);
|
|
1969
1969
|
const x = { x: 0, y: dt };
|
|
1970
1970
|
if (l(0, dt) < -qt) return;
|
|
1971
1971
|
o.nose && l(0, yt - 0.15) >= qt && (o.projection === "volume" ? t.line(Do(e), i) : t.line(a([{ x: 0.01, y: yt - 0.1 }, { x: 0.03, y: dt + 0.2 }, { x: -0.05, y: dt + 0.17 }], { x: 0, y: dt + 0.22 }), i));
|
|
1972
|
-
const
|
|
1973
|
-
if (
|
|
1974
|
-
t.line(a(
|
|
1972
|
+
const w = 0.25 * Math.max(0.3, gt(n, "mouthWidth", 1)), M = Math.min(1, Math.max(0, gt(n, "mouth", 0)));
|
|
1973
|
+
if (M <= 0.05) {
|
|
1974
|
+
t.line(a(Bt({ x: -w, y: dt }, { x: 0, y: dt - c * 0.25 }, { x: w, y: dt }), x), i);
|
|
1975
1975
|
return;
|
|
1976
1976
|
}
|
|
1977
|
-
const v = 0.3 *
|
|
1977
|
+
const v = 0.3 * M;
|
|
1978
1978
|
let P, R, O, $;
|
|
1979
1979
|
if (c > 0.3) {
|
|
1980
|
-
const
|
|
1981
|
-
P = [...
|
|
1980
|
+
const b = dt + 0.05, E = { x: 0, y: dt - v * 2 };
|
|
1981
|
+
P = [...Bt({ x: w, y: b }, E, { x: -w, y: b })], R = () => b, O = (H) => he({ x: w, y: b }, E, { x: -w, y: b }, H), $ = 0.85;
|
|
1982
1982
|
} else if (c < -0.3) {
|
|
1983
|
-
const
|
|
1984
|
-
P = [...
|
|
1983
|
+
const b = dt - v * 0.6, E = { x: 0, y: dt + v * 1.4 };
|
|
1984
|
+
P = [...Bt({ x: w, y: b }, E, { x: -w, y: b })], R = (H) => he({ x: w, y: b }, E, { x: -w, y: b }, H), O = () => b, $ = 0.5;
|
|
1985
1985
|
} else {
|
|
1986
|
-
const
|
|
1987
|
-
P = $t(0, dt,
|
|
1988
|
-
const E = (H) => v * Math.sqrt(Math.max(0, 1 - (H /
|
|
1986
|
+
const b = w * 0.8;
|
|
1987
|
+
P = $t(0, dt, b, v);
|
|
1988
|
+
const E = (H) => v * Math.sqrt(Math.max(0, 1 - (H / b) ** 2));
|
|
1989
1989
|
R = (H) => dt + E(H), O = (H) => dt - E(H), $ = 0.5;
|
|
1990
1990
|
}
|
|
1991
|
-
if (t.shape(a(P, x), t.ink, 0),
|
|
1992
|
-
const A = R(0) - O(0), z =
|
|
1991
|
+
if (t.shape(a(P, x), t.ink, 0), M < gi) return;
|
|
1992
|
+
const A = R(0) - O(0), z = w * $, B = (b, E, H = 8) => Array.from({ length: H + 1 }, (N, D) => b + (E - b) * D / H);
|
|
1993
1993
|
if (o.tongue) {
|
|
1994
|
-
const
|
|
1994
|
+
const b = z * 0.55, E = B(b, -b).map((N) => ({ x: N, y: O(N) })), H = Bt({ x: -b, y: O(-b) }, { x: 0, y: O(0) + A * 0.8 }, { x: b, y: O(b) }, 8);
|
|
1995
1995
|
t.shape(a([...E, ...H.slice(1, -1)], x), yi, 0);
|
|
1996
1996
|
}
|
|
1997
1997
|
if (o.teeth) {
|
|
1998
|
-
const
|
|
1998
|
+
const b = Math.min(0.06, A * 0.4), E = B(-z, z).map((N) => ({ x: N, y: R(N) })), H = E.map(({ x: N, y: D }) => ({ x: N * 0.92, y: D - b })).reverse();
|
|
1999
1999
|
t.shape(a([...E, ...H], x), "#ffffff", 0);
|
|
2000
2000
|
for (const N of [-0.5, 0, 0.5]) {
|
|
2001
2001
|
const D = z * N;
|
|
2002
|
-
t.line(a([{ x: D, y: R(D) }, { x: D * 0.92, y: R(D) -
|
|
2002
|
+
t.line(a([{ x: D, y: R(D) }, { x: D * 0.92, y: R(D) - b }], x), i * 0.6);
|
|
2003
2003
|
}
|
|
2004
2004
|
}
|
|
2005
2005
|
}
|
|
2006
2006
|
function pi(t, e, n, s, o, r, i, a, l, c, h, f, y) {
|
|
2007
|
-
const { x: u, y: g } = n, m = Math.min(1.2, Math.max(0.5, f.eyeScale ?? 1)), d = Math.min(1.2, Math.max(0.45, f.eyeAspect ?? 1)), x = 0.21 * m * (1 + i * 0.15),
|
|
2008
|
-
const q = Math.min(v.x, Math.max(
|
|
2009
|
-
return { x: q, y: Math.min(he(
|
|
2007
|
+
const { x: u, y: g } = n, m = Math.min(1.2, Math.max(0.5, f.eyeScale ?? 1)), d = Math.min(1.2, Math.max(0.45, f.eyeAspect ?? 1)), x = 0.21 * m * (1 + i * 0.15), w = 0.25 * m * d * Math.min(o, 1.6) * (1 - r) * (1 + i * 0.3), M = { x: u - x, y: g }, v = { x: u + x, y: g }, P = { x: u, y: g + w * 1.9 }, R = { x: u, y: g - w * 1.35 }, O = Bt(M, P, v), $ = Bt(v, R, M), A = (X) => et(e, X, n, f.projection).points, z = (X) => X.map((K) => {
|
|
2008
|
+
const q = Math.min(v.x, Math.max(M.x, K.x));
|
|
2009
|
+
return { x: q, y: Math.min(he(M, P, v, q), Math.max(he(v, R, M, q), K.y)) };
|
|
2010
2010
|
});
|
|
2011
2011
|
t.shape(A([...O, ...$.slice(1, -1)]), "#ffffff", h * 0.5);
|
|
2012
|
-
const
|
|
2013
|
-
t.shape(A(z($t(
|
|
2014
|
-
const N = Math.min(0.085, 0.042 * a) * m, D = z($t(
|
|
2012
|
+
const B = u + Math.max(-1, Math.min(1, l)) * 0.07 * m, b = g - Math.max(-1, Math.min(1, c)) * 0.055 * m, E = 0.115 * m, H = 0.185 * m;
|
|
2013
|
+
t.shape(A(z($t(B, b, E, H, 24))), f.iris ?? "#4b7fce", h * 0.4), t.shape(A(z($t(B, b - 0.075 * m, E * 0.7, H * 0.35))), "rgba(255,255,255,0.25)", 0);
|
|
2014
|
+
const N = Math.min(0.085, 0.042 * a) * m, D = z($t(B, b, N, N * 1.35));
|
|
2015
2015
|
if (t.shape(A(D), t.ink, 0), f.inPupil && y) {
|
|
2016
|
-
const [X] = A([{ x:
|
|
2016
|
+
const [X] = A([{ x: B, y: b }]), K = Math.min(...A(D).map((q) => Math.hypot(q.x - X.x, q.y - X.y)));
|
|
2017
2017
|
K > 0.5 && (y.save(), y.beginPath(), y.arc(X.x, X.y, K, 0, Math.PI * 2), y.clip(), f.inPupil(y, { ...X, r: K, side: s === 1 ? "left" : "right" }), y.restore());
|
|
2018
2018
|
}
|
|
2019
|
-
if (t.shape(A(z($t(
|
|
2019
|
+
if (t.shape(A(z($t(B - 0.038 * m, b + 0.075 * m, 0.035 * m, 0.045 * m))), "#ffffff", 0), t.shape(A(z($t(B + 0.04 * m, b - 0.04 * m, 0.014 * m, 0.02 * m))), "#ffffff", 0), t.line(A(O), h * 1.1), f.lashes !== !1)
|
|
2020
2020
|
for (const X of [0, 0.035]) {
|
|
2021
|
-
const K = u + s * (x - X), q = he(
|
|
2021
|
+
const K = u + s * (x - X), q = he(M, P, v, K);
|
|
2022
2022
|
t.line(A([{ x: K, y: q }, { x: K + s * 0.055, y: q + 0.07 }]), h * 0.75);
|
|
2023
2023
|
}
|
|
2024
2024
|
}
|
|
@@ -2032,7 +2032,7 @@ function xi(t, e, n, s, o) {
|
|
|
2032
2032
|
const f = [{ x: a.x, y: a.y }, { x: a.x + i * 0.1, y: a.y + h }];
|
|
2033
2033
|
t.line(et(e, f, a, o).points, s * 0.45 * r);
|
|
2034
2034
|
}
|
|
2035
|
-
const l = { x: i * 0.3, y: -0.38 }, c =
|
|
2035
|
+
const l = { x: i * 0.3, y: -0.38 }, c = Bt({ x: l.x, y: -0.31 }, { x: l.x + i * 0.07, y: -0.4 }, { x: l.x + i * 0.035, y: -0.49 });
|
|
2036
2036
|
t.line(et(e, c, l, o).points, s * 0.35 * r);
|
|
2037
2037
|
}
|
|
2038
2038
|
}
|
|
@@ -2040,7 +2040,7 @@ const Kn = "#8fd0f5", Vn = (t, e, n) => Array.from({ length: 18 }, (s, o) => {
|
|
|
2040
2040
|
const r = Math.PI * 2 * o / 18, i = Math.sin(r / 2);
|
|
2041
2041
|
return { x: t + Math.sin(r) * n * i, y: e - n * 0.9 + Math.cos(r) * n * 1.6 * (0.55 + 0.45 * i) - n * 0.4 };
|
|
2042
2042
|
});
|
|
2043
|
-
function
|
|
2043
|
+
function bi(t, e, n, s, o) {
|
|
2044
2044
|
const r = Math.min(1, Math.max(0, gt(n, "blush", 0))), i = Math.min(1, Math.max(0, gt(n, "tears", 0))), a = Math.min(1, Math.max(0, gt(n, "sweat", 0)));
|
|
2045
2045
|
if (!(r + i + a <= 0.01)) {
|
|
2046
2046
|
for (const l of [1, -1]) {
|
|
@@ -2068,7 +2068,7 @@ function wi(t, e, n, s, o) {
|
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
2070
|
}
|
|
2071
|
-
const
|
|
2071
|
+
const wi = 15;
|
|
2072
2072
|
function It(t, e) {
|
|
2073
2073
|
const n = Math.sqrt(Math.max(0, 1 - e * e));
|
|
2074
2074
|
return [n * Math.sin(t), e, n * Math.cos(t)];
|
|
@@ -2088,43 +2088,43 @@ function $e(t, e) {
|
|
|
2088
2088
|
const n = Math.abs(t - e) % (Math.PI * 2);
|
|
2089
2089
|
return n > Math.PI ? Math.PI * 2 - n : n;
|
|
2090
2090
|
}
|
|
2091
|
-
function
|
|
2092
|
-
const s = e.top ?? 1, o = e.bottom ?? -1, r = Math.max(8, Math.ceil((s - o) *
|
|
2091
|
+
function Be(t, e, n = 64) {
|
|
2092
|
+
const s = e.top ?? 1, o = e.bottom ?? -1, r = Math.max(8, Math.ceil((s - o) * wi)), i = (g) => Math.min(s, Math.max(o, s - (s - o) * (g - 1) / r)), a = (g) => -Math.PI + Math.PI * 2 * g / n, l = (g, m) => e.normal ? e.normal(g, m) : Mi(e.position(g, m)), c = r + 3, h = new Float64Array(n * c), f = new Float64Array(n * c);
|
|
2093
2093
|
for (let g = 0; g < c; g++) {
|
|
2094
2094
|
const m = g === 0 || g === c - 1, d = i(g);
|
|
2095
2095
|
for (let x = 0; x < n; x++) {
|
|
2096
|
-
const
|
|
2096
|
+
const w = g * n + x;
|
|
2097
2097
|
if (m) {
|
|
2098
|
-
h[
|
|
2098
|
+
h[w] = -1;
|
|
2099
2099
|
continue;
|
|
2100
2100
|
}
|
|
2101
|
-
const
|
|
2102
|
-
h[
|
|
2101
|
+
const M = a(x);
|
|
2102
|
+
h[w] = e.inside(M, d), f[w] = h[w] > -0.35 ? pt(t, l(M, d)) : 0;
|
|
2103
2103
|
}
|
|
2104
2104
|
}
|
|
2105
2105
|
const y = (g) => (g % n + n) % n, u = (g) => {
|
|
2106
2106
|
const m = n + 1, d = new Float64Array(m * c);
|
|
2107
|
-
for (let
|
|
2107
|
+
for (let b = 0; b < c; b++)
|
|
2108
2108
|
for (let E = 0; E <= n; E++) {
|
|
2109
|
-
const H =
|
|
2110
|
-
d[
|
|
2109
|
+
const H = b * n + (E === n ? 0 : E);
|
|
2110
|
+
d[b * m + E] = Math.min(h[H], g * f[H]);
|
|
2111
2111
|
}
|
|
2112
|
-
const x = (
|
|
2113
|
-
const D = x(
|
|
2114
|
-
return it(t, e.position(a(
|
|
2115
|
-
},
|
|
2116
|
-
const N = (H * n + y(E)) * 2 + (
|
|
2117
|
-
return R.has(N) || R.set(N,
|
|
2118
|
-
}, $ = (
|
|
2119
|
-
v[
|
|
2120
|
-
}, A = (
|
|
2121
|
-
$(
|
|
2112
|
+
const x = (b, E) => d[E * m + b], w = (b, E, H, N) => {
|
|
2113
|
+
const D = x(b, E), X = x(H, N), K = D === X ? 0.5 : Math.min(1, Math.max(0, D / (D - X)));
|
|
2114
|
+
return it(t, e.position(a(b + (H - b) * K), i(E + (N - E) * K)));
|
|
2115
|
+
}, M = n * c * 2, v = new Int32Array(M).fill(-1), P = new Int32Array(M).fill(-1), R = /* @__PURE__ */ new Map(), O = (b, E, H) => {
|
|
2116
|
+
const N = (H * n + y(E)) * 2 + (b ? 1 : 0);
|
|
2117
|
+
return R.has(N) || R.set(N, b ? w(y(E), H, y(E), H + 1) : w(E, H, E + 1, H)), N;
|
|
2118
|
+
}, $ = (b, E) => {
|
|
2119
|
+
v[b] === -1 ? v[b] = E : P[b] = E;
|
|
2120
|
+
}, A = (b, E) => {
|
|
2121
|
+
$(b, E), $(E, b);
|
|
2122
2122
|
};
|
|
2123
|
-
for (let
|
|
2123
|
+
for (let b = 0; b < c - 1; b++)
|
|
2124
2124
|
for (let E = 0; E < n; E++) {
|
|
2125
|
-
const H =
|
|
2125
|
+
const H = b * m + E, N = (d[H] > 0 ? 8 : 0) | (d[H + 1] > 0 ? 4 : 0) | (d[H + m + 1] > 0 ? 2 : 0) | (d[H + m] > 0 ? 1 : 0);
|
|
2126
2126
|
if (N === 0 || N === 15) continue;
|
|
2127
|
-
const D = () => O(!1, E,
|
|
2127
|
+
const D = () => O(!1, E, b), X = () => O(!1, E, b + 1), K = () => O(!0, E, b), q = () => O(!0, E + 1, b);
|
|
2128
2128
|
switch (N) {
|
|
2129
2129
|
case 1:
|
|
2130
2130
|
case 14:
|
|
@@ -2152,20 +2152,20 @@ function Ce(t, e, n = 64) {
|
|
|
2152
2152
|
break;
|
|
2153
2153
|
case 5:
|
|
2154
2154
|
case 10: {
|
|
2155
|
-
const J = (x(E,
|
|
2155
|
+
const J = (x(E, b) + x(E + 1, b) + x(E + 1, b + 1) + x(E, b + 1)) / 4 > 0;
|
|
2156
2156
|
N === 5 === J ? (A(K(), D()), A(X(), q())) : (A(K(), X()), A(D(), q()));
|
|
2157
2157
|
break;
|
|
2158
2158
|
}
|
|
2159
2159
|
}
|
|
2160
2160
|
}
|
|
2161
|
-
const z = [],
|
|
2162
|
-
for (const
|
|
2163
|
-
if (
|
|
2161
|
+
const z = [], B = new Uint8Array(M);
|
|
2162
|
+
for (const b of R.keys()) {
|
|
2163
|
+
if (B[b]) continue;
|
|
2164
2164
|
const E = [];
|
|
2165
|
-
let H = -1, N =
|
|
2166
|
-
for (; N !== -1 && !
|
|
2167
|
-
|
|
2168
|
-
const D = v[N], X = P[N], K = D !== -1 && D !== H && !
|
|
2165
|
+
let H = -1, N = b;
|
|
2166
|
+
for (; N !== -1 && !B[N]; ) {
|
|
2167
|
+
B[N] = 1, E.push(R.get(N));
|
|
2168
|
+
const D = v[N], X = P[N], K = D !== -1 && D !== H && !B[D] ? D : X !== -1 && X !== H && !B[X] ? X : -1;
|
|
2169
2169
|
H = N, N = K;
|
|
2170
2170
|
}
|
|
2171
2171
|
E.length >= 3 && z.push(E);
|
|
@@ -2222,12 +2222,12 @@ function vi(t) {
|
|
|
2222
2222
|
function Ei(t, e, n, s) {
|
|
2223
2223
|
const o = (t.path.length - 1) / 3, r = o * 20, i = [], a = [], l = s.trail !== 0 || s.lift !== 0, c = Math.max(0, e + n);
|
|
2224
2224
|
for (let h = 0; h <= r; h++) {
|
|
2225
|
-
const f = h / r, y = Math.min(o - 1, Math.floor(f * o)), u = f * o - y, g = 1 - u, m = [g ** 3, 3 * g * g * u, 3 * g * u * u, u ** 3], d = t.path.slice(y * 3, y * 3 + 4), x = Zn(d.reduce((H, N, D) => H + N.around * m[D], 0)),
|
|
2226
|
-
a.push(
|
|
2225
|
+
const f = h / r, y = Math.min(o - 1, Math.floor(f * o)), u = f * o - y, g = 1 - u, m = [g ** 3, 3 * g * g * u, 3 * g * u * u, u ** 3], d = t.path.slice(y * 3, y * 3 + 4), x = Zn(d.reduce((H, N, D) => H + N.around * m[D], 0)), w = d.reduce((H, N, D) => H + N.up * m[D], 0), M = d.reduce((H, N, D) => H + (N.lift ?? 0) * m[D], 0), v = 1 + e + n + M, P = w >= 0 ? Math.sqrt(Math.max(0, 1 - w * w)) : 1, R = f * f * (t.follow ?? 1), O = Zn(s.swing) * R, $ = x - O, A = [Math.sin($) * P * v, w * (w >= 0 ? v : 1), Math.cos($) * P * v], z = [A[0], A[1] + s.lift * R, A[2] - s.trail * R], B = [Math.sin($) * P, Math.max(0, w), Math.cos($) * P], b = cn(A), E = l && R > 0 ? Ke(z, c, b) : z;
|
|
2226
|
+
a.push(b), i.push({ center: E, normal: B, left: E, right: E, t: f });
|
|
2227
2227
|
}
|
|
2228
2228
|
return i.forEach((h, f) => {
|
|
2229
|
-
const y = i[Math.max(0, f - 1)].center, g = i[Math.min(r, f + 1)].center.map((x,
|
|
2230
|
-
h.left = h.center.map((x,
|
|
2229
|
+
const y = i[Math.max(0, f - 1)].center, g = i[Math.min(r, f + 1)].center.map((x, w) => x - y[w]), m = cn(ki(h.normal, g)), d = t.width * Math.sin(Math.PI * h.t) ** 0.6 * 0.5;
|
|
2230
|
+
h.left = h.center.map((x, w) => x + m[w] * d), h.right = h.center.map((x, w) => x - m[w] * d), l && h.t > 0 && (t.follow ?? 1) > 0 && (h.left = Ke(h.left, c, a[f]), h.right = Ke(h.right, c, a[f]));
|
|
2231
2231
|
}), i;
|
|
2232
2232
|
}
|
|
2233
2233
|
const te = (t, e, n) => t.map((s, o) => s + (e[o] - s) * n);
|
|
@@ -2263,10 +2263,10 @@ function Ko(t, e, n, s, o, r, i) {
|
|
|
2263
2263
|
if (t.shape([...y, ...u.slice().reverse()], n.color, 0), t.look === "clean" && (n.shine ?? 0) > 0) {
|
|
2264
2264
|
const m = f.filter((d) => d.t >= 0.2 && d.t <= 0.75);
|
|
2265
2265
|
if (m.length >= 3) {
|
|
2266
|
-
const d = m.map((
|
|
2267
|
-
const v = 0.16 * Math.sin(Math.PI *
|
|
2268
|
-
return it(e, te(
|
|
2269
|
-
}), x = m.map((
|
|
2266
|
+
const d = m.map((w, M) => {
|
|
2267
|
+
const v = 0.16 * Math.sin(Math.PI * M / (m.length - 1));
|
|
2268
|
+
return it(e, te(w.center, w.left, 0.16 + v));
|
|
2269
|
+
}), x = m.map((w) => it(e, te(w.center, w.left, 0.16)));
|
|
2270
2270
|
t.shape([...d, ...x.reverse()], `rgba(255,255,255,${n.shine})`, 0);
|
|
2271
2271
|
}
|
|
2272
2272
|
}
|
|
@@ -2494,17 +2494,17 @@ function Jo(t, e, n = fe) {
|
|
|
2494
2494
|
},
|
|
2495
2495
|
position(h, f) {
|
|
2496
2496
|
if (s && f < 0) {
|
|
2497
|
-
const
|
|
2497
|
+
const M = t.length < 1.5 ? 0.14 * ee(-t.length + 0.45, -t.length - 0.1, f) : 0, v = (t.fall?.taper ?? 0) * ee(0, -Math.max(0.1, a(h)), f), P = 1 + e + t.volume * (1 - M * 2.5) + no(t, h, f) - M - v;
|
|
2498
2498
|
return [P * Math.sin(h), f, P * Math.cos(h)];
|
|
2499
2499
|
}
|
|
2500
2500
|
const y = 0.4 + 0.6 * ee(0, 0.3, f - Le(t, h)), u = 1 + e + (t.volume + no(t, h, f)) * y, g = l(h, f, u);
|
|
2501
2501
|
if (g) return g;
|
|
2502
|
-
const [m, d, x] = It(h, f),
|
|
2502
|
+
const [m, d, x] = It(h, f), w = [m * u, d * u, x * u];
|
|
2503
2503
|
if (t.quiff > 0) {
|
|
2504
|
-
const
|
|
2505
|
-
|
|
2504
|
+
const M = t.quiff * Math.exp(-((h / 0.7) ** 2)) * ee(0.15, 0.85, f);
|
|
2505
|
+
w[1] += M * 0.7, w[2] += M * 0.45;
|
|
2506
2506
|
}
|
|
2507
|
-
return
|
|
2507
|
+
return w;
|
|
2508
2508
|
},
|
|
2509
2509
|
normal(h, f) {
|
|
2510
2510
|
return s && f < 0 ? [Math.sin(h), 0, Math.cos(h)] : It(h, f);
|
|
@@ -2527,16 +2527,16 @@ function Ii(t, e, n) {
|
|
|
2527
2527
|
normal: (r, i) => fn(t.normal(r + o(i), i), o(i))
|
|
2528
2528
|
};
|
|
2529
2529
|
}
|
|
2530
|
-
const
|
|
2530
|
+
const Ti = (t) => t.texture === "spiky" || t.texture === "curly" || t.texture === "locs" ? 104 : t.texture === "wavy" ? 80 : 64;
|
|
2531
2531
|
function Zo(t, e, n, s) {
|
|
2532
|
-
return kn(t, Hi(e, s), () =>
|
|
2532
|
+
return kn(t, Hi(e, s), () => Be(t, n, Ti(e)));
|
|
2533
2533
|
}
|
|
2534
2534
|
const oo = /* @__PURE__ */ new WeakMap();
|
|
2535
|
-
let
|
|
2535
|
+
let Wi = 1;
|
|
2536
2536
|
function Hi(t, e) {
|
|
2537
2537
|
if (Vo(e)) return t;
|
|
2538
2538
|
let n = oo.get(t);
|
|
2539
|
-
return n || oo.set(t, n =
|
|
2539
|
+
return n || oo.set(t, n = Wi++), `${n}:${e.swing}:${e.trail}:${e.lift}`;
|
|
2540
2540
|
}
|
|
2541
2541
|
function Qo(t) {
|
|
2542
2542
|
switch (t) {
|
|
@@ -2577,8 +2577,8 @@ function ts(t, e, n, s, o, r) {
|
|
|
2577
2577
|
t.ellipse(d.x, d.y, m * e.rx, m * e.ry, e.angle, n.color, h);
|
|
2578
2578
|
const x = m * e.rx * 0.55;
|
|
2579
2579
|
t.line(
|
|
2580
|
-
Array.from({ length: 9 }, (
|
|
2581
|
-
const v = -0.4 +
|
|
2580
|
+
Array.from({ length: 9 }, (w, M) => {
|
|
2581
|
+
const v = -0.4 + M / 8 * Math.PI * 1.3;
|
|
2582
2582
|
return { x: d.x + Math.cos(v) * x, y: d.y + Math.sin(v) * x * 0.8 };
|
|
2583
2583
|
}),
|
|
2584
2584
|
f
|
|
@@ -2590,12 +2590,12 @@ function ts(t, e, n, s, o, r) {
|
|
|
2590
2590
|
t.shape(ut(y, u, u * 0.15), n.color, h), t.line(y.slice(3, y.length - 3), f);
|
|
2591
2591
|
else {
|
|
2592
2592
|
const d = y.slice(0, y.length - 3);
|
|
2593
|
-
for (let
|
|
2594
|
-
const v = d[Math.floor(
|
|
2593
|
+
for (let M = 0; M < 7; M++) {
|
|
2594
|
+
const v = d[Math.floor(M / 7 * (d.length - 1))], P = d[Math.floor((M + 1) / 7 * (d.length - 1))], R = Math.atan2(P.y - v.y, P.x - v.x), O = Math.hypot(P.x - v.x, P.y - v.y), $ = u * (1 - M / (7 * 2.2)), A = (M % 2 === 0 ? 1 : -1) * 0.35, z = { x: (v.x + P.x) / 2, y: (v.y + P.y) / 2 };
|
|
2595
2595
|
t.ellipse(z.x, z.y, O * 0.62, $ * 0.5, R + A, n.color, h * 0.8);
|
|
2596
2596
|
}
|
|
2597
|
-
const x = d[d.length - 1],
|
|
2598
|
-
t.shape(ut([x,
|
|
2597
|
+
const x = d[d.length - 1], w = y[y.length - 1];
|
|
2598
|
+
t.shape(ut([x, w], u * 0.7, u * 0.2), n.color, h * 0.8);
|
|
2599
2599
|
}
|
|
2600
2600
|
const g = y[s.kind === "braid" ? y.length - 4 : 2];
|
|
2601
2601
|
t.ellipse(g.x, g.y, u * 0.32, u * 0.22, e.angle, n.color, h);
|
|
@@ -2630,7 +2630,7 @@ function Li(t) {
|
|
|
2630
2630
|
return [];
|
|
2631
2631
|
}
|
|
2632
2632
|
}
|
|
2633
|
-
function
|
|
2633
|
+
function Ci(t, e, n, s, o) {
|
|
2634
2634
|
if (s.fill === "stipple" || s.hairline.front > 1.5) return;
|
|
2635
2635
|
const r = o.motion ?? fe, i = o.lineWidth * 0.45 / n.rx, { far: a } = Zo(n, s, Jo(s, i, r), r);
|
|
2636
2636
|
vn(e, n, () => {
|
|
@@ -2674,7 +2674,7 @@ function ns(t, e, n, s, o, r) {
|
|
|
2674
2674
|
if (pt(e, a) >= 0 !== r) continue;
|
|
2675
2675
|
const l = [Math.cos(Ut(i.around)), 0, -Math.sin(Ut(i.around))], c = [a[1] * l[2], a[2] * l[0] - a[0] * l[2], -a[1] * l[0]], h = 1 + n.volume + o, f = Math.max(0, i.width), y = Math.max(0, i.length), u = [it(e, a.map((g) => g * (h + y)))];
|
|
2676
2676
|
for (let g = 0; g < 8; g++) {
|
|
2677
|
-
const m = g * Math.PI / 4, d = a.map((x,
|
|
2677
|
+
const m = g * Math.PI / 4, d = a.map((x, w) => x * h + f * (l[w] * Math.cos(m) + c[w] * Math.sin(m)));
|
|
2678
2678
|
u.push(it(e, d));
|
|
2679
2679
|
}
|
|
2680
2680
|
t.shape(Mn(u), n.color, Fe(s));
|
|
@@ -2691,8 +2691,8 @@ function ss(t, e, n, s, o) {
|
|
|
2691
2691
|
const f = it(e, r), y = e.rx * (0.12 + 0.08 * a);
|
|
2692
2692
|
t.ellipse(f.x, f.y, y, h, e.angle, c, l);
|
|
2693
2693
|
const u = Math.cos(e.angle), g = Math.sin(e.angle), m = Array.from({ length: 9 }, (d, x) => {
|
|
2694
|
-
const
|
|
2695
|
-
return { x: f.x +
|
|
2694
|
+
const w = -Math.PI * 0.55 + x / 8 * Math.PI * 1.1, M = Math.cos(w) * y * 0.45 * -n, v = Math.sin(w) * h * 0.55;
|
|
2695
|
+
return { x: f.x + M * u - v * g, y: f.y + M * g + v * u };
|
|
2696
2696
|
});
|
|
2697
2697
|
t.line(m, Math.max(0.8, l * 0.7));
|
|
2698
2698
|
}
|
|
@@ -2701,7 +2701,7 @@ function Ri(t, e, n, s) {
|
|
|
2701
2701
|
for (const o of [1, -1]) pt(n, En(o).out) < os && ss(t, n, o, s, !1);
|
|
2702
2702
|
}, s.headOutline);
|
|
2703
2703
|
}
|
|
2704
|
-
function
|
|
2704
|
+
function Bi(t, e, n) {
|
|
2705
2705
|
for (const s of [1, -1]) pt(e, En(s).out) >= os && ss(t, e, s, n, !0);
|
|
2706
2706
|
}
|
|
2707
2707
|
const Fi = {
|
|
@@ -2735,7 +2735,7 @@ function Ni(t, e) {
|
|
|
2735
2735
|
beard: n.beard ?? s?.beard ?? "none"
|
|
2736
2736
|
};
|
|
2737
2737
|
}
|
|
2738
|
-
const
|
|
2738
|
+
const Ct = (t) => t * Math.PI / 180, Ae = (t, e, n) => {
|
|
2739
2739
|
const s = Math.min(1, Math.max(0, (n - t) / (e - t)));
|
|
2740
2740
|
return s * s * (3 - 2 * s);
|
|
2741
2741
|
}, rs = {
|
|
@@ -2750,15 +2750,15 @@ const Bt = (t) => t * Math.PI / 180, Ae = (t, e, n) => {
|
|
|
2750
2750
|
sideburns: { top: [0.08, 0.08], reach: 100, band: 0.42, length: 0, shape: "round", volume: 0.05, aroundMouth: !1 },
|
|
2751
2751
|
muttonChops: { top: [0.08, 0.08], reach: 100, band: 0.75, length: 0, shape: "round", volume: 0.08, aroundMouth: !1 }
|
|
2752
2752
|
}, Yi = (t, e) => {
|
|
2753
|
-
const n = Ae(
|
|
2753
|
+
const n = Ae(Ct(48), Ct(100), $e(e, 0));
|
|
2754
2754
|
return t.top[0] + (t.top[1] - t.top[0]) * n;
|
|
2755
2755
|
}, zi = (t) => t === "sideburns" || t === "muttonChops";
|
|
2756
2756
|
function gn(t, e) {
|
|
2757
2757
|
const n = rs[t];
|
|
2758
2758
|
if (!n) return null;
|
|
2759
|
-
const s =
|
|
2759
|
+
const s = Ct(n.reach), o = (r) => {
|
|
2760
2760
|
const i = $e(r, 0);
|
|
2761
|
-
return n.shape === "point" ? Math.exp(-((i / 0.42) ** 2)) : n.shape === "square" ? 1 - Ae(
|
|
2761
|
+
return n.shape === "point" ? Math.exp(-((i / 0.42) ** 2)) : n.shape === "square" ? 1 - Ae(Ct(45), Ct(85), i) : Math.cos(Math.min(i, Math.PI / 2)) ** 0.7;
|
|
2762
2762
|
};
|
|
2763
2763
|
return {
|
|
2764
2764
|
top: Math.max(n.top[0], n.top[1]) + 0.05,
|
|
@@ -2767,7 +2767,7 @@ function gn(t, e) {
|
|
|
2767
2767
|
const a = $e(r, 0), l = Yi(n, r);
|
|
2768
2768
|
let c = Math.min(l - i, s - a);
|
|
2769
2769
|
if (n.band > 0 && (c = Math.min(c, i - (l - n.band))), zi(t)) {
|
|
2770
|
-
const h = t === "muttonChops" ?
|
|
2770
|
+
const h = t === "muttonChops" ? Ct(70) - Ct(22) * Ae(0.08, -0.6, i) : Ct(72);
|
|
2771
2771
|
c = Math.min(c, a - h);
|
|
2772
2772
|
}
|
|
2773
2773
|
return c;
|
|
@@ -2809,7 +2809,7 @@ function qi(t, e, n, s) {
|
|
|
2809
2809
|
function Ui(t, e, n, s, o) {
|
|
2810
2810
|
const r = s.beard === "stubble" ? null : gn(s.beard, o.lineWidth * 0.45 / n.rx);
|
|
2811
2811
|
if (!r) return;
|
|
2812
|
-
const { far: i } = kn(n, s, () =>
|
|
2812
|
+
const { far: i } = kn(n, s, () => Be(n, r));
|
|
2813
2813
|
vn(e, n, () => {
|
|
2814
2814
|
for (const a of i) t.shape(a, s.color, ue(o.lineWidth));
|
|
2815
2815
|
}, o.headOutline);
|
|
@@ -2828,7 +2828,7 @@ function Xi(t, e, n, s, o) {
|
|
|
2828
2828
|
}
|
|
2829
2829
|
const i = gn(n.beard, r);
|
|
2830
2830
|
if (!i) return;
|
|
2831
|
-
const { near: a } = kn(e, n, () =>
|
|
2831
|
+
const { near: a } = kn(e, n, () => Be(e, i));
|
|
2832
2832
|
for (const l of a) t.shape(l, n.color, ue(s.lineWidth));
|
|
2833
2833
|
if (rs[n.beard]?.aroundMouth) {
|
|
2834
2834
|
const l = 0.27 * Math.max(0.3, o), c = Array.from({ length: 20 }, (y, u) => {
|
|
@@ -2953,13 +2953,13 @@ function na(t) {
|
|
|
2953
2953
|
function as(t, e, n, s) {
|
|
2954
2954
|
const o = is[n.style], i = 1 + s.lineWidth * 0.45 / e.rx + Math.max(0.05, Math.min(0.3, s.hairVolume) + 0.04), a = Math.max(1, s.lineWidth * 0.5), l = ea(e, o, i);
|
|
2955
2955
|
l && t.shape(l, n.color, a);
|
|
2956
|
-
const c = ta(o, i), { near: h, far: f } =
|
|
2956
|
+
const c = ta(o, i), { near: h, far: f } = Be(e, c);
|
|
2957
2957
|
for (const u of [...f, ...h]) t.shape(u, n.color, a);
|
|
2958
2958
|
const y = Math.max(0.8, a * 0.7);
|
|
2959
2959
|
for (const u of na(o)) {
|
|
2960
2960
|
const g = u.map(([d, x]) => {
|
|
2961
|
-
const [
|
|
2962
|
-
return [
|
|
2961
|
+
const [w, M, v] = c.position(d, x);
|
|
2962
|
+
return [w * 0.99, M * 0.99, v * 0.99];
|
|
2963
2963
|
}), m = u.map(([d, x]) => It(d, x));
|
|
2964
2964
|
for (const d of Go(e, g, m, 0.1)) t.line(d, y);
|
|
2965
2965
|
}
|
|
@@ -2982,7 +2982,7 @@ const ls = (t) => !t.hair && !t.facialHair && !t.glasses && !t.hat && !t.ears, h
|
|
|
2982
2982
|
function fs(t, e, n, s, o, r) {
|
|
2983
2983
|
if (ls(n)) return;
|
|
2984
2984
|
const i = { ...r, headOutline: r.face && (r.face.shape === "angular" || r.face.projection === "volume") ? qo(s, r.face) : void 0 };
|
|
2985
|
-
n.hair &&
|
|
2985
|
+
n.hair && Ci(e, t, s, n.hair, { ...i, motion: _e(o) }), n.facialHair && Ui(e, t, s, n.facialHair, i), cs(n) && Ri(e, t, s, i);
|
|
2986
2986
|
}
|
|
2987
2987
|
function sa(t, e, n, s, o, r, i) {
|
|
2988
2988
|
if (ls(n)) {
|
|
@@ -2990,7 +2990,7 @@ function sa(t, e, n, s, o, r, i) {
|
|
|
2990
2990
|
return;
|
|
2991
2991
|
}
|
|
2992
2992
|
const a = hs(s);
|
|
2993
|
-
cs(n) &&
|
|
2993
|
+
cs(n) && Bi(e, s, r), n.hair && !a && !r.faceUnderHair && dn(e, s, n.hair, { ...r, motion: _e(o) }), n.facialHair && Xi(e, s, n.facialHair, r, o.mouthWidth ?? 1), i(), n.hair && !a && r.faceUnderHair && dn(e, s, n.hair, { ...r, motion: _e(o) }), n.facialHair && Gi(e, s, n.facialHair, r), n.glasses && Qi(e, s, n.glasses, r), n.hat && !a && as(e, s, n.hat, { lineWidth: r.lineWidth, hairVolume: n.hair?.volume ?? 0 });
|
|
2994
2994
|
}
|
|
2995
2995
|
function us(t, e, n, s, o, r) {
|
|
2996
2996
|
hs(s) && (n.hair && dn(e, s, n.hair, { ...r, motion: _e(o) }), n.hat && as(e, s, n.hat, { lineWidth: r.lineWidth, hairVolume: n.hair?.volume ?? 0 }));
|
|
@@ -3001,14 +3001,14 @@ const ro = 40, ra = 0.215 + 0.205, Mt = (t, e) => {
|
|
|
3001
3001
|
return n;
|
|
3002
3002
|
}, G = (t, e) => t[e] ?? at[e] ?? 0;
|
|
3003
3003
|
function ia(t, e, n = at, s = 1) {
|
|
3004
|
-
const o =
|
|
3004
|
+
const o = Ce(t), r = e * Math.PI * 2, i = Math.sin(r) * s, a = Math.cos(r) * s, l = (1 + Math.cos(r * 2 * (o.bounces ?? 1))) / 2, c = o.crouch ?? 0, h = o.shoulder ?? 0, f = o.forearm ?? 0, y = { ...at, ...n };
|
|
3005
3005
|
y["leg.left.swing"] = o.swing * i + c * 0.6, y["leg.right.swing"] = -o.swing * i + c * 0.6, y["leg.left.knee"] = o.knee * Math.max(0, a) + c * 1.2, y["leg.right.knee"] = o.knee * Math.max(0, -a) + c * 1.2, y["leg.left.ankle"] = G(n, "leg.left.ankle") - (o.tiptoe ?? 0), y["leg.right.ankle"] = G(n, "leg.right.ankle") - (o.tiptoe ?? 0);
|
|
3006
3006
|
for (const [u, g] of [["left", -1], ["right", 1]])
|
|
3007
3007
|
G(n, `arm.${u}.spread`) > ro || G(n, `arm.${u}.swing`) > ro || (y[`arm.${u}.swing`] = h + g * o.arm * i, y[`arm.${u}.elbow`] = G(n, `arm.${u}.elbow`) + f + o.elbow * Math.max(0, g * i));
|
|
3008
3008
|
return y.lean = G(n, "lean") + o.lean * s, y.bend = G(n, "bend") + (o.bend ?? 0), y["head.nod"] = G(n, "head.nod") - o.lean * 0.5 * s + (o.headTilt ?? 0), y.side = G(n, "side") + (o.sway ?? 0) * Math.sin(r), y.lift = G(n, "lift") + (o.bounce ?? 0) * s * l, y.stretch = G(n, "stretch") * (1 + (o.squash ?? 0) * (l - 0.5)), y;
|
|
3009
3009
|
}
|
|
3010
3010
|
function Ga(t, e, n = 1, s = 1) {
|
|
3011
|
-
const o =
|
|
3011
|
+
const o = Ce(t);
|
|
3012
3012
|
return 4 * ra * s * e * Math.sin(o.swing * n * Math.PI / 180);
|
|
3013
3013
|
}
|
|
3014
3014
|
const Vt = (t) => jr[t], aa = {
|
|
@@ -3194,8 +3194,8 @@ function ho(t, e, n, s, o, r) {
|
|
|
3194
3194
|
const m = { x: a + f * (g / 4 + (u ? 0.07 : -0.04)), y: c + y * (u ? 0.38 : -0.1) }, d = { x: m.x + f * 0.09, y: m.y + y * 0.78 };
|
|
3195
3195
|
n.shape(fa(m, d, f * 0.13), (g + u) % 2 ? o : r, i * 0.6), n.line([m, { x: m.x * 0.45 + d.x * 0.55, y: m.y * 0.45 + d.y * 0.55 }, d], i * 0.45);
|
|
3196
3196
|
for (const x of [0.32, 0.52, 0.7]) {
|
|
3197
|
-
const
|
|
3198
|
-
n.line([{ x:
|
|
3197
|
+
const w = { x: m.x + (d.x - m.x) * x, y: m.y + (d.y - m.y) * x };
|
|
3198
|
+
n.line([{ x: w.x - f * 0.045, y: w.y - y * 0.065 }, w, { x: w.x + f * 0.045, y: w.y - y * 0.05 }], i * 0.3);
|
|
3199
3199
|
}
|
|
3200
3200
|
}
|
|
3201
3201
|
t.restore();
|
|
@@ -3226,136 +3226,136 @@ function uo(t, e, n = 0) {
|
|
|
3226
3226
|
function ya(t = {}) {
|
|
3227
3227
|
if (t = { ...t }, t.top !== void 0 && !["tshirt", "shirt", "blouse", "dress"].includes(t.top)) throw new Error(`basicOutfit: unknown top '${t.top}'`);
|
|
3228
3228
|
if (t.trouserStyle !== void 0 && !["plain", "jeans", "cargo"].includes(t.trouserStyle)) throw new Error(`basicOutfit: unknown trouser style '${t.trouserStyle}'`);
|
|
3229
|
-
const e = t.top, n = t.trouserStyle ?? "plain", s = t.collar ?? e === "shirt", o = t.shirt ?? "#e2493b", r = e === "dress" ? o : t.trousers ?? "#24476b", i = t.sleeves ?? "short", a = e === "dress" ? "skirt" : t.bottom ?? "trousers", l = t.over === "labCoat", c = t.over === "hoodie", h = t.over === "cardigan", f = t.over === "overalls", y = t.over === "sari", u = t.overColor ?? (t.over && t.over !== "overalls" ? da[t.over] : r), g = t.shoes === "boots", m = t.shoeColor ?? "#3b2a1e", d = (p) => p.lineWidth * 0.45, x = (p,
|
|
3230
|
-
const _ =
|
|
3229
|
+
const e = t.top, n = t.trouserStyle ?? "plain", s = t.collar ?? e === "shirt", o = t.shirt ?? "#e2493b", r = e === "dress" ? o : t.trousers ?? "#24476b", i = t.sleeves ?? "short", a = e === "dress" ? "skirt" : t.bottom ?? "trousers", l = t.over === "labCoat", c = t.over === "hoodie", h = t.over === "cardigan", f = t.over === "overalls", y = t.over === "sari", u = t.overColor ?? (t.over && t.over !== "overalls" ? da[t.over] : r), g = t.shoes === "boots", m = t.shoeColor ?? "#3b2a1e", d = (p) => p.lineWidth * 0.45, x = (p, k, I, T) => {
|
|
3230
|
+
const _ = k.parts[`leg.${T}`].points;
|
|
3231
3231
|
if (a === "skirt" && !f) return;
|
|
3232
|
-
const
|
|
3233
|
-
I.shape(F, r, d(
|
|
3234
|
-
const S = (
|
|
3232
|
+
const W = a === "shorts" && !f, L = k.bodyContours?.[`leg.${T}`], F = L ? Ge(L, 0, W ? 0.5 : 1, k.height * 6e-3) : ut(W ? Ze(_, 0, 0.5) : _, k.height * (W ? 0.085 : 0.08), k.height * (W ? 0.07 : 0.05));
|
|
3233
|
+
I.shape(F, r, d(k)), !(n === "plain" || mt(k) < 0.15) && fo(p, F, () => {
|
|
3234
|
+
const S = (C, Y = 0) => uo(_, C, Y * k.height);
|
|
3235
3235
|
if (n === "jeans")
|
|
3236
|
-
I.line([S(0.07, -0.018), S(0.17, -0.02), S(0.23, 0), S(0.17, 0.02), S(0.07, 0.018)], d(
|
|
3236
|
+
I.line([S(0.07, -0.018), S(0.17, -0.02), S(0.23, 0), S(0.17, 0.02), S(0.07, 0.018)], d(k) * 0.65), I.line([S(0.27, 0.013), ...[0.4, 0.55, 0.7, 0.85, 0.96].filter((C) => !W || C < 0.5).map((C) => S(C, 0.013))], d(k) * 0.5);
|
|
3237
3237
|
else {
|
|
3238
|
-
const
|
|
3239
|
-
I.shape(
|
|
3238
|
+
const C = [S(0.25, -0.024), S(0.25, 0.024), S(0.43, 0.024), S(0.43, -0.024)];
|
|
3239
|
+
I.shape(C, r, d(k) * 0.65), I.line([S(0.28, -0.024), S(0.32, 0), S(0.28, 0.024)], d(k) * 0.65);
|
|
3240
3240
|
const Y = S(0.32);
|
|
3241
|
-
I.dot(Y.x, Y.y, d(
|
|
3241
|
+
I.dot(Y.x, Y.y, d(k) * 0.8);
|
|
3242
3242
|
}
|
|
3243
3243
|
});
|
|
3244
|
-
},
|
|
3245
|
-
const
|
|
3244
|
+
}, w = (p, k, I) => {
|
|
3245
|
+
const T = p.parts[`leg.${I}`].points, _ = Ze(T, 0.7, 1);
|
|
3246
3246
|
if (_.length < 2) return;
|
|
3247
|
-
|
|
3248
|
-
const
|
|
3249
|
-
|
|
3250
|
-
},
|
|
3251
|
-
const
|
|
3252
|
-
return { hip: I, top:
|
|
3247
|
+
k.shape(ut(_, p.height * 0.075, p.height * 0.07), m, d(p));
|
|
3248
|
+
const W = _[0], L = _[1], F = L.x - W.x, S = L.y - W.y, C = Math.hypot(F, S) || 1, Y = p.height * 0.04;
|
|
3249
|
+
k.line([{ x: W.x - S / C * Y, y: W.y + F / C * Y }, { x: W.x + S / C * Y, y: W.y - F / C * Y }], d(p) * 0.9);
|
|
3250
|
+
}, M = (p) => {
|
|
3251
|
+
const k = p.chains.spine, I = k[0], T = k[k.length - 1], _ = { x: I.x - (T.x - I.x) * 0.25, y: I.y - (T.y - I.y) * 0.25 };
|
|
3252
|
+
return { hip: I, top: T, below: _, line: [_, ...p.parts.spine.points] };
|
|
3253
3253
|
}, v = (p) => {
|
|
3254
3254
|
if (p.bodyContours?.spine) return Ge(p.bodyContours.spine, 0, 0.97, p.height * (c ? 0.014 : 6e-3));
|
|
3255
|
-
const
|
|
3256
|
-
return ut(
|
|
3257
|
-
}, P = (p,
|
|
3258
|
-
const I = [v(
|
|
3259
|
-
h && I.push(ut([
|
|
3260
|
-
const
|
|
3255
|
+
const k = c ? 1.14 : 1, I = Math.hypot(p.points["hip.left"].x - p.points["hip.right"].x, p.points["hip.left"].y - p.points["hip.right"].y), T = Math.max(p.height * 0.15 * k, I + Math.max(p.height * 0.08, p.lineWidth * 1.45) + d(p));
|
|
3256
|
+
return ut(M(p).line, T, p.height * 0.14 * k);
|
|
3257
|
+
}, P = (p, k) => {
|
|
3258
|
+
const I = [v(k)], { top: T, hip: _ } = M(k);
|
|
3259
|
+
h && I.push(ut([T, Z(T, _, 0.5), Z(T, _, 1.08)], k.height * 0.155, k.height * 0.15)), l && I.push(ut([T, Z(T, _, 0.5), _], k.height * 0.14, k.height * 0.15));
|
|
3260
|
+
const W = Object.values(k.points), L = Math.min(...W.map((Y) => Y.x)) - k.height, F = Math.min(...W.map((Y) => Y.y)) - k.height, S = Math.max(...W.map((Y) => Y.x)) + k.height, C = Math.max(...W.map((Y) => Y.y)) + k.height;
|
|
3261
3261
|
for (const Y of I) {
|
|
3262
|
-
p.beginPath(), p.rect(L, F, S - L,
|
|
3262
|
+
p.beginPath(), p.rect(L, F, S - L, C - F), p.moveTo(Y[0].x, Y[0].y);
|
|
3263
3263
|
for (const V of Y.slice(1)) p.lineTo(V.x, V.y);
|
|
3264
3264
|
p.closePath(), p.clip("evenodd");
|
|
3265
3265
|
}
|
|
3266
|
-
}, R = (p,
|
|
3266
|
+
}, R = (p, k) => {
|
|
3267
3267
|
const I = c ? u : o;
|
|
3268
|
-
|
|
3269
|
-
}, O = (p,
|
|
3270
|
-
const
|
|
3271
|
-
if (!e ||
|
|
3272
|
-
const { top: _, hip:
|
|
3273
|
-
fo(p, v(
|
|
3268
|
+
k.shape(v(p), I, d(p));
|
|
3269
|
+
}, O = (p, k, I) => {
|
|
3270
|
+
const T = mt(k);
|
|
3271
|
+
if (!e || T < 0.2 || c) return;
|
|
3272
|
+
const { top: _, hip: W } = M(k), L = Ht(k) * k.height * 0.025, F = [_, W], S = (C, Y = 0) => uo(F, C, L + Y * k.height * T);
|
|
3273
|
+
fo(p, v(k), () => {
|
|
3274
3274
|
if (e === "shirt") {
|
|
3275
|
-
I.line([S(0.12), S(0.92)], d(
|
|
3276
|
-
for (const
|
|
3277
|
-
const Y = S(
|
|
3278
|
-
I.dot(Y.x, Y.y, d(
|
|
3275
|
+
I.line([S(0.12), S(0.92)], d(k) * 0.65);
|
|
3276
|
+
for (const C of [0.24, 0.4, 0.56, 0.72, 0.88]) {
|
|
3277
|
+
const Y = S(C, 8e-3);
|
|
3278
|
+
I.dot(Y.x, Y.y, d(k) * 0.9);
|
|
3279
3279
|
}
|
|
3280
3280
|
} else if (e === "blouse") {
|
|
3281
|
-
I.line([S(0.025, -0.04), S(0.24), S(0.025, 0.04)], d(
|
|
3282
|
-
const
|
|
3283
|
-
I.dot(
|
|
3284
|
-
} else e === "dress" ? I.line([S(0.04, -0.035), S(0.17, -0.028), S(0.17, 0.028), S(0.04, 0.035)], d(
|
|
3281
|
+
I.line([S(0.025, -0.04), S(0.24), S(0.025, 0.04)], d(k) * 0.75);
|
|
3282
|
+
const C = S(0.31);
|
|
3283
|
+
I.dot(C.x, C.y, d(k));
|
|
3284
|
+
} else e === "dress" ? I.line([S(0.04, -0.035), S(0.17, -0.028), S(0.17, 0.028), S(0.04, 0.035)], d(k) * 0.75) : I.line([S(0.025, -0.035), S(0.1, -0.02), S(0.12), S(0.1, 0.02), S(0.025, 0.035)], d(k) * 0.65);
|
|
3285
3285
|
});
|
|
3286
|
-
}, $ = (p,
|
|
3287
|
-
const I = mt(p), { top:
|
|
3286
|
+
}, $ = (p, k) => {
|
|
3287
|
+
const I = mt(p), { top: T, hip: _ } = M(p), W = p.height * 0.07, L = { x: (T.x - _.x) * 0.16, y: (T.y - _.y) * 0.16 };
|
|
3288
3288
|
if (I >= 0) {
|
|
3289
|
-
|
|
3289
|
+
k.shape(
|
|
3290
3290
|
[
|
|
3291
|
-
{ x:
|
|
3292
|
-
{ x:
|
|
3293
|
-
{ x:
|
|
3294
|
-
{ x:
|
|
3295
|
-
{ x:
|
|
3291
|
+
{ x: T.x - W, y: T.y + L.y * 0.25 },
|
|
3292
|
+
{ x: T.x - W * 0.8 + L.x, y: T.y + L.y },
|
|
3293
|
+
{ x: T.x + L.x * 1.2, y: T.y + L.y * 1.35 },
|
|
3294
|
+
{ x: T.x + W * 0.8 + L.x, y: T.y + L.y },
|
|
3295
|
+
{ x: T.x + W, y: T.y + L.y * 0.25 }
|
|
3296
3296
|
],
|
|
3297
3297
|
u,
|
|
3298
3298
|
d(p)
|
|
3299
3299
|
);
|
|
3300
3300
|
return;
|
|
3301
3301
|
}
|
|
3302
|
-
const F = Z(
|
|
3303
|
-
|
|
3302
|
+
const F = Z(T, _, 0.42);
|
|
3303
|
+
k.shape(
|
|
3304
3304
|
[
|
|
3305
|
-
{ x:
|
|
3306
|
-
{ x:
|
|
3307
|
-
{ x: F.x +
|
|
3305
|
+
{ x: T.x - W * 0.9, y: T.y },
|
|
3306
|
+
{ x: T.x + W * 0.9, y: T.y },
|
|
3307
|
+
{ x: F.x + W * 0.7, y: F.y },
|
|
3308
3308
|
{ x: F.x, y: F.y + p.height * 0.02 },
|
|
3309
|
-
{ x: F.x -
|
|
3309
|
+
{ x: F.x - W * 0.7, y: F.y }
|
|
3310
3310
|
],
|
|
3311
3311
|
u,
|
|
3312
3312
|
d(p)
|
|
3313
3313
|
);
|
|
3314
|
-
}, A = (p,
|
|
3314
|
+
}, A = (p, k) => {
|
|
3315
3315
|
const I = mt(p);
|
|
3316
3316
|
if (I < 0.2) return;
|
|
3317
|
-
const { top:
|
|
3318
|
-
|
|
3319
|
-
const
|
|
3320
|
-
for (const Y of [-1, 1])
|
|
3321
|
-
}, z = (p,
|
|
3322
|
-
const { top: I, hip:
|
|
3323
|
-
if (
|
|
3324
|
-
const
|
|
3325
|
-
|
|
3326
|
-
for (const
|
|
3327
|
-
const Y = Z(I,
|
|
3328
|
-
|
|
3317
|
+
const { top: T, hip: _ } = M(p), W = Ht(p) * p.height * 0.03, L = p.height * 0.06 * I, F = Z(T, _, 0.62), S = Z(T, _, 0.9);
|
|
3318
|
+
k.line([{ x: F.x + W - L, y: F.y }, { x: S.x + W - L * 1.1, y: S.y }], d(p) * 0.7), k.line([{ x: F.x + W + L, y: F.y }, { x: S.x + W + L * 1.1, y: S.y }], d(p) * 0.7);
|
|
3319
|
+
const C = Z(T, _, 0.1);
|
|
3320
|
+
for (const Y of [-1, 1]) k.line([{ x: C.x + W + Y * L * 0.2, y: C.y }, { x: C.x + W + Y * L * 0.35, y: C.y + p.height * 0.07 }], d(p) * 0.6);
|
|
3321
|
+
}, z = (p, k) => {
|
|
3322
|
+
const { top: I, hip: T } = M(p), _ = mt(p);
|
|
3323
|
+
if (k.shape(ut([I, Z(I, T, 0.5), Z(I, T, 1.08)], p.height * 0.155, p.height * 0.15), u, d(p)), _ < 0.2) return;
|
|
3324
|
+
const W = Ht(p) * p.height * 0.03, L = p.height * 0.02 * _, F = Z(I, T, 0.12), S = Z(I, T, 1.05);
|
|
3325
|
+
k.shape([{ x: F.x + W - L, y: F.y }, { x: F.x + W + L, y: F.y }, { x: S.x + W + L * 1.3, y: S.y }, { x: S.x + W - L * 1.3, y: S.y }], o, d(p) * 0.7);
|
|
3326
|
+
for (const C of [0.35, 0.55, 0.75]) {
|
|
3327
|
+
const Y = Z(I, T, C);
|
|
3328
|
+
k.dot(Y.x + W + L * 1.6, Y.y, d(p) * 1.2);
|
|
3329
3329
|
}
|
|
3330
|
-
},
|
|
3331
|
-
const I = mt(p), { top:
|
|
3330
|
+
}, B = (p, k) => {
|
|
3331
|
+
const I = mt(p), { top: T, hip: _ } = M(p), W = Ht(p) * p.height * 0.04, L = Z(_, T, 0.12), F = Z(_, T, 0.74);
|
|
3332
3332
|
if (I < 0.15) {
|
|
3333
3333
|
if (I < -0.3) {
|
|
3334
3334
|
const V = p.points["shoulder.left"], U = p.points["shoulder.right"];
|
|
3335
|
-
|
|
3335
|
+
k.line([V, { x: L.x + p.height * 0.03, y: L.y }], d(p) * 0.8), k.line([U, { x: L.x - p.height * 0.03, y: L.y }], d(p) * 0.8);
|
|
3336
3336
|
}
|
|
3337
3337
|
return;
|
|
3338
3338
|
}
|
|
3339
3339
|
const S = p.height * 0.07 * I;
|
|
3340
|
-
|
|
3340
|
+
k.shape(
|
|
3341
3341
|
[
|
|
3342
|
-
{ x: F.x +
|
|
3343
|
-
{ x: F.x +
|
|
3344
|
-
{ x: L.x +
|
|
3345
|
-
{ x: L.x +
|
|
3342
|
+
{ x: F.x + W - S * 0.75, y: F.y },
|
|
3343
|
+
{ x: F.x + W + S * 0.75, y: F.y },
|
|
3344
|
+
{ x: L.x + W + S * 1.1, y: L.y },
|
|
3345
|
+
{ x: L.x + W - S * 1.1, y: L.y }
|
|
3346
3346
|
],
|
|
3347
3347
|
r,
|
|
3348
3348
|
d(p)
|
|
3349
3349
|
);
|
|
3350
3350
|
for (const V of ["left", "right"]) {
|
|
3351
|
-
const U = p.points[`shoulder.${V}`],
|
|
3352
|
-
|
|
3351
|
+
const U = p.points[`shoulder.${V}`], Tt = { x: F.x + W + (U.x > F.x + W ? 1 : -1) * S * 0.55, y: F.y };
|
|
3352
|
+
k.line([Tt, { x: U.x + (Tt.x - U.x) * 0.15, y: U.y + (Tt.y - U.y) * 0.15 }], d(p) * 1.6);
|
|
3353
3353
|
}
|
|
3354
|
-
const
|
|
3355
|
-
|
|
3356
|
-
},
|
|
3357
|
-
const { hip: I, top:
|
|
3358
|
-
if (
|
|
3354
|
+
const C = Z(F, L, 0.3), Y = S * 0.4;
|
|
3355
|
+
k.line([{ x: C.x + W - Y, y: C.y }, { x: C.x + W - Y, y: C.y + Y * 1.4 }, { x: C.x + W + Y, y: C.y + Y * 1.4 }, { x: C.x + W + Y, y: C.y }], d(p) * 0.6);
|
|
3356
|
+
}, b = (p, k) => {
|
|
3357
|
+
const { hip: I, top: T } = M(p), _ = Z(I, T, 0.2), W = [p.points["ankle.left"], p.points["ankle.right"]], L = Z(I, { x: (W[0].x + W[1].x) / 2, y: (W[0].y + W[1].y) / 2 }, 0.98), F = p.height * 0.075, S = Math.max(p.height * 0.12, Math.abs(W[0].x - W[1].x) / 2 + p.height * 0.07), C = L.x - _.x, Y = L.y - _.y, V = Math.hypot(C, Y) || 1, U = { x: -Y / V, y: C / V };
|
|
3358
|
+
if (k.shape(
|
|
3359
3359
|
[
|
|
3360
3360
|
{ x: _.x + U.x * F, y: _.y + U.y * F },
|
|
3361
3361
|
{ x: L.x + U.x * S, y: L.y + U.y * S },
|
|
@@ -3368,27 +3368,27 @@ function ya(t = {}) {
|
|
|
3368
3368
|
const Ft = Ht(p) * p.height * 0.03;
|
|
3369
3369
|
for (const se of [-0.35, 0, 0.35]) {
|
|
3370
3370
|
const ye = F * 0.5 * se, me = S * 0.45 * se;
|
|
3371
|
-
|
|
3371
|
+
k.line([{ x: _.x + Ft + U.x * ye, y: _.y + U.y * ye + p.height * 0.02 }, { x: L.x + Ft + U.x * me, y: L.y + U.y * me }], d(p) * 0.5);
|
|
3372
3372
|
}
|
|
3373
3373
|
}
|
|
3374
|
-
}, E = (p,
|
|
3375
|
-
const I = mt(p), { top:
|
|
3374
|
+
}, E = (p, k) => {
|
|
3375
|
+
const I = mt(p), { top: T, hip: _ } = M(p), W = Ht(p), L = W >= 0 ? "left" : "right", F = L === "left" ? "right" : "left", S = p.points[`shoulder.${L}`], C = p.height * 0.035;
|
|
3376
3376
|
if (I < 0.15) {
|
|
3377
|
-
const U = Z(
|
|
3378
|
-
|
|
3377
|
+
const U = Z(T, _, 0.9);
|
|
3378
|
+
k.shape(ut([S, { x: U.x + (S.x - T.x) * 0.5, y: U.y }], C * 2.2, C * 2.6), u, d(p));
|
|
3379
3379
|
return;
|
|
3380
3380
|
}
|
|
3381
|
-
const Y = { x: _.x + (p.points[`hip.${F}`].x - _.x) * 1.2, y: Z(_,
|
|
3382
|
-
|
|
3383
|
-
const V = { x: S.x - (_.x - S.x) * 0.05 -
|
|
3384
|
-
|
|
3385
|
-
}, H = (p,
|
|
3381
|
+
const Y = { x: _.x + (p.points[`hip.${F}`].x - _.x) * 1.2, y: Z(_, T, 0.08).y };
|
|
3382
|
+
k.shape(ut([Y, Z(Y, S, 0.5), S], C * 2.4, C * 2), u, d(p));
|
|
3383
|
+
const V = { x: S.x - (_.x - S.x) * 0.05 - W * p.height * 0.03, y: S.y + p.height * 0.16 };
|
|
3384
|
+
k.shape(ut([S, V], C * 2, C * 1.6), u, d(p));
|
|
3385
|
+
}, H = (p, k) => {
|
|
3386
3386
|
if (p.bodyContours) {
|
|
3387
|
-
|
|
3387
|
+
k.shape(gs(p, { top: !1, length: 0.45 }).skirt, r, d(p));
|
|
3388
3388
|
return;
|
|
3389
3389
|
}
|
|
3390
|
-
const { hip: I, top:
|
|
3391
|
-
|
|
3390
|
+
const { hip: I, top: T } = M(p), _ = Z(I, T, 0.18), W = [p.points["knee.left"], p.points["knee.right"]], L = Z(I, { x: (W[0].x + W[1].x) / 2, y: (W[0].y + W[1].y) / 2 }, 1.05), F = p.height * 0.075, S = Math.max(p.height * 0.13, Math.abs(W[0].x - W[1].x) / 2 + p.height * 0.08), C = L.x - _.x, Y = L.y - _.y, V = Math.hypot(C, Y) || 1, U = { x: -Y / V, y: C / V };
|
|
3391
|
+
k.shape(
|
|
3392
3392
|
[
|
|
3393
3393
|
{ x: _.x + U.x * F, y: _.y + U.y * F },
|
|
3394
3394
|
{ x: L.x + U.x * S, y: L.y + U.y * S },
|
|
@@ -3398,88 +3398,88 @@ function ya(t = {}) {
|
|
|
3398
3398
|
r,
|
|
3399
3399
|
d(p)
|
|
3400
3400
|
);
|
|
3401
|
-
}, N = (p,
|
|
3401
|
+
}, N = (p, k) => {
|
|
3402
3402
|
const I = mt(p);
|
|
3403
3403
|
if (I < 0.2) return;
|
|
3404
|
-
const { top:
|
|
3404
|
+
const { top: T, hip: _ } = M(p), W = { x: (_.x - T.x) * 0.12, y: (_.y - T.y) * 0.12 }, L = p.height * 0.045 * I;
|
|
3405
3405
|
for (const F of [-1, 1])
|
|
3406
|
-
|
|
3406
|
+
k.shape(
|
|
3407
3407
|
[
|
|
3408
|
-
{ x:
|
|
3409
|
-
{ x:
|
|
3410
|
-
{ x:
|
|
3408
|
+
{ x: T.x + F * L * 0.2, y: T.y + W.y * 0.1 },
|
|
3409
|
+
{ x: T.x + F * L * 1.3, y: T.y - W.y * 0.1 },
|
|
3410
|
+
{ x: T.x + F * L * 0.6 + W.x, y: T.y + W.y }
|
|
3411
3411
|
],
|
|
3412
3412
|
o,
|
|
3413
3413
|
d(p) * 0.8
|
|
3414
3414
|
);
|
|
3415
|
-
}, D = (p,
|
|
3416
|
-
const
|
|
3417
|
-
if (
|
|
3418
|
-
const { top: _, hip:
|
|
3419
|
-
|
|
3420
|
-
}, X = (p,
|
|
3421
|
-
const I = mt(p), { top:
|
|
3415
|
+
}, D = (p, k, I) => {
|
|
3416
|
+
const T = mt(p);
|
|
3417
|
+
if (T < 0.25) return;
|
|
3418
|
+
const { top: _, hip: W } = M(p), L = Ht(p) * p.height * 0.03, F = (V) => ({ x: Z(_, W, V).x + L, y: Z(_, W, V).y }), S = p.height * 0.022 * T, C = F(0.08), Y = F(0.62);
|
|
3419
|
+
k.shape([{ x: C.x - S, y: C.y - S }, { x: C.x + S, y: C.y - S }, { x: C.x + S * 0.6, y: C.y + S }, { x: C.x - S * 0.6, y: C.y + S }], I, d(p) * 0.7), k.shape([{ x: C.x - S * 0.6, y: C.y + S }, { x: C.x + S * 0.6, y: C.y + S }, { x: Y.x + S * 1.4, y: Y.y - S * 2 }, Y, { x: Y.x - S * 1.4, y: Y.y - S * 2 }], I, d(p) * 0.7);
|
|
3420
|
+
}, X = (p, k) => {
|
|
3421
|
+
const I = mt(p), { top: T, hip: _ } = M(p), W = Z(_, T, 0.72), L = [p.points["knee.left"], p.points["knee.right"]], F = Z(_, { x: (L[0].x + L[1].x) / 2, y: (L[0].y + L[1].y) / 2 }, 0.9), S = Ht(p) * p.height * 0.04;
|
|
3422
3422
|
if (I < 0.15) {
|
|
3423
|
-
const V = Z(_,
|
|
3424
|
-
I < -0.3 &&
|
|
3423
|
+
const V = Z(_, T, 0.2);
|
|
3424
|
+
I < -0.3 && k.line([{ x: V.x - p.height * 0.05, y: V.y }, { x: V.x + p.height * 0.05, y: V.y }], d(p));
|
|
3425
3425
|
return;
|
|
3426
3426
|
}
|
|
3427
|
-
const
|
|
3428
|
-
|
|
3427
|
+
const C = p.height * 0.075 * I, Y = Z(_, T, 0.2);
|
|
3428
|
+
k.shape(
|
|
3429
3429
|
[
|
|
3430
|
-
{ x:
|
|
3431
|
-
{ x:
|
|
3432
|
-
{ x: Y.x + S +
|
|
3433
|
-
{ x: F.x + S +
|
|
3434
|
-
{ x: F.x + S -
|
|
3435
|
-
{ x: Y.x + S -
|
|
3430
|
+
{ x: W.x + S - C * 0.7, y: W.y },
|
|
3431
|
+
{ x: W.x + S + C * 0.7, y: W.y },
|
|
3432
|
+
{ x: Y.x + S + C, y: Y.y },
|
|
3433
|
+
{ x: F.x + S + C * 1.15, y: F.y },
|
|
3434
|
+
{ x: F.x + S - C * 1.15, y: F.y },
|
|
3435
|
+
{ x: Y.x + S - C, y: Y.y }
|
|
3436
3436
|
],
|
|
3437
3437
|
u,
|
|
3438
3438
|
d(p)
|
|
3439
|
-
),
|
|
3440
|
-
}, K = (p,
|
|
3441
|
-
const { top:
|
|
3442
|
-
I ?
|
|
3439
|
+
), k.line([{ x: W.x + S - C * 0.6, y: W.y }, { x: T.x - C * 0.2, y: T.y }, { x: W.x + S + C * 0.6, y: W.y }], d(p) * 0.8);
|
|
3440
|
+
}, K = (p, k, I) => {
|
|
3441
|
+
const { top: T, hip: _ } = M(p), W = [p.points["knee.left"], p.points["knee.right"]], L = Z(_, { x: (W[0].x + W[1].x) / 2, y: (W[0].y + W[1].y) / 2 }, 0.95);
|
|
3442
|
+
I ? k.shape(ut([Z(T, _, 0.8), _, L], p.height * 0.145, p.height * 0.17), u, d(p)) : k.shape(ut([T, Z(T, _, 0.5), _], p.height * 0.14, p.height * 0.15), u, d(p));
|
|
3443
3443
|
const F = mt(p);
|
|
3444
3444
|
if (F > 0.2) {
|
|
3445
|
-
const S = Ht(p) * p.height * 0.03, [
|
|
3446
|
-
if (
|
|
3447
|
-
const V = Z(
|
|
3448
|
-
|
|
3445
|
+
const S = Ht(p) * p.height * 0.03, [C, Y] = I ? [_, L] : [T, _];
|
|
3446
|
+
if (k.line([{ x: C.x + S, y: C.y }, { x: Y.x + S, y: Y.y }], d(p) * 0.8), !I) {
|
|
3447
|
+
const V = Z(T, _, 0.35), U = p.height * 0.025 * F;
|
|
3448
|
+
k.shape([{ x: V.x + S - U * 2.4, y: V.y }, { x: V.x + S - U * 0.6, y: V.y }, { x: V.x + S - U * 0.6, y: V.y + U * 1.6 }, { x: V.x + S - U * 2.4, y: V.y + U * 1.6 }], u, d(p) * 0.6);
|
|
3449
3449
|
}
|
|
3450
3450
|
}
|
|
3451
|
-
}, q = (p,
|
|
3452
|
-
const
|
|
3453
|
-
if (
|
|
3454
|
-
const Lt = Ge(
|
|
3455
|
-
|
|
3456
|
-
const
|
|
3451
|
+
}, q = (p, k, I, T, _) => {
|
|
3452
|
+
const W = p.bodyContours?.[`arm.${I}`];
|
|
3453
|
+
if (W) {
|
|
3454
|
+
const Lt = Ge(W, 0, _, p.height * 6e-3);
|
|
3455
|
+
k.shape(Lt, T, 0);
|
|
3456
|
+
const bs = v(p);
|
|
3457
3457
|
for (let pe = 0; pe < Lt.length; pe++) {
|
|
3458
3458
|
const ze = Lt[pe], De = Lt[(pe + 1) % Lt.length];
|
|
3459
|
-
zo({ x: (ze.x + De.x) / 2, y: (ze.y + De.y) / 2 },
|
|
3459
|
+
zo({ x: (ze.x + De.x) / 2, y: (ze.y + De.y) / 2 }, bs) || k.line([ze, De], d(p));
|
|
3460
3460
|
}
|
|
3461
3461
|
return;
|
|
3462
3462
|
}
|
|
3463
|
-
const L = p.parts[`arm.${I}`].points, F = L[0], S = p.chains.spine[p.chains.spine.length - 1], Y = [{ x: F.x + (S.x - F.x) * 0.45, y: F.y + (S.y - F.y) * 0.45 }, ...Ze(L, 0, _)], V = ut(Y, p.height * 0.085, p.height * (_ > 0.6 ? 0.045 : 0.06)), U = Y.length,
|
|
3464
|
-
|
|
3465
|
-
const se = (Lt) => Math.hypot(Lt[1].x - S.x, Lt[1].y - S.y), [ye, me] = se(
|
|
3466
|
-
|
|
3467
|
-
}, J = l || c || h, j = J ? u : o, Q = J || i === "long" ? 0.95 : 0.45, nt = J || i !== "none", lt = (p,
|
|
3468
|
-
a === "skirt" && !f && !y && H(p,
|
|
3469
|
-
}, xt = (p) => (
|
|
3470
|
-
|
|
3463
|
+
const L = p.parts[`arm.${I}`].points, F = L[0], S = p.chains.spine[p.chains.spine.length - 1], Y = [{ x: F.x + (S.x - F.x) * 0.45, y: F.y + (S.y - F.y) * 0.45 }, ...Ze(L, 0, _)], V = ut(Y, p.height * 0.085, p.height * (_ > 0.6 ? 0.045 : 0.06)), U = Y.length, Tt = V.slice(0, U), Ft = V.slice(U).reverse();
|
|
3464
|
+
k.shape(V, T, 0);
|
|
3465
|
+
const se = (Lt) => Math.hypot(Lt[1].x - S.x, Lt[1].y - S.y), [ye, me] = se(Tt) > se(Ft) ? [Tt, Ft] : [Ft, Tt];
|
|
3466
|
+
k.line(ye.slice(1), d(p)), k.line(me.slice(Math.ceil(U * 0.45)), d(p)), k.line([Tt[U - 1], Ft[U - 1]], d(p));
|
|
3467
|
+
}, J = l || c || h, j = J ? u : o, Q = J || i === "long" ? 0.95 : 0.45, nt = J || i !== "none", lt = (p, k) => {
|
|
3468
|
+
a === "skirt" && !f && !y && H(p, k), y && b(p, k), l && K(p, k, !0), t.over === "apron" && X(p, k);
|
|
3469
|
+
}, xt = (p) => (k, I, T) => {
|
|
3470
|
+
k.save(), P(k, I), x(k, I, T, p), g && w(I, T, p), k.restore(), ga(I) === p && co(I) && lt(I, T);
|
|
3471
3471
|
};
|
|
3472
3472
|
return {
|
|
3473
3473
|
parts: {
|
|
3474
3474
|
"leg.left": { clip: P, over: xt("left") },
|
|
3475
3475
|
"leg.right": { clip: P, over: xt("right") },
|
|
3476
3476
|
spine: {
|
|
3477
|
-
over: (p,
|
|
3478
|
-
c && mt(
|
|
3477
|
+
over: (p, k, I) => {
|
|
3478
|
+
c && mt(k) >= 0 && $(k, I), R(k, I), O(p, k, I), s && !c && N(k, I), t.tie && !c && D(k, I, t.tie), l && K(k, I, !1), h && z(k, I), c && (mt(k) < 0 && $(k, I), A(k, I)), f && B(k, I), y && E(k, I), co(k) || lt(k, I);
|
|
3479
3479
|
}
|
|
3480
3480
|
},
|
|
3481
|
-
"arm.left": { over: nt ? (p,
|
|
3482
|
-
"arm.right": { over: nt ? (p,
|
|
3481
|
+
"arm.left": { over: nt ? (p, k, I) => q(k, I, "left", j, Q) : void 0 },
|
|
3482
|
+
"arm.right": { over: nt ? (p, k, I) => q(k, I, "right", j, Q) : void 0 }
|
|
3483
3483
|
}
|
|
3484
3484
|
};
|
|
3485
3485
|
}
|
|
@@ -3611,11 +3611,11 @@ function xa(t) {
|
|
|
3611
3611
|
const y = i === "left" ? "right" : "left";
|
|
3612
3612
|
(i === "left" ? l.parts["arm.left"].depth >= l.parts["arm.right"].depth : l.parts["arm.right"].depth > l.parts[`arm.${y}`].depth) && s(a, l, c, h, f);
|
|
3613
3613
|
};
|
|
3614
|
-
for (const i of ["left", "right"]) o.parts[`arm.${i}`] = { ...o.parts[`arm.${i}`], over:
|
|
3614
|
+
for (const i of ["left", "right"]) o.parts[`arm.${i}`] = { ...o.parts[`arm.${i}`], over: ba(o.parts[`arm.${i}`]?.over, r(i)) };
|
|
3615
3615
|
}
|
|
3616
3616
|
return o;
|
|
3617
3617
|
}
|
|
3618
|
-
function
|
|
3618
|
+
function ba(t, e) {
|
|
3619
3619
|
return t ? (n, s, o, r, i) => {
|
|
3620
3620
|
t(n, s, o, r, i), e(n, s, o, r, i);
|
|
3621
3621
|
} : e;
|
|
@@ -3630,7 +3630,7 @@ function je(t, e) {
|
|
|
3630
3630
|
}
|
|
3631
3631
|
return { behind: n(t.behind, e.behind), parts: s, front: n(t.front, e.front) };
|
|
3632
3632
|
}
|
|
3633
|
-
function
|
|
3633
|
+
function wa(t = {}) {
|
|
3634
3634
|
if (t.build && !(t.build in Yn)) throw new Error(`character: unknown build '${t.build}'`);
|
|
3635
3635
|
const e = t.build ? Yn[t.build] : {}, n = (t.proportions ?? "bold") === "bold", s = t.figure ?? "fluid", o = t.look ?? "clean", r = t.height ?? 300, i = s === "stick", a = s === "organic", l = t.shoulderWidth ?? e.shoulderWidth ?? (a ? 0.07 : 0.06), c = t.hipWidth ?? e.hipWidth ?? (a ? 0.045 : 0.022), h = t.lineWidth ?? r * (a ? 5e-3 : n ? 0.045 : 0.022), f = t.ink ?? (a ? "#53362d" : o === "pencil" ? "#2f2f33" : "#1e293b"), y = t.skin ?? (a ? "#f1bf98" : o === "pencil" ? "none" : "#ffffff"), u = a ? ni(t.body ?? {}, { skin: y, ink: f, lineWidth: h, shoulderWidth: l, hipWidth: c }) : void 0;
|
|
3636
3636
|
if (t.leafOutfit && !a) throw new Error("character: leafOutfit requires figure: 'organic'");
|
|
@@ -3674,15 +3674,15 @@ function ka(t, e, n) {
|
|
|
3674
3674
|
}
|
|
3675
3675
|
function de(t, e) {
|
|
3676
3676
|
const n = t.plan.id === "human" ? { ...at, ...e } : e;
|
|
3677
|
-
return Ne(t, n,
|
|
3677
|
+
return Ne(t, n, bn(t.plan, n, { height: t.height, contact: t.contact }));
|
|
3678
3678
|
}
|
|
3679
3679
|
function Ne(t, e, n) {
|
|
3680
3680
|
const s = {}, o = {}, r = {}, i = 0.01 * t.height;
|
|
3681
3681
|
t.plan.chains.forEach((u) => {
|
|
3682
3682
|
const g = n.chains[u.id];
|
|
3683
3683
|
s[u.id] = g.points;
|
|
3684
|
-
const m = g.depths.reduce((
|
|
3685
|
-
r[u.id] = Math.abs(
|
|
3684
|
+
const m = g.depths.reduce((M, v) => M + v, 0) / g.depths.length, d = u.parent ? n.chains[u.parent] : void 0, x = d ? d.depths[u.at ?? d.depths.length - 1] : n.hipDepth, w = m - x;
|
|
3685
|
+
r[u.id] = Math.abs(w) < i ? 0 : w, o[u.id] = { points: ka(t, u, g.points), depth: m, order: 0 };
|
|
3686
3686
|
}), o.head = { points: [n.head.center], depth: n.head.depth, order: 0 }, r.head = 0;
|
|
3687
3687
|
const a = [...t.plan.chains.map((u) => u.id), "head"], l = (u) => t.body && u.startsWith("arm.") && r[u] >= 0 ? 1 : 0, c = [...a].sort((u, g) => l(u) - l(g) || r[u] - r[g] || a.indexOf(u) - a.indexOf(g));
|
|
3688
3688
|
c.forEach((u, g) => {
|
|
@@ -3730,7 +3730,7 @@ function ms(t, e, n, s, o, r) {
|
|
|
3730
3730
|
let g;
|
|
3731
3731
|
const m = () => g ??= qo(u, n.face), d = n.skin === "none" ? null : n.skin;
|
|
3732
3732
|
n.face.projection === "volume" || n.face.shape === "angular" ? e.shape(m(), d, i) : e.ellipse(u.center.x, u.center.y, u.rx, u.ry, u.angle, d, i), n.body && n.skin !== "none" && e.look === "clean" && Eo(t, m(), u.center, n.body.shading), sa(t, e, n.head, u, r, { lineWidth: i, skin: n.skin, face: n.face, faceUnderHair: !!n.body }, () => {
|
|
3733
|
-
e.look !== "silhouette" && (t.save(), n.body && (t.beginPath(), m().forEach((x,
|
|
3733
|
+
e.look !== "silhouette" && (t.save(), n.body && (t.beginPath(), m().forEach((x, w) => w ? t.lineTo(x.x, x.y) : t.moveTo(x.x, x.y)), t.closePath(), t.clip()), mi(e, u, r, i, { ...n.face, skin: n.skin === "none" ? "#ffffff" : n.skin }, t), t.restore());
|
|
3734
3734
|
});
|
|
3735
3735
|
return;
|
|
3736
3736
|
}
|
|
@@ -3768,8 +3768,8 @@ function ms(t, e, n, s, o, r) {
|
|
|
3768
3768
|
u && g && Math.hypot(u.x - g.x, u.y - g.y) > 0.5 && e.limb([u, g], i * 1.3, i * 1.3);
|
|
3769
3769
|
const [m, d] = h(0, a.bones.length - 1);
|
|
3770
3770
|
e.limb(c, m, d);
|
|
3771
|
-
const x = s.points["shoulder.left"],
|
|
3772
|
-
x &&
|
|
3771
|
+
const x = s.points["shoulder.left"], w = s.points["shoulder.right"];
|
|
3772
|
+
x && w && Math.hypot(x.x - w.x, x.y - w.y) > 0.5 && e.limb(ne(x, l[l.length - 1], w, 1, 10), i * 1.15, i * 1.15);
|
|
3773
3773
|
return;
|
|
3774
3774
|
}
|
|
3775
3775
|
const [f, y] = h(0, a.bones.length - 1);
|
|
@@ -3808,26 +3808,26 @@ function Ye(t, e) {
|
|
|
3808
3808
|
return { ...t, height: e, lineWidth: t.lineWidth * n };
|
|
3809
3809
|
}
|
|
3810
3810
|
function Za(t, e, n, s) {
|
|
3811
|
-
const o = t.plan.id === "human" ? { ...at, ...e } : e, r =
|
|
3811
|
+
const o = t.plan.id === "human" ? { ...at, ...e } : e, r = wn(t.plan, o, { height: s.height, contact: t.contact }, n);
|
|
3812
3812
|
return Ne(Ye(t, r.height), o, r).joints;
|
|
3813
3813
|
}
|
|
3814
3814
|
function Qa(t, e, n, s, o) {
|
|
3815
|
-
const r = e.plan.id === "human" ? { ...at, ...n } : n, i =
|
|
3815
|
+
const r = e.plan.id === "human" ? { ...at, ...n } : n, i = wn(e.plan, r, { height: o.height, contact: e.contact }, s), a = Ye(e, i.height);
|
|
3816
3816
|
Sn(t, a, r, Ne(a, r, i), o.time ?? 0);
|
|
3817
3817
|
}
|
|
3818
3818
|
function ja(t, e, n, s) {
|
|
3819
|
-
const o = t.plan.id === "human" ? { ...at, ...e } : e, r =
|
|
3819
|
+
const o = t.plan.id === "human" ? { ...at, ...e } : e, r = wn(t.plan, o, { height: s.height, contact: t.contact }, n), i = Ye(t, r.height), { joints: a, order: l } = Ne(i, o, r), c = r.height / s.height, h = l.map((g) => (a.parts[g]?.depth ?? 0) / c), f = l.filter((g) => g === "spine" || g.startsWith("leg.")), y = Math.max(...f.map((g) => a.parts[g].depth / c)), u = Math.max(...f.map((g) => a.parts[g].order));
|
|
3820
3820
|
return l.map((g, m) => ({
|
|
3821
3821
|
part: g,
|
|
3822
3822
|
depth: h[m],
|
|
3823
3823
|
...i.body ? { sortDepth: g.startsWith("arm.") && m > u ? Math.max(h[m], y) : h[m] } : {},
|
|
3824
3824
|
draw(d, x = 0) {
|
|
3825
|
-
const
|
|
3826
|
-
P && (d.save(), P(d, a,
|
|
3825
|
+
const w = pn(d, { look: i.look, ink: i.ink, lineWidth: i.lineWidth, seed: Mo(`${i.seed}:${g}`), time: x, pencil: i.pencil }), M = (P) => {
|
|
3826
|
+
P && (d.save(), P(d, a, w, x, o), d.restore());
|
|
3827
3827
|
};
|
|
3828
|
-
d.save(), d.lineCap = "round", d.lineJoin = "round", m === 0 && (i.look === "pencil" && i.pencil.construction !== !1 && ys(
|
|
3828
|
+
d.save(), d.lineCap = "round", d.lineJoin = "round", m === 0 && (i.look === "pencil" && i.pencil.construction !== !1 && ys(w, i, a), M(i.layers.behind), fs(d, i.body && i.skin === "none" ? ge(d, w) : w, i.head, a.head, o, { lineWidth: i.lineWidth, skin: i.skin, face: i.face }));
|
|
3829
3829
|
const v = i.layers.parts?.[g];
|
|
3830
|
-
|
|
3830
|
+
M(v?.under), d.save(), v?.clip?.(d, a, w, x, o), ms(d, w, i, a, g, o), d.restore(), M(v?.over), g === "head" && us(d, w, i.head, a.head, o, { lineWidth: i.lineWidth, skin: i.skin, face: i.face }), m === l.length - 1 && M(i.layers.front), d.restore();
|
|
3831
3831
|
}
|
|
3832
3832
|
}));
|
|
3833
3833
|
}
|
|
@@ -3867,7 +3867,7 @@ function n0(t, e, n, s) {
|
|
|
3867
3867
|
if (Array.isArray(s))
|
|
3868
3868
|
r = s;
|
|
3869
3869
|
else {
|
|
3870
|
-
const { skeleton: i } = de(t, o), a =
|
|
3870
|
+
const { skeleton: i } = de(t, o), a = bn(t.plan, { ...o, roll: 0 }, { height: t.height, contact: "none" }), l = (o.roll ?? 0) * Math.PI / 180, c = s.x - i.hip.x, h = s.y - i.hip.y, f = a.hip.x + c * Math.cos(-l) - h * Math.sin(-l), y = a.hip.y + c * Math.sin(-l) + h * Math.cos(-l), u = Math.PI / 2 * (o.turn ?? 0), g = s.depth ?? i.chains[n].depths[i.chains[n].depths.length - 1], m = Math.cos(u), d = Math.sin(u);
|
|
3871
3871
|
r = [f * m - g * d, -y, f * d + g * m];
|
|
3872
3872
|
}
|
|
3873
3873
|
return ei(t.plan, o, n, r, { height: t.height });
|
|
@@ -3953,7 +3953,7 @@ function xo() {
|
|
|
3953
3953
|
leg: [{ at: 0, width: 0.036 }, { at: 0.3, width: 0.037 }, { at: 0.5, width: 0.026 }, { at: 0.7, width: 0.029 }, { at: 1, width: 0.015 }]
|
|
3954
3954
|
};
|
|
3955
3955
|
}
|
|
3956
|
-
const
|
|
3956
|
+
const bo = {
|
|
3957
3957
|
youngMan: {
|
|
3958
3958
|
figure: "organic",
|
|
3959
3959
|
skin: "#edb98d",
|
|
@@ -4017,25 +4017,37 @@ const wo = {
|
|
|
4017
4017
|
}
|
|
4018
4018
|
};
|
|
4019
4019
|
function i0(t, e = {}) {
|
|
4020
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
4021
|
-
const n =
|
|
4022
|
-
return
|
|
4020
|
+
if (!Object.prototype.hasOwnProperty.call(bo, t)) throw new Error(`softCartoonCharacter: unknown actor '${t}'`);
|
|
4021
|
+
const n = bo[t];
|
|
4022
|
+
return wa({ ...n, ...e, body: { ...n.body, ...e.body }, face: { ...n.face, ...e.face } });
|
|
4023
4023
|
}
|
|
4024
|
-
const
|
|
4024
|
+
const wo = Object.freeze({
|
|
4025
4025
|
everyday: Object.freeze({ shirt: "#bc7050", trousers: "#495a67", sleeves: "short", bottom: "trousers", collar: !1, tie: null }),
|
|
4026
4026
|
formal: Object.freeze({ top: "shirt", shirt: "#f4ede2", trousers: "#394653", sleeves: "long", bottom: "trousers", trouserStyle: "plain", collar: !0, tie: "#804453" }),
|
|
4027
4027
|
casual: Object.freeze({ top: "tshirt", shirt: "#648a83", trousers: "#426683", sleeves: "short", bottom: "trousers", trouserStyle: "jeans", collar: !1, tie: null })
|
|
4028
4028
|
});
|
|
4029
4029
|
function a0(t, e = {}) {
|
|
4030
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
4031
|
-
const n = { ...
|
|
4030
|
+
if (!Object.prototype.hasOwnProperty.call(wo, t)) throw new Error(`outfitPreset: unknown category '${t}'`);
|
|
4031
|
+
const n = { ...wo[t], ...e };
|
|
4032
4032
|
return e.top && e.top !== "shirt" && (n.collar = e.collar ?? !1, n.tie = e.tie ?? null), n.top === "dress" && (n.bottom = "skirt"), n;
|
|
4033
4033
|
}
|
|
4034
4034
|
const l0 = Object.freeze({
|
|
4035
4035
|
test: Object.freeze({ name: "Test", inningsPerSide: 2, oversPerInnings: null, ballsPerOver: 6, freeHitAfterNoBall: !1, summary: "Multi-day cricket. Each side can have two innings; there is no innings over limit." }),
|
|
4036
4036
|
odi: Object.freeze({ name: "ODI", inningsPerSide: 1, oversPerInnings: 50, ballsPerOver: 6, freeHitAfterNoBall: !0, summary: "One innings per side, up to 50 overs. A no-ball gives a free hit on the next legitimate delivery." }),
|
|
4037
4037
|
t20: Object.freeze({ name: "T20", inningsPerSide: 1, oversPerInnings: 20, ballsPerOver: 6, freeHitAfterNoBall: !0, summary: "One innings per side, up to 20 overs. A no-ball gives a free hit on the next legitimate delivery." })
|
|
4038
|
-
}), h0 = Object.freeze(Object.
|
|
4038
|
+
}), h0 = Object.freeze({ adults: "Adults", men: "Men", children: "Children", mixed: "Mixed cast" }), c0 = Object.freeze({
|
|
4039
|
+
bowler: "Bowler",
|
|
4040
|
+
keeper: "Wicketkeeper",
|
|
4041
|
+
fielder: "Extra cover",
|
|
4042
|
+
slip: "Slip",
|
|
4043
|
+
point: "Point",
|
|
4044
|
+
cover: "Cover",
|
|
4045
|
+
"mid-off": "Mid-off",
|
|
4046
|
+
"mid-on": "Mid-on",
|
|
4047
|
+
"square-leg": "Square leg",
|
|
4048
|
+
"fine-leg": "Fine leg",
|
|
4049
|
+
"third-man": "Third man"
|
|
4050
|
+
}), f0 = Object.freeze(Object.fromEntries(Object.entries({
|
|
4039
4051
|
bowling: { name: "Pace bowling", summary: "Run up, deliver with a straight arm, bounce and follow through." },
|
|
4040
4052
|
spin: { name: "Spin bowling", summary: "A shorter approach and a curved illustrative flight before the bounce." },
|
|
4041
4053
|
batting: { name: "Drive", summary: "Two hands on the bat, a backlift, contact and a follow-through." },
|
|
@@ -4057,149 +4069,153 @@ function Oa(t, e, n) {
|
|
|
4057
4069
|
if (!Object.prototype.hasOwnProperty.call(t, e)) throw new Error(`${n}: unknown choice '${e}'`);
|
|
4058
4070
|
return e;
|
|
4059
4071
|
}
|
|
4060
|
-
const Ia = Object.freeze({ pitch: "Whole pitch", batter: "Batter close-up", bowler: "Bowler close-up", keeper: "Keeper close-up", field: "Whole ground", overhead: "Overhead ground", orbit: "360° ground orbit", "follow-ball": "Follow the ball" }),
|
|
4061
|
-
function
|
|
4062
|
-
const n = Oa(Ia, e.view ?? "pitch", "cricketCamera.view"), s = e.yaw ??
|
|
4072
|
+
const Ia = Object.freeze({ pitch: "Whole pitch", batter: "Batter close-up", bowler: "Bowler close-up", keeper: "Keeper close-up", field: "Whole ground", overhead: "Overhead ground", orbit: "360° ground orbit", "follow-ball": "Follow the ball" }), Ta = Object.freeze({ pitch: 75, batter: 145, bowler: 35, keeper: 145, field: 75, overhead: 75, orbit: 75, "follow-ball": 75 });
|
|
4073
|
+
function u0(t, e = {}) {
|
|
4074
|
+
const n = Oa(Ia, e.view ?? "pitch", "cricketCamera.view"), s = e.yaw ?? Ta[n];
|
|
4063
4075
|
if (!Number.isFinite(s)) throw new Error("cricketCamera: yaw must be finite");
|
|
4064
|
-
const o = (s % 360 + 360) % 360, r = e.
|
|
4065
|
-
if (!Number.isFinite(r) || r <
|
|
4076
|
+
const o = (s % 360 + 360) % 360, r = e.zoom ?? 1;
|
|
4077
|
+
if (!Number.isFinite(r) || r < 0.25 || r > 4) throw new Error("cricketCamera: zoom must be between 0.25 and 4");
|
|
4078
|
+
const i = (y) => r === 1 ? y : Math.atan(Math.tan(y * Math.PI / 360) / r) * 360 / Math.PI, a = e.every ?? 40;
|
|
4079
|
+
if (!Number.isFinite(a) || a < 16 || a > 1e3) throw new Error("cricketCamera: every must be between 16 and 1000 ms");
|
|
4066
4080
|
if (n === "follow-ball") {
|
|
4067
|
-
const
|
|
4068
|
-
const
|
|
4069
|
-
if (!
|
|
4070
|
-
const
|
|
4071
|
-
let
|
|
4072
|
-
return (
|
|
4073
|
-
const
|
|
4074
|
-
for (;
|
|
4075
|
-
return
|
|
4081
|
+
const y = ["x", "y", "z"].map((d) => {
|
|
4082
|
+
const x = t.timeline.tracks.find((P) => P.target === `${t.scene.id}/ball` && P.property === d);
|
|
4083
|
+
if (!x || !("keyframes" in x) || !x.keyframes.length) throw new Error(`cricketCamera: missing ball ${d} keyframes`);
|
|
4084
|
+
const w = x.keyframes;
|
|
4085
|
+
let M = 0, v = new Pn({ ...x, keyframes: w.slice(0, 2) });
|
|
4086
|
+
return (P) => {
|
|
4087
|
+
const R = M;
|
|
4088
|
+
for (; M < w.length - 2 && P - (x.delay ?? 0) > w[M + 1].time; ) M++;
|
|
4089
|
+
return M !== R && (v = new Pn({ ...x, keyframes: w.slice(M, M + 2) })), v.getValueAtTime(P);
|
|
4076
4090
|
};
|
|
4077
|
-
});
|
|
4078
|
-
return
|
|
4091
|
+
}), u = vs({ scene: t.scene.id, camera: "camera", start: 0, end: t.duration, every: a, offset: [5, 3, 6], subjectAt: (d) => y.map((x) => x(d)) }), g = t.scene.objects.find((d) => d.id === "camera" && d.kind === "camera"), m = i(g?.kind === "camera" && g.projection === "perspective" ? g.fov : 48);
|
|
4092
|
+
return [...u, { id: `${t.scene.id}/camera-zoom-fov`, target: `${t.scene.id}/camera`, property: "fov", keyframes: [{ time: 0, value: m }, { time: t.duration, value: m }] }];
|
|
4079
4093
|
}
|
|
4080
|
-
const
|
|
4081
|
-
return Es({ scene: t.scene.id, camera: "camera", start: 0, end: t.duration, every:
|
|
4094
|
+
const l = n === "field" || n === "overhead" || n === "orbit", c = n === "batter" ? [0.1, 0.85, 9.3] : n === "bowler" ? [0.68, 1, -9.55] : n === "keeper" ? [0, 0.7, 10.1] : [0, 0.65, 0], h = l ? t.boundaryRadius * 2.8 : n === "pitch" ? 29 : 4.3, f = n === "overhead" ? 89 : l ? 52 : n === "pitch" ? 16 : 12;
|
|
4095
|
+
return Es({ scene: t.scene.id, camera: "camera", start: 0, end: t.duration, every: a, easing: "linear", from: { target: c, yaw: o, pitch: f, distance: h, fov: i(l ? 48 : n === "pitch" ? 50 : 46) }, to: { yaw: n === "orbit" ? o + 360 : o } });
|
|
4082
4096
|
}
|
|
4083
4097
|
export {
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4098
|
+
tt as $,
|
|
4099
|
+
ja as A,
|
|
4100
|
+
Kr as B,
|
|
4087
4101
|
l0 as C,
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4102
|
+
Ka as D,
|
|
4103
|
+
aa as E,
|
|
4104
|
+
Us as F,
|
|
4091
4105
|
le as G,
|
|
4092
4106
|
at as H,
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4107
|
+
So as I,
|
|
4108
|
+
Xa as J,
|
|
4109
|
+
n0 as K,
|
|
4110
|
+
va as L,
|
|
4111
|
+
Ua as M,
|
|
4112
|
+
xs as N,
|
|
4113
|
+
Aa as O,
|
|
4114
|
+
Br as P,
|
|
4115
|
+
or as Q,
|
|
4102
4116
|
Gt as R,
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4117
|
+
bo as S,
|
|
4118
|
+
kt as T,
|
|
4119
|
+
Na as U,
|
|
4120
|
+
_a as V,
|
|
4121
|
+
Ca as W,
|
|
4122
|
+
Wr as X,
|
|
4123
|
+
Fa as Y,
|
|
4124
|
+
ft as Z,
|
|
4125
|
+
za as _,
|
|
4126
|
+
xn as a,
|
|
4127
|
+
ir as a$,
|
|
4128
|
+
Yo as a0,
|
|
4129
|
+
Da as a1,
|
|
4130
|
+
As as a2,
|
|
4131
|
+
Ps as a3,
|
|
4132
|
+
Ss as a4,
|
|
4133
|
+
ma as a5,
|
|
4134
|
+
is as a6,
|
|
4135
|
+
Ki as a7,
|
|
4136
|
+
Fi as a8,
|
|
4137
|
+
Ai as a9,
|
|
4138
|
+
xa as aA,
|
|
4139
|
+
Va as aB,
|
|
4140
|
+
qa as aC,
|
|
4141
|
+
yo as aD,
|
|
4142
|
+
Pa as aE,
|
|
4143
|
+
Hr as aF,
|
|
4144
|
+
ua as aG,
|
|
4145
|
+
gs as aH,
|
|
4146
|
+
ri as aI,
|
|
4147
|
+
ve as aJ,
|
|
4148
|
+
Ja as aK,
|
|
4149
|
+
Ya as aL,
|
|
4150
|
+
Ni as aM,
|
|
4151
|
+
Ce as aN,
|
|
4152
|
+
Vi as aO,
|
|
4153
|
+
Oi as aP,
|
|
4154
|
+
ji as aQ,
|
|
4155
|
+
oa as aR,
|
|
4156
|
+
pa as aS,
|
|
4157
|
+
ni as aT,
|
|
4158
|
+
Fo as aU,
|
|
4159
|
+
_r as aV,
|
|
4160
|
+
Dt as aW,
|
|
4161
|
+
ne as aX,
|
|
4162
|
+
Ra as aY,
|
|
4163
|
+
wn as aZ,
|
|
4164
|
+
i0 as a_,
|
|
4165
|
+
Yn as aa,
|
|
4166
|
+
jr as ab,
|
|
4167
|
+
Hs as ac,
|
|
4168
|
+
fe as ad,
|
|
4169
|
+
io as ae,
|
|
4170
|
+
wo as af,
|
|
4171
|
+
ya as ag,
|
|
4172
|
+
oi as ah,
|
|
4173
|
+
ha as ai,
|
|
4174
|
+
s0 as aj,
|
|
4175
|
+
Ea as ak,
|
|
4176
|
+
Za as al,
|
|
4177
|
+
r0 as am,
|
|
4178
|
+
o0 as an,
|
|
4179
|
+
Sa as ao,
|
|
4180
|
+
t0 as ap,
|
|
4181
|
+
Qa as aq,
|
|
4182
|
+
go as ar,
|
|
4183
|
+
$r as as,
|
|
4184
|
+
tn as at,
|
|
4185
|
+
er as au,
|
|
4186
|
+
_e as av,
|
|
4187
|
+
Le as aw,
|
|
4188
|
+
Qe as ax,
|
|
4189
|
+
Xs as ay,
|
|
4190
|
+
Ba as az,
|
|
4191
|
+
Pt as b,
|
|
4192
|
+
la as b0,
|
|
4193
|
+
ar as b1,
|
|
4194
|
+
mn as b2,
|
|
4195
|
+
ut as b3,
|
|
4196
|
+
rr as b4,
|
|
4197
|
+
wa as c,
|
|
4198
|
+
ei as d,
|
|
4199
|
+
La as e,
|
|
4200
|
+
Oa as f,
|
|
4185
4201
|
h0 as g,
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4202
|
+
c0 as h,
|
|
4203
|
+
f0 as i,
|
|
4204
|
+
Ga as j,
|
|
4205
|
+
ia as k,
|
|
4206
|
+
Ta as l,
|
|
4207
|
+
Ia as m,
|
|
4208
|
+
u0 as n,
|
|
4193
4209
|
a0 as o,
|
|
4194
|
-
|
|
4195
|
-
|
|
4210
|
+
bt as p,
|
|
4211
|
+
Ot as q,
|
|
4196
4212
|
Re as r,
|
|
4197
4213
|
ti as s,
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4214
|
+
$s as t,
|
|
4215
|
+
Wn as u,
|
|
4216
|
+
an as v,
|
|
4201
4217
|
nr as w,
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4218
|
+
Jr as x,
|
|
4219
|
+
e0 as y,
|
|
4220
|
+
pn as z
|
|
4205
4221
|
};
|