@neutrinoparticles/js-v1.1-phaser 1.0.0 → 1.0.1
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/CHANGELOG.md +4 -1
- package/dist/neutrinoparticles.js-v1.1-phaser.cjs.js +129 -46
- package/dist/neutrinoparticles.js-v1.1-phaser.cjs.js.map +1 -1
- package/dist/neutrinoparticles.js-v1.1-phaser.es.js +195 -112
- package/dist/neutrinoparticles.js-v1.1-phaser.es.js.map +1 -1
- package/dist/neutrinoparticles.js-v1.1-phaser.umd.js +129 -46
- package/dist/neutrinoparticles.js-v1.1-phaser.umd.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (s, e, t) =>
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var N = (s, e, t) => e in s ? F(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var n = (s, e, t) => N(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import Phaser from "phaser";
|
|
5
5
|
import * as Neutrino from "@neutrinoparticles/js-v1.1";
|
|
6
6
|
const vertexShaderSource = `#version 300 es
|
|
@@ -174,6 +174,10 @@ void main() {
|
|
|
174
174
|
// by the sign of w). Forces a discard outside the [-w,w] cube at the end.
|
|
175
175
|
bool nearPlaneClipped = (sp1.w < 1e-3) || (sp2.w < 1e-3);
|
|
176
176
|
|
|
177
|
+
// #236: set when the segment itself is degenerate (much shorter than
|
|
178
|
+
// the ribbon half-width) - the pair is discarded like nearPlaneClipped.
|
|
179
|
+
bool stripDegenerate = false;
|
|
180
|
+
|
|
177
181
|
// Aspect correction so the 2D Faced ortho gives visually-perpendicular
|
|
178
182
|
// dirs on non-square viewports (inverted before gl_Position).
|
|
179
183
|
vec2 aspectMul = vec2(1.0, 1.0 / max(uViewportAspect, 1e-6));
|
|
@@ -211,9 +215,15 @@ void main() {
|
|
|
211
215
|
float wlen01 = length(wp01);
|
|
212
216
|
float wlen12 = length(wp12);
|
|
213
217
|
float wlen23 = length(wp23);
|
|
218
|
+
// #236: degeneracy guards at visual scale (mirror of GPU33).
|
|
219
|
+
// A segment much shorter than the ribbon half-width cannot define
|
|
220
|
+
// a visually meaningful direction; a degenerate neighbour falls
|
|
221
|
+
// back to the straight cap instead of a noise knee.
|
|
222
|
+
float wDegenEps = max(max(abs(halfSize1), abs(halfSize2)) * 0.02, 1e-6);
|
|
223
|
+
if (wlen12 < wDegenEps) stripDegenerate = true;
|
|
214
224
|
vec3 wdir12 = (wlen12 > 1e-6) ? (wp12 / wlen12) : vec3(1.0, 0.0, 0.0);
|
|
215
|
-
vec3 wdir01 = (wlen01 >
|
|
216
|
-
vec3 wdir23 = (wlen23 >
|
|
225
|
+
vec3 wdir01 = (wlen01 > wDegenEps) ? (wp01 / wlen01) : wdir12;
|
|
226
|
+
vec3 wdir23 = (wlen23 > wDegenEps) ? (wp23 / wlen23) : wdir12;
|
|
217
227
|
noKnee1 = dot(wdir01, wdir12) > 0.999;
|
|
218
228
|
noKnee2 = dot(wdir12, wdir23) > 0.999;
|
|
219
229
|
pathLen12 = wlen12;
|
|
@@ -225,9 +235,12 @@ void main() {
|
|
|
225
235
|
vec3 K1 = Kmul1 * normalize(cross(wdir01 + wdir12, n1));
|
|
226
236
|
Bmul1 = sign(dot(B1raw, K1));
|
|
227
237
|
vec3 B1 = B1raw * Bmul1;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
238
|
+
// #236: inner vertex at the ribbon half-width along the
|
|
239
|
+
// bisector, symmetric to the outer vertex (mirror of GPU33).
|
|
240
|
+
// The old true-miter-with-neighbour-length-clamp cut an
|
|
241
|
+
// uncovered wedge out of sharp bends whenever halfSize
|
|
242
|
+
// exceeded the particle spacing.
|
|
243
|
+
float ik1 = halfSize1;
|
|
231
244
|
worldK1 = p1 + K1 * halfSize1;
|
|
232
245
|
worldB1 = p1 + B1 * halfSize1;
|
|
233
246
|
worldIK1 = p1 - K1 * ik1;
|
|
@@ -248,9 +261,8 @@ void main() {
|
|
|
248
261
|
vec3 K2 = Kmul2 * normalize(cross(wdir12 + wdir23, n2));
|
|
249
262
|
Bmul2 = sign(dot(B2raw, K2));
|
|
250
263
|
vec3 B2 = B2raw * Bmul2;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (dot( wdir23, ik2 * -K2) > wlen23) ik2 = wlen23;
|
|
264
|
+
// #236: see ik1 - inner vertex at the ribbon half-width.
|
|
265
|
+
float ik2 = halfSize2;
|
|
254
266
|
worldK2 = p2 + K2 * halfSize2;
|
|
255
267
|
worldB2 = p2 + B2 * halfSize2;
|
|
256
268
|
worldIK2 = p2 - K2 * ik2;
|
|
@@ -278,12 +290,6 @@ void main() {
|
|
|
278
290
|
float len01 = length(d01);
|
|
279
291
|
float len12 = length(d12);
|
|
280
292
|
float len23 = length(d23);
|
|
281
|
-
vec2 dir12 = (len12 > 1e-6) ? (d12 / len12) : vec2(1.0, 0.0);
|
|
282
|
-
vec2 dir01 = (len01 > 1e-6) ? (d01 / len01) : dir12;
|
|
283
|
-
vec2 dir23 = (len23 > 1e-6) ? (d23 / len23) : dir12;
|
|
284
|
-
noKnee1 = dot(dir01, dir12) > 0.999;
|
|
285
|
-
noKnee2 = dot(dir12, dir23) > 0.999;
|
|
286
|
-
pathLen12 = len12;
|
|
287
293
|
|
|
288
294
|
// Section magnitude: project camera_up*halfSize per anchor into NDC.
|
|
289
295
|
vec4 spU1 = mvpMatrix * vec4(p1 + uCameraUp * halfSize1, 1.0);
|
|
@@ -291,15 +297,25 @@ void main() {
|
|
|
291
297
|
float ndcHalfSize1 = length((spU1.xy / spU1.w) * aspectMul - ndc1);
|
|
292
298
|
float ndcHalfSize2 = length((spU2.xy / spU2.w) * aspectMul - ndc2);
|
|
293
299
|
|
|
300
|
+
// #236: degeneracy guards at visual scale (mirror of GPU33).
|
|
301
|
+
float degenEps = max(max(ndcHalfSize1, ndcHalfSize2) * 0.02, 1e-6);
|
|
302
|
+
if (len12 < degenEps) stripDegenerate = true;
|
|
303
|
+
vec2 dir12 = (len12 > 1e-6) ? (d12 / len12) : vec2(1.0, 0.0);
|
|
304
|
+
vec2 dir01 = (len01 > degenEps) ? (d01 / len01) : dir12;
|
|
305
|
+
vec2 dir23 = (len23 > degenEps) ? (d23 / len23) : dir12;
|
|
306
|
+
noKnee1 = dot(dir01, dir12) > 0.999;
|
|
307
|
+
noKnee2 = dot(dir12, dir23) > 0.999;
|
|
308
|
+
pathLen12 = len12;
|
|
309
|
+
|
|
294
310
|
vec2 B = stripOrtho(dir12);
|
|
295
311
|
if (!noKnee1) {
|
|
296
312
|
float Kmul1 = -sign(dot(stripOrtho(dir01), dir12));
|
|
297
313
|
vec2 K1 = Kmul1 * normalize(stripOrtho(dir01 + dir12));
|
|
298
314
|
Bmul1 = sign(dot(B, K1));
|
|
299
315
|
vec2 B1 = B * Bmul1;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
316
|
+
// #236: inner vertex at the ribbon half-width (see the Free
|
|
317
|
+
// branch comment above).
|
|
318
|
+
float ik1 = ndcHalfSize1;
|
|
303
319
|
k1 = ndc1 + K1 * ndcHalfSize1;
|
|
304
320
|
b1 = ndc1 + B1 * ndcHalfSize1;
|
|
305
321
|
IK1 = ndc1 - K1 * ik1;
|
|
@@ -317,9 +333,8 @@ void main() {
|
|
|
317
333
|
vec2 K2 = Kmul2 * normalize(stripOrtho(dir12 + dir23));
|
|
318
334
|
Bmul2 = sign(dot(B, K2));
|
|
319
335
|
vec2 B2 = B * Bmul2;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (dot(dir23, ik2 * -K2) > len23) ik2 = len23;
|
|
336
|
+
// #236: see ik1 - inner vertex at the ribbon half-width.
|
|
337
|
+
float ik2 = ndcHalfSize2;
|
|
323
338
|
k2 = ndc2 + K2 * ndcHalfSize2;
|
|
324
339
|
b2 = ndc2 + B2 * ndcHalfSize2;
|
|
325
340
|
IK2 = ndc2 - K2 * ik2;
|
|
@@ -334,6 +349,33 @@ void main() {
|
|
|
334
349
|
}
|
|
335
350
|
}
|
|
336
351
|
|
|
352
|
+
// #236: a noKnee (straight-cap) end carries no bend side of its own -
|
|
353
|
+
// its raw side label is always the +B side. If the segment's other
|
|
354
|
+
// end is a real knee on the -B side, the mismatched labels would send
|
|
355
|
+
// the ladder into the opposite-sides (twist) branch and flip the
|
|
356
|
+
// texture V across a segment that does not actually change bend side.
|
|
357
|
+
// Relabel the straight end to the knee end's side (swap its k/IK and
|
|
358
|
+
// re-collapse b onto the new k) so the ladder stays untwisted. Both
|
|
359
|
+
// frames are swapped; only the active one is meaningful.
|
|
360
|
+
if (noKnee1 && !noKnee2 && Bmul2 < 0.0) {
|
|
361
|
+
// Swap only the ACTIVE frame's variables - the inactive frame's
|
|
362
|
+
// are uninitialized and must not be read.
|
|
363
|
+
if (isFreeRotation) {
|
|
364
|
+
vec3 tRw1 = worldK1; worldK1 = worldIK1; worldIK1 = tRw1; worldB1 = worldK1;
|
|
365
|
+
} else {
|
|
366
|
+
vec2 tRl1 = k1; k1 = IK1; IK1 = tRl1; b1 = k1;
|
|
367
|
+
}
|
|
368
|
+
Bmul1 = Bmul2;
|
|
369
|
+
}
|
|
370
|
+
if (noKnee2 && !noKnee1 && Bmul1 < 0.0) {
|
|
371
|
+
if (isFreeRotation) {
|
|
372
|
+
vec3 tRw2 = worldK2; worldK2 = worldIK2; worldIK2 = tRw2; worldB2 = worldK2;
|
|
373
|
+
} else {
|
|
374
|
+
vec2 tRl2 = k2; k2 = IK2; IK2 = tRl2; b2 = k2;
|
|
375
|
+
}
|
|
376
|
+
Bmul2 = Bmul1;
|
|
377
|
+
}
|
|
378
|
+
|
|
337
379
|
// V coords (mirror of preview3 / GPU33 make*Strip):
|
|
338
380
|
// V at outer knee (k) = (Bmul + 1) * 0.5
|
|
339
381
|
// V at inner knee (IK) = 1 - V_outer ; bend (b) = outer
|
|
@@ -435,7 +477,10 @@ void main() {
|
|
|
435
477
|
|
|
436
478
|
// Free projects the world-space vertex through MVP directly; Faced
|
|
437
479
|
// reconstructs clip space from aspect-corrected NDC (mirror of preview3).
|
|
438
|
-
if (
|
|
480
|
+
if (stripDegenerate) {
|
|
481
|
+
// #236: sub-visual segment - discard the pair entirely.
|
|
482
|
+
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
483
|
+
} else if (isFreeRotation) {
|
|
439
484
|
gl_Position = mvpMatrix * vec4(vertPos3D, 1.0);
|
|
440
485
|
} else if (nearPlaneClipped) {
|
|
441
486
|
// At least one anchor is at / behind the near plane → the NDC math
|
|
@@ -770,6 +815,10 @@ void main() {
|
|
|
770
815
|
// unaffected by the sign of w).
|
|
771
816
|
bool nearPlaneClipped = (sp1.w < 1e-3) || (sp2.w < 1e-3);
|
|
772
817
|
|
|
818
|
+
// #236: set when the segment itself is degenerate (much shorter than
|
|
819
|
+
// the ribbon half-width) - the pair is discarded like nearPlaneClipped.
|
|
820
|
+
bool stripDegenerate = false;
|
|
821
|
+
|
|
773
822
|
// Aspect correction for the 2D Faced ortho on non-square viewports.
|
|
774
823
|
vec2 aspectMul = vec2(1.0, 1.0 / max(uViewportAspect, 1e-6));
|
|
775
824
|
|
|
@@ -812,9 +861,12 @@ void main() {
|
|
|
812
861
|
float wlen01 = length(wp01);
|
|
813
862
|
float wlen12 = length(wp12);
|
|
814
863
|
float wlen23 = length(wp23);
|
|
864
|
+
// #236: degeneracy guards at visual scale (mirror of GPU33).
|
|
865
|
+
float wDegenEps = max(max(abs(halfSize1), abs(halfSize2)) * 0.02, 1e-6);
|
|
866
|
+
if (wlen12 < wDegenEps) stripDegenerate = true;
|
|
815
867
|
vec3 wdir12 = (wlen12 > 1e-6) ? (wp12 / wlen12) : vec3(1.0, 0.0, 0.0);
|
|
816
|
-
vec3 wdir01 = (wlen01 >
|
|
817
|
-
vec3 wdir23 = (wlen23 >
|
|
868
|
+
vec3 wdir01 = (wlen01 > wDegenEps) ? (wp01 / wlen01) : wdir12;
|
|
869
|
+
vec3 wdir23 = (wlen23 > wDegenEps) ? (wp23 / wlen23) : wdir12;
|
|
818
870
|
noKnee1 = dot(wdir01, wdir12) > 0.999;
|
|
819
871
|
noKnee2 = dot(wdir12, wdir23) > 0.999;
|
|
820
872
|
pathLen12 = wlen12;
|
|
@@ -826,9 +878,9 @@ void main() {
|
|
|
826
878
|
vec3 K1 = Kmul1 * normalize(cross(wdir01 + wdir12, n1));
|
|
827
879
|
Bmul1 = sign(dot(B1raw, K1));
|
|
828
880
|
vec3 B1 = B1raw * Bmul1;
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
881
|
+
// #236: inner vertex at the ribbon half-width (mirror of
|
|
882
|
+
// GPU33; see the ES 3.00 shader for the rationale).
|
|
883
|
+
float ik1 = halfSize1;
|
|
832
884
|
worldK1 = p1 + K1 * halfSize1;
|
|
833
885
|
worldB1 = p1 + B1 * halfSize1;
|
|
834
886
|
worldIK1 = p1 - K1 * ik1;
|
|
@@ -849,9 +901,8 @@ void main() {
|
|
|
849
901
|
vec3 K2 = Kmul2 * normalize(cross(wdir12 + wdir23, n2));
|
|
850
902
|
Bmul2 = sign(dot(B2raw, K2));
|
|
851
903
|
vec3 B2 = B2raw * Bmul2;
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
if (dot( wdir23, ik2 * -K2) > wlen23) ik2 = wlen23;
|
|
904
|
+
// #236: see ik1 - inner vertex at the ribbon half-width.
|
|
905
|
+
float ik2 = halfSize2;
|
|
855
906
|
worldK2 = p2 + K2 * halfSize2;
|
|
856
907
|
worldB2 = p2 + B2 * halfSize2;
|
|
857
908
|
worldIK2 = p2 - K2 * ik2;
|
|
@@ -879,12 +930,6 @@ void main() {
|
|
|
879
930
|
float len01 = length(d01);
|
|
880
931
|
float len12 = length(d12);
|
|
881
932
|
float len23 = length(d23);
|
|
882
|
-
vec2 dir12 = (len12 > 1e-6) ? (d12 / len12) : vec2(1.0, 0.0);
|
|
883
|
-
vec2 dir01 = (len01 > 1e-6) ? (d01 / len01) : dir12;
|
|
884
|
-
vec2 dir23 = (len23 > 1e-6) ? (d23 / len23) : dir12;
|
|
885
|
-
noKnee1 = dot(dir01, dir12) > 0.999;
|
|
886
|
-
noKnee2 = dot(dir12, dir23) > 0.999;
|
|
887
|
-
pathLen12 = len12;
|
|
888
933
|
|
|
889
934
|
// Section magnitude: project camera_up*halfSize per anchor into NDC.
|
|
890
935
|
vec4 spU1 = mvpMatrix * vec4(p1 + uCameraUp * halfSize1, 1.0);
|
|
@@ -892,15 +937,24 @@ void main() {
|
|
|
892
937
|
float ndcHalfSize1 = length((spU1.xy / spU1.w) * aspectMul - ndc1);
|
|
893
938
|
float ndcHalfSize2 = length((spU2.xy / spU2.w) * aspectMul - ndc2);
|
|
894
939
|
|
|
940
|
+
// #236: degeneracy guards at visual scale (mirror of GPU33).
|
|
941
|
+
float degenEps = max(max(ndcHalfSize1, ndcHalfSize2) * 0.02, 1e-6);
|
|
942
|
+
if (len12 < degenEps) stripDegenerate = true;
|
|
943
|
+
vec2 dir12 = (len12 > 1e-6) ? (d12 / len12) : vec2(1.0, 0.0);
|
|
944
|
+
vec2 dir01 = (len01 > degenEps) ? (d01 / len01) : dir12;
|
|
945
|
+
vec2 dir23 = (len23 > degenEps) ? (d23 / len23) : dir12;
|
|
946
|
+
noKnee1 = dot(dir01, dir12) > 0.999;
|
|
947
|
+
noKnee2 = dot(dir12, dir23) > 0.999;
|
|
948
|
+
pathLen12 = len12;
|
|
949
|
+
|
|
895
950
|
vec2 B = stripOrtho(dir12);
|
|
896
951
|
if (!noKnee1) {
|
|
897
952
|
float Kmul1 = -sign(dot(stripOrtho(dir01), dir12));
|
|
898
953
|
vec2 K1 = Kmul1 * normalize(stripOrtho(dir01 + dir12));
|
|
899
954
|
Bmul1 = sign(dot(B, K1));
|
|
900
955
|
vec2 B1 = B * Bmul1;
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
if (dot(dir12, ik1 * -K1) > len12) ik1 = len12;
|
|
956
|
+
// #236: inner vertex at the ribbon half-width.
|
|
957
|
+
float ik1 = ndcHalfSize1;
|
|
904
958
|
k1 = ndc1 + K1 * ndcHalfSize1;
|
|
905
959
|
b1 = ndc1 + B1 * ndcHalfSize1;
|
|
906
960
|
IK1 = ndc1 - K1 * ik1;
|
|
@@ -918,9 +972,8 @@ void main() {
|
|
|
918
972
|
vec2 K2 = Kmul2 * normalize(stripOrtho(dir12 + dir23));
|
|
919
973
|
Bmul2 = sign(dot(B, K2));
|
|
920
974
|
vec2 B2 = B * Bmul2;
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
if (dot(dir23, ik2 * -K2) > len23) ik2 = len23;
|
|
975
|
+
// #236: see ik1 - inner vertex at the ribbon half-width.
|
|
976
|
+
float ik2 = ndcHalfSize2;
|
|
924
977
|
k2 = ndc2 + K2 * ndcHalfSize2;
|
|
925
978
|
b2 = ndc2 + B2 * ndcHalfSize2;
|
|
926
979
|
IK2 = ndc2 - K2 * ik2;
|
|
@@ -935,6 +988,33 @@ void main() {
|
|
|
935
988
|
}
|
|
936
989
|
}
|
|
937
990
|
|
|
991
|
+
// #236: a noKnee (straight-cap) end carries no bend side of its own -
|
|
992
|
+
// its raw side label is always the +B side. If the segment's other
|
|
993
|
+
// end is a real knee on the -B side, the mismatched labels would send
|
|
994
|
+
// the ladder into the opposite-sides (twist) branch and flip the
|
|
995
|
+
// texture V across a segment that does not actually change bend side.
|
|
996
|
+
// Relabel the straight end to the knee end's side (swap its k/IK and
|
|
997
|
+
// re-collapse b onto the new k) so the ladder stays untwisted. Both
|
|
998
|
+
// frames are swapped; only the active one is meaningful.
|
|
999
|
+
if (noKnee1 && !noKnee2 && Bmul2 < 0.0) {
|
|
1000
|
+
// Swap only the ACTIVE frame's variables - the inactive frame's
|
|
1001
|
+
// are uninitialized and must not be read.
|
|
1002
|
+
if (isFreeRotation) {
|
|
1003
|
+
vec3 tRw1 = worldK1; worldK1 = worldIK1; worldIK1 = tRw1; worldB1 = worldK1;
|
|
1004
|
+
} else {
|
|
1005
|
+
vec2 tRl1 = k1; k1 = IK1; IK1 = tRl1; b1 = k1;
|
|
1006
|
+
}
|
|
1007
|
+
Bmul1 = Bmul2;
|
|
1008
|
+
}
|
|
1009
|
+
if (noKnee2 && !noKnee1 && Bmul1 < 0.0) {
|
|
1010
|
+
if (isFreeRotation) {
|
|
1011
|
+
vec3 tRw2 = worldK2; worldK2 = worldIK2; worldIK2 = tRw2; worldB2 = worldK2;
|
|
1012
|
+
} else {
|
|
1013
|
+
vec2 tRl2 = k2; k2 = IK2; IK2 = tRl2; b2 = k2;
|
|
1014
|
+
}
|
|
1015
|
+
Bmul2 = Bmul1;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
938
1018
|
// V coords: V at outer knee (k) = (Bmul + 1) * 0.5; inner = 1 - outer.
|
|
939
1019
|
float Vtop1 = (Bmul1 + 1.0) * 0.5;
|
|
940
1020
|
float Vbot1 = 1.0 - Vtop1;
|
|
@@ -1006,7 +1086,10 @@ void main() {
|
|
|
1006
1086
|
|
|
1007
1087
|
// Free projects the world-space vertex through MVP directly; Faced
|
|
1008
1088
|
// reconstructs clip space from aspect-corrected NDC.
|
|
1009
|
-
if (
|
|
1089
|
+
if (stripDegenerate) {
|
|
1090
|
+
// #236: sub-visual segment - discard the pair entirely.
|
|
1091
|
+
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
1092
|
+
} else if (isFreeRotation) {
|
|
1010
1093
|
gl_Position = mvpMatrix * vec4(vertPos3D, 1.0);
|
|
1011
1094
|
} else if (nearPlaneClipped) {
|
|
1012
1095
|
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
@@ -1152,7 +1235,7 @@ void main() {
|
|
|
1152
1235
|
// world alpha scales the whole RGBA (mirror of the ES 3.00 shader).
|
|
1153
1236
|
gl_FragColor = texColor * vColor * uWorldAlpha;
|
|
1154
1237
|
}
|
|
1155
|
-
`,
|
|
1238
|
+
`, A = class A {
|
|
1156
1239
|
constructor(e, t) {
|
|
1157
1240
|
n(this, "neutrino");
|
|
1158
1241
|
// On a WebGL1 context this actually holds a WebGLRenderingContext; the
|
|
@@ -1165,7 +1248,7 @@ void main() {
|
|
|
1165
1248
|
n(this, "_vao", null);
|
|
1166
1249
|
// WebGL1 render path state (TDD_js-v1.1-webgl1.md)
|
|
1167
1250
|
n(this, "_isWebGL1", !1);
|
|
1168
|
-
n(this, "_maxBatchTextures",
|
|
1251
|
+
n(this, "_maxBatchTextures", A.MAX_BATCH_TEXTURES);
|
|
1169
1252
|
n(this, "_hasElementIndexUint", !1);
|
|
1170
1253
|
n(this, "_vaoExt", null);
|
|
1171
1254
|
n(this, "_aIdBuffer", null);
|
|
@@ -1268,12 +1351,12 @@ void main() {
|
|
|
1268
1351
|
throw new Error(
|
|
1269
1352
|
`NeutrinoParticles (js-v1.1): the effect needs 32-bit indices (${e} particles) but this WebGL1 context lacks OES_element_index_uint.`
|
|
1270
1353
|
);
|
|
1271
|
-
const
|
|
1354
|
+
const d = l ? new Uint32Array(e * 6) : new Uint16Array(e * 6);
|
|
1272
1355
|
for (let i = 0; i < e; i++) {
|
|
1273
|
-
const u = i * 4,
|
|
1274
|
-
|
|
1356
|
+
const u = i * 4, g = i * 6;
|
|
1357
|
+
d[g + 0] = u + 0, d[g + 1] = u + 1, d[g + 2] = u + 2, d[g + 3] = u + 0, d[g + 4] = u + 2, d[g + 5] = u + 3;
|
|
1275
1358
|
}
|
|
1276
|
-
if (this._indexBuffer = t.createBuffer(), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this._indexBuffer), t.bufferData(t.ELEMENT_ARRAY_BUFFER,
|
|
1359
|
+
if (this._indexBuffer = t.createBuffer(), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this._indexBuffer), t.bufferData(t.ELEMENT_ARRAY_BUFFER, d, t.STATIC_DRAW), this._isWebGL1) {
|
|
1277
1360
|
const i = new Float32Array(e * 4);
|
|
1278
1361
|
for (let u = 0; u < i.length; u++) i[u] = u;
|
|
1279
1362
|
this._aIdBuffer = t.createBuffer(), t.bindBuffer(t.ARRAY_BUFFER, this._aIdBuffer), t.bufferData(t.ARRAY_BUFFER, i, t.STATIC_DRAW);
|
|
@@ -1325,7 +1408,7 @@ void main() {
|
|
|
1325
1408
|
const r = e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS), o = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);
|
|
1326
1409
|
this._maxBatchTextures = Math.max(
|
|
1327
1410
|
1,
|
|
1328
|
-
Math.min(
|
|
1411
|
+
Math.min(A.MAX_BATCH_TEXTURES, r - 2, o)
|
|
1329
1412
|
);
|
|
1330
1413
|
}
|
|
1331
1414
|
/**
|
|
@@ -1350,31 +1433,31 @@ void main() {
|
|
|
1350
1433
|
`, a = `precision mediump float;
|
|
1351
1434
|
varying vec4 vC;
|
|
1352
1435
|
void main() { gl_FragColor = vC; }
|
|
1353
|
-
`, r = e.getParameter(e.VIEWPORT), o = e.getParameter(e.CURRENT_PROGRAM), l = e.getParameter(e.ARRAY_BUFFER_BINDING),
|
|
1436
|
+
`, r = e.getParameter(e.VIEWPORT), o = e.getParameter(e.CURRENT_PROGRAM), l = e.getParameter(e.ARRAY_BUFFER_BINDING), d = e.getParameter(e.FRAMEBUFFER_BINDING), i = e.getParameter(e.ACTIVE_TEXTURE);
|
|
1354
1437
|
e.activeTexture(e.TEXTURE0);
|
|
1355
1438
|
const u = e.getParameter(e.TEXTURE_BINDING_2D);
|
|
1356
1439
|
e.activeTexture(e.TEXTURE1);
|
|
1357
|
-
const
|
|
1358
|
-
let x = null, b = null, B = null, p = null, v = null, T = null,
|
|
1440
|
+
const g = e.getParameter(e.TEXTURE_BINDING_2D), I = e.isEnabled(e.BLEND), E = e.isEnabled(e.DEPTH_TEST), U = e.isEnabled(e.SCISSOR_TEST);
|
|
1441
|
+
let x = null, b = null, B = null, p = null, v = null, T = null, c = -1, w = !1, f = null, h = 4, y = 0, _ = 0, P = 0, D = !1, S = !1;
|
|
1359
1442
|
const m = new Uint8Array(4);
|
|
1360
1443
|
try {
|
|
1361
1444
|
x = e.createProgram(), e.attachShader(x, this._compileShader(e.VERTEX_SHADER, t)), e.attachShader(x, this._compileShader(e.FRAGMENT_SHADER, a)), e.linkProgram(x);
|
|
1362
|
-
const C = (R,
|
|
1445
|
+
const C = (R, K) => {
|
|
1363
1446
|
const M = e.createTexture();
|
|
1364
|
-
return e.bindTexture(e.TEXTURE_2D, M), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, R,
|
|
1447
|
+
return e.bindTexture(e.TEXTURE_2D, M), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, R, K), M;
|
|
1365
1448
|
};
|
|
1366
|
-
e.activeTexture(e.TEXTURE0), b = C(e.FLOAT, new Float32Array([1, 0.5, 0.25, 1])), B = C(e.UNSIGNED_BYTE, new Uint8Array([51, 102, 153, 255])), p = e.createTexture(), e.bindTexture(e.TEXTURE_2D, p), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, null), v = e.createFramebuffer(), e.bindFramebuffer(e.FRAMEBUFFER, v), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, p, 0), T = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, T), e.bufferData(e.ARRAY_BUFFER, new Float32Array([0]), e.STATIC_DRAW),
|
|
1449
|
+
e.activeTexture(e.TEXTURE0), b = C(e.FLOAT, new Float32Array([1, 0.5, 0.25, 1])), B = C(e.UNSIGNED_BYTE, new Uint8Array([51, 102, 153, 255])), p = e.createTexture(), e.bindTexture(e.TEXTURE_2D, p), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, null), v = e.createFramebuffer(), e.bindFramebuffer(e.FRAMEBUFFER, v), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, p, 0), T = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, T), e.bufferData(e.ARRAY_BUFFER, new Float32Array([0]), e.STATIC_DRAW), S = e.getProgramParameter(x, e.LINK_STATUS), S && (e.useProgram(x), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, b), e.activeTexture(e.TEXTURE1), e.bindTexture(e.TEXTURE_2D, B), e.uniform1i(e.getUniformLocation(x, "uF"), 0), e.uniform1i(e.getUniformLocation(x, "uB"), 1), c = e.getAttribLocation(x, "aId"), w = e.getVertexAttrib(c, e.VERTEX_ATTRIB_ARRAY_ENABLED), f = e.getVertexAttrib(c, e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING), h = e.getVertexAttrib(c, e.VERTEX_ATTRIB_ARRAY_SIZE), y = e.getVertexAttrib(c, e.VERTEX_ATTRIB_ARRAY_TYPE), D = e.getVertexAttrib(c, e.VERTEX_ATTRIB_ARRAY_NORMALIZED), _ = e.getVertexAttrib(c, e.VERTEX_ATTRIB_ARRAY_STRIDE), P = e.getVertexAttribOffset(c, e.VERTEX_ATTRIB_ARRAY_POINTER), e.enableVertexAttribArray(c), e.vertexAttribPointer(c, 1, e.FLOAT, !1, 0, 0), e.viewport(0, 0, 1, 1), e.disable(e.BLEND), e.disable(e.DEPTH_TEST), e.disable(e.SCISSOR_TEST), e.drawArrays(e.POINTS, 0, 1), e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, m), S = Math.abs(m[0] - 51) <= 2 && Math.abs(m[1] - 51) <= 2 && Math.abs(m[2] - 38) <= 2);
|
|
1367
1450
|
} finally {
|
|
1368
|
-
|
|
1369
|
-
|
|
1451
|
+
c >= 0 && (f && (e.bindBuffer(e.ARRAY_BUFFER, f), e.vertexAttribPointer(
|
|
1452
|
+
c,
|
|
1370
1453
|
h,
|
|
1371
1454
|
y,
|
|
1372
1455
|
D,
|
|
1373
|
-
|
|
1456
|
+
_,
|
|
1374
1457
|
P
|
|
1375
|
-
)), w ? e.enableVertexAttribArray(
|
|
1458
|
+
)), w ? e.enableVertexAttribArray(c) : e.disableVertexAttribArray(c)), v && e.deleteFramebuffer(v), p && e.deleteTexture(p), b && e.deleteTexture(b), B && e.deleteTexture(B), T && e.deleteBuffer(T), x && e.deleteProgram(x), e.bindFramebuffer(e.FRAMEBUFFER, d), e.bindBuffer(e.ARRAY_BUFFER, l), e.useProgram(o), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, u), e.activeTexture(e.TEXTURE1), e.bindTexture(e.TEXTURE_2D, g), e.activeTexture(i), I && e.enable(e.BLEND), E && e.enable(e.DEPTH_TEST), U && e.enable(e.SCISSOR_TEST), e.viewport(r[0], r[1], r[2], r[3]);
|
|
1376
1459
|
}
|
|
1377
|
-
if (!
|
|
1460
|
+
if (!S)
|
|
1378
1461
|
throw new Error(
|
|
1379
1462
|
`NeutrinoParticles (js-v1.1): WebGL1 vertex texture fetch smoke test failed (got ${m[0]},${m[1]},${m[2]}); WebGL2 or WebGL1 with working vertex float textures is required.`
|
|
1380
1463
|
);
|
|
@@ -1384,7 +1467,7 @@ void main() { gl_FragColor = vC; }
|
|
|
1384
1467
|
if (this._shaderProgram = e.createProgram(), e.attachShader(this._shaderProgram, r), e.attachShader(this._shaderProgram, o), e.linkProgram(this._shaderProgram), !e.getProgramParameter(this._shaderProgram, e.LINK_STATUS))
|
|
1385
1468
|
throw new Error("Shader link error: " + e.getProgramInfoLog(this._shaderProgram));
|
|
1386
1469
|
e.deleteShader(r), e.deleteShader(o), this._uDataTexture = e.getUniformLocation(this._shaderProgram, "uDataTexture"), this._uCameraRight = e.getUniformLocation(this._shaderProgram, "uCameraRight"), this._uCameraUp = e.getUniformLocation(this._shaderProgram, "uCameraUp"), this._uCameraDir = e.getUniformLocation(this._shaderProgram, "uCameraDir"), this._uViewProjMatrix = e.getUniformLocation(this._shaderProgram, "uViewProjMatrix"), this._uModelMatrix = e.getUniformLocation(this._shaderProgram, "uModelMatrix"), this._uViewportAspect = e.getUniformLocation(this._shaderProgram, "uViewportAspect"), this._uWorldAlpha = e.getUniformLocation(this._shaderProgram, "uWorldAlpha"), this._isWebGL1 ? (this._uMetaTexture = e.getUniformLocation(this._shaderProgram, "uMetaTexture"), this._uDataTexSize = e.getUniformLocation(this._shaderProgram, "uDataTexSize"), this._aIdLocation = e.getAttribLocation(this._shaderProgram, "aId")) : this._uDataTextureWidth = e.getUniformLocation(this._shaderProgram, "uDataTextureWidth"), this._uTextures = [], this._uTexRemaps = [];
|
|
1387
|
-
for (let l = 0; l <
|
|
1470
|
+
for (let l = 0; l < A.MAX_BATCH_TEXTURES; l++)
|
|
1388
1471
|
this._uTextures.push(e.getUniformLocation(this._shaderProgram, `uTextures[${l}]`)), this._uTexRemaps.push(e.getUniformLocation(this._shaderProgram, `uTexRemaps[${l}]`));
|
|
1389
1472
|
}
|
|
1390
1473
|
_compileShader(e, t) {
|
|
@@ -1396,8 +1479,8 @@ void main() { gl_FragColor = vC; }
|
|
|
1396
1479
|
return r;
|
|
1397
1480
|
}
|
|
1398
1481
|
};
|
|
1399
|
-
n(
|
|
1400
|
-
let NeutrinoContext =
|
|
1482
|
+
n(A, "MAX_BATCH_TEXTURES", 8);
|
|
1483
|
+
let NeutrinoContext = A;
|
|
1401
1484
|
class GamePlugin extends Phaser.Plugins.BasePlugin {
|
|
1402
1485
|
constructor() {
|
|
1403
1486
|
super(...arguments);
|
|
@@ -1465,14 +1548,14 @@ return new NeutrinoEffect(ctx);
|
|
|
1465
1548
|
const a = this.effectModel.textures[t], r = this.gamePlugin.texturesBasePath + a, o = noext(r);
|
|
1466
1549
|
let l = this._findFrameInAtlases(s, a);
|
|
1467
1550
|
if (l || (l = this._findFrameInAtlases(s, noext(a))), !l && this.scene.sys.textures.exists(o)) {
|
|
1468
|
-
const
|
|
1469
|
-
l =
|
|
1551
|
+
const d = this.scene.sys.textures.get(o);
|
|
1552
|
+
l = d.get(d.firstFrame);
|
|
1470
1553
|
}
|
|
1471
1554
|
l ? this._onTextureLoaded(t, l) : (this.scene.load.once(
|
|
1472
1555
|
"filecomplete-image-" + o,
|
|
1473
|
-
/* @__PURE__ */ ((
|
|
1556
|
+
/* @__PURE__ */ ((d, i) => () => {
|
|
1474
1557
|
const u = this.scene.sys.textures.get(i);
|
|
1475
|
-
this._onTextureLoaded(
|
|
1558
|
+
this._onTextureLoaded(d, u.get(u.firstFrame));
|
|
1476
1559
|
})(t, o)
|
|
1477
1560
|
), this.scene.load.image(o, r));
|
|
1478
1561
|
}
|
|
@@ -1515,14 +1598,14 @@ return new NeutrinoEffect(ctx);
|
|
|
1515
1598
|
}
|
|
1516
1599
|
class NeutrinoFile extends Phaser.Loader.File {
|
|
1517
1600
|
constructor(t, a) {
|
|
1518
|
-
const { key: r, url: o, options: l, xhrSettings:
|
|
1601
|
+
const { key: r, url: o, options: l, xhrSettings: d } = a;
|
|
1519
1602
|
super(t, {
|
|
1520
1603
|
type: "binary",
|
|
1521
1604
|
extension: "js",
|
|
1522
1605
|
responseType: "text",
|
|
1523
1606
|
key: r,
|
|
1524
1607
|
url: o,
|
|
1525
|
-
xhrSettings:
|
|
1608
|
+
xhrSettings: d
|
|
1526
1609
|
});
|
|
1527
1610
|
n(this, "_options");
|
|
1528
1611
|
this.cache = t.cacheManager.binary, this._options = l;
|
|
@@ -1558,8 +1641,8 @@ class DataTextureManager {
|
|
|
1558
1641
|
);
|
|
1559
1642
|
this._gl = e, this.textureWidth = a, this.textureHeight = r, this._floatView = new Float32Array(t.buffer, t.byteOffset, t.length);
|
|
1560
1643
|
for (let l = 0; l < RING_BUFFER_SIZE$1; l++) {
|
|
1561
|
-
const
|
|
1562
|
-
e.bindTexture(e.TEXTURE_2D,
|
|
1644
|
+
const d = e.createTexture();
|
|
1645
|
+
e.bindTexture(e.TEXTURE_2D, d), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texImage2D(
|
|
1563
1646
|
e.TEXTURE_2D,
|
|
1564
1647
|
0,
|
|
1565
1648
|
e.RGBA32F,
|
|
@@ -1569,7 +1652,7 @@ class DataTextureManager {
|
|
|
1569
1652
|
e.RGBA,
|
|
1570
1653
|
e.FLOAT,
|
|
1571
1654
|
null
|
|
1572
|
-
), this._textures.push(
|
|
1655
|
+
), this._textures.push(d);
|
|
1573
1656
|
}
|
|
1574
1657
|
e.bindTexture(e.TEXTURE_2D, null);
|
|
1575
1658
|
}
|
|
@@ -1646,10 +1729,10 @@ class DataTextureManagerGL1 {
|
|
|
1646
1729
|
this._gl = e, this.textureWidth = a, this.textureHeight = r, this._floatView = new Float32Array(t.buffer, t.byteOffset, t.length), this.meta = new MetaTextureManager(a, r);
|
|
1647
1730
|
const l = e.getParameter(e.ACTIVE_TEXTURE);
|
|
1648
1731
|
e.activeTexture(e.TEXTURE0);
|
|
1649
|
-
const
|
|
1732
|
+
const d = e.getParameter(e.TEXTURE_BINDING_2D);
|
|
1650
1733
|
for (let i = 0; i < RING_BUFFER_SIZE; i++)
|
|
1651
1734
|
this._dataTextures.push(this._createTexture(e.FLOAT)), this._metaTextures.push(this._createTexture(e.UNSIGNED_BYTE));
|
|
1652
|
-
e.bindTexture(e.TEXTURE_2D,
|
|
1735
|
+
e.bindTexture(e.TEXTURE_2D, d), e.activeTexture(l);
|
|
1653
1736
|
}
|
|
1654
1737
|
get currentDataTexture() {
|
|
1655
1738
|
return this._dataTextures[this._currentIndex];
|
|
@@ -1665,7 +1748,7 @@ class DataTextureManagerGL1 {
|
|
|
1665
1748
|
upload(e, t, a) {
|
|
1666
1749
|
const r = this._gl, o = this.textureWidth, l = Math.min(this.textureHeight, Math.ceil(e * 4 / o));
|
|
1667
1750
|
if (l === 0) return;
|
|
1668
|
-
const
|
|
1751
|
+
const d = l * o * 4;
|
|
1669
1752
|
r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, !1), r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), r.pixelStorei(r.UNPACK_ALIGNMENT, 4), r.activeTexture(r.TEXTURE0 + t), r.bindTexture(r.TEXTURE_2D, this.currentDataTexture), r.texSubImage2D(
|
|
1670
1753
|
r.TEXTURE_2D,
|
|
1671
1754
|
0,
|
|
@@ -1675,7 +1758,7 @@ class DataTextureManagerGL1 {
|
|
|
1675
1758
|
l,
|
|
1676
1759
|
r.RGBA,
|
|
1677
1760
|
r.FLOAT,
|
|
1678
|
-
this._floatView.subarray(0,
|
|
1761
|
+
this._floatView.subarray(0, d)
|
|
1679
1762
|
), r.activeTexture(r.TEXTURE0 + a), r.bindTexture(r.TEXTURE_2D, this.currentMetaTexture), r.texSubImage2D(
|
|
1680
1763
|
r.TEXTURE_2D,
|
|
1681
1764
|
0,
|
|
@@ -1685,7 +1768,7 @@ class DataTextureManagerGL1 {
|
|
|
1685
1768
|
l,
|
|
1686
1769
|
r.RGBA,
|
|
1687
1770
|
r.UNSIGNED_BYTE,
|
|
1688
|
-
this.meta.bytes.subarray(0,
|
|
1771
|
+
this.meta.bytes.subarray(0, d)
|
|
1689
1772
|
);
|
|
1690
1773
|
}
|
|
1691
1774
|
advance() {
|
|
@@ -1737,10 +1820,10 @@ class NeutrinoRenderer {
|
|
|
1737
1820
|
for (let e = 0; e < MAX_BATCHES; e++)
|
|
1738
1821
|
this._batchPool.push(new DrawBatch());
|
|
1739
1822
|
}
|
|
1740
|
-
render(e, t, a, r, o, l,
|
|
1823
|
+
render(e, t, a, r, o, l, d) {
|
|
1741
1824
|
if (l === 0) return;
|
|
1742
|
-
const i = e.gl, u = e.isWebGL1,
|
|
1743
|
-
|
|
1825
|
+
const i = e.gl, u = e.isWebGL1, g = e.maxBatchTextures, I = d.renderStyles, E = d.materials, U = u ? t.meta : null;
|
|
1826
|
+
U && U.build(r, l), this._batchCount = 0;
|
|
1744
1827
|
const x = this._texSlotMap;
|
|
1745
1828
|
for (; this._batchPool.length < o.length; )
|
|
1746
1829
|
this._batchPool.push(new DrawBatch());
|
|
@@ -1750,19 +1833,19 @@ class NeutrinoRenderer {
|
|
|
1750
1833
|
p.reset(), p.blendMode = this._resolveBlend(o[b].blendMode, E), p.startParticle = o[b].startParticleIndex, x.clear();
|
|
1751
1834
|
let v = b;
|
|
1752
1835
|
for (; v < o.length && this._resolveBlend(o[v].blendMode, E) === p.blendMode; ) {
|
|
1753
|
-
const T =
|
|
1836
|
+
const T = I[o[v].renderStyleIndex].textureIndices[0];
|
|
1754
1837
|
if (!x.has(T)) {
|
|
1755
|
-
if (x.size >=
|
|
1838
|
+
if (x.size >= g) break;
|
|
1756
1839
|
const f = x.size;
|
|
1757
|
-
x.set(T, f), p.glTextures[f] =
|
|
1840
|
+
x.set(T, f), p.glTextures[f] = d.glTextures[T] || null, p.remaps[f] = d.remaps[T] || null, p.numTextures = f + 1;
|
|
1758
1841
|
}
|
|
1759
|
-
const
|
|
1760
|
-
if (
|
|
1761
|
-
|
|
1842
|
+
const c = x.get(T), w = o[v];
|
|
1843
|
+
if (U)
|
|
1844
|
+
U.patchSlot(w.startParticleIndex, w.numParticles, c);
|
|
1762
1845
|
else
|
|
1763
1846
|
for (let f = 0; f < w.numParticles; f++) {
|
|
1764
1847
|
const h = (w.startParticleIndex + f) * BYTES_PER_PARTICLE, y = a.getUint32(h, !0);
|
|
1765
|
-
a.setUint32(h, y & 4294967040 |
|
|
1848
|
+
a.setUint32(h, y & 4294967040 | c, !0);
|
|
1766
1849
|
}
|
|
1767
1850
|
p.numParticles += w.numParticles, v++;
|
|
1768
1851
|
}
|
|
@@ -1771,23 +1854,23 @@ class NeutrinoRenderer {
|
|
|
1771
1854
|
const B = i.isEnabled(i.SCISSOR_TEST);
|
|
1772
1855
|
try {
|
|
1773
1856
|
if (i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST), i.disable(i.SCISSOR_TEST), i.disable(i.CULL_FACE), i.depthMask(!1), i.colorMask(!0, !0, !0, !0), i.useProgram(e.shaderProgram), u) {
|
|
1774
|
-
const
|
|
1775
|
-
|
|
1857
|
+
const _ = t;
|
|
1858
|
+
_.upload(l, DATA_TEXTURE_UNIT, META_TEXTURE_UNIT), i.uniform1i(e.uDataTexture, DATA_TEXTURE_UNIT), i.uniform1i(e.uMetaTexture, META_TEXTURE_UNIT), i.uniform2f(e.uDataTexSize, _.textureWidth, _.textureHeight);
|
|
1776
1859
|
} else {
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1860
|
+
const _ = t;
|
|
1861
|
+
_.uploadAndBind(DATA_TEXTURE_UNIT), i.uniform1i(e.uDataTexture, DATA_TEXTURE_UNIT), i.uniform1i(e.uDataTextureWidth, _.textureWidth);
|
|
1779
1862
|
}
|
|
1780
1863
|
i.uniform3f(e.uCameraRight, 1, 0, 0), i.uniform3f(e.uCameraUp, 0, -1, 0), i.uniform3f(e.uCameraDir, 0, 0, -1);
|
|
1781
|
-
const p =
|
|
1782
|
-
|
|
1864
|
+
const p = d.viewportWidth, v = d.viewportHeight, T = d.zoom || 1, c = this._orthoMatrix;
|
|
1865
|
+
c.fill(0), c[0] = 2 / p * T, c[5] = -2 / v * T, c[10] = 1, c[15] = 1, c[12] = -1 - 2 / p * T * d.scrollX, c[13] = 1 + 2 / v * T * d.scrollY, i.uniformMatrix4fv(e.uViewProjMatrix, !1, c);
|
|
1783
1866
|
const w = v > 0 ? p / v : 1;
|
|
1784
|
-
e.uViewportAspect && i.uniform1f(e.uViewportAspect, w), e.uWorldAlpha && i.uniform1f(e.uWorldAlpha,
|
|
1785
|
-
const f =
|
|
1867
|
+
e.uViewportAspect && i.uniform1f(e.uViewportAspect, w), e.uWorldAlpha && i.uniform1f(e.uWorldAlpha, d.worldAlpha);
|
|
1868
|
+
const f = d.model, h = this._modelMatrix;
|
|
1786
1869
|
h[0] = f.a, h[1] = f.b, h[2] = 0, h[3] = 0, h[4] = f.c, h[5] = f.d, h[6] = 0, h[7] = 0, h[8] = 0, h[9] = 0, h[10] = 1, h[11] = 0, h[12] = f.tx, h[13] = f.ty, h[14] = 0, h[15] = 1, i.uniformMatrix4fv(e.uModelMatrix, !1, h), u ? (e.unbindVao(), i.bindBuffer(i.ARRAY_BUFFER, e.aIdBuffer), i.enableVertexAttribArray(e.aIdLocation), i.vertexAttribPointer(e.aIdLocation, 1, i.FLOAT, !1, 0, 0), i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, e.indexBuffer)) : i.bindVertexArray(e.vao);
|
|
1787
1870
|
const y = u ? PARTICLE_TEXTURE_START_UNIT_GL1 : PARTICLE_TEXTURE_START_UNIT;
|
|
1788
1871
|
i.enable(i.BLEND);
|
|
1789
|
-
for (let
|
|
1790
|
-
const P = this._batchPool[
|
|
1872
|
+
for (let _ = 0; _ < this._batchCount; _++) {
|
|
1873
|
+
const P = this._batchPool[_];
|
|
1791
1874
|
this._applyBlendMode(i, P.blendMode);
|
|
1792
1875
|
for (let m = 0; m < P.numTextures; m++) {
|
|
1793
1876
|
const C = y + m;
|
|
@@ -1795,10 +1878,10 @@ class NeutrinoRenderer {
|
|
|
1795
1878
|
const R = P.remaps[m];
|
|
1796
1879
|
R ? i.uniform4f(e.uTexRemaps[m], R.x, R.y, R.width, R.height) : i.uniform4f(e.uTexRemaps[m], 0, 0, 1, 1);
|
|
1797
1880
|
}
|
|
1798
|
-
const D = P.startParticle * 6,
|
|
1881
|
+
const D = P.startParticle * 6, S = P.numParticles * 6;
|
|
1799
1882
|
i.drawElements(
|
|
1800
1883
|
i.TRIANGLES,
|
|
1801
|
-
|
|
1884
|
+
S,
|
|
1802
1885
|
e.indexType,
|
|
1803
1886
|
D * (e.indexType === i.UNSIGNED_INT ? 4 : 2)
|
|
1804
1887
|
);
|
|
@@ -1899,31 +1982,31 @@ class Effect extends Phaser.GameObjects.GameObject {
|
|
|
1899
1982
|
this._checkUnpauseOnUpdateRender();
|
|
1900
1983
|
const o = this.gamePlugin.ctx, l = this._dataTextureManager;
|
|
1901
1984
|
this.effect.construct([0, 0, -1]);
|
|
1902
|
-
const
|
|
1985
|
+
const d = this.effect.renderInstructions, i = d._totalParticles;
|
|
1903
1986
|
if (i === 0) return;
|
|
1904
1987
|
t.flush();
|
|
1905
|
-
const u = this.effectModel.effectModel.textures.length,
|
|
1906
|
-
|
|
1988
|
+
const u = this.effectModel.effectModel.textures.length, g = this._glTexturesScratch;
|
|
1989
|
+
g.length = u;
|
|
1907
1990
|
for (let E = 0; E < u; ++E)
|
|
1908
|
-
|
|
1909
|
-
const
|
|
1991
|
+
g[E] = this.effectModel.glTexture(E);
|
|
1992
|
+
const I = this._worldScale;
|
|
1910
1993
|
try {
|
|
1911
1994
|
sharedRenderer.render(
|
|
1912
1995
|
o,
|
|
1913
1996
|
l,
|
|
1914
1997
|
this.effect.particleDataView,
|
|
1915
1998
|
this.effect.particleDataUint32,
|
|
1916
|
-
|
|
1999
|
+
d,
|
|
1917
2000
|
i,
|
|
1918
2001
|
{
|
|
1919
|
-
model: { a:
|
|
2002
|
+
model: { a: I, b: 0, c: 0, d: I, tx: 0, ty: 0 },
|
|
1920
2003
|
viewportWidth: t.width,
|
|
1921
2004
|
viewportHeight: t.height,
|
|
1922
2005
|
scrollX: r.scrollX * this.scrollFactorX,
|
|
1923
2006
|
scrollY: r.scrollY * this.scrollFactorY,
|
|
1924
2007
|
zoom: r.zoom,
|
|
1925
2008
|
worldAlpha: this.alpha,
|
|
1926
|
-
glTextures:
|
|
2009
|
+
glTextures: g,
|
|
1927
2010
|
remaps: this.effectModel.texturesRemap,
|
|
1928
2011
|
renderStyles: this.effect.model.renderStyles,
|
|
1929
2012
|
materials: this.effect.model.materials
|
|
@@ -1981,8 +2064,8 @@ class Effect extends Phaser.GameObjects.GameObject {
|
|
|
1981
2064
|
_updateWorldTransform() {
|
|
1982
2065
|
const t = (o, l) => {
|
|
1983
2066
|
if (!o) return;
|
|
1984
|
-
const
|
|
1985
|
-
|
|
2067
|
+
const d = this._tempMatrix2;
|
|
2068
|
+
d.applyITRS(o.x, o.y, o.rotation, o.scaleX, o.scaleY), d.multiply(l.matrix, l.matrix), l.angle += o.angle, l.scale *= (o.scaleX + o.scaleY) * 0.5, t(o.parentContainer, l);
|
|
1986
2069
|
}, a = {
|
|
1987
2070
|
matrix: this._tempMatrix1.loadIdentity(),
|
|
1988
2071
|
angle: this.angle,
|