Agent Harness · VibeGit
Agent Harness Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
agent-harness / tools / spells-assets / ue / vfx / Bolts.js 421 строк · изменён 6 нояб., 03:45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
import * as THREE from 'three' ;
import { U , ARENA , COMMON_GLSL , ARENA_GLSL , GROUND_GLSL , FX_VERT_HEAD , FX_FRAG_HEAD , FX_OUT_GLSL , FX_BLENDING , LINES_BLENDING , arenaSDF } from './common.js' ;
import { STRIP_GLSL , instanced, put4 } from './Ribbons.js' ;
import { arenaUniforms } from '../scene/arenaMaterial.js' ;
import { Q } from '../engine/quality.js'
s v
w s s s
w w
v
i x k i salt
a k b k
a b a x i
_d _u _v _q
_d
_d
_d
_u _d _d
_v _d _u
n1 n2 amp f freq
k k octaves k
s seed k
n1 amp t f s
n2 amp t f s
amp gain f
k jag t
out t _u n1 k _v n2 k
_q p dx p dy p dz
e d p
_d p e p e p e p e p e p e
p _d d
max
geo
pos index
strand
seg n
j j n j strand
base pos
i i seg i pos i seg strand i seg strand
i i seg i
a base i
index a a a a a a
geo pos
geo index
geo n max
x
geo
geo
s x x
head
geo
head
geo
head
mirror geo
arenaUniforms
head
mirror
mirror
max
index
t out
out out
h
h
h
h
h
h
h
k opts
v opts k
v v h k v v v h k v h k v
h
h
top dirty
a b s c g m e
h
o h on h h h
dirty c o h h h h h h on h dirty
on
top h
dirty a o h h h h dirty
dirty b o h h h h dirty
dirty s o h h h h dirty
dirty g o h h h h h h h dirty
dirty m o h h h h dirty
dirty e o h h h h dirty
dirty x x
top
top
;
const
STRANDS
=
[
{
seg
:
256
,
n
:
1
}
,
{
seg
:
32
,
n
:
8
}
,
{
seg
:
12
,
n
:
12
}
,
]
;
const
MAIN
=
{
freq
:
2
,
octaves
:
7
}
;
const
BOLT_VERT
=
`
in vec4 aA; // a.xyz, seed
in vec4 aB; // b.xyz, branch seed
in vec4 aShape; // branches, sub-branches, jag, core width (m)
in vec4 aCore; // core rgb * intensity, reveal
in vec4 aGlow; // glow rgb * intensity, glow width multiplier
in vec4 aMisc; // snap to arena, octave gain, extra octave, variation along the strand
in vec4 aFx; // return-stroke reach, dart head, branch level, residual
out vec2 vUv; // along the strand, across (-1..1)
out vec3 vColor;
out vec3 vEdge; // the core's saturated sheath
out float vViewZ;
out float vS; // metres along the strand
#ifdef BOLT_MIRROR
out vec3 vW; // mirrored world position
#endif
float gGain = 0.5; // octave gain, per bolt
uint pcg(uint v) {
uint s = v * 747796405u + 2891336453u;
uint w = ((s >> ((s >> 28u) + 4u)) ^ s) * 277803737u;
return (w >> 22u) ^ w;
}
float urand(uint v) { return float(pcg(v)) * (1.0 / 4294967296.0); }
// piecewise-linear value noise on the integer lattice, -1..1
float lnoise(float x, uint salt) {
float i = floor(x);
uint k = uint(i) + salt;
return mix(urand(k), urand(k + 1u), x - i) * 2.0 - 1.0;
}
vec3 perp(vec3 t) { return normalize(cross(t, abs(t.y) < 0.99 ? vec3(0.0, 1.0, 0.0) : vec3(1.0, 0.0, 0.0))); }
// freeEnd 1: envelope sqrt(sin(pi t / 2)) pins only the start, so branch tips wander
vec3 boltPath(vec3 A, vec3 B, float t, uint seed, float jag, float freq, int octaves, float freeEnd) {
vec3 d = B - A;
float L = length(d);
vec3 T = d / max(L, 1e-6), Ub = perp(T), Vb = cross(T, Ub);
float n1 = 0.0, n2 = 0.0, amp = 1.0, f = freq;
for (int k = 0; k < 8; k++) {
if (k >= octaves) break;
uint s = pcg(seed + uint(k) * 0x9E3779B9u);
n1 += amp * lnoise(t * f, s);
n2 += amp * lnoise(t * f, s ^ 0x5bd1e995u);
amp *= gGain; f *= 2.0;
}
float env = sqrt(max(sin(PI * t * (1.0 - 0.5 * freeEnd)), 0.0));
return mix(A, B, t) + (Ub * n1 + Vb * n2) * (L * jag * env);
}
// 25-50 degrees off the parent tangent, random azimuth
vec3 deviate(vec3 T, uint h) {
float th = radians(mix(25.0, 50.0, urand(h + 1u))), ph = 2.0 * PI * urand(h + 2u);
vec3 Ub = perp(T), Vb = cross(T, Ub);
return cos(th) * T + sin(th) * (cos(ph) * Ub + sin(ph) * Vb);
}
// ground-crawl arcs: project onto the nearest arena surface (exact for planes and capsules)
vec3 snapArena(vec3 p) { return p - arenaNormal(p) * (arenaSDF(p) - 0.03); }
void main() {
vUv = vec2(0.0); vColor = vec3(0.0); vEdge = vec3(0.0); vViewZ = 1.0; vS = 0.0;
#ifdef BOLT_MIRROR
vW = vec3(0.0);
if (aShape.w < 0.02) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return; } // only real channels: not arcs hugging the floor
#endif
float t = position.x;
int strand = int(position.z), nb = int(aShape.x), ns = int(aShape.y);
vec3 A = aA.xyz, B = aB.xyz;
uint seed = pcg(uint(aA.w)), bseed = uint(aB.w);
float L = length(B - A), jag = aShape.z, reveal = aCore.w;
gGain = aMisc.y;
float vary = aMisc.w, stroke = aFx.x, dart = aFx.y, res = aFx.w;
// strand frame: main channel, branch off it, or sub-branch off a branch
vec3 sA = A, sB = B;
uint sSeed = seed;
float freq = ${ MAIN . freq . toFixed ( 1 ) } , freeEnd = 0.0, vis = reveal, wMul = 1.0, iMul = 1.0, sJag = jag, len = L, tm = t;
int oct = ${ MAIN . octaves } + int(aMisc.z);
if (strand > 0) {
bool sub = strand > 8;
int bi = sub ? (strand - 9) % max(nb, 1) : strand - 1;
if (sub ? (strand - 9 >= ns || nb == 0) : bi >= nb) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return; }
uint bh = pcg(bseed + uint(bi) * 0x632BE5ABu);
float tb = mix(0.05, 0.75, urand(bh));
tm = tb;
sA = boltPath(A, B, tb, seed, jag, freq, oct, 0.0);
// smoothed parent tangent (the per-segment one is as jagged as the bolt)
vec3 Tm = normalize(boltPath(A, B, tb + 0.05, seed, jag, freq, oct, 0.0) - sA);
len = mix(0.15, 0.4, urand(bh + 3u)) * L;
sB = sA + deviate(Tm, bh) * len;
sSeed = pcg(bh + 4u); freq = 2.0; oct = 5; freeEnd = 1.0; sJag = jag * 1.3;
vis = (reveal - tb) * L / len; // the leader runs on along the branch at the same speed
wMul = 0.55; iMul = 0.45;
if (sub) {
uint sh = pcg(bseed + uint(strand) * 0x2C1B3C6Du);
float ts = mix(0.1, 0.7, urand(sh));
vec3 q0 = boltPath(sA, sB, ts, sSeed, sJag, freq, oct, 1.0);
vec3 Tq = normalize(boltPath(sA, sB, ts + 0.1, sSeed, sJag, freq, oct, 1.0) - q0);
float len2 = mix(0.3, 0.6, urand(sh + 3u)) * len;
vis = (vis - ts) * len / len2;
sA = q0; sB = q0 + deviate(Tq, sh) * len2; len = len2;
sSeed = pcg(sh + 4u); freq = 1.5; oct = 3;
wMul = 0.35; iMul = 0.25;
}
// branches thin and dim towards their tips, and carry far less current than the channel
wMul *= (1.0 - 0.6 * t) * (0.6 + 0.4 * aFx.z); iMul *= (1.0 - 0.7 * t) * aFx.z * (1.0 - res) * (1.0 - res);
}
if (vis <= 0.0) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return; }
// the fronts below ramp over a distance like the ribbon's width, or the wide glow shows a flat cap
#ifdef BOLT_GLOW
float soft = 1.5;
#else
float soft = 0.25;
#endif
// return stroke: lit up from the ground end, its front burning hottest; a dim leader above it
if (stroke < 1.0) {
float below = (tm - (1.0 - stroke)) * L;
iMul *= mix(0.1, 1.0 + 3.0 * exp(-max(below, 0.0) / 1.5), smoothstep(-soft, 0.0, below));
}
// dart leader: a bright head running down the old channel, a fading tail, the cold channel ahead
if (dart >= 0.0) {
float behind = (dart - tm) * L;
iMul *= mix(0.12, 1.0 + 7.0 * exp(-max(behind, 0.0) / 2.0), smoothstep(-soft, 0.0, behind));
}
// the channel is never uniform: log-normal brightness knots, a width that wanders and swells
// towards the ground, where the current is highest
float wVar = 1.0, x = t * len;
if (vary > 0.0) {
uint hv = sSeed ^ 0x3C6EF372u;
float n2 = lnoise(x * 1.9, hv + 97u);
iMul *= exp(vary * (0.75 * lnoise(x * 0.45, hv) + 0.45 * n2 + 0.25 * lnoise(x * 5.3, hv + 311u)));
wVar = 1.0 + vary * (0.4 * lnoise(x * 0.8, hv + 191u) + 0.2 * n2);
if (strand == 0) { wVar *= 1.0 + vary * 0.7 * t * t; iMul *= 1.0 + vary * 0.6 * t * t; }
}
// the cooling channel diffuses and breaks into beads
if (res > 0.0) {
float b = 0.5 + 0.35 * lnoise(x * 1.3, sSeed + 733u) + 0.15 * lnoise(x * 4.1, sSeed + 1009u);
iMul *= smoothstep(res * 1.15 - 0.3, res * 1.15 + 0.05, b);
wVar *= 1.0 + 1.2 * res;
}
#ifdef BOLT_GLOW
oct = max(oct - 2, 2); // the wide glow follows the big kinks only: no fans at every zigzag
float hs = strand == 0 ? 8.0 : strand <= 8 ? 4.0 : 2.0;
#else
float hs = strand == 0 ? 4.0 : strand <= 8 ? 2.0 : 1.0;
#endif
// stepped leader: vertices past the tip fold onto it (zero-area triangles)
float tt = min(t, vis), h = hs / float(strand == 0 ? ${ STRANDS [ 0 ] . seg } : strand <= 8 ? ${ STRANDS [ 1 ] . seg } : ${ STRANDS [ 2 ] . seg } );
vec3 p = boltPath(sA, sB, tt, sSeed, sJag, freq, oct, freeEnd);
vec3 pP = boltPath(sA, sB, max(tt - h, 0.0), sSeed, sJag, freq, oct, freeEnd);
vec3 pN = boltPath(sA, sB, min(tt + h, 1.0), sSeed, sJag, freq, oct, freeEnd);
if (aMisc.x > 0.5) { p = snapArena(p); pP = snapArena(pP); pN = snapArena(pN); }
// the growing leader's tip burns brighter over its last ~30 cm
if (vis < 1.0) iMul *= 1.0 + 3.0 * exp(-(vis - tt) * len / 0.3);
// the strip's side comes from a tangent a few segments long, so the zigzag can't twist the ribbon
vec3 Ts = pN - pP, eye = p - cameraPosition;
float mu = dot(Ts, eye);
mu *= mu / max(dot(Ts, Ts) * dot(eye, eye), 1e-6); // cos^2 of the angle to the eye ray
// looking down a stretch of channel integrates more of it: knots where it heads at the eye
iMul *= 1.0 + vary * 2.0 * mu * mu;
#ifdef BOLT_MIRROR
// below the floor; ripples and a rough surface smear it the further it is from the plane
float hgt = max(p.y, 0.0), blur = 2.0 + 0.3 * min(hgt, 10.0);
p.xz += vec2(sin(hgt * 3.7 + uTime * 5.0), cos(hgt * 2.9 - uTime * 4.0)) * 0.012 * min(hgt, 8.0);
p.y = -p.y; Ts.y = -Ts.y;
vW = p;
wVar *= blur; iMul /= blur;
#endif
vViewZ = -(viewMatrix * vec4(p, 1.0)).z;
vS = x;
vec3 side = stripSide(p, Ts);
float aa;
#ifdef BOLT_GLOW
float hw = wireHalfWidth(aShape.w * wMul * wVar * aGlow.w, vViewZ, pxPerMetre(uFxResolution.y), aa);
// a wide ribbon seen end-on is a fan, and a branch passing the lens a wedge across the frame
hw = min(hw * smoothstep(0.0, 0.25, 1.0 - mu), 0.07 * vViewZ);
// no flat end caps: the ribbon fades out over about its own width
vColor = aGlow.rgb * iMul * aa * smoothstep(0.0, min(1.5 * hw, 0.3 * len), min(t, min(vis, 1.0) - t) * len);
#else
float hw = min(wireHalfWidth(aShape.w * wMul * wVar, vViewZ, pxPerMetre(uResolution.y), aa), 0.012 * vViewZ);
vColor = aCore.rgb * iMul * aa;
vEdge = aGlow.rgb * iMul * aa;
#endif
vUv = vec2(t, position.y);
gl_Position = projectionMatrix * viewMatrix * vec4(p + side * position.y * hw, 1.0);
} `
;
const
CORE_FRAG
=
`
in vec2 vUv;
in vec3 vColor;
in vec3 vEdge;
in float vS;
out vec4 fragColor;
void main() {
float y = vUv.y, r2 = y * y, env = 1.0 - r2;
float o = y - 0.3 * sin(vS * 9.0 + 2.1 * sin(vS * 3.7));
float body = exp(-r2 * 5.0);
fragColor = vec4((vColor * (0.62 * exp(-o * o * 26.0) + 0.38 * body) + vEdge * 2.0 * (1.0 - body)) * env * env, 1.0);
} `
;
const
MIRROR_FRAG
=
COMMON_GLSL
+
GROUND_GLSL
+
`
uniform sampler2D uSceneDepth;
uniform sampler2D uStoneNoise;
in vec2 vUv;
in vec3 vColor;
in vec3 vW;
out vec4 fragColor;
void main() {
vec3 rd = vW - cameraPosition;
vec3 q = cameraPosition + rd * (-cameraPosition.y / min(rd.y, -1e-4));
float qz = -(viewMatrix * vec4(q, 1.0)).z;
if (dot(q.xz, q.xz) > ${ ( ARENA . radius * ARENA . radius ) . toFixed ( 1 ) } || linearDepth(texelFetch(uSceneDepth, ivec2(gl_FragCoord.xy), 0).r) < qz - 0.12) discard;
vec2 pq = abs(q.xz - vec2( ${ ARENA . pool . center . x . toFixed ( 3 ) } , ${ ARENA . pool . center . y . toFixed ( 3 ) } ));
float refl = 1.0;
if (pq.x > ${ ARENA . pool . half . x . toFixed ( 3 ) } || pq.y > ${ ARENA . pool . half . y . toFixed ( 3 ) } ) {
vec4 g = groundA(q.xz);
float wt = clamp(g.z, 0.0, 1.0);
float puddle = smoothstep(0.35, 0.7, wt * (0.6 + 0.8 * texture(uStoneNoise, q.xz * 0.11 + 0.31).g));
refl = mix(0.16, 1.0, max(puddle, wt * 0.5)) * (1.0 - 0.9 * clamp(g.y, 0.0, 1.0));
}
float nv = 1.0 - clamp((cameraPosition.y - q.y) / length(cameraPosition - q), 0.0, 1.0), nv2 = nv * nv;
float env = 1.0 - vUv.y * vUv.y;
// the real channel is thousands of times brighter than anything else in the frame, so even 2-5%
// Fresnel off a wet slab reads strongly: boosted, with the grazing end capped
fragColor = vec4(vColor * (env * env * refl * min(8.0 * (0.02 + 0.98 * nv2 * nv2 * nv), 1.0)), 1.0);
} `
;
const
GLOW_FRAG
=
`
in vec2 vUv;
in vec3 vColor;
in float vViewZ;
void main() {
float v2 = vUv.y * vUv.y;
// a tight halo hugging the core plus the wide glow; both reach 0 at the strip edge, bloom does the rest
float g = 0.55 * (exp(-v2 * 3.0) - 0.0498) + 0.45 * (exp(-v2 * 18.0));
fxOut(vec3(0.0), 0.0, vColor * max(g, 0.0) * softFade(vViewZ, 0.5), vec2(0.0), vViewZ);
} `
;
function
pcg
(
v
)
{
const
=
(
Math
.
imul
(
,
747796405
)
+
2891336453
)
>>>
0
;
const
=
Math
.
imul
(
(
>>>
(
(
>>>
28
)
+
4
)
)
^
,
277803737
)
>>>
0
;
return
(
(
>>>
22
)
^
)
>>>
0
;
}
const
urand
=
(
v
)
=>
pcg
(
>>>
0
)
/
4294967296
;
function
lnoise
(
x, salt
)
{
const
=
Math
.
floor
(
)
,
=
(
+
)
>>>
0
;
const
=
urand
(
)
,
=
urand
(
(
+
1
)
>>>
0
)
;
return
(
+
(
-
)
*
(
-
)
)
*
2
-
1
;
}
const
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
,
=
new
THREE. Vector3
(
)
;
const
UP
=
new
THREE. Vector3
(
0
,
1
,
0
)
,
RIGHT
=
new
THREE. Vector3
(
1
,
0
,
0
)
;
function
boltPathJS
(
A , B , t, seed, jag, freq, octaves, gain, out
)
{
.
subVectors
(
B
,
A
)
;
const
L
=
.
length
(
)
;
.
multiplyScalar
(
1
/
Math
.
max
(
L
,
1e-6
)
)
;
.
crossVectors
(
,
Math
.
abs
(
.
y
)
<
0.99
?
UP
:
RIGHT
)
.
normalize
(
)
;
.
crossVectors
(
,
)
;
let
=
0
,
=
0
,
=
1
,
=
;
for
(
let
=
0
;
<
;
++
)
{
const
=
pcg
(
(
+
Math
.
imul
(
,
0x9E3779B9
)
)
>>>
0
)
;
+=
*
lnoise
(
*
,
)
;
+=
*
lnoise
(
*
,
(
^
0x5bd1e995
)
>>>
0
)
;
*=
;
*=
2
;
}
const
=
L
*
*
Math
.
sqrt
(
Math
.
max
(
Math
.
sin
(
Math
.
PI
*
)
,
0
)
)
;
return
.
lerpVectors
(
A
,
B
,
)
.
addScaledVector
(
,
*
)
.
addScaledVector
(
,
*
)
;
}
const
sdfAt
=
(
p, dx, dy, dz
)
=>
arenaSDF
(
.
set
(
.
x
+
,
.
y
+
,
.
z
+
)
)
;
function
snapJS
(
p
)
{
const
=
0.01
,
=
arenaSDF
(
)
;
.
set
(
sdfAt
(
,
,
0
,
0
)
-
sdfAt
(
,
-
,
0
,
0
)
,
sdfAt
(
,
0
,
,
0
)
-
sdfAt
(
,
0
,
-
,
0
)
,
sdfAt
(
,
0
,
0
,
)
-
sdfAt
(
,
0
,
0
,
-
)
)
.
normalize
(
)
;
return
.
addScaledVector
(
,
-
(
-
0.03
)
)
;
}
const
DEFAULTS
=
{
seed
:
1
,
branchSeed
:
1
,
branches
:
8
,
subBranches
:
12
,
jag
:
0.11
,
width
:
0.03
,
intensity
:
60
,
glowWidth
:
12
,
reveal
:
1
,
snapToArena
:
false
,
rough
:
0.5
,
fine
:
0
,
vary
:
0
,
stroke
:
1
,
dart
:
-
1
,
branchLevel
:
1
,
residual
:
0
,
}
;
export
class
Bolts
{
constructor
(
{ max = 32 } = { }
)
{
this
.
max
=
;
const
=
new
THREE. InstancedBufferGeometry
(
)
;
const
=
[
]
,
=
[
]
;
let
=
0
;
for
(
const
{
,
}
of
STRANDS
)
{
for
(
let
=
0
;
<
;
++
,
++
)
{
const
=
.
length
/
3
;
for
(
let
=
0
;
<=
;
++
)
.
push
(
/
,
-
1
,
,
/
,
1
,
)
;
for
(
let
=
0
;
<
;
++
)
{
const
=
+
*
2
;
.
push
(
,
+
1
,
+
2
,
+
1
,
+
3
,
+
2
)
;
}
}
}
.
setAttribute
(
'position'
,
new
THREE. Float32BufferAttribute
(
,
3
)
)
;
.
setIndex
(
)
;
this
.
attrs
=
[
'aA'
,
'aB'
,
'aShape'
,
'aCore'
,
'aGlow'
,
'aMisc'
,
'aFx'
]
.
map
(
(
n
)
=>
instanced
(
,
,
)
)
;
this
.
_arrays
=
this
.
attrs
.
map
(
(
x
)
=>
.
array
)
;
.
instanceCount
=
0
;
this
.
geometry
=
;
this
.
segments
=
STRANDS
.
reduce
(
(
s, x
)
=>
+
.
seg
*
.
n
,
0
)
;
this
.
uniforms
=
{
...
U
}
;
const
=
COMMON_GLSL
+
ARENA_GLSL
+
STRIP_GLSL
+
BOLT_VERT
;
this
.
cores
=
new
THREE. Mesh
(
,
new
THREE. ShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
uniforms
:
this
.
uniforms
,
...
LINES_BLENDING
,
side
:
THREE
.
DoubleSide
,
vertexShader
:
,
fragmentShader
:
CORE_FRAG
,
}
)
)
;
this
.
glows
=
new
THREE. Mesh
(
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
uniforms
:
this
.
uniforms
,
...
FX_BLENDING
,
side
:
THREE
.
DoubleSide
,
defines
:
{
BOLT_GLOW
:
1
}
,
vertexShader
:
FX_VERT_HEAD
+
,
fragmentShader
:
FX_FRAG_HEAD
+
COMMON_GLSL
+
FX_OUT_GLSL
+
GLOW_FRAG
,
}
)
)
;
this
.
cores
.
frustumCulled
=
this
.
glows
.
frustumCulled
=
false
;
this
.
cores
.
visible
=
this
.
glows
.
visible
=
false
;
if
(
Q
.
reflectFx
)
{
const
=
new
THREE. Mesh
(
,
new
THREE. ShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
uniforms
:
{
...
this
.
uniforms
,
uStoneNoise
:
.
uStoneNoise
}
,
...
LINES_BLENDING
,
depthTest
:
false
,
side
:
THREE
.
DoubleSide
,
defines
:
{
BOLT_MIRROR
:
1
}
,
vertexShader
:
,
fragmentShader
:
MIRROR_FRAG
,
}
)
)
;
.
frustumCulled
=
false
;
this
.
cores
.
add
(
)
;
}
this
.
bolts
=
Array
.
from
(
{
length
:
}
,
(
_, index
)
=>
(
{
,
active
:
false
,
...
DEFAULTS
,
a
:
new
THREE. Vector3
(
)
,
b
:
new
THREE. Vector3
(
)
,
color
:
new
THREE. Color
(
)
,
glowColor
:
new
THREE. Color
(
)
,
point
(
t, out
)
{
boltPathJS
(
this
.
a
,
this
.
b
,
,
pcg
(
this
.
seed
>>>
0
)
,
this
.
jag
,
MAIN
.
freq
,
MAIN
.
octaves
+
(
this
.
fine
?
1
:
0
)
,
this
.
rough
,
)
;
return
this
.
snapToArena
?
snapJS
(
)
:
;
}
,
release
(
)
{
this
.
active
=
false
;
}
,
}
)
)
;
}
acquire
(
opts = { }
)
{
for
(
const
of
this
.
bolts
)
{
if
(
.
active
)
continue
;
Object
.
assign
(
,
DEFAULTS
)
;
.
seed
=
(
Math
.
random
(
)
*
16777216
)
|
0
;
.
branchSeed
=
(
Math
.
random
(
)
*
16777216
)
|
0
;
.
color
.
setRGB
(
0.82
,
0.9
,
1.0
)
;
.
glowColor
.
setRGB
(
0.05
,
0.075
,
0.2
)
;
for
(
const
in
)
{
const
=
[
]
;
if
(
&&
.
isVector3
)
[
]
.
copy
(
)
;
else
if
(
&&
.
isColor
)
[
]
.
copy
(
)
;
else
[
]
=
;
}
.
active
=
true
;
return
;
}
return
null
;
}
update
(
)
{
let
=
0
,
=
false
;
const
X
=
this
.
_arrays
,
=
X
[
0
]
,
=
X
[
1
]
,
=
X
[
2
]
,
=
X
[
3
]
,
=
X
[
4
]
,
=
X
[
5
]
,
=
X
[
6
]
;
for
(
const
of
this
.
bolts
)
{
const
=
.
index
*
4
,
=
.
active
&&
.
intensity
>
0
&&
.
reveal
>
0
;
=
put4
(
,
,
.
color
.
r
*
.
intensity
,
.
color
.
g
*
.
intensity
,
.
color
.
b
*
.
intensity
,
?
.
reveal
:
0
)
||
;
if
(
!
)
continue
;
=
.
index
+
1
;
=
put4
(
,
,
.
a
.
x
,
.
a
.
y
,
.
a
.
z
,
.
seed
)
||
;
=
put4
(
,
,
.
b
.
x
,
.
b
.
y
,
.
b
.
z
,
.
branchSeed
)
||
;
=
put4
(
,
,
.
branches
,
.
subBranches
,
.
jag
,
.
width
)
||
;
=
put4
(
,
,
.
glowColor
.
r
*
.
intensity
,
.
glowColor
.
g
*
.
intensity
,
.
glowColor
.
b
*
.
intensity
,
.
glowWidth
)
||
;
=
put4
(
,
,
.
snapToArena
?
1
:
0
,
.
rough
,
.
fine
?
1
:
0
,
.
vary
)
||
;
=
put4
(
,
,
.
stroke
,
.
dart
,
.
branchLevel
,
.
residual
)
||
;
}
if
(
)
for
(
const
of
this
.
attrs
)
.
needsUpdate
=
true
;
this
.
geometry
.
instanceCount
=
;
this
.
cores
.
visible
=
this
.
glows
.
visible
=
>
0
;
}
}