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