@algorisys/tinyfly 0.111.0 → 0.113.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.
@@ -1,414 +1,30 @@
1
- import { c as Ne, s as ve, H, a as Fe, r as He, b as qe, d as Be, e as de, f as G, C as ge, g as _e, h as Me, i as ze, j as xe, S as Ae, k as We, o as Le, l as ce, m as Ke, n as Ge, p as Ve, q as De } from "./cricket-markings-KbMjP7r6.js";
2
- import { t as ut, u as ht, v as dt, w as pt, x as ft, y as gt, z as bt } from "./cricket-markings-KbMjP7r6.js";
3
- import { vec3 as k, quat as Ee } from "@algorisys/tinyfly";
4
- const x = (t, n, e) => Math.max(0, Math.min(1, (t - n) / (e - n))), A = (t) => t * t * (3 - 2 * t), T = (t, n) => k.add(t, n), Te = (t, n) => k.scale(t, n);
5
- function ye(t, n) {
6
- const e = n + ((t - n + 2) % 4 + 4) % 4 - 2;
7
- return e === 0 ? 0 : e;
8
- }
9
- function ee(t, n, e = 0) {
10
- return Math.hypot(n[0] - t[0], n[2] - t[2]) < 1e-3 ? e : ye(Math.atan2(n[0] - t[0], n[2] - t[2]) * 2 / Math.PI, e);
11
- }
12
- function Oe() {
13
- return {
14
- turn: 1,
15
- "head.turn": 90,
16
- "leg.left.spread": 12,
17
- "leg.right.spread": 12,
18
- "leg.left.swing": 6,
19
- "leg.right.swing": 6,
20
- "leg.left.knee": 12,
21
- "leg.right.knee": 12
22
- };
23
- }
24
- function Pe(t, n) {
25
- const e = t.objects.find((a) => a.id === n);
26
- if (!e || e.kind !== "character") throw new Error(`cricketAction: required character '${n}' is missing`);
27
- if (e.parent || e.rotation?.some((a) => a !== 0) || e.quaternion || e.scale !== void 0) throw new Error(`cricketAction: '${n}' must use position and pose.turn, without a transformed parent, scale or object rotation`);
28
- return { object: e, who: Ne({ ...e.character, height: e.height ?? 1.78 }) };
29
- }
30
- function Je(t) {
31
- return { position: [...t.object.position ?? [0, 0, 0]], pose: { ...H, ...t.object.pose } };
32
- }
33
- function oe(t, n, e, a) {
34
- const s = ve(t.who.plan, n.pose, { height: t.who.height, contact: t.who.contact });
35
- return T(n.position, s.chains[e][a]);
36
- }
37
- function se(t, n, e) {
38
- const a = oe(t, n, `arm.${e}`, 2), s = oe(t, n, `arm.${e}`, 1);
39
- return T(a, Te(k.normalize(k.subtract(a, s)), t.who.lineWidth * 0.5));
40
- }
41
- function Ue(t, n, e) {
42
- const a = { ...n.pose, "head.turn": 0, "head.nod": 0, "head.tilt": 0 }, s = ve(t.who.plan, a, { height: t.who.height, contact: t.who.contact }).head, l = k.subtract(e, T(n.position, s.center)), c = s.axes.map((w) => k.dot(l, w)), d = Math.atan2(c[0], c[2]) * 180 / Math.PI, g = Math.atan2(-c[1], Math.hypot(c[0], c[2])) * 180 / Math.PI;
43
- return { ...n, pose: { ...n.pose, "head.turn": Math.max(-90, Math.min(90, d)), "head.nod": Math.max(-25, Math.min(30, g)), "head.tilt": 0 } };
44
- }
45
- function J(t, n, e, a, s = "hold") {
46
- let l = { ...n.pose };
47
- for (let c = 0; c < 10; c++) {
48
- const d = { ...n, pose: l }, g = ve(t.who.plan, l, { height: t.who.height, contact: t.who.contact }), w = Fe(t.who.plan, l, t.who.height), b = k.subtract(se(t, d, e), oe(t, d, `arm.${e}`, 2)), E = k.subtract(k.subtract(k.subtract(a, b), n.position), g.hip), W = He(E, (l.roll ?? 0) * Math.PI / 180), q = T(w.root, qe(W, -(l.turn ?? 0) * Math.PI / 2));
49
- l = Be(t.who.plan, l, `arm.${e}`, q, { height: t.who.height });
50
- }
51
- for (const [c, d] of Object.entries(de[s])) l[`hand.${e}.${c}`] = d;
52
- return { ...n, pose: l };
53
- }
54
- function Ye(t, n, e, a) {
55
- const s = k.normalize(a), l = t.who.height / 1.78;
56
- let c = J(t, n, "left", e);
57
- return c = J(t, c, "right", T(se(t, c, "left"), Te(s, 0.105 * l))), { ...c, bat: { grip: se(t, c, "left"), axis: s, scale: l } };
58
- }
59
- function Ze(t) {
60
- return T(t.grip, Te(t.axis, 0.51 * t.scale));
61
- }
62
- function Ie(t) {
63
- const n = k.normalize(t), e = Math.max(-1, Math.min(1, n[1]));
64
- return e > 0.999999 ? [0, 0, 0, 1] : e < -0.999999 ? Ee.fromAxisAngle([1, 0, 0], 180) : Ee.fromAxisAngle(k.normalize(k.cross([0, 1, 0], n)), Math.acos(e) * 180 / Math.PI).map((a) => a === 0 ? 0 : a);
65
- }
66
- function fe(t, n, e) {
67
- const a = {};
68
- for (const s of Object.keys({ ...t, ...n })) {
69
- const l = t[s] ?? H[s] ?? 0;
70
- a[s] = l + ((n[s] ?? H[s] ?? 0) - l) * e;
71
- }
72
- return a;
73
- }
74
- function Se(t, n) {
75
- if (t <= n[0][0]) return { ...H, ...n[0][1] };
76
- for (let e = 1; e < n.length; e++)
77
- if (t <= n[e][0]) return fe({ ...H, ...n[e - 1][1] }, { ...H, ...n[e][1] }, A(x(t, n[e - 1][0], n[e][0])));
78
- return { ...H, ...n.at(-1)[1] };
79
- }
80
- const N = Object.freeze({ length: 20.12, width: 3.05, poppingCrease: 1.22, returnCrease: 1.32, stumpHeight: 0.711, wicketWidth: 0.2286 });
81
- function Qe(t) {
82
- if (!t.id?.trim()) throw new Error("cricketPlayer: id is required");
83
- G({ batter: 1, bowler: 1, keeper: 1, fielder: 1, umpire: 1 }, t.role, "cricketPlayer.role");
84
- const n = G(Ae, t.preset ?? "youngMan", "cricketPlayer.preset"), e = G(ge, t.format ?? "t20", "cricketPlayer.format"), a = G({ none: 1, cap: 1, "sun-hat": 1 }, t.headwear ?? "none", "cricketPlayer.headwear"), s = n === "childBoy" || n === "childGirl", l = t.height ?? (s ? 1.24 : 1.78);
85
- if (!Number.isFinite(l) || l < 0.5 || l > 3) throw new Error("cricketPlayer: height must be between .5 and 3 metres");
86
- We(t.position ?? [0, 0, 0], "cricketPlayer.position");
87
- const c = t.role === "umpire" ? "#f5ebd5" : e === "test" ? "#f5f0df" : t.color ?? "#3577b5", d = JSON.parse(JSON.stringify({
88
- ...Ae[n],
89
- ...t.appearance,
90
- outfit: Le("casual", { top: "shirt", shirt: c, trousers: t.role === "umpire" ? "#405058" : c, bottom: "trousers", trouserStyle: "plain", sleeves: "short", collar: !0, tie: null, shoes: "boots", shoeColor: "#f3ead7" }),
91
- hat: a === "none" ? null : { style: a === "sun-hat" ? "sunHat" : "cap", color: c }
92
- }));
93
- return { id: t.id, name: t.role, kind: "character", look: "pen", height: l, position: [...t.position ?? [0, 0, 0]], character: d, pose: t.role === "batter" ? Oe() : { turn: t.role === "keeper" ? 2 : 0 } };
94
- }
95
- function pe(t, n, e, a, s = 0) {
96
- return { id: t, kind: "mesh", position: n, geometry: { type: "box", size: e }, material: a, layer: s };
97
- }
98
- function Xe(t, n) {
99
- const e = N.stumpHeight, a = (N.wicketWidth - 0.036) / 2;
100
- return [
101
- ...[-1, 0, 1].map((s, l) => ({ id: `${t}-stump-${l}`, kind: "mesh", position: [s * a, e / 2, n], geometry: { type: "cylinder", radius: 0.018, height: e, segments: 10 }, material: "wicket" })),
102
- ...[-1, 1].map((s, l) => pe(`${t}-bail-${l}`, [s * a / 2, e + 0.015, n], [0.105, 0.025, 0.035], "bail"))
103
- ];
104
- }
105
- function je(t, n) {
106
- return [
107
- { id: t, kind: "group", scale: n, visible: !1 },
108
- pe(`${t}-grip`, [0, 0.1, 0], [0.036, 0.28, 0.036], "bat-grip"),
109
- pe(`${t}-blade`, [0, 0.51, 0], [0.108, 0.54, 0.055], "bat-blade"),
110
- pe(`${t}-label`, [0, 0.41, 0.029], [0.07, 0.16, 4e-3], "bat-label")
111
- ].map((a, s) => s === 0 ? a : { ...a, parent: t });
112
- }
113
- function et(t = {}) {
114
- const n = G(ge, t.format ?? "t20", "cricketField.format"), e = G(_e, t.cast ?? "adults", "cricketField.cast"), a = G(Me, t.markingProfile ?? "icc-men", "cricketField.markingProfile"), s = Me[a], l = t.boundaryRadius ?? 64;
115
- if (!Number.isFinite(l) || l < 24 || l > 250) throw new Error("cricketField: boundaryRadius must be between 24 and 250 metres");
116
- const c = t.id ?? "cricket";
117
- if (!c.trim()) throw new Error("cricketField: id is required");
118
- const d = N.length / 2, g = n !== "test" && s.fieldingRadius !== null ? { radius: s.fieldingRadius, centres: [[0, 0, -d], [0, 0, d]] } : null, w = {
119
- "striker-wicket": [0, 0, d],
120
- "bowler-wicket": [0, 0, -d],
121
- "striker-crease": [0, 0, d - N.poppingCrease],
122
- "bowler-crease": [0, 0, -d + N.poppingCrease]
123
- }, b = [
124
- { id: "camera", kind: "camera", projection: "perspective", position: [25, 9, 6], lookAt: [0, 0.65, 0], fov: 48, near: 0.02, far: Math.max(600, l * 4) },
125
- { id: "sun", kind: "light", light: "directional", position: [4, 8, 5], intensity: 0.8, color: "#fff2dd" },
126
- { id: "ambient", kind: "light", light: "ambient", intensity: 0.85, color: "#eaf6f4" },
127
- { id: "outfield", kind: "mesh", layer: -4, position: [0, -0.04, 0], geometry: { type: "cylinder", radius: l + 1, height: 0.06, segments: 80 }, material: "grass" },
128
- { id: "square", kind: "mesh", layer: -3, geometry: { type: "plane", size: [8, 25] }, position: [0, 3e-3, 0], material: "square" },
129
- { id: "pitch", kind: "mesh", layer: -2, geometry: { type: "plane", size: [N.width, N.length] }, position: [0, 8e-3, 0], material: "pitch" },
130
- { id: "boundary", kind: "line", layer: -1, closed: !0, width: 0.15, color: "#f8f2db", points: Array.from({ length: 96 }, ($, I) => [Math.cos(I * Math.PI / 48) * l, 0.022, Math.sin(I * Math.PI / 48) * l]) }
131
- ];
132
- g && b.push({ id: "fielding-circle", kind: "line", layer: -1, closed: !0, width: 0.06, color: "#d6e4c8", points: ze(g) });
133
- for (const $ of [-1, 1]) {
134
- const I = $ > 0 ? "striker" : "bowler", O = $ * d, K = O - $ * N.poppingCrease;
135
- b.push(...Xe(I, O));
136
- const F = (P, C) => b.push({ id: `${I}-${P}`, kind: "line", layer: -1, color: "#fffdf0", width: 0.045, points: C });
137
- F("popping-line", [[-s.poppingCreaseHalfWidth, 0.02, K], [s.poppingCreaseHalfWidth, 0.02, K]]), F("bowling-line", [[-1.32, 0.02, O], [1.32, 0.02, O]]);
138
- for (const P of [-1, 1]) F(`return-line-${P < 0 ? "left" : "right"}`, [[P * 1.32, 0.02, K], [P * 1.32, 0.02, O + $ * 2.5]]);
139
- }
140
- const E = [
141
- ["batter", "batter", [-0.38, 0, 9.3]],
142
- ["non-striker", "batter", [-0.85, 0, -9.3]],
143
- ["bowler", "bowler", [0.68, 0, -17]],
144
- ["keeper", "keeper", [0, 0, 11.25]],
145
- ["fielder", "fielder", [12, 0, -3]],
146
- ["slip", "fielder", [3.5, 0, 12]],
147
- ["point", "fielder", [20, 0, 6]],
148
- ["cover", "fielder", [22, 0, -16]],
149
- ["mid-off", "fielder", [9, 0, -25]],
150
- ["mid-on", "fielder", [-9, 0, -25]],
151
- ["square-leg", "fielder", [-20, 0, 7]],
152
- ["fine-leg", "fielder", [-20, 0, 35]],
153
- ["third-man", "fielder", [23, 0, 35]],
154
- ["umpire", "umpire", [0, 0, -12.4]],
155
- ["square-umpire", "umpire", [-15, 0, 8.84]]
156
- ];
157
- E.forEach(([$, I, O], K) => {
158
- const F = e === "children" || e === "mixed" && K % 3 === 0, P = e === "men" ? "youngMan" : F ? K % 2 ? "childGirl" : "childBoy" : K % 2 ? "youngWoman" : "youngMan", C = Math.hypot(O[0], O[2]), te = C > l * 0.88 ? [O[0] * l * 0.88 / C, 0, O[2] * l * 0.88 / C] : [...O];
159
- w[$] = [...te];
160
- const U = Qe({ id: $, role: I, preset: P, format: n, position: te, color: I === "batter" ? t.battingColor ?? "#397cb9" : t.fieldingColor ?? "#bf604e" });
161
- if (Object.hasOwn(xe, $) && (U.name = xe[$]), $ !== "batter") {
162
- const Y = $ === "non-striker" || $ === "bowler" ? E[0][2] : E.find(([be]) => be === "bowler")[2];
163
- U.pose = { turn: ee(te, Y) };
164
- }
165
- b.push(U);
166
- });
167
- const W = ($) => b.find((I) => I.id === $).height / 1.78;
168
- b.push(...je("bat", W("batter")), ...je("non-striker-bat", W("non-striker"))), b.push({ id: "ball", kind: "mesh", position: [0, 0.075, 0], geometry: { type: "sphere", radius: 0.075, segments: 12 }, material: "ball" }), b.push({ id: "lbw-guide", kind: "group", visible: !1 }, { id: "lbw-projection", kind: "line", parent: "lbw-guide", points: [[0, 0, 0], [0, 1, 0]], width: 0.04, color: "#e9ae38" });
169
- const q = ($) => ({ color: $, shading: "toon", outline: { color: "#69513a", width: 0.8 } });
170
- return { format: n, boundaryRadius: l, landmarks: w, markingProfile: a, fieldingArea: g, scene: {
171
- id: c,
172
- formatVersion: 1,
173
- camera: "camera",
174
- background: { top: "#c8e5ef", bottom: "#e9efcc" },
175
- ground: 0,
176
- objects: b,
177
- materials: {
178
- grass: { color: "#81a95c", shading: "unlit" },
179
- square: { color: "#a6b76a", shading: "unlit", doubleSided: !0 },
180
- pitch: { color: "#ddbd85", shading: "unlit", doubleSided: !0 },
181
- wicket: q("#edd99e"),
182
- bail: q("#bd8c4d"),
183
- "bat-grip": q("#385b5c"),
184
- "bat-blade": q("#e8c58d"),
185
- "bat-label": q("#c34d4c"),
186
- ball: { color: n === "test" ? "#b32d36" : "#fff9e7", shading: "toon", outline: { color: "#9b3840", width: 1 } }
187
- }
188
- } };
189
- }
190
- const R = 1900, ne = 2450, v = 2900, ie = 4100, D = 4200, X = 4600, ue = 5300, me = 5500;
191
- function he(t, n, e, a, s, l, c = t.object.pose?.turn ?? 0) {
192
- const d = x(n, e, a), g = k.distance(s, l), w = ee(s, l, c), b = c + (w - c) * A(x(n, e, e + 200)), E = { ...H, ...t.object.pose, turn: b }, W = Ge("run", t.who.height, 1, t.object.character?.legLength ?? 1), q = Ve("run", g * d / W, E), $ = Math.min(d * 12, (1 - d) * 12, 1);
193
- return { position: k.lerp(s, l, d), pose: fe(E, q, Math.max(0, $)) };
194
- }
195
- function ke(t, n, e) {
196
- const a = (t.pose.turn ?? 0) * Math.PI / 2;
197
- return T(t.position, [Math.sin(a) * n, e, Math.cos(a) * n]);
198
- }
199
- function tt(t, n, e, a, s) {
200
- const l = `${n}/${e.object.id}`, c = { ...H, ...e.object.pose }, d = new Set(s.flatMap((g) => Object.keys(g.pose)));
201
- for (const g of d) {
202
- const w = c[g] ?? 0;
203
- s.some((b) => b.pose[g] !== w) && t.push({ id: `${e.object.id}-${g}`, target: l, property: g, keyframes: a.map((b, E) => ({ time: b, value: s[E].pose[g] ?? w })) });
204
- }
205
- for (const [g, w] of ["x", "y", "z"].entries())
206
- s.some((b) => b.position[g] !== (e.object.position?.[g] ?? 0)) && t.push({ id: `${e.object.id}-${w}`, target: l, property: w, keyframes: a.map((b, E) => ({ time: b, value: s[E].position[g] })) });
207
- if (s[0].bat) {
208
- const g = e.object.id === "batter" ? "bat" : "non-striker-bat", w = `${n}/${g}`;
209
- t.push({ id: `${g}-visible`, target: w, property: "visible", keyframes: [{ time: 0, value: 1 }] }), t.push({ id: `${g}-position`, target: w, property: "position", keyframes: a.map((b, E) => ({ time: b, value: [...s[E].bat.grip] })) }), t.push({ id: `${g}-rotation`, target: w, property: "quaternion", interpolation: "slerp", keyframes: a.map((b, E) => ({ time: b, value: Ie(s[E].bat.axis) })) });
210
- }
211
- }
212
- function rt(t, n) {
213
- const e = { runs: 0, extras: 0, wickets: 0, legalBall: !0, freeHitNext: !1 };
214
- t === "running" && (e.runs = 1), t === "four" && (e.runs = 4), t === "six" && (e.runs = 6), (t === "wide" || t === "no-ball") && (e.extras = 1, e.legalBall = !1), t === "no-ball" && (e.freeHitNext = ge[n].freeHitAfterNoBall);
215
- const s = { catch: "caught", bowled: "bowled", lbw: "lbw", stumping: "stumped", "run-out": "run-out" }[t];
216
- return s && (e.wickets = 1, e.dismissal = s), e;
217
- }
218
- function nt(t, n = {}) {
219
- const e = G(ce, n.action ?? "bowling", "cricketAction.action");
220
- G(ge, t.format, "cricketAction.format");
221
- const a = n.duration ?? 6e3;
222
- if (!Number.isFinite(a) || a < 4e3 || a > 6e4) throw new Error("cricketAction: duration must be between 4000 and 60000 ms");
223
- const s = t.scene.id;
224
- for (const r of ["ball", "bat", "non-striker-bat", "lbw-guide", "striker-bail-0", "striker-bail-1", "bowler-bail-0", "bowler-bail-1"])
225
- if (!t.scene.objects.some((o) => o.id === r)) throw new Error(`cricketAction: required equipment '${r}' is missing`);
226
- const l = Object.fromEntries(["batter", "non-striker", "bowler", "keeper", "fielder", "umpire"].map((r) => [r, Pe(t.scene, r)]));
227
- for (const r of ["slip", "point", "cover", "mid-off", "mid-on", "square-leg", "fine-leg", "third-man", "square-umpire"])
228
- t.scene.objects.some((o) => o.id === r && o.kind === "character") && (l[r] = Pe(t.scene, r));
229
- const c = (r) => l[r].who.height, d = (r) => Je(l[r]), g = (r) => Math.round(r * 6e3 / a * 1e9) / 1e9, w = (r) => r * a / 6e3, b = ["batting", "defend", "running", "four", "six", "catch", "fielding", "throw", "run-out"].includes(e), E = ["bowling", "spin", "no-ball", "stumping"].includes(e), W = ["catch", "fielding", "throw", "run-out", "batting", "running"].includes(e), q = e === "running" || e === "run-out", $ = /* @__PURE__ */ new Map(), I = [d("bowler").position[0], 0, e === "no-ball" ? -8.25 : -9.55], O = e === "fielding" ? [10.5, 0, 2] : [9, 0, -1], K = d("fielder").position, F = (r, o) => {
230
- let y = $.get(r);
231
- y || (y = /* @__PURE__ */ new Map(), $.set(r, y));
232
- const p = y.get(o);
233
- if (p) return p;
234
- const m = l[r];
235
- let i = d(r);
236
- if (r === "bowler") {
237
- const u = i.position;
238
- if (o < 1400) {
239
- const h = T(I, [0, 0, -0.65]);
240
- i = he(m, o, 0, 1400, u, h), i.pose["arm.right.swing"] = 45, i.pose["arm.right.elbow"] = 80;
241
- } else
242
- i.position = o <= R ? k.lerp(T(I, [0, 0, -0.65]), I, A(x(o, 1400, R))) : T(I, [0, 0, 0.8 * A(x(o, R, 2600))]), i.pose = Se(o, [
243
- [1400, { turn: 0, "arm.right.swing": 285, "arm.right.elbow": 8, "arm.left.swing": 115, "leg.right.swing": 15, "leg.left.knee": 45 }],
244
- [1800, { turn: 0, "arm.right.swing": 180, "arm.right.elbow": 0, "arm.left.swing": 80, "leg.right.swing": 25, "leg.right.knee": 0, "leg.left.swing": -25, "leg.left.knee": 60 }],
245
- [R, { turn: 0, lean: 8, "arm.right.swing": 155, "arm.right.elbow": 0, "arm.left.swing": 45, "leg.right.swing": 25, "leg.right.knee": 0, "leg.left.swing": -25, "leg.left.knee": 60 }],
246
- [2250, { turn: 0, lean: 26, bend: 12, "arm.right.swing": 40, "arm.right.elbow": 0, "arm.left.swing": -35, "leg.left.swing": -35, "leg.left.knee": 55 }],
247
- [3e3, { turn: 0, "head.turn": 10 }],
248
- [6e3, { turn: 0, "head.turn": 10 }]
249
- ]);
250
- e === "spin" && (i.pose = { ...i.pose, "arm.right.spread": 18, "head.tilt": -5 });
251
- for (const [h, f] of Object.entries(o < R ? de.hold : de.open)) i.pose[`hand.right.${h}`] = f;
252
- } else if (r === "batter" || r === "non-striker") {
253
- const u = c(r);
254
- if (e === "lbw" && r === "batter" && (i.position[0] = 0), e === "stumping" && r === "batter" && (i.position[2] -= 1.1 * A(x(o, 2150, 2800))), q && o > 3050) {
255
- const h = F(r, 3050), f = r === "batter" ? [1, 0, -9.5] : [-1, 0, 9.5];
256
- i = he(m, o, 3050, e === "run-out" ? 6e3 : me, h.position, f, h.pose.turn);
257
- const L = se(m, i, "right");
258
- i.bat = { grip: L, axis: k.normalize([0.7, -0.35, 0.5]), scale: u / 1.78 };
259
- } else {
260
- i.pose = { ...i.pose, ...r === "batter" ? Oe() : { turn: 0.15, "leg.left.knee": 8, "leg.right.knee": 8 } };
261
- let f = [0, -1, r === "batter" ? 0.05 : 0.12], M = T(i.position, [u * 0.15, u * 0.44, u * 0.04]);
262
- if (r === "non-striker" && (M = T(i.position, [u * 0.08, u * 0.44, u * 0.17])), r === "batter") {
263
- const L = A(x(o, 2100, 2600)) * (1 - A(x(o, 2600, v))), V = A(x(o, 2600, v)) * (1 - A(x(o, v, 3800))), _ = A(x(o, v, 3250)) * (1 - A(x(o, 3250, 4e3)));
264
- if (b) {
265
- M = T(i.position, [u * (0.15 + 0.03 * L - 0.02 * V - 0.03 * _), u * (0.44 + 0.14 * L + 0.07 * V + 0.23 * _), u * (0.04 + 0.16 * L - 0.12 * V - 0.06 * _)]), f = k.normalize([0.15 * L + 0.25 * _, -1 + 1.85 * L + 1.6 * _, 0.05 + 0.55 * L - 0.4 * V - 0.8 * _]), i.pose.turn = 1 + 0.12 * V + 0.3 * _, i.pose.lean = 3 + 4 * V;
266
- const z = 12 + 4 * V;
267
- i.pose["leg.left.spread"] = z, i.pose["leg.right.spread"] = z, e === "defend" && (f = [0, -1, -0.08], M = T(i.position, [u * 0.1, u * 0.5, -u * 0.12]));
268
- } else if (["stumping", "bowled", "lbw"].includes(e)) {
269
- const z = A(x(o, 2100, 2700)) * (1 - A(x(o, 4e3, 4500)));
270
- f = k.normalize([0.15 * z, -1 + 1.85 * z, 0.05 + 0.55 * z]), M = T(i.position, [u * (0.15 + 0.03 * z), u * (0.44 + 0.14 * z), u * (0.04 + 0.16 * z)]);
271
- }
272
- }
273
- i = Ye(m, i, M, f);
274
- }
275
- } else if (r === "keeper") {
276
- i.pose = { ...i.pose, turn: ee(i.position, d("bowler").position, 2), lean: 20, "leg.left.swing": 22, "leg.right.swing": 22, "leg.left.knee": 50, "leg.right.knee": 50 }, e === "wide" && (i.position[0] = 2.15 * A(x(o, 2900, 3500))), e === "stumping" && (i.position[2] -= 0.85 * A(x(o, 3400, 3900)));
277
- const u = ke(i, c(r) * 0.27, c(r) * 0.44);
278
- if (e === "stumping" && o >= 3500) {
279
- const h = ke({ ...i, position: d(r).position }, c(r) * 0.27, c(r) * 0.44), f = [0, N.stumpHeight, N.length / 2], M = k.lerp(h, f, A(x(o, 3500, 3900)));
280
- i = J(m, i, "right", M), i = J(m, i, "left", T(M, [0.045, 0, 0]));
281
- } else
282
- i = J(m, i, "right", u), i = J(m, i, "left", T(u, [0.045, 0, 0]));
283
- } else if (r === "fielder" && W) {
284
- if (i = he(m, o, 3050, e === "catch" ? 3800 : 3950, K, O), o >= 3800) {
285
- const u = { ...H, turn: ee(O, d("batter").position, i.pose.turn), lean: e === "catch" ? 5 : 42, bend: e === "catch" ? 0 : 18, "leg.left.swing": e === "catch" ? 0 : 45, "leg.right.swing": e === "catch" ? 0 : 45, "leg.left.knee": e === "catch" ? 0 : 85, "leg.right.knee": e === "catch" ? 0 : 85, smile: 0.7 };
286
- i.pose = fe(i.pose, u, A(x(o, 3800, D)));
287
- const h = ke(i, c(r) * 0.22, c(r) * (e === "catch" ? 0.73 : 0.2));
288
- if (i = J(m, i, "right", h), i = J(m, i, "left", T(h, [0.035, 0, 0])), (e === "throw" || e === "run-out") && o > D) {
289
- const f = { ...H, turn: ee(O, e === "throw" ? d("keeper").position : t.landmarks["bowler-wicket"], i.pose.turn), "arm.right.swing": 225, "arm.right.elbow": 60, "arm.left.spread": 70, "leg.left.swing": 15 }, M = { ...f, "arm.right.swing": 110, "arm.right.elbow": 0, lean: 15 };
290
- i.pose = Se(o, [[D, i.pose], [4450, f], [X, M], [4900, { ...H, turn: f.turn, "arm.right.swing": 25, lean: 22 }], [6e3, { ...H, turn: f.turn }]]);
291
- }
292
- }
293
- } else if (r === "umpire") {
294
- let u = { ...H };
295
- const h = e === "stumping" ? 4150 : e === "run-out" ? 5150 : e === "bowled" || e === "lbw" ? 3500 : e === "catch" ? 4350 : 5100;
296
- if (e === "no-ball") u = { ...u, "arm.right.spread": 90, "arm.right.elbow": 0 };
297
- else if (e === "wide") u = { ...u, "arm.right.spread": 90, "arm.left.spread": 90, "arm.right.elbow": 0, "arm.left.elbow": 0 };
298
- else if (e === "six") u = { ...u, "arm.right.spread": 180, "arm.left.spread": 180, "arm.right.elbow": 0, "arm.left.elbow": 0 };
299
- else if (e === "four") u = { ...u, "arm.right.spread": 90 - 70 * (0.5 + Math.sin((o - 5100) / 180) * 0.5), "arm.right.elbow": 12 };
300
- else if (["catch", "bowled", "lbw", "stumping", "run-out"].includes(e)) {
301
- u = { ...u, "arm.right.swing": 165, "arm.right.elbow": 0 };
302
- for (const [f, M] of Object.entries(de.point)) u[`hand.right.${f}`] = M;
303
- }
304
- i.pose = fe(i.pose, u, A(x(o, e === "no-ball" ? R : e === "wide" ? 3100 : h, (e === "no-ball" ? R : e === "wide" ? 3100 : h) + 350)));
305
- }
306
- return y.set(o, i), i;
307
- }, P = (r, o) => se(l[r], F(r, o), "right"), C = b ? Ze(F("batter", v).bat) : e === "lbw" ? k.lerp(oe(l.batter, F("batter", v), "leg.right", 1), oe(l.batter, F("batter", v), "leg.right", 2), 0.6) : [E ? N.wicketWidth / 2 + 0.075 + 0.15 : 0, 0.45, 9.25], te = P("bowler", R), U = [e === "wide" ? 0.85 : e === "spin" ? -0.35 : e === "lbw" ? C[0] * 0.6 : 0, 0.075, 3.9], Y = P("keeper", e === "stumping" ? 3400 : 3500), be = P("fielder", ie), $e = P("fielder", D), we = e === "run-out" ? "bowler" : "striker", B = e === "run-out" ? 5e3 : e === "stumping" ? 3900 : 3200, ae = [t.boundaryRadius * 0.8, e === "six" ? 2.1 : 0.075, -t.boundaryRadius * 0.6], S = (r, o, y, p, m, i = 0, u = 0) => De({ target: `${s}/ball`, start: o, end: y, from: p, to: m, arc: i, curve: u }, r), Re = (r) => {
308
- if (r <= R) return P("bowler", r);
309
- if (r <= ne) return S(r, R, ne, te, U, 0.15, e === "spin" ? 0.35 : 0);
310
- const o = e === "wide" ? T(Y, [0, 0, -0.6]) : C;
311
- if (r <= v) return S(r, ne, v, U, o, 0.08);
312
- if (e === "bowled") {
313
- const p = [0, 0.36, N.length / 2];
314
- return r <= B ? S(r, v, B, C, p) : S(r, B, 4100, p, [0, 0.075, 12.5], 0.2);
315
- }
316
- if (e === "lbw") return [...C];
317
- if (["bowling", "spin", "no-ball", "wide", "stumping"].includes(e)) {
318
- const p = e === "stumping" ? 3400 : 3500;
319
- if (E && r <= p) {
320
- const m = [o[0], Y[1], N.length / 2 + 0.2];
321
- return r <= 3200 ? S(r, v, 3200, o, m, 0.04) : S(r, 3200, p, m, Y, 0.04);
322
- }
323
- return r <= p ? S(r, v, p, o, Y, 0.04) : P("keeper", r);
324
- }
325
- if (e === "defend") return S(r, v, 3400, C, T(C, [-0.5, -C[1] + 0.075, -0.7]), 0.12);
326
- if (e === "four" || e === "six") {
327
- if (e === "six") return r <= 5e3 ? S(r, v, 5e3, C, ae, 12) : S(r, 5e3, 5700, ae, T(ae, [2, -2.025, -1.5]));
328
- const p = [5, 0.075, 5];
329
- return r <= 3300 ? S(r, v, 3300, C, p, 0.5) : S(r, 3300, 5e3, p, ae);
330
- }
331
- if (e === "catch") return r <= ie ? S(r, v, ie, C, be, 5) : P("fielder", r);
332
- const y = [4, 0.075, 5];
333
- if (r <= 3300) return S(r, v, 3300, C, y, 0.8);
334
- if (r <= D) return S(r, 3300, D, y, $e);
335
- if (e === "throw" || e === "run-out") {
336
- if (r <= X) return P("fielder", r);
337
- const p = P("fielder", X), m = e === "run-out" ? [0, 0.42, -N.length / 2] : P("keeper", ue), i = e === "run-out" ? B : ue;
338
- return r <= i ? S(r, X, i, p, m, 1.2) : e === "run-out" ? S(r, i, 5700, m, [0, 0.075, -12], 0.18) : P("keeper", r);
339
- }
340
- return [...$e];
341
- }, re = [], j = (r, o, y, p, m) => re.push({ id: r, time: w(o), kind: y, label: p, caption: m });
342
- j("setup", 0, "setup", ce[e].name, ce[e].summary), j("release", R, "release", "Ball released", e === "no-ball" ? "The front foot has landed beyond the popping crease. No-ball." : "The bowler releases the ball; the front foot is behind the popping crease."), j("bounce", ne, "bounce", "Pitch bounce", e === "spin" ? "The curved flight is illustrative. Spin can change the ball’s path after it bounces." : "The delivery bounces on the pitch on its way to the striker."), b ? j("contact", v, "contact", "Bat contact", "The ball meets the blade. The bat is keyed from the same two hand grips.") : e === "lbw" ? j("pad-contact", v, "contact", "Pad contact", "The highlighted path illustrates a ball that would hit the stumps. This is an authored LBW example.") : j("miss", v, "contact", e === "wide" ? "Beyond normal reach" : "The batter misses", e === "wide" ? "The untouched ball is too far away for a normal stroke. The umpire calls Wide." : "The untouched delivery passes the striker."), e === "catch" && j("catch", ie, "collect", "Catch controlled", "The fielder controls the ball before it touches the ground: caught."), ["fielding", "throw", "run-out", "batting", "running"].includes(e) && j("gather", D, "collect", "Ground ball gathered", "The ball has touched the ground. Gathering it is fielding, not a catch dismissal."), ["bowling", "spin", "wide", "no-ball", "stumping"].includes(e) && j("keeper", e === "stumping" ? 3400 : 3500, "collect", "Keeper gathers", "The keeper controls the ball behind the striker’s wicket."), (e === "throw" || e === "run-out") && j("throw", X, "throw", "Throw released", "The fielder releases the gathered ball toward the wicket."), e === "throw" && j("return", ue, "collect", "Return received", "The keeper receives and controls the return throw."), e === "stumping" && j("wicket", B, "wicket", "Stumped", "Holding the ball, the keeper removes a bail. The striker is out of ground and is not attempting a run."), e === "run-out" && j("wicket", B, "wicket", "Run out", "The direct throw removes a bail before the running batter makes this ground."), e === "bowled" && j("wicket", B, "wicket", "Bowled", "The legal delivery hits the wicket and removes a bail."), (e === "four" || e === "six") && j("boundary", 5e3, "boundary", e === "four" ? "Four runs" : "Six runs", e === "four" ? "The struck ball reaches the boundary after touching the ground: four." : "The struck ball clears the boundary without touching the ground: six."), e === "running" && j("run", me, "result", "One run completed", "Both batters have reached the opposite ground. One run is completed.");
343
- const Z = rt(e, t.format);
344
- j("result", 5700, "result", "Illustrated result", e === "no-ball" ? `One no-ball extra; it does not count in the over.${Z.freeHitNext ? " The next legitimate delivery is a free hit." : " Test cricket has no automatic free hit."}` : e === "wide" ? "One wide extra; the delivery does not count in the over." : e === "lbw" ? "LBW is declared for this illustrated legal delivery. A full decision also checks pitching, impact and any bat contact." : `${Z.runs} bat runs · ${Z.extras} extras · ${Z.wickets} wicket${Z.wickets === 1 ? "" : "s"}.`), re.sort((r, o) => r.time - o.time);
345
- const le = Ke(0, a, n.every, [1400, 1800, R, 2100, 2150, 2250, ne, 2600, 2800, v, 3050, 3100, 3200, 3250, 3300, 3400, 3500, 3800, 3900, 3950, 4e3, ie, D, 4350, 4450, X, 4900, 5e3, 5100, 5150, ue, me, 5700].map(w)), Ce = le.map((r) => Re(g(r))), Q = [];
346
- for (const [r, o] of Object.entries(l)) {
347
- let y = o.object.pose?.turn ?? 0, p = y;
348
- const m = le.map((i, u) => {
349
- const h = g(i);
350
- let f = r === "fielder" && W && h > 3050 && h < 3250 ? he(o, h, 3050, e === "catch" ? 3800 : 3950, K, O, p) : F(r, h), M = Ce[u];
351
- const L = !["batter", "non-striker", "bowler", "keeper"].includes(r);
352
- if (L) {
353
- const _ = F("bowler", Math.min(h, R)), z = T(_.position, [0, c("bowler") * 0.8, 0]);
354
- M = h <= R ? z : h < 2100 ? k.lerp(z, M, A(x(h, R, 2100))) : M;
355
- }
356
- if (q && (r === "batter" || r === "non-striker") && h > 3050 && (M = r === "batter" ? [1, c(r) * 0.8, -10.5] : [-1, c(r) * 0.8, 10.5]), r === "bowler" && h <= v && (M = T(F("batter", h).position, [0, c("batter") * 0.65, 0])), L && (r !== "fielder" || !W || h <= 3050) || r === "bowler" && h >= 3e3) {
357
- const _ = ee(f.position, M, y);
358
- y = r === "bowler" && h < 3500 ? (f.pose.turn ?? 0) + (ye(_, f.pose.turn ?? 0) - (f.pose.turn ?? 0)) * A(x(h, 3e3, 3500)) : _, f = { ...f, pose: { ...f.pose, turn: y } };
359
- }
360
- return r === "fielder" && W && (h === 3050 ? p = y : h > 3050 && (y = ye(f.pose.turn ?? 0, y), f = { ...f, pose: { ...f.pose, turn: y } })), Ue(o, f, M);
361
- });
362
- tt(Q, s, o, le, m);
363
- }
364
- for (const [r, o] of ["x", "y", "z"].entries()) Q.push({ id: `ball-${o}`, target: `${s}/ball`, property: o, keyframes: le.map((y, p) => ({ time: y, value: Ce[p][r] })) });
365
- if (["bowled", "stumping", "run-out"].includes(e))
366
- for (let r = 0; r < 2; r++) {
367
- const o = `${we}-bail-${r}`, p = t.scene.objects.find((m) => m.id === o).position;
368
- Q.push({ id: `${o}-fall`, target: `${s}/${o}`, property: "position", keyframes: [{ time: 0, value: [...p] }, { time: w(B), value: [...p] }, { time: w(B + 180), value: T(p, [r ? 0.25 : -0.25, 0.22, we === "striker" ? 0.22 : -0.22]), easing: "ease-out" }, { time: w(B + 650), value: [p[0] + (r ? 0.4 : -0.4), 0.035, p[2] + (we === "striker" ? 0.45 : -0.45)], easing: "ease-in" }] }), Q.push({ id: `${o}-spin`, target: `${s}/${o}`, property: "rotateZ", keyframes: [{ time: 0, value: 0 }, { time: w(B), value: 0 }, { time: w(B + 650), value: r ? 145 : -145 }] });
369
- }
370
- if (e === "lbw") {
371
- const r = [C[0] * 0.8, C[1], N.length / 2], o = k.subtract(r, C);
372
- Q.push(
373
- { id: "lbw-position", target: `${s}/lbw-guide`, property: "position", keyframes: [{ time: 0, value: [...C] }] },
374
- { id: "lbw-rotation", target: `${s}/lbw-guide`, property: "quaternion", interpolation: "slerp", keyframes: [{ time: 0, value: Ie(o) }] },
375
- { id: "lbw-length", target: `${s}/lbw-guide`, property: "scaleY", keyframes: [{ time: 0, value: k.distance(C, r) }] },
376
- { id: "lbw-visible", target: `${s}/lbw-guide`, property: "visible", keyframes: [{ time: 0, value: 0 }, { time: w(v) - 1e-3, value: 0 }, { time: w(v), value: 1 }] }
377
- );
378
- }
379
- return { action: e, duration: a, events: re, result: Z, timeline: { id: `${s}-${e}`, formatVersion: 2, name: ce[e].name, config: { duration: a, markers: re.map((r) => ({ id: r.id, time: r.time, label: r.label })) }, captions: { en: Object.fromEntries(re.map((r) => [r.id, r.caption])) }, tracks: Q } };
380
- }
381
- function st(t = {}) {
382
- const n = et(t);
383
- return { ...n, ...nt(n, t) };
384
- }
385
- function at(t, n) {
386
- if (!Number.isFinite(n)) throw new Error("cricketEventAt: time must be finite");
387
- let e;
388
- for (const a of t) {
389
- if (a.time > n) break;
390
- e = a;
391
- }
392
- return e;
393
- }
1
+ import { C, a as s, b as c, c as e, d as r, e as t, f as I, g as E, h as T, i as l, j as k, k as _, l as R, m as A, n as S, o as n, p as K, q as P, r as F, s as O, t as o, u as N, v as g, w as m, x as y, y as L, z as d } from "./cricket-play-DQqoiwTG.js";
394
2
  export {
395
- ce as CRICKET_ACTIONS,
396
- ut as CRICKET_CAMERA_ANGLES,
397
- _e as CRICKET_CASTS,
398
- xe as CRICKET_FIELDING_POSITIONS,
399
- ge as CRICKET_FORMATS,
400
- Me as CRICKET_MARKING_PROFILES,
401
- N as CRICKET_PITCH,
402
- ht as CRICKET_VIEWS,
403
- De as ballFlightPoint,
404
- dt as ballFlightTracks,
405
- nt as cricketAction,
406
- pt as cricketCameraTracks,
407
- st as cricketClip,
408
- at as cricketEventAt,
409
- et as cricketField,
410
- ft as cricketFieldingAreaContains,
411
- gt as cricketFieldingOverlay,
412
- bt as cricketFieldingPositions,
413
- Qe as cricketPlayer
3
+ C as CRICKET_ACTIONS,
4
+ s as CRICKET_CAMERA_ANGLES,
5
+ c as CRICKET_CASTS,
6
+ e as CRICKET_DECISION_VIEWS,
7
+ r as CRICKET_FIELDING_POSITIONS,
8
+ t as CRICKET_FORMATS,
9
+ I as CRICKET_MARKING_PROFILES,
10
+ E as CRICKET_PITCH,
11
+ T as CRICKET_PLAY_COMPONENTS,
12
+ l as CRICKET_PLAY_EXAMPLES,
13
+ k as CRICKET_VIEWS,
14
+ _ as ballFlightPoint,
15
+ R as ballFlightTracks,
16
+ A as cricketAction,
17
+ S as cricketCameraFraming,
18
+ n as cricketCameraReview,
19
+ K as cricketCameraTracks,
20
+ P as cricketClip,
21
+ F as cricketDecisionOverlay,
22
+ O as cricketEventAt,
23
+ o as cricketField,
24
+ N as cricketFieldingAreaContains,
25
+ g as cricketFieldingOverlay,
26
+ m as cricketFieldingPositions,
27
+ y as cricketPlay,
28
+ L as cricketPlayClip,
29
+ d as cricketPlayer
414
30
  };