@algorisys/tinyfly 0.88.0 → 0.90.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 +5 -4
- package/lib/addons/adapters.js +208 -177
- package/lib/addons/characters.js +2215 -1493
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +4944 -4128
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/engine/tinyfly-engine.js +828 -765
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +45 -7
- package/lib/types/adapters/canvas/camera.d.ts +46 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/browser/index.d.ts +2 -0
- package/lib/types/characters/acting/act-tracks.d.ts +28 -0
- package/lib/types/characters/acting/acting.d.ts +187 -0
- package/lib/types/characters/acting/effects.d.ts +65 -0
- package/lib/types/characters/acting/gags.d.ts +54 -0
- package/lib/types/characters/acting/index.d.ts +12 -0
- package/lib/types/characters/acting/lip-sync.d.ts +115 -0
- package/lib/types/characters/acting/rigs.d.ts +9 -0
- package/lib/types/characters/acting/script.d.ts +83 -0
- package/lib/types/characters/character.d.ts +7 -0
- package/lib/types/characters/gaits.d.ts +141 -0
- package/lib/types/characters/index.d.ts +2 -0
- package/lib/types/characters/stick-figure.d.ts +22 -0
- package/lib/types/engine/authoring/camera-shots.d.ts +73 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/lib/types/engine/core/clock.d.ts +7 -0
- package/lib/types/headless/video-scene.d.ts +21 -0
- package/package.json +1 -1
package/lib/addons/characters.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { a as
|
|
3
|
-
import { createRandom as
|
|
4
|
-
import { f as
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
8
|
-
const o = [],
|
|
9
|
-
return e.forEach((
|
|
10
|
-
const h = e[Math.max(0, a - 1)], c = e[Math.min(
|
|
11
|
-
o.push({ x:
|
|
12
|
-
}), [...o, ...
|
|
13
|
-
}
|
|
14
|
-
function
|
|
1
|
+
import { c as to, s as ut, p as mn, b as Ht } from "./sketch-CYPUbk3Q.js";
|
|
2
|
+
import { a as Zi } from "./sketch-CYPUbk3Q.js";
|
|
3
|
+
import { createRandom as no, hashSeed as Ze, getEasingFunction as Qe, mat4 as D, vec3 as J, quat as Ft, Timeline as oo } from "@algorisys/tinyfly";
|
|
4
|
+
import { f as Rt, h as so, a as ro } from "./load-scene-CQvcFWGJ.js";
|
|
5
|
+
function Ye(e, t, n) {
|
|
6
|
+
const s = e.length;
|
|
7
|
+
if (s < 2) return [];
|
|
8
|
+
const o = [], r = [], l = (i) => t + (n - t) * i / (s - 1);
|
|
9
|
+
return e.forEach((i, a) => {
|
|
10
|
+
const h = e[Math.max(0, a - 1)], c = e[Math.min(s - 1, a + 1)], u = Math.hypot(c.x - h.x, c.y - h.y) || 1, g = l(a) / 2, f = -(c.y - h.y) / u * g, p = (c.x - h.x) / u * g;
|
|
11
|
+
o.push({ x: i.x + f, y: i.y + p }), r.push({ x: i.x - f, y: i.y - p });
|
|
12
|
+
}), [...o, ...r.reverse()];
|
|
13
|
+
}
|
|
14
|
+
function vt(e, t, n, s) {
|
|
15
15
|
const o = t.length;
|
|
16
16
|
if (o < 2) return;
|
|
17
|
-
const
|
|
18
|
-
e.beginPath(), e.moveTo(
|
|
19
|
-
for (const
|
|
20
|
-
e.closePath(), e.fill(), t.forEach((
|
|
21
|
-
a !== 0 && a !== o - 1 && o > 3 || (e.beginPath(), e.arc(
|
|
17
|
+
const r = Ye(t, n, s), l = (i) => n + (s - n) * i / (o - 1);
|
|
18
|
+
e.beginPath(), e.moveTo(r[0].x, r[0].y);
|
|
19
|
+
for (const i of r.slice(1)) e.lineTo(i.x, i.y);
|
|
20
|
+
e.closePath(), e.fill(), t.forEach((i, a) => {
|
|
21
|
+
a !== 0 && a !== o - 1 && o > 3 || (e.beginPath(), e.arc(i.x, i.y, l(a) / 2, 0, Math.PI * 2), e.fill());
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const
|
|
26
|
-
for (let
|
|
27
|
-
const a =
|
|
28
|
-
x: c * c * e.x + 2 * c * a *
|
|
29
|
-
y: c * c * e.y + 2 * c * a *
|
|
24
|
+
function ke(e, t, n, s, o = 16) {
|
|
25
|
+
const r = { x: 2 * t.x - (e.x + n.x) / 2, y: 2 * t.y - (e.y + n.y) / 2 }, l = [];
|
|
26
|
+
for (let i = 0; i <= o; i++) {
|
|
27
|
+
const a = i / o, h = a < 0.5 ? { x: e.x + (t.x - e.x) * 2 * a, y: e.y + (t.y - e.y) * 2 * a } : { x: t.x + (n.x - t.x) * (2 * a - 1), y: t.y + (n.y - t.y) * (2 * a - 1) }, c = 1 - a, u = {
|
|
28
|
+
x: c * c * e.x + 2 * c * a * r.x + a * a * n.x,
|
|
29
|
+
y: c * c * e.y + 2 * c * a * r.y + a * a * n.y
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
l.push({ x: h.x + (u.x - h.x) * s, y: h.y + (u.y - h.y) * s });
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return l;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Lt(e, t, n, s, o, r = 0, l = 1, i = 40) {
|
|
36
36
|
const a = Math.cos(o), h = Math.sin(o);
|
|
37
|
-
return Array.from({ length:
|
|
38
|
-
const
|
|
39
|
-
return { x: e +
|
|
37
|
+
return Array.from({ length: i + 1 }, (c, u) => {
|
|
38
|
+
const g = r + Math.PI * 2 * l * u / i, f = Math.cos(g) * n, p = Math.sin(g) * s;
|
|
39
|
+
return { x: e + f * a - p * h, y: t + f * h + p * a };
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return t.look === "pencil" ?
|
|
42
|
+
function bn(e, t) {
|
|
43
|
+
return t.look === "pencil" ? ho(e, t) : io(e, t.ink, t.look);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function Xe(e, t, n = !1) {
|
|
46
46
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
47
|
-
for (const
|
|
47
|
+
for (const s of t.slice(1)) e.lineTo(s.x, s.y);
|
|
48
48
|
n && e.closePath();
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
const
|
|
50
|
+
function io(e, t, n) {
|
|
51
|
+
const s = n === "silhouette", o = s ? 1.25 : 1;
|
|
52
52
|
return {
|
|
53
53
|
look: n,
|
|
54
54
|
ink: t,
|
|
55
|
-
limb(
|
|
56
|
-
e.fillStyle = t,
|
|
55
|
+
limb(r, l, i) {
|
|
56
|
+
e.fillStyle = t, vt(e, r, l * o, i * o);
|
|
57
57
|
},
|
|
58
|
-
line(
|
|
59
|
-
|
|
58
|
+
line(r, l) {
|
|
59
|
+
r.length < 2 || (e.strokeStyle = t, e.lineWidth = l * o, e.lineCap = "round", e.lineJoin = "round", Xe(e, r), e.stroke());
|
|
60
60
|
},
|
|
61
|
-
shape(
|
|
62
|
-
|
|
61
|
+
shape(r, l, i) {
|
|
62
|
+
Xe(e, r, !0), (l !== null || s) && (e.fillStyle = s ? t : l, e.fill()), !(i <= 0) && (e.strokeStyle = t, e.lineWidth = i * o, e.lineJoin = "round", e.stroke());
|
|
63
63
|
},
|
|
64
|
-
ellipse(
|
|
65
|
-
e.beginPath(), e.ellipse(
|
|
64
|
+
ellipse(r, l, i, a, h, c, u) {
|
|
65
|
+
e.beginPath(), e.ellipse(r, l, i, a, h, 0, Math.PI * 2), (c !== null || s) && (e.fillStyle = s ? t : c, e.fill()), !(u <= 0) && (e.strokeStyle = t, e.lineWidth = u * o, e.stroke());
|
|
66
66
|
},
|
|
67
|
-
dot(
|
|
68
|
-
e.fillStyle = t, e.beginPath(), e.arc(
|
|
67
|
+
dot(r, l, i) {
|
|
68
|
+
e.fillStyle = t, e.beginPath(), e.arc(r, l, i * o, 0, Math.PI * 2), e.fill();
|
|
69
69
|
},
|
|
70
70
|
guide() {
|
|
71
71
|
},
|
|
@@ -73,101 +73,101 @@ function En(e, t, n) {
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function lo(e, t) {
|
|
77
77
|
const n = [e[0]];
|
|
78
|
-
let
|
|
79
|
-
for (let
|
|
80
|
-
const
|
|
81
|
-
let c = t -
|
|
78
|
+
let s = 0;
|
|
79
|
+
for (let l = 1; l < e.length; l++) {
|
|
80
|
+
const i = e[l - 1], a = e[l], h = Math.hypot(a.x - i.x, a.y - i.y);
|
|
81
|
+
let c = t - s;
|
|
82
82
|
for (; c < h; ) {
|
|
83
|
-
const
|
|
84
|
-
n.push({ x:
|
|
83
|
+
const u = c / h;
|
|
84
|
+
n.push({ x: i.x + (a.x - i.x) * u, y: i.y + (a.y - i.y) * u }), c += t;
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
s = h - (c - t);
|
|
87
87
|
}
|
|
88
|
-
const o = e[e.length - 1],
|
|
89
|
-
return Math.hypot(o.x -
|
|
88
|
+
const o = e[e.length - 1], r = n[n.length - 1];
|
|
89
|
+
return Math.hypot(o.x - r.x, o.y - r.y) > t * 0.25 ? n.push(o) : n[n.length - 1] = o, n;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function ao(e, t) {
|
|
92
92
|
const n = e.length;
|
|
93
|
-
return e.map((
|
|
94
|
-
const
|
|
95
|
-
return { x:
|
|
93
|
+
return e.map((s, o) => {
|
|
94
|
+
const r = e[Math.max(0, o - 1)], l = e[Math.min(n - 1, o + 1)], i = Math.hypot(l.x - r.x, l.y - r.y) || 1, a = t(n === 1 ? 0 : o / (n - 1));
|
|
95
|
+
return { x: s.x - (l.y - r.y) / i * a, y: s.y + (l.x - r.x) / i * a };
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
const t = [0.6, 1.4, 2.9].map((
|
|
100
|
-
frequency:
|
|
98
|
+
function Nt(e) {
|
|
99
|
+
const t = [0.6, 1.4, 2.9].map((s) => ({
|
|
100
|
+
frequency: s * (0.8 + e.next() * 0.4),
|
|
101
101
|
phase: e.next() * Math.PI * 2,
|
|
102
102
|
amount: 0.5 + e.next() * 0.5
|
|
103
|
-
})), n = t.reduce((
|
|
104
|
-
return (
|
|
103
|
+
})), n = t.reduce((s, o) => s + o.amount, 0);
|
|
104
|
+
return (s) => t.reduce((o, r) => o + r.amount * Math.sin(Math.PI * 2 * r.frequency * s + r.phase), 0) / n;
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
const n = t.pencil ?? {},
|
|
106
|
+
function ho(e, t) {
|
|
107
|
+
const n = t.pencil ?? {}, s = t.ink, o = n.roughness ?? Math.max(1, t.lineWidth * 0.12), r = Math.max(1, Math.round(n.passes ?? 2)), l = Math.min(1, Math.max(0, n.pressure ?? 0.25)), i = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), a = to(t.time, n.boil ?? 8);
|
|
108
108
|
let h = 0;
|
|
109
|
-
const c = (
|
|
110
|
-
if (
|
|
111
|
-
const H =
|
|
112
|
-
let
|
|
113
|
-
if (
|
|
114
|
-
const [
|
|
115
|
-
|
|
109
|
+
const c = (p, d, m = !1) => no(Ze(`${t.seed}:${m ? "paper" : a}:${p}:${d}`)), u = (p, d, m, b, y, E = 0) => {
|
|
110
|
+
if (p.length < 2) return;
|
|
111
|
+
const H = p.slice(1).reduce((v, T, K) => v + Math.hypot(T.x - p[K].x, T.y - p[K].y), 0);
|
|
112
|
+
let M = lo(p, Math.max(1.5, Math.min(t.lineWidth * 0.8, H / 24)));
|
|
113
|
+
if (E > 0 && M.length >= 2) {
|
|
114
|
+
const [v, T] = [M[M.length - 2], M[M.length - 1]], K = Math.hypot(T.x - v.x, T.y - v.y) || 1;
|
|
115
|
+
M = [...M, { x: T.x + (T.x - v.x) / K * E, y: T.y + (T.y - v.y) / K * E }];
|
|
116
116
|
}
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
}), e.save(), e.globalAlpha *=
|
|
122
|
-
},
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
|
|
117
|
+
const A = Nt(m), w = Nt(m), S = M.length, k = [], x = [];
|
|
118
|
+
M.forEach((v, T) => {
|
|
119
|
+
const K = S === 1 ? 0 : T / (S - 1), P = M[Math.max(0, T - 1)], I = M[Math.min(S - 1, T + 1)], q = Math.hypot(I.x - P.x, I.y - P.y) || 1, G = -(I.y - P.y) / q, W = (I.x - P.x) / q, O = A(K) * y, F = Math.min(1, K / 0.08, (1 - K) / 0.08), $ = (0.55 + 0.45 * Math.sqrt(Math.max(0, F))) * (1 + l * w(K)), B = Math.max(0.3, d(K) * $ / 2), U = v.x + G * O, ne = v.y + W * O;
|
|
120
|
+
k.push({ x: U + G * B, y: ne + W * B }), x.push({ x: U - G * B, y: ne - W * B });
|
|
121
|
+
}), e.save(), e.globalAlpha *= b, e.fillStyle = s, Xe(e, [...k, ...x.reverse()], !0), e.fill(), e.restore();
|
|
122
|
+
}, g = (p, d) => {
|
|
123
|
+
const m = h++, b = c(m, 99, !0);
|
|
124
|
+
if (b.next() < i) {
|
|
125
|
+
const M = (b.next() * 2 - 1) * t.lineWidth * 1.4, A = (b.next() * 2 - 1) * t.lineWidth * 1.4, w = p.map((S) => ({ x: S.x + M, y: S.y + A }));
|
|
126
|
+
u(w, (S) => d(S) * 1.8, c(m, 98, !0), 0.035, o), u(w, (S) => d(S) * 0.45, c(m, 97, !0), 0.12, o * 1.5);
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
for (let
|
|
130
|
-
const
|
|
131
|
-
H.forEach((
|
|
132
|
-
const
|
|
133
|
-
|
|
128
|
+
const y = p.slice(1).reduce((M, A, w) => M + Math.hypot(A.x - p[w].x, A.y - p[w].y), 0), E = d(0.5) > 4 && y > d(0.5) * 6, H = E ? [-0.3, 0.3, 0] : [0];
|
|
129
|
+
for (let M = 0; M < r; M++) {
|
|
130
|
+
const A = M === 0;
|
|
131
|
+
H.forEach((w, S) => {
|
|
132
|
+
const k = c(m, M * 10 + S), x = w === 0 ? p : ao(p, (T) => d(T) * w * Math.sqrt(Math.sin(Math.PI * T))), v = !A && w === 0 ? t.lineWidth * (0.3 + k.next() * 0.8) : 0;
|
|
133
|
+
u(x, (T) => d(T) * (E ? 0.5 : 1) * (A ? 1 : 0.6), k, A ? 0.85 : 0.45, o * (A ? 0.6 : 1), v);
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
},
|
|
137
|
-
const
|
|
138
|
-
|
|
136
|
+
}, f = (p, d, m, b, y, E) => {
|
|
137
|
+
const M = c(h, 50).next() * Math.PI * 2;
|
|
138
|
+
g(Lt(p, d, m, b, y, M, 1.08, 48), () => E);
|
|
139
139
|
};
|
|
140
140
|
return {
|
|
141
141
|
look: "pencil",
|
|
142
|
-
ink:
|
|
143
|
-
limb(
|
|
144
|
-
|
|
142
|
+
ink: s,
|
|
143
|
+
limb(p, d, m) {
|
|
144
|
+
g(p, (b) => d + (m - d) * b);
|
|
145
145
|
},
|
|
146
|
-
line(
|
|
147
|
-
|
|
146
|
+
line(p, d) {
|
|
147
|
+
g(p, () => d);
|
|
148
148
|
},
|
|
149
|
-
shape(
|
|
150
|
-
|
|
149
|
+
shape(p, d, m) {
|
|
150
|
+
d !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = d, Xe(e, p, !0), e.fill(), e.restore()), m > 0 && g([...p, p[0]], () => m);
|
|
151
151
|
},
|
|
152
|
-
ellipse(
|
|
153
|
-
|
|
152
|
+
ellipse(p, d, m, b, y, E, H) {
|
|
153
|
+
E !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = E, e.beginPath(), e.ellipse(p, d, m, b, y, 0, Math.PI * 2), e.fill(), e.restore()), f(p, d, m, b, y, H);
|
|
154
154
|
},
|
|
155
|
-
dot(
|
|
156
|
-
e.save(), e.globalAlpha *= 0.9, e.fillStyle =
|
|
155
|
+
dot(p, d, m) {
|
|
156
|
+
e.save(), e.globalAlpha *= 0.9, e.fillStyle = s, e.beginPath(), e.arc(p, d, m, 0, Math.PI * 2), e.fill(), e.restore();
|
|
157
157
|
},
|
|
158
|
-
guide(
|
|
159
|
-
if (n.construction === !1 ||
|
|
160
|
-
const
|
|
161
|
-
p
|
|
158
|
+
guide(p) {
|
|
159
|
+
if (n.construction === !1 || p.length < 2) return;
|
|
160
|
+
const d = h++;
|
|
161
|
+
u(p, () => Math.max(0.6, t.lineWidth * 0.18), c(d, 0), 0.28, o * 1.2, t.lineWidth);
|
|
162
162
|
},
|
|
163
|
-
guideEllipse(
|
|
163
|
+
guideEllipse(p, d, m, b, y) {
|
|
164
164
|
if (n.construction === !1) return;
|
|
165
|
-
const
|
|
166
|
-
|
|
165
|
+
const E = h++, H = c(E, 0), M = Lt(p, d, m, b, y, H.next() * Math.PI * 2, 1.12, 48);
|
|
166
|
+
u(M, () => Math.max(0.6, t.lineWidth * 0.18), H, 0.28, o * 1.5);
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
const
|
|
170
|
+
const co = ["thumb", "index", "middle", "ring", "pinky"], L = {
|
|
171
171
|
"thumb.curl": 0.15,
|
|
172
172
|
"thumb.across": 0.15,
|
|
173
173
|
"index.curl": 0.12,
|
|
@@ -180,59 +180,59 @@ const xn = ["thumb", "index", "middle", "ring", "pinky"], _ = {
|
|
|
180
180
|
tilt: 0,
|
|
181
181
|
roll: 0
|
|
182
182
|
};
|
|
183
|
-
function
|
|
184
|
-
return { ...
|
|
183
|
+
function R(e = {}) {
|
|
184
|
+
return { ...L, ...e };
|
|
185
185
|
}
|
|
186
|
-
const
|
|
186
|
+
const j = (e, t, n, s, o) => ({
|
|
187
187
|
"thumb.curl": e,
|
|
188
188
|
"index.curl": t,
|
|
189
189
|
"middle.curl": n,
|
|
190
|
-
"ring.curl":
|
|
190
|
+
"ring.curl": s,
|
|
191
191
|
"pinky.curl": o
|
|
192
|
-
}),
|
|
193
|
-
relaxed:
|
|
194
|
-
open:
|
|
195
|
-
spread:
|
|
196
|
-
flat:
|
|
197
|
-
fist:
|
|
198
|
-
point:
|
|
192
|
+
}), C = {
|
|
193
|
+
relaxed: L,
|
|
194
|
+
open: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
|
|
195
|
+
spread: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
|
|
196
|
+
flat: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
|
|
197
|
+
fist: R({ ...j(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
|
|
198
|
+
point: R({ ...j(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
|
|
199
199
|
/** The fist on its side, knuckles toward the viewer, the thumb up */
|
|
200
|
-
thumbsUp:
|
|
201
|
-
peace:
|
|
202
|
-
ok:
|
|
203
|
-
pinch:
|
|
204
|
-
cupped:
|
|
205
|
-
wave:
|
|
200
|
+
thumbsUp: R({ ...j(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
|
|
201
|
+
peace: R({ ...j(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
|
|
202
|
+
ok: R({ ...j(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
|
|
203
|
+
pinch: R({ ...j(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
|
|
204
|
+
cupped: R({ ...j(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
|
|
205
|
+
wave: R({ ...j(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
|
|
206
206
|
/** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
|
|
207
|
-
pencilGrip:
|
|
207
|
+
pencilGrip: R({ ...j(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
|
|
208
208
|
/** Holding a handle, a cup or a bar: every finger wrapped round it */
|
|
209
|
-
hold:
|
|
209
|
+
hold: R({ ...j(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
|
|
210
210
|
};
|
|
211
|
-
function
|
|
212
|
-
const
|
|
213
|
-
for (const [o,
|
|
214
|
-
const
|
|
215
|
-
|
|
211
|
+
function Ke(e, t, n) {
|
|
212
|
+
const s = { ...e };
|
|
213
|
+
for (const [o, r] of Object.entries(t)) {
|
|
214
|
+
const l = e[o] ?? r;
|
|
215
|
+
s[o] = l + (r - l) * n;
|
|
216
216
|
}
|
|
217
|
-
return
|
|
217
|
+
return s;
|
|
218
218
|
}
|
|
219
|
-
const
|
|
219
|
+
const fo = {
|
|
220
220
|
index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
|
|
221
221
|
middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
|
|
222
222
|
ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
|
|
223
223
|
pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
|
|
224
|
-
},
|
|
224
|
+
}, uo = {
|
|
225
225
|
index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
|
|
226
226
|
middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
|
|
227
227
|
pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
|
|
228
|
-
},
|
|
228
|
+
}, se = {
|
|
229
229
|
base: [-0.11, 0.1, -0.05],
|
|
230
230
|
bones: [0.2, 0.15, 0.12],
|
|
231
231
|
widths: [0.2, 0.145, 0.135],
|
|
232
232
|
/** Where the thumb points with `across` 0 and 1 */
|
|
233
233
|
out: [-0.7, 0.68, -0.22],
|
|
234
234
|
across: [0.35, 0.5, -0.8]
|
|
235
|
-
},
|
|
235
|
+
}, go = [82, 100, 62], po = [48, 72], mo = 3, bo = 13, wo = 0.035, yo = -0.075, ko = [
|
|
236
236
|
[-0.17, 0],
|
|
237
237
|
[-0.215, 0.12],
|
|
238
238
|
[-0.235, 0.26],
|
|
@@ -245,186 +245,229 @@ const Tn = {
|
|
|
245
245
|
[0.225, 0.26],
|
|
246
246
|
[0.2, 0.1],
|
|
247
247
|
[0.16, 0]
|
|
248
|
-
],
|
|
248
|
+
], ae = (e) => e * Math.PI / 180, dt = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Ce = (e, t) => [e[0] * t, e[1] * t, e[2] * t], gt = (e, t) => [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]], Ee = (e) => {
|
|
249
249
|
const t = Math.hypot(e[0], e[1], e[2]) || 1;
|
|
250
250
|
return [e[0] / t, e[1] / t, e[2] / t];
|
|
251
251
|
};
|
|
252
|
-
function
|
|
253
|
-
const
|
|
252
|
+
function de(e, t, n) {
|
|
253
|
+
const s = Math.cos(n), o = Math.sin(n), r = gt(t, e), l = t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
|
|
254
254
|
return [
|
|
255
|
-
e[0] *
|
|
256
|
-
e[1] *
|
|
257
|
-
e[2] *
|
|
255
|
+
e[0] * s + r[0] * o + t[0] * l * (1 - s),
|
|
256
|
+
e[1] * s + r[1] * o + t[1] * l * (1 - s),
|
|
257
|
+
e[2] * s + r[2] * o + t[2] * l * (1 - s)
|
|
258
258
|
];
|
|
259
259
|
}
|
|
260
|
-
const
|
|
261
|
-
function
|
|
262
|
-
const
|
|
263
|
-
let
|
|
264
|
-
e.bones.forEach((c,
|
|
265
|
-
|
|
260
|
+
const Yt = [1, 0, 0], Ct = [0, 1, 0], Ae = [0, 0, 1];
|
|
261
|
+
function So(e, t, n) {
|
|
262
|
+
const s = ae(e.fan * (mo + bo * n)), o = [Math.sin(s), Math.cos(s), 0], r = [Math.cos(s), -Math.sin(s), 0], l = [e.knuckle];
|
|
263
|
+
let i = 0;
|
|
264
|
+
e.bones.forEach((c, u) => {
|
|
265
|
+
i += ae(go[u] * t), l.push(dt(l[u], Ce(de(o, r, -i), c)));
|
|
266
266
|
});
|
|
267
|
-
const a =
|
|
268
|
-
return { joints:
|
|
267
|
+
const a = de(Ae, r, -i), h = l.map((c, u) => e.width * (1 - 0.14 * (u / (l.length - 1))));
|
|
268
|
+
return { joints: l, back: a, widths: h };
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
const o = Math.min(1, Math.max(0, t)),
|
|
270
|
+
function Eo(e, t, n = 1, s = 1) {
|
|
271
|
+
const o = Math.min(1, Math.max(0, t)), r = Ee(dt(Ce(Ee(se.out), 1 - o), Ce(Ee(se.across), o))), l = Ee(gt(Ae, r)), i = Ee(gt(r, l)), a = [[se.base[0] * s, se.base[1], se.base[2]]];
|
|
272
272
|
let h = 0;
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
se.bones.forEach((g, f) => {
|
|
274
|
+
f > 0 && (h += ae(po[f - 1] * e)), a.push(dt(a[f], Ce(de(r, l, h), g)));
|
|
275
275
|
});
|
|
276
|
-
const c =
|
|
277
|
-
return { joints: a, back: c, widths:
|
|
278
|
-
}
|
|
279
|
-
function
|
|
280
|
-
const n = { ...
|
|
281
|
-
...
|
|
282
|
-
knuckle: [
|
|
283
|
-
width:
|
|
284
|
-
}),
|
|
285
|
-
const
|
|
286
|
-
return { x:
|
|
287
|
-
},
|
|
288
|
-
const
|
|
289
|
-
return
|
|
290
|
-
},
|
|
291
|
-
thumb:
|
|
292
|
-
},
|
|
293
|
-
for (const
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
const
|
|
298
|
-
for (const [
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
points:
|
|
302
|
-
depths:
|
|
303
|
-
widths:
|
|
304
|
-
nail:
|
|
305
|
-
back:
|
|
276
|
+
const c = de(i, l, h), u = [...se.widths, se.widths[se.widths.length - 1] * 0.92].map((g) => g * n);
|
|
277
|
+
return { joints: a, back: c, widths: u };
|
|
278
|
+
}
|
|
279
|
+
function pt(e, t = {}) {
|
|
280
|
+
const n = { ...L, ...e }, s = t.size ?? 100, o = t.side ?? "right", r = o === "left" ? -1 : 1, l = ae(t.angle ?? 0), i = t.fingers === 4, a = Math.max(0.5, t.plump ?? 1), h = 1 + (a - 1) * 0.7, c = (T) => ({
|
|
281
|
+
...T,
|
|
282
|
+
knuckle: [T.knuckle[0] * h, T.knuckle[1], T.knuckle[2]],
|
|
283
|
+
width: T.width * a
|
|
284
|
+
}), u = ae(n.bend ?? 0), g = ae(n.tilt ?? 0), f = ae(90 * (n.turn ?? 0)), p = (T) => de(de(de(T, Yt, -u), Ae, -g), Ct, f), d = Math.cos(l), m = Math.sin(l), b = ae(n.roll ?? 0), y = Math.cos(b), E = Math.sin(b), H = (T) => {
|
|
285
|
+
const K = T[0] * s, P = -T[1] * s, I = (K * y - P * E) * r, q = K * E + P * y;
|
|
286
|
+
return { x: I * d - q * m, y: I * m + q * d };
|
|
287
|
+
}, M = (T) => {
|
|
288
|
+
const K = H(T), P = Math.hypot(K.x, K.y);
|
|
289
|
+
return P > 1e-6 * s ? { x: K.x / P, y: K.y / P } : { x: 0, y: 0 };
|
|
290
|
+
}, A = {
|
|
291
|
+
thumb: Eo(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, a, h)
|
|
292
|
+
}, w = i ? uo : fo;
|
|
293
|
+
for (const T of co) {
|
|
294
|
+
const K = w[T];
|
|
295
|
+
K && (A[T] = So(c(K), n[`${T}.curl`] ?? 0, n.spread ?? 0));
|
|
296
|
+
}
|
|
297
|
+
const S = {};
|
|
298
|
+
for (const [T, K] of Object.entries(A)) {
|
|
299
|
+
const P = K.joints.map(p), I = p(K.back);
|
|
300
|
+
S[T] = {
|
|
301
|
+
points: P.map(H),
|
|
302
|
+
depths: P.map((q) => q[2] * s),
|
|
303
|
+
widths: K.widths.map((q) => q * s),
|
|
304
|
+
nail: I[2],
|
|
305
|
+
back: M(I)
|
|
306
306
|
};
|
|
307
307
|
}
|
|
308
|
-
const
|
|
308
|
+
const k = ko.flatMap(([T, K]) => [p([T * h, K, wo]), p([T * h, K, yo])]), x = Ho(k.map(H)), v = k.reduce((T, K) => T + K[2], 0) / k.length * s;
|
|
309
309
|
return {
|
|
310
|
-
size:
|
|
310
|
+
size: s,
|
|
311
311
|
side: o,
|
|
312
312
|
wrist: { x: 0, y: 0 },
|
|
313
|
-
palm:
|
|
314
|
-
palmDepth:
|
|
315
|
-
palmFacing: -
|
|
316
|
-
fingers:
|
|
317
|
-
axes: { up:
|
|
318
|
-
curls: Object.fromEntries(Object.keys(
|
|
313
|
+
palm: x,
|
|
314
|
+
palmDepth: v,
|
|
315
|
+
palmFacing: -p(Ae)[2],
|
|
316
|
+
fingers: S,
|
|
317
|
+
axes: { up: M(p(Ct)), across: M(p(Yt)), out: M(p(Ae)) },
|
|
318
|
+
curls: Object.fromEntries(Object.keys(S).map((T) => [T, n[`${T}.curl`] ?? 0]))
|
|
319
319
|
};
|
|
320
320
|
}
|
|
321
|
-
function
|
|
322
|
-
const n = (o) => ({ x: o.x + t.x - e.wrist.x, y: o.y + t.y - e.wrist.y }),
|
|
323
|
-
for (const [o,
|
|
324
|
-
|
|
325
|
-
return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers:
|
|
321
|
+
function Mo(e, t) {
|
|
322
|
+
const n = (o) => ({ x: o.x + t.x - e.wrist.x, y: o.y + t.y - e.wrist.y }), s = {};
|
|
323
|
+
for (const [o, r] of Object.entries(e.fingers))
|
|
324
|
+
s[o] = { ...r, points: r.points.map(n) };
|
|
325
|
+
return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: s };
|
|
326
326
|
}
|
|
327
|
-
function
|
|
328
|
-
const t = [...e].sort((
|
|
327
|
+
function Ho(e) {
|
|
328
|
+
const t = [...e].sort((r, l) => r.x - l.x || r.y - l.y);
|
|
329
329
|
if (t.length < 3) return t;
|
|
330
|
-
const n = (
|
|
331
|
-
for (const
|
|
332
|
-
for (;
|
|
333
|
-
|
|
330
|
+
const n = (r, l, i) => (l.x - r.x) * (i.y - r.y) - (l.y - r.y) * (i.x - r.x), s = [];
|
|
331
|
+
for (const r of t) {
|
|
332
|
+
for (; s.length >= 2 && n(s[s.length - 2], s[s.length - 1], r) <= 0; ) s.pop();
|
|
333
|
+
s.push(r);
|
|
334
334
|
}
|
|
335
335
|
const o = [];
|
|
336
|
-
for (const
|
|
337
|
-
for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1],
|
|
338
|
-
o.push(
|
|
339
|
-
}
|
|
340
|
-
return [...
|
|
341
|
-
}
|
|
342
|
-
const
|
|
343
|
-
function
|
|
344
|
-
const
|
|
345
|
-
look:
|
|
346
|
-
ink:
|
|
347
|
-
lineWidth:
|
|
348
|
-
seed:
|
|
336
|
+
for (const r of [...t].reverse()) {
|
|
337
|
+
for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], r) <= 0; ) o.pop();
|
|
338
|
+
o.push(r);
|
|
339
|
+
}
|
|
340
|
+
return [...s.slice(0, -1), ...o.slice(0, -1)];
|
|
341
|
+
}
|
|
342
|
+
const vo = "#f1c9a5", To = "#2f2f33";
|
|
343
|
+
function Tt(e, t, n, s = {}, o = 0) {
|
|
344
|
+
const r = Mo(pt(n, s), t), l = s.ink ?? To, i = s.lineWidth ?? r.size * 0.035, a = s.pen ?? bn(e, {
|
|
345
|
+
look: s.look ?? "clean",
|
|
346
|
+
ink: l,
|
|
347
|
+
lineWidth: i,
|
|
348
|
+
seed: s.seed ?? 1,
|
|
349
349
|
time: o,
|
|
350
|
-
pencil: { construction: !1, ...
|
|
351
|
-
}), h =
|
|
350
|
+
pencil: { construction: !1, ...s.pencil }
|
|
351
|
+
}), h = s.skin ?? vo, c = s.nails ?? !0, u = [
|
|
352
352
|
{
|
|
353
|
-
depth:
|
|
354
|
-
draw: () =>
|
|
353
|
+
depth: r.palmDepth,
|
|
354
|
+
draw: () => Ao(a, r, h, i)
|
|
355
355
|
}
|
|
356
356
|
];
|
|
357
|
-
for (const
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
depth:
|
|
361
|
-
draw: () =>
|
|
357
|
+
for (const g of Object.values(r.fingers)) {
|
|
358
|
+
const f = g.depths.reduce((p, d) => p + d, 0) / g.depths.length;
|
|
359
|
+
u.push({
|
|
360
|
+
depth: f,
|
|
361
|
+
draw: () => xo(e, a, g, h, i, c)
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
|
-
if (
|
|
365
|
-
const
|
|
366
|
-
|
|
364
|
+
if (s.prop) {
|
|
365
|
+
const g = s.prop;
|
|
366
|
+
u.push({ depth: g.depth, draw: () => g.draw(a) });
|
|
367
367
|
}
|
|
368
368
|
e.save(), e.lineCap = "round", e.lineJoin = "round";
|
|
369
|
-
for (const
|
|
370
|
-
return e.restore(),
|
|
369
|
+
for (const g of [...u].sort((f, p) => f.depth - p.depth)) g.draw();
|
|
370
|
+
return e.restore(), r;
|
|
371
371
|
}
|
|
372
|
-
function
|
|
373
|
-
if (e.shape(t.palm, n,
|
|
372
|
+
function Ao(e, t, n, s) {
|
|
373
|
+
if (e.shape(t.palm, n, s), t.palmFacing < -0.3 && e.look !== "silhouette") {
|
|
374
374
|
const { up: o } = t.axes;
|
|
375
|
-
for (const [
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
const a =
|
|
379
|
-
const
|
|
380
|
-
return { x: c.x + Math.cos(
|
|
375
|
+
for (const [r, l] of Object.entries(t.fingers)) {
|
|
376
|
+
const i = t.curls[r] ?? 0;
|
|
377
|
+
if (r === "thumb" || i < 0.5) continue;
|
|
378
|
+
const a = l.points[0], h = l.widths[0] * 0.42, c = { x: a.x - o.x * h * 0.2, y: a.y - o.y * h * 0.2 }, u = Math.atan2(o.y, o.x), g = Array.from({ length: 7 }, (f, p) => {
|
|
379
|
+
const d = u - Math.PI / 2 + Math.PI * p / 6;
|
|
380
|
+
return { x: c.x + Math.cos(d) * h, y: c.y + Math.sin(d) * h };
|
|
381
381
|
});
|
|
382
|
-
e.line(
|
|
382
|
+
e.line(g, s * 0.6);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
if (t.palmFacing > 0.45 && e.look !== "silhouette") {
|
|
386
|
-
const { up: o, across:
|
|
387
|
-
x:
|
|
388
|
-
y:
|
|
386
|
+
const { up: o, across: r } = t.axes, l = t.size, i = t.wrist, a = (c, u) => ({
|
|
387
|
+
x: i.x + (r.x * c + o.x * u) * l,
|
|
388
|
+
y: i.y + (r.y * c + o.y * u) * l
|
|
389
389
|
}), h = t.side === "left" ? -1 : 1;
|
|
390
|
-
e.line([a(-0.15 * h, 0.36), a(-0.04 * h, 0.3), a(0.1 * h, 0.33)],
|
|
390
|
+
e.line([a(-0.15 * h, 0.36), a(-0.04 * h, 0.3), a(0.1 * h, 0.33)], s * 0.5);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
-
function
|
|
394
|
-
const { widths:
|
|
393
|
+
function xo(e, t, n, s, o, r) {
|
|
394
|
+
const { widths: l } = n, i = Ko(n.points, 2), a = n.points[0], h = i[i.length - 1], c = l[0], u = l[l.length - 1];
|
|
395
395
|
if (e.save(), t.look !== "silhouette") {
|
|
396
396
|
e.beginPath(), e.rect(a.x - 1e5, a.y - 1e5, 2e5, 2e5);
|
|
397
|
-
const
|
|
398
|
-
e.moveTo(a.x +
|
|
397
|
+
const d = c / 2 + o * 1.6;
|
|
398
|
+
e.moveTo(a.x + d, a.y), e.arc(a.x, a.y, d, 0, Math.PI * 2), e.clip("evenodd");
|
|
399
399
|
}
|
|
400
|
-
if (t.limb(
|
|
401
|
-
const
|
|
400
|
+
if (t.limb(i, c + 2 * o, u + 2 * o), e.restore(), t.look !== "silhouette" && (e.fillStyle = s, vt(e, i, c, u)), t.look === "silhouette" || !r || n.nail < 0.25) return;
|
|
401
|
+
const g = i[i.length - 2], f = Po({ x: h.x - g.x, y: h.y - g.y }) ?? {
|
|
402
402
|
x: 0,
|
|
403
403
|
y: -1
|
|
404
|
-
},
|
|
405
|
-
x: h.x -
|
|
406
|
-
y: h.y -
|
|
404
|
+
}, p = {
|
|
405
|
+
x: h.x - f.x * u * 0.22 + n.back.x * u * 0.1,
|
|
406
|
+
y: h.y - f.y * u * 0.22 + n.back.y * u * 0.1
|
|
407
407
|
};
|
|
408
|
-
t.ellipse(
|
|
408
|
+
t.ellipse(p.x, p.y, u * 0.24 * Math.max(0.35, n.nail), u * 0.19, Math.atan2(f.y, f.x), "#f8e3d3", o * 0.45);
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function Ko(e, t) {
|
|
411
411
|
let n = e;
|
|
412
|
-
for (let
|
|
412
|
+
for (let s = 0; s < t; s++) {
|
|
413
413
|
if (n.length < 3) return n;
|
|
414
414
|
const o = [n[0]];
|
|
415
|
-
for (let
|
|
416
|
-
const
|
|
417
|
-
|
|
415
|
+
for (let r = 0; r < n.length - 1; r++) {
|
|
416
|
+
const l = n[r], i = n[r + 1];
|
|
417
|
+
r > 0 && o.push({ x: l.x * 0.75 + i.x * 0.25, y: l.y * 0.75 + i.y * 0.25 }), r < n.length - 2 && o.push({ x: l.x * 0.25 + i.x * 0.75, y: l.y * 0.25 + i.y * 0.75 });
|
|
418
418
|
}
|
|
419
419
|
o.push(n[n.length - 1]), n = o;
|
|
420
420
|
}
|
|
421
421
|
return n;
|
|
422
422
|
}
|
|
423
|
-
const
|
|
423
|
+
const Po = (e) => {
|
|
424
424
|
const t = Math.hypot(e.x, e.y);
|
|
425
425
|
return t > 1e-6 ? { x: e.x / t, y: e.y / t } : null;
|
|
426
|
-
},
|
|
426
|
+
}, we = {
|
|
427
|
+
walk: { swing: 24, knee: 30, arm: 22, elbow: 28, lean: 4 },
|
|
428
|
+
bouncy: { swing: 26, knee: 45, arm: 34, elbow: 30, lean: 2, bend: -4, bounce: 0.035, squash: 0.06 },
|
|
429
|
+
doubleBounce: { swing: 22, knee: 40, arm: 26, elbow: 24, lean: 3, bounce: 0.02, bounces: 2, squash: 0.04 },
|
|
430
|
+
sneak: { swing: 28, knee: 70, arm: 6, elbow: 0, forearm: 110, shoulder: 55, lean: 16, bend: 14, headTilt: -8, crouch: 50, tiptoe: 25 },
|
|
431
|
+
strut: { swing: 26, knee: 30, arm: 30, elbow: 20, lean: -4, bend: -10, headTilt: -6, sway: 4, bounce: 0.01 },
|
|
432
|
+
tired: { swing: 14, knee: 14, arm: 6, elbow: 6, lean: 10, bend: 16, headTilt: 12 },
|
|
433
|
+
run: { swing: 40, knee: 95, arm: 45, elbow: 0, forearm: 90, lean: 16, bend: 6, bounce: 0.05, squash: 0.06 }
|
|
434
|
+
}, Wo = 40;
|
|
435
|
+
function wn(e) {
|
|
436
|
+
return e === void 0 ? we.walk : typeof e == "string" ? we[e] ?? we.walk : e;
|
|
437
|
+
}
|
|
438
|
+
function Oo(e, t, n = _, s = 1) {
|
|
439
|
+
const o = wn(e);
|
|
440
|
+
if (o === we.walk) return $o(t, n, s);
|
|
441
|
+
const r = t * Math.PI * 2, l = Math.sin(r) * s, i = Math.cos(r) * s, a = (b) => b <= Wo, h = o.shoulder ?? 0, c = (b, y) => a(b) ? y * h + o.arm * l : b, u = o.forearm ?? 0, g = a(n.leftShoulder) ? n.leftElbow - u - o.elbow * Math.max(0, -l) : n.leftElbow, f = a(n.rightShoulder) ? n.rightElbow + u + o.elbow * Math.max(0, l) : n.rightElbow, p = o.bounces ?? 1, d = (1 + Math.cos(r * 2 * p)) / 2, m = o.crouch ?? 0;
|
|
442
|
+
return {
|
|
443
|
+
...n,
|
|
444
|
+
lean: n.lean + o.lean * s + (o.sway ?? 0) * Math.sin(r) * (1 - (n.turn ?? 0)),
|
|
445
|
+
bend: (n.bend ?? 0) + (o.bend ?? 0),
|
|
446
|
+
headTilt: n.headTilt - o.lean * 0.5 * s + (o.headTilt ?? 0),
|
|
447
|
+
leftElbow: g,
|
|
448
|
+
rightElbow: f,
|
|
449
|
+
// A crouch brings both thighs forward and folds both shins back.
|
|
450
|
+
leftHip: -o.swing * l - m * 0.5,
|
|
451
|
+
rightHip: -o.swing * l + m * 0.5,
|
|
452
|
+
// The leg swinging forward lifts its knee; a crouch keeps both bent. A positive
|
|
453
|
+
// knee folds toward the centre, which is backward only for the right leg.
|
|
454
|
+
leftKnee: -o.knee * Math.max(0, i) - m,
|
|
455
|
+
rightKnee: o.knee * Math.max(0, -i) + m,
|
|
456
|
+
leftAnkle: (n.leftAnkle ?? 0) + (o.tiptoe ?? 0),
|
|
457
|
+
rightAnkle: (n.rightAnkle ?? 0) + (o.tiptoe ?? 0),
|
|
458
|
+
leftShoulder: c(n.leftShoulder, -1),
|
|
459
|
+
rightShoulder: c(n.rightShoulder, 1),
|
|
460
|
+
rise: (n.rise ?? 0) + (o.bounce ?? 0) * s * d,
|
|
461
|
+
stretch: n.stretch * (1 + (o.squash ?? 0) * (d - 0.5))
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
function Io(e, t, n = 1) {
|
|
465
|
+
const s = wn(e), o = we.walk.swing, r = (l) => Math.sin(l * Math.PI / 180);
|
|
466
|
+
return Bo(t, n) * r(s.swing * n) / r(o * n);
|
|
467
|
+
}
|
|
468
|
+
const _ = {
|
|
427
469
|
lean: 0,
|
|
470
|
+
bend: 0,
|
|
428
471
|
headTilt: 0,
|
|
429
472
|
leftShoulder: 18,
|
|
430
473
|
rightShoulder: 18,
|
|
@@ -457,10 +500,10 @@ const qn = (e) => {
|
|
|
457
500
|
spin: 0,
|
|
458
501
|
rise: 0
|
|
459
502
|
};
|
|
460
|
-
function
|
|
461
|
-
return { ...
|
|
503
|
+
function z(e) {
|
|
504
|
+
return { ..._, ...e };
|
|
462
505
|
}
|
|
463
|
-
const
|
|
506
|
+
const yn = {
|
|
464
507
|
mouth: 0,
|
|
465
508
|
smile: 0,
|
|
466
509
|
mouthWidth: 1,
|
|
@@ -471,200 +514,223 @@ const Lt = {
|
|
|
471
514
|
browTilt: 0,
|
|
472
515
|
lookX: 0,
|
|
473
516
|
lookY: 0
|
|
474
|
-
},
|
|
475
|
-
neutral:
|
|
476
|
-
happy:
|
|
477
|
-
joyful:
|
|
478
|
-
sad:
|
|
479
|
-
crying:
|
|
480
|
-
surprised:
|
|
481
|
-
shocked:
|
|
482
|
-
angry:
|
|
483
|
-
furious:
|
|
484
|
-
worried:
|
|
485
|
-
scared:
|
|
486
|
-
confused:
|
|
487
|
-
skeptical:
|
|
488
|
-
thinking:
|
|
489
|
-
sleepy:
|
|
490
|
-
disgusted:
|
|
491
|
-
smug:
|
|
492
|
-
wink:
|
|
517
|
+
}, N = (e) => ({ ...yn, ...e }), Y = {
|
|
518
|
+
neutral: yn,
|
|
519
|
+
happy: N({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
|
|
520
|
+
joyful: N({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
|
|
521
|
+
sad: N({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
|
|
522
|
+
crying: N({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
|
|
523
|
+
surprised: N({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
|
|
524
|
+
shocked: N({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
|
|
525
|
+
angry: N({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
|
|
526
|
+
furious: N({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
|
|
527
|
+
worried: N({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
|
|
528
|
+
scared: N({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
|
|
529
|
+
confused: N({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
|
|
530
|
+
skeptical: N({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
|
|
531
|
+
thinking: N({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
|
|
532
|
+
sleepy: N({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
|
|
533
|
+
disgusted: N({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
|
|
534
|
+
smug: N({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
|
|
535
|
+
wink: N({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
|
|
493
536
|
};
|
|
494
|
-
function
|
|
495
|
-
return { ...e, ...typeof t == "string" ?
|
|
496
|
-
}
|
|
497
|
-
const
|
|
498
|
-
rest:
|
|
499
|
-
wave:
|
|
500
|
-
cheer:
|
|
501
|
-
shrug:
|
|
502
|
-
point:
|
|
537
|
+
function qe(e, t) {
|
|
538
|
+
return { ...e, ...typeof t == "string" ? Y[t] : t };
|
|
539
|
+
}
|
|
540
|
+
const Oe = {
|
|
541
|
+
rest: _,
|
|
542
|
+
wave: z({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...Y.happy }),
|
|
543
|
+
cheer: z({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...Y.joyful }),
|
|
544
|
+
shrug: z({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...Y.confused, lookX: 0, lookY: 0 }),
|
|
545
|
+
point: z({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
|
|
503
546
|
// The forearm passes 180° to fold back in, so the hand reaches the chin.
|
|
504
|
-
think:
|
|
505
|
-
handsOnHips:
|
|
506
|
-
sad:
|
|
507
|
-
surprised:
|
|
547
|
+
think: z({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...Y.thinking }),
|
|
548
|
+
handsOnHips: z({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
|
|
549
|
+
sad: z({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...Y.sad }),
|
|
550
|
+
surprised: z({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...Y.surprised }),
|
|
508
551
|
// Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
|
|
509
|
-
crouch:
|
|
552
|
+
crouch: z({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
|
|
510
553
|
// Seated, hands resting on the knees. Arm angles spread outward per side, so
|
|
511
554
|
// reaching forward (+x, the way the figure faces) is negative for the left arm.
|
|
512
|
-
sit:
|
|
513
|
-
jump:
|
|
555
|
+
sit: z({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
|
|
556
|
+
jump: z({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...Y.joyful }),
|
|
514
557
|
// Full splits: legs flat along the floor, so the planted feet bring the hips right down to it.
|
|
515
558
|
// Side (straddle) split, seen front-on: each leg straight out to its side, toes pointed.
|
|
516
|
-
sideSplit:
|
|
559
|
+
sideSplit: z({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...Y.happy }),
|
|
517
560
|
// Front split, in profile: the left leg forward (+x), the right leg back.
|
|
518
|
-
frontSplit:
|
|
519
|
-
},
|
|
520
|
-
function
|
|
521
|
-
const
|
|
522
|
-
for (const o of
|
|
523
|
-
return
|
|
561
|
+
frontSplit: z({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...Y.happy })
|
|
562
|
+
}, kn = Object.keys(_);
|
|
563
|
+
function Pe(e, t, n) {
|
|
564
|
+
const s = { ...e };
|
|
565
|
+
for (const o of kn) s[o] = e[o] + (t[o] - e[o]) * n;
|
|
566
|
+
return s;
|
|
524
567
|
}
|
|
525
|
-
const
|
|
526
|
-
function
|
|
527
|
-
const
|
|
568
|
+
const mt = 24, Dt = 4, Xt = 28, _o = 40;
|
|
569
|
+
function $o(e, t = _, n = 1) {
|
|
570
|
+
const s = Math.sin(e * Math.PI * 2) * n, o = Math.cos(e * Math.PI * 2) * n, r = (h) => h <= _o, l = (h) => r(h) ? 22 * s : h, i = r(t.leftShoulder) ? t.leftElbow - Xt * Math.max(0, -s) : t.leftElbow, a = r(t.rightShoulder) ? t.rightElbow + Xt * Math.max(0, s) : t.rightElbow;
|
|
528
571
|
return {
|
|
529
572
|
...t,
|
|
530
573
|
// Lean into the walk, and keep the head a little more level than the body.
|
|
531
|
-
lean: t.lean +
|
|
532
|
-
headTilt: t.headTilt -
|
|
533
|
-
leftElbow:
|
|
574
|
+
lean: t.lean + Dt * n,
|
|
575
|
+
headTilt: t.headTilt - Dt * 0.5 * n,
|
|
576
|
+
leftElbow: i,
|
|
534
577
|
rightElbow: a,
|
|
535
578
|
// Left foot forward while swing > 0, right foot back; then the other way.
|
|
536
|
-
leftHip: -
|
|
537
|
-
rightHip: -
|
|
579
|
+
leftHip: -mt * s,
|
|
580
|
+
rightHip: -mt * s,
|
|
538
581
|
// The leg swinging forward lifts, its shin trailing backward (-x). A positive
|
|
539
582
|
// knee folds toward the centre, which is backward only for the right leg.
|
|
540
583
|
leftKnee: -30 * Math.max(0, o),
|
|
541
584
|
rightKnee: 30 * Math.max(0, -o),
|
|
542
585
|
// Arms swing against the legs: left arm back while the left foot is forward.
|
|
543
|
-
leftShoulder:
|
|
544
|
-
rightShoulder:
|
|
586
|
+
leftShoulder: l(t.leftShoulder),
|
|
587
|
+
rightShoulder: l(t.rightShoulder)
|
|
545
588
|
};
|
|
546
589
|
}
|
|
547
|
-
function
|
|
548
|
-
return 4 * ((
|
|
590
|
+
function Bo(e, t = 1) {
|
|
591
|
+
return 4 * ((bt + Ge) * e) * Math.sin(mt * t * Math.PI / 180);
|
|
549
592
|
}
|
|
550
|
-
function
|
|
593
|
+
function Fo(e) {
|
|
551
594
|
const t = Math.abs(Math.sin(e / 65)), n = 0.55 + 0.45 * Math.sin(e / 310);
|
|
552
595
|
return t * n;
|
|
553
596
|
}
|
|
554
|
-
const
|
|
555
|
-
function
|
|
556
|
-
return
|
|
597
|
+
const Sn = 0.12, qt = 0.46, Ro = 1 - 2 * Sn, Lo = 0.1, No = 0.21, Yo = 0.19, bt = 0.24, Ge = 0.22, En = 0.12, Co = 0.14, Mn = 0.33, Gt = 0.7, Ut = 0.3, Do = 0.35, Xo = [1.7, 1.05], qo = [1.3, 0.75], zt = [1.45, 0.85], Go = [1.15, 0.75], Vt = 0.06, Uo = 0.7, zo = 0.65, Hn = 0.075, Vo = 0.3, jo = 0.02, Jo = 0.012, Zo = 12, Qo = 0.25, Ie = 90, es = 0.25, ts = 0.04, vn = 0.01, fe = (e) => Math.min(1, Math.max(0, e ?? 0));
|
|
598
|
+
function gi(e, t = 1) {
|
|
599
|
+
return Ge * e * t;
|
|
557
600
|
}
|
|
558
|
-
const
|
|
559
|
-
function
|
|
560
|
-
const
|
|
601
|
+
const wt = -0.12, Tn = 0.4, Q = (e) => e * Math.PI / 180, ns = (e, t) => ({ x: t * Math.sin(Q(e)), y: Math.cos(Q(e)) }), An = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), xn = (e, t, n, s) => e - 0.3 * t - n * 0.14 * t - Math.max(0, s - 1) * 0.12 * t;
|
|
602
|
+
function os(e, t, n, s, o, r) {
|
|
603
|
+
const l = Math.max(1, Math.min(r * 0.6, Co * n)), i = fe(t.turn), a = (En + Mn * i) * n, h = s + wt * n, c = a + t.lookX * 0.08 * n, u = t.lookY * 0.07 * n, g = [
|
|
561
604
|
// The left eye is on the far side; turning closes it up more than the near one.
|
|
562
|
-
{ x: -0.34 * n * (1 -
|
|
563
|
-
{ x: 0.34 * n * (1 -
|
|
605
|
+
{ x: -0.34 * n * (1 - Gt * i), squeeze: 1 - Gt * i, open: t.leftEye, brow: t.leftBrow, side: -1 },
|
|
606
|
+
{ x: 0.34 * n * (1 - Ut * i), squeeze: 1 - Ut * i, open: t.rightEye, brow: t.rightBrow, side: 1 }
|
|
564
607
|
];
|
|
565
|
-
e.fillStyle = o, e.strokeStyle = o, e.lineWidth =
|
|
566
|
-
for (const
|
|
567
|
-
const
|
|
568
|
-
if (
|
|
569
|
-
const
|
|
570
|
-
e.beginPath(), e.moveTo(
|
|
608
|
+
e.fillStyle = o, e.strokeStyle = o, e.lineWidth = l;
|
|
609
|
+
for (const b of g) {
|
|
610
|
+
const y = An(b.open, t.blink);
|
|
611
|
+
if (y < 0.2) {
|
|
612
|
+
const A = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
|
|
613
|
+
e.beginPath(), e.moveTo(b.x + a - 0.12 * n, h), e.quadraticCurveTo(b.x + a, h + A, b.x + a + 0.12 * n, h), e.stroke();
|
|
571
614
|
} else {
|
|
572
|
-
if (
|
|
573
|
-
const
|
|
574
|
-
e.beginPath(), e.ellipse(
|
|
615
|
+
if (y > 1.2) {
|
|
616
|
+
const w = 0.13 * n * y;
|
|
617
|
+
e.beginPath(), e.ellipse(b.x + a, h, w * 0.85, w, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = o;
|
|
575
618
|
}
|
|
576
|
-
const
|
|
577
|
-
e.beginPath(), e.ellipse(
|
|
619
|
+
const A = y > 1.2 ? 0.075 * n : 0.1 * n;
|
|
620
|
+
e.beginPath(), e.ellipse(b.x + c, h + u, A, A * 1.1 * Math.min(y, 1), 0, 0, Math.PI * 2), e.fill();
|
|
578
621
|
}
|
|
579
|
-
const
|
|
580
|
-
e.beginPath(), e.moveTo(
|
|
622
|
+
const E = xn(h, n, b.brow, y), H = b.x + a - b.side * 0.13 * n * b.squeeze, M = b.x + a + b.side * 0.13 * n * b.squeeze;
|
|
623
|
+
e.beginPath(), e.moveTo(M, E), e.lineTo(H, E - t.browTilt * 0.1 * n), e.stroke();
|
|
581
624
|
}
|
|
582
|
-
const
|
|
583
|
-
if (e.beginPath(),
|
|
584
|
-
e.moveTo(a -
|
|
625
|
+
const f = s + Tn * n, p = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - Do * i), d = Math.min(1, Math.max(0, t.mouth));
|
|
626
|
+
if (e.beginPath(), d <= 0.05) {
|
|
627
|
+
e.moveTo(a - p, f), e.quadraticCurveTo(a, f + t.smile * 0.25 * n, a + p, f), e.stroke();
|
|
585
628
|
return;
|
|
586
629
|
}
|
|
587
|
-
const
|
|
588
|
-
t.smile > 0.3 ? (e.moveTo(a -
|
|
589
|
-
}
|
|
590
|
-
function
|
|
591
|
-
const n = t.height ?? 300,
|
|
592
|
-
const
|
|
593
|
-
return
|
|
594
|
-
},
|
|
595
|
-
let
|
|
596
|
-
if (a > 0 || !
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
), F = 1 -
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
630
|
+
const m = 0.3 * n * d;
|
|
631
|
+
t.smile > 0.3 ? (e.moveTo(a - p, f - 0.05 * n), e.lineTo(a + p, f - 0.05 * n), e.quadraticCurveTo(a, f + m * 2, a - p, f - 0.05 * n)) : t.smile < -0.3 ? (e.moveTo(a - p, f + m * 0.6), e.lineTo(a + p, f + m * 0.6), e.quadraticCurveTo(a, f - m * 1.4, a - p, f + m * 0.6)) : e.ellipse(a, f, p * 0.8, m, 0, 0, Math.PI * 2), e.fill();
|
|
632
|
+
}
|
|
633
|
+
function Kn(e, t) {
|
|
634
|
+
const n = t.height ?? 300, s = Math.min(3, Math.max(0.3, e.stretch ?? 1)), o = Math.sqrt(s), r = (t.headSize ?? 2 * Sn) / 2, l = t.headSize === void 0 ? Ro : 1 - 2 * r, i = r * n, a = fe(e.sit), h = e.leftHip + (-Ie - e.leftHip) * a, c = e.leftKnee + (-Ie - e.leftKnee) * a, u = e.rightHip + (Ie - e.rightHip) * a, g = e.rightKnee + (Ie - e.rightKnee) * a, f = t.classic === !0, p = fe(e.turn), d = (W, O, F, $, B) => {
|
|
635
|
+
const U = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(Q(O - F) / 2) + Q($))), ne = Math.max(-1, Math.min(1, Uo + B)), et = p + (1 - p) * W * ne;
|
|
636
|
+
return f ? { x: 0, y: 0 } : { x: Math.cos(U) * Vt * et, y: Math.sin(U) * Vt };
|
|
637
|
+
}, m = { left: e.leftAnkle ?? 0, right: e.rightAnkle ?? 0 }, b = { left: e.leftFootOut ?? 0, right: e.rightFootOut ?? 0 };
|
|
638
|
+
let y = 0;
|
|
639
|
+
if (a > 0 || !f) {
|
|
640
|
+
const W = (B, U, ne, et, eo) => bt * Math.cos(Q(U)) + Ge * Math.cos(Q(U - ne)) + Math.max(0, d(B, U, ne, et, eo).y), O = Math.max(
|
|
641
|
+
W(-1, h, c, m.left, b.left),
|
|
642
|
+
W(1, u, g, m.right, b.right)
|
|
643
|
+
), F = 1 - fe((e.rise ?? 0) / ts), $ = (f ? Math.min(1, a / es) : 1) * F;
|
|
644
|
+
y = (qt - O) * $ * n * s;
|
|
645
|
+
}
|
|
646
|
+
const E = -qt * n * s + y, H = -l * n * s + y, M = f ? 0 : (jo * fe(e.turn) + Jo * a) * n * s, A = Q(e.bend ?? 0), w = { end: Jt(E, H, A, 1), bend: A };
|
|
647
|
+
let S;
|
|
648
|
+
if (A !== 0) {
|
|
649
|
+
S = [];
|
|
650
|
+
for (let W = 0; W <= jt; W++) {
|
|
651
|
+
const O = W / jt, F = Jt(E, H, A, O);
|
|
652
|
+
S.push({ x: F.x - M * Math.sin(Math.PI * O), y: F.y });
|
|
653
|
+
}
|
|
654
|
+
} else
|
|
655
|
+
S = M === 0 ? [{ x: 0, y: E }, { x: 0, y: H }] : ke({ x: 0, y: E }, { x: -M, y: (E + H) / 2 }, { x: 0, y: H }, 1, 8);
|
|
656
|
+
const k = H + Lo * n * s, x = (t.shoulderWidth ?? 0) * n * Math.cos(p * Math.PI / 2), v = (W, O, F, $, B) => {
|
|
657
|
+
const U = ns(F, $);
|
|
658
|
+
return { x: W + U.x * B * n, y: O + U.y * B * n };
|
|
659
|
+
}, T = (W, O, F) => {
|
|
660
|
+
const $ = v(0, E, O, W, bt * s);
|
|
661
|
+
return { root: { x: 0, y: E }, joint: $, end: v($.x, $.y, O - F, W, Ge * s) };
|
|
662
|
+
}, K = (W, O, F) => {
|
|
663
|
+
const $ = { x: W * x, y: k }, B = v($.x, $.y, O, W, No * o);
|
|
664
|
+
return { root: $, joint: B, end: v(B.x, B.y, O + F, W, Yo * o) };
|
|
665
|
+
}, P = { left: T(-1, h, c), right: T(1, u, g) }, I = (W, O, F, $, B, U) => {
|
|
666
|
+
const ne = d(W, F, $, B, U);
|
|
667
|
+
return { x: O.end.x + ne.x * n * s, y: O.end.y + ne.y * n * s };
|
|
668
|
+
}, q = (W, O, F, $, B) => v(O.end.x, O.end.y, F + $ + B, W, Hn * o), G = {
|
|
616
669
|
left: K(-1, e.leftShoulder, e.leftElbow),
|
|
617
670
|
right: K(1, e.rightShoulder, e.rightElbow)
|
|
618
671
|
};
|
|
619
672
|
return {
|
|
620
673
|
height: n,
|
|
621
674
|
facing: (t.facing ?? 1) < 0 ? -1 : 1,
|
|
622
|
-
stretch:
|
|
675
|
+
stretch: s,
|
|
623
676
|
lineWidth: t.lineWidth ?? n * 0.025,
|
|
624
|
-
rubber: Math.min(1, Math.max(
|
|
625
|
-
r:
|
|
677
|
+
rubber: Math.min(1, Math.max(f ? 0 : Vo, t.rubber ?? 0)),
|
|
678
|
+
r: i,
|
|
626
679
|
// The head keeps its area: taller and narrower when stretched.
|
|
627
|
-
headRx:
|
|
628
|
-
headRy:
|
|
629
|
-
hipY:
|
|
680
|
+
headRx: i / Math.sqrt(s),
|
|
681
|
+
headRy: i * Math.sqrt(s),
|
|
682
|
+
hipY: E,
|
|
630
683
|
neckY: H,
|
|
631
|
-
drop:
|
|
632
|
-
lean:
|
|
633
|
-
classic:
|
|
634
|
-
legs:
|
|
684
|
+
drop: y,
|
|
685
|
+
lean: f ? e.lean : e.lean + Zo * Math.sin(Math.PI * a),
|
|
686
|
+
classic: f,
|
|
687
|
+
legs: P,
|
|
635
688
|
toes: {
|
|
636
|
-
left:
|
|
637
|
-
right:
|
|
689
|
+
left: I(-1, P.left, h, c, m.left, b.left),
|
|
690
|
+
right: I(1, P.right, u, g, m.right, b.right)
|
|
638
691
|
},
|
|
639
|
-
spine:
|
|
640
|
-
|
|
692
|
+
spine: S,
|
|
693
|
+
chest: w,
|
|
694
|
+
arms: G,
|
|
641
695
|
handTips: {
|
|
642
|
-
left:
|
|
643
|
-
right:
|
|
696
|
+
left: q(-1, G.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
|
|
697
|
+
right: q(1, G.right, e.rightShoulder, e.rightElbow, e.rightWrist ?? 0)
|
|
644
698
|
}
|
|
645
699
|
};
|
|
646
700
|
}
|
|
647
|
-
const
|
|
648
|
-
function
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
return {
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
701
|
+
const jt = 10;
|
|
702
|
+
function Jt(e, t, n, s) {
|
|
703
|
+
const o = e - t, r = n * s;
|
|
704
|
+
if (Math.abs(n) < 1e-9) return { x: 0, y: e - o * s };
|
|
705
|
+
const l = o / n;
|
|
706
|
+
return { x: l * (1 - Math.cos(r)), y: e - l * Math.sin(r) };
|
|
707
|
+
}
|
|
708
|
+
function ss(e, t) {
|
|
709
|
+
if (e.chest.bend === 0) return t;
|
|
710
|
+
const n = We(t, { x: 0, y: e.neckY }, e.chest.bend);
|
|
711
|
+
return { x: n.x + e.chest.end.x, y: n.y + e.chest.end.y - e.neckY };
|
|
712
|
+
}
|
|
713
|
+
const ve = (e, t) => t === 0 ? [e.root, e.joint, e.end] : ke(e.root, e.joint, e.end, t);
|
|
714
|
+
function We(e, t, n) {
|
|
715
|
+
const s = Math.cos(n), o = Math.sin(n), r = e.x - t.x, l = e.y - t.y;
|
|
716
|
+
return { x: t.x + r * s - l * o, y: t.y + r * o + l * s };
|
|
717
|
+
}
|
|
718
|
+
function Pn(e, t, n = !0) {
|
|
719
|
+
const s = is(e, t), o = t.spin ?? 0, r = t.rise ?? 0;
|
|
720
|
+
return n && (o !== 0 || r !== 0) ? rs(s, e, o, r) : s;
|
|
721
|
+
}
|
|
722
|
+
function Wn(e, t, n) {
|
|
723
|
+
return { pivot: { x: 0, y: e.hipY }, angle: e.facing * Q(t), lift: n * e.height };
|
|
724
|
+
}
|
|
725
|
+
function rs(e, t, n, s) {
|
|
726
|
+
const { pivot: o, angle: r, lift: l } = Wn(t, n, s), i = (g) => {
|
|
727
|
+
const f = We(g, o, r);
|
|
728
|
+
return { x: f.x, y: f.y - l };
|
|
729
|
+
}, a = (g) => ({ left: i(g.left), right: i(g.right) }), h = { left: Math.max(i(e.feet.left).y, i(e.toes.left).y), right: Math.max(i(e.feet.right).y, i(e.toes.right).y) }, c = Math.max(h.left, h.right), u = vn * t.height;
|
|
664
730
|
return {
|
|
665
731
|
...e,
|
|
666
|
-
hip:
|
|
667
|
-
neck:
|
|
732
|
+
hip: i(e.hip),
|
|
733
|
+
neck: i(e.neck),
|
|
668
734
|
shoulders: a(e.shoulders),
|
|
669
735
|
elbows: a(e.elbows),
|
|
670
736
|
hands: a(e.hands),
|
|
@@ -673,32 +739,32 @@ function mo(e, t, n, r) {
|
|
|
673
739
|
feet: a(e.feet),
|
|
674
740
|
toes: a(e.toes),
|
|
675
741
|
feetY: c,
|
|
676
|
-
grounded: { left: h.left >= c -
|
|
677
|
-
handAngle: { left: e.handAngle.left +
|
|
742
|
+
grounded: { left: h.left >= c - u, right: h.right >= c - u },
|
|
743
|
+
handAngle: { left: e.handAngle.left + r, right: e.handAngle.right + r },
|
|
678
744
|
limbs: {
|
|
679
|
-
leftArm: e.limbs.leftArm.map(
|
|
680
|
-
rightArm: e.limbs.rightArm.map(
|
|
681
|
-
leftLeg: e.limbs.leftLeg.map(
|
|
682
|
-
rightLeg: e.limbs.rightLeg.map(
|
|
683
|
-
spine: e.limbs.spine.map(
|
|
745
|
+
leftArm: e.limbs.leftArm.map(i),
|
|
746
|
+
rightArm: e.limbs.rightArm.map(i),
|
|
747
|
+
leftLeg: e.limbs.leftLeg.map(i),
|
|
748
|
+
rightLeg: e.limbs.rightLeg.map(i),
|
|
749
|
+
spine: e.limbs.spine.map(i)
|
|
684
750
|
},
|
|
685
|
-
head: { ...e.head, center:
|
|
751
|
+
head: { ...e.head, center: i(e.head.center), angle: e.head.angle + r }
|
|
686
752
|
};
|
|
687
753
|
}
|
|
688
|
-
function
|
|
689
|
-
const n =
|
|
690
|
-
const [
|
|
691
|
-
return
|
|
754
|
+
function is(e, t) {
|
|
755
|
+
const n = Q(e.lean), s = Q(t.headTilt), o = { x: 0, y: e.hipY }, r = (H) => ({ x: e.facing * H.x, y: H.y }), l = (H) => r(We(H, o, n)), i = (H) => l(ss(e, H)), a = (H) => i(We({ x: H.x, y: H.y + e.neckY }, { x: 0, y: e.neckY }, s)), h = ve(e.arms.left, e.rubber).map(i), c = ve(e.arms.right, e.rubber).map(i), u = (H, M) => Math.atan2(M.y - H.y, M.x - H.x), g = { left: i(e.handTips.left), right: i(e.handTips.right) }, f = (H, M) => {
|
|
756
|
+
const [A, w] = H.slice(-2), S = e.arms[M], k = u(i(S.end), g[M]) - u(i(S.joint), i(S.end));
|
|
757
|
+
return u(A, w) + k;
|
|
692
758
|
};
|
|
693
|
-
let
|
|
694
|
-
for (const [
|
|
759
|
+
let p = 1 / 0;
|
|
760
|
+
for (const [H, M] of [
|
|
695
761
|
[t.leftBrow, t.leftEye],
|
|
696
762
|
[t.rightBrow, t.rightEye]
|
|
697
763
|
]) {
|
|
698
|
-
const
|
|
699
|
-
|
|
764
|
+
const A = xn(wt, 1, H, An(M, t.blink));
|
|
765
|
+
p = Math.min(p, A, A - t.browTilt * 0.1);
|
|
700
766
|
}
|
|
701
|
-
const
|
|
767
|
+
const d = { left: r(e.legs.left.end), right: r(e.legs.right.end) }, m = { left: r(e.toes.left), right: r(e.toes.right) }, b = { left: Math.max(d.left.y, m.left.y), right: Math.max(d.right.y, m.right.y) }, y = Math.max(b.left, b.right), E = vn * e.height;
|
|
702
768
|
return {
|
|
703
769
|
facing: e.facing,
|
|
704
770
|
height: e.height,
|
|
@@ -709,45 +775,45 @@ function yo(e, t) {
|
|
|
709
775
|
shoulders: { left: i(e.arms.left.root), right: i(e.arms.right.root) },
|
|
710
776
|
elbows: { left: i(e.arms.left.joint), right: i(e.arms.right.joint) },
|
|
711
777
|
hands: { left: i(e.arms.left.end), right: i(e.arms.right.end) },
|
|
712
|
-
knees: { left:
|
|
713
|
-
feet:
|
|
714
|
-
toes:
|
|
715
|
-
feetY:
|
|
716
|
-
grounded: { left:
|
|
717
|
-
fingertips:
|
|
718
|
-
handAngle: { left:
|
|
778
|
+
knees: { left: r(e.legs.left.joint), right: r(e.legs.right.joint) },
|
|
779
|
+
feet: d,
|
|
780
|
+
toes: m,
|
|
781
|
+
feetY: y,
|
|
782
|
+
grounded: { left: b.left >= y - E, right: b.right >= y - E },
|
|
783
|
+
fingertips: g,
|
|
784
|
+
handAngle: { left: f(h, "left"), right: f(c, "right") },
|
|
719
785
|
limbs: {
|
|
720
|
-
leftArm:
|
|
721
|
-
rightArm:
|
|
722
|
-
leftLeg:
|
|
723
|
-
rightLeg:
|
|
724
|
-
spine: e.spine.map(
|
|
786
|
+
leftArm: h,
|
|
787
|
+
rightArm: c,
|
|
788
|
+
leftLeg: ve(e.legs.left, e.rubber).map(r),
|
|
789
|
+
rightLeg: ve(e.legs.right, e.rubber).map(r),
|
|
790
|
+
spine: e.spine.map(l)
|
|
725
791
|
},
|
|
726
792
|
head: {
|
|
727
|
-
center:
|
|
793
|
+
center: a({ x: 0, y: -e.headRy }),
|
|
728
794
|
rx: e.headRx,
|
|
729
795
|
ry: e.headRy,
|
|
730
796
|
// Mirroring a turn reverses it.
|
|
731
|
-
angle: e.facing * (n +
|
|
732
|
-
eyeY:
|
|
733
|
-
browTopY:
|
|
734
|
-
mouthY:
|
|
735
|
-
faceX: e.facing * (
|
|
797
|
+
angle: e.facing * (n + e.chest.bend + s),
|
|
798
|
+
eyeY: wt,
|
|
799
|
+
browTopY: p,
|
|
800
|
+
mouthY: Tn,
|
|
801
|
+
faceX: e.facing * (En + Mn * fe(t.turn))
|
|
736
802
|
}
|
|
737
803
|
};
|
|
738
804
|
}
|
|
739
|
-
function
|
|
740
|
-
return
|
|
805
|
+
function ls(e, t = {}) {
|
|
806
|
+
return Pn(Kn(e, t), e);
|
|
741
807
|
}
|
|
742
|
-
function
|
|
743
|
-
return
|
|
808
|
+
function pi(e, t, n) {
|
|
809
|
+
return We({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
|
|
744
810
|
}
|
|
745
|
-
function
|
|
746
|
-
const
|
|
811
|
+
function as(e, t, n) {
|
|
812
|
+
const s = (r) => ({ x: r.x + t, y: r.y + n }), o = (r) => ({ left: s(r.left), right: s(r.right) });
|
|
747
813
|
return {
|
|
748
814
|
...e,
|
|
749
|
-
hip:
|
|
750
|
-
neck:
|
|
815
|
+
hip: s(e.hip),
|
|
816
|
+
neck: s(e.neck),
|
|
751
817
|
shoulders: o(e.shoulders),
|
|
752
818
|
elbows: o(e.elbows),
|
|
753
819
|
hands: o(e.hands),
|
|
@@ -758,212 +824,220 @@ function ko(e, t, n) {
|
|
|
758
824
|
grounded: { ...e.grounded },
|
|
759
825
|
handAngle: { ...e.handAngle },
|
|
760
826
|
limbs: {
|
|
761
|
-
leftArm: e.limbs.leftArm.map(
|
|
762
|
-
rightArm: e.limbs.rightArm.map(
|
|
763
|
-
leftLeg: e.limbs.leftLeg.map(
|
|
764
|
-
rightLeg: e.limbs.rightLeg.map(
|
|
765
|
-
spine: e.limbs.spine.map(
|
|
827
|
+
leftArm: e.limbs.leftArm.map(s),
|
|
828
|
+
rightArm: e.limbs.rightArm.map(s),
|
|
829
|
+
leftLeg: e.limbs.leftLeg.map(s),
|
|
830
|
+
rightLeg: e.limbs.rightLeg.map(s),
|
|
831
|
+
spine: e.limbs.spine.map(s)
|
|
766
832
|
},
|
|
767
|
-
head: { ...e.head, center:
|
|
833
|
+
head: { ...e.head, center: s(e.head.center) }
|
|
768
834
|
};
|
|
769
835
|
}
|
|
770
|
-
function
|
|
771
|
-
const o =
|
|
836
|
+
function hs(e, t, n = {}, s = 0) {
|
|
837
|
+
const o = Kn(t, n), r = n.color ?? "#1e293b", l = n.layers ?? {}, i = n.layers ? Pn(o, t, !1) : void 0, a = n.sketch ? ut(e, n.sketch, s) : void 0, h = n.sketch && n.layers ? ut(e, n.sketch, s) : void 0, c = (w) => {
|
|
772
838
|
e.save(), w(), e.restore();
|
|
773
|
-
},
|
|
774
|
-
w &&
|
|
775
|
-
},
|
|
776
|
-
|
|
777
|
-
},
|
|
778
|
-
|
|
839
|
+
}, u = (w) => {
|
|
840
|
+
w && i && c(() => w(e, i, s, h));
|
|
841
|
+
}, g = () => e.scale(o.facing, 1), f = () => {
|
|
842
|
+
g(), e.translate(0, o.hipY), e.rotate(Q(o.lean)), e.translate(0, -o.hipY);
|
|
843
|
+
}, p = () => {
|
|
844
|
+
f(), o.chest.bend !== 0 && (e.translate(o.chest.end.x, o.chest.end.y), e.rotate(o.chest.bend), e.translate(0, -o.neckY));
|
|
845
|
+
}, d = (w, S, k) => {
|
|
846
|
+
if (a) return S ? a.curve(w) : a.line(w);
|
|
779
847
|
if (o.classic) {
|
|
780
848
|
e.beginPath(), e.moveTo(w[0].x, w[0].y);
|
|
781
|
-
for (const
|
|
849
|
+
for (const x of w.slice(1)) e.lineTo(x.x, x.y);
|
|
782
850
|
e.stroke();
|
|
783
851
|
return;
|
|
784
852
|
}
|
|
785
|
-
|
|
786
|
-
},
|
|
787
|
-
o.classic ||
|
|
788
|
-
},
|
|
789
|
-
if (n.hands && !o.classic) return
|
|
853
|
+
vt(e, w, k[0] * o.lineWidth, k[1] * o.lineWidth);
|
|
854
|
+
}, m = (w, S) => d(ve(w, o.rubber), o.rubber > 0, S), b = (w) => {
|
|
855
|
+
o.classic || d([o.legs[w].end, o.toes[w]], !1, Go);
|
|
856
|
+
}, y = (w) => {
|
|
857
|
+
if (n.hands && !o.classic) return H(w);
|
|
790
858
|
if (o.classic || a) return;
|
|
791
|
-
const
|
|
792
|
-
e.beginPath(), e.arc(
|
|
859
|
+
const S = o.arms[w].end;
|
|
860
|
+
e.beginPath(), e.arc(S.x, S.y, zo * o.lineWidth, 0, Math.PI * 2), e.fill();
|
|
793
861
|
};
|
|
794
|
-
e.save(), e.strokeStyle =
|
|
795
|
-
const
|
|
796
|
-
(
|
|
797
|
-
function
|
|
798
|
-
const
|
|
799
|
-
|
|
862
|
+
e.save(), e.strokeStyle = r, e.fillStyle = r, e.lineWidth = o.lineWidth, e.lineCap = "round", e.lineJoin = "round";
|
|
863
|
+
const E = Wn(o, t.spin ?? 0, t.rise ?? 0);
|
|
864
|
+
(E.angle !== 0 || E.lift !== 0) && (e.translate(0, -E.lift), e.translate(E.pivot.x, E.pivot.y), e.rotate(E.angle), e.translate(-E.pivot.x, -E.pivot.y));
|
|
865
|
+
function H(w) {
|
|
866
|
+
const S = n.hands ?? {}, k = o.arms[w].end, x = o.handTips[w], v = n.headFill ?? "#ffffff";
|
|
867
|
+
Tt(e, k, S[w] ?? L, {
|
|
800
868
|
side: w,
|
|
801
869
|
// Degrees clockwise from straight up, in the frame the hand is drawn in.
|
|
802
|
-
angle: Math.atan2(
|
|
803
|
-
size: (
|
|
804
|
-
skin:
|
|
805
|
-
ink:
|
|
870
|
+
angle: Math.atan2(x.x - k.x, k.y - x.y) * 180 / Math.PI,
|
|
871
|
+
size: (S.size ?? Hn) * o.height * Math.sqrt(o.stretch),
|
|
872
|
+
skin: S.skin ?? (v === "none" ? void 0 : v),
|
|
873
|
+
ink: r,
|
|
806
874
|
lineWidth: o.lineWidth * 0.45,
|
|
807
|
-
fingers:
|
|
808
|
-
plump:
|
|
875
|
+
fingers: S.fingers,
|
|
876
|
+
plump: S.plump,
|
|
809
877
|
look: n.sketch ? "pencil" : "clean",
|
|
810
878
|
seed: n.sketch?.seed
|
|
811
|
-
},
|
|
879
|
+
}, s);
|
|
812
880
|
}
|
|
813
|
-
const
|
|
881
|
+
const M = (w) => {
|
|
814
882
|
c(() => {
|
|
815
|
-
|
|
883
|
+
p(), m(o.arms[w], qo), y(w);
|
|
816
884
|
});
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
},
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
}),
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
885
|
+
const S = l.sleeve;
|
|
886
|
+
S && i && c(() => S(e, i, w, s, h));
|
|
887
|
+
}, A = fe(t.turn) > Qo;
|
|
888
|
+
u(l.behind), c(() => {
|
|
889
|
+
g(), m(o.legs.left, zt), b("left"), m(o.legs.right, zt), b("right");
|
|
890
|
+
}), A && M("left"), c(() => {
|
|
891
|
+
f(), d(o.spine, o.spine.length > 2, Xo);
|
|
892
|
+
}), c(() => {
|
|
893
|
+
p();
|
|
894
|
+
const { left: w, right: S } = { left: o.arms.left.root, right: o.arms.right.root };
|
|
895
|
+
if (w.x !== S.x)
|
|
896
|
+
if (o.classic) d([w, S], !1, [1, 1]);
|
|
827
897
|
else {
|
|
828
|
-
const
|
|
829
|
-
|
|
898
|
+
const k = { x: (w.x + S.x) / 2, y: w.y - 0.3 * Math.abs(S.x - w.x) };
|
|
899
|
+
d(ke(w, k, S, 1, 8), !0, [1.1, 1.1]);
|
|
830
900
|
}
|
|
831
|
-
}),
|
|
832
|
-
|
|
901
|
+
}), u(l.body), A || M("left"), M("right"), u(l.behindHead), c(() => {
|
|
902
|
+
p(), e.translate(0, o.neckY), e.rotate(Q(t.headTilt));
|
|
833
903
|
const w = -o.headRy;
|
|
834
904
|
e.beginPath(), e.ellipse(0, w, o.headRx, o.headRy, 0, 0, Math.PI * 2);
|
|
835
|
-
const
|
|
836
|
-
if (
|
|
905
|
+
const S = n.headFill ?? "#ffffff";
|
|
906
|
+
if (S !== "none" && (e.fillStyle = S, e.fill()), a) {
|
|
837
907
|
a.ellipse(0, w, o.headRx, o.headRy);
|
|
838
|
-
const
|
|
839
|
-
e.translate(
|
|
908
|
+
const k = a.nudge();
|
|
909
|
+
e.translate(k.x, k.y);
|
|
840
910
|
} else
|
|
841
911
|
e.stroke();
|
|
842
|
-
e.translate(0, w), e.scale(o.headRx / o.r, o.headRy / o.r),
|
|
843
|
-
}),
|
|
844
|
-
}
|
|
845
|
-
function
|
|
846
|
-
const
|
|
847
|
-
let o = e.walking > 0 ?
|
|
848
|
-
const
|
|
849
|
-
if (n &&
|
|
850
|
-
const
|
|
851
|
-
if (o =
|
|
852
|
-
const a = (h, c) => c ?
|
|
853
|
-
|
|
912
|
+
e.translate(0, w), e.scale(o.headRx / o.r, o.headRy / o.r), os(e, t, o.r, 0, r, o.lineWidth);
|
|
913
|
+
}), u(l.overHead), u(l.front), e.restore(), n.label && (e.save(), e.fillStyle = r, e.font = n.labelFont ?? `700 ${Math.round(o.height * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(n.label, 0, -o.height * o.stretch - 0.04 * o.height + o.drop), e.restore());
|
|
914
|
+
}
|
|
915
|
+
function On(e, t, n) {
|
|
916
|
+
const s = { ...e };
|
|
917
|
+
let o = e.walking > 0 ? Pe(s, Oo(e.gait, e.walk, s), e.walking) : s, r = fs(e);
|
|
918
|
+
const l = e.dancing ?? 0;
|
|
919
|
+
if (n && l > 0) {
|
|
920
|
+
const i = n(e.beat ?? 0);
|
|
921
|
+
if (o = Pe(o, i.pose, l), i.hands) {
|
|
922
|
+
const a = (h, c) => c ? Ke(h ?? L, c, l) : h;
|
|
923
|
+
r = { left: a(r?.left, i.hands.left), right: a(r?.right, i.hands.right) };
|
|
854
924
|
}
|
|
855
925
|
}
|
|
856
|
-
return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk *
|
|
926
|
+
return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk * Fo(t)) }), { pose: o, hands: r };
|
|
857
927
|
}
|
|
858
|
-
function
|
|
859
|
-
return
|
|
928
|
+
function cs(e, t, n) {
|
|
929
|
+
return On(e, t, n).pose;
|
|
860
930
|
}
|
|
861
|
-
const
|
|
862
|
-
function
|
|
931
|
+
const In = (e, t) => (e.facing ?? t.facing ?? 1) < 0 ? -1 : 1, Ue = (e, t) => `hand.${e}.${t}`;
|
|
932
|
+
function fs(e) {
|
|
863
933
|
const t = (o) => {
|
|
864
|
-
if (typeof e[
|
|
865
|
-
return Object.fromEntries(Object.keys(
|
|
866
|
-
}, n = t("left"),
|
|
867
|
-
return n ||
|
|
934
|
+
if (typeof e[Ue(o, "spread")] == "number")
|
|
935
|
+
return Object.fromEntries(Object.keys(L).map((r) => [r, e[Ue(o, r)]]));
|
|
936
|
+
}, n = t("left"), s = t("right");
|
|
937
|
+
return n || s ? { left: n, right: s } : void 0;
|
|
868
938
|
}
|
|
869
|
-
function
|
|
939
|
+
function us(e, t) {
|
|
870
940
|
return !t || !e.hands ? e : { ...e, hands: { ...e.hands, left: t.left ?? e.hands.left, right: t.right ?? e.hands.right } };
|
|
871
941
|
}
|
|
872
|
-
function
|
|
873
|
-
const t = e.style ?? {}, n = t.height ?? 300,
|
|
942
|
+
function mi(e) {
|
|
943
|
+
const t = e.style ?? {}, n = t.height ?? 300, s = n * 0.8, o = { ...z(e.pose ?? {}), walk: 0, walking: 0, gait: "walk", facing: (t.facing ?? 1) < 0 ? -1 : 1, talk: 0, rubber: t.rubber ?? 0, beat: 0, dancing: 0 }, r = {};
|
|
874
944
|
if (t.hands)
|
|
875
|
-
for (const
|
|
876
|
-
const
|
|
877
|
-
for (const a of Object.keys(
|
|
945
|
+
for (const l of ["left", "right"]) {
|
|
946
|
+
const i = t.hands[l] ?? L;
|
|
947
|
+
for (const a of Object.keys(L)) r[Ue(l, a)] = i[a] ?? L[a];
|
|
878
948
|
}
|
|
879
949
|
return {
|
|
880
950
|
type: "custom",
|
|
881
|
-
x: e.x -
|
|
951
|
+
x: e.x - s / 2,
|
|
882
952
|
y: e.y - n,
|
|
883
|
-
width:
|
|
953
|
+
width: s,
|
|
884
954
|
height: n,
|
|
885
|
-
props: { ...o, ...
|
|
955
|
+
props: { ...o, ...r },
|
|
886
956
|
figureStyle: t,
|
|
887
957
|
figureDance: e.dance,
|
|
888
|
-
draw(
|
|
889
|
-
const h =
|
|
890
|
-
|
|
958
|
+
draw(l, i, a) {
|
|
959
|
+
const h = i.props, c = On(h, a, e.dance);
|
|
960
|
+
l.translate(s / 2, n), hs(l, c.pose, us({ ...t, rubber: h.rubber, facing: In(h, t) }, c.hands), a);
|
|
891
961
|
}
|
|
892
962
|
};
|
|
893
963
|
}
|
|
894
|
-
function
|
|
895
|
-
const
|
|
896
|
-
if (!
|
|
964
|
+
function ds(e, t, n) {
|
|
965
|
+
const s = e.figureStyle;
|
|
966
|
+
if (!s) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
|
|
897
967
|
const o = { ...e.props };
|
|
898
|
-
let
|
|
968
|
+
let r = 0, l = 0;
|
|
899
969
|
for (const [h, c] of t.state?.values.get(n) ?? [])
|
|
900
|
-
typeof c == "number" && (h === "x" || h === "motionPathX" ?
|
|
901
|
-
const
|
|
902
|
-
return { pose:
|
|
903
|
-
}
|
|
904
|
-
function
|
|
905
|
-
const
|
|
906
|
-
return
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
}),
|
|
910
|
-
|
|
970
|
+
h === "gait" && typeof c == "string" && (o.gait = c), typeof c == "number" && (h === "x" || h === "motionPathX" ? r = c : h === "y" || h === "motionPathY" ? l = c : h in o && (o[h] = c));
|
|
971
|
+
const i = cs(o, t.time, e.figureDance), a = ls(i, { ...s, rubber: o.rubber, facing: In(o, s) });
|
|
972
|
+
return { pose: i, joints: as(a, e.x + r + e.width / 2, e.y + l + e.height) };
|
|
973
|
+
}
|
|
974
|
+
function _n(e) {
|
|
975
|
+
const t = [];
|
|
976
|
+
return e.forEach((n, s) => {
|
|
977
|
+
const o = s === 0 ? _ : t[s - 1], r = typeof n.pose == "string" ? Oe[n.pose] : { ...o, ...n.pose };
|
|
978
|
+
t.push(n.expression ? qe(r, n.expression) : r);
|
|
979
|
+
}), t;
|
|
980
|
+
}
|
|
981
|
+
function bi(e, t) {
|
|
982
|
+
const n = _n(t);
|
|
983
|
+
return kn.filter((s) => n.some((o) => o[s] !== _[s])).map((s) => ({
|
|
984
|
+
id: `${e}-${s}`,
|
|
911
985
|
target: e,
|
|
912
|
-
property:
|
|
913
|
-
keyframes: t.map((o,
|
|
986
|
+
property: s,
|
|
987
|
+
keyframes: t.map((o, r) => ({
|
|
914
988
|
time: o.time,
|
|
915
|
-
value: n[
|
|
989
|
+
value: n[r][s],
|
|
916
990
|
...o.easing ? { easing: o.easing } : {}
|
|
917
991
|
}))
|
|
918
992
|
}));
|
|
919
993
|
}
|
|
920
|
-
const
|
|
994
|
+
const tt = 0.5, Zt = {
|
|
921
995
|
/** Flag: fingers together and straight, thumb bent in */
|
|
922
|
-
pataka:
|
|
996
|
+
pataka: R({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
|
|
923
997
|
/** Pataka with the ring finger bent */
|
|
924
|
-
tripataka:
|
|
998
|
+
tripataka: R({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
|
|
925
999
|
/** Lotus in bloom: fingers fanned, each a little more curled than the last */
|
|
926
|
-
alapadma:
|
|
1000
|
+
alapadma: R({ "thumb.curl": 0.1, "thumb.across": 0, "index.curl": 0.05, "middle.curl": 0.15, "ring.curl": 0.25, "pinky.curl": 0.35, spread: 1, turn: 2 }),
|
|
927
1001
|
/** Fist */
|
|
928
|
-
mushti:
|
|
1002
|
+
mushti: C.fist,
|
|
929
1003
|
/** Fist, thumb up */
|
|
930
|
-
shikhara:
|
|
1004
|
+
shikhara: C.thumbsUp,
|
|
931
1005
|
/** Swan's beak: thumb and index touch, the others fanned */
|
|
932
|
-
hamsasya:
|
|
1006
|
+
hamsasya: R({ "thumb.curl": 0.15, "thumb.across": 0.6, "index.curl": 0.6, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0.7, turn: 2 }),
|
|
933
1007
|
/** Bracelet: thumb, index and middle meet, ring and little finger out */
|
|
934
|
-
katakamukha:
|
|
1008
|
+
katakamukha: R({ "thumb.curl": 0.2, "thumb.across": 0.6, "index.curl": 0.65, "middle.curl": 0.7, "ring.curl": 0, "pinky.curl": 0, spread: 0.4, turn: 2 })
|
|
935
1009
|
};
|
|
936
|
-
function
|
|
937
|
-
return typeof e != "string" ? e : e in
|
|
1010
|
+
function ze(e) {
|
|
1011
|
+
return typeof e != "string" ? e : e in Zt ? Zt[e] : C[e];
|
|
938
1012
|
}
|
|
939
|
-
function
|
|
940
|
-
const
|
|
1013
|
+
function $n(e, t, n) {
|
|
1014
|
+
const s = [];
|
|
941
1015
|
for (const o of e.keys) {
|
|
942
|
-
const
|
|
943
|
-
|
|
1016
|
+
const r = s[s.length - 1], l = !r || o.reset ? { pose: t, ...n } : r;
|
|
1017
|
+
s.push({
|
|
944
1018
|
beat: o.beat,
|
|
945
|
-
pose: { ...
|
|
946
|
-
left: o.hands?.left ?
|
|
947
|
-
right: o.hands?.right ?
|
|
1019
|
+
pose: { ...l.pose, ...o.pose },
|
|
1020
|
+
left: o.hands?.left ? ze(o.hands.left) : l.left,
|
|
1021
|
+
right: o.hands?.right ? ze(o.hands.right) : l.right,
|
|
948
1022
|
easing: o.easing ?? e.easing
|
|
949
1023
|
});
|
|
950
1024
|
}
|
|
951
|
-
return
|
|
1025
|
+
return s;
|
|
952
1026
|
}
|
|
953
|
-
const
|
|
954
|
-
function
|
|
955
|
-
const o =
|
|
956
|
-
if (o.length === 0) return { pose: n, hands:
|
|
957
|
-
const
|
|
958
|
-
let
|
|
959
|
-
for (let
|
|
960
|
-
const
|
|
1027
|
+
const At = (e, t) => (e % t + t) % t;
|
|
1028
|
+
function gs(e, t, n, s) {
|
|
1029
|
+
const o = $n(e, n, s);
|
|
1030
|
+
if (o.length === 0) return { pose: n, hands: s };
|
|
1031
|
+
const r = At(t, e.beats);
|
|
1032
|
+
let l = o.length - 1;
|
|
1033
|
+
for (let f = 0; f < o.length; f++) o[f].beat <= r && (l = f);
|
|
1034
|
+
const i = o[l], a = o[(l + 1) % o.length], h = i.beat <= r ? i.beat : i.beat - e.beats, c = a.beat > h ? a.beat : a.beat + e.beats, u = c > h ? (r - h) / (c - h) : 0, g = Qe(a.easing ?? "ease-in-out")(Math.min(1, Math.max(0, u)));
|
|
961
1035
|
return {
|
|
962
|
-
pose:
|
|
963
|
-
hands: { left:
|
|
1036
|
+
pose: Pe(i.pose, a.pose, g),
|
|
1037
|
+
hands: { left: Ke(i.left, a.left, g), right: Ke(i.right, a.right, g) }
|
|
964
1038
|
};
|
|
965
1039
|
}
|
|
966
|
-
const
|
|
1040
|
+
const ps = [
|
|
967
1041
|
["leftShoulder", "rightShoulder"],
|
|
968
1042
|
["leftElbow", "rightElbow"],
|
|
969
1043
|
["leftWrist", "rightWrist"],
|
|
@@ -973,151 +1047,151 @@ const xo = [
|
|
|
973
1047
|
["leftFootOut", "rightFootOut"],
|
|
974
1048
|
["leftEye", "rightEye"],
|
|
975
1049
|
["leftBrow", "rightBrow"]
|
|
976
|
-
],
|
|
977
|
-
function
|
|
1050
|
+
], ms = ["lean", "headTilt", "lookX", "spin"], bs = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
|
|
1051
|
+
function ws(e) {
|
|
978
1052
|
const t = { ...e }, n = (e.turn ?? 0) >= 0.5;
|
|
979
|
-
for (const [
|
|
980
|
-
const
|
|
981
|
-
t[
|
|
1053
|
+
for (const [s, o] of ps) {
|
|
1054
|
+
const r = n && bs.has(s) ? -1 : 1;
|
|
1055
|
+
t[s] = r * e[o], t[o] = r * e[s];
|
|
982
1056
|
}
|
|
983
|
-
if (!n) for (const
|
|
1057
|
+
if (!n) for (const s of ms) t[s] = -e[s];
|
|
984
1058
|
return t;
|
|
985
1059
|
}
|
|
986
|
-
const
|
|
987
|
-
function
|
|
988
|
-
const
|
|
1060
|
+
const ys = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
|
|
1061
|
+
function ks(e, t, n) {
|
|
1062
|
+
const s = At(n, 1), o = (1 + Math.cos(2 * Math.PI * s)) / 2, r = t.bounce * (t.accent === "up" ? 1 - o : o), l = Math.min(1, Math.max(0, e.turn ?? 0)), i = ys(l);
|
|
989
1063
|
return {
|
|
990
1064
|
...e,
|
|
991
|
-
leftHip: e.leftHip +
|
|
992
|
-
rightHip: e.rightHip +
|
|
993
|
-
leftKnee: e.leftKnee +
|
|
994
|
-
rightKnee: e.rightKnee +
|
|
995
|
-
lean: e.lean + (t.sway ?? 0) * (1 -
|
|
1065
|
+
leftHip: e.leftHip + i * r / 2,
|
|
1066
|
+
rightHip: e.rightHip + r / 2,
|
|
1067
|
+
leftKnee: e.leftKnee + i * r,
|
|
1068
|
+
rightKnee: e.rightKnee + r,
|
|
1069
|
+
lean: e.lean + (t.sway ?? 0) * (1 - l) * Math.sin(Math.PI * n)
|
|
996
1070
|
};
|
|
997
1071
|
}
|
|
998
|
-
function
|
|
999
|
-
const t = { ...
|
|
1000
|
-
return e.expression ?
|
|
1072
|
+
function yt(e) {
|
|
1073
|
+
const t = { ..._, ...e.stance };
|
|
1074
|
+
return e.expression ? qe(t, e.expression) : t;
|
|
1001
1075
|
}
|
|
1002
|
-
function
|
|
1076
|
+
function Bn(e) {
|
|
1003
1077
|
return {
|
|
1004
|
-
left: e.hands?.left ?
|
|
1005
|
-
right: e.hands?.right ?
|
|
1078
|
+
left: e.hands?.left ? ze(e.hands.left) : L,
|
|
1079
|
+
right: e.hands?.right ? ze(e.hands.right) : L
|
|
1006
1080
|
};
|
|
1007
1081
|
}
|
|
1008
|
-
function
|
|
1009
|
-
const
|
|
1010
|
-
if (!
|
|
1011
|
-
const o =
|
|
1012
|
-
return t.mirror ? { pose:
|
|
1082
|
+
function nt(e, t, n) {
|
|
1083
|
+
const s = e.moves[t.move];
|
|
1084
|
+
if (!s) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
|
|
1085
|
+
const o = gs(s, n, yt(e), Bn(e));
|
|
1086
|
+
return t.mirror ? { pose: ws(o.pose), hands: { left: o.hands?.right, right: o.hands?.left } } : o;
|
|
1013
1087
|
}
|
|
1014
|
-
function
|
|
1015
|
-
const
|
|
1088
|
+
function xt(e, t, n = {}) {
|
|
1089
|
+
const s = typeof e == "string" ? Se[e] : e;
|
|
1016
1090
|
let o;
|
|
1017
1091
|
if (n.move)
|
|
1018
|
-
o =
|
|
1092
|
+
o = nt(s, { move: n.move, mirror: n.mirror }, t);
|
|
1019
1093
|
else {
|
|
1020
|
-
const
|
|
1094
|
+
const r = s.routine, l = r.reduce((u, g) => u + g.beats, 0), i = At(t, l);
|
|
1021
1095
|
let a = 0, h = 0;
|
|
1022
|
-
for (; h <
|
|
1023
|
-
const c =
|
|
1024
|
-
if (o =
|
|
1025
|
-
const
|
|
1096
|
+
for (; h < r.length - 1 && i >= a + r[h].beats; ) a += r[h++].beats;
|
|
1097
|
+
const c = i - a;
|
|
1098
|
+
if (o = nt(s, r[h], c), c < tt && r.length > 1 && t >= tt) {
|
|
1099
|
+
const u = r[(h - 1 + r.length) % r.length], g = nt(s, u, u.beats + c), f = Qe("ease-in-out")(c / tt);
|
|
1026
1100
|
o = {
|
|
1027
|
-
pose:
|
|
1028
|
-
hands: { left:
|
|
1101
|
+
pose: Pe(g.pose, o.pose, f),
|
|
1102
|
+
hands: { left: Ke(g.hands.left, o.hands.left, f), right: Ke(g.hands.right, o.hands.right, f) }
|
|
1029
1103
|
};
|
|
1030
1104
|
}
|
|
1031
1105
|
}
|
|
1032
|
-
return { ...o, pose:
|
|
1106
|
+
return { ...o, pose: ks(o.pose, s.groove, t) };
|
|
1033
1107
|
}
|
|
1034
|
-
function
|
|
1035
|
-
return
|
|
1108
|
+
function wi(e, t, n = {}) {
|
|
1109
|
+
return xt(e, t, n).pose;
|
|
1036
1110
|
}
|
|
1037
|
-
function
|
|
1038
|
-
return (typeof e == "string" ?
|
|
1111
|
+
function Kt(e) {
|
|
1112
|
+
return (typeof e == "string" ? Se[e] : e).routine.reduce((n, s) => n + s.beats, 0);
|
|
1039
1113
|
}
|
|
1040
|
-
const
|
|
1041
|
-
function
|
|
1042
|
-
for (let
|
|
1114
|
+
const Ss = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
|
|
1115
|
+
function Qt(e, t, n, s, o, r, l) {
|
|
1116
|
+
for (let i = 0; i * e.beats < n; i++)
|
|
1043
1117
|
for (const a of e.keys) {
|
|
1044
|
-
const h =
|
|
1045
|
-
if (!(h >= n || c <
|
|
1046
|
-
for (const
|
|
1118
|
+
const h = i * e.beats + a.beat, c = t + h;
|
|
1119
|
+
if (!(h >= n || c < r || c >= l))
|
|
1120
|
+
for (const u of a.taps ?? []) o.push({ beat: c, tap: s ? Ss[u] : u });
|
|
1047
1121
|
}
|
|
1048
1122
|
}
|
|
1049
|
-
function
|
|
1050
|
-
const o = typeof e == "string" ?
|
|
1051
|
-
if (n <= t) return
|
|
1052
|
-
if (
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1123
|
+
function yi(e, t, n, s = {}) {
|
|
1124
|
+
const o = typeof e == "string" ? Se[e] : e, r = [];
|
|
1125
|
+
if (n <= t) return r;
|
|
1126
|
+
if (s.move) {
|
|
1127
|
+
const l = o.moves[s.move], i = Math.floor(t / l.beats) * l.beats;
|
|
1128
|
+
Qt(l, i, Math.ceil((n - i) / l.beats) * l.beats, s.mirror, r, t, n);
|
|
1055
1129
|
} else {
|
|
1056
|
-
const
|
|
1057
|
-
for (let
|
|
1058
|
-
let a =
|
|
1130
|
+
const l = Kt(o);
|
|
1131
|
+
for (let i = Math.floor(t / l) * l; i < n; i += l) {
|
|
1132
|
+
let a = i;
|
|
1059
1133
|
for (const h of o.routine)
|
|
1060
|
-
|
|
1134
|
+
Qt(o.moves[h.move], a, h.beats, h.mirror, r, t, n), a += h.beats;
|
|
1061
1135
|
}
|
|
1062
1136
|
}
|
|
1063
|
-
return
|
|
1137
|
+
return r.sort((l, i) => l.beat - i.beat);
|
|
1064
1138
|
}
|
|
1065
|
-
function
|
|
1139
|
+
function en(e, t) {
|
|
1066
1140
|
const n = e.moves[t.move];
|
|
1067
1141
|
if (!n?.travel) return 0;
|
|
1068
|
-
const
|
|
1069
|
-
return t.mirror ? (
|
|
1142
|
+
const s = n.travel / n.beats;
|
|
1143
|
+
return t.mirror ? ($n(n, yt(e), Bn(e))[0]?.pose.turn ?? yt(e).turn ?? 0) >= 0.5 ? s : -s : s;
|
|
1070
1144
|
}
|
|
1071
|
-
function
|
|
1145
|
+
function Fn(e, t) {
|
|
1072
1146
|
return t.move ? [{ move: t.move, beats: e.moves[t.move].beats, mirror: t.mirror }] : e.routine;
|
|
1073
1147
|
}
|
|
1074
|
-
function
|
|
1075
|
-
const
|
|
1076
|
-
let a =
|
|
1148
|
+
function ot(e, t, n = {}) {
|
|
1149
|
+
const s = typeof e == "string" ? Se[e] : e, o = Fn(s, n), r = o.reduce((c, u) => c + u.beats, 0), l = o.reduce((c, u) => c + en(s, u) * u.beats, 0), i = Math.floor(t / r);
|
|
1150
|
+
let a = i * l, h = t - i * r;
|
|
1077
1151
|
for (const c of o) {
|
|
1078
|
-
const
|
|
1079
|
-
if (a +=
|
|
1152
|
+
const u = Math.min(c.beats, h);
|
|
1153
|
+
if (a += en(s, c) * u, h -= u, h <= 0) break;
|
|
1080
1154
|
}
|
|
1081
1155
|
return a;
|
|
1082
1156
|
}
|
|
1083
|
-
function
|
|
1084
|
-
const
|
|
1085
|
-
let
|
|
1086
|
-
for (let
|
|
1087
|
-
|
|
1157
|
+
function Es(e, t, n) {
|
|
1158
|
+
const s = Fn(e, n), o = [0];
|
|
1159
|
+
let r = 0;
|
|
1160
|
+
for (let l = 0; r < t; l = (l + 1) % s.length)
|
|
1161
|
+
r += s[l].beats, o.push(Math.min(r, t));
|
|
1088
1162
|
return o;
|
|
1089
1163
|
}
|
|
1090
|
-
const
|
|
1091
|
-
function
|
|
1092
|
-
const
|
|
1093
|
-
if (
|
|
1094
|
-
const
|
|
1095
|
-
let
|
|
1096
|
-
const
|
|
1097
|
-
if (
|
|
1098
|
-
const
|
|
1099
|
-
for (let
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1164
|
+
const Ms = 8;
|
|
1165
|
+
function Hs(e, t, n) {
|
|
1166
|
+
const s = typeof t == "string" ? Se[t] : t, o = n.bpm ?? s.bpm, r = n.beats ?? (n.move ? s.moves[n.move].beats : Kt(s)), l = Es(s, r, n);
|
|
1167
|
+
if (l.every((b) => ot(s, b, n) === 0)) return;
|
|
1168
|
+
const i = Math.min(n.fade ?? 1, r / 2), a = Qe("ease-in-out"), h = (b) => i <= 0 ? 1 : Math.min(a(Math.min(1, b / i)), a(Math.min(1, (r - b) / i))), c = Math.ceil(i * Ms), u = i <= 0 ? [] : Array.from({ length: c + 1 }, (b, y) => [y / c * i, r - y / c * i]).flat(), g = [.../* @__PURE__ */ new Set([...l, ...u])].sort((b, y) => b - y);
|
|
1169
|
+
let f = 0;
|
|
1170
|
+
const p = g.map((b, y) => {
|
|
1171
|
+
if (y > 0) {
|
|
1172
|
+
const E = g[y - 1], H = Math.max(1, Math.ceil((b - E) * 16));
|
|
1173
|
+
for (let M = 0; M < H; M++) {
|
|
1174
|
+
const A = E + (b - E) * M / H, w = E + (b - E) * (M + 1) / H;
|
|
1175
|
+
f += (ot(s, w, n) - ot(s, A, n)) * h((A + w) / 2);
|
|
1102
1176
|
}
|
|
1103
1177
|
}
|
|
1104
|
-
return { beat:
|
|
1105
|
-
}),
|
|
1178
|
+
return { beat: b, travel: f };
|
|
1179
|
+
}), d = n.start ?? 0, m = n.x ?? 0;
|
|
1106
1180
|
return {
|
|
1107
1181
|
id: `${e}-x`,
|
|
1108
1182
|
target: e,
|
|
1109
1183
|
property: "x",
|
|
1110
|
-
keyframes:
|
|
1184
|
+
keyframes: p.map((b) => ({ time: d + b.beat * 6e4 / o, value: m + n.height * b.travel, easing: "linear" }))
|
|
1111
1185
|
};
|
|
1112
1186
|
}
|
|
1113
|
-
function
|
|
1187
|
+
function ki(e, t, n = 0) {
|
|
1114
1188
|
return (e - n) * t / 6e4;
|
|
1115
1189
|
}
|
|
1116
|
-
function
|
|
1117
|
-
return (n) =>
|
|
1190
|
+
function Si(e, t = {}) {
|
|
1191
|
+
return (n) => xt(e, n, t);
|
|
1118
1192
|
}
|
|
1119
|
-
function
|
|
1120
|
-
const n = t.start ?? 0,
|
|
1193
|
+
function Ei(e, t) {
|
|
1194
|
+
const n = t.start ?? 0, s = 6e4 / t.bpm, o = n + t.beats * s, r = Math.min((t.fade ?? 1) * s, (o - n) / 2);
|
|
1121
1195
|
return [
|
|
1122
1196
|
{
|
|
1123
1197
|
id: `${e}-beat`,
|
|
@@ -1134,33 +1208,33 @@ function ns(e, t) {
|
|
|
1134
1208
|
property: "dancing",
|
|
1135
1209
|
keyframes: [
|
|
1136
1210
|
{ time: n, value: 0 },
|
|
1137
|
-
{ time: n +
|
|
1138
|
-
{ time: o -
|
|
1211
|
+
{ time: n + r, value: 1, easing: "ease-in-out" },
|
|
1212
|
+
{ time: o - r, value: 1 },
|
|
1139
1213
|
{ time: o, value: 0, easing: "ease-in-out" }
|
|
1140
1214
|
]
|
|
1141
1215
|
}
|
|
1142
1216
|
];
|
|
1143
1217
|
}
|
|
1144
|
-
function
|
|
1145
|
-
const
|
|
1146
|
-
const
|
|
1147
|
-
return { time:
|
|
1148
|
-
}), c = (
|
|
1149
|
-
id: `${e}-${
|
|
1218
|
+
function Mi(e, t, n = {}) {
|
|
1219
|
+
const s = typeof t == "string" ? Se[t] : t, o = n.bpm ?? s.bpm, r = n.beats ?? (n.move ? s.moves[n.move].beats : Kt(s)), l = n.samplesPerBeat ?? 4, i = n.start ?? 0, a = Math.round(r * l), h = Array.from({ length: a + 1 }, (d, m) => {
|
|
1220
|
+
const b = m / l;
|
|
1221
|
+
return { time: i + b * 6e4 / o, frame: xt(s, b, n) };
|
|
1222
|
+
}), c = (d, m) => ({
|
|
1223
|
+
id: `${e}-${d}`,
|
|
1150
1224
|
target: e,
|
|
1151
|
-
property:
|
|
1152
|
-
keyframes: h.map((
|
|
1153
|
-
}),
|
|
1154
|
-
if (
|
|
1155
|
-
const
|
|
1156
|
-
for (const
|
|
1157
|
-
for (const
|
|
1158
|
-
const
|
|
1159
|
-
h.some((
|
|
1225
|
+
property: d,
|
|
1226
|
+
keyframes: h.map((b) => ({ time: b.time, value: m(b.frame) }))
|
|
1227
|
+
}), g = Object.keys(_).filter((d) => h.some((m) => m.frame.pose[d] !== h[0].frame.pose[d]) || h[0].frame.pose[d] !== _[d]).map((d) => c(d, (m) => m.pose[d])), f = n.height === void 0 ? void 0 : Hs(e, s, { ...n, bpm: o, beats: r, start: i, height: n.height, fade: 0 });
|
|
1228
|
+
if (f && g.push(f), n.hands === !1) return g;
|
|
1229
|
+
const p = [];
|
|
1230
|
+
for (const d of ["left", "right"])
|
|
1231
|
+
for (const m of Object.keys(L)) {
|
|
1232
|
+
const b = (y) => y.hands?.[d]?.[m] ?? L[m];
|
|
1233
|
+
h.some((y) => b(y.frame) !== L[m]) && p.push(c(Ue(d, m), b));
|
|
1160
1234
|
}
|
|
1161
|
-
return [...
|
|
1235
|
+
return [...g, ...p];
|
|
1162
1236
|
}
|
|
1163
|
-
const
|
|
1237
|
+
const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic", vs = {
|
|
1164
1238
|
label: "Disco",
|
|
1165
1239
|
bpm: 120,
|
|
1166
1240
|
stance: { leftHip: 10, rightHip: 10, leftKnee: 6, rightKnee: 6 },
|
|
@@ -1170,7 +1244,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1170
1244
|
point: {
|
|
1171
1245
|
label: "The point",
|
|
1172
1246
|
beats: 2,
|
|
1173
|
-
easing:
|
|
1247
|
+
easing: V,
|
|
1174
1248
|
keys: [
|
|
1175
1249
|
{
|
|
1176
1250
|
beat: 0,
|
|
@@ -1195,9 +1269,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1195
1269
|
label: "Bump and clap",
|
|
1196
1270
|
beats: 4,
|
|
1197
1271
|
keys: [
|
|
1198
|
-
{ beat: 0, pose: { lean: -10, rightHip: 22, leftHip: 4, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing:
|
|
1272
|
+
{ beat: 0, pose: { lean: -10, rightHip: 22, leftHip: 4, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: V },
|
|
1199
1273
|
{ beat: 1, pose: { lean: 0, rightHip: 10, leftHip: 10, leftShoulder: 168, rightShoulder: 168, leftElbow: 22, rightElbow: 22, leftWrist: 0, rightWrist: 0 }, hands: { left: "flat", right: "flat" } },
|
|
1200
|
-
{ beat: 2, pose: { lean: 10, rightHip: 4, leftHip: 22, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing:
|
|
1274
|
+
{ beat: 2, pose: { lean: 10, rightHip: 4, leftHip: 22, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: V },
|
|
1201
1275
|
{ beat: 3, pose: { lean: 0, rightHip: 10, leftHip: 10, leftShoulder: 168, rightShoulder: 168, leftElbow: 22, rightElbow: 22, leftWrist: 0, rightWrist: 0 }, hands: { left: "flat", right: "flat" } }
|
|
1202
1276
|
]
|
|
1203
1277
|
}
|
|
@@ -1208,7 +1282,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1208
1282
|
{ move: "point", beats: 8, mirror: !0 },
|
|
1209
1283
|
{ move: "bump", beats: 8 }
|
|
1210
1284
|
]
|
|
1211
|
-
},
|
|
1285
|
+
}, Ts = {
|
|
1212
1286
|
label: "Hip hop",
|
|
1213
1287
|
bpm: 95,
|
|
1214
1288
|
stance: { leftHip: 14, rightHip: 14, leftKnee: 20, rightKnee: 20, leftShoulder: 22, rightShoulder: 22, leftElbow: -30, rightElbow: -30, leftFootOut: 0.15, rightFootOut: 0.15 },
|
|
@@ -1260,7 +1334,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1260
1334
|
{ move: "armWave", beats: 8 },
|
|
1261
1335
|
{ move: "bounce", beats: 4 }
|
|
1262
1336
|
]
|
|
1263
|
-
},
|
|
1337
|
+
}, As = {
|
|
1264
1338
|
label: "Breaking (toprock)",
|
|
1265
1339
|
bpm: 110,
|
|
1266
1340
|
stance: { leftHip: 14, rightHip: 14, leftKnee: 14, rightKnee: 14, leftShoulder: 35, rightShoulder: 35, leftElbow: -90, rightElbow: -90 },
|
|
@@ -1272,9 +1346,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1272
1346
|
label: "Toprock (Indian step)",
|
|
1273
1347
|
beats: 4,
|
|
1274
1348
|
keys: [
|
|
1275
|
-
{ beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing:
|
|
1349
|
+
{ beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: V },
|
|
1276
1350
|
{ beat: 1, reset: !0, pose: { leftHip: 18, rightHip: 18 } },
|
|
1277
|
-
{ beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing:
|
|
1351
|
+
{ beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: V },
|
|
1278
1352
|
{ beat: 3, reset: !0, pose: { leftHip: 18, rightHip: 18 } }
|
|
1279
1353
|
]
|
|
1280
1354
|
},
|
|
@@ -1282,7 +1356,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1282
1356
|
label: "Kick out",
|
|
1283
1357
|
beats: 2,
|
|
1284
1358
|
keys: [
|
|
1285
|
-
{ beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing:
|
|
1359
|
+
{ beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: V },
|
|
1286
1360
|
{ beat: 1, reset: !0 }
|
|
1287
1361
|
]
|
|
1288
1362
|
},
|
|
@@ -1290,7 +1364,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1290
1364
|
label: "B-boy stance",
|
|
1291
1365
|
beats: 4,
|
|
1292
1366
|
keys: [
|
|
1293
|
-
{ beat: 0, reset: !0, pose: { leftShoulder: 26, leftElbow: -122, rightShoulder: 22, rightElbow: -118, leftHip: 18, rightHip: 18, leftKnee: 6, rightKnee: 6, lean: -4, headTilt: 10, smile: 0.6, leftEye: 0.6, rightEye: 0.6 }, easing:
|
|
1367
|
+
{ beat: 0, reset: !0, pose: { leftShoulder: 26, leftElbow: -122, rightShoulder: 22, rightElbow: -118, leftHip: 18, rightHip: 18, leftKnee: 6, rightKnee: 6, lean: -4, headTilt: 10, smile: 0.6, leftEye: 0.6, rightEye: 0.6 }, easing: xe },
|
|
1294
1368
|
{ beat: 2, pose: { headTilt: 14, lean: -6 } }
|
|
1295
1369
|
]
|
|
1296
1370
|
}
|
|
@@ -1302,7 +1376,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1302
1376
|
{ move: "kick", beats: 4, mirror: !0 },
|
|
1303
1377
|
{ move: "freeze", beats: 4 }
|
|
1304
1378
|
]
|
|
1305
|
-
},
|
|
1379
|
+
}, xs = {
|
|
1306
1380
|
label: "Jazz",
|
|
1307
1381
|
bpm: 130,
|
|
1308
1382
|
stance: { leftHip: 10, rightHip: 10 },
|
|
@@ -1318,14 +1392,14 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1318
1392
|
beat: e,
|
|
1319
1393
|
// The hands shimmer: the wrists flick a little each quarter beat.
|
|
1320
1394
|
pose: { leftShoulder: 128, rightShoulder: 128, leftElbow: 8, rightElbow: 8, leftWrist: t % 2 ? 4 : 26, rightWrist: t % 2 ? 26 : 4, leftHip: 16, rightHip: 16, leftKnee: e < 1 ? 26 : 8, rightKnee: e < 1 ? 26 : 8 },
|
|
1321
|
-
hands: t === 0 ? { left: { ...
|
|
1395
|
+
hands: t === 0 ? { left: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } } : void 0
|
|
1322
1396
|
}))
|
|
1323
1397
|
},
|
|
1324
1398
|
kickBallChange: {
|
|
1325
1399
|
label: "Kick ball change",
|
|
1326
1400
|
beats: 2,
|
|
1327
1401
|
keys: [
|
|
1328
|
-
{ beat: 0, reset: !0, pose: { rightHip: 88, rightKnee: 0, rightAnkle: 55, leftHip: 4, lean: -12, leftShoulder: 112, rightShoulder: 112, leftWrist: 15, rightWrist: 15 }, hands: { left: "flat", right: "flat" }, easing:
|
|
1402
|
+
{ beat: 0, reset: !0, pose: { rightHip: 88, rightKnee: 0, rightAnkle: 55, leftHip: 4, lean: -12, leftShoulder: 112, rightShoulder: 112, leftWrist: 15, rightWrist: 15 }, hands: { left: "flat", right: "flat" }, easing: V },
|
|
1329
1403
|
{ beat: 1, reset: !0, pose: { rightHip: 10, rightKnee: 24, rightAnkle: 45, leftShoulder: 60, rightShoulder: 60, leftElbow: -20, rightElbow: -20 } },
|
|
1330
1404
|
{ beat: 1.5, pose: { rightAnkle: 0, rightKnee: 6, leftAnkle: 45, leftKnee: 20 } }
|
|
1331
1405
|
]
|
|
@@ -1363,7 +1437,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1363
1437
|
{ move: "jazzHands", beats: 4 },
|
|
1364
1438
|
{ move: "splitDrop", beats: 8 }
|
|
1365
1439
|
]
|
|
1366
|
-
},
|
|
1440
|
+
}, Ks = {
|
|
1367
1441
|
label: "K-pop",
|
|
1368
1442
|
bpm: 125,
|
|
1369
1443
|
stance: { leftHip: 9, rightHip: 9, leftKnee: 4, rightKnee: 4 },
|
|
@@ -1373,7 +1447,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1373
1447
|
pointCombo: {
|
|
1374
1448
|
label: "Point combo",
|
|
1375
1449
|
beats: 4,
|
|
1376
|
-
easing:
|
|
1450
|
+
easing: xe,
|
|
1377
1451
|
keys: [
|
|
1378
1452
|
{ beat: 0, reset: !0, pose: { rightShoulder: 142, rightElbow: 0, leftShoulder: 25, leftElbow: -125, headTilt: 6, lean: -3, lookX: 0.6, lookY: -0.6 }, hands: { right: "point", left: "flat" } },
|
|
1379
1453
|
{ beat: 1, pose: { rightShoulder: -38, headTilt: -6, lean: 3, lookX: -0.3, lookY: 0.5, rightHip: 18 } },
|
|
@@ -1385,16 +1459,16 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1385
1459
|
label: "Big heart, finger heart",
|
|
1386
1460
|
beats: 4,
|
|
1387
1461
|
keys: [
|
|
1388
|
-
{ beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing:
|
|
1462
|
+
{ beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: xe },
|
|
1389
1463
|
{ beat: 1, pose: { headTilt: 8, lean: 4 } },
|
|
1390
|
-
{ beat: 2, reset: !0, pose: { rightShoulder: 32, rightElbow: 112, rightWrist: 10, leftShoulder: 20, leftElbow: -30, headTilt: 10, leftEye: 0, smile: 1 }, hands: { right: "pinch", left: "relaxed" }, easing:
|
|
1464
|
+
{ beat: 2, reset: !0, pose: { rightShoulder: 32, rightElbow: 112, rightWrist: 10, leftShoulder: 20, leftElbow: -30, headTilt: 10, leftEye: 0, smile: 1 }, hands: { right: "pinch", left: "relaxed" }, easing: xe },
|
|
1391
1465
|
{ beat: 3, pose: { headTilt: 4 } }
|
|
1392
1466
|
]
|
|
1393
1467
|
},
|
|
1394
1468
|
isolations: {
|
|
1395
1469
|
label: "Isolations",
|
|
1396
1470
|
beats: 2,
|
|
1397
|
-
easing:
|
|
1471
|
+
easing: V,
|
|
1398
1472
|
keys: [
|
|
1399
1473
|
{ beat: 0, reset: !0, pose: { lean: -9, headTilt: 11, leftShoulder: 55, leftElbow: -112, rightShoulder: 55, rightElbow: -112, rightHip: 18 }, hands: { left: "fist", right: "fist" } },
|
|
1400
1474
|
{ beat: 0.5, pose: { lean: 0, headTilt: 0, rightHip: 9 } },
|
|
@@ -1410,7 +1484,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1410
1484
|
{ move: "pointCombo", beats: 8, mirror: !0 },
|
|
1411
1485
|
{ move: "isolations", beats: 4 }
|
|
1412
1486
|
]
|
|
1413
|
-
},
|
|
1487
|
+
}, Ps = {
|
|
1414
1488
|
label: "Bollywood",
|
|
1415
1489
|
bpm: 120,
|
|
1416
1490
|
stance: { leftHip: 10, rightHip: 10 },
|
|
@@ -1421,19 +1495,19 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1421
1495
|
label: "Screw the bulb, pat the dog",
|
|
1422
1496
|
beats: 2,
|
|
1423
1497
|
keys: [
|
|
1424
|
-
{ beat: 0, reset: !0, pose: { rightShoulder: 160, rightElbow: 12, rightWrist: -15, leftShoulder: 40, leftElbow: -12, leftWrist: -45, lean: -4, rightHip: 16, lookX: 0.5, lookY: -0.6 }, hands: { right: { ...
|
|
1425
|
-
{ beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...
|
|
1426
|
-
{ beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...
|
|
1427
|
-
{ beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...
|
|
1498
|
+
{ beat: 0, reset: !0, pose: { rightShoulder: 160, rightElbow: 12, rightWrist: -15, leftShoulder: 40, leftElbow: -12, leftWrist: -45, lean: -4, rightHip: 16, lookX: 0.5, lookY: -0.6 }, hands: { right: { ...C.cupped, roll: -30 }, left: { ...C.flat, turn: 0 } } },
|
|
1499
|
+
{ beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...C.cupped, roll: 30 } } },
|
|
1500
|
+
{ beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...C.cupped, roll: -30 } } },
|
|
1501
|
+
{ beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...C.cupped, roll: 30 } } }
|
|
1428
1502
|
]
|
|
1429
1503
|
},
|
|
1430
1504
|
thumka: {
|
|
1431
1505
|
label: "Thumka",
|
|
1432
1506
|
beats: 2,
|
|
1433
1507
|
keys: [
|
|
1434
|
-
{ beat: 0, reset: !0, pose: { lean: -11, rightHip: 22, leftHip: 2, leftKnee: 14, rightShoulder: 45, rightElbow: -105, leftShoulder: 128, leftElbow: 18, leftWrist: 35, headTilt: 10, lookX: -0.5 }, hands: { right: "fist", left: { ...
|
|
1508
|
+
{ beat: 0, reset: !0, pose: { lean: -11, rightHip: 22, leftHip: 2, leftKnee: 14, rightShoulder: 45, rightElbow: -105, leftShoulder: 128, leftElbow: 18, leftWrist: 35, headTilt: 10, lookX: -0.5 }, hands: { right: "fist", left: { ...C.open, turn: 2 } }, easing: V },
|
|
1435
1509
|
{ beat: 0.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } },
|
|
1436
|
-
{ beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing:
|
|
1510
|
+
{ beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: V },
|
|
1437
1511
|
{ beat: 1.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } }
|
|
1438
1512
|
]
|
|
1439
1513
|
},
|
|
@@ -1442,9 +1516,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1442
1516
|
beats: 4,
|
|
1443
1517
|
keys: [
|
|
1444
1518
|
{ beat: 0, reset: !0, pose: { leftShoulder: 22, rightShoulder: 22, leftElbow: -62, rightElbow: -62, leftHip: 16, rightHip: 16, leftKnee: 26, rightKnee: 26 }, hands: { left: "fist", right: "fist" } },
|
|
1445
|
-
{ beat: 1, pose: { leftShoulder: 132, rightShoulder: 132, leftElbow: 0, rightElbow: 0, leftWrist: 30, rightWrist: 30, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10, stretch: 1.03 }, hands: { left: "spread", right: "spread" }, easing:
|
|
1519
|
+
{ beat: 1, pose: { leftShoulder: 132, rightShoulder: 132, leftElbow: 0, rightElbow: 0, leftWrist: 30, rightWrist: 30, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10, stretch: 1.03 }, hands: { left: "spread", right: "spread" }, easing: V },
|
|
1446
1520
|
{ beat: 2, pose: { leftShoulder: 22, rightShoulder: 22, leftElbow: -62, rightElbow: -62, leftWrist: 0, rightWrist: 0, leftHip: 16, rightHip: 16, leftKnee: 26, rightKnee: 26, stretch: 1 }, hands: { left: "fist", right: "fist" } },
|
|
1447
|
-
{ beat: 3, pose: { leftShoulder: 62, rightShoulder: 62, leftElbow: 0, rightElbow: 0, leftWrist: 35, rightWrist: 35, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10 }, hands: { left: "spread", right: "spread" }, easing:
|
|
1521
|
+
{ beat: 3, pose: { leftShoulder: 62, rightShoulder: 62, leftElbow: 0, rightElbow: 0, leftWrist: 35, rightWrist: 35, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10 }, hands: { left: "spread", right: "spread" }, easing: V }
|
|
1448
1522
|
]
|
|
1449
1523
|
}
|
|
1450
1524
|
},
|
|
@@ -1455,7 +1529,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1455
1529
|
{ move: "thumka", beats: 4, mirror: !0 },
|
|
1456
1530
|
{ move: "lightBulb", beats: 8, mirror: !0 }
|
|
1457
1531
|
]
|
|
1458
|
-
},
|
|
1532
|
+
}, Ws = {
|
|
1459
1533
|
label: "Bhangra",
|
|
1460
1534
|
bpm: 100,
|
|
1461
1535
|
stance: { leftShoulder: 150, rightShoulder: 150, leftElbow: 18, rightElbow: 18, leftHip: 10, rightHip: 10 },
|
|
@@ -1490,11 +1564,11 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1490
1564
|
{ move: "basic", beats: 8 },
|
|
1491
1565
|
{ move: "dhamaal", beats: 4 }
|
|
1492
1566
|
]
|
|
1493
|
-
},
|
|
1567
|
+
}, Os = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Is = {
|
|
1494
1568
|
label: "Bharatanatyam",
|
|
1495
1569
|
bpm: 80,
|
|
1496
1570
|
// Natyarambhe: arms out at shoulder height, hands raised in pataka.
|
|
1497
|
-
stance: { ...
|
|
1571
|
+
stance: { ...Os, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
|
|
1498
1572
|
expression: { smile: 0.5, leftEye: 1.2, rightEye: 1.2, leftBrow: 0.3, rightBrow: 0.3 },
|
|
1499
1573
|
hands: { left: "pataka", right: "pataka" },
|
|
1500
1574
|
groove: { bounce: 0 },
|
|
@@ -1536,21 +1610,21 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1536
1610
|
{ move: "alapadma", beats: 8 },
|
|
1537
1611
|
{ move: "tatta", beats: 4 }
|
|
1538
1612
|
]
|
|
1539
|
-
},
|
|
1613
|
+
}, _s = {
|
|
1540
1614
|
label: "Charleston",
|
|
1541
1615
|
bpm: 150,
|
|
1542
1616
|
stance: { leftHip: 10, rightHip: 10, leftKnee: 10, rightKnee: 10, leftShoulder: 30, rightShoulder: 30, leftElbow: 20, rightElbow: 20 },
|
|
1543
1617
|
expression: { mouth: 0.4, smile: 1, leftBrow: 0.5, rightBrow: 0.5 },
|
|
1544
|
-
hands: { left: { ...
|
|
1618
|
+
hands: { left: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } },
|
|
1545
1619
|
groove: { bounce: 8, accent: "down" },
|
|
1546
1620
|
moves: {
|
|
1547
1621
|
basic: {
|
|
1548
1622
|
label: "Kick forward, kick back",
|
|
1549
1623
|
beats: 4,
|
|
1550
1624
|
keys: [
|
|
1551
|
-
{ beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 8, rightAnkle: 45, leftShoulder: 75, rightShoulder: 15, leftElbow: 30, rightElbow: -10, lean: -7, headTilt: -5 }, easing:
|
|
1625
|
+
{ beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 8, rightAnkle: 45, leftShoulder: 75, rightShoulder: 15, leftElbow: 30, rightElbow: -10, lean: -7, headTilt: -5 }, easing: V },
|
|
1552
1626
|
{ beat: 1, reset: !0 },
|
|
1553
|
-
{ beat: 2, reset: !0, pose: { leftHip: 18, leftKnee: 85, leftAnkle: 35, rightShoulder: 75, leftShoulder: 15, rightElbow: 30, leftElbow: -10, lean: 7, headTilt: 5 }, easing:
|
|
1627
|
+
{ beat: 2, reset: !0, pose: { leftHip: 18, leftKnee: 85, leftAnkle: 35, rightShoulder: 75, leftShoulder: 15, rightElbow: 30, leftElbow: -10, lean: 7, headTilt: 5 }, easing: V },
|
|
1554
1628
|
{ beat: 3, reset: !0 }
|
|
1555
1629
|
]
|
|
1556
1630
|
},
|
|
@@ -1586,7 +1660,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1586
1660
|
{ move: "basic", beats: 8, mirror: !0 },
|
|
1587
1661
|
{ move: "twist", beats: 4 }
|
|
1588
1662
|
]
|
|
1589
|
-
},
|
|
1663
|
+
}, $s = {
|
|
1590
1664
|
label: "Tap",
|
|
1591
1665
|
bpm: 120,
|
|
1592
1666
|
// Three-quarters to side-on, so shuffles read as brushes forward and back. Side-on,
|
|
@@ -1672,7 +1746,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1672
1746
|
{ beat: 0.75, pose: { rightAnkle: 0, rise: 0 }, taps: ["rightHeel"] },
|
|
1673
1747
|
{ beat: 0.875, pose: { leftAnkle: 0 }, taps: ["leftHeel"] },
|
|
1674
1748
|
// Arms flare on the finish: one up in front, one up behind.
|
|
1675
|
-
{ beat: 1, pose: { rightShoulder: 135, leftShoulder: 125, leftElbow: 0, rightElbow: 0, leftWrist: 0, rightWrist: 30, rightKnee: 8, leftKnee: -8, rightHip: 4, leftHip: -4 }, hands: { left: { ...
|
|
1749
|
+
{ beat: 1, pose: { rightShoulder: 135, leftShoulder: 125, leftElbow: 0, rightElbow: 0, leftWrist: 0, rightWrist: 30, rightKnee: 8, leftKnee: -8, rightHip: 4, leftHip: -4 }, hands: { left: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } } },
|
|
1676
1750
|
{ beat: 1.75, reset: !0 }
|
|
1677
1751
|
]
|
|
1678
1752
|
}
|
|
@@ -1684,7 +1758,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1684
1758
|
{ move: "heelToe", beats: 8 },
|
|
1685
1759
|
{ move: "crampRoll", beats: 4 }
|
|
1686
1760
|
]
|
|
1687
|
-
},
|
|
1761
|
+
}, Bs = {
|
|
1688
1762
|
label: "Popping (glides, moonwalk)",
|
|
1689
1763
|
bpm: 100,
|
|
1690
1764
|
stance: { leftHip: 9, rightHip: 9, leftShoulder: 16, rightShoulder: 16, leftElbow: -24, rightElbow: -24 },
|
|
@@ -1744,7 +1818,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1744
1818
|
reset: !0,
|
|
1745
1819
|
pose: { leftHip: 6, rightHip: 6, leftKnee: 0, rightKnee: 0, leftAnkle: 65, rightAnkle: 65, rightShoulder: 150, rightElbow: 75, leftShoulder: 30, leftElbow: 20, headTilt: -10, lookY: 0.4 },
|
|
1746
1820
|
hands: { right: "fist", left: "fist" },
|
|
1747
|
-
easing:
|
|
1821
|
+
easing: xe
|
|
1748
1822
|
},
|
|
1749
1823
|
{ beat: 2, pose: { headTilt: -14, lean: -2 } }
|
|
1750
1824
|
]
|
|
@@ -1757,72 +1831,72 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
|
|
|
1757
1831
|
{ move: "forwardGlide", beats: 8 },
|
|
1758
1832
|
{ move: "toeStand", beats: 4 }
|
|
1759
1833
|
]
|
|
1760
|
-
},
|
|
1761
|
-
disco:
|
|
1762
|
-
hipHop:
|
|
1763
|
-
breaking:
|
|
1764
|
-
jazz:
|
|
1765
|
-
kpop:
|
|
1766
|
-
bollywood:
|
|
1767
|
-
bhangra:
|
|
1768
|
-
bharatanatyam:
|
|
1769
|
-
charleston:
|
|
1770
|
-
tap:
|
|
1771
|
-
popping:
|
|
1772
|
-
},
|
|
1773
|
-
function
|
|
1774
|
-
const t = { ...
|
|
1775
|
-
for (const
|
|
1776
|
-
const o = n[n.length - 1],
|
|
1777
|
-
n.push({ at:
|
|
1834
|
+
}, Se = {
|
|
1835
|
+
disco: vs,
|
|
1836
|
+
hipHop: Ts,
|
|
1837
|
+
breaking: As,
|
|
1838
|
+
jazz: xs,
|
|
1839
|
+
kpop: Ks,
|
|
1840
|
+
bollywood: Ps,
|
|
1841
|
+
bhangra: Ws,
|
|
1842
|
+
bharatanatyam: Is,
|
|
1843
|
+
charleston: _s,
|
|
1844
|
+
tap: $s,
|
|
1845
|
+
popping: Bs
|
|
1846
|
+
}, Ve = (e) => Math.min(1, Math.max(0, e));
|
|
1847
|
+
function Fs(e) {
|
|
1848
|
+
const t = { ..._, turn: e.view }, n = [];
|
|
1849
|
+
for (const s of e.keys) {
|
|
1850
|
+
const o = n[n.length - 1], r = !o || s.reset ? t : o.pose;
|
|
1851
|
+
n.push({ at: s.at, pose: { ...r, ...s.pose }, easing: s.easing });
|
|
1778
1852
|
}
|
|
1779
1853
|
return n;
|
|
1780
1854
|
}
|
|
1781
|
-
function
|
|
1782
|
-
return e -
|
|
1855
|
+
function Rs(e) {
|
|
1856
|
+
return e - Ls * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
|
|
1783
1857
|
}
|
|
1784
|
-
const
|
|
1785
|
-
function
|
|
1858
|
+
const Ls = 0.5;
|
|
1859
|
+
function Ns(e, t) {
|
|
1786
1860
|
if (!(t <= e.takeoff || t >= e.landing))
|
|
1787
1861
|
return (t - e.takeoff) / (e.landing - e.takeoff);
|
|
1788
1862
|
}
|
|
1789
|
-
function
|
|
1790
|
-
const n = typeof e == "string" ?
|
|
1791
|
-
let
|
|
1792
|
-
for (let
|
|
1793
|
-
const
|
|
1863
|
+
function Ys(e, t) {
|
|
1864
|
+
const n = typeof e == "string" ? Pt[e] : e, s = Fs(n), o = Ve(t);
|
|
1865
|
+
let r = 0;
|
|
1866
|
+
for (let u = 0; u < s.length; u++) s[u].at <= o && (r = u);
|
|
1867
|
+
const l = s[r], i = s[Math.min(r + 1, s.length - 1)], a = i.at > l.at ? (o - l.at) / (i.at - l.at) : 0, h = Pe(l.pose, i.pose, Qe(i.easing ?? "ease-in-out")(Ve(a))), c = Ns(n, o);
|
|
1794
1868
|
return c === void 0 ? { ...h, spin: 0, rise: 0 } : {
|
|
1795
1869
|
...h,
|
|
1796
|
-
spin: n.spin *
|
|
1870
|
+
spin: n.spin * Rs(c),
|
|
1797
1871
|
rise: 4 * n.height * c * (1 - c)
|
|
1798
1872
|
};
|
|
1799
1873
|
}
|
|
1800
|
-
function
|
|
1801
|
-
const
|
|
1802
|
-
return
|
|
1874
|
+
function Cs(e, t, n) {
|
|
1875
|
+
const s = typeof e == "string" ? Pt[e] : e, o = Ve(t), r = Ve((o - s.takeoff) / (s.landing - s.takeoff));
|
|
1876
|
+
return s.travel * n * r;
|
|
1803
1877
|
}
|
|
1804
|
-
function
|
|
1805
|
-
const
|
|
1806
|
-
const
|
|
1807
|
-
return { time: o +
|
|
1808
|
-
}), h = Object.keys(
|
|
1878
|
+
function Hi(e, t, n = {}) {
|
|
1879
|
+
const s = typeof t == "string" ? Pt[t] : t, o = n.start ?? 0, r = n.duration ?? s.duration, l = n.samples ?? 48, i = Array.from({ length: l + 1 }, (c, u) => {
|
|
1880
|
+
const g = u / l;
|
|
1881
|
+
return { time: o + g * r, progress: g, pose: Ys(s, g) };
|
|
1882
|
+
}), h = Object.keys(_).filter((c) => i.some((u) => u.pose[c] !== _[c])).map((c) => ({
|
|
1809
1883
|
id: `${e}-${c}`,
|
|
1810
1884
|
target: e,
|
|
1811
1885
|
property: c,
|
|
1812
|
-
keyframes:
|
|
1886
|
+
keyframes: i.map((u) => ({ time: u.time, value: u.pose[c] }))
|
|
1813
1887
|
}));
|
|
1814
|
-
if (n.height !== void 0 &&
|
|
1888
|
+
if (n.height !== void 0 && s.travel !== 0) {
|
|
1815
1889
|
const c = (n.facing ?? 1) < 0 ? -1 : 1;
|
|
1816
1890
|
h.push({
|
|
1817
1891
|
id: `${e}-x`,
|
|
1818
1892
|
target: e,
|
|
1819
1893
|
property: "x",
|
|
1820
|
-
keyframes:
|
|
1894
|
+
keyframes: i.map((u) => ({ time: u.time, value: (n.x ?? 0) + c * Cs(s, u.progress, n.height) }))
|
|
1821
1895
|
});
|
|
1822
1896
|
}
|
|
1823
1897
|
return h;
|
|
1824
1898
|
}
|
|
1825
|
-
const
|
|
1899
|
+
const Ds = {
|
|
1826
1900
|
leftHip: -55,
|
|
1827
1901
|
leftKnee: -95,
|
|
1828
1902
|
rightHip: 55,
|
|
@@ -1834,7 +1908,7 @@ const er = {
|
|
|
1834
1908
|
lean: 22,
|
|
1835
1909
|
stretch: 0.94,
|
|
1836
1910
|
headTilt: 6
|
|
1837
|
-
},
|
|
1911
|
+
}, Xs = {
|
|
1838
1912
|
leftHip: 0,
|
|
1839
1913
|
leftKnee: 0,
|
|
1840
1914
|
rightHip: 0,
|
|
@@ -1848,7 +1922,7 @@ const er = {
|
|
|
1848
1922
|
lean: 0,
|
|
1849
1923
|
stretch: 1.08,
|
|
1850
1924
|
headTilt: 0
|
|
1851
|
-
},
|
|
1925
|
+
}, _e = {
|
|
1852
1926
|
leftHip: -128,
|
|
1853
1927
|
leftKnee: -152,
|
|
1854
1928
|
rightHip: 128,
|
|
@@ -1862,7 +1936,7 @@ const er = {
|
|
|
1862
1936
|
lean: 26,
|
|
1863
1937
|
stretch: 1,
|
|
1864
1938
|
headTilt: 14
|
|
1865
|
-
},
|
|
1939
|
+
}, qs = {
|
|
1866
1940
|
leftHip: -22,
|
|
1867
1941
|
leftKnee: -30,
|
|
1868
1942
|
rightHip: 22,
|
|
@@ -1875,7 +1949,7 @@ const er = {
|
|
|
1875
1949
|
rightElbow: 0,
|
|
1876
1950
|
lean: 8,
|
|
1877
1951
|
headTilt: 0
|
|
1878
|
-
},
|
|
1952
|
+
}, Gs = {
|
|
1879
1953
|
leftHip: -58,
|
|
1880
1954
|
leftKnee: -100,
|
|
1881
1955
|
rightHip: 58,
|
|
@@ -1889,42 +1963,42 @@ const er = {
|
|
|
1889
1963
|
lean: 20,
|
|
1890
1964
|
stretch: 0.93
|
|
1891
1965
|
};
|
|
1892
|
-
function
|
|
1966
|
+
function pe(e, t, n, s, o, r = 1300) {
|
|
1893
1967
|
return {
|
|
1894
1968
|
label: e,
|
|
1895
1969
|
view: 1,
|
|
1896
1970
|
spin: t,
|
|
1897
1971
|
height: n,
|
|
1898
|
-
travel:
|
|
1972
|
+
travel: s,
|
|
1899
1973
|
takeoff: 0.27,
|
|
1900
1974
|
landing: 0.8,
|
|
1901
|
-
duration:
|
|
1975
|
+
duration: r,
|
|
1902
1976
|
keys: [
|
|
1903
1977
|
{ at: 0, reset: !0 },
|
|
1904
|
-
{ at: 0.16, pose:
|
|
1905
|
-
{ at: 0.27, pose:
|
|
1978
|
+
{ at: 0.16, pose: Ds },
|
|
1979
|
+
{ at: 0.27, pose: Xs, easing: "ease-out-quad" },
|
|
1906
1980
|
...o,
|
|
1907
|
-
{ at: 0.76, pose:
|
|
1908
|
-
{ at: 0.86, pose:
|
|
1981
|
+
{ at: 0.76, pose: qs },
|
|
1982
|
+
{ at: 0.86, pose: Gs, easing: "ease-out-quad" },
|
|
1909
1983
|
{ at: 1, reset: !0 }
|
|
1910
1984
|
]
|
|
1911
1985
|
};
|
|
1912
1986
|
}
|
|
1913
|
-
const
|
|
1914
|
-
frontFlip:
|
|
1915
|
-
{ at: 0.38, pose:
|
|
1916
|
-
{ at: 0.64, pose:
|
|
1987
|
+
const Pt = {
|
|
1988
|
+
frontFlip: pe("Front flip (tuck)", 360, 0.56, 0.35, [
|
|
1989
|
+
{ at: 0.38, pose: _e, easing: "ease-out-cubic" },
|
|
1990
|
+
{ at: 0.64, pose: _e }
|
|
1917
1991
|
]),
|
|
1918
|
-
backFlip:
|
|
1919
|
-
{ at: 0.36, pose: { ...
|
|
1920
|
-
{ at: 0.64, pose: { ...
|
|
1992
|
+
backFlip: pe("Back flip (tuck)", -360, 0.58, -0.15, [
|
|
1993
|
+
{ at: 0.36, pose: { ..._e, lean: 18 }, easing: "ease-out-cubic" },
|
|
1994
|
+
{ at: 0.64, pose: { ..._e, lean: 18 } }
|
|
1921
1995
|
]),
|
|
1922
|
-
layout:
|
|
1996
|
+
layout: pe("Back layout (straight body)", -360, 0.66, -0.2, [
|
|
1923
1997
|
// Arched, arms overhead, legs together and long.
|
|
1924
1998
|
{ at: 0.4, pose: { leftHip: 8, rightHip: -8, leftKnee: 0, rightKnee: 0, leftAnkle: 60, rightAnkle: 60, leftShoulder: -178, rightShoulder: 178, lean: -18, headTilt: -14 } },
|
|
1925
1999
|
{ at: 0.64, pose: { leftHip: -4, rightHip: 4, lean: -6, headTilt: -4, leftShoulder: -150, rightShoulder: 150 } }
|
|
1926
2000
|
], 1400),
|
|
1927
|
-
scissorFlip:
|
|
2001
|
+
scissorFlip: pe("Scissor flip", 360, 0.6, 0.45, [
|
|
1928
2002
|
// The legs scissor through the turn: left kicks high, then they switch.
|
|
1929
2003
|
{ at: 0.36, pose: { leftHip: -105, leftKnee: 0, rightHip: -40, rightKnee: -20, leftAnkle: 50, rightAnkle: 50, leftShoulder: -150, rightShoulder: 150, leftElbow: 0, rightElbow: 0, lean: 12 }, easing: "ease-out-cubic" },
|
|
1930
2004
|
{ at: 0.52, pose: { leftHip: 40, leftKnee: 20, rightHip: 105, rightKnee: 0, leftShoulder: -140, rightShoulder: 140 } },
|
|
@@ -1970,7 +2044,7 @@ const ut = {
|
|
|
1970
2044
|
]
|
|
1971
2045
|
},
|
|
1972
2046
|
// Leaps: no turn, the shape is the trick.
|
|
1973
|
-
splitLeap:
|
|
2047
|
+
splitLeap: pe("Split leap (grand jeté)", 0, 0.36, 0.9, [
|
|
1974
2048
|
// A front split in the air: front leg reaching, back leg long, arms open.
|
|
1975
2049
|
{ at: 0.4, pose: { leftHip: -96, rightHip: -84, leftKnee: 0, rightKnee: 0, leftAnkle: 55, rightAnkle: 55, leftShoulder: -130, rightShoulder: -105, leftElbow: 0, rightElbow: 0, lean: 4, headTilt: -6 }, easing: "ease-out-cubic" },
|
|
1976
2050
|
{ at: 0.64, pose: { lean: 2 } }
|
|
@@ -1996,12 +2070,12 @@ const ut = {
|
|
|
1996
2070
|
{ at: 1, reset: !0 }
|
|
1997
2071
|
]
|
|
1998
2072
|
},
|
|
1999
|
-
backHandspring:
|
|
2073
|
+
backHandspring: pe("Back handspring", -360, 0.16, -0.7, [
|
|
2000
2074
|
// Arms reach back overhead to the ground, legs snap over.
|
|
2001
2075
|
{ at: 0.38, pose: { leftHip: 10, rightHip: -10, leftKnee: 0, rightKnee: 0, leftShoulder: -178, rightShoulder: 178, lean: -26, headTilt: -20 } },
|
|
2002
2076
|
{ at: 0.6, pose: { leftHip: -40, rightHip: 40, leftKnee: -20, rightKnee: 20, lean: 6, headTilt: 0 } }
|
|
2003
2077
|
], 1200)
|
|
2004
|
-
},
|
|
2078
|
+
}, st = 0.215, rt = 0.205, Us = 0.065, tn = 0.035, zs = 0.165, Vs = 0.155, js = 12, Js = (e) => e * Math.PI / 180, X = {
|
|
2005
2079
|
turn: 0,
|
|
2006
2080
|
lean: 0,
|
|
2007
2081
|
side: 0,
|
|
@@ -2043,33 +2117,33 @@ const ut = {
|
|
|
2043
2117
|
lookX: 0,
|
|
2044
2118
|
lookY: 0
|
|
2045
2119
|
};
|
|
2046
|
-
function
|
|
2047
|
-
return { ...
|
|
2120
|
+
function ee(e = {}) {
|
|
2121
|
+
return { ...X, ...e };
|
|
2048
2122
|
}
|
|
2049
|
-
const
|
|
2050
|
-
function
|
|
2123
|
+
const Zs = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
|
|
2124
|
+
function vi(e) {
|
|
2051
2125
|
const t = {};
|
|
2052
|
-
for (const [n,
|
|
2053
|
-
const o = n.replace(/(^|\.)(left|right)(\.|$)/, (
|
|
2054
|
-
t[o] =
|
|
2126
|
+
for (const [n, s] of Object.entries(e)) {
|
|
2127
|
+
const o = n.replace(/(^|\.)(left|right)(\.|$)/, (r, l, i, a) => `${l}${i === "left" ? "right" : "left"}${a}`);
|
|
2128
|
+
t[o] = Zs.has(n) ? -s : s;
|
|
2055
2129
|
}
|
|
2056
2130
|
return t;
|
|
2057
2131
|
}
|
|
2058
|
-
function
|
|
2132
|
+
function Z(e, t) {
|
|
2059
2133
|
const n = {};
|
|
2060
|
-
for (const
|
|
2134
|
+
for (const s of ["left", "right"]) for (const [o, r] of Object.entries(t)) n[`${e}.${s}.${o}`] = r;
|
|
2061
2135
|
return n;
|
|
2062
2136
|
}
|
|
2063
|
-
const
|
|
2064
|
-
rest:
|
|
2065
|
-
wave:
|
|
2066
|
-
cheer:
|
|
2067
|
-
point:
|
|
2068
|
-
handsOnHips:
|
|
2069
|
-
think:
|
|
2070
|
-
shrug:
|
|
2071
|
-
sit:
|
|
2072
|
-
kneel:
|
|
2137
|
+
const Qs = {
|
|
2138
|
+
rest: X,
|
|
2139
|
+
wave: ee({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
|
|
2140
|
+
cheer: ee({ ...Z("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
|
|
2141
|
+
point: ee({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
|
|
2142
|
+
handsOnHips: ee({ ...Z("arm", { spread: 50, bend: -105, elbow: 0 }), ...Z("leg", { spread: 9 }), smile: 0.8 }),
|
|
2143
|
+
think: ee({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
|
|
2144
|
+
shrug: ee({ ...Z("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
|
|
2145
|
+
sit: ee({ ...Z("leg", { swing: 90, knee: 90, spread: 4 }), ...Z("arm", { swing: 25, elbow: 45, spread: 8 }) }),
|
|
2146
|
+
kneel: ee({
|
|
2073
2147
|
"leg.left.swing": 90,
|
|
2074
2148
|
"leg.left.knee": 90,
|
|
2075
2149
|
// The back thigh leans back a little so its knee meets the ground beside the
|
|
@@ -2077,44 +2151,44 @@ const cr = {
|
|
|
2077
2151
|
"leg.right.swing": -18,
|
|
2078
2152
|
"leg.right.knee": 108,
|
|
2079
2153
|
"leg.right.ankle": 16,
|
|
2080
|
-
...
|
|
2154
|
+
...Z("arm", { swing: 20, elbow: 30 })
|
|
2081
2155
|
}),
|
|
2082
|
-
crouch:
|
|
2156
|
+
crouch: ee({ ...Z("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...Z("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
|
|
2083
2157
|
// On hands and knees: the back nearly level, arms straight down, the toes
|
|
2084
2158
|
// pointed back along the ground.
|
|
2085
|
-
crawl:
|
|
2086
|
-
lieDown:
|
|
2159
|
+
crawl: ee({ lean: 82, "head.nod": -35, ...Z("arm", { swing: 80, elbow: 0, spread: 4 }), ...Z("leg", { knee: 92, ankle: -88 }) }),
|
|
2160
|
+
lieDown: ee({ roll: 90, ...Z("arm", { spread: 8 }), "head.nod": 0 })
|
|
2087
2161
|
};
|
|
2088
|
-
function
|
|
2089
|
-
const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06,
|
|
2162
|
+
function er(e = {}) {
|
|
2163
|
+
const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06, s = e.hipWidth ?? 0.022, o = Math.max(0.12, 1 - t - tn - (st + rt)), r = (a) => ({
|
|
2090
2164
|
id: `arm.${a}`,
|
|
2091
2165
|
parent: "spine",
|
|
2092
2166
|
offset: [(a === "left" ? 1 : -1) * n, -0.035, 0],
|
|
2093
2167
|
rest: [0, -1, 0],
|
|
2094
2168
|
side: a === "left" ? 1 : -1,
|
|
2095
2169
|
bones: [
|
|
2096
|
-
{ length:
|
|
2097
|
-
{ length:
|
|
2170
|
+
{ length: zs, width: [1.25, 0.9] },
|
|
2171
|
+
{ length: Vs, width: [0.9, 0.75] }
|
|
2098
2172
|
]
|
|
2099
|
-
}),
|
|
2173
|
+
}), l = (a) => ({
|
|
2100
2174
|
id: `leg.${a}`,
|
|
2101
2175
|
parent: null,
|
|
2102
|
-
offset: [(a === "left" ? 1 : -1) *
|
|
2176
|
+
offset: [(a === "left" ? 1 : -1) * s, 0, 0],
|
|
2103
2177
|
rest: [0, -1, 0],
|
|
2104
2178
|
side: a === "left" ? 1 : -1,
|
|
2105
2179
|
bones: [
|
|
2106
|
-
{ length:
|
|
2107
|
-
{ length:
|
|
2108
|
-
{ length:
|
|
2180
|
+
{ length: st, width: [1.45, 1.05] },
|
|
2181
|
+
{ length: rt, width: [1.05, 0.85] },
|
|
2182
|
+
{ length: Us, width: [0.95, 0.7] }
|
|
2109
2183
|
]
|
|
2110
|
-
}),
|
|
2184
|
+
}), i = (a, h) => a[h] ?? X[h] ?? 0;
|
|
2111
2185
|
return {
|
|
2112
2186
|
id: "human",
|
|
2113
|
-
hipHeight:
|
|
2187
|
+
hipHeight: st + rt,
|
|
2114
2188
|
// Tie order: legs, then the body, then the arms (in front of the chest unless turned away), then the head.
|
|
2115
2189
|
chains: [
|
|
2116
|
-
|
|
2117
|
-
|
|
2190
|
+
l("left"),
|
|
2191
|
+
l("right"),
|
|
2118
2192
|
{
|
|
2119
2193
|
id: "spine",
|
|
2120
2194
|
parent: null,
|
|
@@ -2124,9 +2198,9 @@ function fr(e = {}) {
|
|
|
2124
2198
|
{ length: o / 2, width: [1.4, 1.1] }
|
|
2125
2199
|
]
|
|
2126
2200
|
},
|
|
2127
|
-
{ id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length:
|
|
2128
|
-
|
|
2129
|
-
|
|
2201
|
+
{ id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: tn, width: [1, 0.9] }] },
|
|
2202
|
+
r("left"),
|
|
2203
|
+
r("right")
|
|
2130
2204
|
],
|
|
2131
2205
|
head: { on: "neck", size: t },
|
|
2132
2206
|
contacts: [
|
|
@@ -2144,47 +2218,47 @@ function fr(e = {}) {
|
|
|
2144
2218
|
],
|
|
2145
2219
|
angles(a, h) {
|
|
2146
2220
|
if (h.id === "spine") {
|
|
2147
|
-
const
|
|
2221
|
+
const d = -i(a, "lean") / 2, m = i(a, "side") / 2;
|
|
2148
2222
|
return [
|
|
2149
|
-
{ swing:
|
|
2150
|
-
{ swing:
|
|
2223
|
+
{ swing: d, spread: m },
|
|
2224
|
+
{ swing: d, spread: m }
|
|
2151
2225
|
];
|
|
2152
2226
|
}
|
|
2153
2227
|
if (h.id === "neck") return [{ swing: 0, spread: 0 }];
|
|
2154
|
-
const [c,
|
|
2228
|
+
const [c, u] = h.id.split("."), g = (d) => i(a, `${c}.${u}.${d}`);
|
|
2155
2229
|
if (c === "arm")
|
|
2156
2230
|
return [
|
|
2157
|
-
{ swing:
|
|
2158
|
-
{ swing:
|
|
2231
|
+
{ swing: g("swing"), spread: g("spread") },
|
|
2232
|
+
{ swing: g("elbow"), spread: g("bend") }
|
|
2159
2233
|
];
|
|
2160
|
-
const
|
|
2234
|
+
const f = (h.side ?? 1) * g("rotate"), p = 1 - Math.cos(Js(g("rotate")));
|
|
2161
2235
|
return [
|
|
2162
|
-
{ swing:
|
|
2163
|
-
{ swing: -
|
|
2236
|
+
{ swing: g("swing"), spread: g("spread"), yaw: f },
|
|
2237
|
+
{ swing: -g("knee"), spread: 0, yaw: f },
|
|
2164
2238
|
// The foot points forward, square to the shin, turned out a little (more with `toeOut`).
|
|
2165
|
-
{ swing: 90 +
|
|
2239
|
+
{ swing: 90 + g("ankle") - p * (g("swing") - g("knee")), spread: 0, yaw: (js + g("toeOut")) * (h.side ?? 1) }
|
|
2166
2240
|
];
|
|
2167
2241
|
},
|
|
2168
2242
|
withAngles(a, h, c) {
|
|
2169
|
-
const [
|
|
2170
|
-
return
|
|
2243
|
+
const [u, g] = h.id.split("."), f = (p) => `${u}.${g}.${p}`;
|
|
2244
|
+
return u === "arm" ? {
|
|
2171
2245
|
...a,
|
|
2172
|
-
[
|
|
2173
|
-
[
|
|
2174
|
-
[
|
|
2175
|
-
[
|
|
2176
|
-
} :
|
|
2246
|
+
[f("swing")]: c[0].swing,
|
|
2247
|
+
[f("spread")]: c[0].spread,
|
|
2248
|
+
[f("elbow")]: c[1].swing,
|
|
2249
|
+
[f("bend")]: c[1].spread
|
|
2250
|
+
} : u === "leg" ? { ...a, [f("swing")]: c[0].swing, [f("spread")]: c[0].spread, [f("knee")]: -c[1].swing } : a;
|
|
2177
2251
|
},
|
|
2178
2252
|
boneScale(a, h) {
|
|
2179
|
-
const c = Math.min(3, Math.max(0.3,
|
|
2253
|
+
const c = Math.min(3, Math.max(0.3, i(a, "stretch")));
|
|
2180
2254
|
return h?.id.startsWith("arm.") ? Math.sqrt(c) : c;
|
|
2181
2255
|
},
|
|
2182
2256
|
headPose(a) {
|
|
2183
|
-
const h = Math.min(3, Math.max(0.3,
|
|
2257
|
+
const h = Math.min(3, Math.max(0.3, i(a, "stretch")));
|
|
2184
2258
|
return {
|
|
2185
|
-
yaw:
|
|
2186
|
-
nod:
|
|
2187
|
-
tilt:
|
|
2259
|
+
yaw: i(a, "head.turn"),
|
|
2260
|
+
nod: i(a, "head.nod"),
|
|
2261
|
+
tilt: i(a, "head.tilt"),
|
|
2188
2262
|
// The head keeps its area: taller and narrower when stretched.
|
|
2189
2263
|
sx: 1 / Math.sqrt(h),
|
|
2190
2264
|
sy: Math.sqrt(h)
|
|
@@ -2209,15 +2283,15 @@ function fr(e = {}) {
|
|
|
2209
2283
|
}
|
|
2210
2284
|
};
|
|
2211
2285
|
}
|
|
2212
|
-
function
|
|
2286
|
+
function Ti(e) {
|
|
2213
2287
|
const t = e.split(".");
|
|
2214
2288
|
if (t[0] === "hand" && t.length >= 3) {
|
|
2215
|
-
const
|
|
2216
|
-
return `${
|
|
2289
|
+
const s = `${t[1] === "left" ? "Left" : "Right"} hand`, o = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, r = t.slice(2).join(".");
|
|
2290
|
+
return `${s} · ${o[r] ?? r.replace(".curl", " curl").replace(".across", " across")}`;
|
|
2217
2291
|
}
|
|
2218
2292
|
if (t.length === 3) {
|
|
2219
|
-
const [
|
|
2220
|
-
return `${`${o === "left" ? "Left" : "Right"} ${
|
|
2293
|
+
const [s, o, r] = t;
|
|
2294
|
+
return `${`${o === "left" ? "Left" : "Right"} ${s}`} · ${{
|
|
2221
2295
|
swing: "forward / back",
|
|
2222
2296
|
spread: "out / in",
|
|
2223
2297
|
elbow: "elbow bend",
|
|
@@ -2226,7 +2300,7 @@ function ls(e) {
|
|
|
2226
2300
|
ankle: "foot tilt",
|
|
2227
2301
|
toeOut: "toes out / in",
|
|
2228
2302
|
rotate: "turn out at the hip"
|
|
2229
|
-
}[
|
|
2303
|
+
}[r] ?? r}`;
|
|
2230
2304
|
}
|
|
2231
2305
|
return {
|
|
2232
2306
|
turn: "View (front → side → back)",
|
|
@@ -2251,284 +2325,285 @@ function ls(e) {
|
|
|
2251
2325
|
lookY: "Look up / down"
|
|
2252
2326
|
}[e] ?? e;
|
|
2253
2327
|
}
|
|
2254
|
-
const
|
|
2328
|
+
const tr = {
|
|
2255
2329
|
leftEye: "eye.left",
|
|
2256
2330
|
rightEye: "eye.right",
|
|
2257
2331
|
leftBrow: "brow.left",
|
|
2258
2332
|
rightBrow: "brow.right"
|
|
2259
|
-
},
|
|
2260
|
-
Object.entries(
|
|
2333
|
+
}, Ai = Object.fromEntries(
|
|
2334
|
+
Object.entries(Y).map(([e, t]) => [
|
|
2261
2335
|
e,
|
|
2262
|
-
Object.fromEntries(Object.entries(t).map(([n,
|
|
2336
|
+
Object.fromEntries(Object.entries(t).map(([n, s]) => [tr[n] ?? n, s]))
|
|
2263
2337
|
])
|
|
2264
2338
|
);
|
|
2265
|
-
function
|
|
2266
|
-
const n = Math.min(1, Math.max(0, e.turn ?? 0)),
|
|
2339
|
+
function xi(e, t) {
|
|
2340
|
+
const n = Math.min(1, Math.max(0, e.turn ?? 0)), s = 1 - n, o = { ...X, turn: n }, r = [
|
|
2267
2341
|
{ stick: "right", human: "left", s: 1 },
|
|
2268
2342
|
{ stick: "left", human: "right", s: -1 }
|
|
2269
2343
|
];
|
|
2270
|
-
for (const { stick: i, human:
|
|
2271
|
-
const
|
|
2272
|
-
o[`arm.${
|
|
2273
|
-
const
|
|
2274
|
-
o[`leg.${
|
|
2344
|
+
for (const { stick: i, human: a, s: h } of r) {
|
|
2345
|
+
const c = e[`${i}Shoulder`], u = e[`${i}Elbow`];
|
|
2346
|
+
o[`arm.${a}.spread`] = c * s, o[`arm.${a}.swing`] = h * c * n, o[`arm.${a}.bend`] = u * s, o[`arm.${a}.elbow`] = h * u * n;
|
|
2347
|
+
const g = e[`${i}Hip`], f = e[`${i}Knee`], p = s + h * n;
|
|
2348
|
+
o[`leg.${a}.rotate`] = 90 * s, o[`leg.${a}.spread`] = 0, o[`leg.${a}.swing`] = g * p, o[`leg.${a}.knee`] = f * p, o[`leg.${a}.ankle`] = -(e[`${i}Ankle`] ?? 0), o[`leg.${a}.toeOut`] = (e[`${i}FootOut`] ?? 0) * nr, o[`eye.${a}`] = e[`${i}Eye`], o[`brow.${a}`] = e[`${i}Brow`], t && Object.assign(o, or(a, t[i] ?? L, e[`${i}Wrist`] ?? 0, n));
|
|
2275
2349
|
}
|
|
2276
|
-
|
|
2350
|
+
const l = e.bend ?? 0;
|
|
2351
|
+
o.lean = (e.lean + l * 0.5) * n, o.side = (e.lean + l * 0.5) * s, o["head.tilt"] = (e.headTilt + l * 0.5) * s, o["head.nod"] = (e.headTilt + l * 0.5) * n;
|
|
2277
2352
|
for (const i of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) o[i] = e[i];
|
|
2278
2353
|
return o.lift = e.rise ?? 0, o.roll = e.spin ?? 0, o;
|
|
2279
2354
|
}
|
|
2280
|
-
const
|
|
2281
|
-
function
|
|
2282
|
-
const o = e === "right" ? 1 -
|
|
2283
|
-
for (const
|
|
2284
|
-
return
|
|
2355
|
+
const nr = 70;
|
|
2356
|
+
function or(e, t, n, s) {
|
|
2357
|
+
const o = e === "right" ? 1 - s : 1 + s, r = {};
|
|
2358
|
+
for (const l of Object.keys(L)) r[`hand.${e}.${l}`] = t[l] ?? L[l];
|
|
2359
|
+
return r[`hand.${e}.turn`] = (t.turn ?? 0) - o, r[`hand.${e}.roll`] = (t.roll ?? 0) + n, r;
|
|
2285
2360
|
}
|
|
2286
|
-
const
|
|
2287
|
-
function
|
|
2288
|
-
const o = Math.cos(
|
|
2289
|
-
return [e, t * o + n *
|
|
2361
|
+
const te = (e) => e * Math.PI / 180;
|
|
2362
|
+
function Rn([e, t, n], s) {
|
|
2363
|
+
const o = Math.cos(s), r = Math.sin(s);
|
|
2364
|
+
return [e, t * o + n * r, -t * r + n * o];
|
|
2290
2365
|
}
|
|
2291
|
-
function
|
|
2292
|
-
const o = Math.cos(
|
|
2293
|
-
return [e * o - t *
|
|
2366
|
+
function Wt([e, t, n], s) {
|
|
2367
|
+
const o = Math.cos(s), r = Math.sin(s);
|
|
2368
|
+
return [e * o - t * r, e * r + t * o, n];
|
|
2294
2369
|
}
|
|
2295
|
-
function
|
|
2296
|
-
const o = Math.cos(
|
|
2297
|
-
return [e * o + n *
|
|
2370
|
+
function ge([e, t, n], s) {
|
|
2371
|
+
const o = Math.cos(s), r = Math.sin(s);
|
|
2372
|
+
return [e * o + n * r, t, -e * r + n * o];
|
|
2298
2373
|
}
|
|
2299
|
-
const
|
|
2300
|
-
function
|
|
2301
|
-
const n =
|
|
2374
|
+
const he = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], je = (e, t) => [e[0] * t, e[1] * t, e[2] * t], De = (e, t) => Wt(Rn(e, t.swing), t.spread);
|
|
2375
|
+
function it(e, t) {
|
|
2376
|
+
const n = ge(e, t);
|
|
2302
2377
|
return { point: { x: n[0], y: -n[1] }, depth: n[2] };
|
|
2303
2378
|
}
|
|
2304
|
-
function
|
|
2305
|
-
const
|
|
2306
|
-
for (const
|
|
2307
|
-
const
|
|
2308
|
-
if (
|
|
2309
|
-
const
|
|
2310
|
-
let
|
|
2311
|
-
|
|
2312
|
-
const
|
|
2313
|
-
|
|
2314
|
-
const
|
|
2315
|
-
|
|
2316
|
-
}),
|
|
2317
|
-
}
|
|
2318
|
-
const
|
|
2319
|
-
return { height:
|
|
2320
|
-
}
|
|
2321
|
-
function
|
|
2322
|
-
const
|
|
2323
|
-
for (const
|
|
2324
|
-
const { joints3:
|
|
2325
|
-
|
|
2326
|
-
id:
|
|
2327
|
-
joints3:
|
|
2328
|
-
frames:
|
|
2329
|
-
points:
|
|
2330
|
-
depths:
|
|
2379
|
+
function Ot(e, t, n) {
|
|
2380
|
+
const s = n, r = [0, e.hipHeight * s * (e.boneScale?.(t, null) ?? 1), 0], l = {};
|
|
2381
|
+
for (const d of e.chains) {
|
|
2382
|
+
const m = d.parent ? l[d.parent] : void 0;
|
|
2383
|
+
if (d.parent && !m) throw new Error(`body plan ${e.id}: chain ${d.id} comes before its parent ${d.parent}`);
|
|
2384
|
+
const b = d.at ?? (m ? m.joints3.length - 1 : 0), y = m ? m.joints3[b] : r, E = m ? m.frames[Math.max(0, b - 1)] : { swing: 0, spread: 0 }, H = d.offset ? he(y, De(je(d.offset, s), E)) : y, M = d.side ?? 1, A = e.boneScale?.(t, d) ?? 1, w = e.angles(t, d), S = [H], k = [];
|
|
2385
|
+
let x = E.swing, v = E.spread;
|
|
2386
|
+
d.bones.forEach((T, K) => {
|
|
2387
|
+
const P = w[K] ?? { swing: 0, spread: 0 };
|
|
2388
|
+
x += te(P.swing), v += te(P.spread) * M, k.push({ swing: x, spread: v });
|
|
2389
|
+
const I = ge(De(d.rest, { swing: x, spread: v }), te(P.yaw ?? 0));
|
|
2390
|
+
S.push(he(S[K], je(I, T.length * s * A)));
|
|
2391
|
+
}), l[d.id] = { joints3: S, frames: k };
|
|
2392
|
+
}
|
|
2393
|
+
const i = l[e.head.on], a = e.headPose?.(t) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, h = i.frames[i.frames.length - 1], c = e.head.size / 2 * s, u = c * a.sx, g = c * a.sy, f = (d) => De(ge(Rn(Wt(d, -te(a.tilt)), -te(a.nod)), te(a.yaw)), h), p = he(i.joints3[i.joints3.length - 1], f([0, g, 0]));
|
|
2394
|
+
return { height: s, root: r, chains: l, head: { center: p, rx: u, ry: g, toBody: f } };
|
|
2395
|
+
}
|
|
2396
|
+
function It(e, t, n) {
|
|
2397
|
+
const s = n.height, o = te(90 * (t.turn ?? 0)), r = Ot(e, t, s), { root: l } = r, i = r.chains, { rx: a, ry: h } = r.head, c = r.head.toBody, u = r.head.center, g = {};
|
|
2398
|
+
for (const k of e.chains) {
|
|
2399
|
+
const { joints3: x, frames: v } = i[k.id], T = x.map((K) => it(K, o));
|
|
2400
|
+
g[k.id] = {
|
|
2401
|
+
id: k.id,
|
|
2402
|
+
joints3: x,
|
|
2403
|
+
frames: v,
|
|
2404
|
+
points: T.map((K) => K.point),
|
|
2405
|
+
depths: T.map((K) => K.depth)
|
|
2331
2406
|
};
|
|
2332
2407
|
}
|
|
2333
|
-
const
|
|
2334
|
-
const
|
|
2335
|
-
return { x:
|
|
2336
|
-
},
|
|
2337
|
-
for (const
|
|
2338
|
-
const
|
|
2339
|
-
center:
|
|
2340
|
-
depth:
|
|
2408
|
+
const f = it(u, o), p = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((k) => ge(c(k), o)), d = it(l, o).point, m = te(t.roll ?? 0), b = (k) => {
|
|
2409
|
+
const x = k.x - d.x, v = k.y - d.y;
|
|
2410
|
+
return { x: d.x + x * Math.cos(m) - v * Math.sin(m), y: d.y + x * Math.sin(m) + v * Math.cos(m) };
|
|
2411
|
+
}, y = ([k, x, v]) => [k * Math.cos(m) + x * Math.sin(m), -k * Math.sin(m) + x * Math.cos(m), v];
|
|
2412
|
+
for (const k of Object.values(g)) k.points = k.points.map(b);
|
|
2413
|
+
const E = {
|
|
2414
|
+
center: b(f.point),
|
|
2415
|
+
depth: f.depth,
|
|
2341
2416
|
rx: a,
|
|
2342
2417
|
ry: h,
|
|
2343
2418
|
angle: 0,
|
|
2344
|
-
axes:
|
|
2345
|
-
}, H =
|
|
2346
|
-
|
|
2347
|
-
const
|
|
2348
|
-
if ("head" in
|
|
2349
|
-
const
|
|
2350
|
-
return
|
|
2419
|
+
axes: p.map(y)
|
|
2420
|
+
}, H = E.axes[1];
|
|
2421
|
+
E.angle = Math.atan2(H[0], H[1]);
|
|
2422
|
+
const M = (k) => {
|
|
2423
|
+
if ("head" in k) return { x: E.center.x + H[0] * h, y: E.center.y - H[1] * h };
|
|
2424
|
+
const x = g[k.chain];
|
|
2425
|
+
return x.points[Math.min(k.joint, x.points.length - 1)];
|
|
2351
2426
|
};
|
|
2352
|
-
let
|
|
2353
|
-
(n.contact ?? "ground") === "ground" && (
|
|
2354
|
-
const
|
|
2355
|
-
for (const
|
|
2356
|
-
|
|
2357
|
-
const
|
|
2427
|
+
let A = 0;
|
|
2428
|
+
(n.contact ?? "ground") === "ground" && (A = -Math.max(...e.contacts.map((k) => M(k).y))), A -= (t.lift ?? 0) * s;
|
|
2429
|
+
const w = (k) => ({ x: k.x, y: k.y + A });
|
|
2430
|
+
for (const k of Object.values(g)) k.points = k.points.map(w);
|
|
2431
|
+
E.center = w(E.center);
|
|
2432
|
+
const S = e.contacts.map((k) => ({ spec: k, point: M(k) }));
|
|
2358
2433
|
return {
|
|
2359
|
-
height:
|
|
2434
|
+
height: s,
|
|
2360
2435
|
view: o,
|
|
2361
|
-
chains:
|
|
2362
|
-
head:
|
|
2363
|
-
hip:
|
|
2364
|
-
contacts:
|
|
2365
|
-
groundY: Math.max(...
|
|
2436
|
+
chains: g,
|
|
2437
|
+
head: E,
|
|
2438
|
+
hip: w(b(d)),
|
|
2439
|
+
contacts: S,
|
|
2440
|
+
groundY: Math.max(...S.map((k) => k.point.y))
|
|
2366
2441
|
};
|
|
2367
2442
|
}
|
|
2368
|
-
const
|
|
2443
|
+
const kt = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], Ln = (e) => {
|
|
2369
2444
|
const t = Math.hypot(e[0], e[1], e[2]) || 1;
|
|
2370
2445
|
return [e[0] / t, e[1] / t, e[2] / t];
|
|
2371
2446
|
};
|
|
2372
|
-
function
|
|
2373
|
-
const
|
|
2374
|
-
for (const
|
|
2375
|
-
const c = a(
|
|
2376
|
-
if ("head" in
|
|
2377
|
-
const
|
|
2378
|
-
return
|
|
2447
|
+
function Nn(e, t, n) {
|
|
2448
|
+
const s = n.height, o = te(90 * (t.turn ?? 0)), r = te(t.roll ?? 0), l = Ot(e, t, s), i = ge(l.root, o), a = (m) => he(Wt(kt(ge(m, o), i), -r), i), h = {};
|
|
2449
|
+
for (const m of e.chains) h[m.id] = l.chains[m.id].joints3.map(a);
|
|
2450
|
+
const c = a(l.head.center), u = (m) => Ln(kt(a(he(l.head.center, l.head.toBody(m))), c)), g = [u([1, 0, 0]), u([0, 1, 0]), u([0, 0, 1])], f = (m) => {
|
|
2451
|
+
if ("head" in m) return he(c, je(g[1], l.head.ry));
|
|
2452
|
+
const b = h[m.chain];
|
|
2453
|
+
return b[Math.min(m.joint, b.length - 1)];
|
|
2379
2454
|
};
|
|
2380
|
-
let
|
|
2381
|
-
(n.contact ?? "ground") === "ground" && (
|
|
2382
|
-
const
|
|
2455
|
+
let p = 0;
|
|
2456
|
+
(n.contact ?? "ground") === "ground" && (p = -Math.min(...e.contacts.map((m) => f(m)[1]))), p += (t.lift ?? 0) * s;
|
|
2457
|
+
const d = (m) => [m[0], m[1] + p, m[2]];
|
|
2383
2458
|
return {
|
|
2384
|
-
height:
|
|
2385
|
-
hip:
|
|
2386
|
-
chains: Object.fromEntries(Object.entries(h).map(([
|
|
2387
|
-
head: { center:
|
|
2459
|
+
height: s,
|
|
2460
|
+
hip: d(i),
|
|
2461
|
+
chains: Object.fromEntries(Object.entries(h).map(([m, b]) => [m, b.map(d)])),
|
|
2462
|
+
head: { center: d(c), rx: l.head.rx, ry: l.head.ry, axes: g }
|
|
2388
2463
|
};
|
|
2389
2464
|
}
|
|
2390
|
-
function
|
|
2391
|
-
const o = n.height,
|
|
2392
|
-
if ("head" in
|
|
2393
|
-
const
|
|
2394
|
-
return
|
|
2395
|
-
},
|
|
2396
|
-
const
|
|
2397
|
-
return { point:
|
|
2398
|
-
},
|
|
2399
|
-
for (const
|
|
2400
|
-
const
|
|
2401
|
-
|
|
2402
|
-
id:
|
|
2403
|
-
joints3:
|
|
2404
|
-
frames:
|
|
2405
|
-
points:
|
|
2406
|
-
depths:
|
|
2465
|
+
function Yn(e, t, n, s) {
|
|
2466
|
+
const o = n.height, r = te(90 * (t.turn ?? 0)), l = Ot(e, t, o), i = Nn(e, t, n), a = i.hip, h = i.chains, c = i.head.center, u = (k) => {
|
|
2467
|
+
if ("head" in k) return he(c, je(i.head.axes[1], i.head.ry));
|
|
2468
|
+
const x = h[k.chain];
|
|
2469
|
+
return x[Math.min(k.joint, x.length - 1)];
|
|
2470
|
+
}, g = s.toView(a), f = s.toScreen(g), p = s.toScreen([g[0] + 1, g[1], g[2]]), d = Math.hypot(p.x - f.x, p.y - f.y), m = (k) => {
|
|
2471
|
+
const x = s.toView(k);
|
|
2472
|
+
return { point: s.toScreen(x), depth: x[2] * d };
|
|
2473
|
+
}, b = {};
|
|
2474
|
+
for (const k of e.chains) {
|
|
2475
|
+
const x = h[k.id].map(m);
|
|
2476
|
+
b[k.id] = {
|
|
2477
|
+
id: k.id,
|
|
2478
|
+
joints3: l.chains[k.id].joints3,
|
|
2479
|
+
frames: l.chains[k.id].frames,
|
|
2480
|
+
points: x.map((v) => v.point),
|
|
2481
|
+
depths: x.map((v) => v.depth)
|
|
2407
2482
|
};
|
|
2408
2483
|
}
|
|
2409
|
-
const
|
|
2410
|
-
center:
|
|
2411
|
-
depth:
|
|
2412
|
-
rx:
|
|
2413
|
-
ry:
|
|
2414
|
-
angle: Math.atan2(
|
|
2415
|
-
axes:
|
|
2416
|
-
},
|
|
2484
|
+
const y = s.toView(c), E = s.toScreen(y), H = s.toScreen([y[0] + 1, y[1], y[2]]), M = Math.hypot(H.x - E.x, H.y - E.y), A = i.head.axes.map((k) => Ln(kt(s.toView(he(c, k)), y))), w = {
|
|
2485
|
+
center: E,
|
|
2486
|
+
depth: y[2] * d,
|
|
2487
|
+
rx: l.head.rx * M,
|
|
2488
|
+
ry: l.head.ry * M,
|
|
2489
|
+
angle: Math.atan2(A[1][0], A[1][1]),
|
|
2490
|
+
axes: A
|
|
2491
|
+
}, S = e.contacts.map((k) => ({ spec: k, point: m(u(k)).point }));
|
|
2417
2492
|
return {
|
|
2418
|
-
height: o *
|
|
2419
|
-
view:
|
|
2420
|
-
chains:
|
|
2421
|
-
head:
|
|
2422
|
-
hip:
|
|
2423
|
-
contacts:
|
|
2424
|
-
groundY: Math.max(...
|
|
2493
|
+
height: o * d,
|
|
2494
|
+
view: r,
|
|
2495
|
+
chains: b,
|
|
2496
|
+
head: w,
|
|
2497
|
+
hip: f,
|
|
2498
|
+
contacts: S,
|
|
2499
|
+
groundY: Math.max(...S.map((k) => k.point.y))
|
|
2425
2500
|
};
|
|
2426
2501
|
}
|
|
2427
|
-
function
|
|
2428
|
-
const [o,
|
|
2429
|
-
o[0] * t * e.rx +
|
|
2430
|
-
o[1] * t * e.rx +
|
|
2431
|
-
o[2] * t * e.rx +
|
|
2432
|
-
], a = Math.hypot(t, n,
|
|
2433
|
-
return { point: { x: e.center.x +
|
|
2502
|
+
function Cn(e, [t, n, s]) {
|
|
2503
|
+
const [o, r, l] = e.axes, i = [
|
|
2504
|
+
o[0] * t * e.rx + r[0] * n * e.ry + l[0] * s * e.rx,
|
|
2505
|
+
o[1] * t * e.rx + r[1] * n * e.ry + l[1] * s * e.rx,
|
|
2506
|
+
o[2] * t * e.rx + r[2] * n * e.ry + l[2] * s * e.rx
|
|
2507
|
+
], a = Math.hypot(t, n, s) || 1, h = (o[2] * t + r[2] * n + l[2] * s) / a;
|
|
2508
|
+
return { point: { x: e.center.x + i[0], y: e.center.y - i[1] }, depth: e.depth + i[2], facing: h };
|
|
2434
2509
|
}
|
|
2435
|
-
const
|
|
2436
|
-
const t =
|
|
2510
|
+
const $e = (e) => e * 180 / Math.PI, me = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], lt = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], Te = (e) => Math.hypot(e[0], e[1], e[2]), St = (e) => {
|
|
2511
|
+
const t = Te(e) || 1;
|
|
2437
2512
|
return [e[0] / t, e[1] / t, e[2] / t];
|
|
2438
|
-
},
|
|
2439
|
-
function
|
|
2440
|
-
const [t, n,
|
|
2441
|
-
return { swing: Math.asin(Math.max(-1, Math.min(1,
|
|
2442
|
-
}
|
|
2443
|
-
function
|
|
2444
|
-
const
|
|
2445
|
-
if (!
|
|
2446
|
-
if (
|
|
2513
|
+
}, Be = (e) => Math.atan2(Math.sin(e), Math.cos(e));
|
|
2514
|
+
function nn(e) {
|
|
2515
|
+
const [t, n, s] = St(e);
|
|
2516
|
+
return { swing: Math.asin(Math.max(-1, Math.min(1, s))), spread: Math.atan2(t, -n) };
|
|
2517
|
+
}
|
|
2518
|
+
function sr(e, t, n, s, o) {
|
|
2519
|
+
const r = e.chains.find((x) => x.id === n);
|
|
2520
|
+
if (!r) throw new Error(`reach: no chain ${n} in ${e.id}`);
|
|
2521
|
+
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`);
|
|
2447
2522
|
if (!e.withAngles) throw new Error(`reach: the ${e.id} plan cannot set angles`);
|
|
2448
|
-
const
|
|
2449
|
-
let
|
|
2450
|
-
|
|
2451
|
-
const
|
|
2452
|
-
a[0] + h * (
|
|
2453
|
-
a[1] + h * (
|
|
2454
|
-
a[2] + h * (
|
|
2455
|
-
],
|
|
2456
|
-
{ swing:
|
|
2457
|
-
{ swing:
|
|
2523
|
+
const l = It(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: o.height, contact: "none" }), i = l.chains[n], a = i.joints3[0], h = Te(me(i.joints3[1], i.joints3[0])), c = Te(me(i.joints3[2], i.joints3[1])), u = r.parent ? l.chains[r.parent].frames[Math.max(0, (r.at ?? l.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, g = me(s, a), f = Math.min(h + c - 1e-6, Math.max(Math.abs(h - c) + 1e-6, Te(g))), p = St(g), d = r.parent !== null, m = De(r.pole ?? (d ? [0, -0.35, -1] : [0, 0, 1]), u);
|
|
2524
|
+
let b = me(m, [p[0] * lt(m, p), p[1] * lt(m, p), p[2] * lt(m, p)]);
|
|
2525
|
+
Te(b) < 1e-6 && (b = ge([1, 0, 0], 0)), b = St(b);
|
|
2526
|
+
const y = (h * h + f * f - c * c) / (2 * h * f), E = Math.sqrt(Math.max(0, 1 - y * y)), H = [
|
|
2527
|
+
a[0] + h * (y * p[0] + E * b[0]),
|
|
2528
|
+
a[1] + h * (y * p[1] + E * b[1]),
|
|
2529
|
+
a[2] + h * (y * p[2] + E * b[2])
|
|
2530
|
+
], M = [a[0] + p[0] * f, a[1] + p[1] * f, a[2] + p[2] * f], A = r.side ?? 1, w = nn(me(H, a)), S = nn(me(M, H)), k = [
|
|
2531
|
+
{ swing: $e(Be(w.swing - u.swing)), spread: $e(Be(w.spread - u.spread)) * A },
|
|
2532
|
+
{ swing: $e(Be(S.swing - w.swing)), spread: $e(Be(S.spread - w.spread)) * A }
|
|
2458
2533
|
];
|
|
2459
|
-
return e.withAngles(t,
|
|
2534
|
+
return e.withAngles(t, r, k);
|
|
2460
2535
|
}
|
|
2461
|
-
const
|
|
2462
|
-
function
|
|
2463
|
-
const
|
|
2536
|
+
const rr = 0.34, ie = 0.12, oe = -0.4, re = (e, t, n) => e[t] ?? n, ir = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), lr = 0.45, ar = 0.35, hr = 0.7;
|
|
2537
|
+
function Je(e, t, n) {
|
|
2538
|
+
const s = (f) => Math.sqrt(Math.max(0, 1 - f.x * f.x - f.y * f.y)), o = Cn(e, [n.x, n.y, s(n)]).facing, r = e.axes[2], l = Math.atan2(r[0], r[2]), i = Math.cos(l), a = i >= 0 ? 1 : -1, h = a * Math.max(ar, Math.abs(i)), c = a * Math.max(hr, Math.abs(i)), u = Math.cos(e.angle), g = Math.sin(e.angle);
|
|
2464
2539
|
return {
|
|
2465
2540
|
facing: o,
|
|
2466
|
-
points: t.map((
|
|
2467
|
-
const
|
|
2468
|
-
return { x: e.center.x +
|
|
2541
|
+
points: t.map((f) => {
|
|
2542
|
+
const p = lr * Math.sin(l) + n.x * h + (f.x - n.x) * c, d = f.y + r[1] * s(f), m = p * e.rx, b = d * e.ry;
|
|
2543
|
+
return { x: e.center.x + m * u + b * g, y: e.center.y + m * g - b * u };
|
|
2469
2544
|
})
|
|
2470
2545
|
};
|
|
2471
2546
|
}
|
|
2472
|
-
const
|
|
2473
|
-
const
|
|
2474
|
-
return { x:
|
|
2475
|
-
}),
|
|
2476
|
-
const
|
|
2477
|
-
return { x: e + Math.cos(
|
|
2478
|
-
}),
|
|
2479
|
-
function
|
|
2480
|
-
const o = Math.max(1, Math.min(
|
|
2481
|
-
for (const
|
|
2482
|
-
const
|
|
2483
|
-
if (
|
|
2484
|
-
const H = { x:
|
|
2485
|
-
if (
|
|
2486
|
-
const
|
|
2487
|
-
e.line(
|
|
2547
|
+
const Fe = (e, t, n, s = 12) => Array.from({ length: s + 1 }, (o, r) => {
|
|
2548
|
+
const l = r / s, i = 1 - l;
|
|
2549
|
+
return { x: i * i * e.x + 2 * i * l * t.x + l * l * n.x, y: i * i * e.y + 2 * i * l * t.y + l * l * n.y };
|
|
2550
|
+
}), at = (e, t, n, s, o = 16) => Array.from({ length: o }, (r, l) => {
|
|
2551
|
+
const i = Math.PI * 2 * l / o;
|
|
2552
|
+
return { x: e + Math.cos(i) * n, y: t + Math.sin(i) * s };
|
|
2553
|
+
}), on = 0.05;
|
|
2554
|
+
function cr(e, t, n, s) {
|
|
2555
|
+
const o = Math.max(1, Math.min(s * 0.6, 0.14 * t.rx)), r = (b, y) => Je(t, b, y).points, l = (b, y) => Je(t, [], { x: b, y }).facing, i = re(n, "smile", 0), a = re(n, "blink", 0), h = re(n, "lookX", 0), c = re(n, "lookY", 0), u = re(n, "browTilt", 0);
|
|
2556
|
+
for (const b of [1, -1]) {
|
|
2557
|
+
const y = b === 1 ? "left" : "right", E = rr * b;
|
|
2558
|
+
if (l(E, ie) < on) continue;
|
|
2559
|
+
const H = { x: E, y: ie }, M = ir(re(n, `eye.${y}`, 1), a);
|
|
2560
|
+
if (M < 0.2) {
|
|
2561
|
+
const k = i > 0.5 ? 0.12 : -0.06;
|
|
2562
|
+
e.line(r(Fe({ x: E - 0.12, y: ie }, { x: E, y: ie + k }, { x: E + 0.12, y: ie }), H), o);
|
|
2488
2563
|
} else {
|
|
2489
|
-
if (
|
|
2490
|
-
const
|
|
2491
|
-
e.shape(
|
|
2564
|
+
if (M > 1.2) {
|
|
2565
|
+
const T = 0.13 * M;
|
|
2566
|
+
e.shape(r(at(E, ie, T * 0.85, T), H), "#ffffff", o);
|
|
2492
2567
|
}
|
|
2493
|
-
const
|
|
2494
|
-
e.shape(
|
|
2568
|
+
const k = M > 1.2 ? 0.075 : 0.1, x = E + h * 0.08, v = ie - c * 0.07;
|
|
2569
|
+
e.shape(r(at(x, v, k, k * 1.1 * Math.min(M, 1)), H), e.ink, 0);
|
|
2495
2570
|
}
|
|
2496
|
-
const
|
|
2497
|
-
e.line(
|
|
2498
|
-
}
|
|
2499
|
-
const
|
|
2500
|
-
if (
|
|
2501
|
-
const
|
|
2502
|
-
if (
|
|
2503
|
-
e.line(
|
|
2571
|
+
const A = ie + 0.3 + re(n, `brow.${y}`, 0) * 0.14 + Math.max(0, M - 1) * 0.12, w = { x: E + b * 0.13, y: A }, S = { x: E - b * 0.13, y: A + u * 0.1 };
|
|
2572
|
+
e.line(r([w, { x: (w.x + S.x) / 2, y: (w.y + S.y) / 2 }, S], { x: E, y: A }), o);
|
|
2573
|
+
}
|
|
2574
|
+
const g = { x: 0, y: oe };
|
|
2575
|
+
if (l(0, oe) < -on) return;
|
|
2576
|
+
const f = 0.25 * Math.max(0.3, re(n, "mouthWidth", 1)), p = Math.min(1, Math.max(0, re(n, "mouth", 0)));
|
|
2577
|
+
if (p <= 0.05) {
|
|
2578
|
+
e.line(r(Fe({ x: -f, y: oe }, { x: 0, y: oe - i * 0.25 }, { x: f, y: oe }), g), o);
|
|
2504
2579
|
return;
|
|
2505
2580
|
}
|
|
2506
|
-
const
|
|
2507
|
-
let
|
|
2508
|
-
if (
|
|
2509
|
-
const
|
|
2510
|
-
|
|
2511
|
-
} else if (
|
|
2512
|
-
const
|
|
2513
|
-
|
|
2581
|
+
const d = 0.3 * p;
|
|
2582
|
+
let m;
|
|
2583
|
+
if (i > 0.3) {
|
|
2584
|
+
const b = oe + 0.05;
|
|
2585
|
+
m = [...Fe({ x: f, y: b }, { x: 0, y: oe - d * 2 }, { x: -f, y: b })];
|
|
2586
|
+
} else if (i < -0.3) {
|
|
2587
|
+
const b = oe - d * 0.6;
|
|
2588
|
+
m = [...Fe({ x: f, y: b }, { x: 0, y: oe + d * 1.4 }, { x: -f, y: b })];
|
|
2514
2589
|
} else
|
|
2515
|
-
|
|
2516
|
-
e.shape(
|
|
2590
|
+
m = at(0, oe, f * 0.8, d);
|
|
2591
|
+
e.shape(r(m, g), e.ink, 0);
|
|
2517
2592
|
}
|
|
2518
|
-
function
|
|
2519
|
-
const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid",
|
|
2593
|
+
function fr(e = {}) {
|
|
2594
|
+
const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid", s = e.look ?? "clean", o = e.height ?? 300, r = n === "stick";
|
|
2520
2595
|
return {
|
|
2521
|
-
plan: e.plan ??
|
|
2596
|
+
plan: e.plan ?? er({
|
|
2522
2597
|
headSize: e.headSize ?? (t ? 0.3 : 0.24),
|
|
2523
|
-
shoulderWidth:
|
|
2524
|
-
hipWidth:
|
|
2598
|
+
shoulderWidth: r ? 0 : e.shoulderWidth ?? 0.06,
|
|
2599
|
+
hipWidth: r ? 0 : e.hipWidth ?? 0.022
|
|
2525
2600
|
}),
|
|
2526
2601
|
figure: n,
|
|
2527
|
-
look:
|
|
2602
|
+
look: s,
|
|
2528
2603
|
height: o,
|
|
2529
2604
|
lineWidth: e.lineWidth ?? o * (t ? 0.045 : 0.022),
|
|
2530
|
-
ink: e.ink ?? (
|
|
2531
|
-
skin: e.skin ?? (
|
|
2605
|
+
ink: e.ink ?? (s === "pencil" ? "#2f2f33" : "#1e293b"),
|
|
2606
|
+
skin: e.skin ?? (s === "pencil" ? "none" : "#ffffff"),
|
|
2532
2607
|
seed: e.seed ?? 1,
|
|
2533
2608
|
pencil: e.pencil ?? {},
|
|
2534
2609
|
layers: e.layers ?? {},
|
|
@@ -2538,108 +2613,108 @@ function Er(e = {}) {
|
|
|
2538
2613
|
handSize: e.handSize ?? (e.handStyle === "natural" ? 0.14 : 0.17)
|
|
2539
2614
|
};
|
|
2540
2615
|
}
|
|
2541
|
-
function
|
|
2542
|
-
const { point: o, facing:
|
|
2543
|
-
return { point: o, facing:
|
|
2544
|
-
}
|
|
2545
|
-
const
|
|
2546
|
-
function
|
|
2547
|
-
return e.figure === "stick" ?
|
|
2548
|
-
}
|
|
2549
|
-
function
|
|
2550
|
-
const n = e.plan.id === "human" ? { ...
|
|
2551
|
-
return
|
|
2552
|
-
}
|
|
2553
|
-
function
|
|
2554
|
-
const
|
|
2555
|
-
e.plan.chains.forEach((
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2558
|
-
const
|
|
2559
|
-
|
|
2560
|
-
}), o.head = { points: [n.head.center], depth: n.head.depth },
|
|
2561
|
-
const
|
|
2562
|
-
for (const [
|
|
2563
|
-
const
|
|
2564
|
-
|
|
2616
|
+
function Ki(e, t, n, s) {
|
|
2617
|
+
const { point: o, facing: r } = Cn(e, [t, n, s]);
|
|
2618
|
+
return { point: o, facing: r };
|
|
2619
|
+
}
|
|
2620
|
+
const Et = (e) => e.rest[1] < -0.5, ur = 0.3;
|
|
2621
|
+
function dr(e, t, n) {
|
|
2622
|
+
return e.figure === "stick" ? Et(t) ? n.slice(0, 3) : n : Et(t) && n.length >= 3 ? ke(n[0], n[1], n[2], ur) : n.length === 3 ? ke(n[0], n[1], n[2], 1) : n;
|
|
2623
|
+
}
|
|
2624
|
+
function _t(e, t) {
|
|
2625
|
+
const n = e.plan.id === "human" ? { ...X, ...t } : t;
|
|
2626
|
+
return $t(e, n, It(e.plan, n, { height: e.height, contact: e.contact }));
|
|
2627
|
+
}
|
|
2628
|
+
function $t(e, t, n) {
|
|
2629
|
+
const s = {}, o = {}, r = {}, l = 0.01 * e.height;
|
|
2630
|
+
e.plan.chains.forEach((g) => {
|
|
2631
|
+
const f = n.chains[g.id];
|
|
2632
|
+
s[g.id] = f.points;
|
|
2633
|
+
const p = f.depths.reduce((y, E) => y + E, 0) / f.depths.length, d = g.parent ? n.chains[g.parent] : void 0, m = d ? d.depths[g.at ?? d.depths.length - 1] : 0, b = p - m;
|
|
2634
|
+
r[g.id] = Math.abs(b) < l ? 0 : b, o[g.id] = { points: dr(e, g, f.points), depth: p };
|
|
2635
|
+
}), o.head = { points: [n.head.center], depth: n.head.depth }, r.head = 0;
|
|
2636
|
+
const i = [...e.plan.chains.map((g) => g.id), "head"], a = [...i].sort((g, f) => r[g] - r[f] || i.indexOf(g) - i.indexOf(f)), h = { hip: n.hip };
|
|
2637
|
+
for (const [g, [f, p]] of Object.entries(e.plan.landmarks ?? {})) {
|
|
2638
|
+
const d = n.chains[f]?.points;
|
|
2639
|
+
d && (h[g] = d[Math.min(p, d.length - 1)]);
|
|
2565
2640
|
}
|
|
2566
2641
|
const c = {};
|
|
2567
|
-
for (const [
|
|
2568
|
-
const
|
|
2642
|
+
for (const [g, f] of Object.entries(h)) c[g] = f.y >= n.groundY - 0.01 * e.height;
|
|
2643
|
+
const u = {
|
|
2569
2644
|
height: e.height,
|
|
2570
2645
|
lineWidth: e.lineWidth,
|
|
2571
2646
|
turn: t.turn ?? 0,
|
|
2572
2647
|
points: h,
|
|
2573
|
-
chains:
|
|
2648
|
+
chains: s,
|
|
2574
2649
|
parts: o,
|
|
2575
2650
|
head: n.head,
|
|
2576
2651
|
groundY: n.groundY,
|
|
2577
2652
|
grounded: c
|
|
2578
2653
|
};
|
|
2579
|
-
return { skeleton: n, joints:
|
|
2654
|
+
return { skeleton: n, joints: u, order: a };
|
|
2580
2655
|
}
|
|
2581
|
-
function
|
|
2582
|
-
return
|
|
2656
|
+
function gr(e, t) {
|
|
2657
|
+
return _t(e, t).joints;
|
|
2583
2658
|
}
|
|
2584
|
-
function
|
|
2585
|
-
const { head:
|
|
2586
|
-
e.guideEllipse(
|
|
2587
|
-
const o = Array.from({ length: 13 }, (a, h) => ({ x: 0, y: -0.95 + 1.9 * h / 12 })),
|
|
2588
|
-
|
|
2589
|
-
const
|
|
2659
|
+
function pr(e, t, n) {
|
|
2660
|
+
const { head: s } = n;
|
|
2661
|
+
e.guideEllipse(s.center.x, s.center.y, s.rx * 1.03, s.ry * 1.03, s.angle);
|
|
2662
|
+
const o = Array.from({ length: 13 }, (a, h) => ({ x: 0, y: -0.95 + 1.9 * h / 12 })), r = Array.from({ length: 13 }, (a, h) => ({ x: -0.95 + 1.9 * h / 12, y: 0.12 })), l = Je(s, o, { x: 0, y: 0 });
|
|
2663
|
+
l.facing > 0 && e.guide(l.points), e.guide(Je(s, r, { x: 0, y: 0.12 }).points), e.guide(n.chains.spine ?? []);
|
|
2664
|
+
const i = t.lineWidth * 0.9;
|
|
2590
2665
|
for (const a of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
|
|
2591
2666
|
const h = n.points[a];
|
|
2592
|
-
h && e.guideEllipse(h.x, h.y,
|
|
2667
|
+
h && e.guideEllipse(h.x, h.y, i, i, 0);
|
|
2593
2668
|
}
|
|
2594
2669
|
}
|
|
2595
|
-
function
|
|
2596
|
-
const
|
|
2670
|
+
function mr(e, t, n, s, o, r) {
|
|
2671
|
+
const l = n.lineWidth;
|
|
2597
2672
|
if (o === "head") {
|
|
2598
|
-
const { head:
|
|
2599
|
-
t.ellipse(
|
|
2673
|
+
const { head: f } = s, p = n.skin === "none" ? null : n.skin;
|
|
2674
|
+
t.ellipse(f.center.x, f.center.y, f.rx, f.ry, f.angle, p, l), t.look !== "silhouette" && cr(t, f, r, l);
|
|
2600
2675
|
return;
|
|
2601
2676
|
}
|
|
2602
|
-
const
|
|
2677
|
+
const i = n.plan.chains.find((f) => f.id === o), a = s.chains[o], h = s.parts[o].points;
|
|
2603
2678
|
if (n.figure === "stick") {
|
|
2604
2679
|
if (o === "neck") return;
|
|
2605
|
-
const
|
|
2606
|
-
t.line(
|
|
2680
|
+
const f = o === "spine" ? [...a, ...s.chains.neck?.slice(1) ?? []] : h;
|
|
2681
|
+
t.line(f, l);
|
|
2607
2682
|
return;
|
|
2608
2683
|
}
|
|
2609
|
-
const c = (
|
|
2610
|
-
if (
|
|
2611
|
-
const [
|
|
2612
|
-
if (t.limb(h,
|
|
2613
|
-
t.limb([a[2], a[3]],
|
|
2684
|
+
const c = (f, p) => [i.bones[f].width[0] * l, i.bones[p].width[1] * l];
|
|
2685
|
+
if (Et(i)) {
|
|
2686
|
+
const [f, p] = c(0, 1);
|
|
2687
|
+
if (t.limb(h, f, p), i.bones.length >= 3)
|
|
2688
|
+
t.limb([a[2], a[3]], i.bones[2].width[0] * l, i.bones[2].width[1] * l);
|
|
2614
2689
|
else if (n.hands === "cartoon" && o.startsWith("arm."))
|
|
2615
|
-
|
|
2690
|
+
wr(e, t, n, a, o.endsWith(".left") ? "left" : "right", r);
|
|
2616
2691
|
else {
|
|
2617
|
-
const
|
|
2618
|
-
t.dot(
|
|
2692
|
+
const d = a[a.length - 1];
|
|
2693
|
+
t.dot(d.x, d.y, l * 0.62);
|
|
2619
2694
|
}
|
|
2620
2695
|
return;
|
|
2621
2696
|
}
|
|
2622
2697
|
if (o === "spine") {
|
|
2623
|
-
const
|
|
2624
|
-
|
|
2625
|
-
const [
|
|
2626
|
-
t.limb(h,
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2698
|
+
const f = s.points["hip.left"], p = s.points["hip.right"];
|
|
2699
|
+
f && p && Math.hypot(f.x - p.x, f.y - p.y) > 0.5 && t.limb([f, p], l * 1.3, l * 1.3);
|
|
2700
|
+
const [d, m] = c(0, i.bones.length - 1);
|
|
2701
|
+
t.limb(h, d, m);
|
|
2702
|
+
const b = s.points["shoulder.left"], y = s.points["shoulder.right"];
|
|
2703
|
+
b && y && Math.hypot(b.x - y.x, b.y - y.y) > 0.5 && t.limb(ke(b, a[a.length - 1], y, 1, 10), l * 1.15, l * 1.15);
|
|
2629
2704
|
return;
|
|
2630
2705
|
}
|
|
2631
|
-
const [
|
|
2632
|
-
t.limb(h,
|
|
2633
|
-
}
|
|
2634
|
-
function
|
|
2635
|
-
const n = `hand.${t}.`,
|
|
2636
|
-
for (const [
|
|
2637
|
-
const o = e.turn ?? 0,
|
|
2638
|
-
return { ...
|
|
2639
|
-
}
|
|
2640
|
-
function
|
|
2641
|
-
const
|
|
2642
|
-
|
|
2706
|
+
const [u, g] = c(0, i.bones.length - 1);
|
|
2707
|
+
t.limb(h, u, g);
|
|
2708
|
+
}
|
|
2709
|
+
function br(e, t) {
|
|
2710
|
+
const n = `hand.${t}.`, s = {};
|
|
2711
|
+
for (const [l, i] of Object.entries(e)) l.startsWith(n) && (s[l.slice(n.length)] = i);
|
|
2712
|
+
const o = e.turn ?? 0, r = t === "right" ? 1 - o : 1 + o;
|
|
2713
|
+
return { ...L, ...s, turn: r + (s.turn ?? 0) };
|
|
2714
|
+
}
|
|
2715
|
+
function wr(e, t, n, s, o, r) {
|
|
2716
|
+
const l = s[s.length - 1], i = s[s.length - 2], a = Math.atan2(l.x - i.x, -(l.y - i.y)) * 180 / Math.PI;
|
|
2717
|
+
Tt(e, l, br(r, o), {
|
|
2643
2718
|
size: n.handSize * n.height,
|
|
2644
2719
|
side: o,
|
|
2645
2720
|
angle: a,
|
|
@@ -2652,24 +2727,24 @@ function Kr(e, t, n, r, o, s) {
|
|
|
2652
2727
|
lineWidth: n.lineWidth * 0.3
|
|
2653
2728
|
});
|
|
2654
2729
|
}
|
|
2655
|
-
function
|
|
2656
|
-
const o = t.plan.id === "human" ? { ...
|
|
2657
|
-
|
|
2730
|
+
function yr(e, t, n, s = 0) {
|
|
2731
|
+
const o = t.plan.id === "human" ? { ...X, ...n } : n;
|
|
2732
|
+
Xn(e, t, o, _t(t, o), s);
|
|
2658
2733
|
}
|
|
2659
|
-
function
|
|
2734
|
+
function Dn(e, t) {
|
|
2660
2735
|
const n = t / e.height;
|
|
2661
2736
|
return { ...e, height: t, lineWidth: e.lineWidth * n };
|
|
2662
2737
|
}
|
|
2663
|
-
function
|
|
2664
|
-
const o = e.plan.id === "human" ? { ...
|
|
2665
|
-
return
|
|
2738
|
+
function Pi(e, t, n, s) {
|
|
2739
|
+
const o = e.plan.id === "human" ? { ...X, ...t } : t, r = Yn(e.plan, o, { height: s.height, contact: e.contact }, n);
|
|
2740
|
+
return $t(Dn(e, r.height), o, r).joints;
|
|
2666
2741
|
}
|
|
2667
|
-
function
|
|
2668
|
-
const
|
|
2669
|
-
|
|
2742
|
+
function kr(e, t, n, s, o) {
|
|
2743
|
+
const r = t.plan.id === "human" ? { ...X, ...n } : n, l = Yn(t.plan, r, { height: o.height, contact: t.contact }, s), i = Dn(t, l.height);
|
|
2744
|
+
Xn(e, i, r, $t(i, r, l), o.time ?? 0);
|
|
2670
2745
|
}
|
|
2671
|
-
function
|
|
2672
|
-
const { joints:
|
|
2746
|
+
function Xn(e, t, n, s, o) {
|
|
2747
|
+
const { joints: r, order: l } = s, i = bn(e, {
|
|
2673
2748
|
look: t.look,
|
|
2674
2749
|
ink: t.ink,
|
|
2675
2750
|
lineWidth: t.lineWidth,
|
|
@@ -2677,87 +2752,91 @@ function fn(e, t, n, r, o) {
|
|
|
2677
2752
|
time: o,
|
|
2678
2753
|
pencil: t.pencil
|
|
2679
2754
|
}), a = (h) => {
|
|
2680
|
-
h && (e.save(), h(e,
|
|
2755
|
+
h && (e.save(), h(e, r, i, o), e.restore());
|
|
2681
2756
|
};
|
|
2682
|
-
e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 &&
|
|
2683
|
-
for (const h of
|
|
2757
|
+
e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && pr(i, t, r), a(t.layers.behind);
|
|
2758
|
+
for (const h of l) {
|
|
2684
2759
|
const c = t.layers.parts?.[h];
|
|
2685
|
-
a(c?.under),
|
|
2760
|
+
a(c?.under), mr(e, i, t, r, h, n), a(c?.over);
|
|
2686
2761
|
}
|
|
2687
2762
|
a(t.layers.front), e.restore();
|
|
2688
2763
|
}
|
|
2689
|
-
function
|
|
2690
|
-
const
|
|
2691
|
-
for (const [o,
|
|
2692
|
-
const
|
|
2693
|
-
|
|
2764
|
+
function Wi(e, t, n) {
|
|
2765
|
+
const s = { ...e };
|
|
2766
|
+
for (const [o, r] of Object.entries(t)) {
|
|
2767
|
+
const l = e[o] ?? r;
|
|
2768
|
+
s[o] = l + (r - l) * n;
|
|
2694
2769
|
}
|
|
2695
|
-
return
|
|
2770
|
+
return s;
|
|
2696
2771
|
}
|
|
2697
|
-
function
|
|
2698
|
-
const o = e.plan.id === "human" ? { ...
|
|
2699
|
-
let
|
|
2700
|
-
if (Array.isArray(
|
|
2701
|
-
|
|
2772
|
+
function Oi(e, t, n, s) {
|
|
2773
|
+
const o = e.plan.id === "human" ? { ...X, ...t } : t;
|
|
2774
|
+
let r;
|
|
2775
|
+
if (Array.isArray(s))
|
|
2776
|
+
r = s;
|
|
2702
2777
|
else {
|
|
2703
|
-
const { skeleton:
|
|
2704
|
-
|
|
2778
|
+
const { skeleton: l } = _t(e, o), i = It(e.plan, { ...o, roll: 0 }, { height: e.height, contact: "none" }), a = (o.roll ?? 0) * Math.PI / 180, h = s.x - l.hip.x, c = s.y - l.hip.y, u = i.hip.x + h * Math.cos(-a) - c * Math.sin(-a), g = i.hip.y + h * Math.sin(-a) + c * Math.cos(-a), f = Math.PI / 2 * (o.turn ?? 0), p = s.depth ?? l.chains[n].depths[l.chains[n].depths.length - 1], d = Math.cos(f), m = Math.sin(f);
|
|
2779
|
+
r = [u * d - p * m, -g, u * m + p * d];
|
|
2705
2780
|
}
|
|
2706
|
-
return
|
|
2781
|
+
return sr(e.plan, o, n, r, { height: e.height });
|
|
2707
2782
|
}
|
|
2708
|
-
function
|
|
2709
|
-
const { character: t } = e, n = t.height * 0.8,
|
|
2783
|
+
function Ii(e) {
|
|
2784
|
+
const { character: t } = e, n = t.height * 0.8, s = t.height, o = t.plan.id === "human" ? X : {};
|
|
2710
2785
|
return {
|
|
2711
2786
|
type: "custom",
|
|
2712
2787
|
x: e.x - n / 2,
|
|
2713
|
-
y: e.y -
|
|
2788
|
+
y: e.y - s,
|
|
2714
2789
|
width: n,
|
|
2715
|
-
height:
|
|
2790
|
+
height: s,
|
|
2716
2791
|
props: { ...o, ...e.pose },
|
|
2717
2792
|
character: t,
|
|
2718
|
-
draw(
|
|
2719
|
-
|
|
2793
|
+
draw(r, l, i) {
|
|
2794
|
+
r.translate(n / 2, s), yr(r, t, l.props, i);
|
|
2720
2795
|
}
|
|
2721
2796
|
};
|
|
2722
2797
|
}
|
|
2723
|
-
function
|
|
2724
|
-
const
|
|
2798
|
+
function Sr(e, t, n) {
|
|
2799
|
+
const s = (r) => ({ x: r.x + t, y: r.y + n }), o = (r) => Object.fromEntries(Object.entries(r).map(([l, i]) => [l, i.map(s)]));
|
|
2725
2800
|
return {
|
|
2726
2801
|
...e,
|
|
2727
|
-
points: Object.fromEntries(Object.entries(e.points).map(([
|
|
2802
|
+
points: Object.fromEntries(Object.entries(e.points).map(([r, l]) => [r, s(l)])),
|
|
2728
2803
|
chains: o(e.chains),
|
|
2729
|
-
parts: Object.fromEntries(Object.entries(e.parts).map(([
|
|
2730
|
-
head: { ...e.head, center:
|
|
2804
|
+
parts: Object.fromEntries(Object.entries(e.parts).map(([r, l]) => [r, { ...l, points: l.points.map(s) }])),
|
|
2805
|
+
head: { ...e.head, center: s(e.head.center) },
|
|
2731
2806
|
groundY: e.groundY + n
|
|
2732
2807
|
};
|
|
2733
2808
|
}
|
|
2734
|
-
function
|
|
2735
|
-
const
|
|
2736
|
-
if (!
|
|
2809
|
+
function _i(e, t, n) {
|
|
2810
|
+
const s = e.character;
|
|
2811
|
+
if (!s) throw new Error("characterAt: the target was not made by characterTarget");
|
|
2737
2812
|
const o = { ...e.props };
|
|
2738
|
-
let
|
|
2813
|
+
let r = 0, l = 0;
|
|
2739
2814
|
for (const [a, h] of t.state?.values.get(n) ?? [])
|
|
2740
|
-
typeof h == "number" && (a === "x" || a === "motionPathX" ?
|
|
2741
|
-
const
|
|
2742
|
-
return { pose: o, joints:
|
|
2743
|
-
}
|
|
2744
|
-
function
|
|
2745
|
-
const
|
|
2746
|
-
return
|
|
2747
|
-
const
|
|
2748
|
-
|
|
2749
|
-
}),
|
|
2750
|
-
|
|
2815
|
+
typeof h == "number" && (a === "x" || a === "motionPathX" ? r = h : a === "y" || a === "motionPathY" ? l = h : a in o && (o[a] = h));
|
|
2816
|
+
const i = gr(s, o);
|
|
2817
|
+
return { pose: o, joints: Sr(i, e.x + r + e.width / 2, e.y + l + e.height) };
|
|
2818
|
+
}
|
|
2819
|
+
function qn(e, t = X) {
|
|
2820
|
+
const n = [];
|
|
2821
|
+
return e.forEach((s, o) => {
|
|
2822
|
+
const r = o === 0 ? t : n[o - 1], l = typeof s.pose == "string" ? Qs[s.pose] : void 0;
|
|
2823
|
+
n.push(l ? { ...l, turn: r.turn ?? 0 } : { ...r, ...s.pose });
|
|
2824
|
+
}), n;
|
|
2825
|
+
}
|
|
2826
|
+
function $i(e, t, n = X) {
|
|
2827
|
+
const s = qn(t, n);
|
|
2828
|
+
return Object.keys(n).filter((r) => s.some((l) => (l[r] ?? n[r]) !== n[r])).map((r) => ({
|
|
2829
|
+
id: `${e}-${r}`,
|
|
2751
2830
|
target: e,
|
|
2752
|
-
property:
|
|
2753
|
-
keyframes: t.map((
|
|
2754
|
-
time:
|
|
2755
|
-
value:
|
|
2756
|
-
...
|
|
2831
|
+
property: r,
|
|
2832
|
+
keyframes: t.map((l, i) => ({
|
|
2833
|
+
time: l.time,
|
|
2834
|
+
value: s[i][r] ?? n[r],
|
|
2835
|
+
...l.easing ? { easing: l.easing } : {}
|
|
2757
2836
|
}))
|
|
2758
2837
|
}));
|
|
2759
2838
|
}
|
|
2760
|
-
const
|
|
2839
|
+
const Er = /* @__PURE__ */ new Set([
|
|
2761
2840
|
"x",
|
|
2762
2841
|
"y",
|
|
2763
2842
|
"z",
|
|
@@ -2773,43 +2852,43 @@ const Ir = /* @__PURE__ */ new Set([
|
|
|
2773
2852
|
"visible",
|
|
2774
2853
|
"opacity",
|
|
2775
2854
|
"color"
|
|
2776
|
-
]),
|
|
2777
|
-
function
|
|
2778
|
-
const
|
|
2779
|
-
const
|
|
2780
|
-
return
|
|
2855
|
+
]), Mr = 1.7;
|
|
2856
|
+
function Hr(e, t, n) {
|
|
2857
|
+
const s = Array.from({ length: 24 }, (o, r) => {
|
|
2858
|
+
const l = r / 24 * Math.PI * 2, i = t.toView([Math.cos(l) * n, 0, Math.sin(l) * n * 0.8]);
|
|
2859
|
+
return i[2] < -1e-3 ? t.toScreen(i) : null;
|
|
2781
2860
|
});
|
|
2782
|
-
|
|
2783
|
-
}
|
|
2784
|
-
function
|
|
2785
|
-
const t =
|
|
2786
|
-
if (t > 0.999999) return
|
|
2787
|
-
if (t < -0.999999) return
|
|
2788
|
-
const n =
|
|
2789
|
-
return
|
|
2790
|
-
}
|
|
2791
|
-
function
|
|
2792
|
-
const
|
|
2793
|
-
for (const
|
|
2794
|
-
const H =
|
|
2795
|
-
|
|
2796
|
-
const
|
|
2797
|
-
if (
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2861
|
+
s.some((o) => o === null) || (e.beginPath(), s.forEach((o, r) => r === 0 ? e.moveTo(o.x, o.y) : e.lineTo(o.x, o.y)), e.closePath(), e.fillStyle = "rgba(0, 0, 0, 0.22)", e.fill());
|
|
2862
|
+
}
|
|
2863
|
+
function vr(e) {
|
|
2864
|
+
const t = J.dot([0, 1, 0], e);
|
|
2865
|
+
if (t > 0.999999) return D.identity();
|
|
2866
|
+
if (t < -0.999999) return D.fromQuat(Ft.fromAxisAngle([1, 0, 0], 180));
|
|
2867
|
+
const n = J.cross([0, 1, 0], e);
|
|
2868
|
+
return D.fromQuat(Ft.fromAxisAngle(n, Math.acos(t) * 180 / Math.PI));
|
|
2869
|
+
}
|
|
2870
|
+
function Tr(e, t, n, s, o) {
|
|
2871
|
+
const r = e.solid ?? {}, l = r.outline === !1 ? void 0 : r.outline ?? { width: 2, color: "#0f172a" }, i = { color: r.color ?? "#475569", shading: r.shading ?? "toon", outline: l }, a = { color: r.skin ?? "#f2c49b", shading: r.shading ?? "toon", outline: l }, h = { color: "#0f172a", shading: "unlit" }, c = s.height * 0.034, u = [], g = (E, H, M) => u.push({ mesh: E, world: D.multiply(o, H), material: M }), f = (E, H, M) => g(t.sphere, D.compose(E, [0, 0, 0, 1], [H, H, H]), M);
|
|
2872
|
+
for (const E of n.chains) {
|
|
2873
|
+
const H = s.chains[E.id], M = E.id === "spine" ? 1.9 : 1;
|
|
2874
|
+
E.bones.forEach((A, w) => {
|
|
2875
|
+
const S = H[w], k = H[w + 1], x = J.distance(S, k), [v, T] = A.width ?? [1, 1], K = c * M * (v + T) / 2;
|
|
2876
|
+
if (x > 1e-6) {
|
|
2877
|
+
const P = J.lerp(S, k, 0.5), I = vr(J.normalize(J.subtract(k, S)));
|
|
2878
|
+
g(t.cylinder, D.multiply(D.translation(P), D.multiply(I, D.scaling([K, x, K]))), i);
|
|
2800
2879
|
}
|
|
2801
|
-
|
|
2802
|
-
}),
|
|
2880
|
+
f(S, c * M * v, i), f(k, c * M * T, i);
|
|
2881
|
+
}), E.id.startsWith("arm.") && f(H[H.length - 1], c * 1.5, a);
|
|
2803
2882
|
}
|
|
2804
|
-
const { center:
|
|
2805
|
-
|
|
2806
|
-
for (const
|
|
2807
|
-
const H =
|
|
2808
|
-
|
|
2883
|
+
const { center: p, rx: d, ry: m, axes: b } = s.head, y = [...b[0], 0, ...b[1], 0, ...b[2], 0, ...p, 1];
|
|
2884
|
+
g(t.sphere, D.multiply(y, D.scaling([d, m, d])), a);
|
|
2885
|
+
for (const E of [-1, 1]) {
|
|
2886
|
+
const H = J.normalize([E * 0.36, 0.15, 0.92]), M = J.add(p, J.add(J.add(J.scale(b[0], H[0] * d * 1.04), J.scale(b[1], H[1] * m * 1.04)), J.scale(b[2], H[2] * d * 1.04))), A = [...b[0], 0, ...b[1], 0, ...b[2], 0, ...M, 1];
|
|
2887
|
+
g(t.sphere, D.multiply(A, D.scaling([d * 0.11, m * 0.14, d * 0.03])), h);
|
|
2809
2888
|
}
|
|
2810
|
-
return
|
|
2889
|
+
return u;
|
|
2811
2890
|
}
|
|
2812
|
-
const
|
|
2891
|
+
const Bi = {
|
|
2813
2892
|
kind: "character",
|
|
2814
2893
|
validate(e) {
|
|
2815
2894
|
const t = e;
|
|
@@ -2817,330 +2896,973 @@ const bs = {
|
|
|
2817
2896
|
},
|
|
2818
2897
|
prepare(e) {
|
|
2819
2898
|
return {
|
|
2820
|
-
who:
|
|
2821
|
-
cylinder:
|
|
2822
|
-
sphere:
|
|
2899
|
+
who: fr({ ...e.character, height: 1 }),
|
|
2900
|
+
cylinder: Rt(ro(1, 1, 16)),
|
|
2901
|
+
sphere: Rt(so(1, 20))
|
|
2823
2902
|
};
|
|
2824
2903
|
},
|
|
2825
|
-
resolve({ object: e, prepared: t, values: n, world:
|
|
2826
|
-
const
|
|
2827
|
-
for (const [
|
|
2828
|
-
typeof
|
|
2829
|
-
const c =
|
|
2830
|
-
toView: (
|
|
2831
|
-
toScreen: (
|
|
2832
|
-
},
|
|
2833
|
-
if (
|
|
2834
|
-
const
|
|
2835
|
-
if (
|
|
2836
|
-
const
|
|
2837
|
-
return { meshes:
|
|
2904
|
+
resolve({ object: e, prepared: t, values: n, world: s, camera: o, toScreen: r }) {
|
|
2905
|
+
const l = e, i = t, a = i.who, h = { ...X, ...l.pose };
|
|
2906
|
+
for (const [m, b] of n)
|
|
2907
|
+
typeof b == "number" && !Er.has(m) && (h[m] = b);
|
|
2908
|
+
const c = l.height ?? Mr, u = D.multiply(o.view, s), g = {
|
|
2909
|
+
toView: (m) => D.transformPoint(u, m),
|
|
2910
|
+
toScreen: (m) => r(m)
|
|
2911
|
+
}, p = -g.toView([0, c / 2, 0])[2];
|
|
2912
|
+
if (p <= o.near) return null;
|
|
2913
|
+
const d = l.shadow === !1 ? [] : [{ depth: p + c, draw: (m) => Hr(m, g, c * 0.18) }];
|
|
2914
|
+
if (l.look === "solid") {
|
|
2915
|
+
const m = Nn(a.plan, h, { height: c, contact: a.contact });
|
|
2916
|
+
return { meshes: Tr(l, i, a.plan, m, s), drawables: d };
|
|
2838
2917
|
}
|
|
2839
2918
|
return {
|
|
2840
2919
|
drawables: [
|
|
2841
|
-
...
|
|
2920
|
+
...d,
|
|
2842
2921
|
{
|
|
2843
|
-
depth:
|
|
2844
|
-
draw(
|
|
2845
|
-
|
|
2922
|
+
depth: p,
|
|
2923
|
+
draw(m, b) {
|
|
2924
|
+
m.lineCap = "round", m.lineJoin = "round", kr(m, a, h, g, { height: c, time: b.time });
|
|
2846
2925
|
}
|
|
2847
2926
|
}
|
|
2848
2927
|
]
|
|
2849
2928
|
};
|
|
2850
2929
|
}
|
|
2851
2930
|
};
|
|
2852
|
-
function
|
|
2853
|
-
const o = n.length ?? 240,
|
|
2854
|
-
e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(
|
|
2931
|
+
function Ar(e, t, n = {}, s) {
|
|
2932
|
+
const o = n.length ?? 240, r = 9, l = 28, i = o - 22;
|
|
2933
|
+
e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(l, -r, i - l, 2 * r), e.fillStyle = "#e8b4a0", e.fillRect(i, -r, o - i, 2 * r), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(l, -r), e.lineTo(l, r), e.closePath(), e.fill(), e.fillStyle = n.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(l * 0.35, -r * 0.35), e.lineTo(l * 0.35, r * 0.35), e.closePath(), e.fill(), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
|
|
2855
2934
|
const a = [
|
|
2856
|
-
[{ x: 0, y: 0 }, { x:
|
|
2857
|
-
[{ x:
|
|
2858
|
-
[{ x:
|
|
2935
|
+
[{ x: 0, y: 0 }, { x: l, y: -r }, { x: o, y: -r }, { x: o, y: r }, { x: l, y: r }, { x: 0, y: 0 }],
|
|
2936
|
+
[{ x: l, y: -r }, { x: l, y: r }],
|
|
2937
|
+
[{ x: i, y: -r }, { x: i, y: r }]
|
|
2859
2938
|
];
|
|
2860
|
-
for (const h of a)
|
|
2939
|
+
for (const h of a) Vn(e, h, s);
|
|
2861
2940
|
e.restore();
|
|
2862
2941
|
}
|
|
2863
|
-
function
|
|
2864
|
-
const o = n.length ?? 90,
|
|
2942
|
+
function Gn(e, t, n = {}, s) {
|
|
2943
|
+
const o = n.length ?? 90, r = n.thickness ?? 34;
|
|
2865
2944
|
e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -35) * Math.PI / 180);
|
|
2866
|
-
const
|
|
2867
|
-
e.fillStyle = n.color ?? "#f4a7b9", e.fillRect(0,
|
|
2868
|
-
const
|
|
2869
|
-
{ x: 0, y:
|
|
2870
|
-
{ x: o, y:
|
|
2871
|
-
{ x: o, y: -
|
|
2872
|
-
{ x: 0, y: -
|
|
2873
|
-
{ x: 0, y:
|
|
2874
|
-
], a = [{ x: o * 0.45, y:
|
|
2875
|
-
if (
|
|
2876
|
-
|
|
2945
|
+
const l = -r / 2;
|
|
2946
|
+
e.fillStyle = n.color ?? "#f4a7b9", e.fillRect(0, l, o, r), e.fillStyle = "#e9edf2", e.fillRect(o * 0.45, l, o * 0.55, r), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
|
|
2947
|
+
const i = [
|
|
2948
|
+
{ x: 0, y: l },
|
|
2949
|
+
{ x: o, y: l },
|
|
2950
|
+
{ x: o, y: -l },
|
|
2951
|
+
{ x: 0, y: -l },
|
|
2952
|
+
{ x: 0, y: l }
|
|
2953
|
+
], a = [{ x: o * 0.45, y: l }, { x: o * 0.45, y: -l }];
|
|
2954
|
+
if (s)
|
|
2955
|
+
s.line(i), s.line(a);
|
|
2877
2956
|
else
|
|
2878
|
-
for (const h of [
|
|
2957
|
+
for (const h of [i, a]) {
|
|
2879
2958
|
e.beginPath(), e.moveTo(h[0].x, h[0].y);
|
|
2880
2959
|
for (const c of h.slice(1)) e.lineTo(c.x, c.y);
|
|
2881
2960
|
e.stroke();
|
|
2882
2961
|
}
|
|
2883
2962
|
e.restore();
|
|
2884
2963
|
}
|
|
2885
|
-
const
|
|
2886
|
-
function
|
|
2887
|
-
const o = n.tool ?? "pencil",
|
|
2888
|
-
a > 0 && (e.save(), e.fillStyle =
|
|
2889
|
-
const
|
|
2890
|
-
const
|
|
2891
|
-
return { pinch:
|
|
2892
|
-
},
|
|
2893
|
-
|
|
2894
|
-
size:
|
|
2895
|
-
angle:
|
|
2896
|
-
skin:
|
|
2897
|
-
ink:
|
|
2898
|
-
lineWidth: 3 *
|
|
2964
|
+
const Un = 150, xr = { pencil: 44, eraser: 30 };
|
|
2965
|
+
function zn(e, t, n = {}, s) {
|
|
2966
|
+
const o = n.tool ?? "pencil", r = n.skin ?? "#f1c9a5", l = n.outline ?? "#2f2f33", i = n.scale ?? 1, a = Math.min(1, Math.max(0, n.lift ?? 0)), h = (n.angle ?? -30) * Math.PI / 180, c = s ? s.nudge(0.6) : { x: 0, y: 0 }, u = Un * i * (1 + 0.05 * a);
|
|
2967
|
+
a > 0 && (e.save(), e.fillStyle = l, e.globalAlpha = 0.15 * a, e.beginPath(), e.ellipse(t.x, t.y, 9 * i, 4 * i, 0, 0, Math.PI * 2), e.fill(), e.restore());
|
|
2968
|
+
const g = { x: t.x + c.x + 6 * a * i, y: t.y + c.y - 18 * a * i }, f = C.pencilGrip, p = (w) => {
|
|
2969
|
+
const S = w.fingers.thumb, k = w.fingers.index, x = w.fingers.middle, v = sn([S.points[3], k.points[3], x.points[3]]), T = sn([S.points[1], k.points[0]]), K = (S.depths[3] + k.depths[3] + x.depths[3]) / 3;
|
|
2970
|
+
return { pinch: v, direction: Math.atan2(T.y - v.y, T.x - v.x), depth: K };
|
|
2971
|
+
}, d = pt(f, { size: u }), m = h - p(d).direction, b = pt(f, { size: u, angle: m * 180 / Math.PI }), y = p(b), E = xr[o] * i, H = { x: y.pinch.x - Math.cos(h) * E, y: y.pinch.y - Math.sin(h) * E }, M = { x: g.x - H.x, y: g.y - H.y }, A = b.axes.up;
|
|
2972
|
+
Kr(e, M, { x: -A.x, y: -A.y }, u, n.arm ?? 300 * i, r, n.sleeve ?? "#5b7db1", l), Tt(e, M, f, {
|
|
2973
|
+
size: u,
|
|
2974
|
+
angle: m * 180 / Math.PI,
|
|
2975
|
+
skin: r,
|
|
2976
|
+
ink: l,
|
|
2977
|
+
lineWidth: 3 * i,
|
|
2899
2978
|
prop: {
|
|
2900
|
-
depth:
|
|
2979
|
+
depth: y.depth,
|
|
2901
2980
|
draw: () => {
|
|
2902
|
-
e.save(), e.translate(
|
|
2981
|
+
e.save(), e.translate(g.x, g.y), e.scale(i, i), o === "eraser" ? Gn(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, outline: l }, s) : Ar(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, length: 190, outline: l }, s), e.restore();
|
|
2903
2982
|
}
|
|
2904
2983
|
}
|
|
2905
2984
|
});
|
|
2906
2985
|
}
|
|
2907
|
-
const
|
|
2986
|
+
const sn = (e) => ({
|
|
2908
2987
|
x: e.reduce((t, n) => t + n.x, 0) / e.length,
|
|
2909
2988
|
y: e.reduce((t, n) => t + n.y, 0) / e.length
|
|
2910
2989
|
});
|
|
2911
|
-
function
|
|
2912
|
-
const a = { x: -n.y, y: n.x }, h =
|
|
2913
|
-
x: t.x + n.x *
|
|
2914
|
-
y: t.y + n.y *
|
|
2915
|
-
}),
|
|
2916
|
-
const
|
|
2917
|
-
return
|
|
2918
|
-
},
|
|
2919
|
-
e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (
|
|
2920
|
-
const
|
|
2921
|
-
e.beginPath(),
|
|
2922
|
-
}
|
|
2923
|
-
function
|
|
2924
|
-
const
|
|
2925
|
-
const
|
|
2926
|
-
return
|
|
2927
|
-
}, c = (
|
|
2928
|
-
if (
|
|
2929
|
-
const
|
|
2930
|
-
return { at:
|
|
2931
|
-
}
|
|
2932
|
-
const
|
|
2933
|
-
if (
|
|
2934
|
-
const
|
|
2935
|
-
return { at: c(
|
|
2936
|
-
}
|
|
2937
|
-
if (
|
|
2938
|
-
const
|
|
2939
|
-
return { at: c(
|
|
2940
|
-
}
|
|
2941
|
-
if (
|
|
2942
|
-
const
|
|
2943
|
-
return { at: c(
|
|
2990
|
+
function Kr(e, t, n, s, o, r, l, i) {
|
|
2991
|
+
const a = { x: -n.y, y: n.x }, h = s * 0.15, c = (d, m, b) => ({
|
|
2992
|
+
x: t.x + n.x * d + a.x * m * b,
|
|
2993
|
+
y: t.y + n.y * d + a.y * m * b
|
|
2994
|
+
}), u = c(o, 0, 0), g = (d) => {
|
|
2995
|
+
const m = e.createLinearGradient(t.x, t.y, u.x, u.y);
|
|
2996
|
+
return m.addColorStop(0, d), m.addColorStop(0.6, d), m.addColorStop(1, Pr(d)), m;
|
|
2997
|
+
}, f = Math.min(s * 0.55, o * 0.35);
|
|
2998
|
+
e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (s / Un), e.beginPath(), e.moveTo(c(-s * 0.1, -1, h).x, c(-s * 0.1, -1, h).y), e.lineTo(c(f + 4, -1, h * 1.1).x, c(f + 4, -1, h * 1.1).y), e.lineTo(c(f + 4, 1, h * 1.1).x, c(f + 4, 1, h * 1.1).y), e.lineTo(c(-s * 0.1, 1, h).x, c(-s * 0.1, 1, h).y), e.closePath(), e.fillStyle = r, e.fill(), e.strokeStyle = i, e.beginPath(), e.moveTo(c(0, -1, h).x, c(0, -1, h).y), e.lineTo(c(f, -1, h * 1.1).x, c(f, -1, h * 1.1).y), e.moveTo(c(0, 1, h).x, c(0, 1, h).y), e.lineTo(c(f, 1, h * 1.1).x, c(f, 1, h * 1.1).y), e.stroke();
|
|
2999
|
+
const p = [c(f, -1, h * 1.3), c(o, -1, h * 1.5), c(o, 1, h * 1.5), c(f, 1, h * 1.3)];
|
|
3000
|
+
e.beginPath(), p.forEach((d, m) => m ? e.lineTo(d.x, d.y) : e.moveTo(d.x, d.y)), e.closePath(), e.fillStyle = g(l), e.fill(), e.strokeStyle = g(i), e.beginPath(), e.moveTo(p[1].x, p[1].y), e.lineTo(p[0].x, p[0].y), e.lineTo(p[3].x, p[3].y), e.lineTo(p[2].x, p[2].y), e.stroke(), e.restore();
|
|
3001
|
+
}
|
|
3002
|
+
function Fi(e, t, n = {}) {
|
|
3003
|
+
const s = n.offstage ?? { x: 2e3, y: 1400 }, o = n.enter ?? 450, r = n.exit ?? 450, l = n.linger ?? 1500, i = [...e].filter((d) => d.path.length > 0).sort((d, m) => d.start - m.start), a = (d) => d.tool ?? "pencil", h = (d) => {
|
|
3004
|
+
const m = Math.min(1, Math.max(0, d));
|
|
3005
|
+
return m * m * (3 - 2 * m);
|
|
3006
|
+
}, c = (d, m, b) => ({ x: d.x + (m.x - d.x) * b, y: d.y + (m.y - d.y) * b }), u = i.find((d) => t >= d.start && t <= d.end);
|
|
3007
|
+
if (u) {
|
|
3008
|
+
const d = u.end - u.start, m = d > 0 ? (t - u.start) / d : 1;
|
|
3009
|
+
return { at: Ht(u.path, m), tool: a(u), lift: 0, drawing: !0 };
|
|
3010
|
+
}
|
|
3011
|
+
const g = [...i].reverse().find((d) => d.end < t), f = i.find((d) => d.start > t), p = (d) => d.path[d.path.length - 1];
|
|
3012
|
+
if (g && f && f.start - g.end <= l) {
|
|
3013
|
+
const d = (t - g.end) / (f.start - g.end), m = d < 0.5 ? a(g) : a(f);
|
|
3014
|
+
return { at: c(p(g), f.path[0], h(d)), tool: m, lift: Math.sin(Math.PI * d), drawing: !1 };
|
|
3015
|
+
}
|
|
3016
|
+
if (f && f.start - t <= o) {
|
|
3017
|
+
const d = 1 - (f.start - t) / o;
|
|
3018
|
+
return { at: c(s, f.path[0], h(d)), tool: a(f), lift: 1 - h(d), drawing: !1 };
|
|
3019
|
+
}
|
|
3020
|
+
if (g && t - g.end <= r) {
|
|
3021
|
+
const d = (t - g.end) / r;
|
|
3022
|
+
return { at: c(p(g), s, h(d)), tool: a(g), lift: h(d), drawing: !1 };
|
|
2944
3023
|
}
|
|
2945
3024
|
return null;
|
|
2946
3025
|
}
|
|
2947
|
-
function
|
|
2948
|
-
const
|
|
2949
|
-
for (let
|
|
2950
|
-
const a = -Math.PI / 2 +
|
|
2951
|
-
|
|
3026
|
+
function Ri(e, t, n, s = 0.08, o = 32) {
|
|
3027
|
+
const r = Math.PI * 2 * (1 + s), l = [];
|
|
3028
|
+
for (let i = 0; i <= o; i++) {
|
|
3029
|
+
const a = -Math.PI / 2 + r * i / o;
|
|
3030
|
+
l.push({ x: e + Math.cos(a) * n, y: t + Math.sin(a) * n });
|
|
2952
3031
|
}
|
|
2953
|
-
return
|
|
3032
|
+
return l;
|
|
2954
3033
|
}
|
|
2955
|
-
function
|
|
2956
|
-
const { path: t } = e, n = t.map((
|
|
3034
|
+
function Li(e) {
|
|
3035
|
+
const { path: t } = e, n = t.map((i) => i.x), s = t.map((i) => i.y), o = Math.min(...n), r = Math.min(...s), l = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
|
|
2957
3036
|
return {
|
|
2958
3037
|
type: "custom",
|
|
2959
3038
|
x: o,
|
|
2960
|
-
y:
|
|
3039
|
+
y: r,
|
|
2961
3040
|
width: Math.max(1, Math.max(...n) - o),
|
|
2962
|
-
height: Math.max(1, Math.max(...
|
|
3041
|
+
height: Math.max(1, Math.max(...s) - r),
|
|
2963
3042
|
props: { draw: 0 },
|
|
2964
|
-
draw(
|
|
3043
|
+
draw(i, a, h) {
|
|
2965
3044
|
const c = Math.min(1, Math.max(0, Number(a.props?.draw ?? 0)));
|
|
2966
|
-
|
|
2967
|
-
const
|
|
2968
|
-
c > 0 && (
|
|
3045
|
+
i.translate(-o, -r), i.strokeStyle = e.color ?? "#2f2f33", i.lineWidth = e.lineWidth ?? 5, i.lineCap = "round", i.lineJoin = "round";
|
|
3046
|
+
const u = e.sketch ? ut(i, e.sketch, h) : void 0;
|
|
3047
|
+
c > 0 && (u ? e.smooth ? u.curve(t, c) : u.line(t, c) : Vn(i, mn(t, c))), l && c > 0 && c < 1 && zn(i, Ht(t, c), l, u);
|
|
2969
3048
|
}
|
|
2970
3049
|
};
|
|
2971
3050
|
}
|
|
2972
|
-
function
|
|
3051
|
+
function Pr(e) {
|
|
2973
3052
|
const t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
|
|
2974
3053
|
if (!t) return "rgba(0, 0, 0, 0)";
|
|
2975
|
-
const n = t[1].length === 3 ? [...t[1]].map((
|
|
2976
|
-
return `rgba(${
|
|
3054
|
+
const n = t[1].length === 3 ? [...t[1]].map((l) => l + l).join("") : t[1], [s, o, r] = [0, 2, 4].map((l) => parseInt(n.slice(l, l + 2), 16));
|
|
3055
|
+
return `rgba(${s}, ${o}, ${r}, 0)`;
|
|
2977
3056
|
}
|
|
2978
|
-
function
|
|
3057
|
+
function Vn(e, t, n) {
|
|
2979
3058
|
if (!(t.length < 2)) {
|
|
2980
3059
|
if (n) return n.line(t);
|
|
2981
3060
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
2982
|
-
for (const
|
|
3061
|
+
for (const s of t.slice(1)) e.lineTo(s.x, s.y);
|
|
2983
3062
|
e.stroke();
|
|
2984
3063
|
}
|
|
2985
3064
|
}
|
|
2986
|
-
const
|
|
2987
|
-
function
|
|
2988
|
-
const
|
|
2989
|
-
for (let
|
|
2990
|
-
|
|
2991
|
-
return
|
|
3065
|
+
const Re = 1e5;
|
|
3066
|
+
function Ni(e, t, n, s, o = 6) {
|
|
3067
|
+
const r = [], l = Math.max(1, Math.round(o));
|
|
3068
|
+
for (let i = 0; i <= l; i++)
|
|
3069
|
+
r.push({ x: i % 2 === 0 ? e : e + n, y: t + s * i / l });
|
|
3070
|
+
return r;
|
|
2992
3071
|
}
|
|
2993
|
-
function
|
|
2994
|
-
if (
|
|
2995
|
-
const o =
|
|
2996
|
-
e.beginPath(), e.rect(-
|
|
3072
|
+
function jn(e, t, n, s) {
|
|
3073
|
+
if (s <= 0 || t.length === 0) return;
|
|
3074
|
+
const o = mn(t, s), r = n / 2, l = (i) => {
|
|
3075
|
+
e.beginPath(), e.rect(-Re, -Re, 2 * Re, 2 * Re), i(), e.clip("evenodd");
|
|
2997
3076
|
};
|
|
2998
|
-
for (const
|
|
2999
|
-
|
|
3000
|
-
e.moveTo(
|
|
3077
|
+
for (const i of o)
|
|
3078
|
+
l(() => {
|
|
3079
|
+
e.moveTo(i.x + r, i.y), e.arc(i.x, i.y, r, 0, Math.PI * 2);
|
|
3001
3080
|
});
|
|
3002
|
-
for (let
|
|
3003
|
-
const a = o[
|
|
3081
|
+
for (let i = 1; i < o.length; i++) {
|
|
3082
|
+
const a = o[i - 1], h = o[i], c = Math.hypot(h.x - a.x, h.y - a.y);
|
|
3004
3083
|
if (c === 0) continue;
|
|
3005
|
-
const
|
|
3006
|
-
|
|
3007
|
-
e.moveTo(a.x +
|
|
3084
|
+
const u = -(h.y - a.y) / c * r, g = (h.x - a.x) / c * r;
|
|
3085
|
+
l(() => {
|
|
3086
|
+
e.moveTo(a.x + u, a.y + g), e.lineTo(h.x + u, h.y + g), e.lineTo(h.x - u, h.y - g), e.lineTo(a.x - u, a.y - g), e.closePath();
|
|
3008
3087
|
});
|
|
3009
3088
|
}
|
|
3010
3089
|
}
|
|
3011
|
-
function
|
|
3012
|
-
e.save(),
|
|
3090
|
+
function Yi(e, t, n, s, o) {
|
|
3091
|
+
e.save(), jn(e, t, n, s), o(), e.restore();
|
|
3013
3092
|
}
|
|
3014
|
-
function
|
|
3015
|
-
const n = t.width ?? 40,
|
|
3093
|
+
function Ci(e, t) {
|
|
3094
|
+
const n = t.width ?? 40, s = t.hand === !0 ? {} : t.hand || void 0, o = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
|
|
3016
3095
|
return {
|
|
3017
3096
|
...e,
|
|
3018
3097
|
props: { ...e.props, erase: 0 },
|
|
3019
|
-
draw(
|
|
3020
|
-
const a = Number(
|
|
3021
|
-
if (
|
|
3022
|
-
const h =
|
|
3023
|
-
|
|
3098
|
+
draw(r, l, i) {
|
|
3099
|
+
const a = Number(l.props?.erase ?? 0);
|
|
3100
|
+
if (r.save(), jn(r, t.path, n, a), e.draw(r, l, i), r.restore(), !o || a <= 0 || a >= 1) return;
|
|
3101
|
+
const h = Ht(t.path, a);
|
|
3102
|
+
s ? zn(r, h, { ...s, tool: "eraser" }) : Gn(r, h, o);
|
|
3024
3103
|
}
|
|
3025
3104
|
};
|
|
3026
3105
|
}
|
|
3027
|
-
const
|
|
3028
|
-
function
|
|
3029
|
-
const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b",
|
|
3030
|
-
const c =
|
|
3031
|
-
a.shape(
|
|
3032
|
-
},
|
|
3033
|
-
const h =
|
|
3034
|
-
a.shape(
|
|
3035
|
-
},
|
|
3036
|
-
const c =
|
|
3037
|
-
a.shape(
|
|
3038
|
-
const
|
|
3039
|
-
a.line(H.slice(1),
|
|
3106
|
+
const Wr = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
|
|
3107
|
+
function Di(e = {}) {
|
|
3108
|
+
const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b", s = (i) => i.lineWidth * 0.45, o = (i, a, h) => {
|
|
3109
|
+
const c = i.parts[`leg.${h}`].points;
|
|
3110
|
+
a.shape(Ye(c, i.height * 0.08, i.height * 0.05), n, s(i));
|
|
3111
|
+
}, r = (i, a) => {
|
|
3112
|
+
const h = i.chains.spine, c = h[0], u = h[h.length - 1], g = { x: c.x - (u.x - c.x) * 0.25, y: c.y - (u.y - c.y) * 0.25 };
|
|
3113
|
+
a.shape(Ye([g, ...i.parts.spine.points], i.height * 0.15, i.height * 0.14), t, s(i));
|
|
3114
|
+
}, l = (i, a, h) => {
|
|
3115
|
+
const c = i.parts[`arm.${h}`].points, u = c[0], g = i.chains.spine[i.chains.spine.length - 1], p = [{ x: u.x + (g.x - u.x) * 0.45, y: u.y + (g.y - u.y) * 0.45 }, ...Wr(c, 0, 0.45)], d = Ye(p, i.height * 0.085, i.height * 0.06), m = p.length, b = d.slice(0, m), y = d.slice(m).reverse();
|
|
3116
|
+
a.shape(d, t, 0);
|
|
3117
|
+
const E = (A) => Math.hypot(A[1].x - g.x, A[1].y - g.y), [H, M] = E(b) > E(y) ? [b, y] : [y, b];
|
|
3118
|
+
a.line(H.slice(1), s(i)), a.line(M.slice(Math.ceil(m * 0.45)), s(i)), a.line([b[m - 1], y[m - 1]], s(i));
|
|
3040
3119
|
};
|
|
3041
3120
|
return {
|
|
3042
3121
|
parts: {
|
|
3043
|
-
"leg.left": { over: (
|
|
3044
|
-
"leg.right": { over: (
|
|
3045
|
-
spine: { over: (
|
|
3046
|
-
"arm.left": { over: (
|
|
3047
|
-
"arm.right": { over: (
|
|
3122
|
+
"leg.left": { over: (i, a, h) => o(a, h, "left") },
|
|
3123
|
+
"leg.right": { over: (i, a, h) => o(a, h, "right") },
|
|
3124
|
+
spine: { over: (i, a, h) => r(a, h) },
|
|
3125
|
+
"arm.left": { over: (i, a, h) => l(a, h, "left") },
|
|
3126
|
+
"arm.right": { over: (i, a, h) => l(a, h, "right") }
|
|
3127
|
+
}
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3130
|
+
const ht = {
|
|
3131
|
+
full: {
|
|
3132
|
+
anticipation: 0.12,
|
|
3133
|
+
anticipationTime: 0.3,
|
|
3134
|
+
hold: 0,
|
|
3135
|
+
overshoot: 0.08,
|
|
3136
|
+
settle: 220,
|
|
3137
|
+
settleEase: "ease-in-out",
|
|
3138
|
+
actionEase: "ease-in-out-cubic",
|
|
3139
|
+
overlap: 45,
|
|
3140
|
+
eyeLead: 120,
|
|
3141
|
+
eyeDart: 160,
|
|
3142
|
+
drift: 0.12,
|
|
3143
|
+
blinks: !0,
|
|
3144
|
+
jumpSquash: 1
|
|
3145
|
+
},
|
|
3146
|
+
snappy: {
|
|
3147
|
+
anticipation: 0.2,
|
|
3148
|
+
anticipationTime: 0.35,
|
|
3149
|
+
hold: 0.12,
|
|
3150
|
+
overshoot: 0.12,
|
|
3151
|
+
settle: 320,
|
|
3152
|
+
settleEase: { type: "elastic", mode: "out", amplitude: 1, period: 0.35 },
|
|
3153
|
+
actionEase: "ease-out-cubic",
|
|
3154
|
+
overlap: 35,
|
|
3155
|
+
eyeLead: 100,
|
|
3156
|
+
eyeDart: 100,
|
|
3157
|
+
drift: 0.1,
|
|
3158
|
+
blinks: !0,
|
|
3159
|
+
jumpSquash: 1.3
|
|
3160
|
+
},
|
|
3161
|
+
limited: {
|
|
3162
|
+
anticipation: 0.06,
|
|
3163
|
+
anticipationTime: 0.25,
|
|
3164
|
+
hold: 0,
|
|
3165
|
+
overshoot: 0,
|
|
3166
|
+
settle: 0,
|
|
3167
|
+
settleEase: "ease-out",
|
|
3168
|
+
actionEase: "ease-in-out",
|
|
3169
|
+
overlap: 30,
|
|
3170
|
+
eyeLead: 80,
|
|
3171
|
+
eyeDart: 120,
|
|
3172
|
+
drift: 0,
|
|
3173
|
+
blinks: !0,
|
|
3174
|
+
jumpSquash: 0.6
|
|
3175
|
+
},
|
|
3176
|
+
none: {
|
|
3177
|
+
anticipation: 0,
|
|
3178
|
+
anticipationTime: 0,
|
|
3179
|
+
hold: 0,
|
|
3180
|
+
overshoot: 0,
|
|
3181
|
+
settle: 0,
|
|
3182
|
+
settleEase: "linear",
|
|
3183
|
+
actionEase: "linear",
|
|
3184
|
+
overlap: 0,
|
|
3185
|
+
eyeLead: 0,
|
|
3186
|
+
eyeDart: 0,
|
|
3187
|
+
drift: 0,
|
|
3188
|
+
blinks: !1,
|
|
3189
|
+
jumpSquash: 0
|
|
3190
|
+
}
|
|
3191
|
+
};
|
|
3192
|
+
function Or(e) {
|
|
3193
|
+
if (e === void 0) return ht.full;
|
|
3194
|
+
if (typeof e == "string") return ht[e];
|
|
3195
|
+
const { base: t, ...n } = e;
|
|
3196
|
+
return { ...ht[t ?? "full"], ...n };
|
|
3197
|
+
}
|
|
3198
|
+
const Mt = 160, Ir = 120, _r = 700, ct = 60, $r = 90, Le = 3200, ye = 1, ue = 1e-6;
|
|
3199
|
+
function Jn(e, t, n = {}) {
|
|
3200
|
+
const s = Or(n.style), o = n.seed ?? 1, r = {};
|
|
3201
|
+
if (e.length === 0) return r;
|
|
3202
|
+
const l = Object.keys(e[0].pose).filter((u) => e.some((g) => Math.abs(g.pose[u] - e[0].pose[u]) > ue));
|
|
3203
|
+
for (const u of l) r[u] = Br(u, e, t, s, o);
|
|
3204
|
+
const i = t.blink, a = i !== void 0 && l.includes(i);
|
|
3205
|
+
if (s.blinks && i !== void 0 && !a && i in e[0].pose) {
|
|
3206
|
+
const u = Fr(e, t, s, o, e[0].pose[i]);
|
|
3207
|
+
u.length > 0 && (r[i] = u);
|
|
3208
|
+
}
|
|
3209
|
+
const { lift: h, stretch: c } = t;
|
|
3210
|
+
if (s.jumpSquash > 0 && h && c && l.includes(h) && !l.includes(c) && c in e[0].pose) {
|
|
3211
|
+
const u = Rr(e, h, e[0].pose[c], s.jumpSquash);
|
|
3212
|
+
u.length > 0 && (r[c] = u);
|
|
3213
|
+
}
|
|
3214
|
+
return r;
|
|
3215
|
+
}
|
|
3216
|
+
function Br(e, t, n, s, o) {
|
|
3217
|
+
const r = n.eyes.includes(e), l = n.limits[e], i = l !== void 0, a = r ? -s.eyeLead : (n.depth[e] ?? 1) * s.overlap, h = (f) => {
|
|
3218
|
+
const p = (t[f].time - t[f - 1].time) / 2;
|
|
3219
|
+
return Math.max(-p, Math.min(p, a));
|
|
3220
|
+
}, c = [{ time: t[0].time, value: t[0].pose[e] }], u = (f, p, d) => {
|
|
3221
|
+
const m = c[c.length - 1];
|
|
3222
|
+
if (f <= m.time + ye) {
|
|
3223
|
+
c[c.length - 1] = { ...m, value: p, ...d ? { easing: d } : {} };
|
|
3224
|
+
return;
|
|
3225
|
+
}
|
|
3226
|
+
c.push({ time: f, value: p, ...d ? { easing: d } : {} });
|
|
3227
|
+
};
|
|
3228
|
+
let g = t[0].pose[e];
|
|
3229
|
+
for (let f = 1; f < t.length; f++) {
|
|
3230
|
+
const p = t[f], d = t[f - 1].pose[e], m = p.pose[e], b = m - d, y = c[c.length - 1].time, E = p.act !== !1;
|
|
3231
|
+
if (Math.abs(b) <= ue) {
|
|
3232
|
+
const v = p.time + (E ? h(f) : 0);
|
|
3233
|
+
if (f === t.length - 1)
|
|
3234
|
+
Math.abs(g - m) > ue && u(Math.max(v, y + Mt), m, "ease-in-out"), g = m;
|
|
3235
|
+
else if (E && i && s.drift > 0 && n.drift.includes(e) && v - y >= _r) {
|
|
3236
|
+
const T = Ze(`${o}:${e}:${f}`) % 2 === 0 ? 1 : -1;
|
|
3237
|
+
g = m + T * s.drift * l, u(v, g, "ease-in-out");
|
|
3238
|
+
}
|
|
3239
|
+
continue;
|
|
3240
|
+
}
|
|
3241
|
+
if (!E) {
|
|
3242
|
+
u(t[f - 1].time, g), u(p.time, m, p.easing), g = m;
|
|
3243
|
+
continue;
|
|
3244
|
+
}
|
|
3245
|
+
const H = h(f), M = Math.max(t[f - 1].time + H, y);
|
|
3246
|
+
let A = p.time + H;
|
|
3247
|
+
r && s.eyeDart > 0 && (A = Math.min(A, M + s.eyeDart));
|
|
3248
|
+
const w = A - M;
|
|
3249
|
+
if (w <= ye) {
|
|
3250
|
+
u(p.time, m, p.easing), g = m;
|
|
3251
|
+
continue;
|
|
3048
3252
|
}
|
|
3253
|
+
u(M, g);
|
|
3254
|
+
const S = Math.sign(b);
|
|
3255
|
+
if (i && s.anticipation > 0 && l > 0 && w >= Mt) {
|
|
3256
|
+
const v = g - S * Math.min(Math.abs(b) * s.anticipation, l), T = M + w * s.anticipationTime;
|
|
3257
|
+
u(T, v, "ease-in-out"), s.hold > 0 && u(T + w * s.hold, v);
|
|
3258
|
+
}
|
|
3259
|
+
const k = f + 1 < t.length ? t[f + 1].time - p.time : 1 / 0, x = Math.min(s.settle, k / 2);
|
|
3260
|
+
if (i && s.overshoot > 0 && l > 0 && w >= Ir && x > ye) {
|
|
3261
|
+
const v = Math.min(Math.abs(b) * s.overshoot, l);
|
|
3262
|
+
u(A, m + S * v, p.easing ?? s.actionEase), u(A + x, m, s.settleEase);
|
|
3263
|
+
} else
|
|
3264
|
+
u(A, m, p.easing ?? s.actionEase);
|
|
3265
|
+
g = m;
|
|
3266
|
+
}
|
|
3267
|
+
return c;
|
|
3268
|
+
}
|
|
3269
|
+
function Fr(e, t, n, s, o) {
|
|
3270
|
+
const r = [], l = ct + $r;
|
|
3271
|
+
for (let f = 1; f < e.length; f++) {
|
|
3272
|
+
const p = e[f - 1].pose, d = e[f].pose;
|
|
3273
|
+
Object.entries(t.headTurns).some(([b, y]) => Math.abs((d[b] ?? 0) - (p[b] ?? 0)) > y) && e[f].act !== !1 && r.push(Math.max(e[0].time, e[f - 1].time - n.eyeLead));
|
|
3274
|
+
}
|
|
3275
|
+
const i = e[0].time, a = e[e.length - 1].time, h = [...r];
|
|
3276
|
+
let c = i + Le * 0.6, u = 0;
|
|
3277
|
+
for (; c < a; ) {
|
|
3278
|
+
h.some((d) => Math.abs(d - c) < Le / 2) || r.push(c);
|
|
3279
|
+
const p = (Ze(`${s}:blink:${u++}`) % 1e3 / 1e3 - 0.5) * (Le * 0.66);
|
|
3280
|
+
c += Le + p;
|
|
3281
|
+
}
|
|
3282
|
+
r.sort((f, p) => f - p);
|
|
3283
|
+
const g = [{ time: i, value: o }];
|
|
3284
|
+
for (const f of r) {
|
|
3285
|
+
const p = g[g.length - 1].time;
|
|
3286
|
+
f + ct <= p + ye || (f > p + ye && g.push({ time: f, value: o }), g.push({ time: f + ct, value: 1, easing: "ease-in" }), g.push({ time: f + l, value: o, easing: "ease-out" }));
|
|
3287
|
+
}
|
|
3288
|
+
return g.length > 1 ? g : [];
|
|
3289
|
+
}
|
|
3290
|
+
function Rr(e, t, n, s) {
|
|
3291
|
+
const o = n * (1 - 0.18 * s), r = n * (1 + 0.14 * s), l = [{ time: e[0].time, value: n }], i = (a, h, c) => {
|
|
3292
|
+
const u = l[l.length - 1];
|
|
3293
|
+
a <= u.time + ye || l.push({ time: a, value: h, ...c ? { easing: c } : {} });
|
|
3049
3294
|
};
|
|
3295
|
+
for (let a = 1; a < e.length; a++) {
|
|
3296
|
+
const h = e[a - 1].pose[t], c = e[a].pose[t], u = e[a - 1].time, g = e[a].time, f = g - u;
|
|
3297
|
+
if (!(f < Mt || e[a].act === !1)) {
|
|
3298
|
+
if (h <= ue && c > ue)
|
|
3299
|
+
i(u, n), i(u + f * 0.2, o, "ease-out"), i(u + f * 0.45, r, "ease-out"), i(g, n, "ease-in-out");
|
|
3300
|
+
else if (h > ue && c <= ue) {
|
|
3301
|
+
const p = a + 1 < e.length ? e[a + 1].time - g : 400;
|
|
3302
|
+
i(u + f * 0.5, n), i(g - Math.min(60, f * 0.15), r, "ease-in"), i(g, o, "ease-out"), i(g + Math.min(260, p / 2), n, { type: "back", mode: "out", overshoot: 1.4 });
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
return l.length > 1 ? l : [];
|
|
3307
|
+
}
|
|
3308
|
+
const Lr = {
|
|
3309
|
+
depth: {
|
|
3310
|
+
lean: 0,
|
|
3311
|
+
bend: 0,
|
|
3312
|
+
rise: 0,
|
|
3313
|
+
sit: 0,
|
|
3314
|
+
spin: 0,
|
|
3315
|
+
stretch: 0,
|
|
3316
|
+
turn: 0,
|
|
3317
|
+
leftHip: 0,
|
|
3318
|
+
rightHip: 0,
|
|
3319
|
+
headTilt: 1,
|
|
3320
|
+
leftShoulder: 1,
|
|
3321
|
+
rightShoulder: 1,
|
|
3322
|
+
leftKnee: 1,
|
|
3323
|
+
rightKnee: 1,
|
|
3324
|
+
leftBrow: 1,
|
|
3325
|
+
rightBrow: 1,
|
|
3326
|
+
browTilt: 1,
|
|
3327
|
+
leftEye: 1,
|
|
3328
|
+
rightEye: 1,
|
|
3329
|
+
leftElbow: 2,
|
|
3330
|
+
rightElbow: 2,
|
|
3331
|
+
leftAnkle: 2,
|
|
3332
|
+
rightAnkle: 2,
|
|
3333
|
+
leftFootOut: 2,
|
|
3334
|
+
rightFootOut: 2,
|
|
3335
|
+
mouth: 2,
|
|
3336
|
+
smile: 2,
|
|
3337
|
+
mouthWidth: 2,
|
|
3338
|
+
leftWrist: 3,
|
|
3339
|
+
rightWrist: 3
|
|
3340
|
+
},
|
|
3341
|
+
limits: {
|
|
3342
|
+
lean: 10,
|
|
3343
|
+
bend: 10,
|
|
3344
|
+
headTilt: 12,
|
|
3345
|
+
spin: 25,
|
|
3346
|
+
turn: 0.06,
|
|
3347
|
+
sit: 0.06,
|
|
3348
|
+
stretch: 0.08,
|
|
3349
|
+
rise: 0,
|
|
3350
|
+
leftShoulder: 20,
|
|
3351
|
+
rightShoulder: 20,
|
|
3352
|
+
leftElbow: 18,
|
|
3353
|
+
rightElbow: 18,
|
|
3354
|
+
leftWrist: 15,
|
|
3355
|
+
rightWrist: 15,
|
|
3356
|
+
leftHip: 12,
|
|
3357
|
+
rightHip: 12,
|
|
3358
|
+
leftKnee: 15,
|
|
3359
|
+
rightKnee: 15,
|
|
3360
|
+
leftAnkle: 10,
|
|
3361
|
+
rightAnkle: 10,
|
|
3362
|
+
leftBrow: 0.25,
|
|
3363
|
+
rightBrow: 0.25,
|
|
3364
|
+
leftEye: 0.15,
|
|
3365
|
+
rightEye: 0.15
|
|
3366
|
+
},
|
|
3367
|
+
eyes: ["lookX", "lookY"],
|
|
3368
|
+
blink: "blink",
|
|
3369
|
+
headTurns: { turn: 0.15, headTilt: 8, lookX: 0.5, spin: 45 },
|
|
3370
|
+
drift: ["lean", "bend", "headTilt", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow"],
|
|
3371
|
+
lift: "rise",
|
|
3372
|
+
stretch: "stretch"
|
|
3373
|
+
};
|
|
3374
|
+
function Nr(e) {
|
|
3375
|
+
return /^(turn|lean|side|lift|roll|stretch)$/.test(e) ? { depth: 0, limit: { turn: 0.06, lean: 10, side: 8, lift: 0, roll: 25, stretch: 0.08 }[e] } : /^leg\.\w+\.(swing|spread|rotate)$/.test(e) ? { depth: 0, limit: 12 } : /^head\./.test(e) ? { depth: 1, limit: 12 } : /^arm\.\w+\.(swing|spread)$/.test(e) ? { depth: 1, limit: 20 } : /^leg\.\w+\.knee$/.test(e) ? { depth: 1, limit: 15 } : /^(brow\.|browTilt$)/.test(e) ? { depth: 1, limit: e === "browTilt" ? void 0 : 0.25 } : /^eye\./.test(e) ? { depth: 1, limit: 0.15 } : /^arm\.\w+\.(elbow|bend)$/.test(e) ? { depth: 2, limit: 18 } : /^leg\.\w+\.(ankle|toeOut)$/.test(e) ? { depth: 2, limit: 10 } : /^(mouth|smile|mouthWidth)$/.test(e) ? { depth: 2 } : /^hand\./.test(e) ? { depth: 3 } : { depth: 1 };
|
|
3376
|
+
}
|
|
3377
|
+
function Yr() {
|
|
3378
|
+
const e = {}, t = {};
|
|
3379
|
+
for (const n of Object.keys(X)) {
|
|
3380
|
+
const s = Nr(n);
|
|
3381
|
+
e[n] = s.depth, s.limit !== void 0 && (t[n] = s.limit);
|
|
3382
|
+
}
|
|
3383
|
+
return {
|
|
3384
|
+
depth: e,
|
|
3385
|
+
limits: t,
|
|
3386
|
+
eyes: ["lookX", "lookY"],
|
|
3387
|
+
blink: "blink",
|
|
3388
|
+
headTurns: { turn: 0.15, "head.turn": 15, "head.nod": 12, lookX: 0.5, roll: 45 },
|
|
3389
|
+
drift: ["lean", "head.tilt", "head.nod", "arm.left.spread", "arm.right.spread", "arm.left.elbow", "arm.right.elbow"],
|
|
3390
|
+
lift: "lift",
|
|
3391
|
+
stretch: "stretch"
|
|
3392
|
+
};
|
|
3393
|
+
}
|
|
3394
|
+
const Cr = Yr();
|
|
3395
|
+
function Zn(e, t) {
|
|
3396
|
+
return Object.entries(t).map(([n, s]) => ({ id: `${e}-${n}`, target: e, property: n, keyframes: s }));
|
|
3397
|
+
}
|
|
3398
|
+
function Dr(e, t, n = {}) {
|
|
3399
|
+
const s = _n(t), o = t.map((r, l) => ({ time: r.time, pose: { ...s[l] }, easing: r.easing, act: r.act }));
|
|
3400
|
+
return Zn(e, Jn(o, n.rig ?? Lr, n));
|
|
3401
|
+
}
|
|
3402
|
+
function Xi(e, t, n = {}) {
|
|
3403
|
+
const s = n.rest ?? X, o = qn(t, s), r = t.map((l, i) => ({ time: l.time, pose: { ...s, ...o[i] }, easing: l.easing, act: l.act }));
|
|
3404
|
+
return Zn(e, Jn(r, n.rig ?? Cr, n));
|
|
3405
|
+
}
|
|
3406
|
+
const rn = Y.shocked, Xr = Y.scared, Bt = {
|
|
3407
|
+
/** The classic take: squash down in a squint, then shoot up stretched with eyes popping, hang, and land squashed. */
|
|
3408
|
+
take: (e) => [
|
|
3409
|
+
{ after: 140, pose: { stretch: 0.8, bend: 10, lean: e.lean - 4, leftShoulder: 8, rightShoulder: 8, leftEye: 0.35, rightEye: 0.35, leftBrow: -0.6, rightBrow: -0.6, mouth: 0 }, easing: "ease-in-out" },
|
|
3410
|
+
{ after: 260, pose: { stretch: 0.78 } },
|
|
3411
|
+
{ after: 360, pose: { rise: 0.22, stretch: 1.35, bend: -14, leftShoulder: 150, rightShoulder: 150, leftElbow: 35, rightElbow: 35, leftHip: 22, rightHip: 22, leftKnee: 45, rightKnee: 45, ...rn, headTilt: 0 }, easing: "ease-out-cubic" },
|
|
3412
|
+
{ after: 720, pose: { rise: 0.25, stretch: 1.25, bend: -10, leftShoulder: 140, rightShoulder: 140 }, easing: "ease-in-out" },
|
|
3413
|
+
{ after: 900, pose: { rise: 0, stretch: 0.74, bend: 12, leftShoulder: 70, rightShoulder: 70, leftHip: 18, rightHip: 18, leftKnee: 30, rightKnee: 30 }, easing: "ease-in-quad" },
|
|
3414
|
+
{ after: 1060, pose: { stretch: 1.06, bend: -3, leftShoulder: 60, rightShoulder: 60, leftHip: e.leftHip, rightHip: e.rightHip, leftKnee: e.leftKnee, rightKnee: e.rightKnee }, easing: "ease-out" },
|
|
3415
|
+
{ after: 1260, pose: { stretch: e.stretch, bend: e.bend, ...Y.surprised, leftShoulder: 70, rightShoulder: 70, leftElbow: 60, rightElbow: 60 }, easing: "ease-in-out" }
|
|
3416
|
+
],
|
|
3417
|
+
/** Glance at something, look away unbothered, then snap back to it in shock. */
|
|
3418
|
+
doubleTake: (e) => [
|
|
3419
|
+
{ after: 160, pose: { lookX: 1, lookY: 0 }, easing: "ease-out" },
|
|
3420
|
+
{ after: 520, pose: { lookX: -0.6, headTilt: e.headTilt - 4, smile: 0.6, mouth: 0 }, easing: "ease-in-out" },
|
|
3421
|
+
{ after: 1100, pose: { lookX: -0.6 } },
|
|
3422
|
+
{ after: 1180, pose: { bend: e.bend - 10, headTilt: e.headTilt + 10, rise: 0.05, stretch: 1.18, ...rn, lookX: 1, lookY: 0 }, easing: "ease-out-cubic" },
|
|
3423
|
+
{ after: 1360, pose: { rise: 0, stretch: 0.88, bend: e.bend + 4, headTilt: e.headTilt + 4 }, easing: "ease-in-quad" },
|
|
3424
|
+
{ after: 1560, pose: { stretch: e.stretch, bend: e.bend, headTilt: e.headTilt }, easing: { type: "elastic", mode: "out", amplitude: 1, period: 0.35 } }
|
|
3425
|
+
],
|
|
3426
|
+
/** Rear back for a zip-off: lean back, one knee up, arms cocked, hold, then pitch forward ready to run. */
|
|
3427
|
+
windUp: () => [
|
|
3428
|
+
{ after: 220, pose: { lean: -18, bend: -16, headTilt: -6, leftShoulder: 70, leftElbow: -100, rightShoulder: 40, rightElbow: 100, leftHip: -45, leftKnee: -80, stretch: 0.92, ...Y.angry, lookX: 1 }, easing: "ease-out" },
|
|
3429
|
+
{ after: 620, pose: { lean: -20, bend: -18, stretch: 0.9 } },
|
|
3430
|
+
{ after: 700, pose: { lean: 28, bend: 14, headTilt: 6, leftShoulder: 30, rightShoulder: 60, leftHip: 30, leftKnee: -30, rightHip: -20, stretch: 1.12 }, easing: "ease-out-cubic" }
|
|
3431
|
+
],
|
|
3432
|
+
/** Coming down to the ground: stretched in the fall, squashed on contact, a spring back up. */
|
|
3433
|
+
land: (e) => [
|
|
3434
|
+
{ after: 120, pose: { rise: 0, stretch: 0.7, bend: 14, leftShoulder: 75, rightShoulder: 75, leftHip: 20, rightHip: 20, leftKnee: 35, rightKnee: 35 }, easing: "ease-in-quad" },
|
|
3435
|
+
{ after: 300, pose: { stretch: 1.05, bend: -4, leftShoulder: e.leftShoulder, rightShoulder: e.rightShoulder }, easing: "ease-out" },
|
|
3436
|
+
{ after: 460, pose: { rise: 0, stretch: e.stretch, bend: e.bend, leftHip: _.leftHip, rightHip: _.rightHip, leftKnee: 0, rightKnee: 0 }, easing: "ease-in-out" }
|
|
3437
|
+
],
|
|
3438
|
+
/** A frightened shiver: small, fast shakes with wide eyes, then still. */
|
|
3439
|
+
tremble: (e) => {
|
|
3440
|
+
const t = [{ after: 80, pose: { ...Xr, bend: e.bend + 8, leftShoulder: 40, rightShoulder: 40, leftElbow: 110, rightElbow: 110, stretch: 0.94 }, easing: "ease-out" }];
|
|
3441
|
+
for (let n = 1; n <= 14; n++) t.push({ after: 80 + n * 45, pose: { lean: e.lean + (n % 2 === 0 ? 2.5 : -2.5), headTilt: e.headTilt + (n % 2 === 0 ? -2 : 2) } });
|
|
3442
|
+
return t.push({ after: 755, pose: { lean: e.lean, headTilt: e.headTilt, bend: e.bend } }), t;
|
|
3443
|
+
},
|
|
3444
|
+
/** A sigh: the body sags, shoulders drop, head and eyes go down. */
|
|
3445
|
+
deflate: (e) => [
|
|
3446
|
+
{ after: 260, pose: { stretch: 1.04, headTilt: e.headTilt + 4, leftBrow: 0.3, rightBrow: 0.3 }, easing: "ease-in-out" },
|
|
3447
|
+
{ after: 900, pose: { ...Oe.sad, bend: 18, stretch: 0.92, lean: e.lean + 5, turn: e.turn, sit: e.sit }, easing: "ease-in-out" }
|
|
3448
|
+
]
|
|
3449
|
+
};
|
|
3450
|
+
function qr(e, t) {
|
|
3451
|
+
const n = typeof t.from == "string" ? Oe[t.from] : t.from ?? _, s = t.speed ?? 1;
|
|
3452
|
+
let o = n;
|
|
3453
|
+
return [
|
|
3454
|
+
// The move onto the starting pose is acted like any other; the gag itself is not.
|
|
3455
|
+
{ time: t.at, pose: n },
|
|
3456
|
+
...Bt[e](n).map((r) => (o = { ...o, ...r.pose }, { time: t.at + r.after * s, pose: o, act: !1, ...r.easing ? { easing: r.easing } : {} }))
|
|
3457
|
+
];
|
|
3458
|
+
}
|
|
3459
|
+
function Gr(e, t = 1) {
|
|
3460
|
+
const n = Bt[e](_);
|
|
3461
|
+
return n[n.length - 1].after * t;
|
|
3462
|
+
}
|
|
3463
|
+
function Ur(e, t, n = {}) {
|
|
3464
|
+
if (t.length < 2) return;
|
|
3465
|
+
const s = Math.max(1, Math.round(n.lines ?? 3)), o = n.spacing ?? 5, r = n.lineWidth ?? 2, l = n.opacity ?? 0.7;
|
|
3466
|
+
e.save(), e.strokeStyle = n.color ?? "#222", e.lineCap = "round";
|
|
3467
|
+
for (let i = 0; i < s; i++) {
|
|
3468
|
+
const a = (i - (s - 1) / 2) * o, h = Math.floor(Math.abs(a) / Math.max(o, 1) * (t.length / 6));
|
|
3469
|
+
for (let c = h + 1; c < t.length; c++) {
|
|
3470
|
+
const u = t[c - 1], g = t[c], f = g.x - u.x, p = g.y - u.y, d = Math.hypot(f, p) || 1, m = -p / d, b = f / d, y = 1 - c / (t.length - 1);
|
|
3471
|
+
e.globalAlpha = l * (1 - y), e.lineWidth = r * (1 - y * 0.7), e.beginPath(), e.moveTo(u.x + m * a, u.y + b * a), e.lineTo(g.x + m * a, g.y + b * a), e.stroke();
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
e.restore();
|
|
3475
|
+
}
|
|
3476
|
+
const zr = {
|
|
3477
|
+
hands: [
|
|
3478
|
+
{ name: "left hand", at: (e) => e.hands.left },
|
|
3479
|
+
{ name: "right hand", at: (e) => e.hands.right }
|
|
3480
|
+
],
|
|
3481
|
+
toes: [
|
|
3482
|
+
{ name: "left toe", at: (e) => e.toes.left },
|
|
3483
|
+
{ name: "right toe", at: (e) => e.toes.right }
|
|
3484
|
+
],
|
|
3485
|
+
head: [{ name: "head", at: (e) => e.head.center }],
|
|
3486
|
+
body: [
|
|
3487
|
+
{ name: "hip", at: (e) => e.hip },
|
|
3488
|
+
{ name: "neck", at: (e) => e.neck }
|
|
3489
|
+
]
|
|
3490
|
+
};
|
|
3491
|
+
function qi(e, t, n, s, o = {}) {
|
|
3492
|
+
const r = n.stateAt;
|
|
3493
|
+
if (!r) return;
|
|
3494
|
+
const l = o.length ?? 120, i = Math.max(2, Math.round(o.samples ?? 8)), a = Math.max(0, n.time - l);
|
|
3495
|
+
if (n.time - a < 1) return;
|
|
3496
|
+
const h = [];
|
|
3497
|
+
for (let f = 0; f < i; f++) {
|
|
3498
|
+
const p = a + (n.time - a) * f / (i - 1);
|
|
3499
|
+
h.push(ds(t, { time: p, state: r(p) }, s).joints);
|
|
3500
|
+
}
|
|
3501
|
+
const c = h[h.length - 1].height, u = (o.threshold ?? 1.2) * c, g = (o.parts ?? ["hands", "toes", "head"]).flatMap((f) => zr[f]);
|
|
3502
|
+
for (const f of g) {
|
|
3503
|
+
const p = h.map(f.at);
|
|
3504
|
+
let d = 0;
|
|
3505
|
+
for (let y = 1; y < p.length; y++) d += Math.hypot(p[y].x - p[y - 1].x, p[y].y - p[y - 1].y);
|
|
3506
|
+
const m = d / ((n.time - a) / 1e3);
|
|
3507
|
+
if (m <= u) continue;
|
|
3508
|
+
const b = Math.min(1, (m - u) / (u * 0.5));
|
|
3509
|
+
Ur(e, p, { ...o, opacity: (o.opacity ?? 0.7) * b, spacing: o.spacing ?? c * 0.02 });
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3512
|
+
function Gi(e, t, n, s = {}) {
|
|
3513
|
+
if (n <= 0 || n >= 1) return;
|
|
3514
|
+
const o = s.size ?? 40, r = s.seed ?? 1, l = 0.45 + 0.55 * (1 - (1 - n) ** 3);
|
|
3515
|
+
e.save(), e.strokeStyle = s.color ?? "#555", e.lineWidth = Math.max(1, o * 0.03), e.globalAlpha = Math.min(1, n / 0.08) * (1 - n);
|
|
3516
|
+
for (let i = 0; i < 5; i++) {
|
|
3517
|
+
const a = Ze(`${r}:puff:${i}`) % 1e3 / 1e3, h = i - 2, c = t.x + h * o * 0.3 * l, u = t.y - o * (0.06 + 0.12 * a) * l + Math.abs(h) * o * 0.03, g = o * (0.11 + 0.07 * a) * l;
|
|
3518
|
+
e.beginPath(), e.arc(c, u, g, Math.PI * 0.95, Math.PI * 2.05), e.stroke();
|
|
3519
|
+
}
|
|
3520
|
+
e.restore();
|
|
3521
|
+
}
|
|
3522
|
+
function Ui(e, t, n, s = {}) {
|
|
3523
|
+
if (n <= 0 || n >= 1) return;
|
|
3524
|
+
const o = s.size ?? 40, r = 5, l = 1 - (1 - n) ** 2;
|
|
3525
|
+
e.save(), e.strokeStyle = s.color ?? "#222", e.lineWidth = Math.max(1, o * 0.035), e.lineJoin = "round", e.globalAlpha = n < 0.7 ? 1 : (1 - n) / 0.3;
|
|
3526
|
+
for (let i = 0; i < r; i++) {
|
|
3527
|
+
const a = -Math.PI / 2 + (i - (r - 1) / 2) * Math.PI / (r + 1), h = o * (0.3 + 0.7 * l), c = t.x + Math.cos(a) * h, u = t.y + Math.sin(a) * h;
|
|
3528
|
+
Vr(e, c, u, o * 0.14, n * Math.PI + i), e.stroke();
|
|
3529
|
+
}
|
|
3530
|
+
e.restore();
|
|
3531
|
+
}
|
|
3532
|
+
function Vr(e, t, n, s, o) {
|
|
3533
|
+
e.beginPath();
|
|
3534
|
+
for (let r = 0; r < 10; r++) {
|
|
3535
|
+
const l = r % 2 === 0 ? s : s * 0.45, i = o + r * Math.PI / 5 - Math.PI / 2, a = t + Math.cos(i) * l, h = n + Math.sin(i) * l;
|
|
3536
|
+
r === 0 ? e.moveTo(a, h) : e.lineTo(a, h);
|
|
3537
|
+
}
|
|
3538
|
+
e.closePath();
|
|
3539
|
+
}
|
|
3540
|
+
const ce = {
|
|
3541
|
+
/** Closed and relaxed */
|
|
3542
|
+
rest: { mouth: 0, mouthWidth: 1 },
|
|
3543
|
+
/** "ah": open wide */
|
|
3544
|
+
a: { mouth: 0.75, mouthWidth: 1.1 },
|
|
3545
|
+
/** "eh": open, wide */
|
|
3546
|
+
e: { mouth: 0.45, mouthWidth: 1.3 },
|
|
3547
|
+
/** "ee": a little open, stretched wide */
|
|
3548
|
+
i: { mouth: 0.28, mouthWidth: 1.45 },
|
|
3549
|
+
/** "oh": round */
|
|
3550
|
+
o: { mouth: 0.6, mouthWidth: 0.7 },
|
|
3551
|
+
/** "oo": small and pursed */
|
|
3552
|
+
u: { mouth: 0.32, mouthWidth: 0.55 },
|
|
3553
|
+
/** m, b, p: lips pressed */
|
|
3554
|
+
m: { mouth: 0, mouthWidth: 0.9 },
|
|
3555
|
+
/** f, v: lip under the teeth */
|
|
3556
|
+
f: { mouth: 0.1, mouthWidth: 1.05 },
|
|
3557
|
+
/** l, th, n, d, t: tongue up, a little open */
|
|
3558
|
+
l: { mouth: 0.3, mouthWidth: 1 },
|
|
3559
|
+
/** Other consonants: slightly open */
|
|
3560
|
+
c: { mouth: 0.2, mouthWidth: 1 }
|
|
3561
|
+
}, Me = 1, Ne = 0.55, ln = 0.35, jr = 1.6, an = { a: "a", e: "e", i: "i", y: "i", o: "o", u: "u" }, hn = { m: "m", b: "m", p: "m", f: "f", v: "f", w: "u", q: "u", l: "l", n: "l", d: "l", t: "l" }, cn = {
|
|
3562
|
+
अ: "a",
|
|
3563
|
+
आ: "a",
|
|
3564
|
+
इ: "i",
|
|
3565
|
+
ई: "i",
|
|
3566
|
+
उ: "u",
|
|
3567
|
+
ऊ: "u",
|
|
3568
|
+
ऋ: "i",
|
|
3569
|
+
ए: "e",
|
|
3570
|
+
ऐ: "e",
|
|
3571
|
+
ओ: "o",
|
|
3572
|
+
औ: "o",
|
|
3573
|
+
ऍ: "e",
|
|
3574
|
+
ऑ: "o"
|
|
3575
|
+
}, fn = {
|
|
3576
|
+
"ा": "a",
|
|
3577
|
+
"ि": "i",
|
|
3578
|
+
"ी": "i",
|
|
3579
|
+
"ु": "u",
|
|
3580
|
+
"ू": "u",
|
|
3581
|
+
"ृ": "i",
|
|
3582
|
+
"े": "e",
|
|
3583
|
+
"ै": "e",
|
|
3584
|
+
"ो": "o",
|
|
3585
|
+
"ौ": "o",
|
|
3586
|
+
"ॅ": "e",
|
|
3587
|
+
"ॉ": "o"
|
|
3588
|
+
}, Jr = { प: "m", फ: "m", ब: "m", भ: "m", म: "m", व: "u" }, Zr = "्", un = "़", Qr = (e) => e >= "क" && e <= "ह", dn = /* @__PURE__ */ new Set([".", ",", "!", "?", ";", ":", "…", "।", "॥", "—", "-"]);
|
|
3589
|
+
function ei(e) {
|
|
3590
|
+
const t = [], n = Array.from(e.toLowerCase()), s = (o, r) => {
|
|
3591
|
+
const l = t[t.length - 1];
|
|
3592
|
+
l && l.viseme === o ? l.weight += r * 0.5 : t.push({ viseme: o, weight: r });
|
|
3593
|
+
};
|
|
3594
|
+
for (let o = 0; o < n.length; o++) {
|
|
3595
|
+
const r = n[o], l = n[o + 1];
|
|
3596
|
+
if (dn.has(r)) s("rest", jr);
|
|
3597
|
+
else if (/\s/.test(r)) {
|
|
3598
|
+
const i = t[t.length - 1];
|
|
3599
|
+
i && i.viseme !== "rest" && t.push({ viseme: "c", weight: ln });
|
|
3600
|
+
} else if ((r === "o" || r === "e") && l === r)
|
|
3601
|
+
s(r === "o" ? "u" : "i", Me), o++;
|
|
3602
|
+
else if (r in an) s(an[r], Me);
|
|
3603
|
+
else if (r in hn) s(hn[r], Ne);
|
|
3604
|
+
else {
|
|
3605
|
+
if (r === "h") continue;
|
|
3606
|
+
if (/[a-z]/.test(r)) s("c", Ne);
|
|
3607
|
+
else if (r in cn) s(cn[r], Me);
|
|
3608
|
+
else if (Qr(r)) {
|
|
3609
|
+
const i = l === un ? r === "फ" ? "f" : void 0 : Jr[r];
|
|
3610
|
+
s(i ?? "c", Ne);
|
|
3611
|
+
let a = o + 1;
|
|
3612
|
+
n[a] === un && a++;
|
|
3613
|
+
const h = n[a];
|
|
3614
|
+
h === Zr ? o = a : h && h in fn ? (s(fn[h], Me), o = a) : (!h || /\s/.test(h) || dn.has(h) || s("a", Me * 0.6), o = a - 1);
|
|
3615
|
+
} else (r === "ं" || r === "ँ") && s("l", Ne * 0.6);
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
for (; t.length > 0 && (t[t.length - 1].viseme === "rest" || t[t.length - 1].weight === ln); ) t.pop();
|
|
3619
|
+
return t;
|
|
3620
|
+
}
|
|
3621
|
+
function Qn(e, t = {}) {
|
|
3622
|
+
const n = t.fields?.mouth ?? "mouth", s = t.fields?.mouthWidth ?? "mouthWidth", o = t.energy ?? 1, r = ei(e.text), l = [{ time: e.start, value: ce.rest.mouth }], i = [{ time: e.start, value: ce.rest.mouthWidth }], a = r.reduce((c, u) => c + u.weight, 0), h = e.end - e.start;
|
|
3623
|
+
if (a > 0 && h > 0) {
|
|
3624
|
+
let c = e.start;
|
|
3625
|
+
for (const u of r) {
|
|
3626
|
+
const g = h * u.weight / a, f = c + Math.min(g * 0.4, 60);
|
|
3627
|
+
if (f > l[l.length - 1].time) {
|
|
3628
|
+
const p = ce[u.viseme];
|
|
3629
|
+
l.push({ time: f, value: p.mouth * o, easing: "ease-out" }), i.push({ time: f, value: 1 + (p.mouthWidth - 1) * Math.min(1.3, o), easing: "ease-out" });
|
|
3630
|
+
}
|
|
3631
|
+
c += g;
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
return e.end > l[l.length - 1].time && (l.push({ time: e.end, value: ce.rest.mouth, easing: "ease-in-out" }), i.push({ time: e.end, value: ce.rest.mouthWidth, easing: "ease-in-out" })), { [n]: l, [s]: i };
|
|
3635
|
+
}
|
|
3636
|
+
function zi(e, t, n = {}) {
|
|
3637
|
+
const s = {};
|
|
3638
|
+
for (const o of [...t].sort((r, l) => r.start - l.start))
|
|
3639
|
+
for (const [r, l] of Object.entries(Qn(o, n))) {
|
|
3640
|
+
const i = s[r] ??= [], a = i.length > 0 ? i[i.length - 1].time : -1 / 0;
|
|
3641
|
+
i.push(...l.filter((h) => h.time > a));
|
|
3642
|
+
}
|
|
3643
|
+
return Object.entries(s).map(([o, r]) => ({ id: `${e}-${o}`, target: e, property: o, keyframes: r }));
|
|
3644
|
+
}
|
|
3645
|
+
function ti(e, t, n, s = {}) {
|
|
3646
|
+
if (n.length === 0) return t;
|
|
3647
|
+
const o = s.fields?.mouth ?? "mouth", r = s.fields?.mouthWidth ?? "mouthWidth", l = { [o]: ce.rest.mouth, [r]: ce.rest.mouthWidth, ...s.rest }, i = new oo({ id: "before-speech", tracks: t }), a = (u, g) => i.getStateAtTime(g).values.get(e)?.get(u) ?? l[u], h = [o, r], c = t.filter((u) => u.target !== e || !h.includes(u.property));
|
|
3648
|
+
for (const u of h) {
|
|
3649
|
+
const g = t.find((p) => p.target === e && p.property === u);
|
|
3650
|
+
let f = g ? [...g.keyframes] : [{ time: 0, value: a(u, 0) }];
|
|
3651
|
+
for (const p of n) {
|
|
3652
|
+
const d = Qn(p, s)[u];
|
|
3653
|
+
d[0] = { ...d[0], value: a(u, p.start) }, d[d.length - 1] = { ...d[d.length - 1], value: a(u, p.end) }, f = [...f.filter((m) => m.time < p.start || m.time > p.end), ...d], f.sort((m, b) => m.time - b.time);
|
|
3654
|
+
}
|
|
3655
|
+
c.push({ id: g?.id ?? `${e}-${u}`, target: e, property: u, keyframes: f });
|
|
3656
|
+
}
|
|
3657
|
+
return c;
|
|
3658
|
+
}
|
|
3659
|
+
const ni = {
|
|
3660
|
+
walk: 1e3,
|
|
3661
|
+
bouncy: 900,
|
|
3662
|
+
doubleBounce: 1100,
|
|
3663
|
+
sneak: 1600,
|
|
3664
|
+
strut: 1100,
|
|
3665
|
+
tired: 1500,
|
|
3666
|
+
run: 560
|
|
3667
|
+
}, le = 450, gn = 1200, oi = 700, be = 320, He = 220, si = 65, ri = 700, ft = (e) => e in we, pn = (e) => e in Bt, ii = (e) => e in Oe;
|
|
3668
|
+
function li(e) {
|
|
3669
|
+
return Math.max(ri, Array.from(e).length * si);
|
|
3670
|
+
}
|
|
3671
|
+
function Vi(e, t, n = {}) {
|
|
3672
|
+
const s = n.from ?? 0, o = n.height ?? 300;
|
|
3673
|
+
let r = s, l = n.facing ?? 1, i = n.start ?? _, a = 0, h = 0;
|
|
3674
|
+
const c = [{ time: 0, pose: i }], u = [{ time: 0, value: 0 }], g = [{ time: 0, value: 0 }], f = [{ time: 0, value: 0 }], p = [{ time: 0, value: "walk" }], d = [{ time: 0, value: l }], m = [], b = [], y = (w, S, k, x) => {
|
|
3675
|
+
i = { ...i, ...S }, k && (i = qe(i, k)), c.push({ time: w, pose: i });
|
|
3676
|
+
}, E = (w, S, k) => (y(w + be / 2, { turn: 0 }, k), d.push({ time: w + be / 2, value: l }, { time: w + be / 2 + 1, value: S }), l = S, y(w + be, { turn: 1 }), w + be), H = (w) => w < r ? -1 : 1;
|
|
3677
|
+
for (const w of t) {
|
|
3678
|
+
const S = Math.max(w.at ?? h, h === 0 ? 0 : c[c.length - 1].time);
|
|
3679
|
+
let k = S;
|
|
3680
|
+
const x = w.pose ?? {};
|
|
3681
|
+
if (ft(w.do)) {
|
|
3682
|
+
const v = w.to ?? r, T = v === r ? l : H(v);
|
|
3683
|
+
let K = S;
|
|
3684
|
+
T !== l ? K = E(S, T, w.mood) : i.turn < 1 ? (K = S + He, y(K, { turn: 1, ...x }, w.mood)) : (w.mood || w.pose) && y(S + He, x, w.mood);
|
|
3685
|
+
const I = Math.abs(v - r) / Io(w.do, o), q = w.for ?? Math.max(He * 2, I * ni[w.do]), G = K + q;
|
|
3686
|
+
p.push({ time: K, value: w.do }), f.push({ time: K, value: 0 }, { time: K + He, value: 1, easing: "ease-out" }), f.push({ time: G - He, value: 1 }, { time: G, value: 0, easing: "ease-in" }), g.push({ time: K, value: a }, { time: G, value: a + I }), u.push({ time: K, value: r - s }, { time: G, value: v - s }), a += I, r = v, y(G, {}), k = G;
|
|
3687
|
+
} else if (pn(w.do)) {
|
|
3688
|
+
const v = qr(w.do, { at: S, from: w.mood ? qe(i, w.mood) : i });
|
|
3689
|
+
c.push(...v), i = v[v.length - 1].pose, k = S + Gr(w.do);
|
|
3690
|
+
} else if (w.do === "look" || w.do === "face") {
|
|
3691
|
+
const v = w.toward ?? "viewer", T = w.for ?? oi;
|
|
3692
|
+
if (v === "viewer") y(S + le, { turn: 0, lookX: 0, lookY: 0, ...x }, w.mood);
|
|
3693
|
+
else if (v === "ahead") y(S + le, { turn: w.do === "face" ? 1 : 0.6, lookX: 1, ...x }, w.mood);
|
|
3694
|
+
else if (v === "back") y(S + le, { turn: 0.2, lookX: -1, ...x }, w.mood);
|
|
3695
|
+
else {
|
|
3696
|
+
const K = H(v);
|
|
3697
|
+
K !== l && w.do === "face" ? (E(S, K, w.mood), y(S + be + 1, { lookX: 1, ...x })) : K !== l ? y(S + le, { turn: 0.25, lookX: -1, ...x }, w.mood) : y(S + le, { turn: w.do === "face" ? 1 : 0.6, lookX: 1, ...x }, w.mood);
|
|
3698
|
+
}
|
|
3699
|
+
k = S + Math.max(T, le);
|
|
3700
|
+
} else if (ii(w.do) || w.do === "stand") {
|
|
3701
|
+
const v = w.do === "stand" ? _ : Oe[w.do], T = v.turn !== _.turn ? v.turn : i.turn, K = w.mood ? Y[w.mood] : { lookX: i.lookX, lookY: i.lookY };
|
|
3702
|
+
y(S + le, { ...v, turn: T, ...K, ...x }), k = S + (w.for ?? gn);
|
|
3703
|
+
} else {
|
|
3704
|
+
const v = w.for ?? (w.say ? li(w.say) : gn);
|
|
3705
|
+
(w.mood || w.pose) && y(S + Math.min(le, v / 2), x, w.mood), k = S + v;
|
|
3706
|
+
}
|
|
3707
|
+
if (w.say) {
|
|
3708
|
+
const v = ft(w.do) || pn(w.do) ? S : S + Math.min(150, (k - S) / 4), T = ft(w.do) ? k : Math.max(v + 200, k - 100);
|
|
3709
|
+
m.push({ text: w.say, start: v, end: T }), w.do === "say" && ci(c, i, v, T);
|
|
3710
|
+
}
|
|
3711
|
+
k > c[c.length - 1].time && c.push({ time: k, pose: i }), b.push({ start: S, end: k }), h = k;
|
|
3712
|
+
}
|
|
3713
|
+
const M = Dr(e, hi(c), n), A = [
|
|
3714
|
+
{ id: `${e}-x`, target: e, property: "x", keyframes: u },
|
|
3715
|
+
{ id: `${e}-walk`, target: e, property: "walk", keyframes: g },
|
|
3716
|
+
{ id: `${e}-walking`, target: e, property: "walking", keyframes: f },
|
|
3717
|
+
{ id: `${e}-gait`, target: e, property: "gait", keyframes: p },
|
|
3718
|
+
{ id: `${e}-facing`, target: e, property: "facing", keyframes: d }
|
|
3719
|
+
].filter((w) => w.keyframes.length > 1 || w.property === "x");
|
|
3720
|
+
return {
|
|
3721
|
+
tracks: [...ti(e, M, m, { energy: n.energy }), ...A],
|
|
3722
|
+
duration: h,
|
|
3723
|
+
lines: m,
|
|
3724
|
+
keys: c,
|
|
3725
|
+
beats: b
|
|
3726
|
+
};
|
|
3727
|
+
}
|
|
3728
|
+
const ai = 30;
|
|
3729
|
+
function hi(e) {
|
|
3730
|
+
const t = [];
|
|
3731
|
+
for (const n of e) {
|
|
3732
|
+
const s = t[t.length - 1];
|
|
3733
|
+
s && n.time - s.time < ai ? t[t.length - 1] = { ...n, time: s.time } : t.push(n);
|
|
3734
|
+
}
|
|
3735
|
+
return t;
|
|
3736
|
+
}
|
|
3737
|
+
function ci(e, t, n, s) {
|
|
3738
|
+
const r = e.filter((a) => a.time > n), l = e.filter((a) => a.time <= n), i = [];
|
|
3739
|
+
for (let a = n + 520, h = 0; a < s - 520 / 2; a += 520, h++) {
|
|
3740
|
+
const c = h % 2 === 0 ? 3 : -2;
|
|
3741
|
+
i.push({ time: a, pose: { ...t, headTilt: t.headTilt + c, leftBrow: t.leftBrow + (h % 2 === 0 ? 0.25 : 0), rightBrow: t.rightBrow + (h % 2 === 0 ? 0.25 : 0) } });
|
|
3742
|
+
}
|
|
3743
|
+
i.length > 0 && i.push({ time: s, pose: t }), e.length = 0, e.push(...l, ...i.filter((a) => !r.some((h) => Math.abs(h.time - a.time) < 60)), ...r), e.sort((a, h) => a.time - h.time);
|
|
3050
3744
|
}
|
|
3051
3745
|
export {
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3746
|
+
ht as ACTING_STYLES,
|
|
3747
|
+
Se as DANCE_STYLES,
|
|
3748
|
+
Y as EXPRESSIONS,
|
|
3749
|
+
co as FINGERS,
|
|
3750
|
+
Pt as FLIPS,
|
|
3751
|
+
Bt as GAGS,
|
|
3752
|
+
we as GAITS,
|
|
3753
|
+
ni as GAIT_CYCLE_MS,
|
|
3754
|
+
L as HAND_REST,
|
|
3755
|
+
C as HAND_SHAPES,
|
|
3756
|
+
Cr as HUMAN_ACTING_RIG,
|
|
3757
|
+
Ai as HUMAN_EXPRESSIONS,
|
|
3758
|
+
Qs as HUMAN_POSES,
|
|
3759
|
+
X as HUMAN_REST,
|
|
3760
|
+
Zt as MUDRAS,
|
|
3761
|
+
Oe as POSES,
|
|
3762
|
+
_ as REST_POSE,
|
|
3763
|
+
Lr as STICK_ACTING_RIG,
|
|
3764
|
+
ce as VISEMES,
|
|
3765
|
+
Xi as actCharacterTracks,
|
|
3766
|
+
Jn as actKeyframes,
|
|
3767
|
+
Dr as actTracks,
|
|
3768
|
+
ks as applyGroove,
|
|
3769
|
+
Mi as bakeDanceTracks,
|
|
3770
|
+
Di as basicOutfit,
|
|
3771
|
+
ki as beatAt,
|
|
3772
|
+
Pe as blendPose,
|
|
3773
|
+
to as boilFrame,
|
|
3774
|
+
fr as character,
|
|
3775
|
+
_i as characterAt,
|
|
3776
|
+
br as characterHandPose,
|
|
3777
|
+
gr as characterJoints,
|
|
3778
|
+
Pi as characterJointsInView,
|
|
3779
|
+
Bi as characterObjects,
|
|
3780
|
+
$i as characterPoseTracks,
|
|
3781
|
+
Ii as characterTarget,
|
|
3782
|
+
Ri as circlePath,
|
|
3783
|
+
jn as clipErased,
|
|
3784
|
+
bn as createPen,
|
|
3785
|
+
xt as danceFrame,
|
|
3786
|
+
wi as dancePose,
|
|
3787
|
+
yt as danceStance,
|
|
3788
|
+
yi as danceTaps,
|
|
3789
|
+
Ei as danceTracks,
|
|
3790
|
+
ot as danceTravel,
|
|
3791
|
+
Hs as danceTravelTrack,
|
|
3792
|
+
Si as dancer,
|
|
3793
|
+
Tt as drawCartoonHand,
|
|
3794
|
+
yr as drawCharacter,
|
|
3795
|
+
kr as drawCharacterInView,
|
|
3796
|
+
Gi as drawDustPuff,
|
|
3797
|
+
Gn as drawEraser,
|
|
3798
|
+
zn as drawHand,
|
|
3799
|
+
Ui as drawImpactStars,
|
|
3800
|
+
Ar as drawPencil,
|
|
3801
|
+
Ur as drawSpeedLines,
|
|
3802
|
+
hs as drawStickFigure,
|
|
3803
|
+
qi as drawStickSmear,
|
|
3804
|
+
Li as drawnPathTarget,
|
|
3805
|
+
Lt as ellipsePoints,
|
|
3806
|
+
Ci as erasable,
|
|
3807
|
+
Ys as flipPose,
|
|
3808
|
+
Hi as flipTracks,
|
|
3809
|
+
Cs as flipTravel,
|
|
3810
|
+
qr as gag,
|
|
3811
|
+
Gr as gagDuration,
|
|
3812
|
+
Oo as gaitPose,
|
|
3813
|
+
Io as gaitStrideLength,
|
|
3814
|
+
Fi as handAt,
|
|
3815
|
+
pt as handJoints,
|
|
3816
|
+
Mo as handJointsAt,
|
|
3817
|
+
R as handPose,
|
|
3818
|
+
Ue as handProp,
|
|
3819
|
+
pi as headPoint,
|
|
3820
|
+
Ti as humanFieldLabel,
|
|
3821
|
+
er as humanPlan,
|
|
3822
|
+
ee as humanPose,
|
|
3823
|
+
Sr as jointsInScene,
|
|
3824
|
+
as as jointsToScene,
|
|
3825
|
+
Qn as lipSyncKeyframes,
|
|
3826
|
+
ti as lipSyncOver,
|
|
3827
|
+
zi as lipSyncTracks,
|
|
3828
|
+
vi as mirrorHumanPose,
|
|
3829
|
+
ws as mirrorPose,
|
|
3830
|
+
Ke as mixHandPoses,
|
|
3831
|
+
Wi as mixPoses,
|
|
3832
|
+
mn as partialPath,
|
|
3833
|
+
Zi as pathLength,
|
|
3834
|
+
Ht as pointAlong,
|
|
3835
|
+
Ki as pointOnHead,
|
|
3836
|
+
z as pose,
|
|
3837
|
+
bi as poseTracks,
|
|
3838
|
+
Oi as reachCharacter,
|
|
3839
|
+
Or as resolveActingStyle,
|
|
3840
|
+
qn as resolveCharacterPoseKeys,
|
|
3841
|
+
wn as resolveGait,
|
|
3842
|
+
_n as resolvePoseKeys,
|
|
3843
|
+
On as resolveStickFrame,
|
|
3844
|
+
cs as resolveStickPose,
|
|
3845
|
+
de as rotateAbout,
|
|
3846
|
+
Kt as routineBeats,
|
|
3847
|
+
ke as rubberLimb,
|
|
3848
|
+
Vi as scriptTracks,
|
|
3849
|
+
Ni as scrubPath,
|
|
3850
|
+
gi as seatHeight,
|
|
3851
|
+
Yn as skeletonInView,
|
|
3852
|
+
ut as sketchPen,
|
|
3853
|
+
Ot as solvePlanSpace,
|
|
3854
|
+
ei as soundsOf,
|
|
3855
|
+
li as speechDuration,
|
|
3856
|
+
Nn as stagePlanSpace,
|
|
3857
|
+
ds as stickFigureAt,
|
|
3858
|
+
ls as stickFigureJoints,
|
|
3859
|
+
mi as stickFigureTarget,
|
|
3860
|
+
xi as stickToHuman,
|
|
3861
|
+
Bo as strideLength,
|
|
3862
|
+
Fo as talkingMouth,
|
|
3863
|
+
vt as taperedLine,
|
|
3864
|
+
Ye as taperedOutline,
|
|
3865
|
+
$o as walkPose,
|
|
3866
|
+
Yi as withErased,
|
|
3867
|
+
qe as withExpression
|
|
3146
3868
|
};
|