agentglow 0.3.1 → 0.4.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 +89 -11
- package/cli/agentglow.mjs +15 -10
- package/cli/lib/autostart.mjs +23 -0
- package/cli/lib/server.mjs +49 -0
- package/dist/chunks/KitScene-DQRuKA06.js +5933 -0
- package/dist/chunks/ResourceWire-BWuyirO3.js +36 -0
- package/dist/chunks/index-BMvsU_SR.js +678 -0
- package/dist/chunks/index-BdJCRn1T.js +1015 -0
- package/dist/chunks/index-BwhbmMX9.js +990 -0
- package/dist/chunks/index-CDUophR-.js +921 -0
- package/dist/chunks/{index-BxCQhz1w.js → index-CW7wP0kH.js} +194 -194
- package/dist/chunks/index-CxdQEVoW.js +52 -0
- package/dist/chunks/{index-BDKoRpg-.js → index-DGesxtsp.js} +195 -194
- package/dist/chunks/{index-oEkhKSlb.js → index-DHQVfGjR.js} +155 -154
- package/dist/index.js +1 -1
- package/dist/node.js +193 -0
- package/dist/pulse.js +20 -0
- package/dist/style.css +1 -1
- package/dist/types/node.d.ts +45 -0
- package/dist/types/pulse.d.ts +37 -0
- package/dist/types/themes.d.ts +1 -1
- package/dist/types/world.d.ts +200 -8
- package/package.json +55 -6
- package/dist/chunks/KitScene-DC6xid52.js +0 -4562
- package/dist/chunks/index-D_pLQJb9.js +0 -48
- package/dist/chunks/index-Ddw88ax_.js +0 -948
- package/dist/chunks/index-tr3L_z5e.js +0 -677
|
@@ -1,948 +0,0 @@
|
|
|
1
|
-
var ge = Object.defineProperty;
|
|
2
|
-
var me = (f, e, a) => e in f ? ge(f, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : f[e] = a;
|
|
3
|
-
var p = (f, e, a) => me(f, typeof e != "symbol" ? e + "" : e, a);
|
|
4
|
-
import { jsx as P, jsxs as ct, Fragment as ce } from "react/jsx-runtime";
|
|
5
|
-
import { useFrame as nt, useThree as Me } from "@react-three/fiber";
|
|
6
|
-
import { EffectComposer as ye, Bloom as Ae, Vignette as be, Noise as we } from "@react-three/postprocessing";
|
|
7
|
-
import { useMemo as mt, useRef as V, useEffect as St } from "react";
|
|
8
|
-
import * as M from "three";
|
|
9
|
-
import { r as xe, w as W, m as Yt, K as Re, x as Se, f as st, o as Z, y as le, z as he, R as Ge, d as oe, p as ve, e as ze, j as Bt, c as Dt, T as fe, i as Ce, n as Ie, G as Pe, L as yt, u as Fe, S as Be, A as Oe, B as Ee, k as Te } from "./KitScene-DC6xid52.js";
|
|
10
|
-
const Ct = 32, It = new M.Vector3(), Ut = new M.Vector3(), wt = new M.Vector3(), xt = new M.Color(), _e = new M.Color(1, 1, 1);
|
|
11
|
-
function ke(f, e, a, r, s) {
|
|
12
|
-
let o = null;
|
|
13
|
-
for (const h of W.mcpCalls) h.server === f && h.resource === e && (!o || h.start > o.start) && (o = h);
|
|
14
|
-
const l = o && o.phase === "result" ? (s - o.start) / o.dur : 9;
|
|
15
|
-
return { busy: a > 0, act: Yt(r, s, 1.5), head: l < 1 ? 1 - l : -1 };
|
|
16
|
-
}
|
|
17
|
-
function Le({ mcp: f, backend: e, color: a, gain: r = 1, y: s, yFrom: o, lift: l = 0, wave: h = 0 }) {
|
|
18
|
-
const i = mt(() => {
|
|
19
|
-
const g = new M.BufferGeometry();
|
|
20
|
-
return g.setAttribute("position", new M.BufferAttribute(new Float32Array(Ct * 2 * 3), 3)), g.setAttribute("color", new M.BufferAttribute(new Float32Array(Ct * 2 * 3), 3)), g;
|
|
21
|
-
}, []), t = mt(() => new M.Color(a ?? f.srv.color), [a, f.srv.color]), n = mt(() => new M.LineBasicMaterial({ vertexColors: !0, transparent: !0, blending: M.AdditiveBlending, depthWrite: !1, toneMapped: !1 }), []);
|
|
22
|
-
return nt(({ clock: g }) => {
|
|
23
|
-
const x = i.getAttribute("position"), R = i.getAttribute("color"), S = performance.now(), G = xe ? 0 : g.elapsedTime, d = e.res, y = ke(f.name, d.name, d.inflight, d.activeAt, S);
|
|
24
|
-
It.copy(f.pos), Ut.copy(e.pos), s !== void 0 && (It.y = s, Ut.y = s), o !== void 0 && (It.y = o);
|
|
25
|
-
const C = (0.18 + y.act * 0.55 + (y.busy ? 0.35 : 0)) * r;
|
|
26
|
-
for (let c = 0; c < Ct; c++)
|
|
27
|
-
for (let b = 0; b < 2; b++) {
|
|
28
|
-
const u = (c + b) / Ct, w = Math.sin(u * Math.PI);
|
|
29
|
-
wt.lerpVectors(It, Ut, u), wt.y += l * w + (h ? Math.sin(u * 9 - G * 2.4) * h * w : 0);
|
|
30
|
-
let A = C;
|
|
31
|
-
y.busy && (A *= 0.45 + Math.pow(Math.max(0, Math.sin(u * 18 - G * 6)), 6) * 2.4), y.head >= 0 && (A += Math.exp(-(((u - y.head) / 0.08) ** 2)) * 2.6 * r), xt.copy(t), y.head >= 0 && xt.lerp(_e, 0.3);
|
|
32
|
-
const m = c * 2 + b;
|
|
33
|
-
x.setXYZ(m, wt.x, wt.y, wt.z), R.setXYZ(m, xt.r * A, xt.g * A, xt.b * A);
|
|
34
|
-
}
|
|
35
|
-
x.needsUpdate = !0, R.needsUpdate = !0;
|
|
36
|
-
}), /* @__PURE__ */ P("lineSegments", { geometry: i, material: n, frustumCulled: !1 });
|
|
37
|
-
}
|
|
38
|
-
var ae;
|
|
39
|
-
const ut = typeof window < "u" && !!((ae = window.matchMedia) != null && ae.call(window, "(prefers-reduced-motion: reduce)").matches), ot = ut ? 0.3 : 1, X = ut ? 9e3 : 24e3, it = ut ? 3500 : 8e3, B = 12, J = ut ? 450 : 1100, jt = 9e3, q = 64, Nt = 31, De = 4.6, rt = 28, Wt = 64, Pt = 18, Xt = 16, dt = 8, Y = Math.PI * 2, et = 200, qt = 5.4, Mt = 3.2, Ue = ["planner", "researcher", "writer"], Rt = Object.fromEntries(Object.entries(fe).map(([f, e]) => [f, new M.Color(e)])), je = Ce, Ne = () => ({ used: !1, id: "", inst: null, seen: 0, x: 0, y: 0, z: 0, r: 1, g: 1, b: 1, omega: 0, bright: 0, swirl: 0, rscale: 1, tiltA: 0, tiltB: 0, count: 0, want: 0, rank: 0, ka: null, released: !1, p: 0, e: 0, waitMcp: 0 }), Ft = et * 3, We = (f) => {
|
|
40
|
-
let e = 7;
|
|
41
|
-
for (let a = 0; a < f.length; a++) e = e * 31 + f.charCodeAt(a) >>> 0;
|
|
42
|
-
return e % 100003;
|
|
43
|
-
}, K = (f) => {
|
|
44
|
-
const e = Math.sin(f * 127.1 + 311.7) * 43758.5453;
|
|
45
|
-
return e - Math.floor(e);
|
|
46
|
-
};
|
|
47
|
-
function pt(f) {
|
|
48
|
-
const e = new M.BufferGeometry();
|
|
49
|
-
return e.setAttribute("position", new M.BufferAttribute(new Float32Array(f * 3), 3).setUsage(M.DynamicDrawUsage)), e.setAttribute("acol", new M.BufferAttribute(new Float32Array(f * 3), 3).setUsage(M.DynamicDrawUsage)), e.setAttribute("size", new M.BufferAttribute(new Float32Array(f), 1).setUsage(M.DynamicDrawUsage)), e;
|
|
50
|
-
}
|
|
51
|
-
const j = (f, e) => f.getAttribute(e).array, gt = (f) => {
|
|
52
|
-
f.getAttribute("position").needsUpdate = !0, f.getAttribute("acol").needsUpdate = !0, f.getAttribute("size").needsUpdate = !0;
|
|
53
|
-
};
|
|
54
|
-
function ie() {
|
|
55
|
-
return new M.ShaderMaterial({
|
|
56
|
-
uniforms: { uScale: { value: 300 }, uPR: { value: 1 } },
|
|
57
|
-
vertexShader: (
|
|
58
|
-
/* glsl */
|
|
59
|
-
`
|
|
60
|
-
attribute vec3 acol;
|
|
61
|
-
attribute float size;
|
|
62
|
-
uniform float uScale;
|
|
63
|
-
uniform float uPR;
|
|
64
|
-
varying vec3 vC;
|
|
65
|
-
void main() {
|
|
66
|
-
vec4 mv = modelViewMatrix * vec4(position, 1.0);
|
|
67
|
-
gl_Position = projectionMatrix * mv;
|
|
68
|
-
gl_PointSize = min(96.0, size * uPR * uScale / max(0.5, -mv.z));
|
|
69
|
-
vC = acol;
|
|
70
|
-
if (size <= 0.0) gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
71
|
-
}`
|
|
72
|
-
),
|
|
73
|
-
fragmentShader: (
|
|
74
|
-
/* glsl */
|
|
75
|
-
`
|
|
76
|
-
varying vec3 vC;
|
|
77
|
-
void main() {
|
|
78
|
-
vec2 c = gl_PointCoord - 0.5;
|
|
79
|
-
float d = dot(c, c) * 4.0;
|
|
80
|
-
if (d > 1.0) discard;
|
|
81
|
-
float a = exp(-d * 3.2) - 0.04;
|
|
82
|
-
gl_FragColor = vec4(vC * max(a, 0.0), 1.0);
|
|
83
|
-
}`
|
|
84
|
-
),
|
|
85
|
-
transparent: !0,
|
|
86
|
-
depthWrite: !1,
|
|
87
|
-
blending: M.AdditiveBlending
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
const v = new M.Vector3(), N = new M.Vector3(), E = new M.Vector3(), z = new M.Color(), Q = new M.Color(), tt = new M.Object3D(), H = new M.Color(1, 1, 1), re = new M.Color("#fbbf24"), Xe = new M.Color("#ef4444"), Ye = new M.Color("#ef4444");
|
|
91
|
-
class qe {
|
|
92
|
-
constructor() {
|
|
93
|
-
p(this, "material", ie());
|
|
94
|
-
/** nebula points live in the (scaled) side graph group: their sprite size follows kit.graph.scale */
|
|
95
|
-
p(this, "nebMaterial", ie());
|
|
96
|
-
p(this, "frame", 0);
|
|
97
|
-
p(this, "selectedId", null);
|
|
98
|
-
/** field radius (grows with the kit core so the murmuration always surrounds the agents + periphery) */
|
|
99
|
-
p(this, "fieldR", Nt);
|
|
100
|
-
// ---- field
|
|
101
|
-
p(this, "fieldGeo", pt(X));
|
|
102
|
-
p(this, "fP", j(this.fieldGeo, "position"));
|
|
103
|
-
p(this, "fC", j(this.fieldGeo, "acol"));
|
|
104
|
-
p(this, "fS", j(this.fieldGeo, "size"));
|
|
105
|
-
p(this, "fYb", new Float32Array(X));
|
|
106
|
-
p(this, "fIvx", new Float32Array(X));
|
|
107
|
-
p(this, "fIvz", new Float32Array(X));
|
|
108
|
-
p(this, "fHeat", new Float32Array(X));
|
|
109
|
-
p(this, "fT", new Float32Array(X * 3));
|
|
110
|
-
p(this, "fOwner", new Int16Array(X).fill(-1));
|
|
111
|
-
p(this, "fAng", new Float32Array(X));
|
|
112
|
-
p(this, "fOrb", new Float32Array(X));
|
|
113
|
-
p(this, "fRnd", new Float32Array(X));
|
|
114
|
-
// ---- slots (agent eddies, one per drawn kit agent)
|
|
115
|
-
p(this, "slots", Array.from({ length: q }, Ne));
|
|
116
|
-
p(this, "idToSlot", /* @__PURE__ */ new Map());
|
|
117
|
-
p(this, "pendingByInst", /* @__PURE__ */ new Map());
|
|
118
|
-
// ---- runs (pooled vortices, one per drawn kit run; a vortex fades out after its run leaves the kit)
|
|
119
|
-
p(this, "runRef", new Array(B).fill(null));
|
|
120
|
-
p(this, "runKit", new Array(B).fill(null));
|
|
121
|
-
p(this, "runId", new Array(B).fill(""));
|
|
122
|
-
p(this, "runPool", /* @__PURE__ */ new Map());
|
|
123
|
-
p(this, "rPresent", new Uint8Array(B));
|
|
124
|
-
p(this, "rSteps", new Uint8Array(B));
|
|
125
|
-
p(this, "rX", new Float32Array(B));
|
|
126
|
-
p(this, "rZ", new Float32Array(B));
|
|
127
|
-
/** vortex loop radius per run (around its agents) */
|
|
128
|
-
p(this, "rR", new Float32Array(B).fill(De));
|
|
129
|
-
/** step attractors (x, z) per run: at the kit's role slots (plan | research | write) */
|
|
130
|
-
p(this, "rAt", new Float32Array(B * 6));
|
|
131
|
-
p(this, "rAlpha", new Float32Array(B));
|
|
132
|
-
p(this, "rCol", Array.from({ length: B }, () => new M.Color()));
|
|
133
|
-
p(this, "rColStr", new Array(B).fill(""));
|
|
134
|
-
p(this, "runGeo", pt(B * J));
|
|
135
|
-
p(this, "rTh", new Float32Array(B * J));
|
|
136
|
-
p(this, "rSp", new Float32Array(B * J));
|
|
137
|
-
p(this, "rRr", new Float32Array(B * J));
|
|
138
|
-
p(this, "rY", new Float32Array(B * J));
|
|
139
|
-
// ---- nebula (FalkorDB side current; local frame of the kit side graph)
|
|
140
|
-
p(this, "nebGeo", pt(it));
|
|
141
|
-
p(this, "anchorGeo", pt(et));
|
|
142
|
-
p(this, "nA", new Uint16Array(it));
|
|
143
|
-
p(this, "nO", new Float32Array(it * 3));
|
|
144
|
-
p(this, "nSpin", new Float32Array(it));
|
|
145
|
-
p(this, "nB", new Float32Array(it));
|
|
146
|
-
p(this, "aLocal", new Float32Array(et * 3));
|
|
147
|
-
p(this, "aCol", new Float32Array(et * 3));
|
|
148
|
-
p(this, "aNamed", new Uint8Array(et));
|
|
149
|
-
p(this, "burst", new Float32Array(et));
|
|
150
|
-
p(this, "burstW", new Float32Array(et));
|
|
151
|
-
p(this, "flareCol", new Float32Array(et * 3));
|
|
152
|
-
p(this, "nameIdx", /* @__PURE__ */ new Map());
|
|
153
|
-
p(this, "nebAngle", 0.4);
|
|
154
|
-
p(this, "nAnchors", 0);
|
|
155
|
-
p(this, "edgeGeo", new M.BufferGeometry());
|
|
156
|
-
p(this, "edgeA", new Uint16Array(Ft * 2));
|
|
157
|
-
p(this, "nEdge", 0);
|
|
158
|
-
p(this, "lastFlareId", 0);
|
|
159
|
-
p(this, "lastFlare", null);
|
|
160
|
-
// ---- streams + lines
|
|
161
|
-
p(this, "streamGeo", pt(jt));
|
|
162
|
-
p(this, "beamGeo");
|
|
163
|
-
p(this, "glowGeo", pt(q + B * 3 + dt));
|
|
164
|
-
// ---- meshes
|
|
165
|
-
p(this, "cores");
|
|
166
|
-
p(this, "attractors");
|
|
167
|
-
p(this, "stepRings");
|
|
168
|
-
p(this, "rings");
|
|
169
|
-
p(this, "pulsars");
|
|
170
|
-
p(this, "pulsarBeams");
|
|
171
|
-
p(this, "selRing");
|
|
172
|
-
p(this, "ringStart", new Float32Array(rt).fill(-1e9));
|
|
173
|
-
p(this, "ringDur", new Float32Array(rt).fill(1));
|
|
174
|
-
p(this, "ringMax", new Float32Array(rt));
|
|
175
|
-
p(this, "ringPos", new Float32Array(rt * 3));
|
|
176
|
-
p(this, "ringCol", new Float32Array(rt * 3));
|
|
177
|
-
p(this, "ringNext", 0);
|
|
178
|
-
p(this, "mcpSpin", new Float32Array(dt));
|
|
179
|
-
// ------------------------------------------------------------------ frame
|
|
180
|
-
/** kit fit size multiplier for eddies, sampled once per frame */
|
|
181
|
-
p(this, "lodK", 1);
|
|
182
|
-
// active runs / swirls packed for the hot loop
|
|
183
|
-
p(this, "aX", new Float32Array(B));
|
|
184
|
-
p(this, "aZ", new Float32Array(B));
|
|
185
|
-
p(this, "aA", new Float32Array(B));
|
|
186
|
-
p(this, "aRR", new Float32Array(B));
|
|
187
|
-
p(this, "aR", new Float32Array(B * 3));
|
|
188
|
-
p(this, "sX", new Float32Array(q));
|
|
189
|
-
p(this, "sZ", new Float32Array(q));
|
|
190
|
-
p(this, "sS", new Float32Array(q));
|
|
191
|
-
p(this, "stTh", new Float32Array(3));
|
|
192
|
-
p(this, "stB", new Float32Array(3));
|
|
193
|
-
for (let t = 0; t < X; t++) {
|
|
194
|
-
const n = Math.sqrt(Math.random()) * Nt, g = Math.random() * Y;
|
|
195
|
-
this.fP[t * 3] = Math.cos(g) * n, this.fP[t * 3 + 2] = Math.sin(g) * n, this.fYb[t] = (Math.random() - 0.5) * (0.6 + n * 0.05), this.fP[t * 3 + 1] = this.fYb[t], this.fRnd[t] = Math.random(), this.fOrb[t] = 0.16 + 1.35 * Math.pow(Math.random(), 1.5), this.fAng[t] = Math.random() * Y;
|
|
196
|
-
}
|
|
197
|
-
for (let t = 0; t < B * J; t++) {
|
|
198
|
-
this.rTh[t] = Math.random() * Y, this.rSp[t] = 0.2 + Math.random() * 0.14;
|
|
199
|
-
const n = (Math.random() + Math.random() + Math.random() - 1.5) * 0.55;
|
|
200
|
-
this.rRr[t] = n, this.rY[t] = (Math.random() - 0.5) * 0.35;
|
|
201
|
-
}
|
|
202
|
-
for (let t = 0; t < it; t++) {
|
|
203
|
-
const n = 0.18 + 0.55 * Math.pow(Math.random(), 3), g = Math.random() * Y, x = n * Math.sqrt(-2 * Math.log(1 - Math.random() * 0.98));
|
|
204
|
-
this.nO[t * 3] = Math.cos(g) * x, this.nO[t * 3 + 1] = (Math.random() - 0.5) * n * 0.8, this.nO[t * 3 + 2] = Math.sin(g) * x, this.nSpin[t] = (0.15 + Math.random() * 0.5) * (Math.random() < 0.5 ? 1 : 0.6), this.nB[t] = 0.5 + Math.random() * 0.7;
|
|
205
|
-
}
|
|
206
|
-
this.anchorGeo.setDrawRange(0, 0), this.edgeGeo.setAttribute("position", new M.BufferAttribute(new Float32Array(Ft * 2 * 3), 3)), this.edgeGeo.setAttribute("color", new M.BufferAttribute(new Float32Array(Ft * 2 * 3), 3).setUsage(M.DynamicDrawUsage)), this.edgeGeo.setDrawRange(0, 0), this.edgeGeo.boundingSphere = new M.Sphere(new M.Vector3(), 50);
|
|
207
|
-
const e = Wt + Xt * Pt;
|
|
208
|
-
this.beamGeo = new M.BufferGeometry(), this.beamGeo.setAttribute("position", new M.BufferAttribute(new Float32Array(e * 6), 3).setUsage(M.DynamicDrawUsage)), this.beamGeo.setAttribute("color", new M.BufferAttribute(new Float32Array(e * 6), 3).setUsage(M.DynamicDrawUsage));
|
|
209
|
-
const a = new M.Sphere(new M.Vector3(), 400), r = new M.MeshBasicMaterial({ toneMapped: !1 });
|
|
210
|
-
this.cores = new M.InstancedMesh(new M.IcosahedronGeometry(0.26, 3), r, q), this.attractors = new M.InstancedMesh(new M.IcosahedronGeometry(0.3, 3), new M.MeshBasicMaterial({ toneMapped: !1 }), B * 3);
|
|
211
|
-
const s = new M.RingGeometry(0.9, 1, 96);
|
|
212
|
-
s.rotateX(-Math.PI / 2);
|
|
213
|
-
const o = () => new M.MeshBasicMaterial({ toneMapped: !1, transparent: !0, blending: M.AdditiveBlending, depthWrite: !1, side: M.DoubleSide });
|
|
214
|
-
this.stepRings = new M.InstancedMesh(new M.RingGeometry(0.93, 1, 6, 1).rotateX(-Math.PI / 2), o(), B * 3), this.rings = new M.InstancedMesh(s, o(), rt), this.pulsars = new M.InstancedMesh(new M.OctahedronGeometry(0.42, 0), new M.MeshBasicMaterial({ toneMapped: !1 }), dt);
|
|
215
|
-
const l = new M.ConeGeometry(0.12, 3.2, 8, 1, !0);
|
|
216
|
-
l.translate(0, 1.6, 0);
|
|
217
|
-
const h = l.clone().rotateX(Math.PI), i = new M.BufferGeometry();
|
|
218
|
-
{
|
|
219
|
-
const t = l.getAttribute("position").array, n = h.getAttribute("position").array, g = l.getIndex().array, x = h.getIndex().array, R = new Float32Array(t.length + n.length);
|
|
220
|
-
R.set(t), R.set(n, t.length);
|
|
221
|
-
const S = [...g, ...Array.from(x, (G) => G + t.length / 3)];
|
|
222
|
-
i.setAttribute("position", new M.BufferAttribute(R, 3)), i.setIndex(S);
|
|
223
|
-
}
|
|
224
|
-
this.pulsarBeams = new M.InstancedMesh(i, o(), dt);
|
|
225
|
-
for (const t of [this.cores, this.attractors, this.stepRings, this.rings, this.pulsars, this.pulsarBeams]) {
|
|
226
|
-
t.boundingSphere = a, t.frustumCulled = !1, t.instanceMatrix.setUsage(M.DynamicDrawUsage), t.setColorAt(0, z.setRGB(0, 0, 0));
|
|
227
|
-
for (let n = 0; n < t.count; n++)
|
|
228
|
-
tt.position.set(0, -999, 0), tt.scale.setScalar(1e-4), tt.updateMatrix(), t.setMatrixAt(n, tt.matrix), t.setColorAt(n, z.setRGB(0, 0, 0));
|
|
229
|
-
}
|
|
230
|
-
this.selRing = new M.Mesh(new M.RingGeometry(1.25, 1.33, 64).rotateX(-Math.PI / 2), o()), this.selRing.visible = !1;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Swap in a new graph sample (the session's graph grows while it runs). Anchors are laid out per node id (stable:
|
|
234
|
-
* a node never moves when others arrive), new anchors take over a share of the nebula particles. No reset.
|
|
235
|
-
*/
|
|
236
|
-
setGalaxy(e) {
|
|
237
|
-
const a = Math.min(et, e.nodes.length), r = this.nAnchors;
|
|
238
|
-
this.nAnchors = a, this.nameIdx.clear();
|
|
239
|
-
const s = /* @__PURE__ */ new Map();
|
|
240
|
-
for (let n = 0; n < a; n++) {
|
|
241
|
-
const g = e.nodes[n];
|
|
242
|
-
this.nameIdx.set(g.name.toLowerCase(), n), s.set(g.id, n);
|
|
243
|
-
const x = We(g.id), R = K(x), S = 0.5 + (qt - 0.9) * Math.sqrt(R) + (K(x + 1) - 0.5) * 0.45, G = x % 3 / 3 * Y + S * 1.15 + (K(x + 2) - 0.5) * 0.5;
|
|
244
|
-
this.aLocal[n * 3] = Math.cos(G) * S, this.aLocal[n * 3 + 1] = (K(x + 3) - 0.5) * 0.7 * (1.3 - R) + 0.4, this.aLocal[n * 3 + 2] = Math.sin(G) * S, z.set(Re[g.kind] ?? "#94a3b8"), this.aCol[n * 3] = z.r, this.aCol[n * 3 + 1] = z.g, this.aCol[n * 3 + 2] = z.b, this.aNamed[n] = n < 22 ? 1 : 0;
|
|
245
|
-
}
|
|
246
|
-
if (a > 0) {
|
|
247
|
-
const n = r > 0 && a > r ? (a - r) / a : r > 0 ? 0 : 1;
|
|
248
|
-
for (let g = 0; g < it; g++)
|
|
249
|
-
this.nA[g] >= a ? this.nA[g] = Math.floor(Math.random() * a) : n > 0 && Math.random() < n && (this.nA[g] = r > 0 ? r + Math.floor(Math.random() * (a - r)) : Math.random() < 0.2 ? Math.floor(Math.random() * Math.min(22, a)) : Math.floor(Math.random() * a));
|
|
250
|
-
}
|
|
251
|
-
this.anchorGeo.setDrawRange(0, a);
|
|
252
|
-
const o = this.edgeA;
|
|
253
|
-
let l = 0;
|
|
254
|
-
const h = /* @__PURE__ */ new Set(), i = (n, g) => {
|
|
255
|
-
if (n === g || l >= Ft) return;
|
|
256
|
-
const x = n < g ? n * 4096 + g : g * 4096 + n;
|
|
257
|
-
h.has(x) || (h.add(x), o[l * 2] = n, o[l * 2 + 1] = g, l++);
|
|
258
|
-
}, t = this.aLocal;
|
|
259
|
-
for (const n of e.links) {
|
|
260
|
-
const g = s.get(n.source), x = s.get(n.target);
|
|
261
|
-
if (g !== void 0 && x !== void 0) {
|
|
262
|
-
const R = t[g * 3] - t[x * 3], S = t[g * 3 + 2] - t[x * 3 + 2];
|
|
263
|
-
R * R + S * S < 9 && i(g, x);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
for (let n = 0; n < a; n++) {
|
|
267
|
-
let g = -1, x = 1e9, R = -1, S = 1e9;
|
|
268
|
-
for (let G = 0; G < a; G++) {
|
|
269
|
-
if (G === n) continue;
|
|
270
|
-
const d = t[n * 3] - t[G * 3], y = t[n * 3 + 1] - t[G * 3 + 1], C = t[n * 3 + 2] - t[G * 3 + 2], c = d * d + y * y + C * C;
|
|
271
|
-
c < x ? (R = g, S = x, g = G, x = c) : c < S && (R = G, S = c);
|
|
272
|
-
}
|
|
273
|
-
g >= 0 && i(n, g), R >= 0 && n % 2 === 0 && i(n, R);
|
|
274
|
-
}
|
|
275
|
-
this.nEdge = l, this.edgeGeo.setDrawRange(0, l * 2);
|
|
276
|
-
}
|
|
277
|
-
dispose() {
|
|
278
|
-
for (const e of [this.edgeGeo, this.fieldGeo, this.runGeo, this.nebGeo, this.anchorGeo, this.streamGeo, this.beamGeo, this.glowGeo]) e.dispose();
|
|
279
|
-
for (const e of [this.cores, this.attractors, this.stepRings, this.rings, this.pulsars, this.pulsarBeams])
|
|
280
|
-
e.geometry.dispose(), e.material.dispose(), e.dispose();
|
|
281
|
-
this.material.dispose(), this.nebMaterial.dispose();
|
|
282
|
-
}
|
|
283
|
-
// ------------------------------------------------------------------ helpers
|
|
284
|
-
anchorIdx(e) {
|
|
285
|
-
const a = e.toLowerCase();
|
|
286
|
-
let r = this.nameIdx.get(a);
|
|
287
|
-
if (r === void 0) {
|
|
288
|
-
let s = 7;
|
|
289
|
-
for (let o = 0; o < a.length; o++) s = s * 31 + a.charCodeAt(o) >>> 0;
|
|
290
|
-
r = s % Math.max(1, this.nAnchors), this.nameIdx.set(a, r);
|
|
291
|
-
}
|
|
292
|
-
return r;
|
|
293
|
-
}
|
|
294
|
-
/** anchor in the nebula's local frame (rotated by the slow spin) */
|
|
295
|
-
anchorLocal(e, a) {
|
|
296
|
-
const r = Math.cos(this.nebAngle), s = Math.sin(this.nebAngle), o = this.aLocal[e * 3], l = this.aLocal[e * 3 + 2];
|
|
297
|
-
return a.set(o * r - l * s, this.aLocal[e * 3 + 1], o * s + l * r);
|
|
298
|
-
}
|
|
299
|
-
/** anchor on stage (the kit places + scales the side graph) */
|
|
300
|
-
anchorWorld(e, a) {
|
|
301
|
-
return Se(this.anchorLocal(e, a), a);
|
|
302
|
-
}
|
|
303
|
-
slotOf(e) {
|
|
304
|
-
const a = this.idToSlot.get(e);
|
|
305
|
-
return a === void 0 ? null : this.slots[a];
|
|
306
|
-
}
|
|
307
|
-
/** stage position of a run's step attractor k (pool slot s) */
|
|
308
|
-
attractor(e, a, r) {
|
|
309
|
-
return r.set(this.rAt[e * 6 + a * 2], 0.35, this.rAt[e * 6 + a * 2 + 1]);
|
|
310
|
-
}
|
|
311
|
-
emitRing(e, a, r, s, o, l, h, i = 1) {
|
|
312
|
-
const t = this.ringNext++ % rt;
|
|
313
|
-
this.ringStart[t] = h, this.ringDur[t] = l, this.ringMax[t] = o, this.ringPos[t * 3] = e, this.ringPos[t * 3 + 1] = a, this.ringPos[t * 3 + 2] = r, this.ringCol[t * 3] = s.r * i, this.ringCol[t * 3 + 1] = s.g * i, this.ringCol[t * 3 + 2] = s.b * i;
|
|
314
|
-
}
|
|
315
|
-
alloc(e, a) {
|
|
316
|
-
const r = e.inst, s = this.slots.findIndex((i) => !i.used);
|
|
317
|
-
if (s < 0) return -1;
|
|
318
|
-
const o = this.slots[s], l = Rt[r.type];
|
|
319
|
-
Object.assign(o, { used: !0, id: r.id, inst: r, ka: e, count: 0, released: !1, r: l.r, g: l.g, b: l.b, omega: 2, bright: 0.6, swirl: 0, p: 0, e: 0 }), o.tiltA = (K(s + a) - 0.5) * 0.7, o.tiltB = (K(s * 3.1 + a) - 0.5) * 0.7, o.rscale = je(r.type) || e.depth > 0 ? 0.72 : 1, o.want = Math.round((o.rscale < 1 ? 380 : 620) * (ut ? 0.5 : 1));
|
|
320
|
-
const h = r.parent ? this.slotOf(r.parent) : null;
|
|
321
|
-
if (h ? (o.x = h.x, o.y = h.y, o.z = h.z) : (o.x = e.pos.x, o.y = 0.9, o.z = e.pos.z), this.idToSlot.set(r.id, s), this.emitRing(o.x, o.y, o.z, l, 2.4 * st.scale, 0.9, a, 2.2), h) {
|
|
322
|
-
const i = this.idToSlot.get(r.parent);
|
|
323
|
-
let t = Math.floor(h.count * 0.28);
|
|
324
|
-
for (let n = 0; n < X && t > 0; n++)
|
|
325
|
-
this.fOwner[n] === i && n & 1 && (this.fOwner[n] = s, h.count--, o.count++, t--);
|
|
326
|
-
}
|
|
327
|
-
return s;
|
|
328
|
-
}
|
|
329
|
-
release(e, a) {
|
|
330
|
-
const r = this.slots[e], s = this.fP;
|
|
331
|
-
for (let o = 0; o < X; o++) {
|
|
332
|
-
if (this.fOwner[o] !== e) continue;
|
|
333
|
-
this.fOwner[o] = -1;
|
|
334
|
-
const l = s[o * 3] - r.x, h = s[o * 3 + 2] - r.z, i = Math.sqrt(l * l + h * h) + 1e-3, t = (2.4 + this.fRnd[o] * 3.6) * (ut ? 0.5 : 1);
|
|
335
|
-
this.fIvx[o] = l / i * t - h / i * r.omega * 0.5, this.fIvz[o] = h / i * t + l / i * r.omega * 0.5, this.fHeat[o] = 1, this.fT[o * 3] = r.r, this.fT[o * 3 + 1] = r.g, this.fT[o * 3 + 2] = r.b;
|
|
336
|
-
}
|
|
337
|
-
r.count = 0, z.setRGB(r.r, r.g, r.b).lerp(H, 0.5), this.emitRing(r.x, r.y, r.z, z, 3.2 * st.scale, 1.1, a, 2.6);
|
|
338
|
-
}
|
|
339
|
-
/** Once per frame, after the kit's ticker (world tick -> lodTick -> kitTick). */
|
|
340
|
-
update(e, a, r) {
|
|
341
|
-
const s = Math.min(0.05, e);
|
|
342
|
-
this.lodK = st.scale, this.frame++;
|
|
343
|
-
const o = Math.max(Nt, Z.core.r + 20);
|
|
344
|
-
this.fieldR += (o - this.fieldR) * Math.min(1, s * 0.8), this.nebAngle += s * 0.04 * ot, this.syncRuns(a, s), this.syncSlots(a, s, r), this.recruit(a), this.updateField(s, r), this.updateFlares(a), this.updateNebula(r), this.updateRunCurrents(a, r), this.updateStreams(a, r), this.updateMeshes(a, r, s);
|
|
345
|
-
}
|
|
346
|
-
syncRuns(e, a) {
|
|
347
|
-
var r;
|
|
348
|
-
this.rPresent.fill(0);
|
|
349
|
-
for (const s of Z.runs.values()) {
|
|
350
|
-
let o = this.runPool.get(s.id);
|
|
351
|
-
if (o === void 0) {
|
|
352
|
-
o = -1;
|
|
353
|
-
for (let l = 0; l < B; l++)
|
|
354
|
-
if (!this.runId[l] || this.rAlpha[l] < 0.01 && !this.runPool.has(this.runId[l])) {
|
|
355
|
-
o = l;
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
if (o < 0)
|
|
359
|
-
for (let l = 0; l < B; l++) this.rAlpha[l] < 0.01 && !Z.runs.has(this.runId[l]) && (o = l, this.runPool.delete(this.runId[l]));
|
|
360
|
-
if (o < 0) continue;
|
|
361
|
-
this.runId[o] = s.id, this.runPool.set(s.id, o), this.rAlpha[o] = 0;
|
|
362
|
-
}
|
|
363
|
-
this.rPresent[o] = 1, this.runKit[o] = s, this.runRef[o] = s.run ?? W.runs.get(s.id) ?? null, this.rX[o] = s.origin.x, this.rZ[o] = s.origin.z, this.rR[o] = Math.max(2.6, Math.min(11, Math.hypot(s.hu, s.hv) * 0.92 + 0.6));
|
|
364
|
-
for (let l = 0; l < 3; l++)
|
|
365
|
-
le(s, he(Ue[l]), 0, v), this.rAt[o * 6 + l * 2] = v.x, this.rAt[o * 6 + l * 2 + 1] = v.z;
|
|
366
|
-
this.rSteps[o] = (r = this.runRef[o]) != null && r.hasSteps ? 1 : 0;
|
|
367
|
-
}
|
|
368
|
-
for (let s = 0; s < B; s++) {
|
|
369
|
-
this.rPresent[s] || this.runId[s] && this.rAlpha[s] < 0.01 && (this.runPool.get(this.runId[s]) === s && this.runPool.delete(this.runId[s]), this.runId[s] = "", this.runRef[s] = null, this.runKit[s] = null);
|
|
370
|
-
const o = this.runRef[s];
|
|
371
|
-
let l = 0;
|
|
372
|
-
o && this.rPresent[s] && (l = Math.min(1, (e - o.startedAt) / 1800), o.endedAt && (l *= Math.max(0, 1 - (e - o.endedAt - (Ge - 3e3)) / 3e3))), o && o.color !== this.rColStr[s] && (this.rColStr[s] = o.color, this.rCol[s].set(o.color)), this.rAlpha[s] += (l - this.rAlpha[s]) * Math.min(1, a * 3);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
syncSlots(e, a, r) {
|
|
376
|
-
const s = this.frame;
|
|
377
|
-
for (const h of Z.agents.values()) {
|
|
378
|
-
let i = this.idToSlot.get(h.id);
|
|
379
|
-
i !== void 0 && this.slots[i].ka !== h && (this.slots[i].ka = h), i === void 0 && (i = this.alloc(h, e)), !(i < 0) && (this.slots[i].seen = s, this.slots[i].inst = h.inst);
|
|
380
|
-
}
|
|
381
|
-
this.pendingByInst.clear();
|
|
382
|
-
for (const h of W.mcpPending.values()) this.pendingByInst.set(h.instance, Math.max(this.pendingByInst.get(h.instance) ?? 0, oe(h, e)));
|
|
383
|
-
const o = 1 - Math.exp(-a * 2.2), l = 1 - Math.exp(-a * 4);
|
|
384
|
-
for (let h = 0; h < q; h++) {
|
|
385
|
-
const i = this.slots[h];
|
|
386
|
-
if (!i.used) continue;
|
|
387
|
-
const t = i.inst;
|
|
388
|
-
if (i.seen !== s) {
|
|
389
|
-
i.count > 0 && this.release(h, e), i.used = !1, i.inst = null, i.ka = null, this.idToSlot.delete(i.id);
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
const n = i.ka, g = n.pos.x, x = n.pos.z, R = 0.9 + Math.sin(r * 0.9 + h) * 0.18;
|
|
393
|
-
t.exitAt || (i.x += (g - i.x) * o, i.y += (R - i.y) * o, i.z += (x - i.z) * o), n.live.set(i.x, i.y, i.z), i.p = ve(t, e), i.e = ze(t, e), i.waitMcp = this.pendingByInst.get(t.id) ?? -1;
|
|
394
|
-
const S = t.status === "thinking", G = t.status === "waiting";
|
|
395
|
-
let d = S ? 3.6 : G ? 0.7 : 2.2, y = S ? 1 : G ? 0.3 : 0.7;
|
|
396
|
-
i.waitMcp >= 0 && (d = 1, y = 0.45 + 0.3 * (0.5 + 0.5 * Math.sin(r * 3.2))), t.exitAt && (d = 0, y = 0), i.omega += (d * (1 + i.e * 0.7) * ot - i.omega) * l, i.bright += (y + i.e * 1.2 - i.bright) * l, i.swirl = t.exitAt ? 0 : (S ? 1.6 : 0.6) * i.p * ot, t.exitAt && !i.released && (i.released = !0, this.release(h, e));
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
recruit(e) {
|
|
400
|
-
const a = this.fP;
|
|
401
|
-
for (let r = 0; r < q; r++) {
|
|
402
|
-
const s = this.slots[r];
|
|
403
|
-
if (!s.used || !s.inst || s.inst.exitAt) continue;
|
|
404
|
-
const o = (e - s.inst.bornAt) / 1e3, l = s.want * Math.min(1, o / 1.6);
|
|
405
|
-
for (let h = 0; h < 140 && s.count < l; h++) {
|
|
406
|
-
const i = Math.random() * X | 0;
|
|
407
|
-
if (this.fOwner[i] !== -1) continue;
|
|
408
|
-
const t = a[i * 3] - s.x, n = a[i * 3 + 2] - s.z;
|
|
409
|
-
t * t + n * n > 120 || (this.fOwner[i] = r, this.fAng[i] = Math.atan2(n, t), s.count++);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
updateField(e, a) {
|
|
414
|
-
const r = this.fP, s = this.fC, o = this.fS, l = this.fOwner, h = this.slots, i = this.fRnd, t = e * ot, n = a * ot, g = 1 - Math.exp(-e * 2.8), x = Math.exp(-e * 0.5), R = Math.exp(-e * 1.3), S = 0.23 * n, G = 0.17 * n, d = 0.11 * n;
|
|
415
|
-
let y = 0;
|
|
416
|
-
for (let u = 0; u < B; u++)
|
|
417
|
-
this.rAlpha[u] < 0.01 || (this.aX[y] = this.rX[u], this.aZ[y] = this.rZ[u], this.aRR[y] = this.rR[u], this.aA[y] = this.rAlpha[u], this.aR[y * 3] = this.rCol[u].r, this.aR[y * 3 + 1] = this.rCol[u].g, this.aR[y * 3 + 2] = this.rCol[u].b, y++);
|
|
418
|
-
let C = 0;
|
|
419
|
-
for (const u of h)
|
|
420
|
-
!u.used || u.swirl <= 0.01 || (this.sX[C] = u.x, this.sZ[C] = u.z, this.sS[C] = u.swirl, C++);
|
|
421
|
-
const c = this.fieldR, b = c * c;
|
|
422
|
-
for (let u = 0; u < X; u++) {
|
|
423
|
-
const w = u * 3;
|
|
424
|
-
let A = r[w], m = r[w + 1], F = r[w + 2];
|
|
425
|
-
const k = l[u];
|
|
426
|
-
if (k >= 0) {
|
|
427
|
-
const O = h[k], T = this.fOrb[u] * O.rscale * (0.35 + 0.65 * O.p) * this.lodK, _ = this.fAng[u] += O.omega * e / (0.3 + T), D = Math.cos(_), I = Math.sin(_), L = O.x + D * T, Gt = O.z + I * T, Ot = O.y + (I * O.tiltA + D * O.tiltB) * T + (i[u] - 0.5) * 0.14;
|
|
428
|
-
A += (L - A) * g, m += (Ot - m) * g, F += (Gt - F) * g;
|
|
429
|
-
const At = O.bright * (1.5 - T * 0.55) * (0.6 + 0.4 * i[u]);
|
|
430
|
-
s[w] = O.r * At + 0.05, s[w + 1] = O.g * At + 0.05, s[w + 2] = O.b * At + 0.05, o[u] = 0.5 + 0.35 * i[u];
|
|
431
|
-
} else {
|
|
432
|
-
const O = A * A + F * F, T = Math.sqrt(O) + 1e-4, _ = T / 11, D = 1.25 * _ / (1 + _ * _);
|
|
433
|
-
let I = -F / T * D, L = A / T * D;
|
|
434
|
-
const Gt = Math.sin(0.27 * A + S), Ot = Math.cos(0.27 * A + S), At = Math.sin(0.31 * F - G), Vt = Math.cos(0.31 * F - G), Zt = 0.41 * F + 0.33 * A + d, de = Math.sin(Zt), $t = Math.cos(Zt);
|
|
435
|
-
I += (Gt * -0.31 * At + 0.7 * 0.41 * $t) * 3, L -= (0.27 * Ot * Vt + 0.7 * 0.33 * $t) * 3;
|
|
436
|
-
const Ht = Gt * Vt + 0.7 * de + T * 0.09, Et = 0.5 + 0.5 * Math.sin(Ht * 5.5), Jt = Et * Et * Et;
|
|
437
|
-
let Qt = 0, te = 0, ee = 0;
|
|
438
|
-
for (let U = 0; U < y; U++) {
|
|
439
|
-
const $ = A - this.aX[U], lt = F - this.aZ[U], bt = $ * $ + lt * lt, ht = this.aRR[U];
|
|
440
|
-
if (bt > ht * ht * 6.6) continue;
|
|
441
|
-
const zt = Math.sqrt(bt) + 1e-4, kt = zt / ht, se = 2.6 * this.aA[U] * kt * Math.exp(-kt * kt * 0.6);
|
|
442
|
-
I -= lt / zt * se, L += $ / zt * se;
|
|
443
|
-
const ne = zt - ht, Lt = Math.exp(-ne * ne * 0.55) * this.aA[U];
|
|
444
|
-
Qt += this.aR[U * 3] * Lt, te += this.aR[U * 3 + 1] * Lt, ee += this.aR[U * 3 + 2] * Lt;
|
|
445
|
-
}
|
|
446
|
-
for (let U = 0; U < C; U++) {
|
|
447
|
-
const $ = A - this.sX[U], lt = F - this.sZ[U], bt = $ * $ + lt * lt;
|
|
448
|
-
if (bt > 16) continue;
|
|
449
|
-
const ht = this.sS[U] / (1 + bt * 0.9);
|
|
450
|
-
I -= lt * ht, L += $ * ht;
|
|
451
|
-
}
|
|
452
|
-
I += this.fIvx[u], L += this.fIvz[u], this.fIvx[u] *= R, this.fIvz[u] *= R, A += I * t, F += L * t, m += (this.fYb[u] - m) * e * 1.2;
|
|
453
|
-
const vt = this.fHeat[u] *= x, pe = I * I + L * L, Tt = (0.14 + Jt * 2.8) * (0.6 + Math.min(1.2, pe * 0.3)) * (0.45 + 0.75 * i[u]), _t = 0.5 + 0.5 * Math.sin(Ht * 1.3 + 1);
|
|
454
|
-
if (s[w] = (0.05 + 0.05 * _t) * Tt + Qt * 0.42 + this.fT[w] * vt * 1.8, s[w + 1] = (0.08 + 0.03 * _t) * Tt + te * 0.42 + this.fT[w + 1] * vt * 1.8, s[w + 2] = (0.2 - 0.04 * _t) * Tt + ee * 0.42 + this.fT[w + 2] * vt * 1.8, o[u] = 0.26 + 0.2 * i[u] + Jt * 0.12 + vt * 0.35, O > b) {
|
|
455
|
-
const U = Math.sqrt(Math.random()) * c * 0.97, $ = Math.random() * Y;
|
|
456
|
-
A = Math.cos($) * U, F = Math.sin($) * U, this.fHeat[u] = 0, this.fIvx[u] = this.fIvz[u] = 0;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
r[w] = A, r[w + 1] = m, r[w + 2] = F;
|
|
460
|
-
}
|
|
461
|
-
gt(this.fieldGeo);
|
|
462
|
-
}
|
|
463
|
-
updateFlares(e) {
|
|
464
|
-
if (this.burst.fill(0), this.burstW.fill(0), !this.nAnchors || !Z.graphWanted) return;
|
|
465
|
-
const a = Z.graph.scale;
|
|
466
|
-
for (const r of W.flares) {
|
|
467
|
-
const s = this.anchorIdx(r.node), o = (e - r.start) / 1e3, l = (1 - Math.exp(-o * 9)) * Math.exp(-o * 1.3);
|
|
468
|
-
if (r.id > this.lastFlareId) {
|
|
469
|
-
if (this.lastFlareId = r.id, this.anchorWorld(s, v), r.op === "write")
|
|
470
|
-
this.emitRing(v.x, v.y, v.z, H, 4.2 * a, 1.7, e, 2.4), this.emitRing(v.x, v.y, v.z, H, 2.2 * a, 1, e, 1.6);
|
|
471
|
-
else {
|
|
472
|
-
const h = W.instances.get(r.instance);
|
|
473
|
-
this.emitRing(v.x, v.y, v.z, h ? Rt[h.type] : H, 1.1 * a, 0.7, e, 1.6);
|
|
474
|
-
}
|
|
475
|
-
this.lastFlare = { name: r.node, op: r.op, at: e, idx: s };
|
|
476
|
-
}
|
|
477
|
-
if (l > this.burst[s]) {
|
|
478
|
-
this.burst[s] = l;
|
|
479
|
-
const h = W.instances.get(r.instance), i = r.op === "write" ? H : h ? Rt[h.type] : H;
|
|
480
|
-
this.flareCol[s * 3] = i.r, this.flareCol[s * 3 + 1] = i.g, this.flareCol[s * 3 + 2] = i.b, r.op === "write" && (this.burstW[s] = 1);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
updateNebula(e) {
|
|
485
|
-
if (!this.nAnchors || !Z.graphWanted) return;
|
|
486
|
-
const a = j(this.nebGeo, "position"), r = j(this.nebGeo, "acol"), s = j(this.nebGeo, "size"), o = Math.cos(this.nebAngle), l = Math.sin(this.nebAngle), h = e * ot, i = this.aLocal, t = this.aCol, n = this.flareCol;
|
|
487
|
-
for (let c = 0; c < it; c++) {
|
|
488
|
-
const b = this.nA[c], u = this.burst[b], w = h * this.nSpin[c], A = Math.cos(w), m = Math.sin(w), F = this.nO[c * 3], k = this.nO[c * 3 + 2], O = 1 + u * (2.2 + this.burstW[b] * 4.5), T = i[b * 3] + (F * A - k * m) * O, _ = i[b * 3 + 2] + (F * m + k * A) * O, D = i[b * 3 + 1] + this.nO[c * 3 + 1] * O;
|
|
489
|
-
a[c * 3] = T * o - _ * l, a[c * 3 + 1] = D, a[c * 3 + 2] = T * l + _ * o;
|
|
490
|
-
const I = this.nB[c] * 0.3;
|
|
491
|
-
r[c * 3] = t[b * 3] * I + 0.05 + n[b * 3] * u * 2.4, r[c * 3 + 1] = t[b * 3 + 1] * I + 0.06 + n[b * 3 + 1] * u * 2.4, r[c * 3 + 2] = t[b * 3 + 2] * I + 0.12 + n[b * 3 + 2] * u * 2.4, s[c] = 0.3 + this.nB[c] * 0.2 + u * 0.5;
|
|
492
|
-
}
|
|
493
|
-
gt(this.nebGeo);
|
|
494
|
-
const g = j(this.anchorGeo, "position"), x = j(this.anchorGeo, "acol"), R = j(this.anchorGeo, "size"), S = this.nAnchors;
|
|
495
|
-
for (let c = 0; c < S; c++) {
|
|
496
|
-
const b = i[c * 3], u = i[c * 3 + 2];
|
|
497
|
-
g[c * 3] = b * o - u * l, g[c * 3 + 1] = i[c * 3 + 1], g[c * 3 + 2] = b * l + u * o;
|
|
498
|
-
const w = this.burst[c], A = this.aNamed[c] ? 2.2 : 1.1;
|
|
499
|
-
x[c * 3] = t[c * 3] * A + n[c * 3] * w * 7, x[c * 3 + 1] = t[c * 3 + 1] * A + n[c * 3 + 1] * w * 7, x[c * 3 + 2] = t[c * 3 + 2] * A + n[c * 3 + 2] * w * 7, R[c] = (this.aNamed[c] ? 1.25 : 0.75) * (1 + w * 3.5);
|
|
500
|
-
}
|
|
501
|
-
gt(this.anchorGeo);
|
|
502
|
-
const G = this.edgeGeo.getAttribute("position").array, d = this.edgeGeo.getAttribute("color").array, y = this.edgeA, C = this.nEdge * 2;
|
|
503
|
-
for (let c = 0; c < C; c++) {
|
|
504
|
-
const b = y[c], u = y[c ^ 1], w = i[b * 3], A = i[b * 3 + 2];
|
|
505
|
-
G[c * 3] = w * o - A * l, G[c * 3 + 1] = i[b * 3 + 1], G[c * 3 + 2] = w * l + A * o;
|
|
506
|
-
const m = Math.max(this.burst[b], this.burst[u] * 0.6);
|
|
507
|
-
d[c * 3] = t[b * 3] * 0.32 + 0.05 + n[b * 3] * m * 3, d[c * 3 + 1] = t[b * 3 + 1] * 0.32 + 0.06 + n[b * 3 + 1] * m * 3, d[c * 3 + 2] = t[b * 3 + 2] * 0.32 + 0.1 + n[b * 3 + 2] * m * 3;
|
|
508
|
-
}
|
|
509
|
-
this.edgeGeo.getAttribute("color").needsUpdate = !0, this.edgeGeo.getAttribute("position").needsUpdate = !0;
|
|
510
|
-
}
|
|
511
|
-
updateRunCurrents(e, a) {
|
|
512
|
-
const r = j(this.runGeo, "position"), s = j(this.runGeo, "acol"), o = j(this.runGeo, "size"), l = a * ot, h = this.stTh, i = this.stB;
|
|
513
|
-
for (let t = 0; t < B; t++) {
|
|
514
|
-
const n = this.runRef[t], g = this.rAlpha[t], x = t * J;
|
|
515
|
-
if (!n || g < 0.01) {
|
|
516
|
-
for (let A = 0; A < J; A++) o[x + A] = 0;
|
|
517
|
-
continue;
|
|
518
|
-
}
|
|
519
|
-
const R = this.rX[t], S = this.rZ[t], G = this.rR[t];
|
|
520
|
-
for (let A = 0; A < 3; A++) {
|
|
521
|
-
const m = this.rAt[t * 6 + A * 2] - R, F = this.rAt[t * 6 + A * 2 + 1] - S;
|
|
522
|
-
h[A] = m * m + F * F < 0.6 ? -Math.PI / 2 : Math.atan2(F, m);
|
|
523
|
-
const k = Bt(n, A);
|
|
524
|
-
i[A] = this.rSteps[t] ? k === "running" ? 2.2 : k === "done" ? 0.5 : 0 : 0;
|
|
525
|
-
}
|
|
526
|
-
const d = (e - n.handoffAt) / 1e3, y = this.rSteps[t] === 1 && n.handoffAt > 0 && d < 2.4, C = h[n.handoffFrom];
|
|
527
|
-
let c = (h[n.handoffTo] - C) % Y;
|
|
528
|
-
c < 0 && (c += Y);
|
|
529
|
-
const b = c * Math.min(1, 1 - Math.pow(1 - Math.min(1, d / 1.4), 3)), u = y ? 3.2 * (1 - d / 2.4) : 0, w = this.rCol[t];
|
|
530
|
-
for (let A = 0; A < J; A++) {
|
|
531
|
-
const m = x + A, F = this.rTh[m] + l * this.rSp[m], k = G + this.rRr[m] + 0.16 * Math.sin(3 * F + l * 0.6 + m);
|
|
532
|
-
r[m * 3] = R + Math.cos(F) * k, r[m * 3 + 1] = 0.25 + this.rY[m], r[m * 3 + 2] = S + Math.sin(F) * k;
|
|
533
|
-
let O = 0;
|
|
534
|
-
for (let I = 0; I < 3; I++) {
|
|
535
|
-
if (i[I] === 0) continue;
|
|
536
|
-
let L = (F - h[I]) % Y;
|
|
537
|
-
L < -Math.PI ? L += Y : L > Math.PI && (L -= Y), L > Math.PI && (L -= Y), O += i[I] * Math.exp(-L * L * 2.2);
|
|
538
|
-
}
|
|
539
|
-
let T = 0;
|
|
540
|
-
if (y) {
|
|
541
|
-
let I = (F - C) % Y;
|
|
542
|
-
if (I < 0 && (I += Y), I <= b && I <= c + 0.1) {
|
|
543
|
-
const L = Math.exp(-(b - I) * 2.2);
|
|
544
|
-
O += u * (0.4 + L), T = 0.6 * L;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
const _ = Math.exp(-this.rRr[m] * this.rRr[m] * 4), D = g * (0.32 + 0.5 * _ + O);
|
|
548
|
-
s[m * 3] = (w.r + (1 - w.r) * T) * D, s[m * 3 + 1] = (w.g + (1 - w.g) * T) * D, s[m * 3 + 2] = (w.b + (1 - w.b) * T) * D, o[m] = 0.36 + 0.28 * _ + O * 0.12;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
gt(this.runGeo);
|
|
552
|
-
}
|
|
553
|
-
updateStreams(e, a) {
|
|
554
|
-
const r = j(this.streamGeo, "position"), s = j(this.streamGeo, "acol"), o = j(this.streamGeo, "size");
|
|
555
|
-
let l = 0;
|
|
556
|
-
const h = (d, y, C, c, b, u, w) => {
|
|
557
|
-
l >= jt || (r[l * 3] = d, r[l * 3 + 1] = y, r[l * 3 + 2] = C, s[l * 3] = c, s[l * 3 + 1] = b, s[l * 3 + 2] = u, o[l] = w, l++);
|
|
558
|
-
}, i = (d, y, C, c, b) => {
|
|
559
|
-
const u = (d.x + y.x) / 2, w = (d.y + y.y) / 2 + C, A = (d.z + y.z) / 2, m = 1 - c;
|
|
560
|
-
return b.set(m * m * d.x + 2 * m * c * u + c * c * y.x, m * m * d.y + 2 * m * c * w + c * c * y.y, m * m * d.z + 2 * m * c * A + c * c * y.z);
|
|
561
|
-
};
|
|
562
|
-
for (let d = 0; d < B; d++) {
|
|
563
|
-
const y = this.runRef[d];
|
|
564
|
-
if (!y || !y.handoffAt) continue;
|
|
565
|
-
const C = (e - y.handoffAt) / 1e3;
|
|
566
|
-
if (C > 2.4 || !this.rSteps[d] || this.rAlpha[d] < 0.01) continue;
|
|
567
|
-
this.attractor(d, y.handoffFrom, v), this.attractor(d, y.handoffTo, N);
|
|
568
|
-
const c = this.rCol[d], b = 220;
|
|
569
|
-
for (let u = 0; u < b; u++) {
|
|
570
|
-
const w = (C - u / b * 1.4) / 0.9;
|
|
571
|
-
if (w < 0 || w > 1) continue;
|
|
572
|
-
i(v, N, 2.2, w, E);
|
|
573
|
-
const A = Math.sin(w * Math.PI) * 0.35, m = (1 - w * 0.4) * 2.4;
|
|
574
|
-
h(E.x + (K(u) - 0.5) * A, E.y + (K(u + 7) - 0.5) * A, E.z + (K(u + 13) - 0.5) * A, (c.r * 0.6 + 0.4) * m, (c.g * 0.6 + 0.4) * m, (c.b * 0.6 + 0.4) * m, 0.7 + (u % 9 === 0 ? 0.8 : 0));
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
for (const d of W.comets) {
|
|
578
|
-
const y = this.slotOf(d.from), C = this.slotOf(d.to);
|
|
579
|
-
if (!y || !C) continue;
|
|
580
|
-
const c = Math.min(1, (e - d.start) / d.dur), b = c < 0.5 ? 2 * c * c : 1 - Math.pow(-2 * c + 2, 2) / 2;
|
|
581
|
-
v.set(y.x, y.y, y.z), N.set(C.x, C.y, C.z);
|
|
582
|
-
const u = v.distanceTo(N), w = y.inst ? Rt[y.inst.type] : H, A = c >= 1 ? Math.max(0, 1 - (e - d.start - d.dur) / 250) : 1;
|
|
583
|
-
for (let m = 0; m < 90; m++) {
|
|
584
|
-
const F = b - m * 55e-4;
|
|
585
|
-
if (F < 0) break;
|
|
586
|
-
i(v, N, 1.2 + u * 0.16, F, E);
|
|
587
|
-
const k = m * 6e-3, O = (m === 0 ? 7 : 3.2 * Math.pow(1 - m / 90, 1.6)) * A;
|
|
588
|
-
h(E.x + (K(d.id + m) - 0.5) * k, E.y + (K(d.id * 3 + m) - 0.5) * k, E.z + (K(d.id * 7 + m) - 0.5) * k, (w.r * 0.7 + 0.3) * O, (w.g * 0.7 + 0.3) * O, (w.b * 0.7 + 0.3) * O, m === 0 ? 2.6 : 0.85 - m * 6e-3);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
const t = this.beamGeo.getAttribute("position").array, n = this.beamGeo.getAttribute("color").array;
|
|
592
|
-
let g = 0;
|
|
593
|
-
const x = (d, y, C, c, b, u, w, A, m, F, k, O) => {
|
|
594
|
-
t.set([d, y, C, c, b, u], g * 6), n.set([w, A, m, F, k, O], g * 6), g++;
|
|
595
|
-
}, R = this.nAnchors > 0 && Z.graphWanted && Z.graph.mix > 0.05;
|
|
596
|
-
for (const d of W.flares) {
|
|
597
|
-
if (!R || g >= Wt) break;
|
|
598
|
-
const y = this.slotOf(d.instance);
|
|
599
|
-
if (!y) continue;
|
|
600
|
-
const C = (e - d.start) / 2600;
|
|
601
|
-
if (C >= 1) continue;
|
|
602
|
-
this.anchorWorld(this.anchorIdx(d.node), N), v.set(y.x, y.y, y.z);
|
|
603
|
-
const c = d.op === "write", b = c ? H : y.inst ? Rt[y.inst.type] : H, u = (1 - C) * (c ? 1.6 : 1);
|
|
604
|
-
x(v.x, v.y, v.z, N.x, N.y, N.z, b.r * u * 0.6, b.g * u * 0.6, b.b * u * 0.6, b.r * u * 1.4, b.g * u * 1.4, b.b * u * 1.4);
|
|
605
|
-
for (let w = 0; w < 22; w++) {
|
|
606
|
-
let A = ((e - d.start) / 1e3 * 0.75 + w / 22) % 1;
|
|
607
|
-
c || (A = 1 - A), i(v, N, 1.2, A, E);
|
|
608
|
-
const m = 2.4 * u * Math.sin(A * Math.PI);
|
|
609
|
-
h(E.x, E.y, E.z, b.r * m, b.g * m, b.b * m, 0.55);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
for (const d of W.mcpCalls) {
|
|
613
|
-
const y = this.slotOf(d.instance), C = W.mcpServers.get(d.server), c = Dt(d.server);
|
|
614
|
-
if (!y || !C || !c) continue;
|
|
615
|
-
const b = (e - d.start) / d.dur;
|
|
616
|
-
if (b > 1) continue;
|
|
617
|
-
v.set(y.x, y.y, y.z), N.copy(c).setY(Mt);
|
|
618
|
-
const u = d.phase === "call" ? v : N, w = d.phase === "call" ? N : v;
|
|
619
|
-
z.set(C.color);
|
|
620
|
-
const A = 1 - Math.pow(1 - b, 2);
|
|
621
|
-
for (let m = 0; m < 60; m++) {
|
|
622
|
-
const F = A - m * 8e-3;
|
|
623
|
-
if (F < 0) break;
|
|
624
|
-
i(u, w, 3, F, E);
|
|
625
|
-
const k = (m === 0 ? 6 : 2.6 * (1 - m / 60)) * (d.phase === "result" ? 1.2 : 1);
|
|
626
|
-
h(E.x, E.y, E.z, (z.r * 0.75 + 0.25) * k, (z.g * 0.75 + 0.25) * k, (z.b * 0.75 + 0.25) * k, m === 0 ? 2.2 : 0.7);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
let S = 0;
|
|
630
|
-
const G = (d, y, C, c) => {
|
|
631
|
-
if (S >= Xt) return;
|
|
632
|
-
const b = this.slotOf(d), u = W.mcpServers.get(y), w = Dt(y);
|
|
633
|
-
if (!b || !u || !w) return;
|
|
634
|
-
S++, v.set(b.x, b.y, b.z), N.copy(w).setY(Mt), z.set(u.color), C < 2 ? z.lerp(re, Math.min(1, C / 2)) : z.copy(re).lerp(Xe, Math.min(1, C - 2));
|
|
635
|
-
const A = c >= 0 ? (1 - c) * 1.2 : 0.5 + Math.min(1.8, C * 0.6), m = a * 2.2;
|
|
636
|
-
let F = v.x, k = v.y, O = v.z;
|
|
637
|
-
for (let T = 1; T <= Pt; T++) {
|
|
638
|
-
const _ = T / Pt;
|
|
639
|
-
i(v, N, 3, _, E);
|
|
640
|
-
const D = 0.5 + 0.5 * Math.sin((_ * 9 - m) * Y * 0.5), I = A * (0.25 + 0.75 * D * D);
|
|
641
|
-
g < Wt + Xt * Pt && x(F, k, O, E.x, E.y, E.z, z.r * I, z.g * I, z.b * I, z.r * I, z.g * I, z.b * I), F = E.x, k = E.y, O = E.z;
|
|
642
|
-
}
|
|
643
|
-
if (c < 0) {
|
|
644
|
-
const T = 5 + Math.min(8, Math.floor(C * 3));
|
|
645
|
-
for (let _ = 0; _ < T; _++) {
|
|
646
|
-
const D = (a * (0.45 + C * 0.15) + _ / T) % 1;
|
|
647
|
-
i(v, N, 3, D, E);
|
|
648
|
-
const I = A * 0.9;
|
|
649
|
-
h(E.x, E.y, E.z, z.r * I, z.g * I, z.b * I, 0.8);
|
|
650
|
-
}
|
|
651
|
-
} else {
|
|
652
|
-
const T = 1 - Math.min(1, c * 1.6);
|
|
653
|
-
for (let _ = 0; _ < 26; _++) {
|
|
654
|
-
const D = T + _ * 0.012;
|
|
655
|
-
if (D > 1) break;
|
|
656
|
-
i(v, N, 3, D, E);
|
|
657
|
-
const I = (_ === 0 ? 9 : 4 * (1 - _ / 26)) * (1 - c * 0.5);
|
|
658
|
-
h(E.x, E.y, E.z, 0.6 * I + z.r * I * 0.4, 0.6 * I + z.g * I * 0.4, 0.6 * I + z.b * I * 0.4, _ === 0 ? 2.8 : 0.9);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
for (const d of W.mcpPending.values()) G(d.instance, d.server, oe(d, e), -1);
|
|
663
|
-
for (const d of W.mcpResolved) G(d.instance, d.server, (d.resolvedAt - d.since) / 1e3, Math.min(1, (e - d.resolvedAt) / 700));
|
|
664
|
-
for (let d = l; d < jt && o[d] !== 0; d++)
|
|
665
|
-
o[d] = 0;
|
|
666
|
-
this.streamGeo.setDrawRange(0, Math.max(l, 1)), gt(this.streamGeo), this.beamGeo.setDrawRange(0, g * 2), this.beamGeo.getAttribute("position").needsUpdate = !0, this.beamGeo.getAttribute("color").needsUpdate = !0;
|
|
667
|
-
}
|
|
668
|
-
setInst(e, a, r, s, o, l, h, i = 0, t = 0, n = 0) {
|
|
669
|
-
tt.position.set(r, s, o), tt.rotation.set(i, t, n), tt.scale.setScalar(Math.max(1e-4, l)), tt.updateMatrix(), e.setMatrixAt(a, tt.matrix), e.setColorAt(a, h);
|
|
670
|
-
}
|
|
671
|
-
updateMeshes(e, a, r) {
|
|
672
|
-
const s = j(this.glowGeo, "position"), o = j(this.glowGeo, "acol"), l = j(this.glowGeo, "size"), h = (t, n, g, x, R, S, G) => {
|
|
673
|
-
s[t * 3] = n, s[t * 3 + 1] = g, s[t * 3 + 2] = x, o[t * 3] = R.r * S, o[t * 3 + 1] = R.g * S, o[t * 3 + 2] = R.b * S, l[t] = G;
|
|
674
|
-
};
|
|
675
|
-
let i = null;
|
|
676
|
-
for (let t = 0; t < q; t++) {
|
|
677
|
-
const n = this.slots[t];
|
|
678
|
-
if (!n.used || !n.inst) {
|
|
679
|
-
this.setInst(this.cores, t, 0, -999, 0, 0, z.setRGB(0, 0, 0)), l[t] = 0;
|
|
680
|
-
continue;
|
|
681
|
-
}
|
|
682
|
-
n.id === this.selectedId && (i = n);
|
|
683
|
-
const g = n.inst, x = (e - g.bornAt) / 1e3, R = Math.exp(-x * 3.5), S = g.exitAt ? (e - g.exitAt) / 1e3 : -1, G = S >= 0 ? Math.exp(-S * 5) : 0, y = g.status === "thinking" && !g.exitAt ? 0.1 * Math.sin(a * 9 + t) : 0, C = S >= 0 ? Math.pow(n.p, 1.6) : n.p, c = st.scale, b = (C * (1 + n.e * 0.45 + y) + G * 0.9 + R * 0.6) * c;
|
|
684
|
-
z.setRGB(n.r, n.g, n.b).multiplyScalar(1.3 + n.bright * 1.5 + n.e * 1.1), z.lerp(Q.setRGB(4, 4, 4), Math.min(1, R + G)), this.setInst(this.cores, t, n.x, n.y, n.z, b, z, a * n.omega * 0.3, a * n.omega, 0), z.setRGB(n.r, n.g, n.b), h(t, n.x, n.y, n.z, z, (0.3 + n.bright * 0.4 + n.e * 0.5 + R * 2 + G * 2.5) * n.p + G, (5 + n.e * 4 + R * 10 + G * 14) * Math.max(n.p, G) * c);
|
|
685
|
-
}
|
|
686
|
-
i ? (this.selRing.visible = !0, this.selRing.position.set(i.x, i.y, i.z), this.selRing.rotation.y = a * 1.5, this.selRing.scale.setScalar(1 + 0.08 * Math.sin(a * 4)), this.selRing.material.color.setRGB(i.r * 3, i.g * 3, i.b * 3)) : this.selRing.visible = !1;
|
|
687
|
-
for (let t = 0; t < B; t++) {
|
|
688
|
-
const n = this.runRef[t], g = this.rAlpha[t];
|
|
689
|
-
for (let x = 0; x < 3; x++) {
|
|
690
|
-
const R = t * 3 + x, S = q + R;
|
|
691
|
-
if (!n || g < 0.01 || !this.rSteps[t]) {
|
|
692
|
-
this.setInst(this.attractors, R, 0, -999, 0, 0, z.setRGB(0, 0, 0)), this.setInst(this.stepRings, R, 0, -999, 0, 0, z), l[S] = 0;
|
|
693
|
-
continue;
|
|
694
|
-
}
|
|
695
|
-
this.attractor(t, x, v);
|
|
696
|
-
const G = Bt(n, x), d = this.rCol[t];
|
|
697
|
-
let y = 0.6, C = 0.5, c = 0.25, b = 0.9, u = 0.12, w = 4;
|
|
698
|
-
if (z.copy(d), G === "running") {
|
|
699
|
-
const A = 0.5 + 0.5 * Math.sin(a * 5);
|
|
700
|
-
y = 1.15 + A * 0.2, z.lerp(H, 0.45), C = 3 + A * 1.5, c = 1.4 + A, b = 1.15 + A * 0.25, u = 1.1 + A * 0.6, w = 12;
|
|
701
|
-
} else G === "done" ? (y = 0.85, C = 1.8, c = 0.7, b = 0.95, u = 0.4, w = 6) : G === "failed" && z.copy(Ye);
|
|
702
|
-
if (n.handoffAt && x === n.handoffTo) {
|
|
703
|
-
const A = (e - n.handoffAt) / 1e3 - 1.2;
|
|
704
|
-
if (A > 0 && A < 1) {
|
|
705
|
-
const m = Math.exp(-A * 4);
|
|
706
|
-
y += m * 0.8, u += m * 2, w += m * 10;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
Q.copy(z).multiplyScalar(C * g), this.setInst(this.attractors, R, v.x, v.y, v.z, y, Q, 0, a * 0.6, 0), Q.copy(z).multiplyScalar(c * g), this.setInst(this.stepRings, R, v.x, v.y, v.z, b, Q, 0, G === "running" ? a * 1.6 : 0.3, 0), h(S, v.x, v.y, v.z, z, u * g, w);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
for (let t = 0; t < dt; t++) {
|
|
713
|
-
const n = q + B * 3 + t;
|
|
714
|
-
this.setInst(this.pulsars, t, 0, -999, 0, 0, z.setRGB(0, 0, 0)), this.setInst(this.pulsarBeams, t, 0, -999, 0, 0, z), l[n] = 0;
|
|
715
|
-
}
|
|
716
|
-
for (const t of W.mcpServers.values()) {
|
|
717
|
-
const n = t.slot % dt, g = q + B * 3 + n, x = Dt(t.name);
|
|
718
|
-
if (!x) continue;
|
|
719
|
-
v.copy(x).setY(Mt);
|
|
720
|
-
const R = Yt(t.activeAt, e, 2.5), S = t.inflight > 0 ? 1 : 0;
|
|
721
|
-
this.mcpSpin[n] += r * (0.4 + S * 3.5) * ot;
|
|
722
|
-
const G = 0.5 + 0.5 * Math.sin(a * (S ? 9 : 2.2) + n);
|
|
723
|
-
z.set(t.color), Q.copy(z).multiplyScalar(1.6 + S * 1.6 + R * 3 + G * 0.6), this.setInst(this.pulsars, n, v.x, v.y, v.z, 1 + R * 0.6 + S * 0.2 * G, Q, 0, this.mcpSpin[n], 0), Q.copy(z).multiplyScalar(0.25 + S * 0.9 * G + R * 0.8), this.setInst(this.pulsarBeams, n, v.x, v.y, v.z, 1 + S * 0.3, Q, 0.5 * Math.sin(this.mcpSpin[n] * 0.5), this.mcpSpin[n], 0.35 + 0.3 * Math.cos(this.mcpSpin[n])), h(g, v.x, v.y, v.z, z, 0.6 + S * 0.8 * G + R * 1.6, 9 + R * 12 + S * 4);
|
|
724
|
-
}
|
|
725
|
-
for (let t = 0; t < rt; t++) {
|
|
726
|
-
const n = (e - this.ringStart[t]) / (this.ringDur[t] * 1e3);
|
|
727
|
-
if (n < 0 || n >= 1) {
|
|
728
|
-
this.setInst(this.rings, t, 0, -999, 0, 0, z.setRGB(0, 0, 0));
|
|
729
|
-
continue;
|
|
730
|
-
}
|
|
731
|
-
const g = 1 - Math.pow(1 - n, 3), x = (1 - n) * (1 - n);
|
|
732
|
-
z.setRGB(this.ringCol[t * 3] * x, this.ringCol[t * 3 + 1] * x, this.ringCol[t * 3 + 2] * x), this.setInst(this.rings, t, this.ringPos[t * 3], this.ringPos[t * 3 + 1], this.ringPos[t * 3 + 2], 0.15 + this.ringMax[t] * g, z);
|
|
733
|
-
}
|
|
734
|
-
for (const t of [this.cores, this.attractors, this.stepRings, this.rings, this.pulsars, this.pulsarBeams])
|
|
735
|
-
t.instanceMatrix.needsUpdate = !0, t.instanceColor && (t.instanceColor.needsUpdate = !0);
|
|
736
|
-
gt(this.glowGeo);
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
const ft = new M.Vector3(), Ke = ["planner", "researcher", "writer"], at = { engine: null }, Kt = () => at.engine ?? (at.engine = new qe());
|
|
740
|
-
function Ve() {
|
|
741
|
-
const f = Kt(), e = Me((r) => r.gl), a = Ee();
|
|
742
|
-
return St(() => {
|
|
743
|
-
f.setGalaxy(a);
|
|
744
|
-
}, [f, a]), St(() => {
|
|
745
|
-
f.material.uniforms.uPR.value = e.getPixelRatio(), f.nebMaterial.uniforms.uPR.value = e.getPixelRatio();
|
|
746
|
-
}, [f, e]), St(
|
|
747
|
-
() => () => {
|
|
748
|
-
f.dispose(), at.engine === f && (at.engine = null);
|
|
749
|
-
},
|
|
750
|
-
[f]
|
|
751
|
-
), nt((r, s) => {
|
|
752
|
-
f.update(s, performance.now(), r.clock.elapsedTime);
|
|
753
|
-
}), /* @__PURE__ */ ct("group", { children: [
|
|
754
|
-
/* @__PURE__ */ P("points", { geometry: f.fieldGeo, material: f.material, frustumCulled: !1 }),
|
|
755
|
-
/* @__PURE__ */ P("points", { geometry: f.runGeo, material: f.material, frustumCulled: !1 }),
|
|
756
|
-
/* @__PURE__ */ P("points", { geometry: f.streamGeo, material: f.material, frustumCulled: !1 }),
|
|
757
|
-
/* @__PURE__ */ P("points", { geometry: f.glowGeo, material: f.material, frustumCulled: !1 }),
|
|
758
|
-
/* @__PURE__ */ P("lineSegments", { geometry: f.beamGeo, frustumCulled: !1, children: /* @__PURE__ */ P("lineBasicMaterial", { vertexColors: !0, transparent: !0, blending: M.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) }),
|
|
759
|
-
/* @__PURE__ */ P("primitive", { object: f.cores }),
|
|
760
|
-
/* @__PURE__ */ P("primitive", { object: f.attractors }),
|
|
761
|
-
/* @__PURE__ */ P("primitive", { object: f.stepRings }),
|
|
762
|
-
/* @__PURE__ */ P("primitive", { object: f.rings }),
|
|
763
|
-
/* @__PURE__ */ P("primitive", { object: f.pulsars }),
|
|
764
|
-
/* @__PURE__ */ P("primitive", { object: f.pulsarBeams }),
|
|
765
|
-
/* @__PURE__ */ P("primitive", { object: f.selRing })
|
|
766
|
-
] });
|
|
767
|
-
}
|
|
768
|
-
function Ze({ agent: f, selected: e, onSelect: a }) {
|
|
769
|
-
const r = V(null);
|
|
770
|
-
return St(() => {
|
|
771
|
-
const s = Kt();
|
|
772
|
-
e ? s.selectedId = f.id : s.selectedId === f.id && (s.selectedId = null);
|
|
773
|
-
}, [e, f.id]), St(
|
|
774
|
-
() => () => {
|
|
775
|
-
const s = at.engine;
|
|
776
|
-
s && s.selectedId === f.id && (s.selectedId = null);
|
|
777
|
-
},
|
|
778
|
-
[f.id]
|
|
779
|
-
), nt(() => {
|
|
780
|
-
const s = r.current;
|
|
781
|
-
s && (s.position.copy(f.live), s.scale.setScalar(Math.max(0.6, st.scale) * (f.depth ? 0.8 : 1)), s.visible = !f.inst.exitAt);
|
|
782
|
-
}), /* @__PURE__ */ ct(
|
|
783
|
-
"mesh",
|
|
784
|
-
{
|
|
785
|
-
ref: r,
|
|
786
|
-
onClick: (s) => (s.stopPropagation(), a(f.id)),
|
|
787
|
-
onPointerOver: () => document.body.style.cursor = "pointer",
|
|
788
|
-
onPointerOut: () => document.body.style.cursor = "",
|
|
789
|
-
children: [
|
|
790
|
-
/* @__PURE__ */ P("sphereGeometry", { args: [0.95, 10, 8] }),
|
|
791
|
-
/* @__PURE__ */ P("meshBasicMaterial", { transparent: !0, opacity: 0, depthWrite: !1, colorWrite: !1 })
|
|
792
|
-
]
|
|
793
|
-
}
|
|
794
|
-
);
|
|
795
|
-
}
|
|
796
|
-
function $e({ run: f }) {
|
|
797
|
-
Fe();
|
|
798
|
-
const e = f.run ?? W.runs.get(f.id), a = V(null), r = V([]);
|
|
799
|
-
if (nt(() => {
|
|
800
|
-
var h;
|
|
801
|
-
(h = a.current) == null || h.position.set(f.origin.x, 0.6, f.origin.z - Math.min(11, Math.hypot(f.hu, f.hv) * 0.92 + 0.6) - 1.3);
|
|
802
|
-
for (let i = 0; i < 3; i++) {
|
|
803
|
-
const t = r.current[i];
|
|
804
|
-
t && (le(f, he(Ke[i]), 0, ft), t.position.set(ft.x, 1.45 * Math.max(0.85, st.scale), ft.z + 0.9 * st.spread));
|
|
805
|
-
}
|
|
806
|
-
}), !e) return null;
|
|
807
|
-
const s = st.w < 900, o = (h) => h === "running" ? e.color : h === "done" ? "#cbd5e1" : h === "failed" ? "#fecaca" : "#64748b", l = () => {
|
|
808
|
-
const { shown: h, more: i } = Te(e), t = h.map((n, g) => ({ text: `${g ? " " : ""}${n.toUpperCase()}`, color: o(e.steps[n]) }));
|
|
809
|
-
return i && t.push({ text: ` +${i}`, color: o("queued") }), t;
|
|
810
|
-
};
|
|
811
|
-
return /* @__PURE__ */ ct(ce, { children: [
|
|
812
|
-
/* @__PURE__ */ P("group", { ref: a, children: /* @__PURE__ */ P(
|
|
813
|
-
yt,
|
|
814
|
-
{
|
|
815
|
-
text: `${e.hasSteps ? "hatchet · " : ""}${e.topic}`,
|
|
816
|
-
secondary: s ? void 0 : e.hasSteps ? l() : e.status === "started" ? "running…" : "run complete",
|
|
817
|
-
secondarySize: 0.24,
|
|
818
|
-
color: e.color,
|
|
819
|
-
size: 0.32,
|
|
820
|
-
maxWidth: s ? 5 : 7,
|
|
821
|
-
fadeMs: 300,
|
|
822
|
-
pxRange: [10, 14]
|
|
823
|
-
}
|
|
824
|
-
) }),
|
|
825
|
-
e.hasSteps && !s && Be.map((h) => /* @__PURE__ */ P("group", { ref: (i) => void (r.current[h] = i), children: /* @__PURE__ */ P(
|
|
826
|
-
yt,
|
|
827
|
-
{
|
|
828
|
-
text: Oe(e, h),
|
|
829
|
-
font: "mono",
|
|
830
|
-
plate: "none",
|
|
831
|
-
uppercase: !0,
|
|
832
|
-
letterSpacing: 0.08,
|
|
833
|
-
textColor: e.color,
|
|
834
|
-
size: 0.24,
|
|
835
|
-
opacity: Bt(e, h) === "running" ? 1 : Bt(e, h) === "done" ? 0.75 : 0.55,
|
|
836
|
-
fadeMs: 300,
|
|
837
|
-
pxRange: [7.5, 10.5]
|
|
838
|
-
}
|
|
839
|
-
) }, h))
|
|
840
|
-
] });
|
|
841
|
-
}
|
|
842
|
-
function He({ mcp: f }) {
|
|
843
|
-
const e = V(null), a = f.target.x >= 0;
|
|
844
|
-
return nt(() => {
|
|
845
|
-
var r;
|
|
846
|
-
return (r = e.current) == null ? void 0 : r.position.set(f.pos.x + (a ? 0.9 : -0.9), Mt, f.pos.z);
|
|
847
|
-
}), /* @__PURE__ */ P("group", { ref: e, children: /* @__PURE__ */ P(yt, { text: `mcp · ${f.name}`, anchorX: a ? "left" : "right", color: f.srv.color, size: 0.28, pxRange: [8.5, 12] }) });
|
|
848
|
-
}
|
|
849
|
-
const ue = new M.IcosahedronGeometry(0.34, 0), Je = new M.EdgesGeometry(ue);
|
|
850
|
-
function Qe({ mcp: f, backend: e }) {
|
|
851
|
-
const a = e.res, r = V(null), s = V(null), o = mt(() => new M.Color(f.srv.color), [f.srv.color]), l = mt(
|
|
852
|
-
() => ({
|
|
853
|
-
fill: new M.MeshBasicMaterial({ color: o, transparent: !0, opacity: 0.55, blending: M.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
|
|
854
|
-
line: new M.LineBasicMaterial({ color: o, transparent: !0, blending: M.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
|
|
855
|
-
}),
|
|
856
|
-
[o]
|
|
857
|
-
);
|
|
858
|
-
nt(({ clock: i }, t) => {
|
|
859
|
-
var G, d;
|
|
860
|
-
const n = r.current;
|
|
861
|
-
if (!n) return;
|
|
862
|
-
n.position.set(e.pos.x, Mt, e.pos.z);
|
|
863
|
-
const g = performance.now(), x = a.inflight > 0, R = Yt(a.activeAt, g, 2.5), S = x ? 0.5 + 0.5 * Math.sin(i.elapsedTime * 9) : 0;
|
|
864
|
-
n.rotation.y += t * (0.4 + (x ? 3 : 0) + R) * (ut ? 0.3 : 1), n.scale.setScalar(1 + R * 0.35 + S * 0.15), l.fill.color.copy(o).multiplyScalar(0.5 + R * 1.6 + S), l.line.color.copy(o).multiplyScalar(1.2 + R * 2.4 + S * 1.5), (G = s.current) == null || G.setOpacity(x ? 1 : 0.6 + R * 0.4), (d = s.current) == null || d.setEmphasis(x);
|
|
865
|
-
});
|
|
866
|
-
const h = e.target.x >= 0;
|
|
867
|
-
return /* @__PURE__ */ ct(ce, { children: [
|
|
868
|
-
/* @__PURE__ */ P(Le, { mcp: f, backend: e, y: Mt, lift: 0.5, wave: 0.12, gain: 1.3 }),
|
|
869
|
-
/* @__PURE__ */ ct("group", { ref: r, children: [
|
|
870
|
-
/* @__PURE__ */ P("mesh", { geometry: ue, material: l.fill }),
|
|
871
|
-
/* @__PURE__ */ P("lineSegments", { geometry: Je, material: l.line }),
|
|
872
|
-
/* @__PURE__ */ P("group", { position: [h ? 0.6 : -0.6, 0, 0], children: /* @__PURE__ */ P(yt, { ref: s, text: a.name, anchorX: h ? "left" : "right", color: f.srv.color, size: 0.24, opacity: 0.6, pxRange: [7.5, 11] }) })
|
|
873
|
-
] })
|
|
874
|
-
] });
|
|
875
|
-
}
|
|
876
|
-
function ts(f) {
|
|
877
|
-
const e = Kt();
|
|
878
|
-
return nt(() => {
|
|
879
|
-
e.nebMaterial.uniforms.uScale.value = e.material.uniforms.uScale.value * Z.graph.scale;
|
|
880
|
-
}), /* @__PURE__ */ ct("group", { children: [
|
|
881
|
-
/* @__PURE__ */ P("points", { geometry: e.nebGeo, material: e.nebMaterial, frustumCulled: !1 }),
|
|
882
|
-
/* @__PURE__ */ P("points", { geometry: e.anchorGeo, material: e.nebMaterial, frustumCulled: !1 }),
|
|
883
|
-
/* @__PURE__ */ P("lineSegments", { geometry: e.edgeGeo, frustumCulled: !1, children: /* @__PURE__ */ P("lineBasicMaterial", { vertexColors: !0, transparent: !0, blending: M.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) }),
|
|
884
|
-
/* @__PURE__ */ P(Pe, { position: [0, -0.6, qt + 0.9], color: "#a5b4fc", size: 0.34, pxRange: [9.5, 13] })
|
|
885
|
-
] });
|
|
886
|
-
}
|
|
887
|
-
function es() {
|
|
888
|
-
const f = V(null), e = V(null), a = V("");
|
|
889
|
-
return nt(() => {
|
|
890
|
-
var i;
|
|
891
|
-
const r = at.engine;
|
|
892
|
-
if (!r) return;
|
|
893
|
-
const s = r.selectedId ?? W.focus, o = s ? r.slotOf(s) : null, l = !!o && !!o.inst && !o.inst.exitAt;
|
|
894
|
-
if ((i = e.current) == null || i.setOpacity(l ? 1 : 0), !o || !o.inst || !f.current || !e.current) return;
|
|
895
|
-
f.current.position.set(o.x, o.y + 1.25 * Math.max(0.85, st.scale), o.z);
|
|
896
|
-
const h = o.inst.name + " · " + o.inst.status;
|
|
897
|
-
h !== a.current && (a.current = h, e.current.setText(h), e.current.setColor(fe[o.inst.type]));
|
|
898
|
-
}), /* @__PURE__ */ P("group", { ref: f, children: /* @__PURE__ */ P(yt, { ref: e, text: "", size: 0.3, opacity: 0, fadeMs: 300, pxRange: [9, 13], renderOrder: 24 }) });
|
|
899
|
-
}
|
|
900
|
-
function ss() {
|
|
901
|
-
const f = V(null), e = V(null), a = V("");
|
|
902
|
-
return nt(() => {
|
|
903
|
-
const r = at.engine, s = r == null ? void 0 : r.lastFlare;
|
|
904
|
-
if (!r || !s || !f.current || !e.current) return;
|
|
905
|
-
const o = (performance.now() - s.at) / 1e3;
|
|
906
|
-
e.current.setOpacity(o < 2.2 && Z.graphWanted ? 1 : 0), r.anchorWorld(s.idx, ft), f.current.position.set(ft.x, ft.y + 0.9, ft.z), a.current !== s.name + s.op && (a.current = s.name + s.op, e.current.setText((s.op === "write" ? "wrote · " : "read · ") + s.name), e.current.setColor(s.op === "write" ? "#ffffff" : "#a5b4fc"));
|
|
907
|
-
}), /* @__PURE__ */ P("group", { ref: f, children: /* @__PURE__ */ P(yt, { ref: e, text: "", size: 0.28, opacity: 0, fadeMs: 400, pxRange: [8.5, 12], renderOrder: 24 }) });
|
|
908
|
-
}
|
|
909
|
-
function ls() {
|
|
910
|
-
const f = mt(() => ({ nRef: 4, min: 0.62, max: 1.45, minRadius: 7 }), []);
|
|
911
|
-
return /* @__PURE__ */ ct(
|
|
912
|
-
Ie,
|
|
913
|
-
{
|
|
914
|
-
title: "flow · murmuration",
|
|
915
|
-
subtitle: "agents are eddies condensing out of the current · hatchet runs are vortices · the knowledge graph is a nebula current on the side",
|
|
916
|
-
preset: "drift",
|
|
917
|
-
plane: "xz",
|
|
918
|
-
camera: { position: [0, 25, 28], fov: 50 },
|
|
919
|
-
controls: { maxPolarAngle: Math.PI * 0.47 },
|
|
920
|
-
bg: "#020309",
|
|
921
|
-
gl: { antialias: !1 },
|
|
922
|
-
fit: f,
|
|
923
|
-
agentRadius: 1.6,
|
|
924
|
-
graph: { natural: qt, radius: 3.6 },
|
|
925
|
-
peripheryGap: 4.5,
|
|
926
|
-
Agent: Ze,
|
|
927
|
-
RunMarker: $e,
|
|
928
|
-
McpServer: He,
|
|
929
|
-
Backend: Qe,
|
|
930
|
-
GraphResource: ts,
|
|
931
|
-
cluster: { radius: 1.7, variant: "swarm", pointSize: 1.1 },
|
|
932
|
-
clusterOffset: [0, 1.8, 0],
|
|
933
|
-
PostFX: /* @__PURE__ */ ct(ye, { multisampling: 0, children: [
|
|
934
|
-
/* @__PURE__ */ P(Ae, { mipmapBlur: !0, intensity: 1.25, luminanceThreshold: 0.22, luminanceSmoothing: 0.25, radius: 0.78 }),
|
|
935
|
-
/* @__PURE__ */ P(be, { eskil: !1, offset: 0.22, darkness: 0.85 }),
|
|
936
|
-
/* @__PURE__ */ P(we, { opacity: 0.03 })
|
|
937
|
-
] }),
|
|
938
|
-
children: [
|
|
939
|
-
/* @__PURE__ */ P(Ve, {}),
|
|
940
|
-
/* @__PURE__ */ P(es, {}),
|
|
941
|
-
/* @__PURE__ */ P(ss, {})
|
|
942
|
-
]
|
|
943
|
-
}
|
|
944
|
-
);
|
|
945
|
-
}
|
|
946
|
-
export {
|
|
947
|
-
ls as default
|
|
948
|
-
};
|