@algorisys/tinyfly 0.112.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.
- package/README.md +5 -5
- package/docs/cricket.md +59 -1
- 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 +9 -0
- package/docs/maps.md +2 -2
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +1043 -1041
- package/lib/addons/cricket-play-DQqoiwTG.js +4936 -0
- package/lib/addons/scene-3d.js +114 -112
- package/lib/addons/sports.js +23 -19
- package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
- package/lib/browser/tinyfly.iife.js +14 -14
- package/lib/browser/tinyfly.js +5863 -5753
- package/lib/browser/tinyfly.umd.js +14 -14
- package/lib/types/characters/capabilities.d.ts +2 -0
- package/lib/types/scene-3d/resolve-scene.d.ts +1 -1
- package/lib/types/sports/cricket/cricket-camera-review.d.ts +34 -0
- package/lib/types/sports/cricket/cricket-camera.d.ts +22 -4
- package/lib/types/sports/cricket/index.d.ts +2 -1
- package/llms-full.txt +79 -10
- package/llms.txt +30 -30
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +9 -0
- package/lib/addons/cricket-play-Zm5cghdV.js +0 -4828
package/lib/addons/scene-3d.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { M as _t, b as Bt, c as Vt, a as Zt, e as Gt, g as Jt, l as Kt, m as Ut, p as Qt, d as qt, f as jt, r as tn, s as nn, h as on, t as en, i as sn, v as rn } from "./load-scene-oWNsYYC1.js";
|
|
2
|
-
import { mat4 as C, ribbon as at, ribbonHeadCap as ct, vec3 as A, quat as
|
|
2
|
+
import { mat4 as C, ribbon as at, ribbonHeadCap as ct, vec3 as A, quat as R, trailSamples as lt } from "@algorisys/tinyfly";
|
|
3
3
|
import { l as dt, r as ht, p as Z } from "./shots-DR_ViiAC.js";
|
|
4
4
|
import { c as cn, a as ln, b as dn, d as hn, e as gn, f as fn, o as un, s as pn, g as yn, h as mn, i as kn, t as wn, w as Mn } from "./shots-DR_ViiAC.js";
|
|
5
5
|
import { p as F, f as gt, s as U, i as Q } from "./shading-0lPgnXmD.js";
|
|
6
6
|
import { l as vn } from "./shading-0lPgnXmD.js";
|
|
7
7
|
function ft(t, n, o, i) {
|
|
8
|
-
const { camera: r } = i, l = r.near, s = t.map((g) => C.transformPoint(r.view, g)), c = r.projection[5] * i.height / 2, a = (g, d) => o.width * (1 - o.taper * g) * c / (r.orthographic ? 1 : Math.max(d, l)),
|
|
8
|
+
const { camera: r } = i, l = r.near, s = t.map((g) => C.transformPoint(r.view, g)), c = r.projection[5] * i.height / 2, a = (g, d) => o.width * (1 - o.taper * g) * c / (r.orthographic ? 1 : Math.max(d, l)), u = F(o.color), y = [];
|
|
9
9
|
let m = [];
|
|
10
10
|
const M = (g) => -g[2] >= l;
|
|
11
11
|
for (let g = 0; g < s.length; g++) {
|
|
12
12
|
const d = s[g];
|
|
13
|
-
M(d) ? (m.length === 0 && g > 0 && !M(s[g - 1]) && m.push(G(s[g - 1], d, n[g - 1], n[g], l)), m.push({ view: d, age: n[g] })) : m.length > 0 && (m.push(G(s[g - 1], d, n[g - 1], n[g], l)),
|
|
13
|
+
M(d) ? (m.length === 0 && g > 0 && !M(s[g - 1]) && m.push(G(s[g - 1], d, n[g - 1], n[g], l)), m.push({ view: d, age: n[g] })) : m.length > 0 && (m.push(G(s[g - 1], d, n[g - 1], n[g], l)), y.push(m), m = []);
|
|
14
14
|
}
|
|
15
|
-
m.length > 0 &&
|
|
15
|
+
m.length > 0 && y.push(m);
|
|
16
16
|
const I = [];
|
|
17
|
-
for (const g of
|
|
17
|
+
for (const g of y) {
|
|
18
18
|
if (g.length < 2) continue;
|
|
19
19
|
const d = g.map((h) => -h.view[2]), b = g.map((h) => i.toScreen(h.view)).map((h, k) => ({ x: h.x, y: h.y, width: a(g[k].age, d[k]) })), e = at(b), f = g[g.length - 1].age === 0 ? ct(b) : null;
|
|
20
20
|
for (let h = 0; h + 1 < g.length; h++) {
|
|
@@ -22,19 +22,19 @@ function ft(t, n, o, i) {
|
|
|
22
22
|
if (k > r.far) continue;
|
|
23
23
|
let v = o.opacity * (1 - o.fade * ((g[h].age + g[h + 1].age) / 2));
|
|
24
24
|
const x = A.lerp(g[h].view, g[h + 1].view, 0.5), P = gt(i.fog, A.length(x));
|
|
25
|
-
let
|
|
25
|
+
let $ = u;
|
|
26
26
|
if (i.fog && P > 0)
|
|
27
27
|
if (o.additive) v *= 1 - P;
|
|
28
28
|
else {
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const p = F(i.fog.color);
|
|
30
|
+
$ = [u[0] + (p[0] - u[0]) * P, u[1] + (p[1] - u[1]) * P, u[2] + (p[2] - u[2]) * P];
|
|
31
31
|
}
|
|
32
32
|
if (v <= 0) continue;
|
|
33
|
-
const D = `rgb(${
|
|
33
|
+
const D = `rgb(${$.map((p) => Math.round(Math.min(1, Math.max(0, p)) * 255)).join(", ")})`, S = [e.left[h], e.left[h + 1], e.right[h + 1], e.right[h]], E = h + 2 === g.length ? f : null;
|
|
34
34
|
I.push({
|
|
35
35
|
depth: k,
|
|
36
|
-
draw(
|
|
37
|
-
o.additive && (
|
|
36
|
+
draw(p) {
|
|
37
|
+
o.additive && (p.globalCompositeOperation = "lighter"), p.globalAlpha = Math.min(1, v), p.fillStyle = D, p.beginPath(), p.moveTo(S[0].x, S[0].y), p.lineTo(S[1].x, S[1].y), E && p.arc(E.x, E.y, E.radius, E.start, E.start - Math.PI, !0), p.lineTo(S[2].x, S[2].y), p.lineTo(S[3].x, S[3].y), p.closePath(), p.fill(), !o.additive && v >= 1 && (p.strokeStyle = D, p.lineWidth = 0.75, p.stroke());
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -45,39 +45,41 @@ function G(t, n, o, i, r) {
|
|
|
45
45
|
const l = (-r - t[2]) / (n[2] - t[2]);
|
|
46
46
|
return { view: A.lerp(t, n, l), age: o + (i - o) * l };
|
|
47
47
|
}
|
|
48
|
-
const ut = Math.cos(30 * Math.PI / 180), q = /* @__PURE__ */ new Map(),
|
|
48
|
+
const ut = Math.cos(30 * Math.PI / 180), q = /* @__PURE__ */ new Map(), T = (t) => typeof t == "number" ? t : void 0, W = (t, n) => Array.isArray(t) && t.length === n ? t : void 0;
|
|
49
49
|
function j(t, n) {
|
|
50
50
|
const o = t.position ?? [0, 0, 0], i = W(n.get("position"), 3) ?? [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
T(n.get("x")) ?? o[0],
|
|
52
|
+
T(n.get("y")) ?? o[1],
|
|
53
|
+
T(n.get("z")) ?? o[2]
|
|
54
54
|
];
|
|
55
55
|
let r;
|
|
56
|
-
const l = W(n.get("quaternion"), 4), s = ["rotateX", "rotateY", "rotateZ"].map((
|
|
57
|
-
if (l) r =
|
|
58
|
-
else if (s.some((
|
|
59
|
-
const
|
|
60
|
-
r =
|
|
61
|
-
} else t.quaternion ? r =
|
|
62
|
-
const c = typeof t.scale == "number" ? [t.scale, t.scale, t.scale] : t.scale ?? [1, 1, 1], a =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
const l = W(n.get("quaternion"), 4), s = ["rotateX", "rotateY", "rotateZ"].map((y) => T(n.get(y)));
|
|
57
|
+
if (l) r = R.normalize(l);
|
|
58
|
+
else if (s.some((y) => y !== void 0)) {
|
|
59
|
+
const y = t.rotation ?? [0, 0, 0];
|
|
60
|
+
r = R.fromEuler(s[0] ?? y[0], s[1] ?? y[1], s[2] ?? y[2]);
|
|
61
|
+
} else t.quaternion ? r = R.normalize(t.quaternion) : r = t.rotation ? R.fromEuler(...t.rotation) : R.identity();
|
|
62
|
+
const c = typeof t.scale == "number" ? [t.scale, t.scale, t.scale] : t.scale ?? [1, 1, 1], a = T(n.get("scale")), u = [
|
|
63
|
+
T(n.get("scaleX")) ?? a ?? c[0],
|
|
64
|
+
T(n.get("scaleY")) ?? a ?? c[1],
|
|
65
|
+
T(n.get("scaleZ")) ?? a ?? c[2]
|
|
66
66
|
];
|
|
67
|
-
return C.compose(i, r,
|
|
67
|
+
return C.compose(i, r, u);
|
|
68
68
|
}
|
|
69
69
|
const B = (t) => [t[12], t[13], t[14]];
|
|
70
70
|
function pt(t, n, o, i) {
|
|
71
|
-
const r = B(n), l = W(o.get("lookAt"), 3) ?? t.lookAt, s =
|
|
71
|
+
const r = B(n), l = W(o.get("lookAt"), 3) ?? t.lookAt, s = T(o.get("roll")) ?? t.roll ?? 0, c = l ? dt(r, l, { up: t.up, roll: s }) : ht(C.invert(n) ?? C.identity(), s), a = T(o.get("far")) ?? t.far;
|
|
72
|
+
if (!Number.isFinite(a) || a <= t.near) throw new Error("resolveScene3D: camera far must be finite and greater than near");
|
|
73
|
+
const u = t.projection === "perspective" ? Z({ ...t, far: a, fov: T(o.get("fov")) ?? t.fov }, i) : Z({ ...t, far: a, height: T(o.get("height")) ?? t.height }, i);
|
|
72
74
|
return {
|
|
73
75
|
id: t.id,
|
|
74
76
|
view: c,
|
|
75
|
-
projection:
|
|
77
|
+
projection: u,
|
|
76
78
|
position: r,
|
|
77
79
|
forward: A.normalize([-c[2], -c[6], -c[10]]),
|
|
78
80
|
orthographic: t.projection === "orthographic",
|
|
79
81
|
near: t.near,
|
|
80
|
-
far:
|
|
82
|
+
far: a
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
85
|
function J(t) {
|
|
@@ -100,15 +102,15 @@ function mt(t, n) {
|
|
|
100
102
|
function kt(t, n, o, i = 16) {
|
|
101
103
|
const r = [t[0], t[1], t[2]], l = [0, 1, 0], s = [];
|
|
102
104
|
for (let a = 0; a < i; a++) {
|
|
103
|
-
const
|
|
104
|
-
r.push(t[0] + Math.cos(
|
|
105
|
+
const u = a / i * Math.PI * 2;
|
|
106
|
+
r.push(t[0] + Math.cos(u) * n, t[1], t[2] + Math.sin(u) * o), l.push(0, 1, 0);
|
|
105
107
|
}
|
|
106
108
|
for (let a = 0; a < i; a++) s.push(0, 1 + (a + 1) % i, 1 + a);
|
|
107
109
|
const c = Array.from({ length: i }, () => []);
|
|
108
110
|
return { positions: r, normals: l, indices: s, faceEdges: c };
|
|
109
111
|
}
|
|
110
112
|
function wt(t, n) {
|
|
111
|
-
const o =
|
|
113
|
+
const o = T(n.get("outlineWidth")) ?? t.outline?.width, i = n.get("outlineColor"), r = (typeof i == "string" ? i : void 0) ?? t.outline?.color ?? "#000000";
|
|
112
114
|
return o !== void 0 && o > 0 ? { width: o, color: r } : void 0;
|
|
113
115
|
}
|
|
114
116
|
function Mt(t, n) {
|
|
@@ -119,10 +121,10 @@ function tt(t, n = /* @__PURE__ */ new Map(), o) {
|
|
|
119
121
|
for (const e of i.objects) {
|
|
120
122
|
const f = r(e.id), h = j(e, f), k = e.parent ? s.get(e.parent) : void 0;
|
|
121
123
|
s.set(e.id, k ? C.multiply(k, h) : h);
|
|
122
|
-
const v =
|
|
124
|
+
const v = T(f.get("visible")) !== void 0 ? T(f.get("visible")) > 0.5 : e.visible !== !1;
|
|
123
125
|
c.set(e.id, v && (e.parent ? c.get(e.parent) !== !1 : !0));
|
|
124
126
|
}
|
|
125
|
-
const a = n.get(i.id)?.get("activeCamera"),
|
|
127
|
+
const a = n.get(i.id)?.get("activeCamera"), u = typeof a == "string" && i.objects.some((e) => e.id === a && e.kind === "camera") ? a : i.camera, y = i.objects.find((e) => e.id === u), m = pt(y, s.get(u), r(u), o.width / o.height), M = (e) => {
|
|
126
128
|
const f = C.transformPoint(m.projection, e);
|
|
127
129
|
return { x: (f[0] + 1) / 2 * o.width, y: (1 - f[1]) / 2 * o.height };
|
|
128
130
|
}, I = [];
|
|
@@ -133,7 +135,7 @@ function tt(t, n = /* @__PURE__ */ new Map(), o) {
|
|
|
133
135
|
id: e.id,
|
|
134
136
|
light: e.light,
|
|
135
137
|
color: typeof v == "string" ? v : e.color,
|
|
136
|
-
intensity:
|
|
138
|
+
intensity: T(f.get("intensity")) ?? e.intensity,
|
|
137
139
|
position: h,
|
|
138
140
|
direction: A.normalize(A.subtract(k, h)),
|
|
139
141
|
range: e.range,
|
|
@@ -145,14 +147,14 @@ function tt(t, n = /* @__PURE__ */ new Map(), o) {
|
|
|
145
147
|
if (e.kind !== "mesh" || !c.get(e.id)) return;
|
|
146
148
|
const h = t.meshes.get(e.id), k = i.materials?.[e.material];
|
|
147
149
|
if (!h || !k) return;
|
|
148
|
-
const v = r(e.id), x = s.get(e.id), P = J(x),
|
|
150
|
+
const v = r(e.id), x = s.get(e.id), P = J(x), $ = v.get("color"), D = (T(v.get("opacity")) ?? 1) * (k.opacity ?? 1);
|
|
149
151
|
if (D <= 0) return;
|
|
150
|
-
const S = wt(k, v),
|
|
151
|
-
d.push({ objectId: e.id, objectIndex: f, mesh: h, world: x, material:
|
|
152
|
+
const S = wt(k, v), E = S === k.outline || S && k.outline && S.width === k.outline.width && S.color === k.outline.color ? k : { ...k, outline: S };
|
|
153
|
+
d.push({ objectId: e.id, objectIndex: f, mesh: h, world: x, material: E, color: typeof $ == "string" ? $ : void 0, opacity: D }), g.push(...L(h, x, P, m, M, E, {
|
|
152
154
|
objectId: e.id,
|
|
153
155
|
objectIndex: f,
|
|
154
156
|
layer: e.layer ?? 0,
|
|
155
|
-
color: typeof
|
|
157
|
+
color: typeof $ == "string" ? $ : void 0,
|
|
156
158
|
opacity: D,
|
|
157
159
|
ink: S,
|
|
158
160
|
nearFade: l
|
|
@@ -162,18 +164,18 @@ function tt(t, n = /* @__PURE__ */ new Map(), o) {
|
|
|
162
164
|
const h = t.meshes.get(e.id);
|
|
163
165
|
if (!h) return;
|
|
164
166
|
const k = r(e.id);
|
|
165
|
-
if ((
|
|
167
|
+
if ((T(k.get("opacity")) ?? 1) <= 0) return;
|
|
166
168
|
const v = s.get(e.id), x = e.shadow === !0 ? {} : e.shadow, P = x.ground ?? i.ground ?? 0;
|
|
167
|
-
let
|
|
168
|
-
for (let
|
|
169
|
-
const
|
|
170
|
-
|
|
169
|
+
let $ = 1 / 0, D = -1 / 0, S = 1 / 0, E = 1 / 0, p = -1 / 0;
|
|
170
|
+
for (let N = 0; N < h.positions.length; N += 3) {
|
|
171
|
+
const O = C.transformPoint(v, [h.positions[N], h.positions[N + 1], h.positions[N + 2]]);
|
|
172
|
+
$ = Math.min($, O[0]), D = Math.max(D, O[0]), S = Math.min(S, O[1]), E = Math.min(E, O[2]), p = Math.max(p, O[2]);
|
|
171
173
|
}
|
|
172
|
-
const z = Math.max(D -
|
|
174
|
+
const z = Math.max(D - $, p - E);
|
|
173
175
|
if (!(z > 0)) return;
|
|
174
|
-
const
|
|
176
|
+
const X = Math.max(0, S - P), Y = Math.min(1, X / (2 * z)), H = (x.opacity ?? 0.22) * (1 - Y * 0.8);
|
|
175
177
|
if (H <= 0.01) return;
|
|
176
|
-
const V = 1.1 +
|
|
178
|
+
const V = 1.1 + Y * 0.4, st = kt([($ + D) / 2, P + 2e-3, (E + p) / 2], (D - $) / 2 * V, (p - E) / 2 * V), rt = { color: "#000000", shading: "unlit", opacity: H };
|
|
177
179
|
g.push(...L(st, C.identity(), C.identity(), m, M, rt, {
|
|
178
180
|
objectId: `${e.id}:shadow`,
|
|
179
181
|
objectIndex: f - 0.5,
|
|
@@ -239,10 +241,10 @@ function bt(t, n) {
|
|
|
239
241
|
const o = n.get("color"), i = t.kind === "trail";
|
|
240
242
|
return {
|
|
241
243
|
color: typeof o == "string" ? o : t.color,
|
|
242
|
-
width:
|
|
244
|
+
width: T(n.get("width")) ?? t.width ?? 0.05,
|
|
243
245
|
taper: t.taper ?? (i ? 1 : 0),
|
|
244
246
|
fade: t.fade ?? (i ? 1 : 0),
|
|
245
|
-
opacity: (
|
|
247
|
+
opacity: (T(n.get("opacity")) ?? 1) * (t.opacity ?? 1),
|
|
246
248
|
additive: t.blend === "add"
|
|
247
249
|
};
|
|
248
250
|
}
|
|
@@ -252,7 +254,7 @@ function vt(t, n) {
|
|
|
252
254
|
}
|
|
253
255
|
function xt(t, n, o, i) {
|
|
254
256
|
if (!i.valuesAt) return null;
|
|
255
|
-
const r = i.time ?? 0, l =
|
|
257
|
+
const r = i.time ?? 0, l = T(o.get(`${n.id}/${t.id}`)?.get("length")) ?? t.length, s = lt(
|
|
256
258
|
(c) => B(nt(n, t.follow, c === r ? o : i.valuesAt(c))),
|
|
257
259
|
r,
|
|
258
260
|
{ length: l, samples: t.samples ?? 32, period: t.period ?? i.period }
|
|
@@ -266,53 +268,53 @@ function nt(t, n, o) {
|
|
|
266
268
|
return i.parent ? C.multiply(nt(t, i.parent, o), r) : r;
|
|
267
269
|
}
|
|
268
270
|
function L(t, n, o, i, r, l, s) {
|
|
269
|
-
const c = t.positions.length / 3, a = [],
|
|
271
|
+
const c = t.positions.length / 3, a = [], u = [];
|
|
270
272
|
for (let d = 0; d < c; d++) {
|
|
271
273
|
const w = C.transformPoint(n, [t.positions[d * 3], t.positions[d * 3 + 1], t.positions[d * 3 + 2]]);
|
|
272
|
-
a.push(w),
|
|
274
|
+
a.push(w), u.push(C.transformPoint(i.view, w));
|
|
273
275
|
}
|
|
274
|
-
const
|
|
275
|
-
for (let d = 0; d <
|
|
276
|
+
const y = t.indices.length / 3, m = [], M = [];
|
|
277
|
+
for (let d = 0; d < y; d++) {
|
|
276
278
|
const [w, b, e] = [0, 1, 2].map((k) => a[t.indices[d * 3 + k]]), f = A.normalize(A.cross(A.subtract(b, w), A.subtract(e, w)));
|
|
277
279
|
m.push(f);
|
|
278
280
|
const h = i.orthographic ? A.scale(i.forward, -1) : A.subtract(i.position, w);
|
|
279
281
|
M.push(A.dot(f, h) > 0);
|
|
280
282
|
}
|
|
281
|
-
const I = (d) => -
|
|
282
|
-
for (let d = 0; d <
|
|
283
|
+
const I = (d) => -u[d][2] >= i.near, g = [];
|
|
284
|
+
for (let d = 0; d < y; d++) {
|
|
283
285
|
const w = M[d];
|
|
284
286
|
if (!w && !l.doubleSided) continue;
|
|
285
|
-
const b = [t.indices[d * 3], t.indices[d * 3 + 1], t.indices[d * 3 + 2]], e = b.map((
|
|
286
|
-
if (e.every((
|
|
287
|
+
const b = [t.indices[d * 3], t.indices[d * 3 + 1], t.indices[d * 3 + 2]], e = b.map((p) => u[p]);
|
|
288
|
+
if (e.every((p) => -p[2] > i.far)) continue;
|
|
287
289
|
const f = mt(e, i.near);
|
|
288
290
|
if (f.length < 3) continue;
|
|
289
|
-
const h = w ? 1 : -1, k = A.scale(m[d], h), v = b.map((
|
|
291
|
+
const h = w ? 1 : -1, k = A.scale(m[d], h), v = b.map((p) => A.scale(yt(o, t.normals[p * 3], t.normals[p * 3 + 1], t.normals[p * 3 + 2]), h)), x = A.scale(A.add(A.add(a[b[0]], a[b[1]]), a[b[2]]), 1 / 3), P = -(e[0][2] + e[1][2] + e[2][2]) / 3, $ = [], D = [];
|
|
290
292
|
if (s.ink && w)
|
|
291
|
-
for (const
|
|
292
|
-
const z =
|
|
293
|
-
(
|
|
293
|
+
for (const p of t.faceEdges[d]) {
|
|
294
|
+
const z = p.across, X = z === -1 || !M[z], Y = l.creases !== !1 && !X && d < z && A.dot(m[d], m[z]) < ut;
|
|
295
|
+
(X || Y) && I(p.a) && I(p.b) && ($.push([r(u[p.a]), r(u[p.b])]), D.push([-u[p.a][2], -u[p.b][2]]));
|
|
294
296
|
}
|
|
295
297
|
const S = s.opacity * Mt(s.nearFade, P);
|
|
296
298
|
if (S <= 0) continue;
|
|
297
|
-
const
|
|
298
|
-
for (let
|
|
299
|
+
const E = f.map(r);
|
|
300
|
+
for (let p = 1; p + 1 < E.length; p++)
|
|
299
301
|
g.push({
|
|
300
302
|
objectId: s.objectId,
|
|
301
303
|
objectIndex: s.objectIndex,
|
|
302
304
|
layer: s.layer,
|
|
303
305
|
face: d,
|
|
304
|
-
part:
|
|
305
|
-
screen: [
|
|
306
|
+
part: p - 1,
|
|
307
|
+
screen: [E[0], E[p], E[p + 1]],
|
|
306
308
|
depth: P,
|
|
307
|
-
depths: [-f[0][2], -f[
|
|
309
|
+
depths: [-f[0][2], -f[p][2], -f[p + 1][2]],
|
|
308
310
|
centroid: x,
|
|
309
311
|
normal: k,
|
|
310
312
|
vertexNormals: v,
|
|
311
313
|
material: l,
|
|
312
314
|
color: s.color ?? t.faceColors?.[d],
|
|
313
315
|
opacity: S,
|
|
314
|
-
outline:
|
|
315
|
-
outlineDepths:
|
|
316
|
+
outline: p === 1 ? $ : [],
|
|
317
|
+
outlineDepths: p === 1 ? D : [],
|
|
316
318
|
ink: s.ink
|
|
317
319
|
});
|
|
318
320
|
}
|
|
@@ -355,8 +357,8 @@ function ot(t, n) {
|
|
|
355
357
|
};
|
|
356
358
|
for (const s of n.triangles) {
|
|
357
359
|
l(s), i(s.layer, s.depth);
|
|
358
|
-
const { color: c, alpha: a } = U(s, n.lights, n.camera, n.fog), [
|
|
359
|
-
t.globalAlpha = a, t.beginPath(), t.moveTo(
|
|
360
|
+
const { color: c, alpha: a } = U(s, n.lights, n.camera, n.fog), [u, y, m] = s.screen;
|
|
361
|
+
t.globalAlpha = a, t.beginPath(), t.moveTo(u.x, u.y), t.lineTo(y.x, y.y), t.lineTo(m.x, m.y), t.closePath(), t.fillStyle = c, t.fill(), a >= 1 && (t.strokeStyle = c, t.lineWidth = 0.75, t.stroke()), s.ink && s.outline.length > 0 && r.push({ objectId: s.objectId, layer: s.layer, depth: s.depth, triangle: s });
|
|
360
362
|
}
|
|
361
363
|
l(), i(1 / 0, -1 / 0), t.restore();
|
|
362
364
|
}
|
|
@@ -372,9 +374,9 @@ function St(t, n = {}) {
|
|
|
372
374
|
const o = t.width, i = t.height, r = new Uint8ClampedArray(o * i * 4), l = new Float32Array(o * i).fill(1 / 0);
|
|
373
375
|
if (n.under && n.under.length === r.length) r.set(n.under);
|
|
374
376
|
else if (t.background && t.background !== "transparent") {
|
|
375
|
-
const
|
|
377
|
+
const y = F(typeof t.background == "string" ? t.background : t.background.top), m = F(typeof t.background == "string" ? t.background : t.background.bottom);
|
|
376
378
|
for (let M = 0; M < i; M++) {
|
|
377
|
-
const I = i > 1 ? M / (i - 1) : 0, g = Math.round((
|
|
379
|
+
const I = i > 1 ? M / (i - 1) : 0, g = Math.round((y[0] + (m[0] - y[0]) * I) * 255), d = Math.round((y[1] + (m[1] - y[1]) * I) * 255), w = Math.round((y[2] + (m[2] - y[2]) * I) * 255);
|
|
378
380
|
for (let b = 0; b < o; b++) {
|
|
379
381
|
const e = M * o + b;
|
|
380
382
|
r[e * 4] = g, r[e * 4 + 1] = d, r[e * 4 + 2] = w, r[e * 4 + 3] = 255;
|
|
@@ -383,21 +385,21 @@ function St(t, n = {}) {
|
|
|
383
385
|
}
|
|
384
386
|
const s = { width: o, height: i, data: r, depth: l };
|
|
385
387
|
let c = -1 / 0;
|
|
386
|
-
const a = [],
|
|
387
|
-
for (const
|
|
388
|
+
const a = [], u = () => {
|
|
389
|
+
for (const y of a) K(s, t, y, !1);
|
|
388
390
|
a.length = 0;
|
|
389
391
|
};
|
|
390
|
-
for (const
|
|
391
|
-
|
|
392
|
-
return
|
|
392
|
+
for (const y of t.triangles)
|
|
393
|
+
y.layer !== c && (u(), c = y.layer, l.fill(1 / 0)), y.opacity < 1 ? a.push(y) : K(s, t, y, !0);
|
|
394
|
+
return u(), s;
|
|
393
395
|
}
|
|
394
396
|
function K(t, n, o, i) {
|
|
395
397
|
const { color: r, alpha: l } = U(o, n.lights, n.camera, n.fog), s = F(r).map((c) => Math.round(c * 255));
|
|
396
398
|
if (Tt(t, o.screen, o.depths, s, l, i), o.ink && o.outline.length > 0) {
|
|
397
399
|
const c = F(Q(o.ink.color, n.fog, A.distance(o.centroid, n.camera.position))).map((a) => Math.round(a * 255));
|
|
398
|
-
o.outline.forEach((a,
|
|
399
|
-
const
|
|
400
|
-
$t(t, a[0], a[1],
|
|
400
|
+
o.outline.forEach((a, u) => {
|
|
401
|
+
const y = o.outlineDepths[u] ?? [o.depth, o.depth];
|
|
402
|
+
$t(t, a[0], a[1], y, o.ink.width, c, l);
|
|
401
403
|
});
|
|
402
404
|
}
|
|
403
405
|
}
|
|
@@ -415,26 +417,26 @@ function it(t, n, o, i) {
|
|
|
415
417
|
}
|
|
416
418
|
const Pt = 4e-3;
|
|
417
419
|
function Tt(t, n, o, i, r, l) {
|
|
418
|
-
const [s, c, a] = n,
|
|
419
|
-
if (
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
422
|
-
const g = [1 / Math.max(1e-9, o[0]), 1 / Math.max(1e-9, o[1]), 1 / Math.max(1e-9, o[2])], d =
|
|
420
|
+
const [s, c, a] = n, u = (c.x - s.x) * (a.y - s.y) - (c.y - s.y) * (a.x - s.x);
|
|
421
|
+
if (u === 0) return;
|
|
422
|
+
const y = Math.max(0, Math.floor(Math.min(s.x, c.x, a.x))), m = Math.min(t.width - 1, Math.ceil(Math.max(s.x, c.x, a.x))), M = Math.max(0, Math.floor(Math.min(s.y, c.y, a.y))), I = Math.min(t.height - 1, Math.ceil(Math.max(s.y, c.y, a.y)));
|
|
423
|
+
if (y > m || M > I) return;
|
|
424
|
+
const g = [1 / Math.max(1e-9, o[0]), 1 / Math.max(1e-9, o[1]), 1 / Math.max(1e-9, o[2])], d = u > 0 ? 1 : -1;
|
|
423
425
|
for (let w = M; w <= I; w++) {
|
|
424
426
|
const b = w + 0.5;
|
|
425
|
-
for (let e =
|
|
427
|
+
for (let e = y; e <= m; e++) {
|
|
426
428
|
const f = e + 0.5, h = ((c.x - f) * (a.y - b) - (c.y - b) * (a.x - f)) * d, k = ((a.x - f) * (s.y - b) - (a.y - b) * (s.x - f)) * d, v = ((s.x - f) * (c.y - b) - (s.y - b) * (c.x - f)) * d;
|
|
427
429
|
if (h < 0 || k < 0 || v < 0) continue;
|
|
428
|
-
const P = (h + k + v) / (h * g[0] + k * g[1] + v * g[2]),
|
|
429
|
-
P >= t.depth[
|
|
430
|
+
const P = (h + k + v) / (h * g[0] + k * g[1] + v * g[2]), $ = w * t.width + e;
|
|
431
|
+
P >= t.depth[$] || (it(t.data, $, i, r), l && (t.depth[$] = P));
|
|
430
432
|
}
|
|
431
433
|
}
|
|
432
434
|
}
|
|
433
435
|
function $t(t, n, o, i, r, l, s) {
|
|
434
|
-
const c = Math.max(0.5, r / 2), a = Math.max(0, Math.floor(Math.min(n.x, o.x) - c)),
|
|
435
|
-
for (let w =
|
|
436
|
+
const c = Math.max(0.5, r / 2), a = Math.max(0, Math.floor(Math.min(n.x, o.x) - c)), u = Math.min(t.width - 1, Math.ceil(Math.max(n.x, o.x) + c)), y = Math.max(0, Math.floor(Math.min(n.y, o.y) - c)), m = Math.min(t.height - 1, Math.ceil(Math.max(n.y, o.y) + c)), M = o.x - n.x, I = o.y - n.y, g = M * M + I * I, d = c * c;
|
|
437
|
+
for (let w = y; w <= m; w++) {
|
|
436
438
|
const b = w + 0.5;
|
|
437
|
-
for (let e = a; e <=
|
|
439
|
+
for (let e = a; e <= u; e++) {
|
|
438
440
|
const f = e + 0.5, h = g > 0 ? Math.min(1, Math.max(0, ((f - n.x) * M + (b - n.y) * I) / g)) : 0, k = n.x + M * h, v = n.y + I * h;
|
|
439
441
|
if ((f - k) ** 2 + (b - v) ** 2 > d) continue;
|
|
440
442
|
const x = (i[0] + (i[1] - i[0]) * h) * (1 - Pt), P = w * t.width + e;
|
|
@@ -458,7 +460,7 @@ class Ft {
|
|
|
458
460
|
et(this.ctx, n);
|
|
459
461
|
}
|
|
460
462
|
}
|
|
461
|
-
class
|
|
463
|
+
class Nt {
|
|
462
464
|
renderer;
|
|
463
465
|
width;
|
|
464
466
|
height;
|
|
@@ -488,21 +490,21 @@ class Ot {
|
|
|
488
490
|
this.renderer.render(tt(n, this.values, { width: this.width, height: this.height, time: this.time, valuesAt: this.valuesAt }));
|
|
489
491
|
}
|
|
490
492
|
}
|
|
491
|
-
function
|
|
493
|
+
function Ot(t, n, o, i) {
|
|
492
494
|
const r = i.stateAt, l = i.valuesAt ?? (r && ((c) => r(c).values)), s = tt(n, o ?? /* @__PURE__ */ new Map(), { width: i.width, height: i.height, time: i.time, period: i.period, valuesAt: l });
|
|
493
495
|
i.depthBuffer ? et(t, s) : ot(t, s);
|
|
494
496
|
}
|
|
495
|
-
function
|
|
496
|
-
const n = t.id ?? "penrose", o = t.length ?? 4, i = t.thickness ?? 0.8, r = t.material ?? "penrose", [l, s, c] = t.position ?? [0, 0, 0], a = i / 2,
|
|
497
|
+
function Rt(t = {}) {
|
|
498
|
+
const n = t.id ?? "penrose", o = t.length ?? 4, i = t.thickness ?? 0.8, r = t.material ?? "penrose", [l, s, c] = t.position ?? [0, 0, 0], a = i / 2, u = (g, d, w) => ({
|
|
497
499
|
id: `${n}-${g}`,
|
|
498
500
|
kind: "mesh",
|
|
499
501
|
geometry: { type: "box", size: [w[0] - d[0], w[1] - d[1], w[2] - d[2]] },
|
|
500
502
|
material: r,
|
|
501
503
|
position: [l + (d[0] + w[0]) / 2, s + (d[1] + w[1]) / 2, c + (d[2] + w[2]) / 2]
|
|
502
|
-
}),
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
504
|
+
}), y = [
|
|
505
|
+
u("x", [-a, -a, -a], [o - a, a, a]),
|
|
506
|
+
u("y", [o - a, -a, -a], [o + a, o - a, a]),
|
|
507
|
+
u("z", [o - a, o - a, -a], [o + a, o + a, o])
|
|
506
508
|
], m = [l + 2 * o / 3, s + o / 3, c + o / 3], M = (t.distance ?? 20) / Math.sqrt(3), I = {
|
|
507
509
|
id: `${n}-camera`,
|
|
508
510
|
kind: "camera",
|
|
@@ -513,7 +515,7 @@ function Xt(t = {}) {
|
|
|
513
515
|
position: [m[0] + M, m[1] + M, m[2] + M],
|
|
514
516
|
lookAt: m
|
|
515
517
|
};
|
|
516
|
-
return { objects:
|
|
518
|
+
return { objects: y, camera: I };
|
|
517
519
|
}
|
|
518
520
|
const _ = {
|
|
519
521
|
day: {
|
|
@@ -554,7 +556,7 @@ const _ = {
|
|
|
554
556
|
fog: { color: "#0a0612", near: 8, far: 24 }
|
|
555
557
|
}
|
|
556
558
|
};
|
|
557
|
-
function
|
|
559
|
+
function Xt(t, n = {}) {
|
|
558
560
|
const o = _[t];
|
|
559
561
|
if (!o) throw new Error(`lightingPreset: unknown mood "${t}" (day, dusk, night, stage)`);
|
|
560
562
|
const i = n.prefix ? `${n.prefix}-` : "";
|
|
@@ -564,19 +566,19 @@ function Yt(t, n = {}) {
|
|
|
564
566
|
fog: { ...o.fog }
|
|
565
567
|
};
|
|
566
568
|
}
|
|
567
|
-
function
|
|
569
|
+
function Yt(t, n, o) {
|
|
568
570
|
const i = _[t], r = _[n];
|
|
569
571
|
if (!i || !r) throw new Error(`lightingTracks: unknown mood "${i ? n : t}" (day, dusk, night, stage)`);
|
|
570
572
|
const l = o.prefix ? `${o.prefix}-` : "", s = /* @__PURE__ */ new Set([...i.lights.map((a) => a.id), ...r.lights.map((a) => a.id)]), c = [];
|
|
571
573
|
for (const a of s) {
|
|
572
|
-
const
|
|
574
|
+
const u = i.lights.find((b) => b.id === a), y = r.lights.find((b) => b.id === a), m = `${o.scene}/${l}${a}`, M = (b, e, f) => {
|
|
573
575
|
const h = [{ time: o.start, value: e }, { time: o.end, value: f, easing: o.easing ?? "ease-in-out" }];
|
|
574
576
|
c.push({ id: `${m}-${b}`, target: m, property: b, keyframes: h });
|
|
575
577
|
};
|
|
576
|
-
M("intensity",
|
|
577
|
-
const I =
|
|
578
|
+
M("intensity", u?.intensity ?? 0, y?.intensity ?? 0), M("color", u?.color ?? y.color, y?.color ?? u.color);
|
|
579
|
+
const I = u?.position ?? y?.position, g = y?.position ?? u?.position;
|
|
578
580
|
I && g && M("position", [...I], [...g]);
|
|
579
|
-
const d =
|
|
581
|
+
const d = u?.target ?? y?.target, w = y?.target ?? u?.target;
|
|
580
582
|
d && w && M("target", [...d], [...w]);
|
|
581
583
|
}
|
|
582
584
|
return c;
|
|
@@ -592,7 +594,7 @@ export {
|
|
|
592
594
|
zt as Canvas2DRenderer,
|
|
593
595
|
_ as LIGHTING_PRESETS,
|
|
594
596
|
_t as MeshBuilder,
|
|
595
|
-
|
|
597
|
+
Nt as Scene3DAdapter,
|
|
596
598
|
Ft as SoftwareRenderer,
|
|
597
599
|
Bt as boxMesh,
|
|
598
600
|
cn as cameraFollowTracks,
|
|
@@ -605,21 +607,21 @@ export {
|
|
|
605
607
|
fn as dollyPosition,
|
|
606
608
|
ot as drawResolvedScene,
|
|
607
609
|
et as drawResolvedSceneWithDepth,
|
|
608
|
-
|
|
610
|
+
Ot as drawScene3D,
|
|
609
611
|
Gt as extrudeMesh,
|
|
610
612
|
gt as fogAmount,
|
|
611
613
|
Jt as geometryMesh,
|
|
612
614
|
Wt as ground,
|
|
613
615
|
Q as inkColor,
|
|
614
616
|
vn as lightAt,
|
|
615
|
-
|
|
616
|
-
|
|
617
|
+
Xt as lightingPreset,
|
|
618
|
+
Yt as lightingTracks,
|
|
617
619
|
Kt as loadScene3D,
|
|
618
620
|
dt as lookAtView,
|
|
619
621
|
Ut as meshEdges,
|
|
620
622
|
un as orbitPosition,
|
|
621
623
|
F as parseColor,
|
|
622
|
-
|
|
624
|
+
Rt as penroseTriangle3D,
|
|
623
625
|
Qt as planeMesh,
|
|
624
626
|
qt as pointInPolygon,
|
|
625
627
|
jt as prepareMesh,
|
package/lib/addons/sports.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { C
|
|
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";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
C as CRICKET_ACTIONS,
|
|
4
|
+
s as CRICKET_CAMERA_ANGLES,
|
|
5
5
|
c as CRICKET_CASTS,
|
|
6
|
-
e as
|
|
6
|
+
e as CRICKET_DECISION_VIEWS,
|
|
7
|
+
r as CRICKET_FIELDING_POSITIONS,
|
|
7
8
|
t as CRICKET_FORMATS,
|
|
8
|
-
|
|
9
|
+
I as CRICKET_MARKING_PROFILES,
|
|
9
10
|
E as CRICKET_PITCH,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
T as CRICKET_PLAY_COMPONENTS,
|
|
12
|
+
l as CRICKET_PLAY_EXAMPLES,
|
|
13
|
+
k as CRICKET_VIEWS,
|
|
13
14
|
_ as ballFlightPoint,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
R as ballFlightTracks,
|
|
16
|
+
A as cricketAction,
|
|
17
|
+
S as cricketCameraFraming,
|
|
18
|
+
n as cricketCameraReview,
|
|
19
|
+
K as cricketCameraTracks,
|
|
17
20
|
P as cricketClip,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
26
30
|
};
|