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