Agent Harness · VibeGit
Agent Harness Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
agent-harness / tools / spells-assets / ue / vfx / ParticleFluid.js 669 строк · изменён 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
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
import * as THREE from 'three' ;
import { U , FX_BLENDING } from './common.js' ;
import { PAINT_BLENDING } from './GroundField.js' ;
import { Q } from '../engine/quality.js' ;
import {
MAXD , MAX_REC , PW , FULL_VERT , P2G_VERT , P2G_FRAG , MARK_FRAG , DIV_FRAG , JACOBI_FRAG , PROJECT_FRAG , ADVECT_FRAG , WHITE_FRAG ,
x
_v _c
foamRT
foamRT foamRT
foamRT
g
g
m g
m
prev renderer
renderer foamRT
renderer m
renderer prev
g m
foamRT
sys index
preset
t
t t t
_c t _c
_c _c _c
dt
s
radius radius speed dt s s s
n
n
n
n pos radius dir speed speed dt spread radial air swirl
s n volume s s s
n
sp vel
_v vel
sp _v
n pos radius _v sp spread radial air
pos
pos pos radius pull swirl
vel
fx
r fx
su
v
w h
type format count filter filter
su su su
tri
tri
tri
frag uniforms extra
m tri mat m m
su
su
su
su
su
su
pg
pg
pg
pg
pg
su
g
g
g
g n
g
g
spriteU su
spriteU
spriteU
m m
foamTex r
foamTex
cg
cg
fx
su foamTex
fx
su
fx
ground fx
ground paintScene
g
g
g
g
su ground
ground
i
size position yaw preset margin life
h
x x h x
h
h preset
h
h h
h size
position h position
h yaw h margin h life
h
r prev r
p r p r r
r prev
h
s h
c s s s
i i i
nx s c ny s c nz s c
tpr nx
tpr nz tpr ny
h c h nx h ny h nz h tpr
h c
c
budget
n n budget
n
n
seed
start
n
take n start o
start
o start o take o h h o type
o pos o pos o pos o radius
o dir o dir o dir o speed
o len o spread o radial o seed
o h o air o swirl o
start start take
n take
start
live
h h live
live
dt
r prevRT r
r _c
prevAlpha r
r
dt dt
h
h dt
h h h h
live camera
r prevRT
r _c prevAlpha
live
live
su d dt
any
h
i h
su i su i su i su i su i
h
any
c h s h hh h nx ny nz h
lx nx hh ly hh lz nz hh
h lx c lz s h ly h lx s lz c hh
nx ny nz h
c s h h
rr h
h rr h rr hh d
h h h h
i h h h h h
i h h
i h h h h
i h h h h
i h h h h
i h h h h
i h h h h
i h
i h
touch h h h h h
any
d0 d1
h h d0 d0 h d1 d1 h
d1 d0 d1
target d0 d1 d0
target
mesh
target
r su cam
su dt
su dt
a
sc
sc
sc sc
a sc
a
r
r
r cam
i i i
i
r
r cam
r
r cam
su s w
su s su s su s
su w su w su w
res
w res h res
w h
w h
t t w h
r
camera
camera
w hh
camera
x0 w y0 hh
x1 w w y1 hh hh
t
t
r t
r t
t x0 y0 x1 x0 y1 y0
t
r
r camera
r
r camera
rad
h h rad rad h
s
s
s rad
s rad
src
i i i
s src
s i i
r i
r
src i
src
r
r
t t
camera
h
h
c h s h m h
ex h h m ez h h m ey h h m
k k k
lx k ex ex lz k ez ez ly k ey m
camera h lx c lz s h ly h lx s lz c
h h
e h p h
k k k camera p k e e p k e e p k e e
out
out
_v x y z camera
_v camera
_v camera
_v _v _v _v
r prev r
r
t r t r
r prev
at c
h at
h c at
h c at
h c
h
r g
g paintTarget
r g
r g
r
DEPTH_VERT
,
DEPTH_FRAG
,
THICK_FRAG
,
SMOOTH_FRAG
,
NORMAL_FRAG
,
COMPOSITE_VERT
,
COMPOSITE_FRAG
,
WHITE_VERT
,
BEAD_VERT
,
BEAD_FRAG
,
WHITE_SPRITE_FRAG
,
PAINT_VERT
,
PAINT_FRAG
,
FOAM_BAKE_FRAG
,
}
from
'./ParticleFluid.glsl.js'
;
const
TIERS
=
{
low
:
{
n
:
8192
,
cells
:
45000
,
region
:
[
256
,
224
]
,
iters
:
8
}
,
medium
:
{
n
:
16384
,
cells
:
80000
,
region
:
[
384
,
256
]
,
iters
:
10
}
,
high
:
{
n
:
32768
,
cells
:
130000
,
region
:
[
512
,
320
]
,
iters
:
12
}
,
ultra
:
{
n
:
65536
,
cells
:
200000
,
region
:
[
512
,
480
]
,
iters
:
18
}
,
}
;
const
PPC
=
8
;
const
REC_W
=
5
;
const
RADIUS_K
=
1.3
;
const
SHUTTER
=
1
/
110
;
const
absorb
=
(
x
)
=>
-
Math
.
log
(
Math
.
max
(
,
0.03
)
)
*
0.4
+
0.02
;
const
=
new
THREE. Vector3
(
)
,
=
new
THREE. Color
(
)
;
const
QUAD
=
[
-
1
,
-
1
,
0
,
1
,
-
1
,
0
,
1
,
1
,
0
,
-
1
,
1
,
0
]
;
let
=
null
;
export
function
foamTexture
(
renderer
)
{
if
(
)
return
.
texture
;
=
new
THREE. WebGLRenderTarget
(
1024
,
1024
,
{
wrapS
:
THREE
.
RepeatWrapping
,
wrapT
:
THREE
.
RepeatWrapping
,
minFilter
:
THREE
.
LinearMipmapLinearFilter
,
magFilter
:
THREE
.
LinearFilter
,
generateMipmaps
:
true
,
depthBuffer
:
false
,
}
)
;
const
=
new
THREE. BufferGeometry
(
)
;
.
setAttribute
(
'position'
,
new
THREE. Float32BufferAttribute
(
[
-
1
,
-
1
,
0
,
3
,
-
1
,
0
,
-
1
,
3
,
0
]
,
3
)
)
;
const
=
new
THREE. Mesh
(
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
FULL_VERT
,
fragmentShader
:
FOAM_BAKE_FRAG
,
uniforms
:
{
uSize
:
{
value
:
new
THREE. Vector2
(
1024
,
1024
)
}
}
,
depthTest
:
false
,
depthWrite
:
false
,
}
)
)
;
.
frustumCulled
=
false
;
const
=
.
getRenderTarget
(
)
;
.
setRenderTarget
(
)
;
.
render
(
,
new
THREE. Camera
(
)
)
;
.
setRenderTarget
(
)
;
.
dispose
(
)
;
.
material
.
dispose
(
)
;
return
.
texture
;
}
class
FluidHandle
{
constructor
(
sys, index
)
{
this
.
sys
=
;
this
.
index
=
;
this
.
active
=
false
;
this
.
gen
=
0
;
this
.
position
=
new
THREE. Vector3
(
)
;
this
.
yaw
=
0
;
this
.
size
=
new
THREE. Vector3
(
4
,
4
,
4
)
;
this
.
h
=
0.1
;
this
.
spacing
=
0.05
;
this
.
n
=
[
8
,
8
,
8
]
;
this
.
tpr
=
1
;
this
.
tint
=
new
THREE. Color
(
)
;
this
.
clarity
=
1
;
this
.
absorption
=
new
THREE. Vector3
(
)
;
this
.
scatter
=
new
THREE. Vector3
(
)
;
this
.
emission
=
new
THREE. Vector3
(
)
;
this
.
foamTint
=
new
THREE. Color
(
)
;
this
.
paintA
=
new
THREE. Vector4
(
)
;
this
.
paintB
=
new
THREE. Vector4
(
)
;
this
.
holdPos
=
new
THREE. Vector3
(
)
;
this
.
holdOn
=
false
;
this
.
holdR
=
0.3
;
this
.
pull
=
6
;
this
.
swirl
=
4
;
this
.
launchVel
=
new
THREE. Vector3
(
)
;
this
.
launching
=
false
;
this
.
thrown
=
9
;
this
.
acc
=
0
;
this
.
reset
(
'water'
)
;
}
reset
(
preset
)
{
this
.
flip
=
0.96
;
this
.
wind
=
1
;
this
.
drain
=
0
;
this
.
foam
=
1
;
this
.
life
=
9
;
this
.
margin
=
1.5
;
this
.
roughness
=
0.035
;
this
.
refraction
=
0.6
;
this
.
aeration
=
1
;
this
.
sss
=
1
;
this
.
emission
.
set
(
0
,
0
,
0
)
;
this
.
paintA
.
set
(
0
,
0
,
0.035
,
0
)
;
this
.
paintB
.
set
(
0
,
0
,
0
,
0
)
;
this
.
holdOn
=
false
;
this
.
launching
=
false
;
this
.
acc
=
0
;
if
(
===
'acid'
)
{
this
.
tint
.
set
(
'#7dff3a'
)
;
this
.
clarity
=
1
;
this
.
absorption
.
set
(
11
,
2.5
,
27
)
;
this
.
scatter
.
set
(
0.05
,
0.1
,
0.004
)
;
this
.
emission
.
set
(
0.06
,
0.45
,
0.02
)
;
this
.
foamTint
.
setRGB
(
0.7
,
0.95
,
0.4
)
;
this
.
paintA
.
set
(
0
,
0
,
0.01
,
0
)
;
this
.
paintB
.
set
(
0
,
0.03
,
0
,
0
)
;
this
.
roughness
=
0.07
;
}
else
{
this
.
tint
.
set
(
'#2fa8ff'
)
;
this
.
clarity
=
1
;
this
.
foamTint
.
setRGB
(
0.62
,
0.78
,
0.82
)
;
this
.
tintWater
(
)
;
}
}
tintWater
(
)
{
const
=
this
.
tint
;
this
.
absorption
.
set
(
absorb
(
.
r
)
,
absorb
(
.
g
)
,
absorb
(
.
b
)
)
.
multiplyScalar
(
1
/
Math
.
max
(
this
.
clarity
,
0.05
)
)
;
.
copy
(
)
.
lerp
(
.
setRGB
(
1
,
1
,
1
)
,
0.5
)
;
this
.
scatter
.
set
(
.
r
,
.
g
,
.
b
)
.
multiplyScalar
(
0.03
+
0.04
/
Math
.
max
(
this
.
clarity
,
0.2
)
)
;
return
this
;
}
jet
(
pos, dir, speed, radius, dt, air = 0 , swirl = 0 , spread = 0.03 , radial = 0
)
{
if
(
!
this
.
active
||
<=
0
)
return
;
const
=
this
.
spacing
;
this
.
acc
+=
Math
.
PI
*
*
*
*
/
(
*
*
)
;
const
=
Math
.
floor
(
this
.
acc
)
;
if
(
<=
0
)
return
;
this
.
acc
-=
;
this
.
sys
.
record
(
this
,
0
,
,
,
,
,
,
*
,
,
,
,
)
;
}
burst
(
pos, radius, vel, volume, spread = 0.3 , radial = 0 , air = 0
)
{
if
(
!
this
.
active
)
return
;
const
=
this
.
spacing
,
=
Math
.
round
(
/
(
*
*
)
)
;
if
(
<=
0
)
return
;
const
=
.
length
(
)
;
.
copy
(
)
;
if
(
<
1e-6
)
.
set
(
0
,
1
,
0
)
;
this
.
sys
.
record
(
this
,
1
,
,
,
,
,
,
0
,
,
,
,
0
)
;
}
hold
(
pos, radius = 0.3 , pull = 6 , swirl = 4
)
{
this
.
holdOn
=
!
!
;
if
(
)
{
this
.
holdPos
.
copy
(
)
;
this
.
holdR
=
;
this
.
pull
=
;
this
.
swirl
=
;
}
}
launch
(
vel
)
{
this
.
launchVel
.
copy
(
)
;
this
.
launching
=
true
;
}
release
(
)
{
if
(
!
this
.
active
)
return
;
this
.
active
=
false
;
this
.
holdOn
=
false
;
this
.
launching
=
false
;
this
.
sys
.
released
=
true
;
}
}
export
class
ParticleFluid
{
constructor
(
fx
)
{
this
.
fx
=
;
const
=
this
.
renderer
=
.
renderer
;
const
T
=
TIERS
[
Q
.
tier
]
??
TIERS
.
high
;
this
.
N
=
Q
.
fluidParticles
??
T
.
n
;
this
.
PH
=
Math
.
ceil
(
this
.
N
/
PW
)
;
this
.
ND
=
Math
.
max
(
PW
,
this
.
N
>>
1
)
;
this
.
WH
=
Math
.
ceil
(
this
.
ND
/
PW
)
;
this
.
cells
=
T
.
cells
;
this
.
region
=
T
.
region
;
this
.
iters
=
T
.
iters
;
this
.
AW
=
T
.
region
[
0
]
;
this
.
AH
=
T
.
region
[
1
]
*
MAXD
;
this
.
timer
=
null
;
this
.
released
=
false
;
this
.
cursor
=
0
;
this
.
recCount
=
0
;
this
.
emitted
=
0
;
const
v4s
=
(
)
=>
Array
.
from
(
{
length
:
MAXD
}
,
(
)
=>
new
THREE. Vector4
(
)
)
;
const
=
this
.
su
=
{
uDomO
:
{
value
:
v4s
(
)
}
,
uDomN
:
{
value
:
v4s
(
)
.
map
(
(
v
)
=>
.
set
(
1
,
1
,
1
,
1
)
)
}
,
uDomR
:
{
value
:
v4s
(
)
}
,
uDomS
:
{
value
:
v4s
(
)
}
,
uDomF
:
{
value
:
v4s
(
)
}
,
uAtlas
:
{
value
:
new
THREE. Vector2
(
this
.
AW
,
this
.
AH
)
}
,
uRegionH
:
{
value
:
T
.
region
[
1
]
}
,
uS0
:
{
value
:
null
}
,
uS1
:
{
value
:
null
}
,
uS2
:
{
value
:
null
}
,
uW0
:
{
value
:
null
}
,
uW1
:
{
value
:
null
}
,
uW2
:
{
value
:
null
}
,
uVn
:
{
value
:
null
}
,
uDV
:
{
value
:
null
}
,
uD
:
{
value
:
null
}
,
uSimDt
:
{
value
:
1
/
60
}
,
uGdt
:
{
value
:
9.81
/
60
}
,
}
;
const
mrt
=
(
w, h, count, type, filter = THREE . NearestFilter , format = THREE . RGBAFormat
)
=>
new
THREE. WebGLRenderTarget
(
,
,
{
,
,
,
minFilter
:
,
magFilter
:
,
depthBuffer
:
false
,
generateMipmaps
:
false
,
}
)
;
this
.
state
=
[
mrt
(
PW
,
this
.
PH
,
3
,
THREE
.
FloatType
)
,
mrt
(
PW
,
this
.
PH
,
3
,
THREE
.
FloatType
)
]
;
this
.
white
=
[
mrt
(
PW
,
this
.
WH
,
3
,
THREE
.
FloatType
)
,
mrt
(
PW
,
this
.
WH
,
3
,
THREE
.
FloatType
)
]
;
this
.
cur
=
0
;
this
.
wcur
=
0
;
const
H16
=
THREE
.
HalfFloatType
,
F32
=
THREE
.
FloatType
;
this
.
acc
=
mrt
(
this
.
AW
,
this
.
AH
,
2
,
H16
)
;
this
.
V
=
mrt
(
this
.
AW
,
this
.
AH
,
1
,
H16
)
;
this
.
D
=
mrt
(
this
.
AW
,
this
.
AH
,
1
,
H16
,
THREE
.
LinearFilter
)
;
this
.
P
=
[
mrt
(
this
.
AW
,
this
.
AH
,
1
,
F32
,
THREE
.
NearestFilter
,
THREE
.
RedFormat
)
,
mrt
(
this
.
AW
,
this
.
AH
,
1
,
F32
,
THREE
.
NearestFilter
,
THREE
.
RedFormat
)
]
;
this
.
pCur
=
0
;
this
.
proj
=
mrt
(
this
.
AW
,
this
.
AH
,
2
,
H16
,
THREE
.
LinearFilter
)
;
.
uVn
.
value
=
this
.
proj
.
textures
[
0
]
;
.
uDV
.
value
=
this
.
proj
.
textures
[
1
]
;
.
uD
.
value
=
this
.
D
.
texture
;
this
.
ssf
=
new
THREE. Vector2
(
1
,
1
)
;
this
.
depthRT
=
new
THREE. WebGLRenderTarget
(
1
,
1
,
{
type
:
F32
,
format
:
THREE
.
RGFormat
,
minFilter
:
THREE
.
NearestFilter
,
magFilter
:
THREE
.
NearestFilter
,
depthBuffer
:
true
,
generateMipmaps
:
false
}
)
;
this
.
thickRT
=
mrt
(
1
,
1
,
1
,
H16
,
THREE
.
LinearFilter
,
THREE
.
RGFormat
)
;
this
.
smooth
=
[
mrt
(
1
,
1
,
1
,
F32
,
THREE
.
NearestFilter
,
THREE
.
RedFormat
)
,
mrt
(
1
,
1
,
1
,
F32
,
THREE
.
NearestFilter
,
THREE
.
RedFormat
)
]
;
this
.
nrmRT
=
mrt
(
1
,
1
,
1
,
F32
)
;
this
.
ssfTargets
=
[
this
.
depthRT
,
this
.
thickRT
,
...
this
.
smooth
,
this
.
nrmRT
]
;
this
.
_rect
=
new
Float64Array
(
5
)
;
this
.
emitData
=
new
Float32Array
(
REC_W
*
MAX_REC
*
4
)
;
this
.
emitTex
=
new
THREE. DataTexture
(
this
.
emitData
,
REC_W
,
MAX_REC
,
THREE
.
RGBAFormat
,
THREE
.
FloatType
)
;
this
.
emitTex
.
magFilter
=
this
.
emitTex
.
minFilter
=
THREE
.
NearestFilter
;
this
.
spans
=
Array
.
from
(
{
length
:
4
}
,
(
)
=>
new
THREE. Vector2
(
)
)
;
this
.
firstStart
=
-
1
;
this
.
cam
=
new
THREE. Camera
(
)
;
const
=
new
THREE. BufferGeometry
(
)
;
.
setAttribute
(
'position'
,
new
THREE. Float32BufferAttribute
(
[
-
1
,
-
1
,
0
,
3
,
-
1
,
0
,
-
1
,
3
,
0
]
,
3
)
)
;
.
boundingSphere
=
new
THREE. Sphere
(
)
;
const
raw
=
(
frag, uniforms, extra = { }
)
=>
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
FULL_VERT
,
fragmentShader
:
,
,
depthTest
:
false
,
depthWrite
:
false
,
...
,
}
)
;
const
quad
=
(
mat
)
=>
{
const
=
new
THREE. Mesh
(
,
)
;
.
frustumCulled
=
false
;
return
;
}
;
this
.
markQ
=
quad
(
raw
(
MARK_FRAG
,
{
...
U
,
...
,
uAccA
:
{
value
:
this
.
acc
.
textures
[
0
]
}
,
uAccB
:
{
value
:
this
.
acc
.
textures
[
1
]
}
,
uFluidThresh
:
{
value
:
0.3
}
}
)
)
;
this
.
divQ
=
quad
(
raw
(
DIV_FRAG
,
{
...
,
uV
:
{
value
:
this
.
V
.
texture
}
,
uAccA
:
{
value
:
this
.
acc
.
textures
[
0
]
}
,
uPPC
:
{
value
:
PPC
}
}
)
)
;
this
.
jacU
=
{
uP
:
{
value
:
null
}
,
uDc
:
{
value
:
this
.
D
.
texture
}
,
uFirst
:
{
value
:
0
}
}
;
this
.
jacQ
=
quad
(
raw
(
JACOBI_FRAG
,
{
...
,
...
this
.
jacU
}
)
)
;
this
.
projU
=
{
uV
:
{
value
:
this
.
V
.
texture
}
,
uP
:
{
value
:
null
}
}
;
this
.
projQ
=
quad
(
raw
(
PROJECT_FRAG
,
{
...
,
...
this
.
projU
}
)
)
;
this
.
holdU
=
{
uHold
:
{
value
:
v4s
(
)
}
,
uHoldB
:
{
value
:
v4s
(
)
}
,
uLaunch
:
{
value
:
v4s
(
)
}
}
;
this
.
advU
=
{
uEmit
:
{
value
:
this
.
emitTex
}
,
uEmitCount
:
{
value
:
0
}
,
uSpan
:
{
value
:
this
.
spans
}
,
uSpanCount
:
{
value
:
0
}
}
;
this
.
advQ
=
quad
(
raw
(
ADVECT_FRAG
,
{
...
U
,
...
,
...
this
.
holdU
,
...
this
.
advU
}
)
)
;
this
.
whiteU
=
{
uFluidN
:
{
value
:
this
.
N
}
,
uWhiteRate
:
{
value
:
7
}
}
;
this
.
whiteQ
=
quad
(
raw
(
WHITE_FRAG
,
{
...
U
,
...
,
...
this
.
whiteU
}
)
)
;
const
=
new
THREE. InstancedBufferGeometry
(
)
;
.
setAttribute
(
'position'
,
new
THREE. BufferAttribute
(
new
Float32Array
(
this
.
N
)
,
1
)
)
;
.
instanceCount
=
3
;
.
boundingSphere
=
new
THREE. Sphere
(
)
;
this
.
p2g
=
new
THREE. Points
(
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
P2G_VERT
,
fragmentShader
:
P2G_FRAG
,
uniforms
:
,
depthTest
:
false
,
depthWrite
:
false
,
transparent
:
true
,
blending
:
THREE
.
CustomBlending
,
blendEquation
:
THREE
.
AddEquation
,
blendSrc
:
THREE
.
OneFactor
,
blendDst
:
THREE
.
OneFactor
,
blendEquationAlpha
:
THREE
.
AddEquation
,
blendSrcAlpha
:
THREE
.
OneFactor
,
blendDstAlpha
:
THREE
.
OneFactor
,
}
)
)
;
this
.
p2g
.
frustumCulled
=
false
;
const
sprites
=
(
n
)
=>
{
const
=
new
THREE. InstancedBufferGeometry
(
)
;
.
setAttribute
(
'position'
,
new
THREE. Float32BufferAttribute
(
QUAD
,
3
)
)
;
.
setIndex
(
[
0
,
1
,
2
,
0
,
2
,
3
]
)
;
.
instanceCount
=
;
.
boundingSphere
=
new
THREE. Sphere
(
)
;
return
;
}
;
const
=
{
...
,
uShutter
:
{
value
:
SHUTTER
}
}
;
this
.
depthMesh
=
new
THREE. Mesh
(
sprites
(
this
.
N
)
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
DEPTH_VERT
,
fragmentShader
:
DEPTH_FRAG
,
uniforms
:
,
depthTest
:
true
,
depthWrite
:
true
,
}
)
)
;
this
.
thickMesh
=
new
THREE. Mesh
(
sprites
(
this
.
N
)
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
DEPTH_VERT
,
fragmentShader
:
THICK_FRAG
,
uniforms
:
,
depthTest
:
false
,
depthWrite
:
false
,
transparent
:
true
,
blending
:
THREE
.
CustomBlending
,
blendEquation
:
THREE
.
AddEquation
,
blendSrc
:
THREE
.
OneFactor
,
blendDst
:
THREE
.
OneFactor
,
}
)
)
;
for
(
const
of
[
this
.
depthMesh
,
this
.
thickMesh
]
)
.
frustumCulled
=
false
;
this
.
smU
=
{
uZ
:
{
value
:
null
}
,
uDir
:
{
value
:
new
THREE. Vector2
(
1
,
0
)
}
,
uPxScale
:
{
value
:
100
}
,
uWorldR
:
{
value
:
0.12
}
,
uRange
:
{
value
:
0.1
}
}
;
this
.
smQ
=
quad
(
raw
(
SMOOTH_FRAG
,
this
.
smU
)
)
;
this
.
nrmU
=
{
uZ
:
{
value
:
null
}
,
uProj
:
{
value
:
new
THREE. Vector2
(
1
,
1
)
}
}
;
this
.
nrmQ
=
quad
(
raw
(
NORMAL_FRAG
,
this
.
nrmU
)
)
;
const
=
foamTexture
(
)
;
const
lk
=
(
)
=>
(
{
value
:
v4s
(
)
}
)
;
this
.
look
=
{
uLook0
:
lk
(
)
,
uLook1
:
lk
(
)
,
uLook2
:
lk
(
)
,
uLook3
:
lk
(
)
}
;
this
.
compU
=
{
...
U
,
...
this
.
look
,
uRect
:
{
value
:
new
THREE. Vector4
(
-
1
,
-
1
,
1
,
1
)
}
,
uNZ
:
{
value
:
this
.
nrmRT
.
texture
}
,
uThick
:
{
value
:
this
.
thickRT
.
texture
}
,
uDomTex
:
{
value
:
this
.
depthRT
.
texture
}
,
uSsf
:
{
value
:
this
.
ssf
}
,
uCamWorld
:
{
value
:
new
THREE. Matrix4
(
)
}
,
uProj
:
{
value
:
this
.
nrmU
.
uProj
.
value
}
,
uFoamTex
:
{
value
:
}
,
}
;
const
=
new
THREE. PlaneGeometry
(
2
,
2
)
;
this
.
composite
=
new
THREE. Mesh
(
,
new
THREE. ShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
COMPOSITE_VERT
,
fragmentShader
:
COMPOSITE_FRAG
,
uniforms
:
this
.
compU
,
transparent
:
true
,
depthTest
:
true
,
depthWrite
:
true
,
blending
:
THREE
.
CustomBlending
,
blendEquation
:
THREE
.
AddEquation
,
blendSrc
:
THREE
.
SrcAlphaFactor
,
blendDst
:
THREE
.
OneMinusSrcAlphaFactor
,
blendEquationAlpha
:
THREE
.
AddEquation
,
blendSrcAlpha
:
THREE
.
ZeroFactor
,
blendDstAlpha
:
THREE
.
OneFactor
,
}
)
)
;
this
.
composite
.
frustumCulled
=
false
;
this
.
composite
.
visible
=
false
;
.
scenes
.
refract
.
add
(
this
.
composite
)
;
this
.
whiteLook
=
new
THREE. Vector4
(
1
,
1
,
0
,
0
)
;
this
.
whiteMesh
=
new
THREE. Mesh
(
sprites
(
this
.
ND
)
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
WHITE_VERT
,
fragmentShader
:
WHITE_SPRITE_FRAG
,
uniforms
:
{
...
U
,
...
,
uWhiteLook
:
{
value
:
this
.
whiteLook
}
,
uFoamTex
:
{
value
:
}
}
,
...
FX_BLENDING
,
}
)
)
;
this
.
whiteMesh
.
frustumCulled
=
false
;
this
.
whiteMesh
.
visible
=
false
;
.
scenes
.
fx
.
add
(
this
.
whiteMesh
)
;
this
.
dropMesh
=
new
THREE. Mesh
(
sprites
(
this
.
N
)
,
new
THREE. ShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
BEAD_VERT
,
fragmentShader
:
BEAD_FRAG
,
uniforms
:
{
...
U
,
...
}
,
transparent
:
true
,
depthWrite
:
false
,
blending
:
THREE
.
CustomBlending
,
blendEquation
:
THREE
.
AddEquation
,
blendSrc
:
THREE
.
SrcAlphaFactor
,
blendDst
:
THREE
.
OneMinusSrcAlphaFactor
,
blendEquationAlpha
:
THREE
.
AddEquation
,
blendSrcAlpha
:
THREE
.
ZeroFactor
,
blendDstAlpha
:
THREE
.
OneFactor
,
}
)
)
;
this
.
dropMesh
.
frustumCulled
=
false
;
this
.
dropMesh
.
visible
=
false
;
this
.
dropMesh
.
renderOrder
=
3
;
.
scenes
.
refract
.
add
(
this
.
dropMesh
)
;
this
.
paintU
=
{
uPaintA
:
{
value
:
v4s
(
)
}
,
uPaintB
:
{
value
:
v4s
(
)
}
}
;
const
=
.
ground
;
if
(
?.
)
{
const
=
new
THREE. BufferGeometry
(
)
;
.
setAttribute
(
'position'
,
new
THREE. BufferAttribute
(
new
Float32Array
(
this
.
N
)
,
1
)
)
;
.
boundingSphere
=
new
THREE. Sphere
(
)
;
this
.
paint
=
new
THREE. Points
(
,
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
PAINT_VERT
,
fragmentShader
:
PAINT_FRAG
,
uniforms
:
{
...
,
...
this
.
paintU
,
uGroundA
:
U
.
uGroundA
,
uGroundB
:
U
.
uGroundB
,
uGroundRect
:
U
.
uGroundRect
,
uTexelsPerM
:
{
value
:
.
size
/
U
.
uGroundRect
.
value
.
z
}
}
,
...
PAINT_BLENDING
,
}
)
)
;
this
.
paint
.
frustumCulled
=
false
;
this
.
paint
.
visible
=
false
;
.
paintScene
.
add
(
this
.
paint
)
;
}
this
.
handles
=
Array
.
from
(
{
length
:
MAXD
}
,
(
_, i
)
=>
new
FluidHandle
(
this
,
)
)
;
this
.
clear
(
)
;
this
.
warm
(
)
;
}
acquire
(
{
=
[
4
,
4
,
4
]
,
=
null
,
=
0
,
=
'water'
,
=
1.5
,
=
9
}
=
{
}
)
{
let
=
null
;
for
(
const
of
this
.
handles
)
if
(
!
.
active
)
{
=
;
break
;
}
if
(
!
)
return
null
;
.
reset
(
)
;
.
active
=
true
;
.
gen
=
(
.
gen
+
1
)
%
1000
;
.
size
.
fromArray
(
)
;
if
(
)
.
position
.
copy
(
)
;
.
yaw
=
;
.
margin
=
;
.
life
=
;
this
.
fit
(
)
;
const
=
this
.
renderer
,
=
.
getRenderTarget
(
)
;
for
(
const
of
this
.
P
)
{
.
setRenderTarget
(
)
;
.
setClearColor
(
0x000000
,
0
)
;
.
clear
(
true
,
false
,
false
)
;
}
.
setRenderTarget
(
)
;
return
;
}
fit
(
h
)
{
const
[
RW
,
RH
]
=
this
.
region
,
=
.
size
;
let
=
Math
.
cbrt
(
.
x
*
.
y
*
.
z
/
this
.
cells
)
;
for
(
let
=
0
;
<
400
;
++
)
{
const
=
Math
.
max
(
4
,
Math
.
ceil
(
.
x
/
)
)
,
=
Math
.
max
(
4
,
Math
.
ceil
(
.
y
/
)
+
1
)
,
=
Math
.
max
(
4
,
Math
.
ceil
(
.
z
/
)
)
;
const
=
Math
.
floor
(
RW
/
(
+
1
)
)
;
if
(
>=
1
&&
Math
.
ceil
(
(
+
1
)
/
)
*
(
+
1
)
<=
RH
)
{
.
h
=
;
.
n
[
0
]
=
;
.
n
[
1
]
=
;
.
n
[
2
]
=
;
.
tpr
=
;
.
spacing
=
/
Math
.
cbrt
(
PPC
)
;
return
;
}
*=
1.015
;
}
}
record
(
h, type, n, pos, radius, dir, speed, len, spread, radial, air, swirl
)
{
const
=
Math
.
max
(
256
,
this
.
N
>>
3
)
;
=
Math
.
min
(
,
-
this
.
emitted
,
this
.
N
)
;
if
(
<=
0
)
return
false
;
this
.
emitted
+=
;
const
=
this
.
fx
.
rand
(
)
;
let
=
this
.
cursor
;
while
(
>
0
&&
this
.
recCount
<
MAX_REC
)
{
const
=
Math
.
min
(
,
this
.
N
-
)
,
=
this
.
recCount
*
REC_W
*
4
,
D
=
this
.
emitData
;
if
(
this
.
firstStart
<
0
)
this
.
firstStart
=
;
D
[
]
=
;
D
[
+
1
]
=
;
D
[
+
2
]
=
.
index
+
MAXD
*
.
gen
;
D
[
+
3
]
=
;
D
[
+
4
]
=
.
x
;
D
[
+
5
]
=
.
y
;
D
[
+
6
]
=
.
z
;
D
[
+
7
]
=
;
D
[
+
8
]
=
.
x
;
D
[
+
9
]
=
.
y
;
D
[
+
10
]
=
.
z
;
D
[
+
11
]
=
;
D
[
+
12
]
=
;
D
[
+
13
]
=
;
D
[
+
14
]
=
;
D
[
+
15
]
=
;
D
[
+
16
]
=
.
life
;
D
[
+
17
]
=
;
D
[
+
18
]
=
;
D
[
+
19
]
=
0
;
this
.
recCount
++
;
=
(
+
)
%
this
.
N
;
-=
;
}
this
.
cursor
=
;
return
true
;
}
update
(
dt, camera
)
{
let
=
0
;
for
(
const
of
this
.
handles
)
if
(
.
active
)
++
;
if
(
!
&&
!
this
.
released
)
{
this
.
composite
.
visible
=
this
.
whiteMesh
.
visible
=
this
.
dropMesh
.
visible
=
false
;
if
(
this
.
paint
)
this
.
paint
.
visible
=
false
;
this
.
recCount
=
0
;
this
.
emitted
=
0
;
this
.
firstStart
=
-
1
;
return
;
}
this
.
pack
(
)
;
const
=
this
.
renderer
,
=
.
getRenderTarget
(
)
;
.
getClearColor
(
)
;
const
=
.
getClearAlpha
(
)
;
.
setClearColor
(
0x000000
,
0
)
;
if
(
>
0
||
this
.
released
)
{
this
.
timer
?.
begin
(
'fluid sim'
)
;
this
.
step
(
Math
.
min
(
Math
.
max
(
,
1e-4
)
,
1
/
30
)
)
;
}
this
.
released
=
false
;
for
(
const
of
this
.
handles
)
{
.
thrown
+=
;
if
(
.
launching
)
{
.
launching
=
false
;
.
holdOn
=
false
;
.
thrown
=
0
;
}
}
this
.
recCount
=
0
;
this
.
emitted
=
0
;
this
.
firstStart
=
-
1
;
if
(
)
{
this
.
timer
?.
begin
(
'ssf'
)
;
this
.
render
(
)
;
}
.
setRenderTarget
(
)
;
.
setClearColor
(
,
)
;
this
.
composite
.
visible
=
this
.
whiteMesh
.
visible
=
this
.
dropMesh
.
visible
=
>
0
;
if
(
this
.
paint
)
this
.
paint
.
visible
=
>
0
;
}
pack
(
dt
)
{
const
=
this
.
su
,
=
Math
.
max
(
,
1
/
240
)
;
let
=
false
;
for
(
const
of
this
.
handles
)
{
const
=
.
index
;
const
O
=
.
uDomO
.
value
[
]
,
N
=
.
uDomN
.
value
[
]
,
R
=
.
uDomR
.
value
[
]
,
S
=
.
uDomS
.
value
[
]
,
F
=
.
uDomF
.
value
[
]
;
if
(
!
.
active
)
{
R
.
z
=
0
;
continue
;
}
=
true
;
const
=
Math
.
cos
(
.
yaw
)
,
=
Math
.
sin
(
.
yaw
)
,
=
.
h
,
[
,
,
]
=
.
n
;
const
=
*
/
2
,
=
,
=
*
/
2
;
O
.
set
(
.
position
.
x
-
(
*
-
*
)
,
.
position
.
y
-
,
.
position
.
z
-
(
*
+
*
)
,
)
;
N
.
set
(
,
,
,
.
tpr
)
;
R
.
set
(
,
,
.
gen
+
1
,
.
margin
)
;
const
=
.
spacing
*
RADIUS_K
;
S
.
set
(
.
spacing
,
,
.
spacing
**
3
/
(
4.19
*
**
3
)
,
0.2
*
/
)
;
F
.
set
(
.
flip
,
.
wind
,
.
drain
,
.
foam
)
;
const
H
=
this
.
holdU
;
H
.
uHold
.
value
[
]
.
set
(
.
holdPos
.
x
,
.
holdPos
.
y
,
.
holdPos
.
z
,
.
holdOn
?
.
pull
:
0
)
;
H
.
uHoldB
.
value
[
]
.
set
(
.
holdR
,
.
swirl
,
0
,
0
)
;
H
.
uLaunch
.
value
[
]
.
set
(
.
launchVel
.
x
,
.
launchVel
.
y
,
.
launchVel
.
z
,
.
launching
?
1
:
0
)
;
const
L
=
this
.
look
;
L
.
uLook0
.
value
[
]
.
set
(
.
absorption
.
x
,
.
absorption
.
y
,
.
absorption
.
z
,
.
roughness
)
;
L
.
uLook1
.
value
[
]
.
set
(
.
scatter
.
x
,
.
scatter
.
y
,
.
scatter
.
z
,
.
refraction
)
;
L
.
uLook2
.
value
[
]
.
set
(
.
emission
.
x
,
.
emission
.
y
,
.
emission
.
z
,
.
aeration
)
;
L
.
uLook3
.
value
[
]
.
set
(
.
foamTint
.
r
,
.
foamTint
.
g
,
.
foamTint
.
b
,
.
sss
)
;
this
.
paintU
.
uPaintA
.
value
[
]
.
copy
(
.
paintA
)
;
this
.
paintU
.
uPaintB
.
value
[
]
.
copy
(
.
paintB
)
;
this
.
fx
.
ground
?.
?.
(
.
position
.
x
,
.
position
.
z
,
0.5
*
Math
.
hypot
(
.
size
.
x
,
.
size
.
z
)
+
.
margin
,
0.5
)
;
}
return
;
}
gridPass
(
mesh, target
)
{
let
=
MAXD
,
=
-
1
;
for
(
const
of
this
.
handles
)
if
(
.
active
)
{
=
Math
.
min
(
,
.
index
)
;
=
Math
.
max
(
,
.
index
)
;
}
if
(
<
0
)
{
=
0
;
=
MAXD
-
1
;
}
const
RH
=
this
.
region
[
1
]
;
.
viewport
.
set
(
0
,
*
RH
,
this
.
AW
,
(
-
+
1
)
*
RH
)
;
this
.
renderer
.
setRenderTarget
(
)
;
this
.
renderer
.
render
(
,
this
.
cam
)
;
.
viewport
.
set
(
0
,
0
,
this
.
AW
,
this
.
AH
)
;
}
step
(
dt
)
{
const
=
this
.
renderer
,
=
this
.
su
,
=
this
.
cam
;
.
uSimDt
.
value
=
;
.
uGdt
.
value
=
9.81
*
;
const
=
this
.
advU
;
let
=
0
;
if
(
this
.
recCount
)
{
const
A
=
this
.
firstStart
,
B
=
this
.
cursor
;
if
(
B
>
A
)
this
.
spans
[
++
]
.
set
(
A
,
B
)
;
else
{
this
.
spans
[
++
]
.
set
(
A
,
this
.
N
)
;
if
(
B
>
0
)
this
.
spans
[
++
]
.
set
(
0
,
B
)
;
}
this
.
emitTex
.
needsUpdate
=
true
;
}
.
uSpanCount
.
value
=
;
.
uEmitCount
.
value
=
this
.
recCount
;
this
.
bind
(
)
;
const
T
=
this
.
fine
?
this
.
timer
:
null
;
T
?.
begin
(
'fl p2g'
)
;
.
setRenderTarget
(
this
.
acc
)
;
.
clear
(
true
,
false
,
false
)
;
.
render
(
this
.
p2g
,
)
;
T
?.
begin
(
'fl mark'
)
;
this
.
gridPass
(
this
.
markQ
,
this
.
V
)
;
this
.
gridPass
(
this
.
divQ
,
this
.
D
)
;
T
?.
begin
(
'fl jacobi'
)
;
for
(
let
=
0
;
<
this
.
iters
;
++
)
{
this
.
jacU
.
uP
.
value
=
this
.
P
[
this
.
pCur
]
.
texture
;
this
.
jacU
.
uFirst
.
value
=
===
0
?
1
:
0
;
this
.
pCur
^=
1
;
this
.
gridPass
(
this
.
jacQ
,
this
.
P
[
this
.
pCur
]
)
;
}
this
.
projU
.
uP
.
value
=
this
.
P
[
this
.
pCur
]
.
texture
;
T
?.
begin
(
'fl proj'
)
;
this
.
gridPass
(
this
.
projQ
,
this
.
proj
)
;
T
?.
begin
(
'fl advect'
)
;
this
.
cur
^=
1
;
.
setRenderTarget
(
this
.
state
[
this
.
cur
]
)
;
.
render
(
this
.
advQ
,
)
;
this
.
bind
(
)
;
T
?.
begin
(
'fl white'
)
;
this
.
wcur
^=
1
;
.
setRenderTarget
(
this
.
white
[
this
.
wcur
]
)
;
.
render
(
this
.
whiteQ
,
)
;
this
.
bind
(
)
;
}
bind
(
)
{
const
=
this
.
su
,
=
this
.
state
[
this
.
cur
]
.
textures
,
=
this
.
white
[
this
.
wcur
]
.
textures
;
.
uS0
.
value
=
[
0
]
;
.
uS1
.
value
=
[
1
]
;
.
uS2
.
value
=
[
2
]
;
.
uW0
.
value
=
[
0
]
;
.
uW1
.
value
=
[
1
]
;
.
uW2
.
value
=
[
2
]
;
}
resize
(
)
{
const
=
U
.
uResolution
.
value
;
const
=
Math
.
max
(
1
,
Math
.
round
(
.
x
*
0.5
)
)
,
=
Math
.
max
(
1
,
Math
.
round
(
.
y
*
0.5
)
)
;
if
(
===
this
.
ssf
.
x
&&
===
this
.
ssf
.
y
)
return
;
this
.
ssf
.
set
(
,
)
;
for
(
const
of
[
this
.
depthRT
,
this
.
thickRT
,
this
.
nrmRT
,
...
this
.
smooth
]
)
.
setSize
(
,
)
;
}
render
(
camera
)
{
const
=
this
.
renderer
;
this
.
resize
(
)
;
.
updateMatrixWorld
(
)
;
const
P
=
.
projectionMatrix
.
elements
;
this
.
nrmU
.
uProj
.
value
.
set
(
P
[
0
]
,
P
[
5
]
)
;
const
R
=
this
.
compU
.
uRect
.
value
,
=
this
.
ssf
.
x
,
=
this
.
ssf
.
y
;
this
.
screenRect
(
,
R
)
;
const
=
Math
.
max
(
Math
.
floor
(
(
R
.
x
*
0.5
+
0.5
)
*
)
-
2
,
0
)
,
=
Math
.
max
(
Math
.
floor
(
(
R
.
y
*
0.5
+
0.5
)
*
)
-
2
,
0
)
;
const
=
Math
.
min
(
Math
.
ceil
(
(
R
.
z
*
0.5
+
0.5
)
*
)
+
2
,
)
,
=
Math
.
min
(
Math
.
ceil
(
(
R
.
w
*
0.5
+
0.5
)
*
)
+
2
,
)
;
const
T
=
this
.
fine
?
this
.
timer
:
null
;
for
(
const
of
this
.
ssfTargets
)
{
.
scissorTest
=
false
;
.
setRenderTarget
(
)
;
.
clear
(
true
,
===
this
.
depthRT
,
false
)
;
.
scissor
.
set
(
,
,
Math
.
max
(
-
,
1
)
,
Math
.
max
(
-
,
1
)
)
;
.
scissorTest
=
true
;
}
T
?.
begin
(
'ssf depth'
)
;
.
setRenderTarget
(
this
.
depthRT
)
;
.
render
(
this
.
depthMesh
,
)
;
T
?.
begin
(
'ssf thick'
)
;
.
setRenderTarget
(
this
.
thickRT
)
;
.
render
(
this
.
thickMesh
,
)
;
let
=
0
;
for
(
const
of
this
.
handles
)
if
(
.
active
)
=
Math
.
max
(
,
.
spacing
*
RADIUS_K
)
;
const
=
this
.
smU
;
.
uPxScale
.
value
=
0.5
*
this
.
ssf
.
y
*
P
[
5
]
;
.
uWorldR
.
value
=
*
2.2
;
.
uRange
.
value
=
*
2.0
;
T
?.
begin
(
'ssf smooth'
)
;
let
=
this
.
depthRT
.
texture
;
for
(
let
=
0
;
<
4
;
++
)
{
.
uZ
.
value
=
;
.
uDir
.
value
.
set
(
&
1
?
0
:
1
,
&
1
?
1
:
0
)
;
.
setRenderTarget
(
this
.
smooth
[
&
1
]
)
;
.
render
(
this
.
smQ
,
this
.
cam
)
;
=
this
.
smooth
[
&
1
]
.
texture
;
}
T
?.
begin
(
'ssf normal'
)
;
this
.
nrmU
.
uZ
.
value
=
;
.
setRenderTarget
(
this
.
nrmRT
)
;
.
render
(
this
.
nrmQ
,
this
.
cam
)
;
for
(
const
of
this
.
ssfTargets
)
.
scissorTest
=
false
;
this
.
compU
.
uCamWorld
.
value
.
copy
(
.
matrixWorld
)
;
}
screenRect
(
camera, out
)
{
const
B
=
this
.
_rect
;
B
[
0
]
=
B
[
1
]
=
1
;
B
[
2
]
=
B
[
3
]
=
-
1
;
B
[
4
]
=
0
;
for
(
const
of
this
.
handles
)
{
if
(
!
.
active
)
continue
;
const
=
Math
.
cos
(
.
yaw
)
,
=
Math
.
sin
(
.
yaw
)
,
=
Math
.
min
(
.
margin
,
1
)
+
0.3
;
const
=
.
n
[
0
]
*
.
h
/
2
+
,
=
.
n
[
2
]
*
.
h
/
2
+
,
=
.
n
[
1
]
*
.
h
+
;
for
(
let
=
0
;
<
8
;
++
)
{
const
=
&
1
?
:
-
,
=
&
2
?
:
-
,
=
&
4
?
:
-
;
this
.
corner
(
,
.
position
.
x
+
*
-
*
,
.
position
.
y
+
,
.
position
.
z
+
*
+
*
)
;
}
if
(
.
holdOn
||
.
thrown
<
1.2
)
{
const
=
.
holdR
*
4
,
=
.
holdPos
;
for
(
let
=
0
;
<
8
;
++
)
this
.
corner
(
,
.
x
+
(
&
1
?
:
-
)
,
.
y
+
(
&
4
?
:
-
)
,
.
z
+
(
&
2
?
:
-
)
)
;
}
}
if
(
B
[
4
]
)
.
set
(
-
1
,
-
1
,
1
,
1
)
;
else
.
set
(
Math
.
max
(
B
[
0
]
-
0.01
,
-
1
)
,
Math
.
max
(
B
[
1
]
-
0.01
,
-
1
)
,
Math
.
min
(
B
[
2
]
+
0.01
,
1
)
,
Math
.
min
(
B
[
3
]
+
0.01
,
1
)
)
;
}
corner
(
camera, x, y, z
)
{
const
B
=
this
.
_rect
;
.
set
(
,
,
)
.
applyMatrix4
(
.
matrixWorldInverse
)
;
if
(
.
z
>
-
.
near
*
1.5
)
{
B
[
4
]
=
1
;
return
;
}
.
applyMatrix4
(
.
projectionMatrix
)
;
B
[
0
]
=
Math
.
min
(
B
[
0
]
,
.
x
)
;
B
[
1
]
=
Math
.
min
(
B
[
1
]
,
.
y
)
;
B
[
2
]
=
Math
.
max
(
B
[
2
]
,
.
x
)
;
B
[
3
]
=
Math
.
max
(
B
[
3
]
,
.
y
)
;
}
clear
(
)
{
const
=
this
.
renderer
,
=
.
getRenderTarget
(
)
;
.
setClearColor
(
0x000000
,
0
)
;
for
(
const
of
[
...
this
.
state
,
...
this
.
white
,
...
this
.
P
]
)
{
.
setRenderTarget
(
)
;
.
clear
(
true
,
false
,
false
)
;
}
.
setRenderTarget
(
)
;
this
.
cursor
=
0
;
this
.
bind
(
)
;
}
warm
(
)
{
const
=
new
THREE. Vector3
(
0
,
0
,
-
30
)
,
=
new
THREE. Vector3
(
0
,
0.5
,
-
30
)
;
const
=
this
.
acquire
(
{
size
:
[
2
,
2
,
2
]
,
position
:
}
)
;
.
burst
(
,
0.3
,
.
set
(
0
,
0
,
0
)
,
0.05
)
;
.
jet
(
,
.
set
(
0
,
1
,
0
)
,
4
,
0.1
,
1
/
60
)
;
.
hold
(
,
0.3
)
;
this
.
update
(
1
/
60
,
this
.
fx
.
camera
)
;
.
release
(
)
;
this
.
update
(
1
/
60
,
this
.
fx
.
camera
)
;
const
=
this
.
renderer
,
=
this
.
fx
.
ground
;
if
(
this
.
paint
&&
?.
)
{
this
.
paint
.
visible
=
true
;
.
setRenderTarget
(
.
paintTarget
)
;
.
render
(
this
.
paint
,
.
paintCamera
)
;
.
setRenderTarget
(
null
)
;
this
.
paint
.
visible
=
false
;
}
this
.
clear
(
)
;
}
}