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