@algorisys/tinyfly 0.125.0 → 0.126.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/docs/editor-guide.md +1 -1
- package/docs/examples.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +4 -0
- package/docs/maps.md +2 -2
- package/docs/math.md +1 -1
- package/docs/props.md +5 -1
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +798 -796
- package/lib/browser/tinyfly.iife.js +14 -14
- package/lib/browser/tinyfly.js +652 -650
- package/lib/browser/tinyfly.umd.js +14 -14
- package/lib/types/characters/props/families/environment.d.ts +7 -1
- package/llms-full.txt +19 -11
- package/llms.txt +32 -32
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +3 -0
package/lib/addons/characters.js
CHANGED
|
@@ -180,24 +180,24 @@ function bi(e, n, t) {
|
|
|
180
180
|
const yi = 8;
|
|
181
181
|
function wi(e, n, t) {
|
|
182
182
|
const o = typeof n == "string" ? st[n] : n, r = t.bpm ?? o.bpm, a = t.beats ?? (t.move ? o.moves[t.move].beats : $o(o)), s = bi(o, a, t);
|
|
183
|
-
if (s.every((
|
|
184
|
-
const i = Math.min(t.fade ?? 1, a / 2), l = $t("ease-in-out"), c = (
|
|
183
|
+
if (s.every((E) => jn(o, E, t) === 0)) return;
|
|
184
|
+
const i = Math.min(t.fade ?? 1, a / 2), l = $t("ease-in-out"), c = (E) => i <= 0 ? 1 : Math.min(l(Math.min(1, E / i)), l(Math.min(1, (a - E) / i))), h = Math.ceil(i * yi), d = i <= 0 ? [] : Array.from({ length: h + 1 }, (E, O) => [O / h * i, a - O / h * i]).flat(), f = [.../* @__PURE__ */ new Set([...s, ...d])].sort((E, O) => E - O);
|
|
185
185
|
let u = 0;
|
|
186
|
-
const p = f.map((
|
|
186
|
+
const p = f.map((E, O) => {
|
|
187
187
|
if (O > 0) {
|
|
188
|
-
const
|
|
188
|
+
const k = f[O - 1], m = Math.max(1, Math.ceil((E - k) * 16));
|
|
189
189
|
for (let A = 0; A < m; A++) {
|
|
190
|
-
const P =
|
|
191
|
-
u += (jn(o,
|
|
190
|
+
const P = k + (E - k) * A / m, v = k + (E - k) * (A + 1) / m;
|
|
191
|
+
u += (jn(o, v, t) - jn(o, P, t)) * c((P + v) / 2);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
return { beat:
|
|
194
|
+
return { beat: E, travel: u };
|
|
195
195
|
}), g = t.start ?? 0, b = t.x ?? 0;
|
|
196
196
|
return {
|
|
197
197
|
id: `${e}-x`,
|
|
198
198
|
target: e,
|
|
199
199
|
property: "x",
|
|
200
|
-
keyframes: p.map((
|
|
200
|
+
keyframes: p.map((E) => ({ time: g + E.beat * 6e4 / r, value: b + t.height * E.travel, easing: "linear" }))
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
function tf(e, n, t = 0) {
|
|
@@ -233,20 +233,20 @@ function of(e, n) {
|
|
|
233
233
|
}
|
|
234
234
|
function sf(e, n, t = {}) {
|
|
235
235
|
const o = typeof n == "string" ? st[n] : n, r = t.bpm ?? o.bpm, a = t.beats ?? (t.move ? o.moves[t.move].beats : $o(o)), s = t.samplesPerBeat ?? 4, i = t.start ?? 0, l = Math.round(a * s), c = Array.from({ length: l + 1 }, (g, b) => {
|
|
236
|
-
const
|
|
237
|
-
return { time: i +
|
|
236
|
+
const E = b / s;
|
|
237
|
+
return { time: i + E * 6e4 / r, frame: Mo(o, E, t) };
|
|
238
238
|
}), h = (g, b) => ({
|
|
239
239
|
id: `${e}-${g}`,
|
|
240
240
|
target: e,
|
|
241
241
|
property: g,
|
|
242
|
-
keyframes: c.map((
|
|
242
|
+
keyframes: c.map((E) => ({ time: E.time, value: b(E.frame) }))
|
|
243
243
|
}), f = Object.keys(de).filter((g) => c.some((b) => b.frame.pose[g] !== c[0].frame.pose[g]) || c[0].frame.pose[g] !== de[g]).map((g) => h(g, (b) => b.pose[g])), u = t.height === void 0 ? void 0 : wi(e, o, { ...t, bpm: r, beats: a, start: i, height: t.height, fade: 0 });
|
|
244
244
|
if (u && f.push(u), t.hands === !1) return f;
|
|
245
245
|
const p = [];
|
|
246
246
|
for (const g of ["left", "right"])
|
|
247
247
|
for (const b of Object.keys(Ie)) {
|
|
248
|
-
const
|
|
249
|
-
c.some((O) =>
|
|
248
|
+
const E = (O) => O.hands?.[g]?.[b] ?? Ie[b];
|
|
249
|
+
c.some((O) => E(O.frame) !== Ie[b]) && p.push(h(Sr(g, b), E));
|
|
250
250
|
}
|
|
251
251
|
return [...f, ...p];
|
|
252
252
|
}
|
|
@@ -909,10 +909,10 @@ function cn(e, n, t = be) {
|
|
|
909
909
|
let a = o.keys.length - 1;
|
|
910
910
|
for (let b = 0; b < o.keys.length; b++) o.keys[b].beat <= r && (a = b);
|
|
911
911
|
const s = o.keys[a], i = o.keys[(a + 1) % o.keys.length], l = s.beat > r ? s.beat - o.beats : s.beat, c = i.beat <= s.beat ? i.beat + o.beats : i.beat, h = Xo((r - l) / (c - s.beat)), d = { ...be, ...t };
|
|
912
|
-
for (const b of new Set(o.keys.flatMap((
|
|
912
|
+
for (const b of new Set(o.keys.flatMap((E) => Object.keys(E.pose)))) {
|
|
913
913
|
if (b === "turn" || b === "roll") continue;
|
|
914
|
-
const
|
|
915
|
-
d[b] =
|
|
914
|
+
const E = b.match(/^hand\.(?:left|right)\.(.+)$/)?.[1], O = t[b] ?? be[b] ?? (E ? Ie[E] : void 0) ?? 0, k = s.pose[b] ?? O;
|
|
915
|
+
d[b] = k + ((i.pose[b] ?? O) - k) * h;
|
|
916
916
|
}
|
|
917
917
|
const f = Math.floor(n), u = n - f, p = u <= 0.6 ? 1 : 1 - Xo((u - 0.6) / 0.4), g = Math.max(0, ...o.strikes.map((b) => 1 - Math.min(pt(r - b, o.beats), pt(b - r, o.beats)) / 0.25));
|
|
918
918
|
return { pose: d, contact: { side: pt(f, 2) === 0 ? "left" : "right", start: f, weight: p }, strike: g };
|
|
@@ -960,8 +960,8 @@ function rf(e, n, t = {}) {
|
|
|
960
960
|
const d = Ta([a[0] - c.position[0], o * 0.2, a[2] - c.position[2]]), f = He(a, dn(d, r));
|
|
961
961
|
let u = vn(c.pose);
|
|
962
962
|
for (let g = 0; g < 6; g++) {
|
|
963
|
-
const b = { ...c, pose: u },
|
|
964
|
-
u = Aa(b, `arm.${h}`, He(f, He(Vo(b, h),
|
|
963
|
+
const b = { ...c, pose: u }, E = vt(b, `arm.${h}`, 2);
|
|
964
|
+
u = Aa(b, `arm.${h}`, He(f, He(Vo(b, h), E)));
|
|
965
965
|
}
|
|
966
966
|
for (const [g, b] of Object.entries(we.hold)) u[`hand.${h}.${g}`] = b;
|
|
967
967
|
const p = Vo({ ...c, pose: u }, h);
|
|
@@ -1331,8 +1331,8 @@ function Xi(e, n, t, o = {}) {
|
|
|
1331
1331
|
if (p.part.part.id === d.part.part.id) continue;
|
|
1332
1332
|
const g = p.face;
|
|
1333
1333
|
if (g.normal[0] * u[0] + g.normal[1] * u[1] + g.normal[2] * u[2] <= 0.8) continue;
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1334
|
+
const E = g.normal[0] * (f[0] - g.center[0]) + g.normal[1] * (f[1] - g.center[1]) + g.normal[2] * (f[2] - g.center[2]);
|
|
1335
|
+
E > -Zo / 5 && E < Zo && (d.layer = Math.max(d.layer, p.layer), d.depth = Math.max(d.depth, p.depth + 1e-6));
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
1338
|
a.sort((h, d) => h.layer - d.layer || h.depth - d.depth);
|
|
@@ -1473,22 +1473,22 @@ function ol(e) {
|
|
|
1473
1473
|
return oe.fromQuat(Be.fromAxisAngle(t, Math.acos(n) * 180 / Math.PI));
|
|
1474
1474
|
}
|
|
1475
1475
|
function sl(e, n, t, o, r) {
|
|
1476
|
-
const a = e.solid ?? {}, s = a.outline === !1 ? void 0 : a.outline ?? { width: 2, color: "#0f172a" }, i = { color: a.color ?? "#475569", shading: a.shading ?? "toon", outline: s }, l = { color: a.skin ?? "#f2c49b", shading: a.shading ?? "toon", outline: s }, c = { color: "#0f172a", shading: "unlit" }, h = o.height * 0.034, d = [], f = (
|
|
1477
|
-
for (const
|
|
1478
|
-
const m = o.chains[
|
|
1479
|
-
|
|
1480
|
-
const y = m[
|
|
1476
|
+
const a = e.solid ?? {}, s = a.outline === !1 ? void 0 : a.outline ?? { width: 2, color: "#0f172a" }, i = { color: a.color ?? "#475569", shading: a.shading ?? "toon", outline: s }, l = { color: a.skin ?? "#f2c49b", shading: a.shading ?? "toon", outline: s }, c = { color: "#0f172a", shading: "unlit" }, h = o.height * 0.034, d = [], f = (k, m, A) => d.push({ mesh: k, world: oe.multiply(r, m), material: A }), u = (k, m, A) => f(n.sphere, oe.compose(k, [0, 0, 0, 1], [m, m, m]), A);
|
|
1477
|
+
for (const k of t.chains) {
|
|
1478
|
+
const m = o.chains[k.id], A = k.id === "spine" ? 1.9 : 1;
|
|
1479
|
+
k.bones.forEach((P, v) => {
|
|
1480
|
+
const y = m[v], S = m[v + 1], w = ke.distance(y, S), [T, H] = P.width ?? [1, 1], x = h * A * (T + H) / 2;
|
|
1481
1481
|
if (w > 1e-6) {
|
|
1482
|
-
const j = ke.lerp(y,
|
|
1482
|
+
const j = ke.lerp(y, S, 0.5), R = ol(ke.normalize(ke.subtract(S, y)));
|
|
1483
1483
|
f(n.cylinder, oe.multiply(oe.translation(j), oe.multiply(R, oe.scaling([x, w, x]))), i);
|
|
1484
1484
|
}
|
|
1485
|
-
u(y, h * A *
|
|
1486
|
-
}),
|
|
1485
|
+
u(y, h * A * T, i), u(S, h * A * H, i);
|
|
1486
|
+
}), k.id.startsWith("arm.") && u(m[m.length - 1], h * 1.5, l);
|
|
1487
1487
|
}
|
|
1488
|
-
const { center: p, rx: g, ry: b, axes:
|
|
1488
|
+
const { center: p, rx: g, ry: b, axes: E } = o.head, O = [...E[0], 0, ...E[1], 0, ...E[2], 0, ...p, 1];
|
|
1489
1489
|
f(n.sphere, oe.multiply(O, oe.scaling([g, b, g])), l);
|
|
1490
|
-
for (const
|
|
1491
|
-
const m = ke.normalize([
|
|
1490
|
+
for (const k of [-1, 1]) {
|
|
1491
|
+
const m = ke.normalize([k * 0.36, 0.15, 0.92]), A = ke.add(p, ke.add(ke.add(ke.scale(E[0], m[0] * g * 1.04), ke.scale(E[1], m[1] * b * 1.04)), ke.scale(E[2], m[2] * g * 1.04))), P = [...E[0], 0, ...E[1], 0, ...E[2], 0, ...A, 1];
|
|
1492
1492
|
f(n.sphere, oe.multiply(P, oe.scaling([g * 0.11, b * 0.14, g * 0.03])), c);
|
|
1493
1493
|
}
|
|
1494
1494
|
return d;
|
|
@@ -1510,35 +1510,35 @@ const df = {
|
|
|
1510
1510
|
resolve({ object: e, prepared: n, values: t, world: o, camera: r, lights: a = [], fog: s, toScreen: i }) {
|
|
1511
1511
|
const l = e, c = n, h = c.who;
|
|
1512
1512
|
let d = { ...be, ...l.pose };
|
|
1513
|
-
for (const [y,
|
|
1514
|
-
typeof
|
|
1513
|
+
for (const [y, S] of t)
|
|
1514
|
+
typeof S == "number" && !Qi.has(y) && !el.has(y) && (d[y] = S);
|
|
1515
1515
|
const f = Math.max(0, Math.min(1, es(t.get("walking")) ?? l.walking ?? 0));
|
|
1516
1516
|
if (f > 0) {
|
|
1517
|
-
const y = typeof t.get("gait") == "string" ? t.get("gait") : l.gait,
|
|
1518
|
-
d = Object.fromEntries(Object.keys({ ...d, ...
|
|
1517
|
+
const y = typeof t.get("gait") == "string" ? t.get("gait") : l.gait, S = Ar(y, es(t.get("walk")) ?? 0, d);
|
|
1518
|
+
d = Object.fromEntries(Object.keys({ ...d, ...S }).map((w) => [w, (d[w] ?? 0) + ((S[w] ?? 0) - (d[w] ?? 0)) * f]));
|
|
1519
1519
|
}
|
|
1520
1520
|
const u = l.height ?? tl, p = oe.multiply(r.view, o), g = {
|
|
1521
1521
|
toView: (y) => oe.transformPoint(p, y),
|
|
1522
1522
|
toScreen: (y) => i(y)
|
|
1523
|
-
},
|
|
1524
|
-
if (
|
|
1525
|
-
const O = l.shadow === !1 ? [] : [{ depth:
|
|
1523
|
+
}, E = -g.toView([0, u / 2, 0])[2];
|
|
1524
|
+
if (E <= r.near) return null;
|
|
1525
|
+
const O = l.shadow === !1 ? [] : [{ depth: E + u, draw: (y) => nl(y, g, u * 0.18) }];
|
|
1526
1526
|
if (l.look === "solid") {
|
|
1527
1527
|
const y = wo(h.plan, d, { height: u, contact: h.contact });
|
|
1528
1528
|
return { meshes: sl(l, c, h.plan, y, o), drawables: O };
|
|
1529
1529
|
}
|
|
1530
|
-
const
|
|
1530
|
+
const k = oe.transformPoint(o, [0, u * 0.6, 0]), m = ke.normalize(ke.subtract(r.position, k)), A = ka(k, m, a).map((y) => Math.min(1, y));
|
|
1531
1531
|
let P = h;
|
|
1532
1532
|
if (a.length > 0 && h.skin !== "none") {
|
|
1533
|
-
const y = ja(h.skin, A, va(s, ke.distance(
|
|
1533
|
+
const y = ja(h.skin, A, va(s, ke.distance(k, r.position)), s?.color);
|
|
1534
1534
|
P = { ...h, skin: y, ...h.body ? { body: { ...h.body, fill: y } } : {} };
|
|
1535
1535
|
}
|
|
1536
|
-
const
|
|
1536
|
+
const v = Pr(P, d, g, { height: u });
|
|
1537
1537
|
return {
|
|
1538
1538
|
drawables: [
|
|
1539
1539
|
...O,
|
|
1540
1540
|
// Ties keep the character's own order.
|
|
1541
|
-
...
|
|
1541
|
+
...v.map((y, S) => ({ depth: -(y.sortDepth ?? y.depth) - S * 1e-6, draw: (w, T) => y.draw(w, T.time) }))
|
|
1542
1542
|
]
|
|
1543
1543
|
};
|
|
1544
1544
|
}
|
|
@@ -1655,7 +1655,7 @@ function Io(e, n, t, o = {}) {
|
|
|
1655
1655
|
let u = f ? [...f.keyframes] : [{ time: 0, value: l(d, 0) }];
|
|
1656
1656
|
for (const p of t) {
|
|
1657
1657
|
const g = _a(p, o)[d];
|
|
1658
|
-
g[0] = { ...g[0], value: l(d, p.start) }, g[g.length - 1] = { ...g[g.length - 1], value: l(d, p.end) }, u = [...u.filter((b) => b.time < p.start || b.time > p.end), ...g], u.sort((b,
|
|
1658
|
+
g[0] = { ...g[0], value: l(d, p.start) }, g[g.length - 1] = { ...g[g.length - 1], value: l(d, p.end) }, u = [...u.filter((b) => b.time < p.start || b.time > p.end), ...g], u.sort((b, E) => b.time - E.time);
|
|
1659
1659
|
}
|
|
1660
1660
|
h.push({ id: f?.id ?? `${e}-${d}`, target: e, property: d, keyframes: u });
|
|
1661
1661
|
}
|
|
@@ -1771,8 +1771,8 @@ function ml(e, n, t = 8) {
|
|
|
1771
1771
|
e.forEach((s, i) => {
|
|
1772
1772
|
const l = e[Math.min(i + 1, e.length - 1)], c = e[Math.max(i - 1, 0)], h = Ct([l[0] - c[0], l[1] - c[1], l[2] - c[2]]), d = Math.abs(h[1]) < 0.9 ? [0, 1, 0] : [1, 0, 0], f = Ct(ls(h, d)), u = ls(f, h);
|
|
1773
1773
|
for (let p = 0; p < t; p++) {
|
|
1774
|
-
const g = Math.PI * 2 * p / t, b = Math.cos(g) * o(i),
|
|
1775
|
-
r.push([s[0] + f[0] * b + u[0] *
|
|
1774
|
+
const g = Math.PI * 2 * p / t, b = Math.cos(g) * o(i), E = Math.sin(g) * o(i);
|
|
1775
|
+
r.push([s[0] + f[0] * b + u[0] * E, s[1] + f[1] * b + u[1] * E, s[2] + f[2] * b + u[2] * E]);
|
|
1776
1776
|
}
|
|
1777
1777
|
});
|
|
1778
1778
|
for (let s = 0; s < e.length - 1; s++)
|
|
@@ -1893,100 +1893,100 @@ function $l(e) {
|
|
|
1893
1893
|
function uf(e, n, t) {
|
|
1894
1894
|
const o = $l(n);
|
|
1895
1895
|
if (o.length > 0) throw new Error(`characterScript3D: ${o.length} problem(s) in the beats:
|
|
1896
|
-
${o.map((
|
|
1896
|
+
${o.map((v) => ` beat ${v.beat}: ${v.message}`).join(`
|
|
1897
1897
|
`)}`);
|
|
1898
|
-
const r = t.height ?? 1.7, a = { ...be, ...t.pose }, s = (
|
|
1899
|
-
const
|
|
1900
|
-
return y[
|
|
1898
|
+
const r = t.height ?? 1.7, a = { ...be, ...t.pose }, s = (v, y = a) => {
|
|
1899
|
+
const S = v.match(/^hand\.(?:left|right)\.(.+)$/)?.[1];
|
|
1900
|
+
return y[v] ?? be[v] ?? (S ? Ie[S] : void 0) ?? 0;
|
|
1901
1901
|
};
|
|
1902
1902
|
let [i, l] = t.position ?? [0, 0], c = t.heading ?? 0, h = 0;
|
|
1903
|
-
const d = /* @__PURE__ */ new Map(), f = [], u = (
|
|
1904
|
-
const
|
|
1905
|
-
|
|
1906
|
-
}, p = (
|
|
1907
|
-
const w = d.get(
|
|
1908
|
-
for (let
|
|
1909
|
-
if (w[
|
|
1910
|
-
if (w[
|
|
1903
|
+
const d = /* @__PURE__ */ new Map(), f = [], u = (v, y, S, w = "linear") => {
|
|
1904
|
+
const T = d.get(v) ?? [];
|
|
1905
|
+
T.push({ time: y, value: S, easing: w }), d.set(v, T);
|
|
1906
|
+
}, p = (v, y, S) => {
|
|
1907
|
+
const w = d.get(v) ?? [];
|
|
1908
|
+
for (let T = w.length - 1; T >= 0; T--)
|
|
1909
|
+
if (w[T].time === y) {
|
|
1910
|
+
if (w[T].value === S) return;
|
|
1911
1911
|
break;
|
|
1912
1912
|
}
|
|
1913
|
-
u(
|
|
1913
|
+
u(v, y, S);
|
|
1914
1914
|
};
|
|
1915
1915
|
u("x", 0, i), u("z", 0, l), u("rotateY", 0, c);
|
|
1916
|
-
const g = (
|
|
1916
|
+
const g = (v, y, S) => {
|
|
1917
1917
|
const w = un(c, y);
|
|
1918
1918
|
if (Math.abs(w) < 1)
|
|
1919
|
-
return
|
|
1920
|
-
const
|
|
1921
|
-
return p("rotateY",
|
|
1922
|
-
}, b = (
|
|
1923
|
-
for (const [
|
|
1924
|
-
s(
|
|
1925
|
-
},
|
|
1919
|
+
return S !== void 0 && (p("rotateY", v, c), u("rotateY", v + S, c)), v + (S ?? 0);
|
|
1920
|
+
const T = S ?? Math.max(Sl, Math.abs(w) * vl);
|
|
1921
|
+
return p("rotateY", v, c), c += w, u("rotateY", v + T, c, "ease-in-out"), v + T;
|
|
1922
|
+
}, b = (v, y, S, w = "ease-in-out") => {
|
|
1923
|
+
for (const [T, H] of Object.entries(S))
|
|
1924
|
+
s(T) !== H && (p(T, v, s(T)), u(T, y, H, w), a[T] = H);
|
|
1925
|
+
}, E = (v, y, S) => {
|
|
1926
1926
|
const w = Ka([[i, l], ...y.through ?? [y.to]]);
|
|
1927
|
-
if (w.length < 2) return
|
|
1928
|
-
const
|
|
1929
|
-
f.push({ time:
|
|
1927
|
+
if (w.length < 2) return S;
|
|
1928
|
+
const T = g(S, mt(w[0].point, w[1].point)), H = w[w.length - 1].at, x = y.speed ?? wl[v] * Math.sqrt(r / 1.7), j = y.for ?? H / x * 1e3, R = ua(v, r), G = $t("ease-in-out"), Y = Math.min(Ml, j / 4);
|
|
1929
|
+
f.push({ time: T, value: v }), p("walking", T, 0), u("walking", T + Y, 1, "ease-out"), u("walking", T + j - Y, 1), u("walking", T + j, 0, "ease-in");
|
|
1930
1930
|
const ne = h;
|
|
1931
1931
|
let B = c;
|
|
1932
1932
|
for (let I = 0; ; I = Math.min(H, I + kl)) {
|
|
1933
|
-
const N =
|
|
1934
|
-
B += un(B, mt([0, 0],
|
|
1933
|
+
const N = T + Ra(G, I / H) * j, { point: K, direction: M } = Wa(w, I);
|
|
1934
|
+
B += un(B, mt([0, 0], M));
|
|
1935
1935
|
const _ = I === 0 ? p : u;
|
|
1936
1936
|
if (_("x", N, K[0]), _("z", N, K[1]), _("rotateY", N, B), _("walk", N, ne + I / R), I >= H) break;
|
|
1937
1937
|
}
|
|
1938
|
-
return h = ne + H / R, [i, l] = w[w.length - 1].point, c = B,
|
|
1939
|
-
}, O = [],
|
|
1938
|
+
return h = ne + H / R, [i, l] = w[w.length - 1].point, c = B, T + j;
|
|
1939
|
+
}, O = [], k = [];
|
|
1940
1940
|
let m = 0;
|
|
1941
|
-
for (const
|
|
1942
|
-
const y =
|
|
1943
|
-
let
|
|
1944
|
-
if (ao.includes(
|
|
1945
|
-
else if (
|
|
1946
|
-
else if (
|
|
1947
|
-
|
|
1948
|
-
else if (
|
|
1949
|
-
const w = kt[
|
|
1950
|
-
|
|
1951
|
-
const x = { ...a }, j = Math.max(1, Math.ceil(H * 16)), R = Array.from({ length: j + 1 }, (Y, ne) => cn(
|
|
1941
|
+
for (const v of n) {
|
|
1942
|
+
const y = v.at ?? m;
|
|
1943
|
+
let S = y;
|
|
1944
|
+
if (ao.includes(v.do)) S = E(v.do, v, y);
|
|
1945
|
+
else if (v.do === "face") S = g(y, typeof v.toward == "number" ? v.toward : mt([i, l], v.toward), v.for);
|
|
1946
|
+
else if (v.do === "spin")
|
|
1947
|
+
S = y + (v.for ?? 1e3), p("rotateY", y, c), c += (v.turns ?? 1) * 360, u("rotateY", S, c, "linear");
|
|
1948
|
+
else if (v.do === "dance") {
|
|
1949
|
+
const w = kt[v.dance], T = v.bpm ?? w.bpm, H = v.beats ?? (v.for !== void 0 ? v.for * T / 6e4 : w.beats);
|
|
1950
|
+
S = y + (v.for ?? H * 6e4 / T);
|
|
1951
|
+
const x = { ...a }, j = Math.max(1, Math.ceil(H * 16)), R = Array.from({ length: j + 1 }, (Y, ne) => cn(v.dance, H * ne / j, x).pose), G = Math.min(150, (S - y) / 4);
|
|
1952
1952
|
for (const Y of Object.keys(R[0])) {
|
|
1953
1953
|
const ne = s(Y, x);
|
|
1954
1954
|
Y === "turn" || Y === "roll" || R.every((B) => B[Y] === ne) || (p(Y, y, ne), R.slice(1).forEach((B, I) => {
|
|
1955
|
-
const N = y + (
|
|
1956
|
-
u(Y, N, ne + (B[Y] - ne) *
|
|
1955
|
+
const N = y + (S - y) * (I + 1) / j, K = Math.min(1, (N - y) / G), M = K * K * (3 - 2 * K);
|
|
1956
|
+
u(Y, N, ne + (B[Y] - ne) * M);
|
|
1957
1957
|
}), a[Y] = R[j][Y]);
|
|
1958
1958
|
}
|
|
1959
|
-
} else if (
|
|
1960
|
-
else if (
|
|
1961
|
-
p("x", y, i), p("z", y, l), [i, l] =
|
|
1962
|
-
else if (
|
|
1963
|
-
|
|
1964
|
-
const w = typeof
|
|
1965
|
-
b(y,
|
|
1966
|
-
} else if (
|
|
1967
|
-
const w = Or(
|
|
1968
|
-
let
|
|
1959
|
+
} else if (v.do === "hold") S = y + (v.for ?? 1e3);
|
|
1960
|
+
else if (v.do === "place")
|
|
1961
|
+
p("x", y, i), p("z", y, l), [i, l] = v.to, u("x", y + 1, i), u("z", y + 1, l), typeof v.toward == "number" && (p("rotateY", y, c), c = v.toward, u("rotateY", y + 1, c)), S = y + 1;
|
|
1962
|
+
else if (v.do === "pose") {
|
|
1963
|
+
S = y + (v.for ?? 500);
|
|
1964
|
+
const w = typeof v.pose == "string" ? Re[v.pose] : v.pose;
|
|
1965
|
+
b(y, S, w);
|
|
1966
|
+
} else if (v.do === "gag") {
|
|
1967
|
+
const w = Or(v.gag, { at: y, from: { ...a } });
|
|
1968
|
+
let T = w[0];
|
|
1969
1969
|
for (const H of w.slice(1))
|
|
1970
|
-
b(
|
|
1971
|
-
|
|
1972
|
-
} else if (
|
|
1973
|
-
|
|
1970
|
+
b(T.time, H.time, Object.fromEntries(Object.entries(H.pose).filter(([x, j]) => a[x] !== j)), H.easing ?? "ease-in-out"), T = H;
|
|
1971
|
+
S = T.time;
|
|
1972
|
+
} else if (v.do === "say") {
|
|
1973
|
+
S = y + (v.for ?? yl(v.say)), k.push({ text: v.say, start: y, end: S });
|
|
1974
1974
|
const w = { tilt: a["head.tilt"] ?? 0, left: a["brow.left"] ?? 0, right: a["brow.right"] ?? 0 };
|
|
1975
|
-
let
|
|
1976
|
-
for (let H = y + Ht; H <
|
|
1977
|
-
const x =
|
|
1975
|
+
let T = 0;
|
|
1976
|
+
for (let H = y + Ht; H < S - Ht / 2; H += Ht, T++) {
|
|
1977
|
+
const x = T % 2 === 0;
|
|
1978
1978
|
b(H - Ht / 2, H, { "head.tilt": w.tilt + (x ? 3 : -2), "brow.left": w.left + (x ? 0.25 : 0), "brow.right": w.right + (x ? 0.25 : 0) });
|
|
1979
1979
|
}
|
|
1980
|
-
|
|
1981
|
-
} else if (
|
|
1982
|
-
const w =
|
|
1983
|
-
|
|
1980
|
+
T > 0 && b(S - Ht / 2, S, { "head.tilt": w.tilt, "brow.left": w.left, "brow.right": w.right });
|
|
1981
|
+
} else if (v.do === "look") {
|
|
1982
|
+
const w = v.look ?? v.toward, T = r * 0.9, H = w === "camera" ? t.camera ?? [0, 1.6, 8] : w.length === 3 ? w : [w[0], T, w[1]];
|
|
1983
|
+
S = y + (v.for ?? 500), b(y, S, za({ x: i, z: l, heading: c, eyeHeight: T }, H), "ease-out");
|
|
1984
1984
|
}
|
|
1985
|
-
O.push({ do:
|
|
1985
|
+
O.push({ do: v.do, start: y, end: S }), m = S;
|
|
1986
1986
|
}
|
|
1987
1987
|
const A = `${t.scene}/${e}`;
|
|
1988
|
-
let P = [...d].map(([
|
|
1989
|
-
return f.length > 0 && P.push({ id: `${e}-gait`, target: A, property: "gait", keyframes: f }),
|
|
1988
|
+
let P = [...d].map(([v, y]) => ({ id: `${e}-${v}`, target: A, property: v, keyframes: Na(y) }));
|
|
1989
|
+
return f.length > 0 && P.push({ id: `${e}-gait`, target: A, property: "gait", keyframes: f }), k.length > 0 && (P = Io(A, P, k, { rest: { mouth: t.pose?.mouth ?? be.mouth ?? 0, mouthWidth: t.pose?.mouthWidth ?? be.mouthWidth ?? 1 } })), { tracks: P, duration: m, beats: O, end: { position: [i, l], heading: c, pose: { ...a } } };
|
|
1990
1990
|
}
|
|
1991
1991
|
function fs(e, n, t = [0, 0, 0]) {
|
|
1992
1992
|
const o = e.filter((a) => a.target === n), r = new ve({ id: `${n}-position`, tracks: o });
|
|
@@ -2010,8 +2010,8 @@ function gf(e, n) {
|
|
|
2010
2010
|
})(), c = ["head.turn", "head.nod", "lookX", "lookY"], h = { "head.turn": [], "head.nod": [], lookX: [], lookY: [] };
|
|
2011
2011
|
for (let d = n.start; ; d = Math.min(n.end, d + r)) {
|
|
2012
2012
|
const f = s.getStateAtTime(d).values.get(t), u = (g, b) => {
|
|
2013
|
-
const
|
|
2014
|
-
return typeof
|
|
2013
|
+
const E = f?.get(g);
|
|
2014
|
+
return typeof E == "number" ? E : b;
|
|
2015
2015
|
}, p = za({ x: u("x", a[0]), z: u("z", a[2]), heading: u("rotateY", 0), eyeHeight: u("y", a[1]) + o * 0.9 }, l(d));
|
|
2016
2016
|
for (const g of c) h[g].push({ time: d, value: p[g] ?? 0 });
|
|
2017
2017
|
if (d >= n.end) break;
|
|
@@ -2034,8 +2034,8 @@ function pf(e) {
|
|
|
2034
2034
|
for (let u = 0; u < n; u++) {
|
|
2035
2035
|
let p = [t, o], g = -1 / 0;
|
|
2036
2036
|
for (let b = 0; b < 24; b++) {
|
|
2037
|
-
const
|
|
2038
|
-
if (m > g && (g = m, p =
|
|
2037
|
+
const E = Math.sqrt(d()) * r * Math.max(1, Math.sqrt(n) * 0.9), O = d() * Math.PI * 2, k = [t + Math.cos(O) * E, o + Math.sin(O) * E], m = f.length === 0 ? 1 / 0 : Math.min(...f.map((A) => Math.hypot(A[0] - k[0], A[1] - k[1])));
|
|
2038
|
+
if (m > g && (g = m, p = k), m >= r) break;
|
|
2039
2039
|
}
|
|
2040
2040
|
f.push(p), s.push({ position: p, heading: 0 });
|
|
2041
2041
|
}
|
|
@@ -2090,10 +2090,10 @@ const Da = 150, Tl = { pencil: 44, eraser: 30 };
|
|
|
2090
2090
|
function La(e, n, t = {}, o) {
|
|
2091
2091
|
const r = t.tool ?? "pencil", a = t.skin ?? "#f1c9a5", s = t.outline ?? "#2f2f33", i = t.scale ?? 1, l = Math.min(1, Math.max(0, t.lift ?? 0)), c = (t.angle ?? -30) * Math.PI / 180, h = o ? o.nudge(0.6) : { x: 0, y: 0 }, d = Da * i * (1 + 0.05 * l);
|
|
2092
2092
|
l > 0 && (e.save(), e.fillStyle = s, e.globalAlpha = 0.15 * l, e.beginPath(), e.ellipse(n.x, n.y, 9 * i, 4 * i, 0, 0, Math.PI * 2), e.fill(), e.restore());
|
|
2093
|
-
const f = { x: n.x + h.x + 6 * l * i, y: n.y + h.y - 18 * l * i }, u = we.pencilGrip, p = (
|
|
2094
|
-
const y =
|
|
2095
|
-
return { pinch:
|
|
2096
|
-
}, g = Go(u, { size: d }), b = c - p(g).direction,
|
|
2093
|
+
const f = { x: n.x + h.x + 6 * l * i, y: n.y + h.y - 18 * l * i }, u = we.pencilGrip, p = (v) => {
|
|
2094
|
+
const y = v.fingers.thumb, S = v.fingers.index, w = v.fingers.middle, T = us([y.points[3], S.points[3], w.points[3]]), H = us([y.points[1], S.points[0]]), x = (y.depths[3] + S.depths[3] + w.depths[3]) / 3;
|
|
2095
|
+
return { pinch: T, direction: Math.atan2(H.y - T.y, H.x - T.x), depth: x };
|
|
2096
|
+
}, g = Go(u, { size: d }), b = c - p(g).direction, E = Go(u, { size: d, angle: b * 180 / Math.PI }), O = p(E), k = Tl[r] * i, m = { x: O.pinch.x - Math.cos(c) * k, y: O.pinch.y - Math.sin(c) * k }, A = { x: f.x - m.x, y: f.y - m.y }, P = E.axes.up;
|
|
2097
2097
|
Al(e, A, { x: -P.x, y: -P.y }, d, t.arm ?? 300 * i, a, t.sleeve ?? "#5b7db1", s), Hr(e, A, u, {
|
|
2098
2098
|
size: d,
|
|
2099
2099
|
angle: b * 180 / Math.PI,
|
|
@@ -2113,9 +2113,9 @@ const us = (e) => ({
|
|
|
2113
2113
|
y: e.reduce((n, t) => n + t.y, 0) / e.length
|
|
2114
2114
|
});
|
|
2115
2115
|
function Al(e, n, t, o, r, a, s, i) {
|
|
2116
|
-
const l = { x: -t.y, y: t.x }, c = o * 0.15, h = (g, b,
|
|
2117
|
-
x: n.x + t.x * g + l.x * b *
|
|
2118
|
-
y: n.y + t.y * g + l.y * b *
|
|
2116
|
+
const l = { x: -t.y, y: t.x }, c = o * 0.15, h = (g, b, E) => ({
|
|
2117
|
+
x: n.x + t.x * g + l.x * b * E,
|
|
2118
|
+
y: n.y + t.y * g + l.y * b * E
|
|
2119
2119
|
}), d = h(r, 0, 0), f = (g) => {
|
|
2120
2120
|
const b = e.createLinearGradient(n.x, n.y, d.x, d.y);
|
|
2121
2121
|
return b.addColorStop(0, g), b.addColorStop(0.6, g), b.addColorStop(1, Pl(g)), b;
|
|
@@ -2128,7 +2128,7 @@ function mf(e, n, t = {}) {
|
|
|
2128
2128
|
const o = t.offstage ?? { x: 2e3, y: 1400 }, r = t.enter ?? 450, a = t.exit ?? 450, s = t.linger ?? 1500, i = [...e].filter((g) => g.path.length > 0).sort((g, b) => g.start - b.start), l = (g) => g.tool ?? "pencil", c = (g) => {
|
|
2129
2129
|
const b = Math.min(1, Math.max(0, g));
|
|
2130
2130
|
return b * b * (3 - 2 * b);
|
|
2131
|
-
}, h = (g, b,
|
|
2131
|
+
}, h = (g, b, E) => ({ x: g.x + (b.x - g.x) * E, y: g.y + (b.y - g.y) * E }), d = i.find((g) => n >= g.start && n <= g.end);
|
|
2132
2132
|
if (d) {
|
|
2133
2133
|
const g = d.end - d.start, b = g > 0 ? (n - d.start) / g : 1;
|
|
2134
2134
|
return { at: vo(d.path, b), tool: l(d), lift: 0, drawing: !0 };
|
|
@@ -2306,30 +2306,30 @@ function $n(e) {
|
|
|
2306
2306
|
};
|
|
2307
2307
|
}
|
|
2308
2308
|
function xo(e, n, { ground: t, every: o, floors: r }) {
|
|
2309
|
-
if (r.every((
|
|
2310
|
-
const a = e.find((
|
|
2311
|
-
const m = t + i(
|
|
2309
|
+
if (r.every((k) => k.windows.length === 0)) return e;
|
|
2310
|
+
const a = e.find((k) => k.target === n && k.property === "y"), s = new ve({ id: `${n}-ride`, tracks: a ? [a] : [] }), i = (k) => a ? Number(s.getStateAtTime(k).values.get(n)?.get("y") ?? 0) : 0, l = (k) => {
|
|
2311
|
+
const m = t + i(k);
|
|
2312
2312
|
return r.findIndex((A) => Math.abs(A.top - m) < 0.5);
|
|
2313
|
-
}, c = (a?.keyframes ?? []).map((
|
|
2314
|
-
const m = (
|
|
2313
|
+
}, c = (a?.keyframes ?? []).map((k) => k.time), h = (k) => {
|
|
2314
|
+
const m = (S) => S < 0 ? 0 : r[S].offset(k), A = l(k);
|
|
2315
2315
|
if (A >= 0) return m(A);
|
|
2316
|
-
if (Math.abs(i(
|
|
2317
|
-
const P = (
|
|
2318
|
-
return
|
|
2319
|
-
}, d = r.flatMap((
|
|
2316
|
+
if (Math.abs(i(k)) < 0.5) return 0;
|
|
2317
|
+
const P = (S) => l(S) >= 0 || Math.abs(i(S)) < 0.5, v = [...c].reverse().find((S) => S <= k && P(S)), y = c.find((S) => S >= k && P(S));
|
|
2318
|
+
return v === void 0 && y === void 0 ? 0 : v === void 0 ? m(l(y)) : y === void 0 || y === v ? m(l(v)) : m(l(v)) + (m(l(y)) - m(l(v))) * (k - v) / (y - v);
|
|
2319
|
+
}, d = r.flatMap((k) => k.windows), f = (k, m) => d.some((A) => A.start < m && A.end > k) || h(k) !== h(m), u = a ? [...a.keyframes] : [{ time: 0, value: 0 }], p = [{ ...u[0], value: u[0].value + h(u[0].time) }], g = (k, m) => {
|
|
2320
2320
|
const A = /* @__PURE__ */ new Set([m]);
|
|
2321
|
-
for (let P =
|
|
2322
|
-
for (const P of d) for (const
|
|
2323
|
-
for (const P of [...A].sort((
|
|
2321
|
+
for (let P = k + o; P < m; P += o) A.add(P);
|
|
2322
|
+
for (const P of d) for (const v of [P.start, P.end]) v > k && v < m && A.add(v);
|
|
2323
|
+
for (const P of [...A].sort((v, y) => v - y)) p.push({ time: P, value: i(P) + h(P) });
|
|
2324
2324
|
};
|
|
2325
|
-
for (let
|
|
2326
|
-
const m = u[
|
|
2327
|
-
f(m, A) ? g(m, A) : p.push({ ...u[
|
|
2325
|
+
for (let k = 1; k < u.length; k++) {
|
|
2326
|
+
const m = u[k - 1].time, A = u[k].time;
|
|
2327
|
+
f(m, A) ? g(m, A) : p.push({ ...u[k], value: u[k].value + h(A) });
|
|
2328
2328
|
}
|
|
2329
|
-
const b = u[u.length - 1].time,
|
|
2330
|
-
|
|
2329
|
+
const b = u[u.length - 1].time, E = Math.max(b, ...d.map((k) => k.end));
|
|
2330
|
+
E > b && g(b, E);
|
|
2331
2331
|
const O = { id: a?.id ?? `${n}-y`, target: n, property: "y", keyframes: p };
|
|
2332
|
-
return a ? e.map((
|
|
2332
|
+
return a ? e.map((k) => k === a ? O : k) : [...e, O];
|
|
2333
2333
|
}
|
|
2334
2334
|
function Mt(e) {
|
|
2335
2335
|
const n = e.indexOf(":");
|
|
@@ -2390,15 +2390,15 @@ function Sf(e) {
|
|
|
2390
2390
|
const n = { ...jl, ...e.theme }, t = e.code.replace(/\t/g, " ").replace(/\n$/, "").split(`
|
|
2391
2391
|
`), o = e.fontSize ?? 16, r = (e.lineHeight ?? 1.6) * o, a = (e.charWidth ?? 0.6) * o, s = e.padding ?? 12, i = e.lineNumbers === !1 ? 0 : (String(t.length).length + 2) * a, l = Math.max(1, ...t.map((I) => I.length)), c = e.width ?? s * 2 + i + l * a, h = s * 2 + t.length * r, d = e.x + s + i, f = new Set(e.hidden ?? []), u = e.language ?? "plain";
|
|
2392
2392
|
if (!io.includes(u)) throw new Error(`codePanel: ${ce("language", u, io)}`);
|
|
2393
|
-
const p = t.map((I) => Wl(I, u).flatMap((N) => Array.from(N.text, () => n[N.kind]))), g = Ft(), b = $n(g),
|
|
2393
|
+
const p = t.map((I) => Wl(I, u).flatMap((N) => Array.from(N.text, () => n[N.kind]))), g = Ft(), b = $n(g), E = [], O = /* @__PURE__ */ new Map(), k = [], m = [], A = (I) => {
|
|
2394
2394
|
if (!Number.isInteger(I) || I < 1 || I > t.length) throw new Error(`codePanel: no line ${I} (it has ${t.length})`);
|
|
2395
|
-
}, P = g.tween,
|
|
2396
|
-
A(I), P(`line.${I}.${N}`, K,
|
|
2397
|
-
},
|
|
2398
|
-
let
|
|
2395
|
+
}, P = g.tween, v = g.last, y = (I, N, K, M, _, V = 300) => {
|
|
2396
|
+
A(I), P(`line.${I}.${N}`, K, M, _, V);
|
|
2397
|
+
}, S = (I, N) => E.filter((K) => K.line < I && K.closed <= N).length, w = me, T = (I) => e.y + s + (I - 1) * r, H = (I) => Array.isArray(I) ? I : [I], x = (I, N, K) => {
|
|
2398
|
+
let M = -1;
|
|
2399
2399
|
for (let _ = 0; _ < K; _++)
|
|
2400
|
-
if (
|
|
2401
|
-
return
|
|
2400
|
+
if (M = t[I - 1].indexOf(N, M + 1), M < 0) throw new Error(`codePanel: line ${I} has no ${K > 1 ? `${K}th ` : ""}"${N}"`);
|
|
2401
|
+
return M;
|
|
2402
2402
|
}, j = {};
|
|
2403
2403
|
t.forEach((I, N) => {
|
|
2404
2404
|
const K = N + 1;
|
|
@@ -2421,7 +2421,7 @@ function Sf(e) {
|
|
|
2421
2421
|
actions: Ga
|
|
2422
2422
|
},
|
|
2423
2423
|
draw(I, N) {
|
|
2424
|
-
const K = N.props ?? {},
|
|
2424
|
+
const K = N.props ?? {}, M = (F) => Number(K[F] ?? j[F]), _ = s + i, V = (F) => s + (F - 1) * r - M(`line.${F}.shift`) * r;
|
|
2425
2425
|
I.fillStyle = n.background, gs(I, 0, 0, c, h, 8), I.fill(), I.font = `${o}px ${n.font}`, I.textBaseline = "middle", I.textAlign = "left";
|
|
2426
2426
|
const ee = (F, Q, ae, C, X) => {
|
|
2427
2427
|
const D = t[F - 1];
|
|
@@ -2429,14 +2429,14 @@ function Sf(e) {
|
|
|
2429
2429
|
D[Z] !== " " && (I.fillStyle = p[F - 1][Z], I.fillText(D[Z], C + (Z - Q) * a, X));
|
|
2430
2430
|
};
|
|
2431
2431
|
I.save(), gs(I, 0, 0, c, h, 8), I.clip(), t.forEach((F, Q) => {
|
|
2432
|
-
const ae = Q + 1, C =
|
|
2432
|
+
const ae = Q + 1, C = M(`line.${ae}.wipe`);
|
|
2433
2433
|
if (C >= 1) return;
|
|
2434
|
-
const X = V(ae), D = X + r / 2, Z = Math.max(1, F.length) * a, se = Math.round(
|
|
2434
|
+
const X = V(ae), D = X + r / 2, Z = Math.max(1, F.length) * a, se = Math.round(M(`line.${ae}.reveal`) * F.length), re = O.get(ae) ?? { style: "wipe", from: "left" };
|
|
2435
2435
|
I.save(), C > 0 && Cl(I, re, C, { left: _ - i, top: X, width: i + Z + a, height: r }, c);
|
|
2436
|
-
const ie =
|
|
2436
|
+
const ie = M(`line.${ae}.highlight`);
|
|
2437
2437
|
ie > 0 && (I.globalAlpha *= Math.min(1, ie), I.fillStyle = n.highlight, I.fillRect(_ - a / 2, X, Z + a, r), I.globalAlpha /= Math.min(1, ie)), i > 0 && se > 0 && (I.fillStyle = n.gutter, I.textAlign = "right", I.fillText(String(ae), _ - a, D), I.textAlign = "left");
|
|
2438
2438
|
const $ = [
|
|
2439
|
-
...
|
|
2439
|
+
...k.filter((q) => q.line === ae).map((q) => ({ column: q.column, length: q.text.length, piece: q, insert: void 0 })),
|
|
2440
2440
|
...m.filter((q) => q.line === ae).map((q) => ({ column: q.column, length: 0, piece: void 0, insert: q }))
|
|
2441
2441
|
].sort((q, le) => q.column - le.column || q.length - le.length);
|
|
2442
2442
|
let z = 0, U = _;
|
|
@@ -2444,49 +2444,49 @@ function Sf(e) {
|
|
|
2444
2444
|
ee(ae, z, Math.min(q.column, se), U, D), U += (q.column - z) * a;
|
|
2445
2445
|
let le = q.length, L = "";
|
|
2446
2446
|
if (q.piece) {
|
|
2447
|
-
const W = q.piece.written ?? "", J =
|
|
2448
|
-
W && J > 0 ? (L = W.slice(0, Math.round(J * W.length)), le = q.length + (W.length - q.length) * Math.min(1, J * 2)) : le = q.length * (1 -
|
|
2449
|
-
} else q.insert && (le = q.insert.chars *
|
|
2447
|
+
const W = q.piece.written ?? "", J = M(`piece.${q.piece.id}.write`);
|
|
2448
|
+
W && J > 0 ? (L = W.slice(0, Math.round(J * W.length)), le = q.length + (W.length - q.length) * Math.min(1, J * 2)) : le = q.length * (1 - M(`piece.${q.piece.id}.away`));
|
|
2449
|
+
} else q.insert && (le = q.insert.chars * M(`insert.${q.insert.id}.open`), q.insert.text && (L = q.insert.text.slice(0, Math.round(M(`insert.${q.insert.id}.type`) * q.insert.text.length))));
|
|
2450
2450
|
I.fillStyle = n.text;
|
|
2451
2451
|
for (let W = 0; W < L.length; W++) L[W] !== " " && I.fillText(L[W], U + W * a, D);
|
|
2452
2452
|
U += le * a, z = q.column + q.length;
|
|
2453
2453
|
}
|
|
2454
2454
|
ee(ae, z, Math.max(z, se), U, D);
|
|
2455
|
-
const te =
|
|
2455
|
+
const te = M(`line.${ae}.strike`);
|
|
2456
2456
|
te > 0 && (I.strokeStyle = n.strike, I.lineWidth = Math.max(1.5, o / 10), I.beginPath(), I.moveTo(_, D), I.lineTo(_ + Z * Math.min(1, te), D), I.stroke()), I.restore();
|
|
2457
2457
|
});
|
|
2458
|
-
for (const F of
|
|
2459
|
-
const Q =
|
|
2460
|
-
if (Q <= 0 ||
|
|
2461
|
-
const ae = _ + (F.column + F.text.length / 2) * a +
|
|
2462
|
-
I.save(), I.globalAlpha = Math.min(1, Q), I.translate(ae, C), I.rotate(
|
|
2458
|
+
for (const F of k) {
|
|
2459
|
+
const Q = M(`piece.${F.id}.opacity`);
|
|
2460
|
+
if (Q <= 0 || M(`line.${F.line}.wipe`) >= 1) continue;
|
|
2461
|
+
const ae = _ + (F.column + F.text.length / 2) * a + M(`piece.${F.id}.x`), C = V(F.line) + r / 2 + M(`piece.${F.id}.y`);
|
|
2462
|
+
I.save(), I.globalAlpha = Math.min(1, Q), I.translate(ae, C), I.rotate(M(`piece.${F.id}.rotate`) * Math.PI / 180), ee(F.line, F.column, F.column + F.text.length, -F.text.length * a / 2, 0), I.restore();
|
|
2463
2463
|
}
|
|
2464
2464
|
I.restore();
|
|
2465
2465
|
}
|
|
2466
2466
|
}, G = (I) => {
|
|
2467
|
-
const { kind: N, rest: K } = Mt(I),
|
|
2467
|
+
const { kind: N, rest: K } = Mt(I), M = (_) => et("codePanel", I, nn, _);
|
|
2468
2468
|
if (N === "box") {
|
|
2469
|
-
if (K) throw
|
|
2469
|
+
if (K) throw M("box takes no arguments");
|
|
2470
2470
|
return { kind: N };
|
|
2471
2471
|
}
|
|
2472
2472
|
if (N === "line") {
|
|
2473
|
-
if (!/^\d+$/.test(K)) throw
|
|
2473
|
+
if (!/^\d+$/.test(K)) throw M("write it line:N");
|
|
2474
2474
|
return { kind: N, n: Number(K) };
|
|
2475
2475
|
}
|
|
2476
2476
|
if (N === "token") {
|
|
2477
2477
|
const _ = /^(\d+)(?:#(\d+))?:(.+)$/.exec(K);
|
|
2478
|
-
if (!_) throw
|
|
2478
|
+
if (!_) throw M("write it token:N:TEXT, or token:N#K:TEXT for the Kth");
|
|
2479
2479
|
return { kind: N, n: Number(_[1]), occurrence: _[2] ? Number(_[2]) : 1, text: _[3] };
|
|
2480
2480
|
}
|
|
2481
2481
|
if (N === "spot") {
|
|
2482
2482
|
const _ = /^(\d+):(\d+)(?::(\d+))?$/.exec(K);
|
|
2483
|
-
if (!_) throw
|
|
2483
|
+
if (!_) throw M("write it spot:N:C, or spot:N:C:W for W characters");
|
|
2484
2484
|
return { kind: N, n: Number(_[1]), column: Number(_[2]), width: _[3] ? Number(_[3]) : 1 };
|
|
2485
2485
|
}
|
|
2486
|
-
throw
|
|
2487
|
-
}, Y = (I, N, K,
|
|
2486
|
+
throw M();
|
|
2487
|
+
}, Y = (I, N, K, M = !1) => {
|
|
2488
2488
|
const _ = Array.isArray(N) ? N : [N];
|
|
2489
|
-
if (_.length === 0 ||
|
|
2489
|
+
if (_.length === 0 || M && _.length > 1) throw new Error(`codePanel.edit: ${I} takes ${M ? "one" : "at least one"} ${K} anchor`);
|
|
2490
2490
|
return _.map((V) => {
|
|
2491
2491
|
const ee = G(V);
|
|
2492
2492
|
if (ee.kind !== K) throw new Error(`codePanel.edit: ${I} takes ${K} anchors (${K}:…), not "${V}"`);
|
|
@@ -2502,35 +2502,35 @@ function Sf(e) {
|
|
|
2502
2502
|
lines: t,
|
|
2503
2503
|
box: w(e.x, e.y, c, h),
|
|
2504
2504
|
line(I, N = 1 / 0) {
|
|
2505
|
-
return A(I), w(d,
|
|
2505
|
+
return A(I), w(d, T(I) - S(I, N) * r, Math.max(1, t[I - 1].length) * a, r);
|
|
2506
2506
|
},
|
|
2507
|
-
token(I, N, K = 1,
|
|
2507
|
+
token(I, N, K = 1, M = 1 / 0) {
|
|
2508
2508
|
A(I);
|
|
2509
2509
|
const _ = x(I, N, K);
|
|
2510
|
-
return w(d + _ * a,
|
|
2510
|
+
return w(d + _ * a, T(I) - S(I, M) * r, N.length * a, r);
|
|
2511
2511
|
},
|
|
2512
2512
|
highlight(I, N) {
|
|
2513
2513
|
for (const K of H(I)) {
|
|
2514
|
-
const
|
|
2515
|
-
y(K, "highlight",
|
|
2514
|
+
const M = v(`line.${K}.highlight`, 0);
|
|
2515
|
+
y(K, "highlight", M, N.on === !1 ? 0 : 1, N, 200);
|
|
2516
2516
|
}
|
|
2517
2517
|
return B;
|
|
2518
2518
|
},
|
|
2519
2519
|
strike(I, N) {
|
|
2520
|
-
for (const K of H(I)) y(K, "strike",
|
|
2520
|
+
for (const K of H(I)) y(K, "strike", v(`line.${K}.strike`, 0), 1, N);
|
|
2521
2521
|
return B;
|
|
2522
2522
|
},
|
|
2523
2523
|
remove(I, N) {
|
|
2524
|
-
const K = H(I),
|
|
2525
|
-
if (!ro.includes(
|
|
2526
|
-
const _ =
|
|
2524
|
+
const K = H(I), M = N.style ?? "wipe";
|
|
2525
|
+
if (!ro.includes(M)) throw new Error(`codePanel.remove: ${ce("style", M, ro)}`);
|
|
2526
|
+
const _ = M === "wipe" ? 300 : 450, V = N.at + (N.duration ?? _), ee = N.close ?? 250;
|
|
2527
2527
|
for (const F of K)
|
|
2528
|
-
y(F, "wipe", 0, 1, { ...N, easing: N.easing ?? (
|
|
2528
|
+
y(F, "wipe", 0, 1, { ...N, easing: N.easing ?? (M === "fly" ? "ease-in" : void 0) }, _), O.set(F, { style: M, from: N.from ?? "left" }), E.push({ line: F, closed: V + ee });
|
|
2529
2529
|
for (let F = 1; F <= t.length; F++) {
|
|
2530
2530
|
if (K.includes(F)) continue;
|
|
2531
2531
|
const Q = K.filter((C) => C < F).length;
|
|
2532
2532
|
if (Q === 0) continue;
|
|
2533
|
-
const ae =
|
|
2533
|
+
const ae = v(`line.${F}.shift`, 0);
|
|
2534
2534
|
y(F, "shift", ae, ae + Q, { at: V, duration: ee, easing: "ease-in-out" });
|
|
2535
2535
|
}
|
|
2536
2536
|
return B;
|
|
@@ -2544,15 +2544,15 @@ function Sf(e) {
|
|
|
2544
2544
|
if (F.kind !== "token") throw new Error(`codePanel.piece: a piece is a word, token:N:TEXT, not "${I}"`);
|
|
2545
2545
|
return B.piece(F.n, F.text, F.occurrence);
|
|
2546
2546
|
}
|
|
2547
|
-
const
|
|
2547
|
+
const M = I;
|
|
2548
2548
|
if (N === void 0) throw new Error('codePanel.piece: which word? piece(n, text) or piece("token:N:TEXT")');
|
|
2549
|
-
A(
|
|
2550
|
-
const _ = x(
|
|
2549
|
+
A(M);
|
|
2550
|
+
const _ = x(M, N, K), V = k.find((F) => F.line === M && F.column === _ && F.text === N);
|
|
2551
2551
|
if (V) return V;
|
|
2552
|
-
if (
|
|
2553
|
-
throw new Error(`codePanel: "${N}" on line ${
|
|
2554
|
-
const ee = { id:
|
|
2555
|
-
|
|
2552
|
+
if (k.some((F) => F.line === M && _ < F.column + F.text.length && F.column < _ + N.length))
|
|
2553
|
+
throw new Error(`codePanel: "${N}" on line ${M} overlaps another piece`);
|
|
2554
|
+
const ee = { id: k.length + 1, line: M, column: _, text: N, home: B.token(M, N, K, 0) };
|
|
2555
|
+
k.push(ee);
|
|
2556
2556
|
for (const F of ["x", "y", "rotate", "write", "away"]) j[`piece.${ee.id}.${F}`] = 0;
|
|
2557
2557
|
return j[`piece.${ee.id}.opacity`] = 1, ee;
|
|
2558
2558
|
},
|
|
@@ -2568,33 +2568,33 @@ function Sf(e) {
|
|
|
2568
2568
|
write(I, N, K) {
|
|
2569
2569
|
return I.written = N, P(`piece.${I.id}.write`, 0, 1, { duration: Math.max(1, N.length) * 70, ...K }), B;
|
|
2570
2570
|
},
|
|
2571
|
-
spot(I, N, K = 1,
|
|
2571
|
+
spot(I, N, K = 1, M = 1 / 0) {
|
|
2572
2572
|
A(I);
|
|
2573
|
-
const _ = m.filter((V) => V.line === I && V.column <= N && V.at <=
|
|
2574
|
-
return w(d + (N + _) * a,
|
|
2573
|
+
const _ = m.filter((V) => V.line === I && V.column <= N && V.at <= M).reduce((V, ee) => V + ee.chars, 0);
|
|
2574
|
+
return w(d + (N + _) * a, T(I) - S(I, M) * r, K * a, r);
|
|
2575
2575
|
},
|
|
2576
|
-
insert(I, N, K,
|
|
2576
|
+
insert(I, N, K, M) {
|
|
2577
2577
|
A(I);
|
|
2578
|
-
const _ = { id: m.length + 1, line: I, column: N, chars: K.length, text: K, at:
|
|
2578
|
+
const _ = { id: m.length + 1, line: I, column: N, chars: K.length, text: K, at: M.at };
|
|
2579
2579
|
m.push(_), j[`insert.${_.id}.open`] = 0, j[`insert.${_.id}.type`] = 0;
|
|
2580
|
-
const V =
|
|
2581
|
-
return P(`insert.${_.id}.open`, 0, 1, { at:
|
|
2580
|
+
const V = M.duration ?? K.length * 70;
|
|
2581
|
+
return P(`insert.${_.id}.open`, 0, 1, { at: M.at, duration: V * 0.6, easing: "ease-out" }), P(`insert.${_.id}.type`, 0, 1, { at: M.at, duration: V }), B;
|
|
2582
2582
|
},
|
|
2583
|
-
drop(I, N, K,
|
|
2583
|
+
drop(I, N, K, M) {
|
|
2584
2584
|
A(N);
|
|
2585
|
-
const _ =
|
|
2586
|
-
return m.push(Q), j[`insert.${Q.id}.open`] = 0, P(`insert.${Q.id}.open`, 0, 1, { at:
|
|
2585
|
+
const _ = M.duration ?? 250, V = N === I.line, ee = M.easing ?? (V ? "linear" : "ease-out"), F = B.landing(I, N, K, M.at), Q = { id: m.length + 1, line: N, column: K, chars: I.text.length, at: M.at };
|
|
2586
|
+
return m.push(Q), j[`insert.${Q.id}.open`] = 0, P(`insert.${Q.id}.open`, 0, 1, { at: M.at, duration: _, easing: V ? ee : "ease-out" }), P(`piece.${I.id}.away`, v(`piece.${I.id}.away`, 0), 1, { at: M.at, duration: _, easing: V ? ee : "ease-in-out" }), b.cutAfter(I, M.at), B.move(I, { at: M.at, duration: _, easing: ee, to: { x: F.x, y: F.y } }), P(`piece.${I.id}.rotate`, g.valueAt(`piece.${I.id}.rotate`, M.at), 0, { at: M.at, duration: _ }), B;
|
|
2587
2587
|
},
|
|
2588
|
-
landing(I, N, K,
|
|
2589
|
-
const _ = B.spot(N, K, I.text.length,
|
|
2588
|
+
landing(I, N, K, M = 1 / 0) {
|
|
2589
|
+
const _ = B.spot(N, K, I.text.length, M), V = N === I.line && K > I.column ? I.text.length * a : 0;
|
|
2590
2590
|
return w(_.left - V, _.top, _.width, _.height);
|
|
2591
2591
|
},
|
|
2592
2592
|
ride(I, N, K) {
|
|
2593
|
-
const
|
|
2593
|
+
const M = t.map((_, V) => {
|
|
2594
2594
|
const ee = g.keys(`line.${V + 1}.shift`) ?? [];
|
|
2595
|
-
return { top:
|
|
2595
|
+
return { top: T(V + 1), offset: (F) => -jo(ee, F) * r, windows: Wt(ee) };
|
|
2596
2596
|
});
|
|
2597
|
-
return xo(I, N, { ground: K.ground, every: K.every ?? Qe, floors:
|
|
2597
|
+
return xo(I, N, { ground: K.ground, every: K.every ?? Qe, floors: M });
|
|
2598
2598
|
},
|
|
2599
2599
|
tracks: g.tracks,
|
|
2600
2600
|
anchor(I, N = 1 / 0) {
|
|
@@ -2602,12 +2602,12 @@ function Sf(e) {
|
|
|
2602
2602
|
return K.kind === "box" ? B.box : K.kind === "line" ? B.line(K.n, N) : K.kind === "token" ? B.token(K.n, K.text, K.occurrence, N) : B.spot(K.n, K.column, K.width, N);
|
|
2603
2603
|
},
|
|
2604
2604
|
edit(I, N, K) {
|
|
2605
|
-
const
|
|
2606
|
-
if (I === "highlight") return B.highlight(
|
|
2607
|
-
if (I === "strike") return B.strike(
|
|
2608
|
-
if (I === "remove") return B.remove(
|
|
2605
|
+
const M = () => Y(I, N, "line").map((_) => _.n);
|
|
2606
|
+
if (I === "highlight") return B.highlight(M(), K);
|
|
2607
|
+
if (I === "strike") return B.strike(M(), K);
|
|
2608
|
+
if (I === "remove") return B.remove(M(), K);
|
|
2609
2609
|
if (I === "type") {
|
|
2610
|
-
for (const _ of
|
|
2610
|
+
for (const _ of M()) B.type(_, K);
|
|
2611
2611
|
return B;
|
|
2612
2612
|
}
|
|
2613
2613
|
if (I === "insert") {
|
|
@@ -2785,38 +2785,38 @@ const Nn = '"Patrick Hand", "Segoe Print", "Bradley Hand", "Comic Sans MS", "Cha
|
|
|
2785
2785
|
function Mf(e) {
|
|
2786
2786
|
const n = typeof e.theme == "string" ? e.theme : "whiteboard";
|
|
2787
2787
|
if (!(n in Ut)) throw new Error(`whiteboard: ${ce("theme", n, Object.keys(Ut))}`);
|
|
2788
|
-
const t = typeof e.theme == "object" ? { ...Ut.whiteboard, ...e.theme } : Ut[n], o = e.fontSize ?? 28, r = e.charWidth ?? 0.55, a = (m) => m === void 0 ? t.ink : t.colors[m] ?? m, s = (m) => me(e.x + m.left, e.y + m.top, m.width, m.height), i = Ft(), l = $n(i), c = {}, h = /* @__PURE__ */ new Map(), d = [], f = [], u = (m, A, P,
|
|
2788
|
+
const t = typeof e.theme == "object" ? { ...Ut.whiteboard, ...e.theme } : Ut[n], o = e.fontSize ?? 28, r = e.charWidth ?? 0.55, a = (m) => m === void 0 ? t.ink : t.colors[m] ?? m, s = (m) => me(e.x + m.left, e.y + m.top, m.width, m.height), i = Ft(), l = $n(i), c = {}, h = /* @__PURE__ */ new Map(), d = [], f = [], u = (m, A, P, v) => {
|
|
2789
2789
|
const y = h.get(m);
|
|
2790
|
-
if (!y || y.kind !== "text") throw et("whiteboard",
|
|
2791
|
-
let
|
|
2792
|
-
for (let
|
|
2793
|
-
if (
|
|
2790
|
+
if (!y || y.kind !== "text") throw et("whiteboard", v, De, `there is no text "${m}" (texts: ${p().join(", ") || "none"})`);
|
|
2791
|
+
let S = -1;
|
|
2792
|
+
for (let T = 0; T < P; T++)
|
|
2793
|
+
if (S = y.item.text.indexOf(A, S + 1), S < 0) throw et("whiteboard", v, De, `text "${m}" has no ${P > 1 ? `${P}th ` : ""}"${A}"`);
|
|
2794
2794
|
const w = y.size * r;
|
|
2795
|
-
return { column:
|
|
2795
|
+
return { column: S, box: me(y.box.left + S * w, y.box.top, A.length * w, y.box.height) };
|
|
2796
2796
|
}, p = () => [...h.values()].filter((m) => m.kind === "text").map((m) => m.item.id), g = (m) => {
|
|
2797
|
-
const { kind: A, rest: P } = Mt(m),
|
|
2797
|
+
const { kind: A, rest: P } = Mt(m), v = (y) => et("whiteboard", m, De, y);
|
|
2798
2798
|
if (A === "box") {
|
|
2799
|
-
if (P) throw
|
|
2799
|
+
if (P) throw v("box takes no arguments");
|
|
2800
2800
|
return { kind: A };
|
|
2801
2801
|
}
|
|
2802
2802
|
if (A === "text" || A === "mark") {
|
|
2803
|
-
if (!P) throw
|
|
2803
|
+
if (!P) throw v(`write it ${A}:ID`);
|
|
2804
2804
|
return { kind: A, id: P };
|
|
2805
2805
|
}
|
|
2806
2806
|
if (A === "term") {
|
|
2807
2807
|
const y = /^([^:#]+)(?:#(\d+))?:(.+)$/.exec(P);
|
|
2808
|
-
if (!y) throw
|
|
2808
|
+
if (!y) throw v("write it term:ID:TEXT, or term:ID#K:TEXT for the Kth");
|
|
2809
2809
|
return { kind: A, id: y[1], occurrence: y[2] ? Number(y[2]) : 1, text: y[3] };
|
|
2810
2810
|
}
|
|
2811
|
-
throw
|
|
2811
|
+
throw v();
|
|
2812
2812
|
}, b = (m) => {
|
|
2813
2813
|
const A = g(m);
|
|
2814
2814
|
if (A.kind === "box") return me(0, 0, e.width, e.height);
|
|
2815
2815
|
if (A.kind === "term") return u(A.id, A.text, A.occurrence, m).box;
|
|
2816
2816
|
const P = h.get(A.id);
|
|
2817
2817
|
if (!P || P.kind !== A.kind) {
|
|
2818
|
-
const
|
|
2819
|
-
throw et("whiteboard", m, De, `there is no ${A.kind} "${A.id}" (${A.kind}s: ${
|
|
2818
|
+
const v = [...h.values()].filter((y) => y.kind === A.kind).map((y) => y.item.id);
|
|
2819
|
+
throw et("whiteboard", m, De, `there is no ${A.kind} "${A.id}" (${A.kind}s: ${v.join(", ") || "none"})`);
|
|
2820
2820
|
}
|
|
2821
2821
|
return P.box;
|
|
2822
2822
|
};
|
|
@@ -2824,18 +2824,18 @@ function Mf(e) {
|
|
|
2824
2824
|
if (!m || typeof m.id != "string" || !m.id || /[:#]/.test(m.id)) throw new Error(`whiteboard: every item needs an \`id\` without ":" or "#" (got ${JSON.stringify(m?.id)})`);
|
|
2825
2825
|
if (h.has(m.id)) throw new Error(`whiteboard: two items are called "${m.id}"`);
|
|
2826
2826
|
if ("text" in m) {
|
|
2827
|
-
if (!Array.isArray(m.at) || m.at.length !== 2 || !m.at.every((
|
|
2828
|
-
const
|
|
2829
|
-
h.set(m.id, { kind: "text", item: m, size:
|
|
2827
|
+
if (!Array.isArray(m.at) || m.at.length !== 2 || !m.at.every((T) => typeof T == "number")) throw new Error(`whiteboard: text "${m.id}" needs \`at\`, [x, y] from the board's top-left`);
|
|
2828
|
+
const S = m.size ?? o, w = me(m.at[0], m.at[1], Math.max(1, m.text.length) * S * r, S * 1.3);
|
|
2829
|
+
h.set(m.id, { kind: "text", item: m, size: S, color: a(m.color), box: w }), c[`text.${m.id}.write`] = m.hidden ? 0 : 1, c[`text.${m.id}.erase`] = 0;
|
|
2830
2830
|
continue;
|
|
2831
2831
|
}
|
|
2832
2832
|
if (!ps.includes(m.mark)) throw new Error(`whiteboard: mark "${m.id}": ${ce("mark", m.mark, ps)}`);
|
|
2833
2833
|
const A = m.mark === "arrow" ? ["from", "to"] : ["around"];
|
|
2834
|
-
for (const
|
|
2835
|
-
const P = new Set([m.from, m.to].filter((
|
|
2834
|
+
for (const S of A) if (typeof m[S] != "string") throw new Error(`whiteboard: ${m.mark} "${m.id}" needs \`${S}\`, a place on the board (an item before it)`);
|
|
2835
|
+
const P = new Set([m.from, m.to].filter((S) => typeof S == "string").map((S) => S.split(":")[1])), v = m.mark === "arrow" ? [...h.values()].filter((S) => S.kind === "text" && !P.has(S.item.id)).map((S) => S.box) : [], y = zl(m, b, o, v);
|
|
2836
2836
|
h.set(m.id, { kind: "mark", item: m, color: a(m.color), points: y, box: Ll(y) }), c[`mark.${m.id}.draw`] = m.hidden ? 0 : 1, c[`mark.${m.id}.erase`] = 0;
|
|
2837
2837
|
}
|
|
2838
|
-
const
|
|
2838
|
+
const E = (m) => d.filter((A) => A.item === m), O = {
|
|
2839
2839
|
type: "custom",
|
|
2840
2840
|
x: e.x,
|
|
2841
2841
|
y: e.y,
|
|
@@ -2851,51 +2851,51 @@ function Mf(e) {
|
|
|
2851
2851
|
actions: De.edits
|
|
2852
2852
|
},
|
|
2853
2853
|
draw(m, A) {
|
|
2854
|
-
const P = A.props ?? {},
|
|
2854
|
+
const P = A.props ?? {}, v = (y) => Number(P[y] ?? c[y] ?? 0);
|
|
2855
2855
|
if (m.save(), m.fillStyle = t.background, ks(m, 0, 0, e.width, e.height, 10), m.fill(), m.lineWidth = Math.max(4, e.width * 0.012), m.strokeStyle = t.frame, m.stroke(), t.rule) {
|
|
2856
2856
|
m.save(), m.beginPath(), ks(m, 0, 0, e.width, e.height, 10), m.clip(), m.lineWidth = 1, m.strokeStyle = t.rule.color;
|
|
2857
2857
|
const y = o * (t.rule.spacing ?? 1.55);
|
|
2858
|
-
for (let
|
|
2859
|
-
m.beginPath(), m.moveTo(0,
|
|
2858
|
+
for (let S = y; S < e.height; S += y)
|
|
2859
|
+
m.beginPath(), m.moveTo(0, S), m.lineTo(e.width, S), m.stroke();
|
|
2860
2860
|
t.rule.margin && (m.strokeStyle = t.rule.margin, m.beginPath(), m.moveTo(o * 2.2, 0), m.lineTo(o * 2.2, e.height), m.stroke()), m.restore();
|
|
2861
2861
|
}
|
|
2862
2862
|
m.textAlign = "center", m.textBaseline = "middle", m.lineCap = "round", m.lineJoin = "round", m.globalAlpha = t.opacity;
|
|
2863
2863
|
for (const y of h.values()) {
|
|
2864
|
-
if (m.save(), Kn(m, y.box,
|
|
2865
|
-
const
|
|
2864
|
+
if (m.save(), Kn(m, y.box, v(`${y.kind}.${y.item.id}.erase`)), y.kind === "text") {
|
|
2865
|
+
const S = E(y.item.id), w = v(`text.${y.item.id}.write`) * y.item.text.length;
|
|
2866
2866
|
m.font = `${y.size}px ${t.font}`, m.fillStyle = y.color;
|
|
2867
|
-
for (let
|
|
2868
|
-
y.item.text[
|
|
2867
|
+
for (let T = 0; T < Math.ceil(w); T++)
|
|
2868
|
+
y.item.text[T] === " " || S.some((H) => T >= H.column && T < H.column + H.text.length) || (m.globalAlpha = t.opacity * Math.min(1, w - T), m.fillText(y.item.text[T], y.box.left + (T + 0.5) * y.size * r, y.box.y));
|
|
2869
2869
|
} else
|
|
2870
|
-
ws(m, y.points,
|
|
2870
|
+
ws(m, y.points, v(`mark.${y.item.id}.draw`), y.color, o * t.stroke, y.item.mark === "arrow");
|
|
2871
2871
|
m.restore();
|
|
2872
2872
|
}
|
|
2873
2873
|
for (const y of f) {
|
|
2874
|
-
const
|
|
2875
|
-
if (
|
|
2876
|
-
const { box: w } = y,
|
|
2877
|
-
ws(m, [{ x: w.left - 3, y: w.y +
|
|
2874
|
+
const S = v(`strike.${y.id}.draw`);
|
|
2875
|
+
if (S <= 0) continue;
|
|
2876
|
+
const { box: w } = y, T = w.height * 0.15;
|
|
2877
|
+
ws(m, [{ x: w.left - 3, y: w.y + T }, { x: w.right + 3, y: w.y - T }], S, t.colors.red ?? t.ink, o * t.stroke * 0.8, !1);
|
|
2878
2878
|
}
|
|
2879
2879
|
for (const y of d) {
|
|
2880
|
-
const
|
|
2881
|
-
m.font = `${
|
|
2882
|
-
const
|
|
2883
|
-
if (
|
|
2884
|
-
const R =
|
|
2880
|
+
const S = h.get(y.item), w = S.size * r;
|
|
2881
|
+
m.font = `${S.size}px ${t.font}`, m.fillStyle = S.color;
|
|
2882
|
+
const T = y.written;
|
|
2883
|
+
if (T) {
|
|
2884
|
+
const R = v(`piece.${y.id}.write`) * T.length, G = y.home.x - e.x - T.length * w / 2;
|
|
2885
2885
|
for (let Y = 0; Y < Math.ceil(R); Y++)
|
|
2886
|
-
|
|
2886
|
+
T[Y] !== " " && (m.globalAlpha = t.opacity * Math.min(1, R - Y), m.fillText(T[Y], G + (Y + 0.5) * w, y.home.y - e.y));
|
|
2887
2887
|
}
|
|
2888
|
-
const H =
|
|
2888
|
+
const H = v(`piece.${y.id}.opacity`) * Math.min(1, v(`text.${y.item}.write`) * S.item.text.length - y.column);
|
|
2889
2889
|
if (H <= 0) continue;
|
|
2890
2890
|
m.save();
|
|
2891
|
-
const x = { x: y.home.x - e.x, y: y.home.y - e.y }, j = { x:
|
|
2892
|
-
Kn(m, me(x.x + j.x - y.home.width / 2, x.y + j.y - y.home.height / 2, y.home.width, y.home.height),
|
|
2891
|
+
const x = { x: y.home.x - e.x, y: y.home.y - e.y }, j = { x: v(`piece.${y.id}.x`), y: v(`piece.${y.id}.y`) };
|
|
2892
|
+
Kn(m, me(x.x + j.x - y.home.width / 2, x.y + j.y - y.home.height / 2, y.home.width, y.home.height), v(`piece.${y.id}.erase`)), Math.hypot(j.x, j.y) < 1 && Kn(m, S.box, v(`text.${y.item}.erase`)), m.globalAlpha = t.opacity * Math.min(1, H), m.translate(x.x + j.x, x.y + j.y), m.rotate(v(`piece.${y.id}.rotate`) * Math.PI / 180);
|
|
2893
2893
|
for (let R = 0; R < y.text.length; R++) y.text[R] !== " " && m.fillText(y.text[R], (R + 0.5 - y.text.length / 2) * w, 0);
|
|
2894
2894
|
m.restore();
|
|
2895
2895
|
}
|
|
2896
2896
|
m.restore();
|
|
2897
2897
|
}
|
|
2898
|
-
},
|
|
2898
|
+
}, k = {
|
|
2899
2899
|
kind: "board",
|
|
2900
2900
|
about: De,
|
|
2901
2901
|
target: O,
|
|
@@ -2906,101 +2906,101 @@ function Mf(e) {
|
|
|
2906
2906
|
piece(m) {
|
|
2907
2907
|
const A = g(m);
|
|
2908
2908
|
if (A.kind !== "term") throw new Error(`whiteboard.piece: a piece is a term, term:ID:TEXT, not "${m}"`);
|
|
2909
|
-
const { column: P, box:
|
|
2909
|
+
const { column: P, box: v } = u(A.id, A.text, A.occurrence, m), y = d.find((w) => w.item === A.id && w.column === P && w.text === A.text);
|
|
2910
2910
|
if (y) return y;
|
|
2911
2911
|
if (d.some((w) => w.item === A.id && P < w.column + w.text.length && w.column < P + A.text.length))
|
|
2912
2912
|
throw new Error(`whiteboard: "${A.text}" in "${A.id}" overlaps another piece`);
|
|
2913
|
-
const
|
|
2914
|
-
d.push(
|
|
2915
|
-
for (const w of ["x", "y", "rotate", "erase", "write"]) c[`piece.${
|
|
2916
|
-
return c[`piece.${
|
|
2913
|
+
const S = { id: d.length + 1, item: A.id, column: P, text: A.text, home: s(v) };
|
|
2914
|
+
d.push(S);
|
|
2915
|
+
for (const w of ["x", "y", "rotate", "erase", "write"]) c[`piece.${S.id}.${w}`] = 0;
|
|
2916
|
+
return c[`piece.${S.id}.opacity`] = 1, S;
|
|
2917
2917
|
},
|
|
2918
2918
|
edit(m, A, P) {
|
|
2919
|
-
const
|
|
2920
|
-
if (
|
|
2921
|
-
const y =
|
|
2922
|
-
for (const { name:
|
|
2923
|
-
const
|
|
2924
|
-
const x = y.find((j) => !
|
|
2925
|
-
if (x) throw new Error(`whiteboard.edit: ${m} takes ${
|
|
2926
|
-
if (H && y.length > 1) throw new Error(`whiteboard.edit: ${m} takes one ${
|
|
2927
|
-
}, w = () =>
|
|
2919
|
+
const v = Array.isArray(A) ? A : [A];
|
|
2920
|
+
if (v.length === 0) throw new Error(`whiteboard.edit: ${m} takes at least one anchor`);
|
|
2921
|
+
const y = v.map((T) => ({ name: T, anchor: g(T) }));
|
|
2922
|
+
for (const { name: T } of y) b(T);
|
|
2923
|
+
const S = (T, H = !1) => {
|
|
2924
|
+
const x = y.find((j) => !T.includes(j.anchor.kind));
|
|
2925
|
+
if (x) throw new Error(`whiteboard.edit: ${m} takes ${T.join(" or ")} anchors, not "${x.name}"`);
|
|
2926
|
+
if (H && y.length > 1) throw new Error(`whiteboard.edit: ${m} takes one ${T.join(" or ")} anchor`);
|
|
2927
|
+
}, w = () => k.piece(y[0].name);
|
|
2928
2928
|
if (m === "write") {
|
|
2929
|
-
if (y.some((
|
|
2930
|
-
if (
|
|
2931
|
-
const
|
|
2932
|
-
return
|
|
2929
|
+
if (y.some((T) => T.anchor.kind === "term")) {
|
|
2930
|
+
if (S(["term"], !0), typeof P.text != "string") throw new Error("whiteboard.edit: write into a term needs `text` (the new text)");
|
|
2931
|
+
const T = w();
|
|
2932
|
+
return T.written = P.text, i.tween(`piece.${T.id}.write`, 0, 1, { duration: Math.max(bs, P.text.length * ms), ...P }), k;
|
|
2933
2933
|
}
|
|
2934
|
-
|
|
2935
|
-
for (const { anchor:
|
|
2936
|
-
const H =
|
|
2934
|
+
S(["text"]);
|
|
2935
|
+
for (const { anchor: T } of y) {
|
|
2936
|
+
const H = T.id, x = h.get(H).item.text;
|
|
2937
2937
|
i.tween(`text.${H}.write`, 0, 1, { duration: Math.max(bs, x.length * ms), ...P });
|
|
2938
2938
|
}
|
|
2939
|
-
return
|
|
2939
|
+
return k;
|
|
2940
2940
|
}
|
|
2941
2941
|
if (m === "draw") {
|
|
2942
|
-
|
|
2943
|
-
for (const { anchor:
|
|
2944
|
-
return
|
|
2942
|
+
S(["mark"]);
|
|
2943
|
+
for (const { anchor: T } of y) i.tween(`mark.${T.id}.draw`, 0, 1, { duration: 500, ...P });
|
|
2944
|
+
return k;
|
|
2945
2945
|
}
|
|
2946
2946
|
if (m === "erase") {
|
|
2947
|
-
|
|
2948
|
-
for (const
|
|
2949
|
-
const H =
|
|
2947
|
+
S(["text", "term", "mark"]);
|
|
2948
|
+
for (const T of y) {
|
|
2949
|
+
const H = T.anchor.kind === "term" ? `piece.${k.piece(T.name).id}.erase` : `${T.anchor.kind}.${T.anchor.id}.erase`;
|
|
2950
2950
|
i.tween(H, 0, 1, { duration: 400, ...P });
|
|
2951
2951
|
}
|
|
2952
|
-
return
|
|
2952
|
+
return k;
|
|
2953
2953
|
}
|
|
2954
2954
|
if (m === "strike") {
|
|
2955
|
-
|
|
2956
|
-
for (const
|
|
2957
|
-
const H = { id: f.length + 1, box: b(
|
|
2955
|
+
S(["text", "term"]);
|
|
2956
|
+
for (const T of y) {
|
|
2957
|
+
const H = { id: f.length + 1, box: b(T.name) };
|
|
2958
2958
|
f.push(H), c[`strike.${H.id}.draw`] = 0, i.tween(`strike.${H.id}.draw`, 0, 1, { duration: 250, ...P });
|
|
2959
2959
|
}
|
|
2960
|
-
return
|
|
2960
|
+
return k;
|
|
2961
2961
|
}
|
|
2962
2962
|
if (m === "move") {
|
|
2963
|
-
|
|
2964
|
-
const
|
|
2965
|
-
if (!
|
|
2966
|
-
return
|
|
2963
|
+
S(["term"], !0);
|
|
2964
|
+
const T = typeof P.to == "string" ? k.anchor(P.to) : P.to;
|
|
2965
|
+
if (!T || typeof T.x != "number" || typeof T.y != "number") throw new Error("whiteboard.edit: move needs `to`, an anchor name or { x, y }");
|
|
2966
|
+
return k.move(w(), { ...P, to: T });
|
|
2967
2967
|
}
|
|
2968
2968
|
if (m === "fling")
|
|
2969
|
-
return
|
|
2969
|
+
return S(["term"], !0), k.fling(w(), P);
|
|
2970
2970
|
throw En("whiteboard", m, De);
|
|
2971
2971
|
},
|
|
2972
2972
|
follow(m, A) {
|
|
2973
|
-
return l.follow(m, A),
|
|
2973
|
+
return l.follow(m, A), k;
|
|
2974
2974
|
},
|
|
2975
2975
|
fling(m, A) {
|
|
2976
|
-
return l.fling(m, A),
|
|
2976
|
+
return l.fling(m, A), k;
|
|
2977
2977
|
},
|
|
2978
2978
|
move(m, A) {
|
|
2979
|
-
return l.move(m, A),
|
|
2979
|
+
return l.move(m, A), k;
|
|
2980
2980
|
},
|
|
2981
2981
|
ride(m) {
|
|
2982
2982
|
return m;
|
|
2983
2983
|
},
|
|
2984
2984
|
tracks: i.tracks
|
|
2985
2985
|
};
|
|
2986
|
-
return
|
|
2986
|
+
return k;
|
|
2987
2987
|
}
|
|
2988
2988
|
function zl(e, n, t, o = []) {
|
|
2989
2989
|
const r = Et(Ye(e.id)), a = (g) => (r.next() * 2 - 1) * g, s = t * Rl;
|
|
2990
2990
|
if (e.mark === "arrow") {
|
|
2991
|
-
const g = n(e.from), b = n(e.to),
|
|
2992
|
-
let A =
|
|
2993
|
-
if (e.bend !== void 0) A =
|
|
2991
|
+
const g = n(e.from), b = n(e.to), E = ys(g, b, s * 0.6), O = ys(b, g, s * 0.6), k = Math.hypot(O.x - E.x, O.y - E.y), m = Dl(E, O);
|
|
2992
|
+
let A = k * (0.06 + a(0.04));
|
|
2993
|
+
if (e.bend !== void 0) A = k * e.bend;
|
|
2994
2994
|
else {
|
|
2995
|
-
const y = Fl(
|
|
2995
|
+
const y = Fl(E, O, m, o, s);
|
|
2996
2996
|
y !== 0 && (A = y);
|
|
2997
2997
|
}
|
|
2998
|
-
const P = { x: (
|
|
2998
|
+
const P = { x: (E.x + O.x) / 2 + m.x * A, y: (E.y + O.y) / 2 + m.y * A }, v = [];
|
|
2999
2999
|
for (let y = 0; y <= 24; y++) {
|
|
3000
|
-
const
|
|
3001
|
-
|
|
3000
|
+
const S = y / 24;
|
|
3001
|
+
v.push({ x: (1 - S) ** 2 * E.x + 2 * (1 - S) * S * P.x + S * S * O.x, y: (1 - S) ** 2 * E.y + 2 * (1 - S) * S * P.y + S * S * O.y });
|
|
3002
3002
|
}
|
|
3003
|
-
return
|
|
3003
|
+
return v;
|
|
3004
3004
|
}
|
|
3005
3005
|
const i = n(e.around);
|
|
3006
3006
|
if (e.mark === "underline") {
|
|
@@ -3012,13 +3012,13 @@ function zl(e, n, t, o = []) {
|
|
|
3012
3012
|
];
|
|
3013
3013
|
}
|
|
3014
3014
|
if (e.mark === "box") {
|
|
3015
|
-
const g = i.left - s, b = i.right + s,
|
|
3016
|
-
return [m,
|
|
3015
|
+
const g = i.left - s, b = i.right + s, E = i.top - s * 0.6, O = i.bottom + s * 0.6, k = (A, P) => ({ x: A + a(s * 0.2), y: P + a(s * 0.2) }), m = k(g, E);
|
|
3016
|
+
return [m, k(b, E), k(b, O), k(g, O), m, { x: m.x + s * 0.8, y: m.y + a(2) }];
|
|
3017
3017
|
}
|
|
3018
3018
|
const l = i.width / 2 + s, c = i.height / 2 + s * 0.6, h = -2.2 + a(0.3), d = r.next() * Math.PI * 2, f = 1.12, u = 64, p = [];
|
|
3019
3019
|
for (let g = 0; g <= u * f; g++) {
|
|
3020
|
-
const b = g / u,
|
|
3021
|
-
p.push({ x: i.x + Math.cos(
|
|
3020
|
+
const b = g / u, E = h + b * Math.PI * 2, O = 1 + 0.035 * Math.sin(b * Math.PI * 4 + d) + 0.06 * b;
|
|
3021
|
+
p.push({ x: i.x + Math.cos(E) * l * O, y: i.y + Math.sin(E) * c * O });
|
|
3022
3022
|
}
|
|
3023
3023
|
return p;
|
|
3024
3024
|
}
|
|
@@ -3166,12 +3166,12 @@ function $f(e) {
|
|
|
3166
3166
|
}
|
|
3167
3167
|
const f = o === "bar" ? "bar" : o === "line" ? "point" : "slice", u = Math.max(...e.data.flatMap(($) => s.map((z) => d($, z)))), p = r ? e.data.reduce(($, z) => $ + d(z, s[0]), 0) : e.max ?? Jl(u * 1.1);
|
|
3168
3168
|
if (!r && !(p > 0)) throw new Error(`chart: \`max\` must be above 0 (got ${p})`);
|
|
3169
|
-
const g = Math.max(10, Math.min(16, e.height / 20)), b = a && e.legend !== !1,
|
|
3169
|
+
const g = Math.max(10, Math.min(16, e.height / 20)), b = a && e.legend !== !1, E = r ? void 0 : e.axis?.x, O = r ? void 0 : e.axis?.y, k = e.title ? g * 2.3 : g * 0.5, m = {
|
|
3170
3170
|
left: g * 3.6 + (O ? g * 1.5 : 0),
|
|
3171
3171
|
right: e.width - g,
|
|
3172
3172
|
top: (e.title ? g * 3 : g * 1.6) + (b ? g * 1.6 : 0),
|
|
3173
|
-
bottom: e.height - g * 2.4 - (
|
|
3174
|
-
}, A = m.bottom - m.top, P = (m.right - m.left) / e.data.length,
|
|
3173
|
+
bottom: e.height - g * 2.4 - (E ? g * 1.4 : 0)
|
|
3174
|
+
}, A = m.bottom - m.top, P = (m.right - m.left) / e.data.length, v = a ? P * 0.72 / s.length : P * 0.6, y = a ? v * 0.86 : v, S = Math.max(4, g * 0.35), w = A / p, T = new Map(e.data.map(($, z) => [$.id, z])), H = ($) => m.left + P * (T.get($) + 0.5), x = ($, z) => a ? H($) - P * 0.36 + v * l.get(z) + (v - y) / 2 : H($) - y / 2, j = ($, z) => x($, z) + y / 2, R = e.height - g * 1.2, G = {
|
|
3175
3175
|
cx: e.width / 2,
|
|
3176
3176
|
cy: (m.top + R) / 2,
|
|
3177
3177
|
r: Math.max(10, Math.min(e.width / 2, (R - m.top) / 2) - g * 2.6)
|
|
@@ -3180,18 +3180,18 @@ function $f(e) {
|
|
|
3180
3180
|
let $ = m.right;
|
|
3181
3181
|
for (const z of [...s].reverse()) {
|
|
3182
3182
|
const U = z.label ?? z.id, te = g * 0.62 * U.length + g * 1.9;
|
|
3183
|
-
B.set(z.id, me($ - te,
|
|
3183
|
+
B.set(z.id, me($ - te, k, te, g * 1.4)), $ -= te + g * 0.6;
|
|
3184
3184
|
}
|
|
3185
3185
|
}
|
|
3186
|
-
const I = Ft(), N = $n(I), K = {},
|
|
3186
|
+
const I = Ft(), N = $n(I), K = {}, M = ($, z, U) => a ? `${f}.${$}.${z}.${U}` : `${f}.${$}.${U}`;
|
|
3187
3187
|
for (const $ of e.data)
|
|
3188
3188
|
for (const z of s)
|
|
3189
|
-
K[
|
|
3190
|
-
const _ = ($, z) => I.keys($)?.length ? jo(I.keys($), z) : K[$], V = ($, z, U) => _(
|
|
3191
|
-
const z = s[0].id, U = e.data.map((L) => Math.max(0, $(
|
|
3189
|
+
K[M($.id, z.id, "value")] = d($, z), K[M($.id, z.id, "show")] = $.hidden ? 0 : 1, K[M($.id, z.id, "highlight")] = 0, r && (K[M($.id, z.id, "pull")] = 0);
|
|
3190
|
+
const _ = ($, z) => I.keys($)?.length ? jo(I.keys($), z) : K[$], V = ($, z, U) => _(M($, z, "value"), U) * (o === "bar" ? _(M($, z, "show"), U) : 1) * w, ee = ($) => {
|
|
3191
|
+
const z = s[0].id, U = e.data.map((L) => Math.max(0, $(M(L.id, z, "value"))) * Math.max(0, Math.min(1, $(M(L.id, z, "show"))))), te = U.reduce((L, W) => L + W, 0), q = /* @__PURE__ */ new Map();
|
|
3192
3192
|
let le = -Math.PI / 2;
|
|
3193
3193
|
return e.data.forEach((L, W) => {
|
|
3194
|
-
const J = te > 0 ? Vl * U[W] / te : 0, he = le + J / 2, fe = Math.max(0, Math.min(1, $(
|
|
3194
|
+
const J = te > 0 ? Vl * U[W] / te : 0, he = le + J / 2, fe = Math.max(0, Math.min(1, $(M(L.id, z, "pull")))) * G.r * Xl;
|
|
3195
3195
|
q.set(L.id, {
|
|
3196
3196
|
start: le,
|
|
3197
3197
|
sweep: J,
|
|
@@ -3213,7 +3213,7 @@ function $f(e) {
|
|
|
3213
3213
|
if (z === "bar" || z === "point" || z === "slice" || z === "label" || z === "value") {
|
|
3214
3214
|
if (!U) throw te(`write it ${z}:ID`);
|
|
3215
3215
|
const q = U.indexOf(":"), le = q < 0 ? U : U.slice(0, q), L = q < 0 ? s[0].id : U.slice(q + 1);
|
|
3216
|
-
if (!
|
|
3216
|
+
if (!T.has(le)) throw te(`there is no "${le}" (data: ${[...T.keys()].join(", ")})`);
|
|
3217
3217
|
if (!i.has(L)) throw te(`there is no series "${L}" (series: ${s.map((W) => W.id).join(", ")})`);
|
|
3218
3218
|
if (z === "label" && q >= 0) throw te("a label is one per datum: label:ID");
|
|
3219
3219
|
if ((z === "bar" || z === "point" || z === "slice") && z !== f) throw te(`a ${o} chart has ${f}s, not ${z}s: ${f}:${le}`);
|
|
@@ -3231,9 +3231,9 @@ function $f(e) {
|
|
|
3231
3231
|
}
|
|
3232
3232
|
const U = $.kind === "label" ? H($.id) : j($.id, $.series), te = m.bottom - V($.id, $.series, z);
|
|
3233
3233
|
if ($.kind === "bar") return me(U - y / 2, te, y, m.bottom - te);
|
|
3234
|
-
if ($.kind === "point") return me(H($.id) -
|
|
3234
|
+
if ($.kind === "point") return me(H($.id) - S, te - S, S * 2, S * 2);
|
|
3235
3235
|
if ($.kind === "label") return me(U - P / 2, m.bottom + g * 0.4, P, g * 1.4);
|
|
3236
|
-
const q = te - (o === "line" ?
|
|
3236
|
+
const q = te - (o === "line" ? S : 0) - g * 0.3, le = a && o === "bar" ? v : P;
|
|
3237
3237
|
return me((o === "line" ? H($.id) : U) - le / 2, q - g * 1.3, le, g * 1.3);
|
|
3238
3238
|
}, C = ($) => {
|
|
3239
3239
|
const z = G.r + $.out + g * 0.9, U = { x: G.cx + Math.cos($.mid) * z, y: G.cy + Math.sin($.mid) * z }, te = g * 4.2, q = Math.cos($.mid), le = q > 0.2 ? U.x : q < -0.2 ? U.x - te : U.x - te / 2;
|
|
@@ -3269,19 +3269,19 @@ function $f(e) {
|
|
|
3269
3269
|
const W = m.bottom - A * L / 4;
|
|
3270
3270
|
$.strokeStyle = t.grid, $.beginPath(), $.moveTo(m.left, W), $.lineTo(m.right, W), $.stroke(), $.fillStyle = t.text, $.globalAlpha = 0.7, $.fillText(Zl(p * L / 4), m.left - g * 0.5, W), $.globalAlpha = 1;
|
|
3271
3271
|
}
|
|
3272
|
-
(O ||
|
|
3273
|
-
const q = (L, W) => te(
|
|
3272
|
+
(O || E) && ($.fillStyle = t.text, $.textAlign = "center", $.globalAlpha = 0.85, O && ($.save(), $.translate(g * 0.9, (m.top + m.bottom) / 2), $.rotate(-Math.PI / 2), $.fillText(O, 0, 0), $.restore()), E && $.fillText(E, (m.left + m.right) / 2, m.bottom + g * 2.3), $.globalAlpha = 1);
|
|
3273
|
+
const q = (L, W) => te(M(L, W, "value")) * (o === "bar" ? te(M(L, W, "show")) : 1) * w, le = (L, W) => Wn(c(W), t.highlight, te(M(L, W, "highlight")));
|
|
3274
3274
|
if (o === "line") {
|
|
3275
3275
|
$.lineWidth = Math.max(2, g * 0.2), $.lineJoin = "round", $.lineCap = "round";
|
|
3276
3276
|
for (const L of s)
|
|
3277
3277
|
$.strokeStyle = c(L.id), $.beginPath(), e.data.forEach((W, J) => {
|
|
3278
|
-
const he = { x: H(W.id), y: m.bottom - q(W.id, L.id) }, fe = te(
|
|
3278
|
+
const he = { x: H(W.id), y: m.bottom - q(W.id, L.id) }, fe = te(M(W.id, L.id, "show"));
|
|
3279
3279
|
if (J === 0) {
|
|
3280
3280
|
fe > 0 && $.moveTo(he.x, he.y);
|
|
3281
3281
|
return;
|
|
3282
3282
|
}
|
|
3283
3283
|
const pe = e.data[J - 1];
|
|
3284
|
-
if (te(
|
|
3284
|
+
if (te(M(pe.id, L.id, "show")) < 1 || fe <= 0) return;
|
|
3285
3285
|
const ge = { x: H(pe.id), y: m.bottom - q(pe.id, L.id) };
|
|
3286
3286
|
$.lineTo(ge.x + (he.x - ge.x) * fe, ge.y + (he.y - ge.y) * fe);
|
|
3287
3287
|
}), $.stroke();
|
|
@@ -3289,11 +3289,11 @@ function $f(e) {
|
|
|
3289
3289
|
$.textAlign = "center";
|
|
3290
3290
|
for (const L of e.data) {
|
|
3291
3291
|
for (const W of s) {
|
|
3292
|
-
const J = o === "bar" ? j(L.id, W.id) : H(L.id), he = q(L.id, W.id), fe = te(
|
|
3293
|
-
if ($.fillStyle = le(L.id, W.id), o === "bar" ? he > 0.5 && (Ql($, J - y / 2, m.bottom - he, y, he, Math.min(6, y / 4)), $.fill()) : fe > 0 && ($.beginPath(), $.arc(J, m.bottom - he,
|
|
3294
|
-
$.globalAlpha = Math.min(1, fe * 2), $.font = `600 ${a ? g * 0.85 : g}px ${t.font}`, $.fillStyle = Wn(t.text, t.highlight, te(
|
|
3295
|
-
const pe = m.bottom - he - (o === "line" ?
|
|
3296
|
-
$.fillText(D(te(
|
|
3292
|
+
const J = o === "bar" ? j(L.id, W.id) : H(L.id), he = q(L.id, W.id), fe = te(M(L.id, W.id, "show"));
|
|
3293
|
+
if ($.fillStyle = le(L.id, W.id), o === "bar" ? he > 0.5 && (Ql($, J - y / 2, m.bottom - he, y, he, Math.min(6, y / 4)), $.fill()) : fe > 0 && ($.beginPath(), $.arc(J, m.bottom - he, S * Math.min(1, fe * 1.5) * (1 + 0.3 * te(M(L.id, W.id, "highlight"))), 0, Math.PI * 2), $.fill()), e.values !== !1 && fe > 0) {
|
|
3294
|
+
$.globalAlpha = Math.min(1, fe * 2), $.font = `600 ${a ? g * 0.85 : g}px ${t.font}`, $.fillStyle = Wn(t.text, t.highlight, te(M(L.id, W.id, "highlight")));
|
|
3295
|
+
const pe = m.bottom - he - (o === "line" ? S : 0) - g * 0.95;
|
|
3296
|
+
$.fillText(D(te(M(L.id, W.id, "value"))), J, pe), $.font = `${g}px ${t.font}`, $.globalAlpha = 1;
|
|
3297
3297
|
}
|
|
3298
3298
|
}
|
|
3299
3299
|
$.fillStyle = t.text, $.fillText(L.label ?? L.id, H(L.id), m.bottom + g * 1.1);
|
|
@@ -3310,11 +3310,11 @@ function $f(e) {
|
|
|
3310
3310
|
if (fe <= 0) return;
|
|
3311
3311
|
$.save(), $.globalAlpha = fe;
|
|
3312
3312
|
const pe = { x: G.cx + Math.cos(L.mid) * L.out, y: G.cy + Math.sin(L.mid) * L.out };
|
|
3313
|
-
$.translate(L.centre.x + J.x, L.centre.y + J.y), $.rotate(he), $.translate(-L.centre.x, -L.centre.y), $.beginPath(), $.arc(pe.x, pe.y, G.r, L.start, L.start + L.sweep), Y > 0 ? $.arc(pe.x, pe.y, Y, L.start + L.sweep, L.start, !0) : $.lineTo(pe.x, pe.y), $.closePath(), $.fillStyle = Wn(t.palette[le % t.palette.length], t.highlight, z(
|
|
3313
|
+
$.translate(L.centre.x + J.x, L.centre.y + J.y), $.rotate(he), $.translate(-L.centre.x, -L.centre.y), $.beginPath(), $.arc(pe.x, pe.y, G.r, L.start, L.start + L.sweep), Y > 0 ? $.arc(pe.x, pe.y, Y, L.start + L.sweep, L.start, !0) : $.lineTo(pe.x, pe.y), $.closePath(), $.fillStyle = Wn(t.palette[le % t.palette.length], t.highlight, z(M(q.id, U, "highlight"))), $.fill(), $.strokeStyle = t.background, $.lineWidth = Math.max(1.5, g * 0.15), $.stroke(), e.values !== !1 && L.sweep >= 0.3 && ($.fillStyle = t.background, $.font = `600 ${g}px ${t.font}`, $.textAlign = "center", $.fillText(D(z(M(q.id, U, "value"))), L.centre.x, L.centre.y), $.font = `${g}px ${t.font}`), $.restore();
|
|
3314
3314
|
const ge = C(L), Ee = Math.cos(L.mid);
|
|
3315
3315
|
$.globalAlpha = fe, $.fillStyle = t.text, $.textAlign = Ee > 0.2 ? "left" : Ee < -0.2 ? "right" : "center";
|
|
3316
3316
|
const At = Ee > 0.2 ? ge.left : Ee < -0.2 ? ge.right : ge.left + ge.width / 2;
|
|
3317
|
-
$.fillText(q.label ?? q.id, At, ge.top + ge.height / 2), e.values !== !1 && L.sweep < 0.3 && ($.globalAlpha = fe * 0.8, $.fillText(D(z(
|
|
3317
|
+
$.fillText(q.label ?? q.id, At, ge.top + ge.height / 2), e.values !== !1 && L.sweep < 0.3 && ($.globalAlpha = fe * 0.8, $.fillText(D(z(M(q.id, U, "value"))), At, ge.bottom + g * 0.65)), $.globalAlpha = 1;
|
|
3318
3318
|
});
|
|
3319
3319
|
}
|
|
3320
3320
|
const ie = {
|
|
@@ -3349,7 +3349,7 @@ function $f(e) {
|
|
|
3349
3349
|
return L;
|
|
3350
3350
|
});
|
|
3351
3351
|
for (const { id: le, series: L } of q) {
|
|
3352
|
-
const W = (J) =>
|
|
3352
|
+
const W = (J) => M(le, L, J);
|
|
3353
3353
|
if ($ === "set") {
|
|
3354
3354
|
if (typeof U.value != "number" || !Number.isFinite(U.value)) throw new Error("chart.edit: set needs `value`, a number");
|
|
3355
3355
|
I.tween(W("value"), _(W("value"), U.at), U.value, U, ql);
|
|
@@ -3370,7 +3370,7 @@ function $f(e) {
|
|
|
3370
3370
|
if (o !== "bar") return $;
|
|
3371
3371
|
const te = e.data.flatMap(
|
|
3372
3372
|
(q) => s.map((le) => {
|
|
3373
|
-
const L = V(q.id, le.id, 0), W = [...Wt(I.keys(
|
|
3373
|
+
const L = V(q.id, le.id, 0), W = [...Wt(I.keys(M(q.id, le.id, "value"))), ...Wt(I.keys(M(q.id, le.id, "show")))];
|
|
3374
3374
|
return { top: e.y + m.bottom - L, offset: (J) => L - V(q.id, le.id, J), windows: W };
|
|
3375
3375
|
})
|
|
3376
3376
|
);
|
|
@@ -3811,21 +3811,21 @@ const $s = 0.075;
|
|
|
3811
3811
|
function Af(e, n, t, o = {}) {
|
|
3812
3812
|
const r = pn[e];
|
|
3813
3813
|
if (!r) throw new Error(`meetHands: unknown meeting '${e}' (one of ${Object.keys(pn).join(", ")})`);
|
|
3814
|
-
const [a, s] = n.x <= t.x ? [n, t] : [t, n], i = o.view === "side", l = Math.min(a.character.height, s.character.height), c = { x: (a.x + s.x) / 2, y: -(o.height ?? r.height) * l }, h = (b,
|
|
3815
|
-
const O =
|
|
3816
|
-
let
|
|
3817
|
-
const m =
|
|
3818
|
-
|
|
3814
|
+
const [a, s] = n.x <= t.x ? [n, t] : [t, n], i = o.view === "side", l = Math.min(a.character.height, s.character.height), c = { x: (a.x + s.x) / 2, y: -(o.height ?? r.height) * l }, h = (b, E) => {
|
|
3815
|
+
const O = E ? i ? 1 : 0.62 : i ? 3 : 3.38;
|
|
3816
|
+
let k = { ...be, ...b.pose, turn: O, lean: (b.pose?.lean ?? 0) + r.lean };
|
|
3817
|
+
const m = E ? 1 : -1, A = (P, v, y) => {
|
|
3818
|
+
k = Ge(b.character, k, P, { x: c.x + v - b.x, y: c.y, depth: y });
|
|
3819
3819
|
};
|
|
3820
3820
|
if (e === "handOver") {
|
|
3821
3821
|
const P = $s * l;
|
|
3822
3822
|
A("arm.left", -m * P * 0.9, P), A("arm.right", -m * P * 0.9, -P);
|
|
3823
3823
|
} else
|
|
3824
3824
|
A("arm.right", 0, 0);
|
|
3825
|
-
return e === "fistBump" && (
|
|
3826
|
-
}, d = h(a, !0), f = h(s, !1), u = 0.03 * l, p = (b,
|
|
3827
|
-
const O = xe(b.character,
|
|
3828
|
-
return
|
|
3825
|
+
return e === "fistBump" && (k = { ...k, "hand.right.index.curl": 1, "hand.right.middle.curl": 1, "hand.right.ring.curl": 1, "hand.right.pinky.curl": 1 }), k;
|
|
3826
|
+
}, d = h(a, !0), f = h(s, !1), u = 0.03 * l, p = (b, E) => {
|
|
3827
|
+
const O = xe(b.character, E), k = e === "handOver" ? ["hand.left", "hand.right"] : ["hand.right"], m = e === "handOver" ? $s * l + u : u;
|
|
3828
|
+
return k.every((A) => Math.abs(O.points[A].y - c.y) < u && Math.abs(O.points[A].x + b.x - c.x) < m);
|
|
3829
3829
|
}, g = p(a, d) && p(s, f);
|
|
3830
3830
|
return n.x <= t.x ? { a: d, b: f, point: c, reached: g } : { a: f, b: d, point: c, reached: g };
|
|
3831
3831
|
}
|
|
@@ -3838,13 +3838,13 @@ function Of(e, n, t = {}) {
|
|
|
3838
3838
|
over: { x: g.x - b * 0.02 * s - p.x, y: -0.72 * s, depth: -0.08 * s },
|
|
3839
3839
|
round: { x: g.x - b * 0.04 * s - p.x, y: -0.5 * s, depth: 0.06 * s }
|
|
3840
3840
|
}), l = (p, g, b) => {
|
|
3841
|
-
const
|
|
3842
|
-
let
|
|
3841
|
+
const E = b ? a ? 1 : 0.62 : a ? 3 : 3.38, O = b ? 1 : -1;
|
|
3842
|
+
let k = { ...be, ...p.pose, turn: E, lean: (p.pose?.lean ?? 0) + lo.lean, "head.tilt": (p.pose?.["head.tilt"] ?? 0) + O * lo.tilt };
|
|
3843
3843
|
const { over: m, round: A } = i(p, g, O);
|
|
3844
|
-
return
|
|
3845
|
-
}, c = l(o, r, !0), h = l(r, o, !1), d = 0.05 * s, f = (p, g, b,
|
|
3846
|
-
const O = xe(p.character,
|
|
3847
|
-
return Math.hypot(O["hand.right"].x -
|
|
3844
|
+
return k = Ge(p.character, k, "arm.right", m), k = Ge(p.character, k, "arm.left", A), k;
|
|
3845
|
+
}, c = l(o, r, !0), h = l(r, o, !1), d = 0.05 * s, f = (p, g, b, E) => {
|
|
3846
|
+
const O = xe(p.character, E).points, { over: k, round: m } = i(p, g, b);
|
|
3847
|
+
return Math.hypot(O["hand.right"].x - k.x, O["hand.right"].y - k.y) < d && Math.hypot(O["hand.left"].x - m.x, O["hand.left"].y - m.y) < d;
|
|
3848
3848
|
}, u = f(o, r, 1, c) && f(r, o, -1, h);
|
|
3849
3849
|
return e.x <= n.x ? { a: c, b: h, reached: u } : { a: h, b: c, reached: u };
|
|
3850
3850
|
}
|
|
@@ -3859,8 +3859,8 @@ function If(e, n, t, o = {}) {
|
|
|
3859
3859
|
const d = { ...Re.sitFloor, ...n.pose, turn: c(!s) }, f = { ...be, ...n.pose, turn: c(!s) };
|
|
3860
3860
|
let u = fa(d, f, r);
|
|
3861
3861
|
u = Ge(n.character, u, "arm.right", { x: l.x - n.x, y: l.y });
|
|
3862
|
-
const p = 0.04 * i, g = (b,
|
|
3863
|
-
const O = xe(b.character,
|
|
3862
|
+
const p = 0.04 * i, g = (b, E) => {
|
|
3863
|
+
const O = xe(b.character, E).points["hand.right"];
|
|
3864
3864
|
return Math.hypot(O.x + b.x - l.x, O.y - l.y) < p;
|
|
3865
3865
|
};
|
|
3866
3866
|
return { helper: h, sitter: u, point: l, reached: g(e, h) && g(n, u) };
|
|
@@ -3874,12 +3874,12 @@ function uh(e, n) {
|
|
|
3874
3874
|
return p.turn * 90 + (p.headTurn ?? 0);
|
|
3875
3875
|
}, c = { start: t, end: n.end, step: n.step, stiffness: n.stiffness ?? 70, damping: n.damping ?? 6 }, h = tn(l, c), d = tn((u) => i(u).x, c), f = tn((u) => i(u).y, c);
|
|
3876
3876
|
return h.map((u, p) => {
|
|
3877
|
-
const g = i(u.time), b = u.value - l(u.time),
|
|
3877
|
+
const g = i(u.time), b = u.value - l(u.time), E = d[p].value - g.x - (n.wind ?? 0) * sh * r, O = f[p].value - g.y, k = Math.sin(g.turn * Math.PI / 2), m = Math.cos(g.turn * Math.PI / 2), A = b * lh + E * m / r * hh, P = -E * k / r * ch, v = -O / r * dh;
|
|
3878
3878
|
return {
|
|
3879
3879
|
time: u.time,
|
|
3880
3880
|
swing: Rn(A * o, ah),
|
|
3881
3881
|
trail: Rn(P * o, rh),
|
|
3882
|
-
lift: Rn(
|
|
3882
|
+
lift: Rn(v * o, ih)
|
|
3883
3883
|
};
|
|
3884
3884
|
});
|
|
3885
3885
|
}
|
|
@@ -3903,28 +3903,28 @@ const Es = (e) => ({ "hair.swing": e.swing, "hair.trail": e.trail, "hair.lift":
|
|
|
3903
3903
|
function xf(e, n, t, o = {}) {
|
|
3904
3904
|
const r = t.head.hair;
|
|
3905
3905
|
if (!r || !Ir(r)) return [];
|
|
3906
|
-
const a = n.filter((O) => O.target === e), s = a.reduce((O,
|
|
3907
|
-
const A = c.getStateAtTime(O).values.get(e)?.get(
|
|
3906
|
+
const a = n.filter((O) => O.target === e), s = a.reduce((O, k) => k.keyframes.reduce((m, A) => Math.max(m, A.time), O), 0), i = be, l = /* @__PURE__ */ new Set(["x", "y", "turn", "head.turn"]), c = new ve({ id: `${e}-hair-follow`, tracks: a.filter((O) => l.has(O.property)) }), h = (O, k, m) => {
|
|
3907
|
+
const A = c.getStateAtTime(O).values.get(e)?.get(k);
|
|
3908
3908
|
return typeof A == "number" ? A : m;
|
|
3909
3909
|
}, d = new ve({ id: `${e}-hair-pose`, tracks: a }), f = (O) => d.getStateAtTime(O).values.get(e), u = /* @__PURE__ */ new Map(), p = (O) => {
|
|
3910
|
-
const
|
|
3911
|
-
let m = u.get(
|
|
3910
|
+
const k = Math.round(O / ct);
|
|
3911
|
+
let m = u.get(k);
|
|
3912
3912
|
if (!m) {
|
|
3913
3913
|
const A = {};
|
|
3914
|
-
for (const [
|
|
3914
|
+
for (const [v, y] of f(k * ct) ?? []) A[v] = y;
|
|
3915
3915
|
const P = xe(t, jr(A, i, o.gaits)).head.center;
|
|
3916
|
-
u.set(
|
|
3916
|
+
u.set(k, m = { x: P.x, y: P.y });
|
|
3917
3917
|
}
|
|
3918
3918
|
return m;
|
|
3919
3919
|
}, g = (O) => {
|
|
3920
|
-
const
|
|
3920
|
+
const k = Math.floor(O / ct), m = O / ct - k, A = p(k * ct), P = p((k + 1) * ct);
|
|
3921
3921
|
return { x: A.x + (P.x - A.x) * m, y: A.y + (P.y - A.y) * m };
|
|
3922
3922
|
}, b = uh(
|
|
3923
3923
|
(O) => {
|
|
3924
|
-
const
|
|
3924
|
+
const k = g(O);
|
|
3925
3925
|
return {
|
|
3926
|
-
x: h(O, "x", 0) +
|
|
3927
|
-
y: h(O, "y", 0) +
|
|
3926
|
+
x: h(O, "x", 0) + k.x,
|
|
3927
|
+
y: h(O, "y", 0) + k.y,
|
|
3928
3928
|
turn: h(O, "turn", i.turn ?? 0),
|
|
3929
3929
|
headTurn: h(O, "head.turn", i["head.turn"] ?? 0)
|
|
3930
3930
|
};
|
|
@@ -3939,19 +3939,19 @@ function xf(e, n, t, o = {}) {
|
|
|
3939
3939
|
amount: o.amount,
|
|
3940
3940
|
wind: o.wind
|
|
3941
3941
|
}
|
|
3942
|
-
),
|
|
3942
|
+
), E = [];
|
|
3943
3943
|
for (const O of fh) {
|
|
3944
|
-
const
|
|
3945
|
-
let m = b.map((P) => ({ time: P.time, value: P[
|
|
3944
|
+
const k = O.slice(5);
|
|
3945
|
+
let m = b.map((P) => ({ time: P.time, value: P[k] }));
|
|
3946
3946
|
if (m.every((P) => Math.abs(P.value) < 1e-3)) continue;
|
|
3947
3947
|
const A = a.find((P) => P.property === O);
|
|
3948
3948
|
if (A) {
|
|
3949
|
-
const P = new ve({ id: `${e}-${O}-own`, tracks: [A] }),
|
|
3950
|
-
m = m.map((y) => ({ time: y.time, value: y.value +
|
|
3949
|
+
const P = new ve({ id: `${e}-${O}-own`, tracks: [A] }), v = (y) => Number(P.getStateAtTime(y).values.get(e)?.get(O) ?? 0);
|
|
3950
|
+
m = m.map((y) => ({ time: y.time, value: y.value + v(y.time) }));
|
|
3951
3951
|
}
|
|
3952
|
-
|
|
3952
|
+
E.push({ id: `${e}-${O}`, target: e, property: O, keyframes: m });
|
|
3953
3953
|
}
|
|
3954
|
-
return
|
|
3954
|
+
return E;
|
|
3955
3955
|
}
|
|
3956
3956
|
const bt = {
|
|
3957
3957
|
full: {
|
|
@@ -4053,39 +4053,39 @@ function yh(e, n, t, o, r) {
|
|
|
4053
4053
|
};
|
|
4054
4054
|
let f = n[0].pose[e];
|
|
4055
4055
|
for (let u = 1; u < n.length; u++) {
|
|
4056
|
-
const p = n[u], g = n[u - 1].pose[e], b = p.pose[e],
|
|
4057
|
-
if (Math.abs(
|
|
4058
|
-
const
|
|
4056
|
+
const p = n[u], g = n[u - 1].pose[e], b = p.pose[e], E = b - g, O = h[h.length - 1].time, k = p.act !== !1;
|
|
4057
|
+
if (Math.abs(E) <= tt) {
|
|
4058
|
+
const T = p.time + (k ? c(u) : 0);
|
|
4059
4059
|
if (u === n.length - 1)
|
|
4060
|
-
Math.abs(f - b) > tt && d(Math.max(
|
|
4061
|
-
else if (
|
|
4060
|
+
Math.abs(f - b) > tt && d(Math.max(T, O + ho), b, "ease-in-out"), f = b;
|
|
4061
|
+
else if (k && i && o.drift > 0 && t.drift.includes(e) && T - O >= mh) {
|
|
4062
4062
|
const H = Ye(`${r}:${e}:${u}`) % 2 === 0 ? 1 : -1;
|
|
4063
|
-
f = b + H * o.drift * s, d(
|
|
4063
|
+
f = b + H * o.drift * s, d(T, f, "ease-in-out");
|
|
4064
4064
|
}
|
|
4065
4065
|
continue;
|
|
4066
4066
|
}
|
|
4067
|
-
if (!
|
|
4067
|
+
if (!k) {
|
|
4068
4068
|
d(n[u - 1].time, f), d(p.time, b, p.easing), f = b;
|
|
4069
4069
|
continue;
|
|
4070
4070
|
}
|
|
4071
4071
|
const m = c(u), A = Math.max(n[u - 1].time + m, O);
|
|
4072
4072
|
let P = p.time + m;
|
|
4073
4073
|
a && o.eyeDart > 0 && (P = Math.min(P, A + o.eyeDart));
|
|
4074
|
-
const
|
|
4075
|
-
if (
|
|
4074
|
+
const v = P - A;
|
|
4075
|
+
if (v <= yt) {
|
|
4076
4076
|
d(p.time, b, p.easing), f = b;
|
|
4077
4077
|
continue;
|
|
4078
4078
|
}
|
|
4079
4079
|
d(A, f);
|
|
4080
|
-
const y = Math.sign(
|
|
4081
|
-
if (i && o.anticipation > 0 && s > 0 &&
|
|
4082
|
-
const
|
|
4083
|
-
d(H,
|
|
4084
|
-
}
|
|
4085
|
-
const
|
|
4086
|
-
if (i && o.overshoot > 0 && s > 0 &&
|
|
4087
|
-
const
|
|
4088
|
-
d(P, b + y *
|
|
4080
|
+
const y = Math.sign(E);
|
|
4081
|
+
if (i && o.anticipation > 0 && s > 0 && v >= ho) {
|
|
4082
|
+
const T = f - y * Math.min(Math.abs(E) * o.anticipation, s), H = A + v * o.anticipationTime;
|
|
4083
|
+
d(H, T, "ease-in-out"), o.hold > 0 && d(H + v * o.hold, T);
|
|
4084
|
+
}
|
|
4085
|
+
const S = u + 1 < n.length ? n[u + 1].time - p.time : 1 / 0, w = Math.min(o.settle, S / 2);
|
|
4086
|
+
if (i && o.overshoot > 0 && s > 0 && v >= ph && w > yt) {
|
|
4087
|
+
const T = Math.min(Math.abs(E) * o.overshoot, s);
|
|
4088
|
+
d(P, b + y * T, p.easing ?? o.actionEase), d(P + w, b, o.settleEase);
|
|
4089
4089
|
} else
|
|
4090
4090
|
d(P, b, p.easing ?? o.actionEase);
|
|
4091
4091
|
f = b;
|
|
@@ -4096,7 +4096,7 @@ function wh(e, n, t, o, r) {
|
|
|
4096
4096
|
const a = [], s = zn + bh;
|
|
4097
4097
|
for (let u = 1; u < e.length; u++) {
|
|
4098
4098
|
const p = e[u - 1].pose, g = e[u].pose;
|
|
4099
|
-
Object.entries(n.headTurns).some(([
|
|
4099
|
+
Object.entries(n.headTurns).some(([E, O]) => Math.abs((g[E] ?? 0) - (p[E] ?? 0)) > O) && e[u].act !== !1 && a.push(Math.max(e[0].time, e[u - 1].time - t.eyeLead));
|
|
4100
4100
|
}
|
|
4101
4101
|
const i = e[0].time, l = e[e.length - 1].time, c = [...a];
|
|
4102
4102
|
let h = i + Vt * 0.6, d = 0;
|
|
@@ -4296,8 +4296,8 @@ function Ph(e, n, t = {}) {
|
|
|
4296
4296
|
for (let i = 0; i < o; i++) {
|
|
4297
4297
|
const l = (i - (o - 1) / 2) * r, c = Math.floor(Math.abs(l) / Math.max(r, 1) * (n.length / 6));
|
|
4298
4298
|
for (let h = c + 1; h < n.length; h++) {
|
|
4299
|
-
const d = n[h - 1], f = n[h], u = f.x - d.x, p = f.y - d.y, g = Math.hypot(u, p) || 1, b = -p / g,
|
|
4300
|
-
e.globalAlpha = s * (1 - O), e.lineWidth = a * (1 - O * 0.7), e.beginPath(), e.moveTo(d.x + b * l, d.y +
|
|
4299
|
+
const d = n[h - 1], f = n[h], u = f.x - d.x, p = f.y - d.y, g = Math.hypot(u, p) || 1, b = -p / g, E = u / g, O = 1 - h / (n.length - 1);
|
|
4300
|
+
e.globalAlpha = s * (1 - O), e.lineWidth = a * (1 - O * 0.7), e.beginPath(), e.moveTo(d.x + b * l, d.y + E * l), e.lineTo(f.x + b * l, f.y + E * l), e.stroke();
|
|
4301
4301
|
}
|
|
4302
4302
|
}
|
|
4303
4303
|
e.restore();
|
|
@@ -4334,8 +4334,8 @@ function _f(e, n, t, o, r = {}) {
|
|
|
4334
4334
|
for (let O = 1; O < p.length; O++) g += Math.hypot(p[O].x - p[O - 1].x, p[O].y - p[O - 1].y);
|
|
4335
4335
|
const b = g / ((t.time - l) / 1e3);
|
|
4336
4336
|
if (b <= d) continue;
|
|
4337
|
-
const
|
|
4338
|
-
Ph(e, p, { ...r, opacity: (r.opacity ?? 0.7) *
|
|
4337
|
+
const E = Math.min(1, (b - d) / (d * 0.5));
|
|
4338
|
+
Ph(e, p, { ...r, opacity: (r.opacity ?? 0.7) * E, spacing: r.spacing ?? h * 0.02 });
|
|
4339
4339
|
}
|
|
4340
4340
|
}
|
|
4341
4341
|
function Hh(e, n, t, o = {}) {
|
|
@@ -4537,80 +4537,80 @@ function nc(e) {
|
|
|
4537
4537
|
function No(e, n, t = {}) {
|
|
4538
4538
|
const o = { actions: t.actions, gaits: t.gaits };
|
|
4539
4539
|
Ps(n, o);
|
|
4540
|
-
const r = t.gait ?? "walk", a = Co(n, t.actions).map((
|
|
4540
|
+
const r = t.gait ?? "walk", a = Co(n, t.actions).map((M) => M.do === "go" ? { ...M, do: r } : M);
|
|
4541
4541
|
Ps(a, o, "scriptTracks (after expanding custom actions)");
|
|
4542
|
-
const s = (
|
|
4543
|
-
const _ = t.actions?.[
|
|
4542
|
+
const s = (M) => ze[M] ?? t.gaits?.[M], i = (M) => Hs[M] ?? t.gaits?.[M]?.cycle ?? 1e3, l = (M) => {
|
|
4543
|
+
const _ = t.actions?.[M];
|
|
4544
4544
|
return _ && "steps" in _ ? _ : void 0;
|
|
4545
4545
|
}, c = t.from ?? 0, h = t.ground ?? 0, d = t.height ?? 300;
|
|
4546
|
-
let f = c, u = h, p = t.facing ?? 1, g = t.start ?? de, b = 0,
|
|
4547
|
-
const O = [{ time: 0, pose: g }],
|
|
4548
|
-
g = { ...g, ..._ }, V && (g = gt(g, V)), O.push({ time:
|
|
4549
|
-
}, x = (
|
|
4550
|
-
const F = ee === "arm", Q = We({ ...
|
|
4546
|
+
let f = c, u = h, p = t.facing ?? 1, g = t.start ?? de, b = 0, E = 0;
|
|
4547
|
+
const O = [{ time: 0, pose: g }], k = [{ time: 0, value: 0 }], m = [{ time: 0, value: 0 }], A = [{ time: 0, value: 0 }], P = [{ time: 0, value: 0 }], v = [{ time: 0, value: "walk" }], y = [{ time: 0, value: p }], S = [], w = [], T = [], H = (M, _, V, ee) => {
|
|
4548
|
+
g = { ...g, ..._ }, V && (g = gt(g, V)), O.push({ time: M, pose: g, ...ee === !1 ? { act: ee } : {} });
|
|
4549
|
+
}, x = (M, _, V) => (H(M + dt / 2, { turn: 0 }, V), y.push({ time: M + dt / 2, value: p }, { time: M + dt / 2 + 1, value: _ }), p = _, H(M + dt, { turn: 1 }), M + dt), j = (M) => M < f ? -1 : 1, R = (M, _, V) => j(_) !== p ? x(M, j(_), V) : M, G = (M, _, V, ee = "arm") => {
|
|
4550
|
+
const F = ee === "arm", Q = We({ ...M, ...F ? { rightShoulder: 0, rightElbow: 0 } : { rightHip: 0, rightKnee: 0 } }, { height: d, facing: p }), ae = F ? Q.shoulders.right : Q.hip, C = F ? Q.elbows.right : Q.knees.right, X = (se, re) => Math.atan2(p * se, re) * 180 / Math.PI, Z = ((X(_ - (f + ae.x), V - (u + ae.y)) - X(C.x - ae.x, C.y - ae.y)) % 360 + 360) % 360;
|
|
4551
4551
|
return Z > 270 ? Z - 360 : Z;
|
|
4552
|
-
}, Y = (
|
|
4553
|
-
const F = ee === "arm", Q = We({ ...
|
|
4552
|
+
}, Y = (M, _, V, ee) => {
|
|
4553
|
+
const F = ee === "arm", Q = We({ ...M, ...F ? { rightShoulder: 90, rightElbow: 0, rightWrist: 0 } : { rightHip: 90, rightKnee: 0 } }, { height: d, facing: p }), ae = F ? Q.shoulders.right : Q.hip, C = F ? { x: (Q.hands.right.x + Q.fingertips.right.x) / 2, y: (Q.hands.right.y + Q.fingertips.right.y) / 2 } : Q.feet.right, X = Math.hypot(C.x - ae.x, C.y - ae.y) * ((F ? t.reach?.arm : t.reach?.leg) ?? 1), D = V - (u + ae.y), Z = Math.abs(D) < X ? Math.sqrt(X * X - D * D) : X * 0.1;
|
|
4554
4554
|
return _ - ae.x - p * Z;
|
|
4555
|
-
}, ne = (
|
|
4556
|
-
const _ = We(
|
|
4555
|
+
}, ne = (M) => {
|
|
4556
|
+
const _ = We(M, { height: d, facing: p });
|
|
4557
4557
|
return { x: f + (_.hands.right.x + _.fingertips.right.x) / 2, y: u + (_.hands.right.y + _.fingertips.right.y) / 2 };
|
|
4558
|
-
}, B = (
|
|
4559
|
-
const ee = { ...
|
|
4558
|
+
}, B = (M, _, V) => {
|
|
4559
|
+
const ee = { ...M, rightWrist: 0, rightElbow: 0, rightShoulder: G(M, _, V) }, F = We(ee, { height: d, facing: p }), Q = { x: f + F.shoulders.right.x, y: u + F.shoulders.right.y }, ae = { x: f + F.elbows.right.x, y: u + F.elbows.right.y }, C = ne(ee), X = Math.hypot(ae.x - Q.x, ae.y - Q.y), D = Math.hypot(C.x - ae.x, C.y - ae.y), Z = Math.min(X + D - 0.01, Math.max(Math.abs(X - D) + 0.01, Math.hypot(_ - Q.x, V - Q.y))), se = (U) => U * 180 / Math.PI, re = se(Math.acos((X * X + Z * Z - D * D) / (2 * X * Z))), ie = 180 - se(Math.acos((X * X + D * D - Z * Z) / (2 * X * D)));
|
|
4560
4560
|
let $ = { rightShoulder: ee.rightShoulder, rightElbow: 0 }, z = 1 / 0;
|
|
4561
4561
|
for (const U of [1, -1])
|
|
4562
4562
|
for (const te of [1, -1]) {
|
|
4563
|
-
const q = { rightShoulder: ee.rightShoulder + U * re, rightElbow: te * ie }, le = { ...
|
|
4563
|
+
const q = { rightShoulder: ee.rightShoulder + U * re, rightElbow: te * ie }, le = { ...M, rightWrist: 0, ...q }, L = ne(le), J = Math.hypot(L.x - _, L.y - V) - We(le, { height: d, facing: p }).elbows.right.y * 1e-3;
|
|
4564
4564
|
J < z && (z = J, $ = q);
|
|
4565
4565
|
}
|
|
4566
4566
|
return $;
|
|
4567
|
-
}, I = (
|
|
4568
|
-
for (const
|
|
4569
|
-
const _ = Math.max(
|
|
4567
|
+
}, I = (M, _, V) => Math.abs(_ - f) < 2 ? M : (k.push({ time: M, value: f - c }, { time: M + V, value: _ - c, easing: "ease-in-out" }), f = _, M + V);
|
|
4568
|
+
for (const M of a) {
|
|
4569
|
+
const _ = Math.max(M.at ?? E, E === 0 ? 0 : O[O.length - 1].time);
|
|
4570
4570
|
let V = _, ee, F;
|
|
4571
|
-
const Q =
|
|
4572
|
-
if (s(
|
|
4573
|
-
const C =
|
|
4571
|
+
const Q = M.pose ?? {}, ae = l(M.do);
|
|
4572
|
+
if (s(M.do)) {
|
|
4573
|
+
const C = M.to ?? f, X = C === f ? p : j(C);
|
|
4574
4574
|
let D = _;
|
|
4575
|
-
X !== p ? D = x(_, X,
|
|
4576
|
-
const se = Math.abs(C - f) / eo(s(
|
|
4577
|
-
|
|
4578
|
-
} else if (
|
|
4579
|
-
const C =
|
|
4575
|
+
X !== p ? D = x(_, X, M.mood) : g.turn < 1 ? (D = _ + Ne, H(D, { turn: 1, ...Q }, M.mood)) : (M.mood || M.pose) && H(_ + Ne, Q, M.mood);
|
|
4576
|
+
const se = Math.abs(C - f) / eo(s(M.do), d), re = M.for ?? Math.max(Ne * 2, se * i(M.do)), ie = D + re;
|
|
4577
|
+
v.push({ time: D, value: M.do }), P.push({ time: D, value: 0 }, { time: D + Ne, value: 1, easing: "ease-out" }), P.push({ time: ie - Ne, value: 1 }, { time: ie, value: 0, easing: "ease-in" }), A.push({ time: D, value: b }, { time: ie, value: b + se }), k.push({ time: D, value: f - c }, { time: ie, value: C - c }), b += se, f = C, H(ie, {}), V = ie;
|
|
4578
|
+
} else if (M.do === "zip") {
|
|
4579
|
+
const C = M.to ?? f, X = C === f ? p : j(C);
|
|
4580
4580
|
let D = _;
|
|
4581
|
-
X !== p ? D = x(_, X,
|
|
4582
|
-
const Z = As("windUp", { at: D, from:
|
|
4581
|
+
X !== p ? D = x(_, X, M.mood) : g.turn < 1 && (D = _ + Ne, H(D, { turn: 1 }, M.mood));
|
|
4582
|
+
const Z = As("windUp", { at: D, from: M.mood ? gt(g, M.mood) : g });
|
|
4583
4583
|
O.push(...Z), g = Z[Z.length - 1].pose;
|
|
4584
4584
|
const se = D + mn("windUp"), re = se + _h, ie = re + Math.max(Nh, Math.abs(C - f) / Ch);
|
|
4585
|
-
|
|
4586
|
-
} else if (
|
|
4587
|
-
const C =
|
|
4588
|
-
let D = C === f ? _ : R(_, C,
|
|
4589
|
-
g.turn < 1 && (D += Ne, H(D, { turn: 1 },
|
|
4585
|
+
v.push({ time: se, value: "run" }), P.push({ time: se, value: 0 }, { time: se + 80, value: 1, easing: "ease-out" }, { time: ie, value: 1 }, { time: ie + 120, value: 0 }), A.push({ time: se, value: b }, { time: re, value: b + Is, easing: "ease-in" }), b += Is + (ie - re) / Hs.run * 1.5, A.push({ time: ie, value: b }), k.push({ time: re, value: f - c }, { time: ie, value: C - c, easing: "ease-in" }), T.push({ kind: "dust", time: re, x: f, y: u, length: 900 }), f = C, H(ie, {}), V = ie;
|
|
4586
|
+
} else if (M.do === "leap") {
|
|
4587
|
+
const C = M.to ?? f, X = M.onto ?? u;
|
|
4588
|
+
let D = C === f ? _ : R(_, C, M.mood);
|
|
4589
|
+
g.turn < 1 && (D += Ne, H(D, { turn: 1 }, M.mood));
|
|
4590
4590
|
const Z = { leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50 };
|
|
4591
|
-
H(D + Kh, { stretch: 0.75, bend: 12, leftHip: 22, rightHip: 22, ...Z },
|
|
4591
|
+
H(D + Kh, { stretch: 0.75, bend: 12, leftHip: 22, rightHip: 22, ...Z }, M.mood, !1);
|
|
4592
4592
|
const se = D + Wh;
|
|
4593
4593
|
H(se - 40, { stretch: 0.72 }, void 0, !1), H(se, { stretch: 1.2, bend: -6, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4 }, void 0, !1);
|
|
4594
|
-
const re = Math.hypot(C - f, X - u), ie =
|
|
4595
|
-
H(te, { stretch: 1, bend: 4, leftHip: -55, leftKnee: -80, rightHip: 55, rightKnee: 80, leftShoulder: 110, rightShoulder: 110 }, void 0, !1), H(q, { stretch: 0.72, bend: 12, leftShoulder: 75, rightShoulder: 75, leftElbow: 0, rightElbow: 0, leftHip: 18, rightHip: 18, leftKnee: 0, rightKnee: 0 }, void 0, !1), H(q + 180, { stretch: 1.05, bend: -3 }, void 0, !1), H(q + 340, { stretch: 1, bend: 0, leftHip: de.leftHip, rightHip: de.rightHip, leftShoulder: de.leftShoulder, rightShoulder: de.rightShoulder, leftElbow: de.leftElbow, rightElbow: de.rightElbow }, void 0, !1),
|
|
4594
|
+
const re = Math.hypot(C - f, X - u), ie = M.for ?? Math.min(js[1], Math.max(js[0], 300 + re * Rh)), $ = Math.min(u, X) - zh * d, z = Math.sqrt(u - $), U = Math.sqrt(X - $), te = se + ie * z / (z + U), q = se + ie;
|
|
4595
|
+
H(te, { stretch: 1, bend: 4, leftHip: -55, leftKnee: -80, rightHip: 55, rightKnee: 80, leftShoulder: 110, rightShoulder: 110 }, void 0, !1), H(q, { stretch: 0.72, bend: 12, leftShoulder: 75, rightShoulder: 75, leftElbow: 0, rightElbow: 0, leftHip: 18, rightHip: 18, leftKnee: 0, rightKnee: 0 }, void 0, !1), H(q + 180, { stretch: 1.05, bend: -3 }, void 0, !1), H(q + 340, { stretch: 1, bend: 0, leftHip: de.leftHip, rightHip: de.rightHip, leftShoulder: de.leftShoulder, rightShoulder: de.rightShoulder, leftElbow: de.leftElbow, rightElbow: de.rightElbow }, void 0, !1), k.push({ time: se, value: f - c }, { time: q, value: C - c }), m.push(
|
|
4596
4596
|
{ time: se, value: u - h },
|
|
4597
4597
|
{ time: te, value: $ - h, easing: "ease-out-quad" },
|
|
4598
4598
|
{ time: q, value: X - h, easing: "ease-in-quad" }
|
|
4599
|
-
), f = C, u = X,
|
|
4600
|
-
} else if (
|
|
4601
|
-
const C =
|
|
4602
|
-
H(ie, { ...D, rightShoulder: G(D, C.x, C.y), lookX: 1, lookY: oc(re / Math.max(1, Math.hypot(se, re))) * 0.8 }), V = ie + (
|
|
4603
|
-
} else if (
|
|
4604
|
-
const C =
|
|
4605
|
-
H(D + Zt, { ...re, rightShoulder: G(re, f - p * d * 0.3, u - d * 1.1) },
|
|
4599
|
+
), f = C, u = X, T.push({ kind: "dust", time: q, x: f, y: u, length: 500 }), V = q + 340, ee = q;
|
|
4600
|
+
} else if (M.do === "point" && M.target) {
|
|
4601
|
+
const C = M.target, X = R(_, C.x, M.mood), D = { ...g, ...M.mood ? Te[M.mood] : {}, turn: Math.max(g.turn, 0.6), rightElbow: 0, rightWrist: 0, ...Q }, Z = We(D, { height: d, facing: p }).head.center, se = Math.abs(C.x - (f + Z.x)), re = C.y - (u + Z.y), ie = X + Ce;
|
|
4602
|
+
H(ie, { ...D, rightShoulder: G(D, C.x, C.y), lookX: 1, lookY: oc(re / Math.max(1, Math.hypot(se, re))) * 0.8 }), V = ie + (M.for ?? Yn), ee = ie, F = V;
|
|
4603
|
+
} else if (M.do === "swipe") {
|
|
4604
|
+
const C = M.target ?? { x: f + p * d * 0.5, y: u - d * 0.6 }, X = j(C.x), D = R(_, C.x, M.mood), Z = X === 1 ? C.left ?? C.x : C.right ?? C.x, se = X === 1 ? C.right ?? C.x : C.left ?? C.x, re = { ...g, turn: 1, lean: -10, bend: -8, rightElbow: 40, lookX: 1, ...Q };
|
|
4605
|
+
H(D + Zt, { ...re, rightShoulder: G(re, f - p * d * 0.3, u - d * 1.1) }, M.mood, !1);
|
|
4606
4606
|
const ie = { ...g, lean: 6, bend: 4, rightElbow: 0, rightWrist: 0 }, $ = { ...g, lean: 14, bend: 12, rightElbow: 0, rightWrist: 0 };
|
|
4607
4607
|
I(D, Y(ie, Z, C.y, "arm"), Zt + Fn), H(D + Zt + Fn, { lean: -12 }, void 0, !1);
|
|
4608
4608
|
const z = D + Zt + Fn + 80;
|
|
4609
4609
|
H(z, { ...ie, rightShoulder: G(ie, Z, C.y) }, void 0, !1);
|
|
4610
|
-
const U = z + (
|
|
4611
|
-
|
|
4612
|
-
} else if (
|
|
4613
|
-
const C =
|
|
4610
|
+
const U = z + (M.for ?? Math.max(Fh, Math.abs(se - Z) / Dh));
|
|
4611
|
+
k.push({ time: z, value: f - c }), f = Y($, se, C.y, "arm"), k.push({ time: U, value: f - c }), H(U, { ...$, rightShoulder: G($, se, C.y) }, void 0, !1), H(U + Dn, { lean: 16, bend: 14, rightShoulder: G(g, se + X * d * 0.4, C.y + d * 0.25) }, void 0, !1), H(U + Dn + xs, { lean: 0, bend: 0, rightShoulder: de.rightShoulder, rightElbow: de.rightElbow }), V = U + Dn + xs, ee = z, F = U;
|
|
4612
|
+
} else if (M.do === "grab" && M.target) {
|
|
4613
|
+
const C = M.target, X = R(_, C.x, M.mood), D = C.y > u - d * 0.5, Z = {
|
|
4614
4614
|
...g,
|
|
4615
4615
|
turn: 1,
|
|
4616
4616
|
rightElbow: 0,
|
|
@@ -4621,15 +4621,15 @@ function No(e, n, t = {}) {
|
|
|
4621
4621
|
lookY: D ? 0.8 : 0,
|
|
4622
4622
|
...Q
|
|
4623
4623
|
}, re = I(X, Y(Z, C.x, C.y, "arm"), It) + Lh;
|
|
4624
|
-
H(re, { ...Z, rightShoulder: G(Z, C.x, C.y) },
|
|
4625
|
-
} else if (
|
|
4626
|
-
const C =
|
|
4627
|
-
H(X + Ln, { ...D, rightShoulder: G(D, f - p * d * 0.4, u - d * 1.05) },
|
|
4624
|
+
H(re, { ...Z, rightShoulder: G(Z, C.x, C.y) }, M.mood, !1), H(re + 120, {}, void 0, !1), H(re + _s, { bend: 0, lean: -3, stretch: 1, rightShoulder: 165, rightElbow: 20, lookY: -0.6 }), V = re + _s + 150, ee = re;
|
|
4625
|
+
} else if (M.do === "throw") {
|
|
4626
|
+
const C = M.target?.x ?? M.to ?? f + p * d, X = R(_, C, M.mood), D = { ...g, turn: 1, lean: -12, bend: -10, rightElbow: 60, stretch: 0.95, lookX: 1, lookY: -0.3, ...Q };
|
|
4627
|
+
H(X + Ln, { ...D, rightShoulder: G(D, f - p * d * 0.4, u - d * 1.05) }, M.mood, !1), H(X + Ln + Cs, { lean: -14 }, void 0, !1);
|
|
4628
4628
|
const Z = X + Ln + Cs + Bh, se = { ...g, lean: 14, bend: 12, rightElbow: 0, stretch: 1.04 };
|
|
4629
4629
|
O.push({ time: Z, pose: g = { ...se, rightShoulder: G(se, f + p * d, u - d * 1.1) }, easing: "ease-in", act: !1 }), H(Z + Bn, { lean: 18, bend: 14, rightShoulder: 55, stretch: 1 }, void 0, !1), H(Z + Bn + Ns, { lean: 0, bend: 0, rightShoulder: de.rightShoulder, rightElbow: de.rightElbow, lookY: 0 }), V = Z + Bn + Ns, ee = Z, F = Z;
|
|
4630
|
-
} else if (
|
|
4631
|
-
const C =
|
|
4632
|
-
H(Z + Ks, { turn: 1, lean: 8, bend: 6, rightHip: -40, rightKnee: 80, lookX: 1, lookY: 0.7, ...se, ...Q },
|
|
4630
|
+
} else if (M.do === "kick" && M.target) {
|
|
4631
|
+
const C = M.target, X = R(_, C.x, M.mood), D = { ...g, turn: 1, lean: -12, bend: -6, rightKnee: 0, leftShoulder: 100, rightShoulder: 70 }, Z = I(X, Y(D, C.x, C.y, "leg"), qh), se = { leftShoulder: 70, rightShoulder: 50, leftElbow: -20, rightElbow: 20 };
|
|
4632
|
+
H(Z + Ks, { turn: 1, lean: 8, bend: 6, rightHip: -40, rightKnee: 80, lookX: 1, lookY: 0.7, ...se, ...Q }, M.mood, !1);
|
|
4633
4633
|
const re = Z + Ks + Gh, ie = G(D, C.x, C.y, "leg");
|
|
4634
4634
|
O.push({ time: re, pose: g = { ...g, ...D, rightHip: ie }, easing: "ease-in", act: !1 }), H(re + qn, { lean: -15, rightHip: ie + 20 }, void 0, !1), H(re + qn + Ws, {
|
|
4635
4635
|
lean: 0,
|
|
@@ -4642,77 +4642,77 @@ function No(e, n, t = {}) {
|
|
|
4642
4642
|
rightElbow: de.rightElbow,
|
|
4643
4643
|
lookY: 0
|
|
4644
4644
|
}), V = re + qn + Ws, ee = re;
|
|
4645
|
-
} else if (
|
|
4646
|
-
const C =
|
|
4647
|
-
H(re, { ...Z, rightShoulder: G(Z, C.x, C.y) },
|
|
4648
|
-
} else if (
|
|
4649
|
-
const C =
|
|
4645
|
+
} else if (M.do === "put" && M.target) {
|
|
4646
|
+
const C = M.target, X = R(_, C.x, M.mood), D = C.y > u - d * 0.5, Z = { ...g, turn: 1, rightElbow: 0, rightWrist: 0, bend: D ? 35 : 0, lean: D ? 12 : 0, stretch: D ? 0.75 : 1, lookX: 1, lookY: D ? 0.8 : 0, ...Q }, re = I(X, Y(Z, C.x, C.y, "arm"), It) + Yh;
|
|
4647
|
+
H(re, { ...Z, rightShoulder: G(Z, C.x, C.y) }, M.mood, !1), H(re + Gn, {}, void 0, !1), H(re + Gn + Rs, { bend: 0, lean: 0, stretch: 1, rightShoulder: de.rightShoulder, rightElbow: de.rightElbow, lookY: 0 }), V = re + Gn + Rs, ee = re;
|
|
4648
|
+
} else if (M.do === "write" && M.target) {
|
|
4649
|
+
const C = M.target, X = C.left ?? C.x, D = C.right ?? C.x, Z = R(_, (X + D) / 2, M.mood), se = { ...g, turn: 1, rightElbow: 0, rightWrist: 0, ...Te.thinking, lookX: 1, lookY: 0, ...Q }, re = (L) => Y(se, L, C.y, "arm") + p * d * 0.08, ie = (L) => {
|
|
4650
4650
|
const W = ne({ ...se, ...B(se, L, C.y), rightWrist: 0 });
|
|
4651
4651
|
return Math.hypot(W.x - L, W.y - C.y) < 2;
|
|
4652
4652
|
}, $ = p === 1 ? X : D, z = I(Z, re((X + D) / 2), It), U = !ie(X) || !ie(D), te = U ? I(z, re(X), It) + zs : z + zs;
|
|
4653
|
-
H(te, { ...se, ...B(se, U ? X : $, C.y) },
|
|
4654
|
-
const q =
|
|
4655
|
-
U &&
|
|
4653
|
+
H(te, { ...se, ...B(se, U ? X : $, C.y) }, M.mood, !1);
|
|
4654
|
+
const q = M.for ?? Math.max(Xh, Math.abs(D - X) * Uh);
|
|
4655
|
+
U && k.push({ time: te, value: f - c });
|
|
4656
4656
|
for (let L = Fs, W = 0; L <= q; L += Fs, W++) {
|
|
4657
4657
|
const J = X + (D - X) * Math.min(L, q) / q;
|
|
4658
|
-
U && (f = re(J),
|
|
4658
|
+
U && (f = re(J), k.push({ time: te + L, value: f - c }));
|
|
4659
4659
|
const he = (W % 2 === 0 ? -1 : 1) * d * 0.02;
|
|
4660
4660
|
H(te + L, B(se, J, C.y + he), void 0, !1);
|
|
4661
4661
|
}
|
|
4662
4662
|
const le = te + q;
|
|
4663
4663
|
H(le, B(se, D, C.y), void 0, !1), H(le + Ds, { rightShoulder: de.rightShoulder, rightElbow: de.rightElbow, ...Te.happy }), V = le + Ds, ee = te, F = le;
|
|
4664
|
-
} else if (
|
|
4665
|
-
const C =
|
|
4666
|
-
H(U, z,
|
|
4667
|
-
const te = Math.abs(X - C.x), q = U + (
|
|
4668
|
-
|
|
4664
|
+
} else if (M.do === "push" && M.target) {
|
|
4665
|
+
const C = M.target, X = M.to ?? C.x, D = R(_, f + (X >= C.x ? 1 : -1), M.mood), Z = p === 1 ? C.left ?? C.x : C.right ?? C.x, se = { ...g, turn: 1, lean: 16, bend: 8, rightWrist: 0, leftWrist: 0, lookX: 1, ...Q }, re = Y(se, Z, C.y, "arm"), ie = I(D, re + p * d * 0.06, It), $ = B(se, Z, C.y), z = { ...se, ...$, leftShoulder: -$.rightShoulder, leftElbow: -$.rightElbow }, U = ie + Vh;
|
|
4666
|
+
H(U, z, M.mood, !1);
|
|
4667
|
+
const te = Math.abs(X - C.x), q = U + (M.for ?? Math.max(600, te / Jh)), le = te / eo("shove", d);
|
|
4668
|
+
v.push({ time: U, value: "shove" }), P.push({ time: U, value: 0 }, { time: U + Ne, value: 1, easing: "ease-out" }, { time: q - Ne, value: 1 }, { time: q, value: 0, easing: "ease-in" }), A.push({ time: U, value: b }, { time: q, value: b + le }), b += le, k.push({ time: U, value: f - c }, { time: q, value: f + (X - C.x) - c }), f += X - C.x, H(q, {}, void 0, !1), H(q + Ls, { lean: 0, bend: 0, rightShoulder: de.rightShoulder, leftShoulder: de.leftShoulder, rightElbow: de.rightElbow, leftElbow: de.leftElbow }), V = q + Ls, ee = U, F = q;
|
|
4669
4669
|
} else if (ae) {
|
|
4670
|
-
const C =
|
|
4671
|
-
O.push(...D), g = D[D.length - 1].pose, V = _ + Math.max(xh(X),
|
|
4672
|
-
} else if (Bs(
|
|
4673
|
-
const C = As(
|
|
4674
|
-
O.push(...C), g = C[C.length - 1].pose, V = _ + mn(
|
|
4675
|
-
} else if (
|
|
4676
|
-
const C =
|
|
4677
|
-
if (C === "viewer") H(_ + Ce, { turn: 0, lookX: 0, lookY: 0, ...Q },
|
|
4678
|
-
else if (C === "ahead") H(_ + Ce, { turn:
|
|
4679
|
-
else if (C === "back") H(_ + Ce, { turn: 0.2, lookX: -1, ...Q },
|
|
4670
|
+
const C = M.mood ? gt(g, M.mood) : g, X = ae.steps(C, M), D = Va(X, { at: _, from: C });
|
|
4671
|
+
O.push(...D), g = D[D.length - 1].pose, V = _ + Math.max(xh(X), M.for ?? 0);
|
|
4672
|
+
} else if (Bs(M.do)) {
|
|
4673
|
+
const C = As(M.do, { at: _, from: M.mood ? gt(g, M.mood) : g });
|
|
4674
|
+
O.push(...C), g = C[C.length - 1].pose, V = _ + mn(M.do), M.do === "take" && T.push({ kind: "dust", time: _ + 900, x: f, y: u, length: 500 }), M.do === "land" && T.push({ kind: "dust", time: _ + 120, x: f, y: u, length: 500 });
|
|
4675
|
+
} else if (M.do === "look" || M.do === "face") {
|
|
4676
|
+
const C = M.toward ?? "viewer", X = M.for ?? Zh;
|
|
4677
|
+
if (C === "viewer") H(_ + Ce, { turn: 0, lookX: 0, lookY: 0, ...Q }, M.mood);
|
|
4678
|
+
else if (C === "ahead") H(_ + Ce, { turn: M.do === "face" ? 1 : 0.6, lookX: 1, ...Q }, M.mood);
|
|
4679
|
+
else if (C === "back") H(_ + Ce, { turn: 0.2, lookX: -1, ...Q }, M.mood);
|
|
4680
4680
|
else {
|
|
4681
4681
|
const D = j(C);
|
|
4682
|
-
D !== p &&
|
|
4682
|
+
D !== p && M.do === "face" ? (x(_, D, M.mood), H(_ + dt + 1, { lookX: 1, ...Q })) : D !== p ? H(_ + Ce, { turn: 0.25, lookX: -1, ...Q }, M.mood) : H(_ + Ce, { turn: M.do === "face" ? 1 : 0.6, lookX: 1, ...Q }, M.mood);
|
|
4683
4683
|
}
|
|
4684
4684
|
V = _ + Math.max(X, Ce);
|
|
4685
|
-
} else if (tc(
|
|
4686
|
-
const C =
|
|
4687
|
-
H(_ + Ce, { ...C, turn: X, ...D, ...Q }), V = _ + (
|
|
4685
|
+
} else if (tc(M.do) || M.do === "stand") {
|
|
4686
|
+
const C = M.do === "stand" ? t.rest ?? de : Pe[M.do], X = C.turn !== de.turn ? C.turn : g.turn, D = M.mood ? Te[M.mood] : { lookX: g.lookX, lookY: g.lookY };
|
|
4687
|
+
H(_ + Ce, { ...C, turn: X, ...D, ...Q }), V = _ + (M.for ?? Yn);
|
|
4688
4688
|
} else {
|
|
4689
|
-
const C =
|
|
4690
|
-
(
|
|
4689
|
+
const C = M.for ?? (M.say ? nc(M.say) : Yn);
|
|
4690
|
+
(M.mood || M.pose) && H(_ + Math.min(Ce, C / 2), Q, M.mood), V = _ + C;
|
|
4691
4691
|
}
|
|
4692
|
-
if (
|
|
4693
|
-
const C = s(
|
|
4694
|
-
|
|
4692
|
+
if (M.say) {
|
|
4693
|
+
const C = s(M.do) || Bs(M.do) || ae ? _ : _ + Math.min(150, (V - _) / 4), X = s(M.do) ? V : Math.max(C + 200, V - 100);
|
|
4694
|
+
S.push({ text: M.say, start: C, end: X }), M.do === "say" && rc(O, g, C, X);
|
|
4695
4695
|
}
|
|
4696
|
-
|
|
4696
|
+
M.onto !== void 0 && M.do !== "leap" && M.onto !== u && (m.push({ time: _, value: u - h }, { time: V, value: M.onto - h, easing: "ease-in-out" }), u = M.onto), V > O[O.length - 1].time && O.push({ time: V, pose: g }), w.push({ start: _, end: V, ...ee !== void 0 ? { contact: ee } : {}, ...F !== void 0 ? { release: F } : {} }), E = V;
|
|
4697
4697
|
}
|
|
4698
4698
|
const N = Eh(e, ac(O), t), K = [
|
|
4699
|
-
{ id: `${e}-x`, target: e, property: "x", keyframes:
|
|
4699
|
+
{ id: `${e}-x`, target: e, property: "x", keyframes: k },
|
|
4700
4700
|
{ id: `${e}-y`, target: e, property: "y", keyframes: m },
|
|
4701
4701
|
{ id: `${e}-walk`, target: e, property: "walk", keyframes: A },
|
|
4702
4702
|
{ id: `${e}-walking`, target: e, property: "walking", keyframes: P },
|
|
4703
|
-
{ id: `${e}-gait`, target: e, property: "gait", keyframes:
|
|
4703
|
+
{ id: `${e}-gait`, target: e, property: "gait", keyframes: v },
|
|
4704
4704
|
{ id: `${e}-facing`, target: e, property: "facing", keyframes: y }
|
|
4705
4705
|
].filter(
|
|
4706
|
-
(
|
|
4707
|
-
|
|
4706
|
+
(M) => M.keyframes.length > 1 || M.property === "x" || // Starting left is kept even if it never turns: a figure target faces right unless told.
|
|
4707
|
+
M.property === "facing" && M.keyframes[0].value === -1
|
|
4708
4708
|
);
|
|
4709
4709
|
return {
|
|
4710
|
-
tracks: [...Io(e, N,
|
|
4711
|
-
duration:
|
|
4712
|
-
lines:
|
|
4710
|
+
tracks: [...Io(e, N, S, { energy: t.energy }), ...K],
|
|
4711
|
+
duration: E,
|
|
4712
|
+
lines: S,
|
|
4713
4713
|
keys: O,
|
|
4714
4714
|
beats: w,
|
|
4715
|
-
effects:
|
|
4715
|
+
effects: T
|
|
4716
4716
|
};
|
|
4717
4717
|
}
|
|
4718
4718
|
const oc = (e) => Math.max(-1, Math.min(1, e)), sc = 30;
|
|
@@ -4751,29 +4751,29 @@ ${r.map((f) => ` ${f.beat >= 0 ? `beat ${f.beat}: ` : ""}${f.message}`).join(`
|
|
|
4751
4751
|
t.forEach((f, u) => {
|
|
4752
4752
|
for (const p of hc(f)) {
|
|
4753
4753
|
const g = (m) => new Error(`surfaceScript: beat ${u} (${f.do}), ${p.edit} on ${p.surface}: ${m}`), b = (m, A) => {
|
|
4754
|
-
const P = typeof m == "object" ? m.beat : u,
|
|
4754
|
+
const P = typeof m == "object" ? m.beat : u, v = (typeof m == "object" ? m.at : m) ?? A ?? "start", y = i[P][v];
|
|
4755
4755
|
if (y === void 0) {
|
|
4756
|
-
const
|
|
4757
|
-
throw g(`beat ${P} (${t[P].do}) has no ${
|
|
4756
|
+
const S = Nt.filter((w) => i[P][w] !== void 0).join(", ");
|
|
4757
|
+
throw g(`beat ${P} (${t[P].do}) has no ${v} (it has ${S})`);
|
|
4758
4758
|
}
|
|
4759
4759
|
return y;
|
|
4760
|
-
},
|
|
4761
|
-
if (
|
|
4760
|
+
}, E = n[p.surface], O = b(p.at ?? (i[u].contact !== void 0 ? "contact" : "start")), k = p.until === void 0 ? void 0 : b(p.until, "end");
|
|
4761
|
+
if (k !== void 0 && k < O) throw g(`it ends (${k} ms) before it starts (${O} ms)`);
|
|
4762
4762
|
try {
|
|
4763
4763
|
if (p.edit === "carry") {
|
|
4764
|
-
const A =
|
|
4764
|
+
const A = E.piece(p.anchor), P = er(e, c(s.tracks), {
|
|
4765
4765
|
x: o.from ?? 0,
|
|
4766
4766
|
y: l,
|
|
4767
4767
|
style: o.figureStyle ?? (o.height ? { height: o.height } : void 0),
|
|
4768
4768
|
cast: o,
|
|
4769
4769
|
start: O,
|
|
4770
|
-
end:
|
|
4770
|
+
end: k
|
|
4771
4771
|
});
|
|
4772
|
-
|
|
4772
|
+
E.follow(A, P);
|
|
4773
4773
|
continue;
|
|
4774
4774
|
}
|
|
4775
4775
|
const m = Object.fromEntries(Object.entries(p).filter(([A]) => !ic.includes(A)));
|
|
4776
|
-
|
|
4776
|
+
E.edit(p.edit, p.anchor, { ...m, at: O, ...k !== void 0 ? { duration: k - O } : {} });
|
|
4777
4777
|
} catch (m) {
|
|
4778
4778
|
throw g(m.message);
|
|
4779
4779
|
}
|
|
@@ -4821,9 +4821,9 @@ function cc(e, n, t = {}) {
|
|
|
4821
4821
|
}
|
|
4822
4822
|
const p = u, g = a(h, p.surface, "`then`");
|
|
4823
4823
|
if (!g) return;
|
|
4824
|
-
const b = `\`then\` (${String(p.edit)} on ${String(p.surface)})`,
|
|
4825
|
-
if (typeof p.edit != "string" || !
|
|
4826
|
-
o.push({ level: "error", beat: h, message: `\`then\`: ${ce("edit", p.edit,
|
|
4824
|
+
const b = `\`then\` (${String(p.edit)} on ${String(p.surface)})`, E = [...Object.keys(g.about.edits), ...lc];
|
|
4825
|
+
if (typeof p.edit != "string" || !E.includes(p.edit)) {
|
|
4826
|
+
o.push({ level: "error", beat: h, message: `\`then\`: ${ce("edit", p.edit, E)}` });
|
|
4827
4827
|
return;
|
|
4828
4828
|
}
|
|
4829
4829
|
for (const O of Array.isArray(p.anchor) ? p.anchor : [p.anchor]) s(h, g, O, b);
|
|
@@ -4910,21 +4910,21 @@ function uc(e, n, t = 1) {
|
|
|
4910
4910
|
return ua(n, i / qs, t);
|
|
4911
4911
|
}
|
|
4912
4912
|
function zf(e, n, t, o = {}) {
|
|
4913
|
-
const r = No(e, t, { ...o, height: n.height, reach: o.reach ?? gc(n) }), a = r.tracks.find((
|
|
4913
|
+
const r = No(e, t, { ...o, height: n.height, reach: o.reach ?? gc(n) }), a = r.tracks.find((E) => E.property === "facing")?.keyframes ?? [], s = (E) => {
|
|
4914
4914
|
let O = o.facing ?? 1;
|
|
4915
|
-
for (const
|
|
4915
|
+
for (const k of a) k.time <= E && (O = k.value);
|
|
4916
4916
|
return O;
|
|
4917
|
-
}, i = pa(r.keys), l = r.keys.map((
|
|
4918
|
-
const
|
|
4917
|
+
}, i = pa(r.keys), l = r.keys.map((E, O) => {
|
|
4918
|
+
const k = qi(i[O]);
|
|
4919
4919
|
return {
|
|
4920
|
-
time:
|
|
4921
|
-
pose: s(
|
|
4922
|
-
...
|
|
4923
|
-
...
|
|
4920
|
+
time: E.time,
|
|
4921
|
+
pose: s(E.time) < 0 ? Nr(k) : k,
|
|
4922
|
+
...E.easing ? { easing: E.easing } : {},
|
|
4923
|
+
...E.act === !1 ? { act: !1 } : {}
|
|
4924
4924
|
};
|
|
4925
4925
|
}), { rest: c, start: h, ...d } = o;
|
|
4926
4926
|
bc(l, i, t, r, n, s, o);
|
|
4927
|
-
const f = Th(e, l, d), u = Io(e, f, r.lines, { energy: o.energy }), p = r.tracks.filter((
|
|
4927
|
+
const f = Th(e, l, d), u = Io(e, f, r.lines, { energy: o.energy }), p = r.tracks.filter((E) => fc.has(E.property)), g = r.tracks.find((E) => E.property === "walk");
|
|
4928
4928
|
return { tracks: g ? [...u, ...p, Mc(e, g, r.tracks, n, o)] : [...u, ...p], duration: r.duration, lines: r.lines, keys: l, beats: r.beats, effects: r.effects };
|
|
4929
4929
|
}
|
|
4930
4930
|
function gc(e) {
|
|
@@ -4943,20 +4943,20 @@ function bc(e, n, t, o, r, a, s) {
|
|
|
4943
4943
|
const f = pc[h.do], u = i[d];
|
|
4944
4944
|
if (!f || u.contact === void 0 || h.do !== "swipe" && !h.target) return;
|
|
4945
4945
|
const p = u.contact, g = u.release ?? u.contact;
|
|
4946
|
-
e.forEach((b,
|
|
4946
|
+
e.forEach((b, E) => {
|
|
4947
4947
|
if (b.time < p - 1 || b.time > g + 1) return;
|
|
4948
|
-
const O = a(b.time),
|
|
4948
|
+
const O = a(b.time), k = We(n[E], { height: r.height, facing: O < 0 ? -1 : 1 }), m = c(b.time), A = mc.has(h.do) && h.target ? { x: h.target.x - m.x, y: h.target.y - m.y } : void 0, P = { x: (k.hands.right.x + k.fingertips.right.x) / 2, y: (k.hands.right.y + k.fingertips.right.y) / 2 }, v = A ?? (f === "arm" ? P : k.toes.right), y = O < 0 ? "right" : "left", S = `${f}.${y}`;
|
|
4949
4949
|
let w = b.pose;
|
|
4950
4950
|
if (h.do === "point")
|
|
4951
|
-
w = Ge(r, w,
|
|
4951
|
+
w = Ge(r, w, S, v);
|
|
4952
4952
|
else if (f === "arm")
|
|
4953
|
-
w = Ge(r, Sc(r, w, y,
|
|
4953
|
+
w = Ge(r, Sc(r, w, y, v), S, v);
|
|
4954
4954
|
else
|
|
4955
|
-
for (let
|
|
4955
|
+
for (let T = 0; T < 3; T++) {
|
|
4956
4956
|
const H = xe(r, w).points, x = H[`ankle.${y}`], j = H[`toe.${y}`];
|
|
4957
|
-
w = Ge(r, w,
|
|
4957
|
+
w = Ge(r, w, S, { x: v.x - (j.x - x.x), y: v.y - (j.y - x.y) });
|
|
4958
4958
|
}
|
|
4959
|
-
e[
|
|
4959
|
+
e[E] = { ...b, pose: w };
|
|
4960
4960
|
});
|
|
4961
4961
|
});
|
|
4962
4962
|
}
|
|
@@ -5039,7 +5039,7 @@ function Ff(e, n, t) {
|
|
|
5039
5039
|
const l = t.speed ?? 900, c = t.length ?? 34, h = t.slant ?? -8, d = Et(t.seed ?? 1), f = s + c * 2;
|
|
5040
5040
|
e.save(), e.beginPath(), e.rect(o, r, a, s), e.clip(), e.strokeStyle = je(t.color ?? "rgb(190,210,235)", t.opacity ?? 0.35), e.lineWidth = t.lineWidth ?? 2, e.lineCap = "round", e.beginPath();
|
|
5041
5041
|
for (let u = 0; u < i; u++) {
|
|
5042
|
-
const p = o + d.next() * a, g = l * (1 + d.next() * 0.6), b = d.next() * f,
|
|
5042
|
+
const p = o + d.next() * a, g = l * (1 + d.next() * 0.6), b = d.next() * f, E = n / 1e3 * g + b, O = r - c + (E % f + f) % f;
|
|
5043
5043
|
e.moveTo(p, O), e.lineTo(p + h, O + c);
|
|
5044
5044
|
}
|
|
5045
5045
|
e.stroke(), e.restore();
|
|
@@ -5146,10 +5146,10 @@ function Zf(e, n, t) {
|
|
|
5146
5146
|
e.translate(t.anchor.x + (l === "right" ? h : -h), t.anchor.y + a * 0.6), e.rotate((t.tilt ?? -3.4) * Math.PI / 180), e.globalAlpha *= o, e.font = Se(a, 800, i);
|
|
5147
5147
|
const d = e.measureText(t.name).width;
|
|
5148
5148
|
e.font = Se(s, 700, i);
|
|
5149
|
-
const f = t.role ? e.measureText(t.role).width : 0, u = a * 0.47, p = Math.max(d, f) + u * 2 + 10, g = -a * 1.1, b = t.role ? a + s + a * 0.95 : a * 1.6,
|
|
5150
|
-
Oe(e,
|
|
5149
|
+
const f = t.role ? e.measureText(t.role).width : 0, u = a * 0.47, p = Math.max(d, f) + u * 2 + 10, g = -a * 1.1, b = t.role ? a + s + a * 0.95 : a * 1.6, E = l === "right" ? 0 : -p;
|
|
5150
|
+
Oe(e, E, g, p, b, 4), e.fillStyle = t.color ?? Tt, e.fill(), e.strokeStyle = t.ink ?? at, e.lineWidth = 5, e.stroke(), e.textAlign = "left", e.textBaseline = "alphabetic", e.fillStyle = "#ffffff", e.font = Se(a, 800, i);
|
|
5151
5151
|
const O = t.role ? g + a * 1.1 + a * 0.22 : g + b / 2 + a * 0.35;
|
|
5152
|
-
return e.fillText(t.name,
|
|
5152
|
+
return e.fillText(t.name, E + u, O), t.role && (e.font = Se(s, 700, i), e.fillStyle = Ro, e.fillText(t.role, E + u, O + s * 1.45)), e.restore(), o;
|
|
5153
5153
|
}
|
|
5154
5154
|
function Pc(e, n, t, o) {
|
|
5155
5155
|
const r = _e($e(e, n - 50, 300)) * (1 - _e($e(e, t, 250))), a = o ?? Math.min(1600, Math.max(0, t - n) * 0.5);
|
|
@@ -5177,8 +5177,8 @@ function Qf(e, n, t) {
|
|
|
5177
5177
|
e.font = Se(l, 700, c), e.fillStyle = h, e.textBaseline = "alphabetic";
|
|
5178
5178
|
const p = Oc(f, r);
|
|
5179
5179
|
return f.forEach((g, b) => {
|
|
5180
|
-
const
|
|
5181
|
-
e.textAlign = "left", e.fillText(p[b], a + s / 2 -
|
|
5180
|
+
const E = e.measureText(g).width;
|
|
5181
|
+
e.textAlign = "left", e.fillText(p[b], a + s / 2 - E / 2, u + l * 1.38 + b * d);
|
|
5182
5182
|
}), e.restore(), o;
|
|
5183
5183
|
}
|
|
5184
5184
|
function eu(e, n, t) {
|
|
@@ -5186,19 +5186,19 @@ function eu(e, n, t) {
|
|
|
5186
5186
|
if (!(n >= o && n <= r + 220) || a <= 0.01) return 0;
|
|
5187
5187
|
const s = t.size ?? 40, i = t.font ?? ot, l = t.ink ?? at, c = t.fill ?? "#ffffff", h = t.bounds ?? { x: 40, y: 40, width: 1840 }, d = t.tail;
|
|
5188
5188
|
e.save(), e.font = Se(s, 700, i);
|
|
5189
|
-
const f = Wo(e, t.text, t.maxWidth ?? 640), u = s * 1.3, p = Math.max(...f.map((A) => e.measureText(A).width)) + s * 1.75, g = f.length * u + s * 1.25, b = t.speaker ? s * 0.5 : 0,
|
|
5189
|
+
const f = Wo(e, t.text, t.maxWidth ?? 640), u = s * 1.3, p = Math.max(...f.map((A) => e.measureText(A).width)) + s * 1.75, g = f.length * u + s * 1.25, b = t.speaker ? s * 0.5 : 0, E = Math.min(h.x + h.width - p / 2, Math.max(h.x + p / 2, d.x));
|
|
5190
5190
|
let O = Math.min(d.y - (t.gap ?? 70) - g / 2, t.maxCenterY ?? 1 / 0);
|
|
5191
5191
|
O = Math.max(h.y + b + g / 2, O);
|
|
5192
|
-
const
|
|
5193
|
-
e.translate(
|
|
5194
|
-
const m = Math.min(Math.max(
|
|
5195
|
-
if (e.beginPath(), e.moveTo(m - 22, O + g / 2 - 4), e.lineTo(
|
|
5192
|
+
const k = { x: d.x + (E - d.x) * 0.2, y: Math.max(O + g / 2 + 16, d.y - 14) };
|
|
5193
|
+
e.translate(k.x, k.y), e.scale(a, a), e.translate(-k.x, -k.y), e.fillStyle = c, e.strokeStyle = l, e.lineWidth = 5, e.lineJoin = "round";
|
|
5194
|
+
const m = Math.min(Math.max(k.x, E - p / 2 + 50), E + p / 2 - 50);
|
|
5195
|
+
if (e.beginPath(), e.moveTo(m - 22, O + g / 2 - 4), e.lineTo(k.x, k.y), e.lineTo(m + 22, O + g / 2 - 4), e.closePath(), e.fill(), e.stroke(), Oe(e, E - p / 2, O - g / 2, p, g, 26), e.fill(), e.stroke(), e.fillRect(m - 19, O + g / 2 - 8, 38, 6), t.speaker) {
|
|
5196
5196
|
const A = s * 0.68;
|
|
5197
5197
|
e.font = Se(A, 800, i);
|
|
5198
5198
|
const P = e.measureText(t.speaker).width + A * 1.1;
|
|
5199
|
-
Oe(e,
|
|
5199
|
+
Oe(e, E - p / 2 + 18, O - g / 2 - A * 0.74, P, A * 1.4, 6), e.fillStyle = t.tagColor ?? l, e.fill(), e.fillStyle = t.tagText ?? Ro, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t.speaker, E - p / 2 + 18 + A * 0.55, O - g / 2 - A * 0.04);
|
|
5200
5200
|
}
|
|
5201
|
-
return e.font = Se(s, 700, i), e.fillStyle = l, e.textAlign = "center", e.textBaseline = "alphabetic", f.forEach((A, P) => e.fillText(A,
|
|
5201
|
+
return e.font = Se(s, 700, i), e.fillStyle = l, e.textAlign = "center", e.textBaseline = "alphabetic", f.forEach((A, P) => e.fillText(A, E, O - g / 2 + s * 1.65 + P * u)), e.restore(), a;
|
|
5202
5202
|
}
|
|
5203
5203
|
const fo = ["photo", "note"], uo = {
|
|
5204
5204
|
cross: "two diagonals across the card, one after the other (ruled out)",
|
|
@@ -5331,9 +5331,9 @@ function nu(e, n, t, o = {}) {
|
|
|
5331
5331
|
if (u <= 0) continue;
|
|
5332
5332
|
const p = f.width, g = f.height;
|
|
5333
5333
|
e.save(), e.translate(r + f.x, a + f.y - 40 * (1 - Math.min(1, u))), e.rotate(f.angle * Math.PI / 180), e.scale(u, u), Oe(e, -p / 2, 0, p, g, 3), e.fillStyle = f.color, e.fill(), e.lineWidth = 3, e.strokeStyle = l, e.stroke();
|
|
5334
|
-
const b = f.kind === "photo",
|
|
5335
|
-
b && (e.fillStyle = "#1e2530", e.fillRect(
|
|
5336
|
-
const O =
|
|
5334
|
+
const b = f.kind === "photo", E = b ? { x: -p / 2 + 18, y: 18, width: p - 36, height: g * 0.62 } : { x: -p / 2 + 12, y: 14, width: p - 24, height: g * 0.45 };
|
|
5335
|
+
b && (e.fillStyle = "#1e2530", e.fillRect(E.x, E.y, E.width, E.height)), o.drawCard && (e.save(), e.beginPath(), e.rect(E.x, E.y, E.width, E.height), e.clip(), o.drawCard(e, f, E, t), e.restore()), e.textAlign = "center", e.textBaseline = "alphabetic";
|
|
5336
|
+
const O = E.y + E.height;
|
|
5337
5337
|
if (b)
|
|
5338
5338
|
f.title && (e.font = Se(28, 800, n.font), e.fillStyle = l, e.fillText(f.title, 0, O + (g - O) * 0.45, p - 16)), f.note && (e.font = Se(19, 600, n.font), e.fillStyle = "#7f1d1d", e.fillText(f.note, 0, O + (g - O) * 0.8, p - 16));
|
|
5339
5339
|
else {
|
|
@@ -5341,11 +5341,11 @@ function nu(e, n, t, o = {}) {
|
|
|
5341
5341
|
`);
|
|
5342
5342
|
e.font = Se(26, 700, n.handFont), e.fillStyle = l;
|
|
5343
5343
|
const A = Wo(e, m, p - 20), P = o.drawCard ? O + 8 : (g - A.length * 30) / 2;
|
|
5344
|
-
A.forEach((
|
|
5344
|
+
A.forEach((v, y) => e.fillText(v, 0, P + 24 + y * 30, p - 12));
|
|
5345
5345
|
}
|
|
5346
5346
|
f.highlight && t >= f.highlight.at && t <= f.highlight.at + f.highlight.duration && (e.strokeStyle = nr, e.lineWidth = 8, e.globalAlpha *= 0.6 + 0.4 * Math.sin((t - f.highlight.at) / 1e3 * 6), e.strokeRect(-p / 2 - 8, -8, p + 16, g + 16)), e.restore();
|
|
5347
|
-
const
|
|
5348
|
-
Ic(e,
|
|
5347
|
+
const k = Un(n, f.id).pin;
|
|
5348
|
+
Ic(e, k.x, k.y - 40 * (1 - Math.min(1, u)), { ink: l });
|
|
5349
5349
|
}
|
|
5350
5350
|
for (const f of n.marks) {
|
|
5351
5351
|
if (t <= f.at) continue;
|
|
@@ -5448,7 +5448,7 @@ function Kc(e, n, t) {
|
|
|
5448
5448
|
for (let s = 0; s + 1 < n.length; s++)
|
|
5449
5449
|
for (let i = 0; i + 1 < t.length; i++) {
|
|
5450
5450
|
const l = [], c = /* @__PURE__ */ new Map(), h = (p) => {
|
|
5451
|
-
const g = p.map((
|
|
5451
|
+
const g = p.map((E) => Math.round(E * 1e6)).join(",");
|
|
5452
5452
|
let b = c.get(g);
|
|
5453
5453
|
return b === void 0 && (b = l.length, l.push(p), c.set(g, b)), b;
|
|
5454
5454
|
}, d = [], f = (p) => p === 0, u = (p, g) => p + 2 === g.length;
|
|
@@ -5600,7 +5600,7 @@ const Vn = (() => {
|
|
|
5600
5600
|
})(), qc = Math.cos(35 * po);
|
|
5601
5601
|
function hr(e, n, t, o, r = {}) {
|
|
5602
5602
|
const a = e.derive ? { ...n, ...e.derive(n) } : n, s = Do(e, a), i = t.toView([0, 0, 0]), l = (j) => (R) => [j[0] * R[0] + j[4] * R[1] + j[8] * R[2], j[1] * R[0] + j[5] * R[1] + j[9] * R[2], j[2] * R[0] + j[6] * R[1] + j[10] * R[2]], c = Rt(e, a), h = r.slice === void 0 ? null : oe.invert(c), d = h ? e.parts.map((j) => ({ part: j, mesh: an(j.shape), local: oe.multiply(h, s.get(j.id)), whole: j.shape.type === "tube" })) : void 0, f = d ? Fc(d, r.slice) : void 0, u = d ? ir(d.map((j) => ({ part: j.part.id, mesh: j.mesh, ...Fo(j.mesh, j.local) }))) : void 0, p = (j, R, G, Y) => {
|
|
5603
|
-
const ne = (W) => t.toView(oe.transformPoint(G, W)), B = R.vertices.map(ne), I = B.map((W) => t.toScreen(W)), N = r.perspective ? r.near : void 0, K = (W) => W.map((J) => t.toScreen(J)),
|
|
5603
|
+
const ne = (W) => t.toView(oe.transformPoint(G, W)), B = R.vertices.map(ne), I = B.map((W) => t.toScreen(W)), N = r.perspective ? r.near : void 0, K = (W) => W.map((J) => t.toScreen(J)), M = (W) => N === void 0 ? W : Ys(W, N), _ = (W) => N === void 0 ? [W] : _c(W, N), V = l(G), ee = R.faces.map((W) => {
|
|
5604
5604
|
const J = t.toView(V(W.normal)), he = [J[0] - i[0], J[1] - i[1], J[2] - i[2]], fe = Math.hypot(...he) || 1;
|
|
5605
5605
|
return [he[0] / fe, he[1] / fe, he[2] / fe];
|
|
5606
5606
|
}), F = u && Y ? lr(j.id, R, Y, ar(Y), u) : void 0, Q = (W) => F?.[W] ?? !1, ae = ee.map((W, J) => {
|
|
@@ -5611,7 +5611,7 @@ function hr(e, n, t, o, r = {}) {
|
|
|
5611
5611
|
}), C = (W) => R.faces[W].corners.reduce((J, he) => J + B[he][2], 0) / R.faces[W].corners.length, X = R.faces.map((W, J) => ({ face: W, i: J })).filter(({ i: W }) => ae[W]).map(({ face: W, i: J }) => ({
|
|
5612
5612
|
i: J,
|
|
5613
5613
|
solved: {
|
|
5614
|
-
points: N === void 0 ? W.corners.map((he) => I[he]) : K(
|
|
5614
|
+
points: N === void 0 ? W.corners.map((he) => I[he]) : K(M(W.corners.map((he) => B[he]))),
|
|
5615
5615
|
depth: C(J),
|
|
5616
5616
|
tone: 0.72 + 0.33 * Math.max(0, ee[J][0] * Vn[0] + ee[J][1] * Vn[1] + ee[J][2] * Vn[2])
|
|
5617
5617
|
}
|
|
@@ -5657,25 +5657,25 @@ function hr(e, n, t, o, r = {}) {
|
|
|
5657
5657
|
...j.shape.type === "tube" ? { spine: Vc(_(j.shape.points.map(ne)).map(K)) } : {},
|
|
5658
5658
|
...R.walls ? { cut: !0 } : {}
|
|
5659
5659
|
};
|
|
5660
|
-
}, g = new Map(d?.map((j) => [j.part.id, j.local])),
|
|
5660
|
+
}, g = new Map(d?.map((j) => [j.part.id, j.local])), E = (f ? f.pieces.map((j) => ({
|
|
5661
5661
|
part: j.part,
|
|
5662
5662
|
mesh: j.mesh,
|
|
5663
5663
|
// A cut piece is already in rest space: the body's matrix places it.
|
|
5664
5664
|
m: j.cut ? c : s.get(j.part.id),
|
|
5665
5665
|
local: j.cut ? oe.identity() : g.get(j.part.id),
|
|
5666
5666
|
cell: j.cell
|
|
5667
|
-
})) : e.parts.map((j) => ({ part: j, mesh: an(j.shape), m: s.get(j.id), local: void 0, cell: void 0 }))).map((j) => ({ cell: j.cell, solved: p(j.part, j.mesh, j.m, j.local) })), O =
|
|
5667
|
+
})) : e.parts.map((j) => ({ part: j, mesh: an(j.shape), m: s.get(j.id), local: void 0, cell: void 0 }))).map((j) => ({ cell: j.cell, solved: p(j.part, j.mesh, j.m, j.local) })), O = E.map((j) => j.solved), k = (j) => j.filter((R) => R.faces.length > 0 && R.opacity > 0.01).sort((R, G) => R.depth - G.depth);
|
|
5668
5668
|
let m;
|
|
5669
5669
|
if (f) {
|
|
5670
5670
|
const j = new Map(e.parts.map((G) => {
|
|
5671
5671
|
const Y = s.get(G.id), ne = an(G.shape).vertices;
|
|
5672
5672
|
return [G.id, ne.reduce((B, I) => B + t.toView(oe.transformPoint(Y, I))[2], 0) / Math.max(1, ne.length)];
|
|
5673
5673
|
})), R = /* @__PURE__ */ new Map();
|
|
5674
|
-
for (const G of
|
|
5674
|
+
for (const G of E) {
|
|
5675
5675
|
const Y = G.cell.join(",");
|
|
5676
5676
|
R.has(Y) || R.set(Y, { cell: G.cell, parts: [] }), R.get(Y).parts.push(G.solved), G.solved.depth = j.get(G.solved.part.id);
|
|
5677
5677
|
}
|
|
5678
|
-
m = [...R.values()].map(({ cell: G, parts: Y }) => ({ depth: t.toView(oe.transformPoint(c, f.middle(G)))[2], parts:
|
|
5678
|
+
m = [...R.values()].map(({ cell: G, parts: Y }) => ({ depth: t.toView(oe.transformPoint(c, f.middle(G)))[2], parts: k(Y) })).filter((G) => G.parts.length > 0);
|
|
5679
5679
|
}
|
|
5680
5680
|
const A = {};
|
|
5681
5681
|
for (const [j, R] of Object.entries(e.anchors ?? {})) {
|
|
@@ -5684,14 +5684,14 @@ function hr(e, n, t, o, r = {}) {
|
|
|
5684
5684
|
const Y = t.toView(oe.transformPoint(G, R.at));
|
|
5685
5685
|
A[j] = { point: t.toScreen(Y), depth: Y[2] };
|
|
5686
5686
|
}
|
|
5687
|
-
const [P,
|
|
5687
|
+
const [P, v] = e.footprint ?? [e.length * 0.45, e.length], y = Math.max(0, ye(e, a, "lift")), S = Math.max(0, ye(e, a, "size")) / (1 + y * 0.8), w = Array.from({ length: 24 }, (j, R) => {
|
|
5688
5688
|
const G = Math.PI * 2 * R / 24;
|
|
5689
|
-
return t.toView([Math.cos(G) * P * 0.55 *
|
|
5690
|
-
}),
|
|
5691
|
-
points: (
|
|
5692
|
-
opacity: 0.16 *
|
|
5689
|
+
return t.toView([Math.cos(G) * P * 0.55 * S, 0, Math.sin(G) * v * 0.55 * S]);
|
|
5690
|
+
}), T = r.perspective ? r.near : void 0, H = {
|
|
5691
|
+
points: (T === void 0 ? w : Ys(w, T)).map((j) => t.toScreen(j)),
|
|
5692
|
+
opacity: 0.16 * S
|
|
5693
5693
|
}, x = O.filter((j) => j.part.seeThrough && j.opacity > 0.01).flatMap((j) => j.faces.map((R) => R.points));
|
|
5694
|
-
return { under:
|
|
5694
|
+
return { under: k(O.filter((j) => !j.part.overRider)), over: k(O.filter((j) => j.part.overRider)), ...m ? { cells: m } : {}, anchors: A, openings: x, shadow: H, pxPerUnit: o, sizePx: e.height * o };
|
|
5695
5695
|
}
|
|
5696
5696
|
const ea = /* @__PURE__ */ new WeakMap();
|
|
5697
5697
|
function Gc(e) {
|
|
@@ -5853,53 +5853,53 @@ const xt = {
|
|
|
5853
5853
|
}
|
|
5854
5854
|
}, Qc = 400, e0 = 0.2;
|
|
5855
5855
|
function su(e, n = {}) {
|
|
5856
|
-
const { prop: t } = e, o = dr(t), r = Object.keys(o), a = Object.keys(t.rig.anchors ?? {}), s = t.rig.parts.map((P) => P.id), i = Ft(), l = $n(i), c = n.tracks?.length ? new ve({ id: `${t.kind}-surface`, tracks: n.tracks }) : void 0, h = Math.max(0, ...(n.tracks ?? []).flatMap((P) => P.keyframes.map((
|
|
5856
|
+
const { prop: t } = e, o = dr(t), r = Object.keys(o), a = Object.keys(t.rig.anchors ?? {}), s = t.rig.parts.map((P) => P.id), i = Ft(), l = $n(i), c = n.tracks?.length ? new ve({ id: `${t.kind}-surface`, tracks: n.tracks }) : void 0, h = Math.max(0, ...(n.tracks ?? []).flatMap((P) => P.keyframes.map((v) => v.time))), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
5857
5857
|
e.loose = f;
|
|
5858
5858
|
const u = e.props, p = (P) => {
|
|
5859
|
-
const
|
|
5860
|
-
let y = 0,
|
|
5859
|
+
const v = { ...e.props };
|
|
5860
|
+
let y = 0, S = 0;
|
|
5861
5861
|
if (c) {
|
|
5862
5862
|
const w = c.getStateAtTime(Math.min(P, h));
|
|
5863
|
-
for (const
|
|
5864
|
-
for (const [H, x] of
|
|
5865
|
-
typeof x == "number" && (H === "x" ? y = x : H === "y" ?
|
|
5863
|
+
for (const T of w.values.values())
|
|
5864
|
+
for (const [H, x] of T)
|
|
5865
|
+
typeof x == "number" && (H === "x" ? y = x : H === "y" ? S = x : H in v && (v[H] = x));
|
|
5866
5866
|
}
|
|
5867
|
-
for (const w of r) i.keys(w)?.length && (
|
|
5868
|
-
return { values:
|
|
5867
|
+
for (const w of r) i.keys(w)?.length && (v[w] = i.valueAt(w, P));
|
|
5868
|
+
return { values: v, origin: { x: e.x + e.width / 2 + y, y: e.y + e.height + S } };
|
|
5869
5869
|
}, g = (P) => {
|
|
5870
|
-
const { kind:
|
|
5871
|
-
if (
|
|
5872
|
-
if (y) throw
|
|
5873
|
-
return { kind:
|
|
5870
|
+
const { kind: v, rest: y } = Mt(P), S = (w) => et(t.kind, P, xt, w);
|
|
5871
|
+
if (v === "box") {
|
|
5872
|
+
if (y) throw S("box takes no arguments");
|
|
5873
|
+
return { kind: v };
|
|
5874
5874
|
}
|
|
5875
|
-
if (
|
|
5876
|
-
if (!a.includes(y)) throw
|
|
5877
|
-
return { kind:
|
|
5875
|
+
if (v === "anchor") {
|
|
5876
|
+
if (!a.includes(y)) throw S(ce(`${t.kind} anchor`, y, a));
|
|
5877
|
+
return { kind: v, name: y };
|
|
5878
5878
|
}
|
|
5879
|
-
if (
|
|
5880
|
-
if (!s.includes(y)) throw
|
|
5881
|
-
return { kind:
|
|
5879
|
+
if (v === "part") {
|
|
5880
|
+
if (!s.includes(y)) throw S(ce(`${t.kind} part`, y, s));
|
|
5881
|
+
return { kind: v, name: y };
|
|
5882
5882
|
}
|
|
5883
|
-
if (
|
|
5884
|
-
if (!r.includes(y)) throw
|
|
5885
|
-
return { kind:
|
|
5883
|
+
if (v === "control") {
|
|
5884
|
+
if (!r.includes(y)) throw S(ce(`${t.kind} control`, y, r));
|
|
5885
|
+
return { kind: v, name: y };
|
|
5886
5886
|
}
|
|
5887
|
-
throw
|
|
5887
|
+
throw S();
|
|
5888
5888
|
}, b = (P) => {
|
|
5889
|
-
const
|
|
5890
|
-
return /* @__PURE__ */ new Set([...
|
|
5891
|
-
},
|
|
5892
|
-
let
|
|
5893
|
-
if (!
|
|
5889
|
+
const v = (t.rig.controls[P]?.bind ?? []).flatMap((S) => S.parts), y = t.rig.parts.filter((S) => S.glow?.control === P).map((S) => S.id);
|
|
5890
|
+
return /* @__PURE__ */ new Set([...v, ...y]);
|
|
5891
|
+
}, E = /* @__PURE__ */ new Map(), O = (P) => {
|
|
5892
|
+
let v = E.get(P);
|
|
5893
|
+
if (!v) {
|
|
5894
5894
|
const y = p(P);
|
|
5895
|
-
|
|
5895
|
+
E.set(P, v = { ...y, solved: Lt(t, y.values, e.propScale) });
|
|
5896
5896
|
}
|
|
5897
|
-
return
|
|
5898
|
-
},
|
|
5899
|
-
const y = g(P), { values:
|
|
5897
|
+
return v;
|
|
5898
|
+
}, k = (P, v) => {
|
|
5899
|
+
const y = g(P), { values: S, origin: w, solved: T } = O(v);
|
|
5900
5900
|
if (y.kind === "box") return me(w.x - e.width / 2, w.y - e.height, e.width, e.height);
|
|
5901
5901
|
if (y.kind === "anchor") {
|
|
5902
|
-
const j =
|
|
5902
|
+
const j = T.anchors[y.name].point, R = e0 * e.propScale;
|
|
5903
5903
|
return me(w.x + j.x - R / 2, w.y + j.y - R / 2, R, R);
|
|
5904
5904
|
}
|
|
5905
5905
|
if (y.kind === "part") return x(/* @__PURE__ */ new Set([y.name]), `part "${y.name}" is`);
|
|
@@ -5907,17 +5907,17 @@ function su(e, n = {}) {
|
|
|
5907
5907
|
if (H.size === 0) return me(w.x - e.width / 2, w.y - e.height, e.width, e.height);
|
|
5908
5908
|
return x(H, `the parts control "${y.name}" moves are`);
|
|
5909
5909
|
function x(j, R) {
|
|
5910
|
-
const G = [...
|
|
5910
|
+
const G = [...T.under, ...T.over].filter((N) => j.has(N.part.id)).flatMap((N) => N.faces.flatMap((K) => K.points));
|
|
5911
5911
|
if (G.length === 0) {
|
|
5912
|
-
const N = Number.isFinite(
|
|
5912
|
+
const N = Number.isFinite(v) ? `at ${v} ms` : "after its edits";
|
|
5913
5913
|
throw new Error(`${t.kind}: ${R} turned away from the viewer ${N}; aim at an anchor (${a.map((K) => `anchor:${K}`).join(", ") || "none"}) or box`);
|
|
5914
5914
|
}
|
|
5915
5915
|
const Y = G.map((N) => N.x), ne = G.map((N) => N.y), B = Math.min(...Y), I = Math.min(...ne);
|
|
5916
5916
|
return me(w.x + B, w.y + I, Math.max(...Y) - B, Math.max(...ne) - I);
|
|
5917
5917
|
}
|
|
5918
|
-
}, m = (P,
|
|
5918
|
+
}, m = (P, v) => {
|
|
5919
5919
|
try {
|
|
5920
|
-
return
|
|
5920
|
+
return k(P, v);
|
|
5921
5921
|
} catch {
|
|
5922
5922
|
return;
|
|
5923
5923
|
}
|
|
@@ -5927,69 +5927,69 @@ function su(e, n = {}) {
|
|
|
5927
5927
|
about: xt,
|
|
5928
5928
|
target: e,
|
|
5929
5929
|
box: me(e.x, e.y, e.width, e.height),
|
|
5930
|
-
anchor(P,
|
|
5931
|
-
return
|
|
5930
|
+
anchor(P, v = 1 / 0) {
|
|
5931
|
+
return k(P, v);
|
|
5932
5932
|
},
|
|
5933
5933
|
piece(P) {
|
|
5934
|
-
const
|
|
5935
|
-
if (
|
|
5936
|
-
const y = d.get(
|
|
5934
|
+
const v = g(P);
|
|
5935
|
+
if (v.kind !== "part") throw new Error(`${t.kind}: a piece is a part, part:ID (${s.slice(0, 6).map((T) => `part:${T}`).join(", ")}…), not "${P}"`);
|
|
5936
|
+
const y = d.get(v.name);
|
|
5937
5937
|
if (y) return y;
|
|
5938
|
-
const
|
|
5939
|
-
for (let
|
|
5940
|
-
const w = { id: d.size + 1, part:
|
|
5941
|
-
d.set(
|
|
5942
|
-
for (const
|
|
5943
|
-
for (const
|
|
5938
|
+
const S = [v.name];
|
|
5939
|
+
for (let T = 0; T < S.length; T++) for (const H of t.rig.parts) H.parent === S[T] && !S.includes(H.id) && S.push(H.id);
|
|
5940
|
+
const w = { id: d.size + 1, part: v.name, home: k(P, 0) };
|
|
5941
|
+
d.set(v.name, w);
|
|
5942
|
+
for (const T of S) f.set(T, w.id);
|
|
5943
|
+
for (const T of ["x", "y", "rotate"]) u[`piece.${w.id}.${T}`] = 0;
|
|
5944
5944
|
return u[`piece.${w.id}.opacity`] = 1, w;
|
|
5945
5945
|
},
|
|
5946
|
-
edit(P,
|
|
5946
|
+
edit(P, v, y) {
|
|
5947
5947
|
if (!(P in xt.edits)) throw En(t.kind, P, xt);
|
|
5948
|
-
const
|
|
5949
|
-
if (
|
|
5950
|
-
if (
|
|
5951
|
-
if (
|
|
5952
|
-
const w = A.piece(
|
|
5948
|
+
const S = Array.isArray(v) ? v : [v];
|
|
5949
|
+
if (S.length === 0) throw new Error(`${t.kind}.edit: ${P} takes at least one anchor`);
|
|
5950
|
+
if (E.clear(), P === "move" || P === "fling") {
|
|
5951
|
+
if (S.length > 1) throw new Error(`${t.kind}.edit: ${P} takes one part anchor`);
|
|
5952
|
+
const w = A.piece(S[0]);
|
|
5953
5953
|
if (P === "fling") return A.fling(w, y);
|
|
5954
|
-
const
|
|
5955
|
-
if (!
|
|
5956
|
-
const H = typeof
|
|
5957
|
-
return A.move(w, { ...y, to: H ? { x: H.left + H.width / 2, y: H.top + H.height / 2 } :
|
|
5954
|
+
const T = y.to;
|
|
5955
|
+
if (!T) throw new Error(`${t.kind}.edit: move needs \`to\`, an anchor name or { x, y }`);
|
|
5956
|
+
const H = typeof T == "string" ? k(T, y.at) : void 0;
|
|
5957
|
+
return A.move(w, { ...y, to: H ? { x: H.left + H.width / 2, y: H.top + H.height / 2 } : T });
|
|
5958
5958
|
}
|
|
5959
|
-
for (const w of
|
|
5960
|
-
const
|
|
5961
|
-
if (
|
|
5962
|
-
const H = o[
|
|
5959
|
+
for (const w of S) {
|
|
5960
|
+
const T = g(w);
|
|
5961
|
+
if (T.kind !== "control") throw new Error(`${t.kind}.edit: ${P} takes control anchors (control:${r.join(", control:")}), not "${w}"`);
|
|
5962
|
+
const H = o[T.name];
|
|
5963
5963
|
let x;
|
|
5964
5964
|
if (P === "set") {
|
|
5965
|
-
if (typeof y.value != "number" || !Number.isFinite(y.value)) throw new Error(`${t.kind}.edit: set needs \`value\`, a number (${
|
|
5965
|
+
if (typeof y.value != "number" || !Number.isFinite(y.value)) throw new Error(`${t.kind}.edit: set needs \`value\`, a number (${T.name}: ${H.description})`);
|
|
5966
5966
|
x = y.value;
|
|
5967
5967
|
} else
|
|
5968
5968
|
x = y.on === !1 ? H.default ?? H.min ?? 0 : H.max ?? 1;
|
|
5969
|
-
i.tween(
|
|
5969
|
+
i.tween(T.name, p(y.at).values[T.name], x, y, Qc);
|
|
5970
5970
|
}
|
|
5971
5971
|
return A;
|
|
5972
5972
|
},
|
|
5973
|
-
follow(P,
|
|
5974
|
-
return
|
|
5973
|
+
follow(P, v) {
|
|
5974
|
+
return E.clear(), l.follow(P, v), A;
|
|
5975
5975
|
},
|
|
5976
|
-
fling(P,
|
|
5977
|
-
return
|
|
5976
|
+
fling(P, v) {
|
|
5977
|
+
return E.clear(), l.fling(P, v), A;
|
|
5978
5978
|
},
|
|
5979
|
-
move(P,
|
|
5980
|
-
return
|
|
5979
|
+
move(P, v) {
|
|
5980
|
+
return E.clear(), l.move(P, v), A;
|
|
5981
5981
|
},
|
|
5982
|
-
ride(P,
|
|
5983
|
-
const
|
|
5984
|
-
...r.flatMap((
|
|
5985
|
-
...(n.tracks ?? []).flatMap((
|
|
5982
|
+
ride(P, v, y) {
|
|
5983
|
+
const S = [
|
|
5984
|
+
...r.flatMap((T) => Wt(i.keys(T))),
|
|
5985
|
+
...(n.tracks ?? []).flatMap((T) => Wt(T.keyframes.filter((H) => typeof H.value == "number")))
|
|
5986
5986
|
];
|
|
5987
|
-
if (
|
|
5988
|
-
const w = [...a.map((
|
|
5989
|
-
const H = m(
|
|
5990
|
-
return H ? [{ top: H.top, offset: (x) => (m(
|
|
5987
|
+
if (S.length === 0) return P;
|
|
5988
|
+
const w = [...a.map((T) => `anchor:${T}`), ...s.map((T) => `part:${T}`)].flatMap((T) => {
|
|
5989
|
+
const H = m(T, 0);
|
|
5990
|
+
return H ? [{ top: H.top, offset: (x) => (m(T, x)?.top ?? H.top) - H.top, windows: S }] : [];
|
|
5991
5991
|
});
|
|
5992
|
-
return xo(P,
|
|
5992
|
+
return xo(P, v, { ground: y.ground, every: y.every ?? Qe, floors: w });
|
|
5993
5993
|
},
|
|
5994
5994
|
tracks: i.tracks
|
|
5995
5995
|
};
|
|
@@ -6063,16 +6063,16 @@ function Xe(e) {
|
|
|
6063
6063
|
outline: 0.5,
|
|
6064
6064
|
seeThrough: !0
|
|
6065
6065
|
});
|
|
6066
|
-
const
|
|
6066
|
+
const E = h + (d - h) * 0.15, O = h + (d - h) * 0.55;
|
|
6067
6067
|
t.push({
|
|
6068
6068
|
id: `seat-back-${b}`,
|
|
6069
|
-
shape: { type: "panel", points: [[
|
|
6069
|
+
shape: { type: "panel", points: [[E, f + 0.05], [O, f + 0.05], [O - 0.08, u - 0.06], [E + 0.06, u - 0.04]], facing: g > 0 ? "left" : "right" },
|
|
6070
6070
|
at: [g * (e.width / 2 + 6e-3), 0, 0],
|
|
6071
6071
|
fill: n.seat,
|
|
6072
6072
|
outline: 0.4
|
|
6073
6073
|
}), t.push({
|
|
6074
6074
|
id: `door-${b}`,
|
|
6075
|
-
shape: { type: "panel", points: p.map(([
|
|
6075
|
+
shape: { type: "panel", points: p.map(([k, m]) => [k - d, m]), facing: g > 0 ? "left" : "right" },
|
|
6076
6076
|
// The panel's origin is at its hinge (its front edge), just outside the body.
|
|
6077
6077
|
at: [g * (e.width / 2 + 0.01), 0, d],
|
|
6078
6078
|
fill: n.body,
|
|
@@ -6094,8 +6094,8 @@ function Xe(e) {
|
|
|
6094
6094
|
}
|
|
6095
6095
|
if (e.lights) {
|
|
6096
6096
|
const { across: h, low: d, high: f, front: u, back: p } = e.lights, g = (e.lights.size ?? 0.32) / 2, b = [[-g, d], [g, d], [g, f], [-g, f]];
|
|
6097
|
-
for (const
|
|
6098
|
-
t.push({ id: `headlight-${
|
|
6097
|
+
for (const E of [1, -1])
|
|
6098
|
+
t.push({ id: `headlight-${E}`, shape: { type: "panel", points: b, facing: "front" }, at: [E * h, 0, u], fill: n.light, outline: 0.6, glow: { control: "lights", color: "#ffffff" } }), t.push({ id: `taillight-${E}`, shape: { type: "panel", points: b, facing: "back" }, at: [E * h, 0, p], fill: Ho(n.tail, 0.62), outline: 0.6, glow: { control: "lights", color: n.tail } });
|
|
6099
6099
|
l.lights = { description: "Lights on: 0 off, 1 on", unit: "0..1", min: 0, max: 1 };
|
|
6100
6100
|
}
|
|
6101
6101
|
e.antenna && (t.push({ id: "antenna", shape: { type: "tube", points: [[0, 0, 0], [0, 0.75, 0]], radius: 0.018, segments: 5 }, at: e.antenna, fill: n.trim, outline: 0.6 }), t.push({ id: "antenna-tip", parent: "antenna", shape: { type: "ellipsoid", radii: [0.05, 0.05, 0.05], segments: 8 }, at: [0, 0.77, 0], fill: n.tail, outline: 0.6 }), l.antenna = {
|
|
@@ -6186,8 +6186,8 @@ function o0(e) {
|
|
|
6186
6186
|
run(i, l, c) {
|
|
6187
6187
|
const h = Math.sign(l.to - i.x);
|
|
6188
6188
|
if (h === 0) return { end: c };
|
|
6189
|
-
const d = a(i, c, h), f = i.exaggeration, u = i.x, p = Math.abs(l.to - u), g = l.for ?? Math.max(600, p / (l.speed ?? na * 1.2)), b = d + g * 0.55,
|
|
6190
|
-
return i.key(d + 140, { pitch: -1.5 * f, squash: 1 + 0.06 * f, lean: 0.14 * f }, { act: !1, easing: "ease-out" }), en(i, d, b,
|
|
6189
|
+
const d = a(i, c, h), f = i.exaggeration, u = i.x, p = Math.abs(l.to - u), g = l.for ?? Math.max(600, p / (l.speed ?? na * 1.2)), b = d + g * 0.55, E = u + (l.to - u) * 0.65;
|
|
6190
|
+
return i.key(d + 140, { pitch: -1.5 * f, squash: 1 + 0.06 * f, lean: 0.14 * f }, { act: !1, easing: "ease-out" }), en(i, d, b, E, "ease-in", n), i.key(b + 80, { pitch: -7 * f, lean: -0.12 * f, squash: 0.94 }, { act: !1, easing: "ease-out" }), en(i, b, d + g, l.to, "ease-out", n, !0), i.effect({ kind: "skid", time: b, x: E, toX: l.to, y: i.floor, length: g * 0.45 + 1500 }), i.effect({ kind: "dust", time: d + g, x: l.to + h * r * i.scale, y: i.floor, length: 600, direction: h }), s(i, d + g, !0), { end: d + g + 380, contact: b, release: d + g };
|
|
6191
6191
|
}
|
|
6192
6192
|
},
|
|
6193
6193
|
bump: {
|
|
@@ -6470,10 +6470,10 @@ function g0() {
|
|
|
6470
6470
|
};
|
|
6471
6471
|
}
|
|
6472
6472
|
function p0(e = {}) {
|
|
6473
|
-
const n = e.width ?? 4, t = e.depth ?? 3.2, o = e.wallHeight ?? 2.5, r = e.roofHeight ?? 1.5, a = e.overhang ?? 0.25, s = { walls: "#f1d9a8", roof: "#b8433a", door: "#7a4b2a", doorway: "#3a2a22", glass: "#bfe3f2", lit: "#ffd66b", chimney: "#9b5a45", ...e.colors }, i = t / 2 + 0.01, l = e.door?.width ?? 0.9, c = e.door?.height ?? 1.9, h = e.door?.at ?? 0,
|
|
6473
|
+
const n = e.width ?? 4, t = e.depth ?? 3.2, o = e.wallHeight ?? 2.5, r = e.roofHeight ?? 1.5, a = e.overhang ?? 0.25, s = { walls: "#f1d9a8", roof: "#b8433a", door: "#7a4b2a", doorway: "#3a2a22", glass: "#bfe3f2", lit: "#ffd66b", chimney: "#9b5a45", ...e.colors }, i = t / 2 + 0.01, l = e.door?.width ?? 0.9, c = e.door?.height ?? 1.9, h = e.door?.at ?? 0, f = (e.door?.hinge ?? "left") === "left" ? 1 : -1, u = h - f * l / 2, p = -80 * f * ((e.door?.opens ?? "out") === "out" ? 1 : -1), g = e.windows ?? [
|
|
6474
6474
|
{ at: -1.25, low: 1, width: 0.8, height: 0.8 },
|
|
6475
6475
|
{ at: 1.25, low: 1, width: 0.8, height: 0.8 }
|
|
6476
|
-
],
|
|
6476
|
+
], b = [
|
|
6477
6477
|
{ id: "walls", shape: { type: "box", size: [n, o, t] }, at: [0, o / 2, 0], fill: s.walls },
|
|
6478
6478
|
{
|
|
6479
6479
|
id: "roof",
|
|
@@ -6484,39 +6484,39 @@ function p0(e = {}) {
|
|
|
6484
6484
|
},
|
|
6485
6485
|
// The doorway behind the door shows when it opens.
|
|
6486
6486
|
{ id: "doorway", shape: { type: "panel", points: [[0, 0], [l, 0], [l, c], [0, c]], facing: "front" }, at: [h - l / 2, 0, i - 5e-3], fill: s.doorway, outline: 0.6, seeThrough: !0 },
|
|
6487
|
-
// The door, hinged on
|
|
6488
|
-
{ id: "door", shape: { type: "panel", points: [[0, 0], [l, 0], [l, c], [0, c]], facing: "front" }, at: [
|
|
6487
|
+
// The door, hinged on the panel's origin edge (left or right); drawn over a rider, so a figure in the doorway shows only when it opens.
|
|
6488
|
+
{ id: "door", shape: { type: "panel", points: [[0, 0], [f * l, 0], [f * l, c], [0, c]], facing: "front" }, at: [u, 0, i + 5e-3], fill: s.door, outline: 0.8, overRider: !0 }
|
|
6489
6489
|
];
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
id: `window-${
|
|
6493
|
-
shape: { type: "panel", points: [[-
|
|
6490
|
+
g.forEach((k, m) => {
|
|
6491
|
+
b.push({
|
|
6492
|
+
id: `window-${m}`,
|
|
6493
|
+
shape: { type: "panel", points: [[-k.width / 2, k.low], [k.width / 2, k.low], [k.width / 2, k.low + k.height], [-k.width / 2, k.low + k.height]], facing: "front" },
|
|
6494
6494
|
// A centimetre out from the wall, as the side windows are: never in its very plane (a depth buffer can't
|
|
6495
6495
|
// tell which is in front).
|
|
6496
|
-
at: [
|
|
6496
|
+
at: [k.at, 0, i + 0.01],
|
|
6497
6497
|
fill: s.glass,
|
|
6498
6498
|
outline: 0.8,
|
|
6499
6499
|
glow: { control: "lights", color: s.lit }
|
|
6500
6500
|
});
|
|
6501
6501
|
});
|
|
6502
|
-
for (const
|
|
6503
|
-
|
|
6504
|
-
id: `side-window-${
|
|
6505
|
-
shape: { type: "panel", points: [[-0.4, 1], [0.4, 1], [0.4, 1.8], [-0.4, 1.8]], facing:
|
|
6506
|
-
at: [
|
|
6502
|
+
for (const k of [1, -1])
|
|
6503
|
+
b.push({
|
|
6504
|
+
id: `side-window-${k > 0 ? "left" : "right"}`,
|
|
6505
|
+
shape: { type: "panel", points: [[-0.4, 1], [0.4, 1], [0.4, 1.8], [-0.4, 1.8]], facing: k > 0 ? "left" : "right" },
|
|
6506
|
+
at: [k * (n / 2 + 0.01), 0, 0],
|
|
6507
6507
|
fill: s.glass,
|
|
6508
6508
|
outline: 0.8,
|
|
6509
6509
|
glow: { control: "lights", color: s.lit }
|
|
6510
6510
|
});
|
|
6511
|
-
const
|
|
6512
|
-
if (
|
|
6513
|
-
const
|
|
6514
|
-
|
|
6511
|
+
const E = e.chimney === !1 ? void 0 : { at: e.chimney?.at ?? n * 0.28, back: e.chimney?.back ?? -t * 0.18 };
|
|
6512
|
+
if (E) {
|
|
6513
|
+
const k = o + r * (1 - Math.abs(E.back) / (t / 2 + a)), m = o + r + 0.45;
|
|
6514
|
+
b.push({ id: "chimney", shape: { type: "box", size: [0.42, m - k + 0.3, 0.42] }, at: [E.at, (m + k - 0.3) / 2, E.back], fill: s.chimney, layer: 1 });
|
|
6515
6515
|
}
|
|
6516
|
-
const
|
|
6517
|
-
parts:
|
|
6516
|
+
const O = {
|
|
6517
|
+
parts: b,
|
|
6518
6518
|
controls: {
|
|
6519
|
-
door: { description: "The front door open: 0 shut, 1 open", unit: "0..1", min: 0, max: 1, bind: [{ parts: ["door"], rotate: { axis: "y", degrees:
|
|
6519
|
+
door: { description: "The front door open: 0 shut, 1 open", unit: "0..1", min: 0, max: 1, bind: [{ parts: ["door"], rotate: { axis: "y", degrees: p } }] },
|
|
6520
6520
|
lights: { description: "The windows lit: 0 dark, 1 lit", unit: "0..1", min: 0, max: 1 }
|
|
6521
6521
|
},
|
|
6522
6522
|
length: t + a * 2,
|
|
@@ -6524,17 +6524,19 @@ function p0(e = {}) {
|
|
|
6524
6524
|
footprint: [n + 0.6, t + 0.6],
|
|
6525
6525
|
anchors: {
|
|
6526
6526
|
door: { at: [h, c / 2, i] },
|
|
6527
|
+
// The handle, a hand's width in from the free edge.
|
|
6528
|
+
handle: { at: [u + f * (l - 0.12), c * 0.5, i + 0.02] },
|
|
6527
6529
|
doorstep: { at: [h, 0, i + 0.4] },
|
|
6528
6530
|
ridge: { at: [0, o + r, 0] },
|
|
6529
|
-
...
|
|
6531
|
+
...E ? { chimney: { at: [E.at, o + r + 0.5, E.back] } } : {}
|
|
6530
6532
|
}
|
|
6531
6533
|
};
|
|
6532
6534
|
return {
|
|
6533
6535
|
kind: e.kind ?? "house",
|
|
6534
6536
|
family: "building",
|
|
6535
6537
|
summary: e.summary ?? "A house: opens its door, lights its windows, puffs chimney smoke, shakes, pops up.",
|
|
6536
|
-
rig:
|
|
6537
|
-
actions: b0(!!
|
|
6538
|
+
rig: O,
|
|
6539
|
+
actions: b0(!!E),
|
|
6538
6540
|
acting: m0,
|
|
6539
6541
|
colors: { body: s.walls }
|
|
6540
6542
|
};
|
|
@@ -6824,19 +6826,19 @@ function P0(e = {}) {
|
|
|
6824
6826
|
{ id: "footrest", shape: { type: "box", size: [n * 0.8, 0.02, 0.14] }, at: [0, 0.12, l / 2 + 0.22], fill: a.frame }
|
|
6825
6827
|
];
|
|
6826
6828
|
for (const [g, b] of [[-1, "left"], [1, "right"]]) {
|
|
6827
|
-
const
|
|
6828
|
-
f.push({ id:
|
|
6829
|
+
const E = g * d, O = (k, m, A = i) => {
|
|
6830
|
+
f.push({ id: k, shape: { type: "tube", points: m, radius: A, segments: 6 }, fill: a.frame, outline: 0.7 });
|
|
6829
6831
|
};
|
|
6830
|
-
O(`post-${b}`, [[
|
|
6832
|
+
O(`post-${b}`, [[E, t - 0.1, -l / 2], [E, c + 0.04, -l / 2], [E, c + 0.04, -l / 2 - 0.14]]), O(`rail-${b}`, [[E, t - 0.03, -l / 2], [E, t - 0.03, l / 2]]), O(`leg-${b}`, [[E, t - 0.03, l / 2], [E * 0.85, r, l / 2 + 0.06]]), O(`strut-${b}`, [[E * 0.85, r + 0.08, l / 2 + 0.04], [E * 0.8, 0.13, l / 2 + 0.22]]), O(`armrest-${b}`, [[E, t + 0.22, -l / 2 + 0.02], [E, t + 0.22, l / 2 - 0.08]], i * 1.3), f.push({
|
|
6831
6833
|
id: `wheel-${b}`,
|
|
6832
6834
|
shape: { type: "cylinder", radius: o, length: 0.04, axis: "x", segments: 20, spokes: 8 },
|
|
6833
|
-
at: [
|
|
6835
|
+
at: [E + g * 0.03, o, h],
|
|
6834
6836
|
ink: a.tyre,
|
|
6835
6837
|
outline: 1.3
|
|
6836
6838
|
}), f.push({ id: `rim-${b}`, shape: { type: "cylinder", radius: o * 0.9, length: 0.012, axis: "x", segments: 20 }, at: [g * 0.045, 0, 0], parent: `wheel-${b}`, ink: a.frame, outline: 0.8 }), f.push({
|
|
6837
6839
|
id: `castor-${b}`,
|
|
6838
6840
|
shape: { type: "cylinder", radius: r, length: 0.03, axis: "x", segments: 12, spokes: 3 },
|
|
6839
|
-
at: [
|
|
6841
|
+
at: [E * 0.85, r, l / 2 + 0.06],
|
|
6840
6842
|
fill: a.tyre
|
|
6841
6843
|
});
|
|
6842
6844
|
}
|
|
@@ -7249,11 +7251,11 @@ function N0(e, n) {
|
|
|
7249
7251
|
const Ae = Array.from({ length: 7 }, (e, n) => n === 0 ? "tail" : `tail-${n}`);
|
|
7250
7252
|
function K0(e, n, t) {
|
|
7251
7253
|
const o = Ca(e.tail.points, Ae.length + 1), [, r, a] = e.body.radii, s = (e.tail.at[1] - t) / r, i = Math.abs(s) < 1 ? -a * Math.sqrt(1 - s * s) : e.tail.at[2], l = [e.tail.at[0], e.tail.at[1], i + Math.min(0.04, a * 0.08)], c = (u) => e.tail.radius * (1 - 0.5 * u / Ae.length), h = Ae.map((u, p) => {
|
|
7252
|
-
const g = o[p], b = o[p + 1],
|
|
7254
|
+
const g = o[p], b = o[p + 1], E = [b[0] - g[0], b[1] - g[1], b[2] - g[2]], O = p === 0 ? void 0 : o[p - 1];
|
|
7253
7255
|
return {
|
|
7254
7256
|
id: u,
|
|
7255
7257
|
...p > 0 ? { parent: Ae[p - 1] } : {},
|
|
7256
|
-
shape: { type: "tube", points: [[0, 0, 0],
|
|
7258
|
+
shape: { type: "tube", points: [[0, 0, 0], E], radius: [c(p), c(p + 1)], segments: 8, joined: !0 },
|
|
7257
7259
|
// The first segment starts where the tail does; each next one starts at the end of the one before.
|
|
7258
7260
|
at: p === 0 ? l : [g[0] - O[0], g[1] - O[1], g[2] - O[2]],
|
|
7259
7261
|
fill: n.dark,
|
|
@@ -8042,20 +8044,20 @@ function ad(e, n) {
|
|
|
8042
8044
|
}), r;
|
|
8043
8045
|
}
|
|
8044
8046
|
function rd(e, n, t, o = {}) {
|
|
8045
|
-
const r = ad(t, n).filter((
|
|
8047
|
+
const r = ad(t, n).filter((S) => S.level === "error");
|
|
8046
8048
|
if (r.length > 0) throw new Error(`propScript (${n.kind}): ${r.length} problem(s) in the beats:
|
|
8047
|
-
${r.map((
|
|
8049
|
+
${r.map((S) => ` beat ${S.beat}: ${S.message}`).join(`
|
|
8048
8050
|
`)}`);
|
|
8049
8051
|
const a = o.from ?? 0, s = o.ground ?? 0, i = o.scale ?? 60, l = o.exaggeration ?? 1, c = qo(n), h = {};
|
|
8050
|
-
for (const
|
|
8052
|
+
for (const S of [...Object.keys(Dt), ...Object.keys(n.rig.controls)]) h[S] = o.start?.[S] ?? ye(n.rig, {}, S);
|
|
8051
8053
|
const d = [{ time: 0, pose: { ...h } }], f = /* @__PURE__ */ new Map(), u = [];
|
|
8052
8054
|
let p = a, g = s;
|
|
8053
|
-
const b = (
|
|
8054
|
-
const x = f.get(
|
|
8055
|
-
x.push({ time: w, value:
|
|
8056
|
-
},
|
|
8057
|
-
const
|
|
8058
|
-
(!H || H[H.length - 1].time < w) && b(
|
|
8055
|
+
const b = (S, w, T, H) => {
|
|
8056
|
+
const x = f.get(S) ?? [{ time: 0, value: S === "x" || S === "y" ? 0 : h[S] }];
|
|
8057
|
+
x.push({ time: w, value: T, ...H ? { easing: H } : {} }), f.set(S, x), S !== "x" && S !== "y" && (h[S] = T);
|
|
8058
|
+
}, E = (S, w) => {
|
|
8059
|
+
const T = S === "x" ? p - a : S === "y" ? g - s : h[S], H = f.get(S);
|
|
8060
|
+
(!H || H[H.length - 1].time < w) && b(S, w, T);
|
|
8059
8061
|
}, O = {
|
|
8060
8062
|
prop: n,
|
|
8061
8063
|
scale: i,
|
|
@@ -8068,53 +8070,53 @@ ${r.map((v) => ` beat ${v.beat}: ${v.message}`).join(`
|
|
|
8068
8070
|
},
|
|
8069
8071
|
values: h,
|
|
8070
8072
|
facing() {
|
|
8071
|
-
const
|
|
8072
|
-
return Math.abs(
|
|
8073
|
+
const S = Math.sin(h.turn * Math.PI / 2);
|
|
8074
|
+
return Math.abs(S) < 0.5 ? 0 : S > 0 ? 1 : -1;
|
|
8073
8075
|
},
|
|
8074
|
-
key(
|
|
8075
|
-
Object.assign(h, w), d.push({ time:
|
|
8076
|
+
key(S, w, T = {}) {
|
|
8077
|
+
Object.assign(h, w), d.push({ time: S, pose: { ...h }, ...T.act === !1 ? { act: !1 } : {}, ...T.easing ? { easing: T.easing } : {} });
|
|
8076
8078
|
},
|
|
8077
|
-
move(
|
|
8078
|
-
|
|
8079
|
+
move(S, w, T, H = {}) {
|
|
8080
|
+
E("x", S), b("x", w, T - a, H.easing), p = T, H.floor !== void 0 && (E("y", S), b("y", w, H.floor - s, H.easing), g = H.floor);
|
|
8079
8081
|
},
|
|
8080
|
-
set(
|
|
8081
|
-
b(
|
|
8082
|
+
set(S, w, T, H) {
|
|
8083
|
+
b(S, w, T, H);
|
|
8082
8084
|
},
|
|
8083
|
-
turnTo(
|
|
8084
|
-
const
|
|
8085
|
-
if (j.d < 1e-3) return
|
|
8086
|
-
const R =
|
|
8085
|
+
turnTo(S, w) {
|
|
8086
|
+
const T = typeof w == "number" ? w : bo[w], H = h.turn, j = [T - 4, T, T + 4].map((G) => ({ t: G, d: Math.abs(G - H) })).sort((G, Y) => G.d - Y.d || Math.abs(G.t) - Math.abs(Y.t))[0];
|
|
8087
|
+
if (j.d < 1e-3) return S;
|
|
8088
|
+
const R = S + sd * Math.max(1, j.d);
|
|
8087
8089
|
return O.key(R, { turn: j.t }), R;
|
|
8088
8090
|
},
|
|
8089
|
-
effect(
|
|
8090
|
-
u.push(
|
|
8091
|
+
effect(S) {
|
|
8092
|
+
u.push(S);
|
|
8091
8093
|
},
|
|
8092
|
-
anchor(
|
|
8093
|
-
const
|
|
8094
|
-
if (!
|
|
8095
|
-
return { x: p +
|
|
8094
|
+
anchor(S) {
|
|
8095
|
+
const T = Lt(n, h, i).anchors[S];
|
|
8096
|
+
if (!T) throw new Error(`${n.kind}: no anchor "${S}"`);
|
|
8097
|
+
return { x: p + T.point.x, y: g + T.point.y };
|
|
8096
8098
|
}
|
|
8097
|
-
},
|
|
8099
|
+
}, k = [];
|
|
8098
8100
|
let m = 0;
|
|
8099
|
-
for (const
|
|
8100
|
-
const w = Math.max(
|
|
8101
|
-
|
|
8101
|
+
for (const S of t) {
|
|
8102
|
+
const w = Math.max(S.at ?? m, d[d.length - 1].time), T = c[S.do].run(O, S, w);
|
|
8103
|
+
T.end > d[d.length - 1].time && d.push({ time: T.end, pose: { ...h } }), k.push({ start: w, end: T.end, ...T.contact !== void 0 ? { contact: T.contact } : {}, ...T.release !== void 0 ? { release: T.release } : {} }), m = T.end;
|
|
8102
8104
|
}
|
|
8103
|
-
const A = Ua(o.style ?? "snappy"), P = { ...A, anticipation: A.anticipation * l, overshoot: A.overshoot * l },
|
|
8105
|
+
const A = Ua(o.style ?? "snappy"), P = { ...A, anticipation: A.anticipation * l, overshoot: A.overshoot * l }, v = _o(cd(d), n.acting, { style: P }), y = [
|
|
8104
8106
|
// Controls keyed exactly (wheels, rotors) are not acted.
|
|
8105
|
-
...Object.entries(
|
|
8106
|
-
...[...f].map(([
|
|
8107
|
+
...Object.entries(v).filter(([S]) => !f.has(S)).map(([S, w]) => ({ id: `${e}-${S}`, target: e, property: S, keyframes: w })),
|
|
8108
|
+
...[...f].map(([S, w]) => ({ id: `${e}-${S}`, target: e, property: S, keyframes: dd(w) }))
|
|
8107
8109
|
];
|
|
8108
|
-
for (const
|
|
8109
|
-
const w = y.findIndex((x) => x.property ===
|
|
8110
|
+
for (const S of ld(e, n, y, m, d[0].pose)) {
|
|
8111
|
+
const w = y.findIndex((x) => x.property === S.property);
|
|
8110
8112
|
if (w < 0) {
|
|
8111
|
-
y.push(
|
|
8113
|
+
y.push(S);
|
|
8112
8114
|
continue;
|
|
8113
8115
|
}
|
|
8114
|
-
const
|
|
8115
|
-
y[w] = { ...
|
|
8116
|
+
const T = new ve({ id: `${e}-own`, tracks: [y[w]] }), H = (x) => Number(T.getStateAtTime(x).values.get(e)?.get(S.property) ?? 0);
|
|
8117
|
+
y[w] = { ...S, keyframes: S.keyframes.map((x) => ({ time: x.time, value: Number(x.value) + H(x.time) })) };
|
|
8116
8118
|
}
|
|
8117
|
-
return { tracks: y, duration: m, beats:
|
|
8119
|
+
return { tracks: y, duration: m, beats: k, effects: u };
|
|
8118
8120
|
}
|
|
8119
8121
|
const id = 1500;
|
|
8120
8122
|
function ld(e, n, t, o, r) {
|
|
@@ -8700,12 +8702,12 @@ function fu(e) {
|
|
|
8700
8702
|
const n = new ve({ id: `${e.leaderId}-tow`, tracks: e.leaderTracks.filter((u) => u.target === e.leaderId) }), t = e.every ?? 33, o = e.towed, r = o.x + o.width / 2, a = o.props, s = o.prop.wheelRadius, i = [], l = [], c = [];
|
|
8701
8703
|
let h = a.wheelSpin ?? 0, d;
|
|
8702
8704
|
for (let u = e.start; ; u = Math.min(e.end, u + t)) {
|
|
8703
|
-
const p = Lo(e.leader, { state: n.getStateAtTime(u) }, e.leaderId), g = p.anchor(e.hitch), b = p.values.turn,
|
|
8704
|
-
if (!
|
|
8705
|
-
const O = g.x -
|
|
8705
|
+
const p = Lo(e.leader, { state: n.getStateAtTime(u) }, e.leaderId), g = p.anchor(e.hitch), b = p.values.turn, E = Lt(o.prop, { ...a, turn: b }, o.propScale).anchors[e.anchor];
|
|
8706
|
+
if (!E) throw new Error(`propTow: ${o.prop.kind} has no anchor "${e.anchor}"`);
|
|
8707
|
+
const O = g.x - E.point.x;
|
|
8706
8708
|
if (d !== void 0 && s) {
|
|
8707
|
-
const
|
|
8708
|
-
h += (O - d) * (
|
|
8709
|
+
const k = Math.sin(b * Math.PI / 2);
|
|
8710
|
+
h += (O - d) * (k || 1) / o.propScale / s * (180 / Math.PI);
|
|
8709
8711
|
}
|
|
8710
8712
|
if (d = O, i.push({ time: u, value: O - r }), l.push({ time: u, value: b }), c.push({ time: u, value: h }), u >= e.end) break;
|
|
8711
8713
|
}
|
|
@@ -8728,8 +8730,8 @@ function kd(e, n) {
|
|
|
8728
8730
|
for (const g of f.corners) for (const b of [0, 1, 2]) l[g][b] += f.normal[b];
|
|
8729
8731
|
const [u, ...p] = f.corners;
|
|
8730
8732
|
for (let g = 0; g + 1 < p.length; g++) {
|
|
8731
|
-
const [b,
|
|
8732
|
-
c.push(...
|
|
8733
|
+
const [b, E, O] = [u, p[g], p[g + 1]], [k, m, A] = [s.vertices[b], s.vertices[E], s.vertices[O]], P = [m[0] - k[0], m[1] - k[1], m[2] - k[2]], v = [A[0] - k[0], A[1] - k[1], A[2] - k[2]], y = [P[1] * v[2] - P[2] * v[1], P[2] * v[0] - P[0] * v[2], P[0] * v[1] - P[1] * v[0]], S = y[0] * f.normal[0] + y[1] * f.normal[1] + y[2] * f.normal[2];
|
|
8734
|
+
c.push(...S >= 0 ? [b, E, O] : [b, O, E]);
|
|
8733
8735
|
}
|
|
8734
8736
|
});
|
|
8735
8737
|
const h = l.flatMap((f) => {
|
|
@@ -8795,33 +8797,33 @@ const Ed = /* @__PURE__ */ new Set([
|
|
|
8795
8797
|
// `lights` may be missing from a scene entry older than this add-on: treated as none.
|
|
8796
8798
|
resolve({ object: e, prepared: n, values: t, world: o, camera: r, lights: a = [], fog: s, toScreen: i }) {
|
|
8797
8799
|
const l = e, c = n, h = { ...l.values };
|
|
8798
|
-
for (const [
|
|
8799
|
-
typeof y == "number" && !Ed.has(
|
|
8800
|
+
for (const [v, y] of t)
|
|
8801
|
+
typeof y == "number" && !Ed.has(v) && (h[v] = y);
|
|
8800
8802
|
h.turn = 0, h.tilt = 0;
|
|
8801
8803
|
const d = oe.multiply(r.view, o), f = {
|
|
8802
|
-
toView: (
|
|
8803
|
-
toScreen: (
|
|
8804
|
+
toView: (v) => oe.transformPoint(d, v),
|
|
8805
|
+
toScreen: (v) => i(v)
|
|
8804
8806
|
}, u = f.toView([0, c.rig.height / 2, 0]);
|
|
8805
8807
|
if (-u[2] <= r.near) return null;
|
|
8806
8808
|
if (l.look === "mesh") {
|
|
8807
|
-
const
|
|
8808
|
-
mesh: kd(
|
|
8809
|
+
const v = Yc(c.rig, h), y = v.map(({ part: T, local: H }) => ({ part: T.id, mesh: yn(T.shape), ...Fo(yn(T.shape), H) })), S = ir(y), w = v.map((T, H) => ({ ...T, hidden: lr(T.part.id, y[H].mesh, T.local, y[H].key, S) })).filter(({ opacity: T }) => T > 0.01).map(({ part: T, matrix: H, glow: x, opacity: j, hidden: R }) => ({
|
|
8810
|
+
mesh: kd(T.shape, R),
|
|
8809
8811
|
world: oe.multiply(o, H),
|
|
8810
|
-
material: vd(
|
|
8812
|
+
material: vd(T, { glow: x, opacity: j }, { shading: l.shading, ink: l.ink, outline: l.outline })
|
|
8811
8813
|
}));
|
|
8812
8814
|
return { meshes: l.shadow === !1 ? w : [$d(c, h, o), ...w] };
|
|
8813
8815
|
}
|
|
8814
|
-
const p = i(u), g = i(f.toView([0, c.rig.height / 2 + 1, 0])), b = Math.hypot(g.x - p.x, g.y - p.y),
|
|
8815
|
-
const
|
|
8816
|
-
return { light: ka(
|
|
8817
|
-
}, O = hr(c.rig, h, f, b, { perspective: !0, near: r.near, slice: Td, light:
|
|
8816
|
+
const p = i(u), g = i(f.toView([0, c.rig.height / 2 + 1, 0])), b = Math.hypot(g.x - p.x, g.y - p.y), E = a.length === 0 ? void 0 : (v, y) => {
|
|
8817
|
+
const S = oe.transformPoint(o, v), w = [o[0] * y[0] + o[4] * y[1] + o[8] * y[2], o[1] * y[0] + o[5] * y[1] + o[9] * y[2], o[2] * y[0] + o[6] * y[1] + o[10] * y[2]], T = Math.hypot(...w) || 1;
|
|
8818
|
+
return { light: ka(S, [w[0] / T, w[1] / T, w[2] / T], a), fog: va(s, Math.hypot(S[0] - r.position[0], S[1] - r.position[1], S[2] - r.position[2])) };
|
|
8819
|
+
}, O = hr(c.rig, h, f, b, { perspective: !0, near: r.near, slice: Td, light: E }), k = { look: l.look, style: l.style, ink: l.ink, paper: l.paper, fog: s?.color }, m = Oa(O), A = O.cells ?? [], P = Math.max(...A.map((v) => -v.depth), -u[2]);
|
|
8818
8820
|
return {
|
|
8819
8821
|
drawables: [
|
|
8820
|
-
...l.shadow === !1 ? [] : [{ depth: P + c.rig.length, draw: (
|
|
8821
|
-
...A.map((
|
|
8822
|
-
depth: -
|
|
8823
|
-
draw(y,
|
|
8824
|
-
y.lineCap = "round", y.lineJoin = "round", Xi(y,
|
|
8822
|
+
...l.shadow === !1 ? [] : [{ depth: P + c.rig.length, draw: (v) => Ha(v, O, k) }],
|
|
8823
|
+
...A.map((v) => ({
|
|
8824
|
+
depth: -v.depth,
|
|
8825
|
+
draw(y, S) {
|
|
8826
|
+
y.lineCap = "round", y.lineJoin = "round", Xi(y, v.parts, m, { ...k, time: S.time });
|
|
8825
8827
|
}
|
|
8826
8828
|
}))
|
|
8827
8829
|
]
|
|
@@ -8850,68 +8852,68 @@ function xd(e, n) {
|
|
|
8850
8852
|
function gu(e, n, t, o) {
|
|
8851
8853
|
const r = xd(t, n);
|
|
8852
8854
|
if (r.length > 0) throw new Error(`propScript3D (${n.kind}): ${r.length} problem(s) in the beats:
|
|
8853
|
-
${r.map((
|
|
8855
|
+
${r.map((k) => ` beat ${k.beat}: ${k.message}`).join(`
|
|
8854
8856
|
`)}`);
|
|
8855
8857
|
const a = {};
|
|
8856
|
-
for (const
|
|
8858
|
+
for (const k of [...Object.keys(Dt), ...Object.keys(n.rig.controls)]) a[k] = o.values?.[k] ?? ye(n.rig, {}, k);
|
|
8857
8859
|
let [s, i] = o.position ?? [0, 0], l = o.heading ?? 0;
|
|
8858
|
-
const c = /* @__PURE__ */ new Map(), h = (
|
|
8859
|
-
const
|
|
8860
|
-
|
|
8861
|
-
}, d = (
|
|
8860
|
+
const c = /* @__PURE__ */ new Map(), h = (k, m, A, P = "linear") => {
|
|
8861
|
+
const v = c.get(k) ?? [];
|
|
8862
|
+
v.push({ time: m, value: A, easing: P }), c.set(k, v);
|
|
8863
|
+
}, d = (k, m, A) => h(k, m, A);
|
|
8862
8864
|
h("x", 0, s), h("z", 0, i), h("rotateY", 0, l);
|
|
8863
|
-
const f = (
|
|
8865
|
+
const f = (k, m) => {
|
|
8864
8866
|
const A = un(l, m);
|
|
8865
|
-
if (Math.abs(A) < 1) return
|
|
8867
|
+
if (Math.abs(A) < 1) return k;
|
|
8866
8868
|
const P = Math.max(Od, Math.abs(A) * Pd);
|
|
8867
|
-
return d("rotateY",
|
|
8868
|
-
}, u = (
|
|
8869
|
+
return d("rotateY", k, l), l += A, h("rotateY", k + P, l, "ease-in-out"), k + P;
|
|
8870
|
+
}, u = (k, m, A) => {
|
|
8869
8871
|
const P = Ka([[s, i], ...m.through ?? [m.to]]);
|
|
8870
8872
|
if (P.length < 2) return A;
|
|
8871
|
-
const
|
|
8872
|
-
for (const [Y, ne] of Object.entries(
|
|
8873
|
-
d(Y,
|
|
8874
|
-
const H =
|
|
8875
|
-
for (const [Y, ne] of Object.entries(
|
|
8876
|
-
d(Y,
|
|
8877
|
-
H !== void 0 && (d("lift",
|
|
8873
|
+
const v = f(A, mt(P[0].point, P[1].point)), y = P[P.length - 1].at, S = m.for ?? y / (m.speed ?? k.speed) * 1e3, w = $t("ease-in-out"), T = Math.min(Hd, S / 4);
|
|
8874
|
+
for (const [Y, ne] of Object.entries(k.set ?? {}))
|
|
8875
|
+
d(Y, v, a[Y]), h(Y, v + 1, ne), a[Y] = ne;
|
|
8876
|
+
const H = k.flies ? m.height ?? (a.lift > 0.05 ? a.lift : 2) : void 0, x = H !== void 0 && H > 0.05;
|
|
8877
|
+
for (const [Y, ne] of Object.entries(k.hold ?? {}))
|
|
8878
|
+
d(Y, v, a[Y]), h(Y, v + T, ne, "ease-out"), x || (h(Y, v + S - T, ne), h(Y, v + S, 0, "ease-in")), a[Y] = x ? ne : 0;
|
|
8879
|
+
H !== void 0 && (d("lift", v, a.lift), h("lift", v + Math.min(S * 0.35, 1400), H, "ease-out"), h("lift", v + S, H), a.lift = H);
|
|
8878
8880
|
const j = { ...a };
|
|
8879
8881
|
let R = l;
|
|
8880
8882
|
for (let Y = 0; ; Y = Math.min(y, Y + Ad)) {
|
|
8881
|
-
const ne =
|
|
8883
|
+
const ne = v + Ra(w, Y / y) * S, { point: B, direction: I } = Wa(P, Y);
|
|
8882
8884
|
R += un(R, mt([0, 0], I)), h("x", ne, B[0]), h("z", ne, B[1]), h("rotateY", ne, R);
|
|
8883
|
-
for (const [N, K] of Object.entries(
|
|
8884
|
-
for (const [N, K] of Object.entries(
|
|
8885
|
+
for (const [N, K] of Object.entries(k.perMetre ?? {})) h(N, ne, j[N] + Y * K);
|
|
8886
|
+
for (const [N, K] of Object.entries(k.perSecond ?? {})) h(N, ne, j[N] + (ne - v) / 1e3 * K);
|
|
8885
8887
|
if (Y >= y) break;
|
|
8886
8888
|
}
|
|
8887
|
-
for (const [Y, ne] of Object.entries(
|
|
8888
|
-
for (const [Y, ne] of Object.entries(
|
|
8889
|
-
return [s, i] = P[P.length - 1].point, l = R,
|
|
8890
|
-
}, p = (
|
|
8891
|
-
const A = Object.fromEntries(Object.entries(
|
|
8892
|
-
for (const
|
|
8893
|
-
if (_d.includes(
|
|
8894
|
-
const y =
|
|
8895
|
-
if (!y.every((w) => w.value ===
|
|
8896
|
-
d(
|
|
8897
|
-
for (const w of y) w.time > 0 && c.get(
|
|
8898
|
-
a[
|
|
8889
|
+
for (const [Y, ne] of Object.entries(k.perMetre ?? {})) a[Y] = j[Y] + y * ne;
|
|
8890
|
+
for (const [Y, ne] of Object.entries(k.perSecond ?? {})) a[Y] = j[Y] + S / 1e3 * ne;
|
|
8891
|
+
return [s, i] = P[P.length - 1].point, l = R, v + S;
|
|
8892
|
+
}, p = (k, m) => {
|
|
8893
|
+
const A = Object.fromEntries(Object.entries(k).filter(([v]) => !["at", "to", "through", "toward"].includes(v))), P = rd(e, n, [A], { start: { ...a, turn: 1 }, scale: 100, style: o.style, exaggeration: o.exaggeration });
|
|
8894
|
+
for (const v of P.tracks) {
|
|
8895
|
+
if (_d.includes(v.property)) continue;
|
|
8896
|
+
const y = v.keyframes ?? [], S = a[v.property];
|
|
8897
|
+
if (!y.every((w) => w.value === S)) {
|
|
8898
|
+
d(v.property, m, S);
|
|
8899
|
+
for (const w of y) w.time > 0 && c.get(v.property).push({ ...w, time: m + w.time });
|
|
8900
|
+
a[v.property] = y[y.length - 1].value;
|
|
8899
8901
|
}
|
|
8900
8902
|
}
|
|
8901
8903
|
return m + P.duration;
|
|
8902
8904
|
}, g = [];
|
|
8903
8905
|
let b = 0;
|
|
8904
|
-
for (const
|
|
8905
|
-
const m =
|
|
8906
|
+
for (const k of t) {
|
|
8907
|
+
const m = k.at ?? b;
|
|
8906
8908
|
let A = m;
|
|
8907
|
-
const P = n.moves?.[
|
|
8908
|
-
P ? A = u(P,
|
|
8909
|
-
}
|
|
8910
|
-
const
|
|
8911
|
-
return { tracks: [...c].map(([
|
|
8912
|
-
id: `${e}-${
|
|
8913
|
-
target:
|
|
8914
|
-
property:
|
|
8909
|
+
const P = n.moves?.[k.do];
|
|
8910
|
+
P ? A = u(P, k, m) : k.do === "face" ? A = f(m, typeof k.toward == "number" ? k.toward : mt([s, i], k.toward)) : k.do === "hold" ? A = m + (k.for ?? 1e3) : A = p(k, m), g.push({ do: k.do, start: m, end: A }), b = A;
|
|
8911
|
+
}
|
|
8912
|
+
const E = `${o.scene}/${e}`;
|
|
8913
|
+
return { tracks: [...c].map(([k, m]) => ({
|
|
8914
|
+
id: `${e}-${k}`,
|
|
8915
|
+
target: E,
|
|
8916
|
+
property: k,
|
|
8915
8917
|
keyframes: Na(m)
|
|
8916
8918
|
})), duration: b, beats: g, end: { position: [s, i], heading: l, values: { ...a } } };
|
|
8917
8919
|
}
|
|
@@ -8952,21 +8954,21 @@ const ca = (e, n) => {
|
|
|
8952
8954
|
function mu(e) {
|
|
8953
8955
|
const n = `${e.scene}/${e.propId}`, t = new ve({ id: `${e.propId}-ride-3d`, tracks: e.propTracks.filter((b) => b.target === n) }), o = e.placement ?? {}, [r, a, s] = o.position ?? [0, 0, 0], i = e.prop.rig, l = ko({ ...e.character, height: 1 }), c = { ...be, ...e.pose ?? kr.seated }, h = wo(l.plan, c, { height: e.height ?? 1.7, contact: l.contact }).hip, d = e.facing ?? 0, f = e.every ?? 33, u = { x: [], y: [], z: [], rotateY: [] };
|
|
8954
8956
|
for (let b = e.start; ; b = Math.min(e.end, b + f)) {
|
|
8955
|
-
const
|
|
8956
|
-
const G =
|
|
8957
|
+
const E = t.getStateAtTime(b).values.get(n) ?? /* @__PURE__ */ new Map(), O = (j, R) => {
|
|
8958
|
+
const G = E.get(j);
|
|
8957
8959
|
return typeof G == "number" ? G : R;
|
|
8958
|
-
},
|
|
8959
|
-
for (const j of Object.keys(i.controls))
|
|
8960
|
-
for (const j of ["pitch", "roll", "squash", "lift", "lean", "size"])
|
|
8961
|
-
const m = Uc(i,
|
|
8960
|
+
}, k = { ...o.values };
|
|
8961
|
+
for (const j of Object.keys(i.controls)) k[j] = O(j, o.values?.[j] ?? ye(i, {}, j));
|
|
8962
|
+
for (const j of ["pitch", "roll", "squash", "lift", "lean", "size"]) k[j] = O(j, o.values?.[j] ?? ye(i, {}, j));
|
|
8963
|
+
const m = Uc(i, k)[e.anchor];
|
|
8962
8964
|
if (!m) throw new Error(`propRide3D: ${e.prop.kind} has no anchor "${e.anchor}" (it has ${Object.keys(i.anchors ?? {}).join(", ") || "none"})`);
|
|
8963
|
-
const A = O("rotateY", o.heading ?? 0), P = ca(m, A),
|
|
8964
|
-
let w = [
|
|
8965
|
-
const
|
|
8965
|
+
const A = O("rotateY", o.heading ?? 0), P = ca(m, A), v = [O("x", r) + P[0], O("y", a) + P[1], O("z", s) + P[2]], y = A + d, S = ca(h, y);
|
|
8966
|
+
let w = [v[0] - S[0], v[1] - S[1], v[2] - S[2]];
|
|
8967
|
+
const T = (j, R) => {
|
|
8966
8968
|
const G = R * R * (3 - 2 * R);
|
|
8967
8969
|
return [j[0] + (w[0] - j[0]) * G, w[1] * G + Cd * Math.sin(Math.PI * R), j[1] + (w[2] - j[1]) * G];
|
|
8968
8970
|
}, H = e.mount ? Math.max(1, e.mount.for ?? 450) : 0, x = e.dismount ? Math.max(1, e.dismount.for ?? 450) : 0;
|
|
8969
|
-
if (e.mount && b < e.start + H ? w =
|
|
8971
|
+
if (e.mount && b < e.start + H ? w = T(e.mount.from, (b - e.start) / H) : e.dismount && b > e.end - x && (w = T(e.dismount.to, (e.end - b) / x)), u.x.push({ time: b, value: w[0] }), u.y.push({ time: b, value: w[1] }), u.z.push({ time: b, value: w[2] }), u.rotateY.push({ time: b, value: y }), b >= e.end) break;
|
|
8970
8972
|
}
|
|
8971
8973
|
const p = e.riderId, g = `${e.scene}/${p}`;
|
|
8972
8974
|
return Object.keys(u).map((b) => ({ id: `${p}-${b}`, target: g, property: b, keyframes: u[b] }));
|
|
@@ -9017,17 +9019,17 @@ const zd = (e, n) => {
|
|
|
9017
9019
|
return t <= 12 ? t / 12 : -1;
|
|
9018
9020
|
}, Fd = 9, Dd = 55, Ld = 28;
|
|
9019
9021
|
function Bd(e) {
|
|
9020
|
-
const { x: n, y: t, width: o, height: r } = e, a = e.kind ?? "sky", s = e.ground ?? t + r * 0.85, i = { ...Kd, ...e.colors }, l = e.horizon ?? "hills", c = e.window !== !1, h = Et(e.seed ?? 1), d = o * r / 1e5, f = Array.from({ length: Math.ceil(Fd * d) + 2 }, () => ({ u: h.next(), v: h.next(), size: 0.6 + h.next() * 0.8, puffs: 2 + Math.floor(h.next() * 3) })), u = Array.from({ length: Math.ceil(Dd * d) + 4 }, () => ({ u: h.next(), v: h.next(), speed: 0.8 + h.next() * 0.5 })), p = Array.from({ length: Math.ceil(Ld * d) + 4 }, () => ({ u: h.next(), v: h.next(), speed: 0.7 + h.next() * 0.6, sway: h.next() * Math.PI * 2, size: 1.5 + h.next() * 2 })), g = Array.from({ length: Math.ceil(30 * d) + 10 }, () => ({ u: h.next(), v: h.next() * 0.6, size: 0.6 + h.next() * 1.2 })), b = Array.from({ length: 6 }, () => ({ phase: h.next() * Math.PI * 2, amp: 0.5 + h.next() })),
|
|
9022
|
+
const { x: n, y: t, width: o, height: r } = e, a = e.kind ?? "sky", s = e.ground ?? t + r * 0.85, i = { ...Kd, ...e.colors }, l = e.horizon ?? "hills", c = e.window !== !1, h = Et(e.seed ?? 1), d = o * r / 1e5, f = Array.from({ length: Math.ceil(Fd * d) + 2 }, () => ({ u: h.next(), v: h.next(), size: 0.6 + h.next() * 0.8, puffs: 2 + Math.floor(h.next() * 3) })), u = Array.from({ length: Math.ceil(Dd * d) + 4 }, () => ({ u: h.next(), v: h.next(), speed: 0.8 + h.next() * 0.5 })), p = Array.from({ length: Math.ceil(Ld * d) + 4 }, () => ({ u: h.next(), v: h.next(), speed: 0.7 + h.next() * 0.6, sway: h.next() * Math.PI * 2, size: 1.5 + h.next() * 2 })), g = Array.from({ length: Math.ceil(30 * d) + 10 }, () => ({ u: h.next(), v: h.next() * 0.6, size: 0.6 + h.next() * 1.2 })), b = Array.from({ length: 6 }, () => ({ phase: h.next() * Math.PI * 2, amp: 0.5 + h.next() })), E = Array.from({ length: 24 }, () => ({ h: 0.35 + h.next() * 0.65, w: 0.6 + h.next() * 0.8, windows: h.next() > 0.3 })), O = {
|
|
9021
9023
|
hour: e.hour ?? 12,
|
|
9022
9024
|
clouds: e.clouds ?? 0.3,
|
|
9023
9025
|
wind: e.wind ?? 0,
|
|
9024
9026
|
rain: e.rain ?? 0,
|
|
9025
9027
|
snow: e.snow ?? 0
|
|
9026
|
-
},
|
|
9027
|
-
const H = zd(w,
|
|
9028
|
+
}, k = Ft(), m = (w, T) => k.keys(w)?.length ? k.valueAt(w, T) : O[w], A = (w, T) => {
|
|
9029
|
+
const H = zd(w, T), x = H < 0 ? 0.5 : H, j = s - t;
|
|
9028
9030
|
return { x: 0.1 * o + 0.8 * o * x, y: H < 0 ? j + r * 0.2 : j - Math.sin(x * Math.PI) * j * 0.8, up: H >= 0 };
|
|
9029
|
-
}, P = (w,
|
|
9030
|
-
const R =
|
|
9031
|
+
}, P = (w, T, H, x, j) => {
|
|
9032
|
+
const R = T("hour"), { top: G, bottom: Y } = Rd(R), ne = w.createLinearGradient(0, x.y, 0, x.ground);
|
|
9031
9033
|
ne.addColorStop(0, G), ne.addColorStop(1, Y), w.fillStyle = ne, w.fillRect(x.x, x.y, x.w, x.ground - x.y);
|
|
9032
9034
|
const B = Wd(R);
|
|
9033
9035
|
if (B < 0.6) {
|
|
@@ -9041,7 +9043,7 @@ function Bd(e) {
|
|
|
9041
9043
|
const F = x.x + N.x / o * x.w, Q = x.y + N.y / r * x.h;
|
|
9042
9044
|
w.fillStyle = i.moon, w.beginPath(), w.arc(F, Q, K * 0.8, 0, Math.PI * 2), w.fill(), w.fillStyle = G, w.beginPath(), w.arc(F - K * 0.35, Q - K * 0.15, K * 0.7, 0, Math.PI * 2), w.fill();
|
|
9043
9045
|
}
|
|
9044
|
-
const
|
|
9046
|
+
const M = Math.max(0, Math.min(1, T("clouds"))), _ = Math.max(-1, Math.min(1, T("wind"))), V = Math.round(M * f.length);
|
|
9045
9047
|
w.fillStyle = Kt("#ffffff", i.cloud === "#ffffff" ? "#ffffff" : i.cloud, 1), w.globalAlpha = 0.55 + 0.4 * B;
|
|
9046
9048
|
for (let F = 0; F < V; F++) {
|
|
9047
9049
|
const Q = f[F], ae = ((Q.u * x.w + _ * H * 0.012 * (0.6 + Q.size * 0.5)) % (x.w * 1.4) + x.w * 1.4) % (x.w * 1.4) - x.w * 0.2, C = x.x + ae, X = x.y + (0.08 + Q.v * 0.42) * (x.ground - x.y), D = Math.min(x.w, x.h) * 0.07 * Q.size;
|
|
@@ -9063,7 +9065,7 @@ function Bd(e) {
|
|
|
9063
9065
|
w.fillStyle = ee(i.city);
|
|
9064
9066
|
let F = x.x;
|
|
9065
9067
|
const Q = x.w / 18;
|
|
9066
|
-
for (const ae of
|
|
9068
|
+
for (const ae of E) {
|
|
9067
9069
|
if (F > x.x + x.w) break;
|
|
9068
9070
|
const C = Q * ae.w, X = x.h * 0.22 * ae.h;
|
|
9069
9071
|
if (w.fillRect(F, x.ground - X, C, X), ae.windows && B < 0.5) {
|
|
@@ -9075,15 +9077,15 @@ function Bd(e) {
|
|
|
9075
9077
|
}
|
|
9076
9078
|
}
|
|
9077
9079
|
w.fillStyle = ee(i.ground), w.fillRect(x.x, x.ground, x.w, x.y + x.h - x.ground);
|
|
9078
|
-
},
|
|
9079
|
-
const j = Math.max(-1, Math.min(1,
|
|
9080
|
+
}, v = (w, T, H, x) => {
|
|
9081
|
+
const j = Math.max(-1, Math.min(1, T("wind"))), R = Math.max(0, Math.min(1, T("rain"))), G = Math.max(0, Math.min(1, T("snow")));
|
|
9080
9082
|
if (R > 0) {
|
|
9081
9083
|
w.strokeStyle = i.rain, w.globalAlpha = 0.35 + 0.45 * R, w.lineWidth = 1.2, w.lineCap = "round";
|
|
9082
9084
|
const Y = x.h * 0.05, ne = j * 0.45, B = Math.round(R * u.length);
|
|
9083
9085
|
w.beginPath();
|
|
9084
9086
|
for (let I = 0; I < B; I++) {
|
|
9085
|
-
const N = u[I], K = ((N.v * x.h + H * N.speed * 0.9) % x.h + x.h) % x.h,
|
|
9086
|
-
w.moveTo(x.x +
|
|
9087
|
+
const N = u[I], K = ((N.v * x.h + H * N.speed * 0.9) % x.h + x.h) % x.h, M = ((N.u * x.w + K * ne) % x.w + x.w) % x.w;
|
|
9088
|
+
w.moveTo(x.x + M, x.y + K), w.lineTo(x.x + M + ne * Y, x.y + K + Y);
|
|
9087
9089
|
}
|
|
9088
9090
|
w.stroke(), w.globalAlpha = 1;
|
|
9089
9091
|
}
|
|
@@ -9096,7 +9098,7 @@ function Bd(e) {
|
|
|
9096
9098
|
}
|
|
9097
9099
|
w.globalAlpha = 1;
|
|
9098
9100
|
}
|
|
9099
|
-
},
|
|
9101
|
+
}, S = {
|
|
9100
9102
|
kind: "scenery",
|
|
9101
9103
|
target: {
|
|
9102
9104
|
type: "custom",
|
|
@@ -9110,22 +9112,22 @@ function Bd(e) {
|
|
|
9110
9112
|
summary: a === "room" ? "A room: a wall, a floor and a window on the sky. Its values are tracks: hour, clouds, wind, rain, snow (seen through the window)." : `A sky over ${l === "flat" ? "the ground" : l}: the sun and moon on their arcs, stars, clouds on the wind, rain and snow. Its values are tracks: hour (0–24), clouds, wind (−1..1), rain, snow (0..1).`,
|
|
9111
9113
|
props: Object.fromEntries(Object.keys(O).map((w) => [w, qd(w)]))
|
|
9112
9114
|
},
|
|
9113
|
-
draw(w,
|
|
9114
|
-
const x =
|
|
9115
|
+
draw(w, T, H) {
|
|
9116
|
+
const x = T.props ?? {}, j = (G) => Number(x[G] ?? O[G] ?? 0);
|
|
9115
9117
|
w.save();
|
|
9116
9118
|
const R = { x: 0, y: 0, w: o, h: r, ground: s - t };
|
|
9117
9119
|
if (a === "sky")
|
|
9118
|
-
P(w, j, H, R),
|
|
9120
|
+
P(w, j, H, R), v(w, j, H, R);
|
|
9119
9121
|
else if (w.fillStyle = i.wall, w.fillRect(0, 0, o, R.ground), w.fillStyle = i.floor, w.fillRect(0, R.ground, o, r - R.ground), w.fillStyle = i.skirting, w.fillRect(0, R.ground - r * 0.012, o, r * 0.012), c) {
|
|
9120
9122
|
const G = o * 0.26, Y = R.ground * 0.5, ne = o * 0.62, B = R.ground * 0.14;
|
|
9121
|
-
w.fillStyle = i.frame, w.fillRect(ne - 6, B - 6, G + 12, Y + 12), w.save(), w.beginPath(), w.rect(ne, B, G, Y), w.clip(), P(w, j, H, { x: ne, y: B, w: G, h: Y, ground: B + Y * 0.8 }),
|
|
9123
|
+
w.fillStyle = i.frame, w.fillRect(ne - 6, B - 6, G + 12, Y + 12), w.save(), w.beginPath(), w.rect(ne, B, G, Y), w.clip(), P(w, j, H, { x: ne, y: B, w: G, h: Y, ground: B + Y * 0.8 }), v(w, j, H, { x: ne, y: B, w: G, h: Y }), w.restore(), w.strokeStyle = i.frame, w.lineWidth = 4, w.beginPath(), w.moveTo(ne + G / 2, B), w.lineTo(ne + G / 2, B + Y), w.moveTo(ne, B + Y / 2), w.lineTo(ne + G, B + Y / 2), w.stroke();
|
|
9122
9124
|
}
|
|
9123
9125
|
w.restore();
|
|
9124
9126
|
}
|
|
9125
9127
|
},
|
|
9126
9128
|
ground: s,
|
|
9127
|
-
anchor(w,
|
|
9128
|
-
const H = m("hour",
|
|
9129
|
+
anchor(w, T = 1 / 0) {
|
|
9130
|
+
const H = m("hour", T);
|
|
9129
9131
|
if (w === "sun" || w === "moon") {
|
|
9130
9132
|
const x = A(H, w === "sun" ? 6 : 18);
|
|
9131
9133
|
return { x: n + x.x, y: t + x.y };
|
|
@@ -9134,14 +9136,14 @@ function Bd(e) {
|
|
|
9134
9136
|
if (w === "ground") return { x: n + o / 2, y: s };
|
|
9135
9137
|
throw new Error(`scenery: ${ce("place", w, ["sun", "moon", "horizon", "ground"])}`);
|
|
9136
9138
|
},
|
|
9137
|
-
set(w,
|
|
9139
|
+
set(w, T) {
|
|
9138
9140
|
if (!(w in O)) throw new Error(`scenery: ${ce("value", w, Object.keys(O))}`);
|
|
9139
|
-
if (typeof
|
|
9140
|
-
return
|
|
9141
|
+
if (typeof T.value != "number" || !Number.isFinite(T.value)) throw new Error("scenery.set needs `value`, a number");
|
|
9142
|
+
return k.tween(w, m(w, T.at), T.value, T, 1e3), S;
|
|
9141
9143
|
},
|
|
9142
|
-
tracks:
|
|
9144
|
+
tracks: k.tracks
|
|
9143
9145
|
};
|
|
9144
|
-
return
|
|
9146
|
+
return S;
|
|
9145
9147
|
}
|
|
9146
9148
|
function qd(e) {
|
|
9147
9149
|
switch (e) {
|