@algorisys/tinyfly 0.107.1 → 0.109.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 +22 -12
- package/docs/character-appearance.md +148 -0
- package/docs/cricket.md +127 -0
- 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 +58 -0
- package/docs/maps.md +2 -2
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +4674 -8156
- package/lib/addons/cricket-camera-BWByoNgz.js +4205 -0
- package/lib/addons/scene-3d.js +436 -540
- package/lib/addons/shots-DR_ViiAC.js +125 -0
- package/lib/addons/sports.js +390 -0
- package/lib/browser/tinyfly.iife.js +14 -14
- package/lib/browser/tinyfly.js +9334 -8322
- package/lib/browser/tinyfly.umd.js +14 -14
- package/lib/types/browser/index.d.ts +1 -0
- package/lib/types/characters/body/organic-body.d.ts +56 -0
- package/lib/types/characters/body/organic-draw.d.ts +5 -0
- package/lib/types/characters/body/organic-geometry.d.ts +25 -0
- package/lib/types/characters/capabilities.d.ts +14 -0
- package/lib/types/characters/character.d.ts +15 -2
- package/lib/types/characters/hands/draw-cartoon-hand.d.ts +4 -0
- package/lib/types/characters/head/face.d.ts +6 -4
- package/lib/types/characters/head/facial-hair.d.ts +2 -0
- package/lib/types/characters/head/glasses.d.ts +2 -0
- package/lib/types/characters/head/head-look.d.ts +4 -2
- package/lib/types/characters/head/head-shape.d.ts +4 -0
- package/lib/types/characters/index.d.ts +5 -0
- package/lib/types/characters/look/pen.d.ts +1 -0
- package/lib/types/characters/look/skin-shading.d.ts +4 -0
- package/lib/types/characters/rig/skeleton.d.ts +2 -0
- package/lib/types/characters/soft-cartoon-cast.d.ts +166 -0
- package/lib/types/characters/wardrobe/basic-outfit.d.ts +5 -1
- package/lib/types/characters/wardrobe/leaf-outfit.d.ts +18 -0
- package/lib/types/characters/wardrobe/outfit-preset.d.ts +6 -0
- package/lib/types/sports/ball-flight.d.ts +22 -0
- package/lib/types/sports/cricket/cricket-action.d.ts +7 -0
- package/lib/types/sports/cricket/cricket-camera.d.ts +13 -0
- package/lib/types/sports/cricket/cricket-field.d.ts +13 -0
- package/lib/types/sports/cricket/cricket-motion.d.ts +36 -0
- package/lib/types/sports/cricket/cricket-types.d.ts +84 -0
- package/lib/types/sports/cricket/index.d.ts +5 -0
- package/lib/types/sports/index.d.ts +3 -0
- package/llms-full.txt +377 -9
- package/llms.txt +30 -29
- package/package.json +5 -1
- package/skills/tinyfly/SKILL.md +49 -0
package/lib/addons/scene-3d.js
CHANGED
|
@@ -1,484 +1,464 @@
|
|
|
1
|
-
import { M as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
function tt(t, n) {
|
|
10
|
-
return n ? P.multiply(P.fromQuat(F.fromAxisAngle([0, 0, 1], -n)), t) : t;
|
|
11
|
-
}
|
|
12
|
-
function L(t, n, o, e) {
|
|
13
|
-
const i = n * Math.PI / 180, a = o * Math.PI / 180;
|
|
14
|
-
return [t[0] + e * Math.cos(a) * Math.sin(i), t[1] + e * Math.sin(a), t[2] + e * Math.cos(a) * Math.cos(i)];
|
|
15
|
-
}
|
|
16
|
-
function Rt(t, n, o) {
|
|
17
|
-
const e = A.subtract(t, n), i = A.length(e);
|
|
18
|
-
if (i === 0) return t;
|
|
19
|
-
const a = Math.max(1e-3, i - o);
|
|
20
|
-
return A.add(n, A.scale(e, a / i));
|
|
21
|
-
}
|
|
22
|
-
function J(t, n) {
|
|
23
|
-
if (t.projection === "perspective") return P.perspective(t.fov, n, t.near, t.far);
|
|
24
|
-
const o = t.height / 2;
|
|
25
|
-
return P.orthographic(-o * n, o * n, -o, o, t.near, t.far);
|
|
26
|
-
}
|
|
27
|
-
function mt(t, n, o, e) {
|
|
28
|
-
const { camera: i } = e, a = i.near, r = t.map((p) => P.transformPoint(i.view, p)), l = i.projection[5] * e.height / 2, c = (p, h) => o.width * (1 - o.taper * p) * l / (i.orthographic ? 1 : Math.max(h, a)), u = N(o.color), g = [];
|
|
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 X, trailSamples as lt } from "@algorisys/tinyfly";
|
|
3
|
+
import { l as dt, r as ht, p as Z } from "./shots-DR_ViiAC.js";
|
|
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
|
+
import { p as F, f as gt, s as U, i as Q } from "./shading-0lPgnXmD.js";
|
|
6
|
+
import { l as vn } from "./shading-0lPgnXmD.js";
|
|
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)), y = F(o.color), p = [];
|
|
29
9
|
let m = [];
|
|
30
|
-
const
|
|
31
|
-
for (let
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
m.length > 0 &&
|
|
36
|
-
const
|
|
37
|
-
for (const
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
for (let
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
let T =
|
|
46
|
-
if (
|
|
47
|
-
if (o.additive)
|
|
10
|
+
const M = (g) => -g[2] >= l;
|
|
11
|
+
for (let g = 0; g < s.length; g++) {
|
|
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)), p.push(m), m = []);
|
|
14
|
+
}
|
|
15
|
+
m.length > 0 && p.push(m);
|
|
16
|
+
const I = [];
|
|
17
|
+
for (const g of p) {
|
|
18
|
+
if (g.length < 2) continue;
|
|
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
|
+
for (let h = 0; h + 1 < g.length; h++) {
|
|
21
|
+
const k = (d[h] + d[h + 1]) / 2;
|
|
22
|
+
if (k > r.far) continue;
|
|
23
|
+
let v = o.opacity * (1 - o.fade * ((g[h].age + g[h + 1].age) / 2));
|
|
24
|
+
const x = A.lerp(g[h].view, g[h + 1].view, 0.5), P = gt(i.fog, A.length(x));
|
|
25
|
+
let T = y;
|
|
26
|
+
if (i.fog && P > 0)
|
|
27
|
+
if (o.additive) v *= 1 - P;
|
|
48
28
|
else {
|
|
49
|
-
const
|
|
50
|
-
T = [
|
|
29
|
+
const u = F(i.fog.color);
|
|
30
|
+
T = [y[0] + (u[0] - y[0]) * P, y[1] + (u[1] - y[1]) * P, y[2] + (u[2] - y[2]) * P];
|
|
51
31
|
}
|
|
52
|
-
if (
|
|
53
|
-
const D = `rgb(${T.map((
|
|
54
|
-
|
|
55
|
-
depth:
|
|
56
|
-
draw(
|
|
57
|
-
o.additive && (
|
|
32
|
+
if (v <= 0) continue;
|
|
33
|
+
const D = `rgb(${T.map((u) => Math.round(Math.min(1, Math.max(0, u)) * 255)).join(", ")})`, S = [e.left[h], e.left[h + 1], e.right[h + 1], e.right[h]], $ = h + 2 === g.length ? f : null;
|
|
34
|
+
I.push({
|
|
35
|
+
depth: k,
|
|
36
|
+
draw(u) {
|
|
37
|
+
o.additive && (u.globalCompositeOperation = "lighter"), u.globalAlpha = Math.min(1, v), u.fillStyle = D, u.beginPath(), u.moveTo(S[0].x, S[0].y), u.lineTo(S[1].x, S[1].y), $ && u.arc($.x, $.y, $.radius, $.start, $.start - Math.PI, !0), u.lineTo(S[2].x, S[2].y), u.lineTo(S[3].x, S[3].y), u.closePath(), u.fill(), !o.additive && v >= 1 && (u.strokeStyle = D, u.lineWidth = 0.75, u.stroke());
|
|
58
38
|
}
|
|
59
39
|
});
|
|
60
40
|
}
|
|
61
41
|
}
|
|
62
|
-
return
|
|
42
|
+
return I;
|
|
63
43
|
}
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
return { view: A.lerp(t, n,
|
|
44
|
+
function G(t, n, o, i, r) {
|
|
45
|
+
const l = (-r - t[2]) / (n[2] - t[2]);
|
|
46
|
+
return { view: A.lerp(t, n, l), age: o + (i - o) * l };
|
|
67
47
|
}
|
|
68
|
-
const
|
|
69
|
-
function
|
|
70
|
-
const o = t.position ?? [0, 0, 0],
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
48
|
+
const ut = Math.cos(30 * Math.PI / 180), q = /* @__PURE__ */ new Map(), E = (t) => typeof t == "number" ? t : void 0, W = (t, n) => Array.isArray(t) && t.length === n ? t : void 0;
|
|
49
|
+
function j(t, n) {
|
|
50
|
+
const o = t.position ?? [0, 0, 0], i = W(n.get("position"), 3) ?? [
|
|
51
|
+
E(n.get("x")) ?? o[0],
|
|
52
|
+
E(n.get("y")) ?? o[1],
|
|
53
|
+
E(n.get("z")) ?? o[2]
|
|
74
54
|
];
|
|
75
|
-
let
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
else if (
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
} else t.quaternion ?
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
55
|
+
let r;
|
|
56
|
+
const l = W(n.get("quaternion"), 4), s = ["rotateX", "rotateY", "rotateZ"].map((p) => E(n.get(p)));
|
|
57
|
+
if (l) r = X.normalize(l);
|
|
58
|
+
else if (s.some((p) => p !== void 0)) {
|
|
59
|
+
const p = t.rotation ?? [0, 0, 0];
|
|
60
|
+
r = X.fromEuler(s[0] ?? p[0], s[1] ?? p[1], s[2] ?? p[2]);
|
|
61
|
+
} else t.quaternion ? r = X.normalize(t.quaternion) : r = t.rotation ? X.fromEuler(...t.rotation) : X.identity();
|
|
62
|
+
const c = typeof t.scale == "number" ? [t.scale, t.scale, t.scale] : t.scale ?? [1, 1, 1], a = E(n.get("scale")), y = [
|
|
63
|
+
E(n.get("scaleX")) ?? a ?? c[0],
|
|
64
|
+
E(n.get("scaleY")) ?? a ?? c[1],
|
|
65
|
+
E(n.get("scaleZ")) ?? a ?? c[2]
|
|
86
66
|
];
|
|
87
|
-
return
|
|
67
|
+
return C.compose(i, r, y);
|
|
88
68
|
}
|
|
89
|
-
const
|
|
90
|
-
function
|
|
91
|
-
const
|
|
69
|
+
const B = (t) => [t[12], t[13], t[14]];
|
|
70
|
+
function pt(t, n, o, i) {
|
|
71
|
+
const r = B(n), l = W(o.get("lookAt"), 3) ?? t.lookAt, s = E(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.projection === "perspective" ? Z({ ...t, fov: E(o.get("fov")) ?? t.fov }, i) : Z({ ...t, height: E(o.get("height")) ?? t.height }, i);
|
|
92
72
|
return {
|
|
93
73
|
id: t.id,
|
|
94
|
-
view:
|
|
95
|
-
projection:
|
|
96
|
-
position:
|
|
97
|
-
forward: A.normalize([-
|
|
74
|
+
view: c,
|
|
75
|
+
projection: a,
|
|
76
|
+
position: r,
|
|
77
|
+
forward: A.normalize([-c[2], -c[6], -c[10]]),
|
|
98
78
|
orthographic: t.projection === "orthographic",
|
|
99
79
|
near: t.near,
|
|
100
80
|
far: t.far
|
|
101
81
|
};
|
|
102
82
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
83
|
+
function J(t) {
|
|
84
|
+
return C.transpose(C.invert(t) ?? C.identity());
|
|
105
85
|
}
|
|
106
|
-
function
|
|
107
|
-
return A.normalize([t[0] * n + t[4] * o + t[8] *
|
|
86
|
+
function yt(t, n, o, i) {
|
|
87
|
+
return A.normalize([t[0] * n + t[4] * o + t[8] * i, t[1] * n + t[5] * o + t[9] * i, t[2] * n + t[6] * o + t[10] * i]);
|
|
108
88
|
}
|
|
109
|
-
function
|
|
110
|
-
const o = (
|
|
111
|
-
for (let
|
|
112
|
-
const
|
|
113
|
-
if (o(
|
|
114
|
-
const
|
|
115
|
-
|
|
89
|
+
function mt(t, n) {
|
|
90
|
+
const o = (r) => -r[2] >= n, i = [];
|
|
91
|
+
for (let r = 0; r < t.length; r++) {
|
|
92
|
+
const l = t[r], s = t[(r + 1) % t.length];
|
|
93
|
+
if (o(l) && i.push(l), o(l) !== o(s)) {
|
|
94
|
+
const c = (-n - l[2]) / (s[2] - l[2]);
|
|
95
|
+
i.push(A.lerp(l, s, c));
|
|
116
96
|
}
|
|
117
97
|
}
|
|
118
|
-
return
|
|
98
|
+
return i;
|
|
119
99
|
}
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
for (let
|
|
123
|
-
const
|
|
124
|
-
|
|
100
|
+
function kt(t, n, o, i = 16) {
|
|
101
|
+
const r = [t[0], t[1], t[2]], l = [0, 1, 0], s = [];
|
|
102
|
+
for (let a = 0; a < i; a++) {
|
|
103
|
+
const y = a / i * Math.PI * 2;
|
|
104
|
+
r.push(t[0] + Math.cos(y) * n, t[1], t[2] + Math.sin(y) * o), l.push(0, 1, 0);
|
|
125
105
|
}
|
|
126
|
-
for (let
|
|
127
|
-
const
|
|
128
|
-
return { positions:
|
|
106
|
+
for (let a = 0; a < i; a++) s.push(0, 1 + (a + 1) % i, 1 + a);
|
|
107
|
+
const c = Array.from({ length: i }, () => []);
|
|
108
|
+
return { positions: r, normals: l, indices: s, faceEdges: c };
|
|
129
109
|
}
|
|
130
|
-
function
|
|
131
|
-
const o =
|
|
132
|
-
return o !== void 0 && o > 0 ? { width: o, color:
|
|
110
|
+
function wt(t, n) {
|
|
111
|
+
const o = E(n.get("outlineWidth")) ?? t.outline?.width, i = n.get("outlineColor"), r = (typeof i == "string" ? i : void 0) ?? t.outline?.color ?? "#000000";
|
|
112
|
+
return o !== void 0 && o > 0 ? { width: o, color: r } : void 0;
|
|
133
113
|
}
|
|
134
|
-
function
|
|
114
|
+
function Mt(t, n) {
|
|
135
115
|
return !t || t.to <= t.from ? 1 : Math.min(1, Math.max(0, (n - t.from) / (t.to - t.from)));
|
|
136
116
|
}
|
|
137
|
-
function
|
|
138
|
-
const { scene:
|
|
139
|
-
for (const
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
return { x: (
|
|
148
|
-
},
|
|
149
|
-
for (const
|
|
150
|
-
if (
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
id:
|
|
154
|
-
light:
|
|
155
|
-
color: typeof
|
|
156
|
-
intensity:
|
|
157
|
-
position:
|
|
158
|
-
direction: A.normalize(A.subtract(
|
|
159
|
-
range:
|
|
160
|
-
angle:
|
|
117
|
+
function tt(t, n = /* @__PURE__ */ new Map(), o) {
|
|
118
|
+
const { scene: i } = t, r = (e) => n.get(`${i.id}/${e}`) ?? q, l = o.nearFade ?? i.nearFade, s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
119
|
+
for (const e of i.objects) {
|
|
120
|
+
const f = r(e.id), h = j(e, f), k = e.parent ? s.get(e.parent) : void 0;
|
|
121
|
+
s.set(e.id, k ? C.multiply(k, h) : h);
|
|
122
|
+
const v = E(f.get("visible")) !== void 0 ? E(f.get("visible")) > 0.5 : e.visible !== !1;
|
|
123
|
+
c.set(e.id, v && (e.parent ? c.get(e.parent) !== !1 : !0));
|
|
124
|
+
}
|
|
125
|
+
const a = n.get(i.id)?.get("activeCamera"), y = typeof a == "string" && i.objects.some((e) => e.id === a && e.kind === "camera") ? a : i.camera, p = i.objects.find((e) => e.id === y), m = pt(p, s.get(y), r(y), o.width / o.height), M = (e) => {
|
|
126
|
+
const f = C.transformPoint(m.projection, e);
|
|
127
|
+
return { x: (f[0] + 1) / 2 * o.width, y: (1 - f[1]) / 2 * o.height };
|
|
128
|
+
}, I = [];
|
|
129
|
+
for (const e of i.objects) {
|
|
130
|
+
if (e.kind !== "light" || !c.get(e.id)) continue;
|
|
131
|
+
const f = r(e.id), h = B(s.get(e.id)), k = W(f.get("target"), 3) ?? e.target ?? [0, 0, 0], v = f.get("color");
|
|
132
|
+
I.push({
|
|
133
|
+
id: e.id,
|
|
134
|
+
light: e.light,
|
|
135
|
+
color: typeof v == "string" ? v : e.color,
|
|
136
|
+
intensity: E(f.get("intensity")) ?? e.intensity,
|
|
137
|
+
position: h,
|
|
138
|
+
direction: A.normalize(A.subtract(k, h)),
|
|
139
|
+
range: e.range,
|
|
140
|
+
angle: e.angle ?? 30
|
|
161
141
|
});
|
|
162
142
|
}
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
168
|
-
const
|
|
143
|
+
const g = [], d = [];
|
|
144
|
+
i.objects.forEach((e, f) => {
|
|
145
|
+
if (e.kind !== "mesh" || !c.get(e.id)) return;
|
|
146
|
+
const h = t.meshes.get(e.id), k = i.materials?.[e.material];
|
|
147
|
+
if (!h || !k) return;
|
|
148
|
+
const v = r(e.id), x = s.get(e.id), P = J(x), T = v.get("color"), D = (E(v.get("opacity")) ?? 1) * (k.opacity ?? 1);
|
|
169
149
|
if (D <= 0) return;
|
|
170
|
-
const S =
|
|
171
|
-
|
|
172
|
-
objectId:
|
|
173
|
-
objectIndex:
|
|
174
|
-
layer:
|
|
150
|
+
const S = wt(k, v), $ = S === k.outline || S && k.outline && S.width === k.outline.width && S.color === k.outline.color ? k : { ...k, outline: S };
|
|
151
|
+
d.push({ objectId: e.id, objectIndex: f, mesh: h, world: x, material: $, color: typeof T == "string" ? T : void 0, opacity: D }), g.push(...L(h, x, P, m, M, $, {
|
|
152
|
+
objectId: e.id,
|
|
153
|
+
objectIndex: f,
|
|
154
|
+
layer: e.layer ?? 0,
|
|
175
155
|
color: typeof T == "string" ? T : void 0,
|
|
176
156
|
opacity: D,
|
|
177
157
|
ink: S,
|
|
178
|
-
nearFade:
|
|
158
|
+
nearFade: l
|
|
179
159
|
}));
|
|
180
|
-
}),
|
|
181
|
-
if (
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
184
|
-
const
|
|
185
|
-
if ((
|
|
186
|
-
const
|
|
187
|
-
let T = 1 / 0, D = -1 / 0, S = 1 / 0,
|
|
188
|
-
for (let O = 0; O <
|
|
189
|
-
const R =
|
|
190
|
-
T = Math.min(T, R[0]), D = Math.max(D, R[0]), S = Math.min(S, R[1]),
|
|
160
|
+
}), i.objects.forEach((e, f) => {
|
|
161
|
+
if (e.kind !== "mesh" || !e.shadow || !c.get(e.id)) return;
|
|
162
|
+
const h = t.meshes.get(e.id);
|
|
163
|
+
if (!h) return;
|
|
164
|
+
const k = r(e.id);
|
|
165
|
+
if ((E(k.get("opacity")) ?? 1) <= 0) return;
|
|
166
|
+
const v = s.get(e.id), x = e.shadow === !0 ? {} : e.shadow, P = x.ground ?? i.ground ?? 0;
|
|
167
|
+
let T = 1 / 0, D = -1 / 0, S = 1 / 0, $ = 1 / 0, u = -1 / 0;
|
|
168
|
+
for (let O = 0; O < h.positions.length; O += 3) {
|
|
169
|
+
const R = C.transformPoint(v, [h.positions[O], h.positions[O + 1], h.positions[O + 2]]);
|
|
170
|
+
T = Math.min(T, R[0]), D = Math.max(D, R[0]), S = Math.min(S, R[1]), $ = Math.min($, R[2]), u = Math.max(u, R[2]);
|
|
191
171
|
}
|
|
192
|
-
const z = Math.max(D - T,
|
|
172
|
+
const z = Math.max(D - T, u - $);
|
|
193
173
|
if (!(z > 0)) return;
|
|
194
|
-
const
|
|
174
|
+
const Y = Math.max(0, S - P), N = Math.min(1, Y / (2 * z)), H = (x.opacity ?? 0.22) * (1 - N * 0.8);
|
|
195
175
|
if (H <= 0.01) return;
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
objectId: `${
|
|
199
|
-
objectIndex:
|
|
200
|
-
layer:
|
|
176
|
+
const V = 1.1 + N * 0.4, st = kt([(T + D) / 2, P + 2e-3, ($ + u) / 2], (D - T) / 2 * V, (u - $) / 2 * V), rt = { color: "#000000", shading: "unlit", opacity: H };
|
|
177
|
+
g.push(...L(st, C.identity(), C.identity(), m, M, rt, {
|
|
178
|
+
objectId: `${e.id}:shadow`,
|
|
179
|
+
objectIndex: f - 0.5,
|
|
180
|
+
layer: e.layer ?? 0,
|
|
201
181
|
opacity: H,
|
|
202
|
-
nearFade:
|
|
182
|
+
nearFade: l
|
|
203
183
|
}));
|
|
204
184
|
});
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
209
|
-
const
|
|
210
|
-
object:
|
|
211
|
-
prepared: t.prepared.get(
|
|
212
|
-
values:
|
|
213
|
-
world:
|
|
185
|
+
const w = [];
|
|
186
|
+
i.objects.forEach((e, f) => {
|
|
187
|
+
const h = t.kinds.get(e.kind);
|
|
188
|
+
if (!h || !c.get(e.id)) return;
|
|
189
|
+
const k = h.resolve({
|
|
190
|
+
object: e,
|
|
191
|
+
prepared: t.prepared.get(e.id),
|
|
192
|
+
values: r(e.id),
|
|
193
|
+
world: s.get(e.id),
|
|
214
194
|
camera: m,
|
|
215
|
-
lights:
|
|
216
|
-
fog:
|
|
195
|
+
lights: I,
|
|
196
|
+
fog: i.fog,
|
|
217
197
|
width: o.width,
|
|
218
198
|
height: o.height,
|
|
219
|
-
toScreen:
|
|
199
|
+
toScreen: M
|
|
220
200
|
});
|
|
221
|
-
if (!
|
|
222
|
-
const
|
|
223
|
-
for (const
|
|
224
|
-
for (const
|
|
225
|
-
|
|
226
|
-
objectId:
|
|
227
|
-
objectIndex:
|
|
228
|
-
layer:
|
|
229
|
-
opacity:
|
|
230
|
-
ink:
|
|
231
|
-
nearFade:
|
|
201
|
+
if (!k) return;
|
|
202
|
+
const v = e.layer ?? 0;
|
|
203
|
+
for (const x of k.drawables ?? []) w.push({ ...x, objectId: e.id, objectIndex: f, layer: v });
|
|
204
|
+
for (const x of k.meshes ?? [])
|
|
205
|
+
d.push({ objectId: e.id, objectIndex: f, mesh: x.mesh, world: x.world, material: x.material, opacity: x.material.opacity ?? 1 }), g.push(...L(x.mesh, x.world, J(x.world), m, M, x.material, {
|
|
206
|
+
objectId: e.id,
|
|
207
|
+
objectIndex: f,
|
|
208
|
+
layer: v,
|
|
209
|
+
opacity: x.material.opacity ?? 1,
|
|
210
|
+
ink: x.material.outline,
|
|
211
|
+
nearFade: l
|
|
232
212
|
}));
|
|
233
213
|
});
|
|
234
|
-
const b = { camera: m, height: o.height, fog:
|
|
235
|
-
return
|
|
236
|
-
if (
|
|
237
|
-
const
|
|
238
|
-
if (!
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
const
|
|
242
|
-
for (const
|
|
243
|
-
}),
|
|
244
|
-
id:
|
|
214
|
+
const b = { camera: m, height: o.height, fog: i.fog, toScreen: M };
|
|
215
|
+
return i.objects.forEach((e, f) => {
|
|
216
|
+
if (e.kind !== "line" && e.kind !== "trail" || !c.get(e.id)) return;
|
|
217
|
+
const h = r(e.id), k = e.kind === "line" ? vt(e, s.get(e.id)) : xt(e, i, n, o);
|
|
218
|
+
if (!k) return;
|
|
219
|
+
const v = bt(e, h);
|
|
220
|
+
if (v.opacity <= 0 || v.width <= 0) return;
|
|
221
|
+
const x = e.layer ?? 0;
|
|
222
|
+
for (const P of ft(k.points, k.ages, v, b)) w.push({ ...P, objectId: e.id, objectIndex: f, layer: x });
|
|
223
|
+
}), w.sort((e, f) => e.layer - f.layer || f.depth - e.depth || e.objectIndex - f.objectIndex), g.sort((e, f) => e.layer - f.layer || f.depth - e.depth || e.objectIndex - f.objectIndex || e.face - f.face || e.part - f.part), {
|
|
224
|
+
id: i.id,
|
|
245
225
|
width: o.width,
|
|
246
226
|
height: o.height,
|
|
247
|
-
background:
|
|
248
|
-
fog:
|
|
227
|
+
background: i.background,
|
|
228
|
+
fog: i.fog,
|
|
249
229
|
camera: m,
|
|
250
|
-
lights:
|
|
251
|
-
worlds:
|
|
252
|
-
triangles:
|
|
253
|
-
drawables:
|
|
254
|
-
meshes:
|
|
230
|
+
lights: I,
|
|
231
|
+
worlds: s,
|
|
232
|
+
triangles: g,
|
|
233
|
+
drawables: w,
|
|
234
|
+
meshes: d,
|
|
255
235
|
time: o.time ?? 0
|
|
256
236
|
};
|
|
257
237
|
}
|
|
258
|
-
function
|
|
259
|
-
const o = n.get("color"),
|
|
238
|
+
function bt(t, n) {
|
|
239
|
+
const o = n.get("color"), i = t.kind === "trail";
|
|
260
240
|
return {
|
|
261
241
|
color: typeof o == "string" ? o : t.color,
|
|
262
|
-
width:
|
|
263
|
-
taper: t.taper ?? (
|
|
264
|
-
fade: t.fade ?? (
|
|
265
|
-
opacity: (
|
|
242
|
+
width: E(n.get("width")) ?? t.width ?? 0.05,
|
|
243
|
+
taper: t.taper ?? (i ? 1 : 0),
|
|
244
|
+
fade: t.fade ?? (i ? 1 : 0),
|
|
245
|
+
opacity: (E(n.get("opacity")) ?? 1) * (t.opacity ?? 1),
|
|
266
246
|
additive: t.blend === "add"
|
|
267
247
|
};
|
|
268
248
|
}
|
|
269
|
-
function
|
|
270
|
-
const
|
|
271
|
-
return { points:
|
|
272
|
-
}
|
|
273
|
-
function
|
|
274
|
-
if (!
|
|
275
|
-
const
|
|
276
|
-
(
|
|
277
|
-
|
|
278
|
-
{ length:
|
|
249
|
+
function vt(t, n) {
|
|
250
|
+
const i = (t.closed ? [...t.points, t.points[0]] : t.points).map((r) => C.transformPoint(n, r));
|
|
251
|
+
return { points: i, ages: i.map((r, l) => 1 - l / (i.length - 1)) };
|
|
252
|
+
}
|
|
253
|
+
function xt(t, n, o, i) {
|
|
254
|
+
if (!i.valuesAt) return null;
|
|
255
|
+
const r = i.time ?? 0, l = E(o.get(`${n.id}/${t.id}`)?.get("length")) ?? t.length, s = lt(
|
|
256
|
+
(c) => B(nt(n, t.follow, c === r ? o : i.valuesAt(c))),
|
|
257
|
+
r,
|
|
258
|
+
{ length: l, samples: t.samples ?? 32, period: t.period ?? i.period }
|
|
279
259
|
);
|
|
280
|
-
return
|
|
281
|
-
}
|
|
282
|
-
function
|
|
283
|
-
const
|
|
284
|
-
if (!
|
|
285
|
-
const
|
|
286
|
-
return
|
|
287
|
-
}
|
|
288
|
-
function
|
|
289
|
-
const
|
|
290
|
-
for (let
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
const
|
|
295
|
-
for (let
|
|
296
|
-
const [
|
|
297
|
-
m.push(
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
const
|
|
302
|
-
for (let
|
|
303
|
-
const
|
|
304
|
-
if (!
|
|
305
|
-
const b = [t.indices[
|
|
306
|
-
if (
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
for (const
|
|
312
|
-
const z =
|
|
313
|
-
(
|
|
260
|
+
return s.length >= 2 ? { points: s.map((c) => c.at), ages: s.map((c) => c.age) } : null;
|
|
261
|
+
}
|
|
262
|
+
function nt(t, n, o) {
|
|
263
|
+
const i = t.objects.find((l) => l.id === n);
|
|
264
|
+
if (!i) return C.identity();
|
|
265
|
+
const r = j(i, o.get(`${t.id}/${n}`) ?? q);
|
|
266
|
+
return i.parent ? C.multiply(nt(t, i.parent, o), r) : r;
|
|
267
|
+
}
|
|
268
|
+
function L(t, n, o, i, r, l, s) {
|
|
269
|
+
const c = t.positions.length / 3, a = [], y = [];
|
|
270
|
+
for (let d = 0; d < c; d++) {
|
|
271
|
+
const w = C.transformPoint(n, [t.positions[d * 3], t.positions[d * 3 + 1], t.positions[d * 3 + 2]]);
|
|
272
|
+
a.push(w), y.push(C.transformPoint(i.view, w));
|
|
273
|
+
}
|
|
274
|
+
const p = t.indices.length / 3, m = [], M = [];
|
|
275
|
+
for (let d = 0; d < p; d++) {
|
|
276
|
+
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
|
+
m.push(f);
|
|
278
|
+
const h = i.orthographic ? A.scale(i.forward, -1) : A.subtract(i.position, w);
|
|
279
|
+
M.push(A.dot(f, h) > 0);
|
|
280
|
+
}
|
|
281
|
+
const I = (d) => -y[d][2] >= i.near, g = [];
|
|
282
|
+
for (let d = 0; d < p; d++) {
|
|
283
|
+
const w = M[d];
|
|
284
|
+
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((u) => y[u]);
|
|
286
|
+
if (e.every((u) => -u[2] > i.far)) continue;
|
|
287
|
+
const f = mt(e, i.near);
|
|
288
|
+
if (f.length < 3) continue;
|
|
289
|
+
const h = w ? 1 : -1, k = A.scale(m[d], h), v = b.map((u) => A.scale(yt(o, t.normals[u * 3], t.normals[u * 3 + 1], t.normals[u * 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, T = [], D = [];
|
|
290
|
+
if (s.ink && w)
|
|
291
|
+
for (const u of t.faceEdges[d]) {
|
|
292
|
+
const z = u.across, Y = z === -1 || !M[z], N = l.creases !== !1 && !Y && d < z && A.dot(m[d], m[z]) < ut;
|
|
293
|
+
(Y || N) && I(u.a) && I(u.b) && (T.push([r(y[u.a]), r(y[u.b])]), D.push([-y[u.a][2], -y[u.b][2]]));
|
|
314
294
|
}
|
|
315
|
-
const S =
|
|
295
|
+
const S = s.opacity * Mt(s.nearFade, P);
|
|
316
296
|
if (S <= 0) continue;
|
|
317
|
-
const
|
|
318
|
-
for (let
|
|
319
|
-
|
|
320
|
-
objectId:
|
|
321
|
-
objectIndex:
|
|
322
|
-
layer:
|
|
323
|
-
face:
|
|
324
|
-
part:
|
|
325
|
-
screen: [
|
|
326
|
-
depth:
|
|
327
|
-
depths: [-
|
|
328
|
-
centroid:
|
|
329
|
-
normal:
|
|
330
|
-
vertexNormals:
|
|
331
|
-
material:
|
|
332
|
-
color:
|
|
297
|
+
const $ = f.map(r);
|
|
298
|
+
for (let u = 1; u + 1 < $.length; u++)
|
|
299
|
+
g.push({
|
|
300
|
+
objectId: s.objectId,
|
|
301
|
+
objectIndex: s.objectIndex,
|
|
302
|
+
layer: s.layer,
|
|
303
|
+
face: d,
|
|
304
|
+
part: u - 1,
|
|
305
|
+
screen: [$[0], $[u], $[u + 1]],
|
|
306
|
+
depth: P,
|
|
307
|
+
depths: [-f[0][2], -f[u][2], -f[u + 1][2]],
|
|
308
|
+
centroid: x,
|
|
309
|
+
normal: k,
|
|
310
|
+
vertexNormals: v,
|
|
311
|
+
material: l,
|
|
312
|
+
color: s.color ?? t.faceColors?.[d],
|
|
333
313
|
opacity: S,
|
|
334
|
-
outline:
|
|
335
|
-
outlineDepths:
|
|
336
|
-
ink:
|
|
314
|
+
outline: u === 1 ? T : [],
|
|
315
|
+
outlineDepths: u === 1 ? D : [],
|
|
316
|
+
ink: s.ink
|
|
337
317
|
});
|
|
338
318
|
}
|
|
339
|
-
return
|
|
319
|
+
return g;
|
|
340
320
|
}
|
|
341
|
-
class
|
|
321
|
+
class zt {
|
|
342
322
|
ctx;
|
|
343
323
|
constructor(n) {
|
|
344
324
|
this.ctx = n;
|
|
345
325
|
}
|
|
346
326
|
render(n) {
|
|
347
|
-
|
|
327
|
+
ot(this.ctx, n);
|
|
348
328
|
}
|
|
349
329
|
}
|
|
350
|
-
function
|
|
330
|
+
function ot(t, n) {
|
|
351
331
|
if (t.save(), n.background && n.background !== "transparent") {
|
|
352
332
|
if (typeof n.background == "string") t.fillStyle = n.background;
|
|
353
333
|
else {
|
|
354
|
-
const
|
|
355
|
-
|
|
334
|
+
const s = t.createLinearGradient(0, 0, 0, n.height);
|
|
335
|
+
s.addColorStop(0, n.background.top), s.addColorStop(1, n.background.bottom), t.fillStyle = s;
|
|
356
336
|
}
|
|
357
337
|
t.fillRect(0, 0, n.width, n.height);
|
|
358
338
|
}
|
|
359
339
|
t.lineJoin = "round", t.lineCap = "round";
|
|
360
340
|
let o = 0;
|
|
361
|
-
const
|
|
341
|
+
const i = (s, c) => {
|
|
362
342
|
for (; o < n.drawables.length; ) {
|
|
363
|
-
const
|
|
364
|
-
if (
|
|
365
|
-
t.save(),
|
|
343
|
+
const a = n.drawables[o];
|
|
344
|
+
if (a.layer > s || a.layer === s && a.depth <= c) break;
|
|
345
|
+
t.save(), a.draw(t, n), t.restore(), o++;
|
|
366
346
|
}
|
|
367
347
|
};
|
|
368
|
-
let
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
const
|
|
372
|
-
for (const
|
|
373
|
-
|
|
374
|
-
|
|
348
|
+
let r = [];
|
|
349
|
+
const l = (s) => {
|
|
350
|
+
if (r.length === 0) return;
|
|
351
|
+
const c = [];
|
|
352
|
+
for (const a of r)
|
|
353
|
+
s && s.objectId === a.objectId && s.layer === a.layer && a.depth - s.depth <= It * a.depth ? c.push(a) : At(t, a.triangle, n);
|
|
354
|
+
r = c;
|
|
375
355
|
};
|
|
376
|
-
for (const
|
|
377
|
-
|
|
378
|
-
const { color:
|
|
379
|
-
t.globalAlpha =
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
const
|
|
384
|
-
function
|
|
385
|
-
const
|
|
386
|
-
t.globalAlpha = n.opacity, t.strokeStyle =
|
|
387
|
-
for (const [
|
|
388
|
-
t.moveTo(
|
|
356
|
+
for (const s of n.triangles) {
|
|
357
|
+
l(s), i(s.layer, s.depth);
|
|
358
|
+
const { color: c, alpha: a } = U(s, n.lights, n.camera, n.fog), [y, p, m] = s.screen;
|
|
359
|
+
t.globalAlpha = a, t.beginPath(), t.moveTo(y.x, y.y), t.lineTo(p.x, p.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
|
+
}
|
|
361
|
+
l(), i(1 / 0, -1 / 0), t.restore();
|
|
362
|
+
}
|
|
363
|
+
const It = 0.04;
|
|
364
|
+
function At(t, n, o) {
|
|
365
|
+
const i = n.ink;
|
|
366
|
+
t.globalAlpha = n.opacity, t.strokeStyle = Q(i.color, o.fog, A.distance(n.centroid, o.camera.position)), t.lineWidth = i.width, t.beginPath();
|
|
367
|
+
for (const [r, l] of n.outline)
|
|
368
|
+
t.moveTo(r.x, r.y), t.lineTo(l.x, l.y);
|
|
389
369
|
t.stroke();
|
|
390
370
|
}
|
|
391
|
-
function
|
|
392
|
-
const o = t.width,
|
|
393
|
-
if (n.under && n.under.length ===
|
|
371
|
+
function St(t, n = {}) {
|
|
372
|
+
const o = t.width, i = t.height, r = new Uint8ClampedArray(o * i * 4), l = new Float32Array(o * i).fill(1 / 0);
|
|
373
|
+
if (n.under && n.under.length === r.length) r.set(n.under);
|
|
394
374
|
else if (t.background && t.background !== "transparent") {
|
|
395
|
-
const
|
|
396
|
-
for (let
|
|
397
|
-
const
|
|
375
|
+
const p = F(typeof t.background == "string" ? t.background : t.background.top), m = F(typeof t.background == "string" ? t.background : t.background.bottom);
|
|
376
|
+
for (let M = 0; M < i; M++) {
|
|
377
|
+
const I = i > 1 ? M / (i - 1) : 0, g = Math.round((p[0] + (m[0] - p[0]) * I) * 255), d = Math.round((p[1] + (m[1] - p[1]) * I) * 255), w = Math.round((p[2] + (m[2] - p[2]) * I) * 255);
|
|
398
378
|
for (let b = 0; b < o; b++) {
|
|
399
|
-
const
|
|
400
|
-
|
|
379
|
+
const e = M * o + b;
|
|
380
|
+
r[e * 4] = g, r[e * 4 + 1] = d, r[e * 4 + 2] = w, r[e * 4 + 3] = 255;
|
|
401
381
|
}
|
|
402
382
|
}
|
|
403
383
|
}
|
|
404
|
-
const
|
|
405
|
-
let
|
|
406
|
-
const
|
|
407
|
-
for (const
|
|
408
|
-
|
|
384
|
+
const s = { width: o, height: i, data: r, depth: l };
|
|
385
|
+
let c = -1 / 0;
|
|
386
|
+
const a = [], y = () => {
|
|
387
|
+
for (const p of a) K(s, t, p, !1);
|
|
388
|
+
a.length = 0;
|
|
409
389
|
};
|
|
410
|
-
for (const
|
|
411
|
-
|
|
412
|
-
return
|
|
413
|
-
}
|
|
414
|
-
function
|
|
415
|
-
const { color:
|
|
416
|
-
if (
|
|
417
|
-
const
|
|
418
|
-
o.outline.forEach((
|
|
419
|
-
const
|
|
420
|
-
|
|
390
|
+
for (const p of t.triangles)
|
|
391
|
+
p.layer !== c && (y(), c = p.layer, l.fill(1 / 0)), p.opacity < 1 ? a.push(p) : K(s, t, p, !0);
|
|
392
|
+
return y(), s;
|
|
393
|
+
}
|
|
394
|
+
function K(t, n, o, i) {
|
|
395
|
+
const { color: r, alpha: l } = U(o, n.lights, n.camera, n.fog), s = F(r).map((c) => Math.round(c * 255));
|
|
396
|
+
if (Tt(t, o.screen, o.depths, s, l, i), o.ink && o.outline.length > 0) {
|
|
397
|
+
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, y) => {
|
|
399
|
+
const p = o.outlineDepths[y] ?? [o.depth, o.depth];
|
|
400
|
+
$t(t, a[0], a[1], p, o.ink.width, c, l);
|
|
421
401
|
});
|
|
422
402
|
}
|
|
423
403
|
}
|
|
424
|
-
function
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
427
|
-
t[
|
|
404
|
+
function it(t, n, o, i) {
|
|
405
|
+
const r = n * 4;
|
|
406
|
+
if (i >= 1) {
|
|
407
|
+
t[r] = o[0], t[r + 1] = o[1], t[r + 2] = o[2], t[r + 3] = 255;
|
|
428
408
|
return;
|
|
429
409
|
}
|
|
430
|
-
const
|
|
431
|
-
if (!(
|
|
432
|
-
for (let
|
|
433
|
-
t[
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
const
|
|
437
|
-
function
|
|
438
|
-
const [
|
|
439
|
-
if (
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
442
|
-
const
|
|
443
|
-
for (let
|
|
444
|
-
const b =
|
|
445
|
-
for (let
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
448
|
-
const
|
|
449
|
-
|
|
410
|
+
const l = t[r + 3] / 255, s = i + l * (1 - i);
|
|
411
|
+
if (!(s <= 0)) {
|
|
412
|
+
for (let c = 0; c < 3; c++) t[r + c] = Math.round((o[c] * i + t[r + c] * l * (1 - i)) / s);
|
|
413
|
+
t[r + 3] = Math.round(s * 255);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const Pt = 4e-3;
|
|
417
|
+
function Tt(t, n, o, i, r, l) {
|
|
418
|
+
const [s, c, a] = n, y = (c.x - s.x) * (a.y - s.y) - (c.y - s.y) * (a.x - s.x);
|
|
419
|
+
if (y === 0) return;
|
|
420
|
+
const p = 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)));
|
|
421
|
+
if (p > m || M > I) return;
|
|
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 = y > 0 ? 1 : -1;
|
|
423
|
+
for (let w = M; w <= I; w++) {
|
|
424
|
+
const b = w + 0.5;
|
|
425
|
+
for (let e = p; e <= m; e++) {
|
|
426
|
+
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
|
+
if (h < 0 || k < 0 || v < 0) continue;
|
|
428
|
+
const P = (h + k + v) / (h * g[0] + k * g[1] + v * g[2]), T = w * t.width + e;
|
|
429
|
+
P >= t.depth[T] || (it(t.data, T, i, r), l && (t.depth[T] = P));
|
|
450
430
|
}
|
|
451
431
|
}
|
|
452
432
|
}
|
|
453
|
-
function
|
|
454
|
-
const
|
|
455
|
-
for (let
|
|
456
|
-
const b =
|
|
457
|
-
for (let
|
|
458
|
-
const
|
|
459
|
-
if ((
|
|
460
|
-
const
|
|
461
|
-
|
|
433
|
+
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)), y = Math.min(t.width - 1, Math.ceil(Math.max(n.x, o.x) + c)), p = 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;
|
|
435
|
+
for (let w = p; w <= m; w++) {
|
|
436
|
+
const b = w + 0.5;
|
|
437
|
+
for (let e = a; e <= y; e++) {
|
|
438
|
+
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
|
+
if ((f - k) ** 2 + (b - v) ** 2 > d) continue;
|
|
440
|
+
const x = (i[0] + (i[1] - i[0]) * h) * (1 - Pt), P = w * t.width + e;
|
|
441
|
+
x > t.depth[P] || it(t.data, P, l, s);
|
|
462
442
|
}
|
|
463
443
|
}
|
|
464
444
|
}
|
|
465
|
-
function
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
for (const
|
|
469
|
-
t.save(),
|
|
445
|
+
function et(t, n) {
|
|
446
|
+
const i = !n.background || n.background === "transparent" ? t.getImageData(0, 0, n.width, n.height).data : void 0, r = St(n, { under: i }), l = t.createImageData(n.width, n.height);
|
|
447
|
+
l.data.set(r.data), t.putImageData(l, 0, 0), t.save(), t.lineJoin = "round", t.lineCap = "round";
|
|
448
|
+
for (const s of n.drawables)
|
|
449
|
+
t.save(), s.draw(t, n), t.restore();
|
|
470
450
|
t.restore();
|
|
471
451
|
}
|
|
472
|
-
class
|
|
452
|
+
class Ft {
|
|
473
453
|
ctx;
|
|
474
454
|
constructor(n) {
|
|
475
455
|
this.ctx = n;
|
|
476
456
|
}
|
|
477
457
|
render(n) {
|
|
478
|
-
|
|
458
|
+
et(this.ctx, n);
|
|
479
459
|
}
|
|
480
460
|
}
|
|
481
|
-
class
|
|
461
|
+
class Ot {
|
|
482
462
|
renderer;
|
|
483
463
|
width;
|
|
484
464
|
height;
|
|
@@ -505,121 +485,37 @@ class Wt {
|
|
|
505
485
|
time = 0;
|
|
506
486
|
render() {
|
|
507
487
|
for (const n of this.scenes.values())
|
|
508
|
-
this.renderer.render(
|
|
488
|
+
this.renderer.render(tt(n, this.values, { width: this.width, height: this.height, time: this.time, valuesAt: this.valuesAt }));
|
|
509
489
|
}
|
|
510
490
|
}
|
|
511
|
-
function
|
|
512
|
-
const
|
|
513
|
-
|
|
491
|
+
function Rt(t, n, o, i) {
|
|
492
|
+
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
|
+
i.depthBuffer ? et(t, s) : ot(t, s);
|
|
514
494
|
}
|
|
515
|
-
function
|
|
516
|
-
const n = t.id ?? "penrose", o = t.length ?? 4,
|
|
517
|
-
id: `${n}-${
|
|
495
|
+
function Xt(t = {}) {
|
|
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, y = (g, d, w) => ({
|
|
497
|
+
id: `${n}-${g}`,
|
|
518
498
|
kind: "mesh",
|
|
519
|
-
geometry: { type: "box", size: [
|
|
520
|
-
material:
|
|
521
|
-
position: [
|
|
522
|
-
}),
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
], m = [
|
|
499
|
+
geometry: { type: "box", size: [w[0] - d[0], w[1] - d[1], w[2] - d[2]] },
|
|
500
|
+
material: r,
|
|
501
|
+
position: [l + (d[0] + w[0]) / 2, s + (d[1] + w[1]) / 2, c + (d[2] + w[2]) / 2]
|
|
502
|
+
}), p = [
|
|
503
|
+
y("x", [-a, -a, -a], [o - a, a, a]),
|
|
504
|
+
y("y", [o - a, -a, -a], [o + a, o - a, a]),
|
|
505
|
+
y("z", [o - a, o - a, -a], [o + a, o + a, o])
|
|
506
|
+
], m = [l + 2 * o / 3, s + o / 3, c + o / 3], M = (t.distance ?? 20) / Math.sqrt(3), I = {
|
|
527
507
|
id: `${n}-camera`,
|
|
528
508
|
kind: "camera",
|
|
529
509
|
projection: "orthographic",
|
|
530
510
|
height: o * 1.6,
|
|
531
511
|
near: 0.1,
|
|
532
512
|
far: (t.distance ?? 20) * 3,
|
|
533
|
-
position: [m[0] +
|
|
513
|
+
position: [m[0] + M, m[1] + M, m[2] + M],
|
|
534
514
|
lookAt: m
|
|
535
515
|
};
|
|
536
|
-
return { objects:
|
|
537
|
-
}
|
|
538
|
-
function _t(t, n) {
|
|
539
|
-
let o;
|
|
540
|
-
for (const e of [...t].sort((i, a) => i.start - a.start)) e.start <= n && (o = e);
|
|
541
|
-
return o;
|
|
542
|
-
}
|
|
543
|
-
function Bt(t) {
|
|
544
|
-
const n = [], o = [...t].sort((i, a) => i.start - a.start), e = /* @__PURE__ */ new Set();
|
|
545
|
-
return o.forEach((i, a) => {
|
|
546
|
-
e.has(i.id) && n.push(`two shots share the id "${i.id}"`), e.add(i.id), i.end > i.start || n.push(`shot "${i.id}" ends before it starts`), a > 0 && i.start < o[a - 1].end && n.push(`shot "${i.id}" starts before "${o[a - 1].id}" ends`), i.transition && a === 0 && n.push(`shot "${i.id}" is first: nothing to transition from`), i.transition && i.transition.duration > i.end - i.start && n.push(`shot "${i.id}": its transition is longer than the shot`);
|
|
547
|
-
}), n;
|
|
548
|
-
}
|
|
549
|
-
function Vt(t, n) {
|
|
550
|
-
const o = [...t].sort((i, a) => i.start - a.start);
|
|
551
|
-
if (o.length === 0) return [];
|
|
552
|
-
const e = o.map((i) => ({ time: i.start, value: i.camera }));
|
|
553
|
-
return [{ id: `${n}-shots`, target: n, property: "activeCamera", keyframes: e }];
|
|
554
|
-
}
|
|
555
|
-
function Zt(t) {
|
|
556
|
-
return [...t].sort((n, o) => n.start - o.start).map((n) => ({ id: n.id, time: n.start, label: n.label ?? n.id }));
|
|
557
|
-
}
|
|
558
|
-
function Gt(t, n) {
|
|
559
|
-
const o = [...t].sort((e, i) => e.start - i.start);
|
|
560
|
-
for (let e = 1; e < o.length; e++) {
|
|
561
|
-
const i = o[e], a = i.transition;
|
|
562
|
-
if (!(!a || a.kind === "cut" || !(a.duration > 0)) && n >= i.start && n < i.start + a.duration)
|
|
563
|
-
return { kind: a.kind, progress: (n - i.start) / a.duration, from: o[e - 1], to: i, direction: a.direction ?? "left", color: a.color ?? "#000000" };
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
function Jt(t, n) {
|
|
567
|
-
const o = 6e4 / n.bpm, e = (a) => n.offset + Math.round((a - n.offset) / o) * o, i = [...t].sort((a, r) => a.start - r.start).map((a) => ({ ...a }));
|
|
568
|
-
for (let a = 1; a < i.length; a++) {
|
|
569
|
-
const r = Math.max(i[a - 1].start + 1, e(i[a].start));
|
|
570
|
-
i[a - 1].end = r, i[a].start = r;
|
|
571
|
-
}
|
|
572
|
-
return i;
|
|
516
|
+
return { objects: p, camera: I };
|
|
573
517
|
}
|
|
574
|
-
|
|
575
|
-
const e = new Map(t ?? []), i = new Map(e.get(n) ?? []);
|
|
576
|
-
return i.set("activeCamera", o), e.set(n, i), e;
|
|
577
|
-
}
|
|
578
|
-
const B = (t, n, o) => [t[0] + (n[0] - t[0]) * o, t[1] + (n[1] - t[1]) * o, t[2] + (n[2] - t[2]) * o];
|
|
579
|
-
function Ft(t, n, o) {
|
|
580
|
-
const e = { target: [0, 0, 0], yaw: 0, pitch: 15, distance: 8, ...t }, i = { ...e, ...n }, a = B(e.target, i.target, o), r = e.position || i.position ? B(e.position ?? L(e.target, e.yaw, e.pitch, e.distance), i.position ?? L(i.target, i.yaw, i.pitch, i.distance), o) : L(a, e.yaw + (i.yaw - e.yaw) * o, e.pitch + (i.pitch - e.pitch) * o, e.distance + (i.distance - e.distance) * o), l = B(e.lookAt ?? e.target, i.lookAt ?? i.target, o), c = e.fov !== void 0 || i.fov !== void 0 ? (e.fov ?? i.fov) + ((i.fov ?? e.fov) - (e.fov ?? i.fov)) * o : void 0;
|
|
581
|
-
return { position: r, lookAt: l, fov: c };
|
|
582
|
-
}
|
|
583
|
-
function Qt(t) {
|
|
584
|
-
const n = Math.max(1, t.every ?? 33), o = ut(t.easing ?? "ease-in-out"), e = `${t.scene}/${t.camera}`, i = [], a = [], r = [];
|
|
585
|
-
for (let c = t.start; ; c = Math.min(t.end, c + n)) {
|
|
586
|
-
const u = t.end > t.start ? o((c - t.start) / (t.end - t.start)) : 1, g = Ft(t.from, t.to, u);
|
|
587
|
-
if (i.push({ time: c, value: g.position }), a.push({ time: c, value: g.lookAt }), g.fov !== void 0 && r.push({ time: c, value: g.fov }), c >= t.end) break;
|
|
588
|
-
}
|
|
589
|
-
const l = [
|
|
590
|
-
{ id: `${e}-move-position`, target: e, property: "position", keyframes: i },
|
|
591
|
-
{ id: `${e}-move-lookAt`, target: e, property: "lookAt", keyframes: a }
|
|
592
|
-
];
|
|
593
|
-
return r.length > 0 && l.push({ id: `${e}-move-fov`, target: e, property: "fov", keyframes: r }), l;
|
|
594
|
-
}
|
|
595
|
-
function Ut(t) {
|
|
596
|
-
const n = Math.max(1, t.every ?? 33), o = t.offset ?? [0, 2, 6], e = t.lag ?? 0, i = `${t.scene}/${t.camera}`, a = [], r = [];
|
|
597
|
-
for (let l = t.start; ; l = Math.min(t.end, l + n)) {
|
|
598
|
-
const c = t.subjectAt(l), u = t.subjectAt(Math.max(t.start, l - e));
|
|
599
|
-
if (a.push({ time: l, value: [u[0] + o[0], u[1] + o[1], u[2] + o[2]] }), r.push({ time: l, value: c }), l >= t.end) break;
|
|
600
|
-
}
|
|
601
|
-
return [
|
|
602
|
-
{ id: `${i}-follow-position`, target: i, property: "position", keyframes: a },
|
|
603
|
-
{ id: `${i}-follow-lookAt`, target: i, property: "lookAt", keyframes: r }
|
|
604
|
-
];
|
|
605
|
-
}
|
|
606
|
-
function qt(t, n) {
|
|
607
|
-
const o = `${n.scene}/${n.camera}`, e = n.amount ?? 0.04, i = n.aim ?? 0.08, a = n.rate ?? 1.2, r = Math.max(1, n.every ?? 33), l = n.end - n.start, c = Math.max(1, l), u = Math.max(1, Math.round(c / 1e3 * a)), g = typeof n.seed == "string" ? n.seed : `handheld-${n.seed ?? 0}`, m = (s, d) => gt(s - n.start, { period: c, seed: `${g}-${d}`, cycles: u, octaves: 2 }), v = t.filter((s) => s.target === o), $ = t.filter((s) => s.target !== o), p = (s, d, f) => {
|
|
608
|
-
const w = v.find((k) => k.property === s), x = [];
|
|
609
|
-
if (w)
|
|
610
|
-
for (const k of w.keyframes) {
|
|
611
|
-
const I = k.value;
|
|
612
|
-
x.push({ time: k.time, value: [I[0] + m(k.time, `${s}x`) * d, I[1] + m(k.time, `${s}y`) * d, I[2] + m(k.time, `${s}z`) * d * 0.5], easing: k.easing });
|
|
613
|
-
}
|
|
614
|
-
else if (f)
|
|
615
|
-
for (let k = n.start; x.push({ time: k, value: [f[0] + m(k, `${s}x`) * d, f[1] + m(k, `${s}y`) * d, f[2] + m(k, `${s}z`) * d * 0.5] }), !(k >= n.end); k = Math.min(n.end, k + r))
|
|
616
|
-
;
|
|
617
|
-
else return;
|
|
618
|
-
return { id: w?.id ?? `${o}-handheld-${s}`, target: o, property: s, keyframes: x };
|
|
619
|
-
}, h = [...$, ...v.filter((s) => s.property !== "position" && s.property !== "lookAt")], M = p("position", e, n.base?.position), b = p("lookAt", i, n.base?.lookAt);
|
|
620
|
-
return M && h.push(M), b && h.push(b), h;
|
|
621
|
-
}
|
|
622
|
-
const V = {
|
|
518
|
+
const _ = {
|
|
623
519
|
day: {
|
|
624
520
|
lights: [
|
|
625
521
|
{ id: "key", kind: "light", light: "directional", color: "#fff6e0", intensity: 0.95, position: [4, 8, 3] },
|
|
@@ -658,34 +554,34 @@ const V = {
|
|
|
658
554
|
fog: { color: "#0a0612", near: 8, far: 24 }
|
|
659
555
|
}
|
|
660
556
|
};
|
|
661
|
-
function
|
|
662
|
-
const o =
|
|
557
|
+
function Yt(t, n = {}) {
|
|
558
|
+
const o = _[t];
|
|
663
559
|
if (!o) throw new Error(`lightingPreset: unknown mood "${t}" (day, dusk, night, stage)`);
|
|
664
|
-
const
|
|
560
|
+
const i = n.prefix ? `${n.prefix}-` : "";
|
|
665
561
|
return {
|
|
666
|
-
objects: o.lights.map((
|
|
562
|
+
objects: o.lights.map((r) => ({ ...r, id: `${i}${r.id}`, position: r.position ? [...r.position] : void 0, target: r.target ? [...r.target] : void 0 })),
|
|
667
563
|
background: { ...o.background },
|
|
668
564
|
fog: { ...o.fog }
|
|
669
565
|
};
|
|
670
566
|
}
|
|
671
|
-
function
|
|
672
|
-
const
|
|
673
|
-
if (!
|
|
674
|
-
const
|
|
675
|
-
for (const
|
|
676
|
-
const
|
|
677
|
-
const
|
|
678
|
-
|
|
567
|
+
function Nt(t, n, o) {
|
|
568
|
+
const i = _[t], r = _[n];
|
|
569
|
+
if (!i || !r) throw new Error(`lightingTracks: unknown mood "${i ? n : t}" (day, dusk, night, stage)`);
|
|
570
|
+
const l = o.prefix ? `${o.prefix}-` : "", s = /* @__PURE__ */ new Set([...i.lights.map((a) => a.id), ...r.lights.map((a) => a.id)]), c = [];
|
|
571
|
+
for (const a of s) {
|
|
572
|
+
const y = i.lights.find((b) => b.id === a), p = r.lights.find((b) => b.id === a), m = `${o.scene}/${l}${a}`, M = (b, e, f) => {
|
|
573
|
+
const h = [{ time: o.start, value: e }, { time: o.end, value: f, easing: o.easing ?? "ease-in-out" }];
|
|
574
|
+
c.push({ id: `${m}-${b}`, target: m, property: b, keyframes: h });
|
|
679
575
|
};
|
|
680
|
-
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
const
|
|
684
|
-
|
|
576
|
+
M("intensity", y?.intensity ?? 0, p?.intensity ?? 0), M("color", y?.color ?? p.color, p?.color ?? y.color);
|
|
577
|
+
const I = y?.position ?? p?.position, g = p?.position ?? y?.position;
|
|
578
|
+
I && g && M("position", [...I], [...g]);
|
|
579
|
+
const d = y?.target ?? p?.target, w = p?.target ?? y?.target;
|
|
580
|
+
d && w && M("target", [...d], [...w]);
|
|
685
581
|
}
|
|
686
|
-
return
|
|
582
|
+
return c;
|
|
687
583
|
}
|
|
688
|
-
function
|
|
584
|
+
function Wt(t = {}) {
|
|
689
585
|
const n = t.id ?? "ground", o = t.size ?? 24;
|
|
690
586
|
return {
|
|
691
587
|
objects: [{ id: n, kind: "mesh", layer: -1, geometry: { type: "plane", size: [o, o], segments: t.segments ?? 24 }, material: n, position: [0, t.y ?? 0, 0] }],
|
|
@@ -693,55 +589,55 @@ function nn(t = {}) {
|
|
|
693
589
|
};
|
|
694
590
|
}
|
|
695
591
|
export {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
592
|
+
zt as Canvas2DRenderer,
|
|
593
|
+
_ as LIGHTING_PRESETS,
|
|
594
|
+
_t as MeshBuilder,
|
|
595
|
+
Ot as Scene3DAdapter,
|
|
596
|
+
Ft as SoftwareRenderer,
|
|
597
|
+
Bt as boxMesh,
|
|
598
|
+
cn as cameraFollowTracks,
|
|
599
|
+
ln as cameraHandheldTracks,
|
|
600
|
+
dn as cameraMoveTracks,
|
|
601
|
+
hn as cameraPoseAt,
|
|
602
|
+
gn as checkShots,
|
|
603
|
+
Vt as coneMesh,
|
|
604
|
+
Zt as cylinderMesh,
|
|
605
|
+
fn as dollyPosition,
|
|
606
|
+
ot as drawResolvedScene,
|
|
607
|
+
et as drawResolvedSceneWithDepth,
|
|
608
|
+
Rt as drawScene3D,
|
|
609
|
+
Gt as extrudeMesh,
|
|
610
|
+
gt as fogAmount,
|
|
611
|
+
Jt as geometryMesh,
|
|
612
|
+
Wt as ground,
|
|
613
|
+
Q as inkColor,
|
|
614
|
+
vn as lightAt,
|
|
615
|
+
Yt as lightingPreset,
|
|
616
|
+
Nt as lightingTracks,
|
|
617
|
+
Kt as loadScene3D,
|
|
618
|
+
dt as lookAtView,
|
|
619
|
+
Ut as meshEdges,
|
|
620
|
+
un as orbitPosition,
|
|
621
|
+
F as parseColor,
|
|
622
|
+
Xt as penroseTriangle3D,
|
|
623
|
+
Qt as planeMesh,
|
|
624
|
+
qt as pointInPolygon,
|
|
625
|
+
jt as prepareMesh,
|
|
626
|
+
Z as projectionMatrix,
|
|
627
|
+
St as rasterizeResolvedScene,
|
|
628
|
+
tn as rawMesh,
|
|
629
|
+
tt as resolveScene3D,
|
|
630
|
+
ht as rollView,
|
|
631
|
+
U as shadeTriangle,
|
|
632
|
+
pn as shotAt,
|
|
633
|
+
yn as shotMarkers,
|
|
634
|
+
mn as shotTracks,
|
|
635
|
+
nn as signedArea,
|
|
636
|
+
kn as snapShotsToBeats,
|
|
637
|
+
on as sphereMesh,
|
|
638
|
+
en as torusMesh,
|
|
639
|
+
wn as transitionAt,
|
|
640
|
+
sn as triangulate,
|
|
641
|
+
rn as validateScene3D,
|
|
642
|
+
Mn as withActiveCamera
|
|
747
643
|
};
|