rapid-render 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/dist/buffer.d.ts +1 -0
- package/dist/color.d.ts +2 -0
- package/dist/draw.d.ts +12 -11
- package/dist/particle.d.ts +38 -39
- package/dist/rapid-render.js +768 -702
- package/dist/rapid-render.umd.cjs +9 -9
- package/dist/region/particleRegion.d.ts +3 -1
- package/dist/render.d.ts +2 -2
- package/dist/texture.d.ts +1 -1
- package/package.json +1 -1
package/dist/rapid-render.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
class
|
|
1
|
+
var U = /* @__PURE__ */ ((n) => (n[n.Float32 = 0] = "Float32", n[n.Uint32 = 1] = "Uint32", n[n.Uint16 = 2] = "Uint16", n))(U || {});
|
|
2
|
+
class P {
|
|
3
3
|
/** The number of elements currently used in the buffer. */
|
|
4
4
|
usedElemNum;
|
|
5
5
|
/** The main typed array view corresponding to the specified ArrayType. */
|
|
@@ -63,6 +63,27 @@ class B {
|
|
|
63
63
|
clear() {
|
|
64
64
|
this.usedElemNum = 0;
|
|
65
65
|
}
|
|
66
|
+
static removeAtIndices(t, e) {
|
|
67
|
+
const r = Math.max(...e.map((o) => o.usedElemNum)), i = [...new Set(t)].filter(
|
|
68
|
+
(o) => o >= 0 && o < r
|
|
69
|
+
).sort((o, h) => o - h);
|
|
70
|
+
if (i.length === 0)
|
|
71
|
+
return 0;
|
|
72
|
+
let s = 0, a = 0;
|
|
73
|
+
for (let o = 0; o < r; o++) {
|
|
74
|
+
if (a < i.length && o === i[a]) {
|
|
75
|
+
a++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (s !== o)
|
|
79
|
+
for (const h of e)
|
|
80
|
+
h.typedArray[s] = h.typedArray[o];
|
|
81
|
+
s++;
|
|
82
|
+
}
|
|
83
|
+
for (const o of e)
|
|
84
|
+
o.usedElemNum = s;
|
|
85
|
+
return r - s;
|
|
86
|
+
}
|
|
66
87
|
/**
|
|
67
88
|
* Checks if the buffer has enough space for additional elements and resizes the buffer if necessary.
|
|
68
89
|
* @param size - The number of new elements that need to be accommodated.
|
|
@@ -151,7 +172,7 @@ class B {
|
|
|
151
172
|
this.usedElemNum = 0;
|
|
152
173
|
}
|
|
153
174
|
}
|
|
154
|
-
class
|
|
175
|
+
class et extends P {
|
|
155
176
|
/** The actual WebGLBuffer object maintained by this instance. */
|
|
156
177
|
buffer;
|
|
157
178
|
/** The related WebGL rendering context. */
|
|
@@ -202,7 +223,7 @@ class Q extends B {
|
|
|
202
223
|
}
|
|
203
224
|
}
|
|
204
225
|
}
|
|
205
|
-
class
|
|
226
|
+
class x {
|
|
206
227
|
_r;
|
|
207
228
|
_g;
|
|
208
229
|
_b;
|
|
@@ -283,7 +304,7 @@ class p {
|
|
|
283
304
|
*/
|
|
284
305
|
updateUint() {
|
|
285
306
|
this.uint32 = (this._a << 24 | this._b << 16 | this._g << 8 | this._r) >>> 0;
|
|
286
|
-
const t =
|
|
307
|
+
const t = x.clampByte(this._a), e = x.clampByte(this._r * t / 255), r = x.clampByte(this._g * t / 255), i = x.clampByte(this._b * t / 255);
|
|
287
308
|
this.premultipliedUint32 = (t << 24 | i << 16 | r << 8 | e) >>> 0;
|
|
288
309
|
}
|
|
289
310
|
reset() {
|
|
@@ -301,9 +322,9 @@ class p {
|
|
|
301
322
|
}
|
|
302
323
|
setHSL(t, e, r) {
|
|
303
324
|
t = (t % 360 + 360) % 360, e = Math.max(0, Math.min(100, e)) / 100, r = Math.max(0, Math.min(100, r)) / 100;
|
|
304
|
-
const i = (1 - Math.abs(2 * r - 1)) * e,
|
|
305
|
-
let
|
|
306
|
-
return t < 60 ? [
|
|
325
|
+
const i = (1 - Math.abs(2 * r - 1)) * e, s = i * (1 - Math.abs(t / 60 % 2 - 1)), a = r - i / 2;
|
|
326
|
+
let o = 0, h = 0, c = 0;
|
|
327
|
+
return t < 60 ? [o, h, c] = [i, s, 0] : t < 120 ? [o, h, c] = [s, i, 0] : t < 180 ? [o, h, c] = [0, i, s] : t < 240 ? [o, h, c] = [0, s, i] : t < 300 ? [o, h, c] = [s, 0, i] : [o, h, c] = [i, 0, s], this.setRGBA((o + a) * 255, (h + a) * 255, (c + a) * 255, 255), this;
|
|
307
328
|
}
|
|
308
329
|
toHex() {
|
|
309
330
|
const t = (e) => Math.max(0, Math.min(255, Math.round(e))).toString(16).padStart(2, "0");
|
|
@@ -321,7 +342,7 @@ class p {
|
|
|
321
342
|
* @returns A new `Color` instance with the same RGBA values.
|
|
322
343
|
*/
|
|
323
344
|
clone() {
|
|
324
|
-
return new
|
|
345
|
+
return new x(this._r, this._g, this._b, this._a);
|
|
325
346
|
}
|
|
326
347
|
/**
|
|
327
348
|
* Converts the color to a hexadecimal string representation (e.g., '#RRGGBBAA').
|
|
@@ -329,8 +350,8 @@ class p {
|
|
|
329
350
|
* @returns The hexadecimal string representation of the color.
|
|
330
351
|
*/
|
|
331
352
|
toHexString(t = !0) {
|
|
332
|
-
const e = this.r.toString(16).padStart(2, "0"), r = this.g.toString(16).padStart(2, "0"), i = this.b.toString(16).padStart(2, "0"),
|
|
333
|
-
return `#${e}${r}${i}${t ?
|
|
353
|
+
const e = this.r.toString(16).padStart(2, "0"), r = this.g.toString(16).padStart(2, "0"), i = this.b.toString(16).padStart(2, "0"), s = this.a.toString(16).padStart(2, "0");
|
|
354
|
+
return `#${e}${r}${i}${t ? s : ""}`;
|
|
334
355
|
}
|
|
335
356
|
/**
|
|
336
357
|
* Checks if the current color is equal to another color.
|
|
@@ -355,19 +376,26 @@ class p {
|
|
|
355
376
|
* Color.fromNorm(0.9, 0.87, 0.55, 0.1) // moon glow
|
|
356
377
|
*/
|
|
357
378
|
static FromHSL(t, e, r) {
|
|
358
|
-
return new
|
|
379
|
+
return new x(0, 0, 0).setHSL(t, e, r);
|
|
359
380
|
}
|
|
360
381
|
static FromRGB(t, e, r) {
|
|
361
|
-
return new
|
|
382
|
+
return new x(t, e, r);
|
|
362
383
|
}
|
|
363
384
|
static fromNorm(t, e, r, i = 1) {
|
|
364
|
-
return new
|
|
385
|
+
return new x(
|
|
365
386
|
Math.round(t * 255),
|
|
366
387
|
Math.round(e * 255),
|
|
367
388
|
Math.round(r * 255),
|
|
368
389
|
Math.round(i * 255)
|
|
369
390
|
);
|
|
370
391
|
}
|
|
392
|
+
static clampColorByte(t) {
|
|
393
|
+
return t <= 0 ? 0 : t >= 255 ? 255 : Math.round(t);
|
|
394
|
+
}
|
|
395
|
+
static packColor(t, e, r, i, s) {
|
|
396
|
+
const a = x.clampColorByte(i), o = s ? a / 255 : 1, h = x.clampColorByte(t * o), c = x.clampColorByte(e * o), u = x.clampColorByte(r * o);
|
|
397
|
+
return (a << 24 | u << 16 | c << 8 | h) >>> 0;
|
|
398
|
+
}
|
|
371
399
|
/**
|
|
372
400
|
* Creates a Color instance from a hexadecimal color string.
|
|
373
401
|
* @param hexString - The hexadecimal color string, e.g., '#RRGGBB' or '#RRGGBBAA'.
|
|
@@ -376,8 +404,8 @@ class p {
|
|
|
376
404
|
static fromHex(t) {
|
|
377
405
|
t.startsWith("#") && (t = t.slice(1));
|
|
378
406
|
const e = parseInt(t.slice(0, 2), 16), r = parseInt(t.slice(2, 4), 16), i = parseInt(t.slice(4, 6), 16);
|
|
379
|
-
let
|
|
380
|
-
return t.length >= 8 && (
|
|
407
|
+
let s = 255;
|
|
408
|
+
return t.length >= 8 && (s = parseInt(t.slice(6, 8), 16)), new x(e, r, i, s);
|
|
381
409
|
}
|
|
382
410
|
/**
|
|
383
411
|
* Adds the components of another color to this color, clamping the result to 255.
|
|
@@ -385,7 +413,7 @@ class p {
|
|
|
385
413
|
* @returns A new Color instance with the result of the addition.
|
|
386
414
|
*/
|
|
387
415
|
add(t) {
|
|
388
|
-
return new
|
|
416
|
+
return new x(
|
|
389
417
|
Math.min(this.r + t.r, 255),
|
|
390
418
|
Math.min(this.g + t.g, 255),
|
|
391
419
|
Math.min(this.b + t.b, 255),
|
|
@@ -398,7 +426,7 @@ class p {
|
|
|
398
426
|
* @returns A new Color instance with the result of the subtraction.
|
|
399
427
|
*/
|
|
400
428
|
subtract(t) {
|
|
401
|
-
return new
|
|
429
|
+
return new x(
|
|
402
430
|
this.r - t.r,
|
|
403
431
|
this.g - t.g,
|
|
404
432
|
this.b - t.b,
|
|
@@ -406,12 +434,12 @@ class p {
|
|
|
406
434
|
);
|
|
407
435
|
}
|
|
408
436
|
divide(t) {
|
|
409
|
-
return t instanceof
|
|
437
|
+
return t instanceof x ? new x(
|
|
410
438
|
this.r / t.r,
|
|
411
439
|
this.g / t.g,
|
|
412
440
|
this.b / t.b,
|
|
413
441
|
this.a / t.a
|
|
414
|
-
) : new
|
|
442
|
+
) : new x(
|
|
415
443
|
this.r / t,
|
|
416
444
|
this.g / t,
|
|
417
445
|
this.b / t,
|
|
@@ -419,12 +447,12 @@ class p {
|
|
|
419
447
|
);
|
|
420
448
|
}
|
|
421
449
|
multiply(t) {
|
|
422
|
-
return t instanceof
|
|
450
|
+
return t instanceof x ? new x(
|
|
423
451
|
this.r * t.r,
|
|
424
452
|
this.g * t.g,
|
|
425
453
|
this.b * t.b,
|
|
426
454
|
this.a * t.a
|
|
427
|
-
) : new
|
|
455
|
+
) : new x(
|
|
428
456
|
this.r * t,
|
|
429
457
|
this.g * t,
|
|
430
458
|
this.b * t,
|
|
@@ -434,24 +462,24 @@ class p {
|
|
|
434
462
|
clamp() {
|
|
435
463
|
this.r = Math.max(0, Math.min(255, this.r)), this.g = Math.max(0, Math.min(255, this.g)), this.b = Math.max(0, Math.min(255, this.b)), this.a = Math.max(0, Math.min(255, this.a));
|
|
436
464
|
}
|
|
437
|
-
static Red = new
|
|
438
|
-
static Green = new
|
|
439
|
-
static Blue = new
|
|
440
|
-
static Yellow = new
|
|
441
|
-
static Purple = new
|
|
442
|
-
static Orange = new
|
|
443
|
-
static Pink = new
|
|
444
|
-
static Gray = new
|
|
445
|
-
static Brown = new
|
|
446
|
-
static Cyan = new
|
|
447
|
-
static Magenta = new
|
|
448
|
-
static Lime = new
|
|
449
|
-
static White = new
|
|
450
|
-
static Black = new
|
|
451
|
-
static Transparent = new
|
|
452
|
-
static TRANSPARENT = new
|
|
465
|
+
static Red = new x(255, 0, 0, 255);
|
|
466
|
+
static Green = new x(0, 255, 0, 255);
|
|
467
|
+
static Blue = new x(0, 0, 255, 255);
|
|
468
|
+
static Yellow = new x(255, 255, 0, 255);
|
|
469
|
+
static Purple = new x(128, 0, 128, 255);
|
|
470
|
+
static Orange = new x(255, 165, 0, 255);
|
|
471
|
+
static Pink = new x(255, 192, 203, 255);
|
|
472
|
+
static Gray = new x(128, 128, 128, 255);
|
|
473
|
+
static Brown = new x(139, 69, 19, 255);
|
|
474
|
+
static Cyan = new x(0, 255, 255, 255);
|
|
475
|
+
static Magenta = new x(255, 0, 255, 255);
|
|
476
|
+
static Lime = new x(192, 255, 0, 255);
|
|
477
|
+
static White = new x(255, 255, 255, 255);
|
|
478
|
+
static Black = new x(0, 0, 0, 255);
|
|
479
|
+
static Transparent = new x(0, 0, 0, 0);
|
|
480
|
+
static TRANSPARENT = new x(0, 0, 0, 0);
|
|
453
481
|
}
|
|
454
|
-
const
|
|
482
|
+
const E = 6;
|
|
455
483
|
class Mt {
|
|
456
484
|
/** Total number of matrices currently allocated in the store. */
|
|
457
485
|
matrixCount = 0;
|
|
@@ -465,7 +493,7 @@ class Mt {
|
|
|
465
493
|
* @param capacity - The initial capacity of the matrix store (default is 10).
|
|
466
494
|
*/
|
|
467
495
|
constructor(t = 10) {
|
|
468
|
-
this.buffer = new
|
|
496
|
+
this.buffer = new P(U.Float32), this.buffer.resize(t * E), this.data = this.buffer.getArray(), this.reset();
|
|
469
497
|
}
|
|
470
498
|
/**
|
|
471
499
|
* Allocates a new matrix and initializes it to the identity matrix.
|
|
@@ -480,7 +508,7 @@ class Mt {
|
|
|
480
508
|
* @returns The index of the newly allocated matrix.
|
|
481
509
|
*/
|
|
482
510
|
allocDirty() {
|
|
483
|
-
return this.buffer.resize(
|
|
511
|
+
return this.buffer.resize(E) && (this.data = this.buffer.getArray()), this.buffer.usedElemNum += E, this.matrixCount++;
|
|
484
512
|
}
|
|
485
513
|
/**
|
|
486
514
|
* Resets the store, clearing all allocated matrices.
|
|
@@ -493,7 +521,7 @@ class Mt {
|
|
|
493
521
|
* @param index - The index of the matrix to modify.
|
|
494
522
|
*/
|
|
495
523
|
identity(t) {
|
|
496
|
-
const e = t *
|
|
524
|
+
const e = t * E, r = this.data;
|
|
497
525
|
r[e] = 1, r[e + 1] = 0, r[e + 2] = 0, r[e + 3] = 1, r[e + 4] = 0, r[e + 5] = 0;
|
|
498
526
|
}
|
|
499
527
|
/**
|
|
@@ -503,8 +531,8 @@ class Mt {
|
|
|
503
531
|
* @param y - The y translation.
|
|
504
532
|
*/
|
|
505
533
|
translate(t, e, r) {
|
|
506
|
-
const i = t *
|
|
507
|
-
|
|
534
|
+
const i = t * E, s = this.data;
|
|
535
|
+
s[i + 4] = s[i] * e + s[i + 2] * r + s[i + 4], s[i + 5] = s[i + 1] * e + s[i + 3] * r + s[i + 5];
|
|
508
536
|
}
|
|
509
537
|
/**
|
|
510
538
|
* Scales the matrix at the given index by scaleX and scaleY.
|
|
@@ -513,8 +541,8 @@ class Mt {
|
|
|
513
541
|
* @param scaleY - The scale factor along the y-axis.
|
|
514
542
|
*/
|
|
515
543
|
scale(t, e, r) {
|
|
516
|
-
const i = t *
|
|
517
|
-
|
|
544
|
+
const i = t * E, s = this.data;
|
|
545
|
+
s[i] *= e, s[i + 1] *= e, s[i + 2] *= r, s[i + 3] *= r;
|
|
518
546
|
}
|
|
519
547
|
/**
|
|
520
548
|
* Rotates the matrix at the given index by the specified radians.
|
|
@@ -522,8 +550,8 @@ class Mt {
|
|
|
522
550
|
* @param radians - The rotation angle in radians.
|
|
523
551
|
*/
|
|
524
552
|
rotate(t, e) {
|
|
525
|
-
const r = t *
|
|
526
|
-
i[r] =
|
|
553
|
+
const r = t * E, i = this.data, s = Math.cos(e), a = Math.sin(e), o = i[r], h = i[r + 1], c = i[r + 2], u = i[r + 3];
|
|
554
|
+
i[r] = o * s + c * a, i[r + 1] = h * s + u * a, i[r + 2] = o * -a + c * s, i[r + 3] = h * -a + u * s;
|
|
527
555
|
}
|
|
528
556
|
/**
|
|
529
557
|
* Rotates the matrix at the given index around a local offset point (pivot).
|
|
@@ -550,8 +578,8 @@ class Mt {
|
|
|
550
578
|
* @param src - The index of the source matrix.
|
|
551
579
|
*/
|
|
552
580
|
copy(t, e) {
|
|
553
|
-
const r = t *
|
|
554
|
-
|
|
581
|
+
const r = t * E, i = e * E, s = this.data;
|
|
582
|
+
s[r] = s[i], s[r + 1] = s[i + 1], s[r + 2] = s[i + 2], s[r + 3] = s[i + 3], s[r + 4] = s[i + 4], s[r + 5] = s[i + 5];
|
|
555
583
|
}
|
|
556
584
|
/**
|
|
557
585
|
* Multiplies the destination matrix by the source matrix and stores the result in the destination.
|
|
@@ -568,21 +596,21 @@ class Mt {
|
|
|
568
596
|
* @param bIdx - The index of matrix B.
|
|
569
597
|
*/
|
|
570
598
|
multiplyOut(t, e, r) {
|
|
571
|
-
const i = t *
|
|
572
|
-
|
|
599
|
+
const i = t * E, s = e * E, a = r * E, o = this.data, h = o[s], c = o[s + 1], u = o[s + 2], l = o[s + 3], d = o[s + 4], f = o[s + 5], m = o[a], g = o[a + 1], v = o[a + 2], y = o[a + 3], R = o[a + 4], A = o[a + 5];
|
|
600
|
+
o[i] = h * m + u * g, o[i + 1] = c * m + l * g, o[i + 2] = h * v + u * y, o[i + 3] = c * v + l * y, o[i + 4] = h * R + u * A + d, o[i + 5] = c * R + l * A + f;
|
|
573
601
|
}
|
|
574
602
|
/**
|
|
575
603
|
* Inverts the matrix at the given index. If the matrix is not invertible, it defaults to the identity matrix.
|
|
576
604
|
* @param index - The index of the matrix to invert.
|
|
577
605
|
*/
|
|
578
606
|
invert(t) {
|
|
579
|
-
const e = t *
|
|
580
|
-
let u = i *
|
|
607
|
+
const e = t * E, r = this.data, i = r[e], s = r[e + 1], a = r[e + 2], o = r[e + 3], h = r[e + 4], c = r[e + 5];
|
|
608
|
+
let u = i * o - s * a;
|
|
581
609
|
if (!u) {
|
|
582
610
|
this.identity(t);
|
|
583
611
|
return;
|
|
584
612
|
}
|
|
585
|
-
u = 1 / u, r[e] =
|
|
613
|
+
u = 1 / u, r[e] = o * u, r[e + 1] = -s * u, r[e + 2] = -a * u, r[e + 3] = i * u, r[e + 4] = (a * c - o * h) * u, r[e + 5] = (s * h - i * c) * u;
|
|
586
614
|
}
|
|
587
615
|
/**
|
|
588
616
|
* Transforms a point by the matrix at the given index.
|
|
@@ -592,10 +620,10 @@ class Mt {
|
|
|
592
620
|
* @returns The transformed point {x, y}.
|
|
593
621
|
*/
|
|
594
622
|
transformPoint(t, e, r) {
|
|
595
|
-
const i = t *
|
|
623
|
+
const i = t * E, s = this.data;
|
|
596
624
|
return {
|
|
597
|
-
x: e *
|
|
598
|
-
y: e *
|
|
625
|
+
x: e * s[i] + r * s[i + 2] + s[i + 4],
|
|
626
|
+
y: e * s[i + 1] + r * s[i + 3] + s[i + 5]
|
|
599
627
|
};
|
|
600
628
|
}
|
|
601
629
|
/**
|
|
@@ -609,8 +637,8 @@ class Mt {
|
|
|
609
637
|
worldToLocal(t, e, r) {
|
|
610
638
|
const i = this.allocDirty();
|
|
611
639
|
this.copy(i, t), this.invert(i);
|
|
612
|
-
const
|
|
613
|
-
return this.matrixCount--, this.buffer.usedElemNum -=
|
|
640
|
+
const s = this.transformPoint(i, e, r);
|
|
641
|
+
return this.matrixCount--, this.buffer.usedElemNum -= E, s;
|
|
614
642
|
}
|
|
615
643
|
/**
|
|
616
644
|
* Transforms a point from local coordinates to world coordinates.
|
|
@@ -628,7 +656,7 @@ class Mt {
|
|
|
628
656
|
* @returns An object containing `x` and `y` global coordinates.
|
|
629
657
|
*/
|
|
630
658
|
getPosition(t) {
|
|
631
|
-
const e = t *
|
|
659
|
+
const e = t * E, r = this.data;
|
|
632
660
|
return { x: r[e + 4], y: r[e + 5] };
|
|
633
661
|
}
|
|
634
662
|
/**
|
|
@@ -637,8 +665,8 @@ class Mt {
|
|
|
637
665
|
* @returns An object containing `x` and `y` global scale factors.
|
|
638
666
|
*/
|
|
639
667
|
getScale(t) {
|
|
640
|
-
const e = t *
|
|
641
|
-
return { x: i, y:
|
|
668
|
+
const e = t * E, r = this.data, i = Math.sqrt(r[e] * r[e] + r[e + 1] * r[e + 1]), s = Math.sqrt(r[e + 2] * r[e + 2] + r[e + 3] * r[e + 3]);
|
|
669
|
+
return { x: i, y: s };
|
|
642
670
|
}
|
|
643
671
|
/**
|
|
644
672
|
* Extracts the global rotation (in radians) from the matrix at the given index.
|
|
@@ -646,7 +674,7 @@ class Mt {
|
|
|
646
674
|
* @returns The global rotation in radians.
|
|
647
675
|
*/
|
|
648
676
|
getRotation(t) {
|
|
649
|
-
const e = t *
|
|
677
|
+
const e = t * E, r = this.data;
|
|
650
678
|
return Math.atan2(r[e + 1], r[e]);
|
|
651
679
|
}
|
|
652
680
|
/**
|
|
@@ -657,8 +685,8 @@ class Mt {
|
|
|
657
685
|
* @returns A CSS matrix string.
|
|
658
686
|
*/
|
|
659
687
|
toCSSMatrix(t, e = 1, r = 1) {
|
|
660
|
-
const i = t *
|
|
661
|
-
return `matrix(${
|
|
688
|
+
const i = t * E, s = this.data;
|
|
689
|
+
return `matrix(${s[i] * e}, ${s[i + 1] * r}, ${s[i + 2] * e}, ${s[i + 3] * r}, ${s[i + 4] * e}, ${s[i + 5] * r})`;
|
|
662
690
|
}
|
|
663
691
|
/**
|
|
664
692
|
* Retrieves a copy of the 6 elements [a, b, c, d, tx, ty] for the matrix at the specified index.
|
|
@@ -668,8 +696,8 @@ class Mt {
|
|
|
668
696
|
* @returns A new Float32Array containing the 6 elements of the matrix.
|
|
669
697
|
*/
|
|
670
698
|
getMatrix(t) {
|
|
671
|
-
const e = t *
|
|
672
|
-
return this.data.slice(e, e +
|
|
699
|
+
const e = t * E;
|
|
700
|
+
return this.data.slice(e, e + E);
|
|
673
701
|
}
|
|
674
702
|
/**
|
|
675
703
|
* Retrieves a direct reference (view) to the 6 elements [a, b, c, d, tx, ty] for the matrix at the specified index.
|
|
@@ -679,8 +707,8 @@ class Mt {
|
|
|
679
707
|
* @returns A Float32Array view pointing directly to the matrix's data in memory.
|
|
680
708
|
*/
|
|
681
709
|
getMatrixRef(t) {
|
|
682
|
-
const e = t *
|
|
683
|
-
return this.data.subarray(e, e +
|
|
710
|
+
const e = t * E;
|
|
711
|
+
return this.data.subarray(e, e + E);
|
|
684
712
|
}
|
|
685
713
|
/**
|
|
686
714
|
* Overwrites the matrix at the specified index with the provided 6 elements [a, b, c, d, tx, ty].
|
|
@@ -689,33 +717,33 @@ class Mt {
|
|
|
689
717
|
* @param f - An array (Float32Array or standard number array) containing the 6 new elements.
|
|
690
718
|
*/
|
|
691
719
|
setMatrix(t, e) {
|
|
692
|
-
const r = t *
|
|
720
|
+
const r = t * E, i = this.data;
|
|
693
721
|
i[r] = e[0], i[r + 1] = e[1], i[r + 2] = e[2], i[r + 3] = e[3], i[r + 4] = e[4], i[r + 5] = e[5];
|
|
694
722
|
}
|
|
695
|
-
multiplyAffineInPlace(t, e, r, i,
|
|
696
|
-
const h = t * 6,
|
|
697
|
-
|
|
723
|
+
multiplyAffineInPlace(t, e, r, i, s, a, o) {
|
|
724
|
+
const h = t * 6, c = this.data, u = c[h], l = c[h + 1], d = c[h + 2], f = c[h + 3], m = c[h + 4], g = c[h + 5];
|
|
725
|
+
c[h] = u * e + d * r, c[h + 1] = l * e + f * r, c[h + 2] = u * i + d * s, c[h + 3] = l * i + f * s, c[h + 4] = u * a + d * o + m, c[h + 5] = l * a + f * o + g;
|
|
698
726
|
}
|
|
699
|
-
multiplyAffine(t, e, r, i,
|
|
700
|
-
const
|
|
701
|
-
l[u] = d * r +
|
|
727
|
+
multiplyAffine(t, e, r, i, s, a, o, h) {
|
|
728
|
+
const c = t * 6, u = e * 6, l = this.data, d = l[c], f = l[c + 1], m = l[c + 2], g = l[c + 3], v = l[c + 4], y = l[c + 5];
|
|
729
|
+
l[u] = d * r + m * i, l[u + 1] = f * r + g * i, l[u + 2] = d * s + m * a, l[u + 3] = f * s + g * a, l[u + 4] = d * o + m * h + v, l[u + 5] = f * o + g * h + y;
|
|
702
730
|
}
|
|
703
731
|
}
|
|
704
|
-
class
|
|
732
|
+
class At {
|
|
705
733
|
/** The underlying store for matrices. */
|
|
706
734
|
matrix = new Mt();
|
|
707
735
|
/** The current step or depth in the transformation hierarchy. */
|
|
708
736
|
step = 0;
|
|
709
737
|
/** Internal stack maintaining structural information. */
|
|
710
|
-
stack = new
|
|
738
|
+
stack = new P(U.Uint32);
|
|
711
739
|
/** Records the world matrices generated at each step. */
|
|
712
|
-
stepWorldM = new
|
|
740
|
+
stepWorldM = new P(U.Uint32);
|
|
713
741
|
/** Records actions (push/pop) taken during the traversal. */
|
|
714
|
-
stepAction = new
|
|
742
|
+
stepAction = new P(U.Uint32);
|
|
715
743
|
/** Records the parent world matrix for each step (used by updateMatrix). */
|
|
716
|
-
stepParentM = new
|
|
744
|
+
stepParentM = new P(U.Uint32);
|
|
717
745
|
/** Buffer used during hierarchy traversal updates. */
|
|
718
|
-
parentStack = new
|
|
746
|
+
parentStack = new P(U.Uint32);
|
|
719
747
|
/** The index of the current local matrix in the matrix store. */
|
|
720
748
|
curLocalM = -1;
|
|
721
749
|
/** The index of the current world matrix in the matrix store. */
|
|
@@ -750,15 +778,15 @@ class St {
|
|
|
750
778
|
*/
|
|
751
779
|
updateMatrix(t) {
|
|
752
780
|
const e = (typeof t == "number" ? t : t.step) - 1, r = this.stepParentM.get(e);
|
|
753
|
-
let i = 0,
|
|
781
|
+
let i = 0, s = e;
|
|
754
782
|
const a = this.parentStack;
|
|
755
|
-
for (a.reset(), a.push(r);
|
|
756
|
-
if (this.stepAction.get(
|
|
757
|
-
const h = this.stepWorldM.get(
|
|
758
|
-
this.matrix.multiplyOut(h, u,
|
|
783
|
+
for (a.reset(), a.push(r); s < this.stepAction.length; ) {
|
|
784
|
+
if (this.stepAction.get(s) === 1) {
|
|
785
|
+
const h = this.stepWorldM.get(s), c = h - 1, u = a.top();
|
|
786
|
+
this.matrix.multiplyOut(h, u, c), a.push(h), i++;
|
|
759
787
|
} else if (a.pop(), i--, i === 0)
|
|
760
788
|
break;
|
|
761
|
-
|
|
789
|
+
s++;
|
|
762
790
|
}
|
|
763
791
|
}
|
|
764
792
|
/**
|
|
@@ -864,14 +892,14 @@ class St {
|
|
|
864
892
|
* Returns the current world matrix as Float32Array [a, b, c, d, tx, ty].
|
|
865
893
|
*/
|
|
866
894
|
getTransform() {
|
|
867
|
-
const t = this.curWorldM *
|
|
868
|
-
return this.matrix.data.slice(t, t +
|
|
895
|
+
const t = this.curWorldM * E;
|
|
896
|
+
return this.matrix.data.slice(t, t + E);
|
|
869
897
|
}
|
|
870
898
|
/**
|
|
871
899
|
* Directly overwrites the current world matrix with the given 6-element 2D transform.
|
|
872
900
|
*/
|
|
873
901
|
setTransform(t) {
|
|
874
|
-
const e = this.curWorldM *
|
|
902
|
+
const e = this.curWorldM * E, r = this.matrix.data;
|
|
875
903
|
r[e] = t[0], r[e + 1] = t[1], r[e + 2] = t[2], r[e + 3] = t[3], r[e + 4] = t[4], r[e + 5] = t[5];
|
|
876
904
|
}
|
|
877
905
|
transformPoint(t, e) {
|
|
@@ -882,51 +910,51 @@ class St {
|
|
|
882
910
|
* Optionally saves the matrix first
|
|
883
911
|
*/
|
|
884
912
|
applyTransform(t, e = 0, r = 0, i = -1) {
|
|
885
|
-
let
|
|
886
|
-
t.position && (
|
|
887
|
-
let
|
|
888
|
-
const
|
|
889
|
-
|
|
913
|
+
let s = t.x ?? 0, a = t.y ?? 0;
|
|
914
|
+
t.position && (s += t.position.x, a += t.position.y);
|
|
915
|
+
let o = 1, h = 1;
|
|
916
|
+
const c = t.scale;
|
|
917
|
+
c && (typeof c == "number" ? (o = c, h = c) : (o = c.x, h = c.y));
|
|
890
918
|
const u = t.rotation ?? 0;
|
|
891
919
|
let l = t.offsetX ?? 0, d = t.offsetY ?? 0;
|
|
892
920
|
t.offset && (l += t.offset.x, d += t.offset.y);
|
|
893
921
|
const f = t.origin;
|
|
894
922
|
f !== void 0 && (typeof f == "number" ? (l -= f * e, d -= f * r) : (l -= f.x * e, d -= f.y * r));
|
|
895
|
-
const
|
|
923
|
+
const m = u ? Math.cos(u) : 1, g = u ? Math.sin(u) : 0, v = m * o, y = g * o, R = -g * h, A = m * h, C = s + v * l + R * d, S = a + y * l + A * d;
|
|
896
924
|
if (i !== -1) {
|
|
897
925
|
this.matrix.multiplyAffine(
|
|
898
926
|
this.curWorldM,
|
|
899
927
|
i,
|
|
900
928
|
v,
|
|
901
|
-
|
|
929
|
+
y,
|
|
902
930
|
R,
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
931
|
+
A,
|
|
932
|
+
C,
|
|
933
|
+
S
|
|
906
934
|
);
|
|
907
935
|
return;
|
|
908
936
|
}
|
|
909
937
|
this.matrix.multiplyAffineInPlace(
|
|
910
938
|
this.curLocalM,
|
|
911
939
|
v,
|
|
912
|
-
|
|
940
|
+
y,
|
|
913
941
|
R,
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
942
|
+
A,
|
|
943
|
+
C,
|
|
944
|
+
S
|
|
917
945
|
), this.matrix.multiplyAffineInPlace(
|
|
918
946
|
this.curWorldM,
|
|
919
947
|
v,
|
|
920
|
-
|
|
948
|
+
y,
|
|
921
949
|
R,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
950
|
+
A,
|
|
951
|
+
C,
|
|
952
|
+
S
|
|
925
953
|
);
|
|
926
954
|
}
|
|
927
955
|
}
|
|
928
|
-
var
|
|
929
|
-
class
|
|
956
|
+
var q = /* @__PURE__ */ ((n) => (n[n.REPEAT = 0] = "REPEAT", n[n.CLAMP = 1] = "CLAMP", n[n.MIRRORED_REPEAT = 2] = "MIRRORED_REPEAT", n))(q || {});
|
|
957
|
+
class St {
|
|
930
958
|
render;
|
|
931
959
|
cache = /* @__PURE__ */ new Map();
|
|
932
960
|
constructor(t) {
|
|
@@ -941,10 +969,10 @@ class bt {
|
|
|
941
969
|
async load(t, e) {
|
|
942
970
|
let r = this.cache.get(t);
|
|
943
971
|
if (r)
|
|
944
|
-
return new
|
|
972
|
+
return new B(r);
|
|
945
973
|
try {
|
|
946
974
|
const i = await this._fetchImage(t);
|
|
947
|
-
return r =
|
|
975
|
+
return r = z.fromSource(this.render, i, e), r.uid = t, this.cache.set(t, r), new B(r);
|
|
948
976
|
} catch (i) {
|
|
949
977
|
throw console.error(`[TextureManager] Failed to load: ${t}`, i), i;
|
|
950
978
|
}
|
|
@@ -957,9 +985,9 @@ class bt {
|
|
|
957
985
|
*/
|
|
958
986
|
create(t, e) {
|
|
959
987
|
if (e?.key && this.cache.has(e.key))
|
|
960
|
-
return new
|
|
961
|
-
const r =
|
|
962
|
-
return e?.key && (r.uid = e.key, this.cache.set(e.key, r)), new
|
|
988
|
+
return new B(this.cache.get(e.key));
|
|
989
|
+
const r = z.fromSource(this.render, t, e);
|
|
990
|
+
return e?.key && (r.uid = e.key, this.cache.set(e.key, r)), new B(r);
|
|
963
991
|
}
|
|
964
992
|
/**
|
|
965
993
|
* Creates a generic Render Texture (FrameBuffer).
|
|
@@ -969,7 +997,7 @@ class bt {
|
|
|
969
997
|
* @returns The newly created RenderTexture.
|
|
970
998
|
*/
|
|
971
999
|
createRenderTexture(t) {
|
|
972
|
-
return new
|
|
1000
|
+
return new bt(this.render, t);
|
|
973
1001
|
}
|
|
974
1002
|
/**
|
|
975
1003
|
* Creates a TextTexture for rendering text.
|
|
@@ -977,7 +1005,7 @@ class bt {
|
|
|
977
1005
|
* @returns The newly created TextTexture.
|
|
978
1006
|
*/
|
|
979
1007
|
createTextTexture(t) {
|
|
980
|
-
return new
|
|
1008
|
+
return new Ct(this.render, t);
|
|
981
1009
|
}
|
|
982
1010
|
/**
|
|
983
1011
|
* Destroys a texture and potentially removes its BaseTexture from the cache.
|
|
@@ -988,7 +1016,7 @@ class bt {
|
|
|
988
1016
|
*/
|
|
989
1017
|
destroy(t, e = !1) {
|
|
990
1018
|
let r, i;
|
|
991
|
-
typeof t == "string" ? (i = t, r = this.cache.get(i)) : t instanceof
|
|
1019
|
+
typeof t == "string" ? (i = t, r = this.cache.get(i)) : t instanceof B ? (r = t.base, i = r?.uid, t.destroy()) : (r = t, i = r.uid), r && (r.refCount <= 0 || e) && (r.destroy(this.render.gl), i && this.cache.delete(i));
|
|
992
1020
|
}
|
|
993
1021
|
/**
|
|
994
1022
|
* Destroys all cached textures and clears the cache, ignoring reference counts.
|
|
@@ -1005,7 +1033,7 @@ class bt {
|
|
|
1005
1033
|
});
|
|
1006
1034
|
}
|
|
1007
1035
|
}
|
|
1008
|
-
class
|
|
1036
|
+
class z {
|
|
1009
1037
|
glTexture = null;
|
|
1010
1038
|
width;
|
|
1011
1039
|
height;
|
|
@@ -1022,8 +1050,8 @@ class k {
|
|
|
1022
1050
|
* @returns The created BaseTexture.
|
|
1023
1051
|
*/
|
|
1024
1052
|
static fromSource(t, e, r = {}) {
|
|
1025
|
-
const i =
|
|
1026
|
-
return new
|
|
1053
|
+
const i = J(t, e, r);
|
|
1054
|
+
return new z(i, e.width, e.height);
|
|
1027
1055
|
}
|
|
1028
1056
|
/**
|
|
1029
1057
|
* Updates the content of the existing texture (e.g. for Video or dynamic Canvas).
|
|
@@ -1032,19 +1060,19 @@ class k {
|
|
|
1032
1060
|
* @param source - The new image source.
|
|
1033
1061
|
*/
|
|
1034
1062
|
updateSource(t, e, r = {}) {
|
|
1035
|
-
this.glTexture && (t.bindTexture(t.TEXTURE_2D, this.glTexture), r.textureFilter !== void 0 &&
|
|
1063
|
+
this.glTexture && (t.bindTexture(t.TEXTURE_2D, this.glTexture), r.textureFilter !== void 0 && it(t, r.textureFilter), r.wrap !== void 0 && rt(t, r.wrap), t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, 1), t.pixelStorei(t.UNPACK_ALIGNMENT, 1), r.premultipliedAlpha !== void 0 && t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r.premultipliedAlpha), this.width === e.width && this.height === e.height ? t.texSubImage2D(t.TEXTURE_2D, 0, 0, 0, t.RGBA, t.UNSIGNED_BYTE, e) : (t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, e), this.width = e.width, this.height = e.height), r.premultipliedAlpha !== void 0 && t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1));
|
|
1036
1064
|
}
|
|
1037
1065
|
/**
|
|
1038
1066
|
* Dynamically updates the texture filtering mode.
|
|
1039
1067
|
*/
|
|
1040
1068
|
setFilterMode(t, e) {
|
|
1041
|
-
this.glTexture && (t.bindTexture(t.TEXTURE_2D, this.glTexture),
|
|
1069
|
+
this.glTexture && (t.bindTexture(t.TEXTURE_2D, this.glTexture), it(t, e), t.bindTexture(t.TEXTURE_2D, null));
|
|
1042
1070
|
}
|
|
1043
1071
|
/**
|
|
1044
1072
|
* Dynamically updates the texture wrap mode.
|
|
1045
1073
|
*/
|
|
1046
1074
|
setWrapMode(t, e) {
|
|
1047
|
-
this.glTexture && (t.bindTexture(t.TEXTURE_2D, this.glTexture),
|
|
1075
|
+
this.glTexture && (t.bindTexture(t.TEXTURE_2D, this.glTexture), rt(t, e), t.bindTexture(t.TEXTURE_2D, null));
|
|
1048
1076
|
}
|
|
1049
1077
|
/**
|
|
1050
1078
|
* Destroys the WebGL texture resource.
|
|
@@ -1054,7 +1082,7 @@ class k {
|
|
|
1054
1082
|
this.glTexture && (t.deleteTexture(this.glTexture), this.glTexture = null);
|
|
1055
1083
|
}
|
|
1056
1084
|
}
|
|
1057
|
-
class
|
|
1085
|
+
class B {
|
|
1058
1086
|
base;
|
|
1059
1087
|
uvX = 0;
|
|
1060
1088
|
uvY = 0;
|
|
@@ -1100,7 +1128,7 @@ class P {
|
|
|
1100
1128
|
* @returns The current Texture instance.
|
|
1101
1129
|
*/
|
|
1102
1130
|
setRegion(t, e, r, i) {
|
|
1103
|
-
return this.base ? (this._px = t, this._py = e, this._pw = r, this._ph = i, this.isAtlas = t !== 0 || e !== 0 || r !== this.base.width || i !== this.base.height, this.uvX = t / this.base.width, this.uvY = e / this.base.height, this.uvW = this.uvX + r / this.base.width, this.uvH = this.uvY + i / this.base.height, this.rawWidth = r, this.rawHeight = i, this) : this;
|
|
1131
|
+
return this.base ? (this._px = t, this._py = e, this._pw = r, this._ph = i, this.isAtlas = t !== 0 || e !== 0 || r !== this.base.width || i !== this.base.height, this.uvX = t / this.base.width, this.uvY = e / this.base.height, this.uvW = this.uvX + r / this.base.width, this.uvH = this.uvY + i / this.base.height, this.rawWidth = r * this.scale, this.rawHeight = i * this.scale, this) : this;
|
|
1104
1132
|
}
|
|
1105
1133
|
/**
|
|
1106
1134
|
* Creates a new Texture representing a sub-region of this Texture.
|
|
@@ -1111,16 +1139,16 @@ class P {
|
|
|
1111
1139
|
* @returns A new Texture pointing to the sub-region.
|
|
1112
1140
|
*/
|
|
1113
1141
|
getSubTexture(t, e, r, i) {
|
|
1114
|
-
if (!this.base) return new
|
|
1115
|
-
const
|
|
1116
|
-
return
|
|
1142
|
+
if (!this.base) return new B();
|
|
1143
|
+
const s = this.clone(), a = this._px, o = this._py;
|
|
1144
|
+
return s.setRegion(a + t, o + e, r, i), s;
|
|
1117
1145
|
}
|
|
1118
1146
|
/**
|
|
1119
1147
|
* Creates a shallow copy of this Texture, sharing the same BaseTexture.
|
|
1120
1148
|
* @returns A new Texture instance.
|
|
1121
1149
|
*/
|
|
1122
1150
|
clone(t) {
|
|
1123
|
-
const e = t ?? new
|
|
1151
|
+
const e = t ?? new B(this.base);
|
|
1124
1152
|
return t && this.base && t.setBase(this.base), e.scale = this.scale, e.uvX = this.uvX, e.uvY = this.uvY, e.uvW = this.uvW, e.uvH = this.uvH, e.rawWidth = this.rawWidth, e.rawHeight = this.rawHeight, e.offsetX = this.offsetX, e.offsetY = this.offsetY, e.flipY = this.flipY, e.isRotated = this.isRotated, e.isAtlas = this.isAtlas, e._px = this._px, e._py = this._py, e._pw = this._pw, e._ph = this._ph, e;
|
|
1125
1153
|
}
|
|
1126
1154
|
/**
|
|
@@ -1133,12 +1161,12 @@ class P {
|
|
|
1133
1161
|
* @param gap - Optional pixel gap between cells.
|
|
1134
1162
|
* @returns An array of split Textures.
|
|
1135
1163
|
*/
|
|
1136
|
-
splitGrid(t, e, r, i,
|
|
1164
|
+
splitGrid(t, e, r, i, s = 0) {
|
|
1137
1165
|
if (!this.base) return [];
|
|
1138
|
-
const a = [],
|
|
1139
|
-
for (let
|
|
1166
|
+
const a = [], o = this.rawWidth, h = this.rawHeight, c = Math.max(0, s), u = t + c, l = e + c, d = r ?? Math.floor((o + c) / u), f = i ?? Math.floor((h + c) / l);
|
|
1167
|
+
for (let m = 0; m < f; m++)
|
|
1140
1168
|
for (let g = 0; g < d; g++)
|
|
1141
|
-
a.push(this.getSubTexture(g * u,
|
|
1169
|
+
a.push(this.getSubTexture(g * u, m * l, t, e));
|
|
1142
1170
|
return a;
|
|
1143
1171
|
}
|
|
1144
1172
|
/**
|
|
@@ -1147,8 +1175,8 @@ class P {
|
|
|
1147
1175
|
* @param options - Optional antialias and wrap mode settings.
|
|
1148
1176
|
*/
|
|
1149
1177
|
static fromImageSource(t, e, r = {}) {
|
|
1150
|
-
const i =
|
|
1151
|
-
return new
|
|
1178
|
+
const i = J(t, e, r);
|
|
1179
|
+
return new B(new z(i, e.width, e.height));
|
|
1152
1180
|
}
|
|
1153
1181
|
/**
|
|
1154
1182
|
* Marks this Texture as destroyed, decrementing the BaseTexture reference count.
|
|
@@ -1157,7 +1185,7 @@ class P {
|
|
|
1157
1185
|
this.base && (this.base.refCount--, this.base = void 0), this.glTexture = null;
|
|
1158
1186
|
}
|
|
1159
1187
|
}
|
|
1160
|
-
class
|
|
1188
|
+
class bt extends B {
|
|
1161
1189
|
framebuffer;
|
|
1162
1190
|
renderbuffer;
|
|
1163
1191
|
gl;
|
|
@@ -1167,9 +1195,9 @@ class At extends P {
|
|
|
1167
1195
|
_allocW = 0;
|
|
1168
1196
|
_allocH = 0;
|
|
1169
1197
|
constructor(t, e) {
|
|
1170
|
-
super(), this.gl = t.gl, this.clearColor = e.clearColor ??
|
|
1171
|
-
const r = Math.max(Math.round(e.width), 1), i = Math.max(Math.round(e.height), 1), a =
|
|
1172
|
-
if (this.setBase(new
|
|
1198
|
+
super(), this.gl = t.gl, this.clearColor = e.clearColor ?? x.Black;
|
|
1199
|
+
const r = Math.max(Math.round(e.width), 1), i = Math.max(Math.round(e.height), 1), a = J(t, { width: r, height: i }, { ...e, onlySize: !0 });
|
|
1200
|
+
if (this.setBase(new z(a, r, i)), this.framebuffer = this.gl.createFramebuffer(), this.renderbuffer = this.gl.createRenderbuffer(), !this.framebuffer || !this.renderbuffer)
|
|
1173
1201
|
throw new Error("Failed to create Framebuffer or Renderbuffer");
|
|
1174
1202
|
this.resize(r, i, !0);
|
|
1175
1203
|
}
|
|
@@ -1189,8 +1217,8 @@ class At extends P {
|
|
|
1189
1217
|
t = Math.max(Math.round(t), 1), e = Math.max(Math.round(e), 1);
|
|
1190
1218
|
const i = this.rawWidth === t && this.rawHeight === e;
|
|
1191
1219
|
if (!r && i) return;
|
|
1192
|
-
const
|
|
1193
|
-
(r || t > this._allocW || e > this._allocH) && this.base && (this._allocW = Math.max(this._allocW, t), this._allocH = Math.max(this._allocH, e), this.base.width = this._allocW, this.base.height = this._allocH,
|
|
1220
|
+
const s = this.gl;
|
|
1221
|
+
(r || t > this._allocW || e > this._allocH) && this.base && (this._allocW = Math.max(this._allocW, t), this._allocH = Math.max(this._allocH, e), this.base.width = this._allocW, this.base.height = this._allocH, s.bindTexture(s.TEXTURE_2D, this.base.glTexture), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, this._allocW, this._allocH, 0, s.RGBA, s.UNSIGNED_BYTE, null), s.bindRenderbuffer(s.RENDERBUFFER, this.renderbuffer), s.renderbufferStorage(s.RENDERBUFFER, s.STENCIL_INDEX8, this._allocW, this._allocH), s.bindFramebuffer(s.FRAMEBUFFER, this.framebuffer), s.framebufferTexture2D(s.FRAMEBUFFER, s.COLOR_ATTACHMENT0, s.TEXTURE_2D, this.base.glTexture, 0), s.framebufferRenderbuffer(s.FRAMEBUFFER, s.STENCIL_ATTACHMENT, s.RENDERBUFFER, this.renderbuffer), s.bindFramebuffer(s.FRAMEBUFFER, null), s.bindRenderbuffer(s.RENDERBUFFER, null), s.bindTexture(s.TEXTURE_2D, null)), this.rawWidth = t, this.rawHeight = e, this.uvX = 0, this.uvW = t / this._allocW, this.uvY = 0, this.uvH = e / this._allocH;
|
|
1194
1222
|
}
|
|
1195
1223
|
/**
|
|
1196
1224
|
* Activates this texture as the current render target.
|
|
@@ -1222,14 +1250,14 @@ class At extends P {
|
|
|
1222
1250
|
*/
|
|
1223
1251
|
GetPixels(t = 0, e = 0, r = this.rawWidth, i = this.rawHeight) {
|
|
1224
1252
|
if (!this.framebuffer) return new Uint8Array(0);
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1227
|
-
if (
|
|
1253
|
+
const s = Math.floor(t), a = Math.floor(e), o = Math.floor(r), h = Math.floor(i);
|
|
1254
|
+
if (o <= 0 || h <= 0) return new Uint8Array(0);
|
|
1255
|
+
if (s < 0 || a < 0 || s >= this.rawWidth || a >= this.rawHeight)
|
|
1228
1256
|
return new Uint8Array(0);
|
|
1229
|
-
const
|
|
1257
|
+
const c = Math.min(o, this.rawWidth - s), u = Math.min(h, this.rawHeight - a), l = this.rawHeight - a - u, d = this.gl, f = d.getParameter(d.FRAMEBUFFER_BINDING);
|
|
1230
1258
|
d.bindFramebuffer(d.FRAMEBUFFER, this.framebuffer);
|
|
1231
|
-
const
|
|
1232
|
-
return d.readPixels(
|
|
1259
|
+
const m = new Uint8Array(c * u * 4);
|
|
1260
|
+
return d.readPixels(s, l, c, u, d.RGBA, d.UNSIGNED_BYTE, m), d.bindFramebuffer(d.FRAMEBUFFER, f), m;
|
|
1233
1261
|
}
|
|
1234
1262
|
/**
|
|
1235
1263
|
* Get the color at a pixel in the render texture.
|
|
@@ -1238,7 +1266,7 @@ class At extends P {
|
|
|
1238
1266
|
*/
|
|
1239
1267
|
GetColorAt(t, e) {
|
|
1240
1268
|
const r = this.GetPixels(t, e, 1, 1);
|
|
1241
|
-
return r.length < 4 ? new
|
|
1269
|
+
return r.length < 4 ? new x(0, 0, 0, 0) : new x(r[0], r[1], r[2], r[3]);
|
|
1242
1270
|
}
|
|
1243
1271
|
/**
|
|
1244
1272
|
* Destroys the framebuffer, renderbuffer, and base texture.
|
|
@@ -1254,9 +1282,9 @@ const Ut = {
|
|
|
1254
1282
|
fill: "#000000",
|
|
1255
1283
|
strokeThickness: 1,
|
|
1256
1284
|
align: "left",
|
|
1257
|
-
|
|
1285
|
+
lineHeight: 1
|
|
1258
1286
|
};
|
|
1259
|
-
class
|
|
1287
|
+
class Ct extends B {
|
|
1260
1288
|
canvas;
|
|
1261
1289
|
ctx;
|
|
1262
1290
|
render;
|
|
@@ -1269,8 +1297,8 @@ class _t extends P {
|
|
|
1269
1297
|
const r = this.canvas.getContext("2d", { willReadFrequently: !0 });
|
|
1270
1298
|
if (!r) throw new Error("Failed to get 2d context for TextTexture");
|
|
1271
1299
|
this.ctx = r, this.canvas.width = 1, this.canvas.height = 1;
|
|
1272
|
-
const i =
|
|
1273
|
-
this.setBase(new
|
|
1300
|
+
const i = J(t, this.canvas, this.options);
|
|
1301
|
+
this.setBase(new z(i, 1, 1)), this.update();
|
|
1274
1302
|
}
|
|
1275
1303
|
get text() {
|
|
1276
1304
|
return this._text;
|
|
@@ -1293,122 +1321,108 @@ class _t extends P {
|
|
|
1293
1321
|
updateOffset(t, e) {
|
|
1294
1322
|
switch (this._style.align) {
|
|
1295
1323
|
case "center":
|
|
1296
|
-
|
|
1297
|
-
break;
|
|
1324
|
+
return t / 2;
|
|
1298
1325
|
case "right":
|
|
1299
|
-
|
|
1300
|
-
break;
|
|
1301
|
-
default:
|
|
1302
|
-
this.offsetX = 0;
|
|
1303
|
-
break;
|
|
1304
|
-
}
|
|
1305
|
-
switch (this._style.baseline) {
|
|
1306
|
-
case "middle":
|
|
1307
|
-
this.offsetY = -e / 2;
|
|
1308
|
-
break;
|
|
1309
|
-
case "bottom":
|
|
1310
|
-
this.offsetY = -e;
|
|
1311
|
-
break;
|
|
1326
|
+
return t;
|
|
1312
1327
|
default:
|
|
1313
|
-
|
|
1314
|
-
break;
|
|
1328
|
+
return e;
|
|
1315
1329
|
}
|
|
1316
1330
|
}
|
|
1317
1331
|
/**
|
|
1318
1332
|
* Updates the internal canvas and uploads it to WebGL
|
|
1319
1333
|
*/
|
|
1320
1334
|
update() {
|
|
1321
|
-
const t = this.ctx, e = this.
|
|
1322
|
-
t.font =
|
|
1335
|
+
const t = this.ctx, e = this.style, r = e.fontSize, i = e.fontWeight, s = e.fontFamily, a = e.lineHeight, o = `${i} ${r}px ${s}`, h = this.render.dpr;
|
|
1336
|
+
t.font = o, t.textBaseline = "top";
|
|
1323
1337
|
const c = this._text.split(`
|
|
1324
1338
|
`);
|
|
1325
|
-
let
|
|
1326
|
-
t.
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
b.width > h && (h = b.width), o += l + d;
|
|
1339
|
+
let u = 0, l = 0;
|
|
1340
|
+
const d = t.measureText(c[0]), f = d.fontBoundingBoxAscent + d.fontBoundingBoxDescent;
|
|
1341
|
+
for (const S of c) {
|
|
1342
|
+
const L = t.measureText(S);
|
|
1343
|
+
L.width > u && (u = L.width), l += f * a;
|
|
1331
1344
|
}
|
|
1332
|
-
|
|
1333
|
-
const
|
|
1334
|
-
(this.canvas.width !==
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1345
|
+
l -= f * (a - 1);
|
|
1346
|
+
const m = this._style.strokeThickness || 0, g = Math.ceil(u + m * 2) || 1, v = Math.ceil(l + m * 2) || 1, y = g * h, R = v * h;
|
|
1347
|
+
(this.canvas.width !== y || this.canvas.height !== R) && (this.canvas.width = y, this.canvas.height = R), t.setTransform(h, 0, 0, h, 0, 0), t.clearRect(0, 0, g, v), t.font = o, t.textBaseline = "top", t.textAlign = this._style.align;
|
|
1348
|
+
const A = this.updateOffset(g, m);
|
|
1349
|
+
let C = m;
|
|
1350
|
+
for (const S of c) {
|
|
1351
|
+
let L = A;
|
|
1352
|
+
e.stroke && e.strokeThickness > 0 && (t.lineWidth = e.strokeThickness, t.strokeStyle = e.stroke, t.strokeText(S, L, C)), e.fill && (t.fillStyle = e.fill, t.fillText(S, L, C)), C += f * a;
|
|
1339
1353
|
}
|
|
1340
|
-
this.base?.updateSource(this.render.gl, this.canvas, this.options), this.setRegion(0, 0,
|
|
1354
|
+
this.base?.updateSource(this.render.gl, this.canvas, this.options), this.setRegion(0, 0, y, R);
|
|
1341
1355
|
}
|
|
1342
1356
|
}
|
|
1343
|
-
const
|
|
1344
|
-
const r =
|
|
1357
|
+
const _t = (n, t = !1, e = !0) => {
|
|
1358
|
+
const r = n.getContext("webgl2", { stencil: !0, antialias: t, premultipliedAlpha: e });
|
|
1345
1359
|
if (!r)
|
|
1346
1360
|
throw new Error("WebGL2 is not supported in this browser.");
|
|
1347
1361
|
return r;
|
|
1348
|
-
},
|
|
1349
|
-
const r =
|
|
1362
|
+
}, ot = (n, t, e) => {
|
|
1363
|
+
const r = n.createShader(e);
|
|
1350
1364
|
if (!r)
|
|
1351
1365
|
throw new Error("Unable to create webgl shader");
|
|
1352
|
-
if (
|
|
1353
|
-
const
|
|
1354
|
-
throw console.error("Shader compilation failed:",
|
|
1366
|
+
if (n.shaderSource(r, t), n.compileShader(r), !n.getShaderParameter(r, n.COMPILE_STATUS)) {
|
|
1367
|
+
const s = n.getShaderInfoLog(r);
|
|
1368
|
+
throw console.error("Shader compilation failed:", s), new Error("Unable to compile shader: " + s + t);
|
|
1355
1369
|
}
|
|
1356
1370
|
return r;
|
|
1357
|
-
}, Pt = (
|
|
1358
|
-
var r =
|
|
1371
|
+
}, Pt = (n, t, e) => {
|
|
1372
|
+
var r = n.createProgram(), i = ot(n, t, 35633), s = ot(n, e, 35632);
|
|
1359
1373
|
if (!r)
|
|
1360
1374
|
throw new Error("Unable to create program shader");
|
|
1361
|
-
if (
|
|
1362
|
-
const
|
|
1363
|
-
throw new Error("Unable to link shader program: " +
|
|
1375
|
+
if (n.attachShader(r, i), n.attachShader(r, s), n.linkProgram(r), !n.getProgramParameter(r, n.LINK_STATUS)) {
|
|
1376
|
+
const o = n.getProgramInfoLog(r);
|
|
1377
|
+
throw new Error("Unable to link shader program: " + o);
|
|
1364
1378
|
}
|
|
1365
1379
|
return r;
|
|
1366
1380
|
};
|
|
1367
|
-
function
|
|
1381
|
+
function rt(n, t) {
|
|
1368
1382
|
const e = {
|
|
1369
|
-
[
|
|
1370
|
-
[
|
|
1371
|
-
[
|
|
1372
|
-
}[t] ||
|
|
1373
|
-
|
|
1383
|
+
[q.CLAMP]: n.CLAMP_TO_EDGE,
|
|
1384
|
+
[q.REPEAT]: n.REPEAT,
|
|
1385
|
+
[q.MIRRORED_REPEAT]: n.MIRRORED_REPEAT
|
|
1386
|
+
}[t] || n.CLAMP_TO_EDGE;
|
|
1387
|
+
n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, e), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, e);
|
|
1374
1388
|
}
|
|
1375
|
-
function
|
|
1389
|
+
function it(n, t) {
|
|
1376
1390
|
const e = {
|
|
1377
|
-
[
|
|
1378
|
-
[
|
|
1379
|
-
}[t] ??
|
|
1380
|
-
|
|
1391
|
+
[nt.LINEAR]: n.LINEAR,
|
|
1392
|
+
[nt.NEAREST]: n.NEAREST
|
|
1393
|
+
}[t] ?? n.NEAREST;
|
|
1394
|
+
n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, e), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, e);
|
|
1381
1395
|
}
|
|
1382
|
-
function
|
|
1383
|
-
const r =
|
|
1396
|
+
function J(n, t, e) {
|
|
1397
|
+
const r = n.gl, i = r.createTexture();
|
|
1384
1398
|
if (!i)
|
|
1385
1399
|
throw new Error("Unable to create WebGL texture");
|
|
1386
|
-
if (r.bindTexture(r.TEXTURE_2D, i), r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, 0), r.pixelStorei(r.UNPACK_ALIGNMENT, 1),
|
|
1387
|
-
const
|
|
1388
|
-
r.texImage2D(r.TEXTURE_2D, 0, r.RGBA,
|
|
1400
|
+
if (r.bindTexture(r.TEXTURE_2D, i), r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, 0), r.pixelStorei(r.UNPACK_ALIGNMENT, 1), rt(r, e.wrap ?? q.CLAMP), it(r, e.textureFilter ?? n.textureFilter), e.onlySize) {
|
|
1401
|
+
const s = t;
|
|
1402
|
+
r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, s.width, s.height, 0, r.RGBA, r.UNSIGNED_BYTE, null);
|
|
1389
1403
|
} else {
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1404
|
+
const s = e.premultipliedAlpha ?? n.premultipliedAlpha;
|
|
1405
|
+
s && r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0), r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, r.RGBA, r.UNSIGNED_BYTE, t), s && r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1);
|
|
1392
1406
|
}
|
|
1393
1407
|
return r.bindTexture(r.TEXTURE_2D, null), i;
|
|
1394
1408
|
}
|
|
1395
|
-
function
|
|
1396
|
-
if (
|
|
1409
|
+
function H(n, t) {
|
|
1410
|
+
if (n.includes("%TEXTURE_NUM%") && (n = n.replace("%TEXTURE_NUM%", t.toString())), n.includes("%GET_COLOR%")) {
|
|
1397
1411
|
let e = "";
|
|
1398
1412
|
for (let r = 0; r < t; r++)
|
|
1399
1413
|
r == 0 ? e += `if(vTextureId == ${r})` : r == t - 1 ? e += "else" : e += `else if(vTextureId == ${r})`, e += `{return texture(uTextures[${r}], uv);}`;
|
|
1400
|
-
|
|
1414
|
+
n = n.replace("%GET_COLOR%", e);
|
|
1401
1415
|
}
|
|
1402
|
-
return
|
|
1416
|
+
return n;
|
|
1403
1417
|
}
|
|
1404
|
-
const Nt = 5126,
|
|
1405
|
-
function Lt(
|
|
1406
|
-
|
|
1418
|
+
const Nt = 5126, st = 5121;
|
|
1419
|
+
function Lt(n, t, e) {
|
|
1420
|
+
n.vertexAttribDivisor(t, e);
|
|
1407
1421
|
}
|
|
1408
|
-
function
|
|
1409
|
-
|
|
1422
|
+
function yt(n, t, e, r, i) {
|
|
1423
|
+
n.drawArraysInstanced(t, e, r, i);
|
|
1410
1424
|
}
|
|
1411
|
-
let
|
|
1425
|
+
let It = 0;
|
|
1412
1426
|
class Tt {
|
|
1413
1427
|
program;
|
|
1414
1428
|
attributeLoc = {};
|
|
@@ -1421,7 +1435,7 @@ class Tt {
|
|
|
1421
1435
|
/** Whether the uniform is an array (e.g. sampler2D uTextures[8]) */
|
|
1422
1436
|
uniformIsArray = {};
|
|
1423
1437
|
gl;
|
|
1424
|
-
shaderId =
|
|
1438
|
+
shaderId = It++;
|
|
1425
1439
|
// for debug
|
|
1426
1440
|
vao;
|
|
1427
1441
|
constructor(t, e, r, i) {
|
|
@@ -1450,8 +1464,8 @@ class Tt {
|
|
|
1450
1464
|
setUniform(t, e) {
|
|
1451
1465
|
const r = this.uniformLoc[t];
|
|
1452
1466
|
if (r === void 0) return;
|
|
1453
|
-
const i = this.uniformType[t],
|
|
1454
|
-
|
|
1467
|
+
const i = this.uniformType[t], s = this.uniformIsArray[t];
|
|
1468
|
+
Ot(this.gl, r, i, e, s);
|
|
1455
1469
|
}
|
|
1456
1470
|
/**
|
|
1457
1471
|
* Batch-set uniforms via a plain value map.
|
|
@@ -1498,77 +1512,77 @@ class Tt {
|
|
|
1498
1512
|
parseShader(t) {
|
|
1499
1513
|
const e = this.gl, r = t.match(/(?:in|attribute)\s+\w+\s+\w+/g);
|
|
1500
1514
|
if (r)
|
|
1501
|
-
for (const
|
|
1502
|
-
const
|
|
1503
|
-
h !== -1 && (this.attributeLoc[
|
|
1515
|
+
for (const s of r) {
|
|
1516
|
+
const o = s.split(/\s+/)[2], h = e.getAttribLocation(this.program, o);
|
|
1517
|
+
h !== -1 && (this.attributeLoc[o] = h);
|
|
1504
1518
|
}
|
|
1505
1519
|
const i = t.match(/uniform\s+\w+\s+\w+(?:\[\d+\])?/g);
|
|
1506
1520
|
if (i)
|
|
1507
|
-
for (const
|
|
1508
|
-
const a =
|
|
1509
|
-
|
|
1521
|
+
for (const s of i) {
|
|
1522
|
+
const a = s.split(/\s+/), o = a[1], h = a[2].replace(/\[\d+\]$/, ""), c = e.getUniformLocation(this.program, h);
|
|
1523
|
+
c !== null && (this.uniformLoc[h] = c, this.uniformType[h] = o, this.uniformIsArray[h] = /\[\d+\]$/.test(a[2]));
|
|
1510
1524
|
}
|
|
1511
1525
|
}
|
|
1512
1526
|
}
|
|
1513
|
-
function
|
|
1527
|
+
function Ot(n, t, e, r, i = !1) {
|
|
1514
1528
|
switch (e) {
|
|
1515
1529
|
// scalars
|
|
1516
1530
|
case "float":
|
|
1517
|
-
return
|
|
1531
|
+
return n.uniform1f(t, r);
|
|
1518
1532
|
case "int":
|
|
1519
1533
|
case "bool":
|
|
1520
1534
|
case "sampler2D":
|
|
1521
1535
|
case "samplerCube":
|
|
1522
|
-
return i ?
|
|
1536
|
+
return i ? n.uniform1iv(t, r) : n.uniform1i(t, r);
|
|
1523
1537
|
// float vectors
|
|
1524
1538
|
case "vec2":
|
|
1525
|
-
return
|
|
1539
|
+
return n.uniform2fv(t, r);
|
|
1526
1540
|
case "vec3":
|
|
1527
|
-
return
|
|
1541
|
+
return n.uniform3fv(t, r);
|
|
1528
1542
|
case "vec4":
|
|
1529
|
-
return
|
|
1543
|
+
return n.uniform4fv(t, r);
|
|
1530
1544
|
// int / bool vectors
|
|
1531
1545
|
case "ivec2":
|
|
1532
1546
|
case "bvec2":
|
|
1533
|
-
return
|
|
1547
|
+
return n.uniform2iv(t, r);
|
|
1534
1548
|
case "ivec3":
|
|
1535
1549
|
case "bvec3":
|
|
1536
|
-
return
|
|
1550
|
+
return n.uniform3iv(t, r);
|
|
1537
1551
|
case "ivec4":
|
|
1538
1552
|
case "bvec4":
|
|
1539
|
-
return
|
|
1553
|
+
return n.uniform4iv(t, r);
|
|
1540
1554
|
// matrices (column-major, transpose = false)
|
|
1541
1555
|
case "mat2":
|
|
1542
|
-
return
|
|
1556
|
+
return n.uniformMatrix2fv(t, !1, r);
|
|
1543
1557
|
case "mat3":
|
|
1544
|
-
return
|
|
1558
|
+
return n.uniformMatrix3fv(t, !1, r);
|
|
1545
1559
|
case "mat4":
|
|
1546
|
-
return
|
|
1560
|
+
return n.uniformMatrix4fv(t, !1, r);
|
|
1547
1561
|
// fallback: guess by value shape
|
|
1548
1562
|
default:
|
|
1549
|
-
return
|
|
1563
|
+
return Ft(n, t, r);
|
|
1550
1564
|
}
|
|
1551
1565
|
}
|
|
1552
|
-
function
|
|
1566
|
+
function Ft(n, t, e) {
|
|
1553
1567
|
if (typeof e == "number")
|
|
1554
|
-
return
|
|
1568
|
+
return n.uniform1f(t, e);
|
|
1555
1569
|
const r = e;
|
|
1556
1570
|
switch (r.length) {
|
|
1557
1571
|
case 2:
|
|
1558
|
-
return
|
|
1572
|
+
return n.uniform2fv(t, r);
|
|
1559
1573
|
case 3:
|
|
1560
|
-
return
|
|
1574
|
+
return n.uniform3fv(t, r);
|
|
1561
1575
|
case 4:
|
|
1562
|
-
return
|
|
1576
|
+
return n.uniform4fv(t, r);
|
|
1563
1577
|
case 9:
|
|
1564
|
-
return
|
|
1578
|
+
return n.uniformMatrix3fv(t, !1, r);
|
|
1565
1579
|
case 16:
|
|
1566
|
-
return
|
|
1580
|
+
return n.uniformMatrix4fv(t, !1, r);
|
|
1567
1581
|
default:
|
|
1568
|
-
return
|
|
1582
|
+
return n.uniform1fv(t, r);
|
|
1569
1583
|
}
|
|
1570
1584
|
}
|
|
1571
|
-
class
|
|
1585
|
+
class ct {
|
|
1572
1586
|
/** Custom vertex shader code */
|
|
1573
1587
|
vs;
|
|
1574
1588
|
/** Custom fragment shader code */
|
|
@@ -1586,8 +1600,8 @@ class ot {
|
|
|
1586
1600
|
/** Padding in pixels this shader needs beyond the sprite bounds (for outline/glow effects) */
|
|
1587
1601
|
padding = 0;
|
|
1588
1602
|
rapid;
|
|
1589
|
-
constructor(t, e, r, i = 0,
|
|
1590
|
-
this.vs = e, this.fs = r, this.rapid = t, this.uniforms =
|
|
1603
|
+
constructor(t, e, r, i = 0, s) {
|
|
1604
|
+
this.vs = e, this.fs = r, this.rapid = t, this.uniforms = s ?? {}, this.usedTextureUnitNum = i;
|
|
1591
1605
|
}
|
|
1592
1606
|
/**
|
|
1593
1607
|
* Updates uniform values or textures for the custom shader.
|
|
@@ -1596,8 +1610,8 @@ class ot {
|
|
|
1596
1610
|
setUniforms(t) {
|
|
1597
1611
|
this.rapid.flush();
|
|
1598
1612
|
const e = {}, r = {};
|
|
1599
|
-
for (const [i,
|
|
1600
|
-
|
|
1613
|
+
for (const [i, s] of Object.entries(t))
|
|
1614
|
+
s instanceof WebGLTexture ? r[i] = s : e[i] = s;
|
|
1601
1615
|
Object.assign(this.uniforms, e), Object.assign(this.uniformTextures, r);
|
|
1602
1616
|
for (const i of this.glshader.keys())
|
|
1603
1617
|
this.uniformDirty.add(i);
|
|
@@ -1636,11 +1650,11 @@ class ot {
|
|
|
1636
1650
|
if (i == null || r == null)
|
|
1637
1651
|
return console.warn("CustomGlShader: missing base shader for " + e), null;
|
|
1638
1652
|
r = r.replace("// CUSTOM_CODE_CALL", "vertex(position, vRegion);"), i = i.replace("// CUSTOM_CODE_CALL", "fragment(fragColor);"), r = r.replace("// CUSTOM_CODE", this.vs), i = i.replace("// CUSTOM_CODE", this.fs);
|
|
1639
|
-
const
|
|
1640
|
-
return
|
|
1653
|
+
const s = t.createShader(r, i);
|
|
1654
|
+
return s.isCustom = !0, s.padding = this.padding, this.glshader.set(e, s), this.uniformDirty.add(e), s;
|
|
1641
1655
|
}
|
|
1642
1656
|
}
|
|
1643
|
-
class
|
|
1657
|
+
class Et {
|
|
1644
1658
|
constructor(t) {
|
|
1645
1659
|
this.rapid = t, this.gl = t.gl, this.maxTextureUnits = t.maxTextureUnits, this.matrixStore = t.matrix;
|
|
1646
1660
|
}
|
|
@@ -1672,8 +1686,8 @@ class yt {
|
|
|
1672
1686
|
}
|
|
1673
1687
|
findTextureUnit(t, e = 0, r = 0) {
|
|
1674
1688
|
for (let i = 0; i < this.usedTextures.length; i++) {
|
|
1675
|
-
const
|
|
1676
|
-
if (this.usedTextures[i] === t && this.usedTexturePadding[
|
|
1689
|
+
const s = i * 2;
|
|
1690
|
+
if (this.usedTextures[i] === t && this.usedTexturePadding[s] === e && this.usedTexturePadding[s + 1] === r)
|
|
1677
1691
|
return i;
|
|
1678
1692
|
}
|
|
1679
1693
|
return -1;
|
|
@@ -1691,7 +1705,7 @@ class yt {
|
|
|
1691
1705
|
getCustomShader(t) {
|
|
1692
1706
|
if (!t)
|
|
1693
1707
|
return this.defaultShader;
|
|
1694
|
-
if (t instanceof
|
|
1708
|
+
if (t instanceof ct) {
|
|
1695
1709
|
const e = this.createCustomShader(t);
|
|
1696
1710
|
return e ?? this.defaultShader;
|
|
1697
1711
|
}
|
|
@@ -1706,7 +1720,7 @@ class yt {
|
|
|
1706
1720
|
return this.isDefaultShader && !t ? !0 : this.getCustomShader(t) == this.currentShader;
|
|
1707
1721
|
}
|
|
1708
1722
|
enter(t) {
|
|
1709
|
-
this.resetRender(), this.currentShader = this.getCustomShader(t), t instanceof
|
|
1723
|
+
this.resetRender(), this.currentShader = this.getCustomShader(t), t instanceof ct ? (this.customShader = t, this.customShaderUsedTextureNum = t.usedTextureUnitNum) : (this.customShader = null, this.customShaderUsedTextureNum = 0), this.isDefaultShader = this.currentShader == this.defaultShader, this.currentShader.use(), this.currentShader.setUniform("u_projection", this.rapid.projection);
|
|
1710
1724
|
}
|
|
1711
1725
|
exit() {
|
|
1712
1726
|
this.hasPendingContent() && this.flush(), this.gl.bindVertexArray(null);
|
|
@@ -1721,8 +1735,8 @@ class yt {
|
|
|
1721
1735
|
const t = this.currentShader;
|
|
1722
1736
|
if (t.use(), this.customShader) {
|
|
1723
1737
|
const r = this.customShader, i = {};
|
|
1724
|
-
for (const
|
|
1725
|
-
i[
|
|
1738
|
+
for (const s in r.uniformTextures)
|
|
1739
|
+
i[s] = this.useTexture(r.uniformTextures[s]);
|
|
1726
1740
|
this.customShader.applyUniform(this.KEY, i);
|
|
1727
1741
|
}
|
|
1728
1742
|
const e = this.gl;
|
|
@@ -1743,7 +1757,7 @@ class yt {
|
|
|
1743
1757
|
return !1;
|
|
1744
1758
|
}
|
|
1745
1759
|
}
|
|
1746
|
-
const
|
|
1760
|
+
const Z = `#version 300 es\r
|
|
1747
1761
|
precision highp float;\r
|
|
1748
1762
|
\r
|
|
1749
1763
|
// per-vertex\r
|
|
@@ -1791,7 +1805,7 @@ void main(void) {\r
|
|
|
1791
1805
|
\r
|
|
1792
1806
|
gl_Position = u_projection * position;\r
|
|
1793
1807
|
}\r
|
|
1794
|
-
`,
|
|
1808
|
+
`, ut = `#version 300 es\r
|
|
1795
1809
|
precision mediump float;\r
|
|
1796
1810
|
\r
|
|
1797
1811
|
uniform sampler2D uTextures[%TEXTURE_NUM%];\r
|
|
@@ -1840,8 +1854,8 @@ void main(void) {\r
|
|
|
1840
1854
|
\r
|
|
1841
1855
|
// CUSTOM_CODE_CALL\r
|
|
1842
1856
|
}\r
|
|
1843
|
-
`,
|
|
1844
|
-
class
|
|
1857
|
+
`, j = 48, Wt = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
|
|
1858
|
+
class at extends Et {
|
|
1845
1859
|
instanceBuffer;
|
|
1846
1860
|
quadBuffer;
|
|
1847
1861
|
instanceCount = 0;
|
|
@@ -1853,28 +1867,28 @@ class it extends yt {
|
|
|
1853
1867
|
}
|
|
1854
1868
|
createBuffer() {
|
|
1855
1869
|
const t = this.gl;
|
|
1856
|
-
this.quadBuffer = new
|
|
1857
|
-
for (const e of
|
|
1858
|
-
this.quadBuffer.makeDirty(), this.quadBuffer.bufferData(), this.instanceBuffer = new
|
|
1870
|
+
this.quadBuffer = new et(t, U.Float32, t.ARRAY_BUFFER, t.STATIC_DRAW), this.quadBuffer.bindBuffer();
|
|
1871
|
+
for (const e of Wt) this.quadBuffer.pushFloat32(e);
|
|
1872
|
+
this.quadBuffer.makeDirty(), this.quadBuffer.bufferData(), this.instanceBuffer = new et(t, U.Uint32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW);
|
|
1859
1873
|
}
|
|
1860
1874
|
createDefaultShader() {
|
|
1861
|
-
const t = this.rapid, e =
|
|
1875
|
+
const t = this.rapid, e = H(ut, t.maxTextureUnits), r = H(Z, t.maxTextureUnits);
|
|
1862
1876
|
return this.vs = r, this.fs = e, this.defaultShader = this.createShader(r, e), this.defaultShader;
|
|
1863
1877
|
}
|
|
1864
1878
|
createShader(t, e) {
|
|
1865
1879
|
const r = super.createShader(t, e);
|
|
1866
1880
|
return r.use(), r.bindVAO(), this.instanceBuffer.bindBuffer(), r.setAttributes([
|
|
1867
|
-
{ name: "aMatrixRow0", size: 3, stride:
|
|
1868
|
-
{ name: "aMatrixRow1", size: 3, stride:
|
|
1869
|
-
{ name: "aUVRect", size: 4, stride:
|
|
1870
|
-
{ name: "aColor", size: 4, type:
|
|
1871
|
-
{ name: "aTextureId", size: 1, type:
|
|
1881
|
+
{ name: "aMatrixRow0", size: 3, stride: j, offset: 0, divisor: 1 },
|
|
1882
|
+
{ name: "aMatrixRow1", size: 3, stride: j, offset: 12, divisor: 1 },
|
|
1883
|
+
{ name: "aUVRect", size: 4, stride: j, offset: 24, divisor: 1 },
|
|
1884
|
+
{ name: "aColor", size: 4, type: st, normalized: !0, stride: j, offset: 40, divisor: 1 },
|
|
1885
|
+
{ name: "aTextureId", size: 1, type: st, stride: j, offset: 44, divisor: 1 }
|
|
1872
1886
|
]), this.quadBuffer.bindBuffer(), r.setAttributes([
|
|
1873
1887
|
{ name: "aVertex", size: 2, stride: 8, offset: 0, divisor: 0 }
|
|
1874
1888
|
]), r.unbindVAO(), this.currentShader && this.currentShader.use(), r;
|
|
1875
1889
|
}
|
|
1876
1890
|
createCustomShader(t) {
|
|
1877
|
-
const e =
|
|
1891
|
+
const e = H(ut, this.rapid.maxTextureUnits - t.usedTextureUnitNum), r = H(Z, this.rapid.maxTextureUnits - t.usedTextureUnitNum);
|
|
1878
1892
|
return t.getGLShader(this, this.KEY, r, e);
|
|
1879
1893
|
}
|
|
1880
1894
|
/**
|
|
@@ -1889,45 +1903,45 @@ class it extends yt {
|
|
|
1889
1903
|
* @param v1 Bottom UV mapped coordinate (default 1).
|
|
1890
1904
|
* @param color The tint color as packed ABGR uniform uint32 (default 0xFFFFFFFF).
|
|
1891
1905
|
*/
|
|
1892
|
-
drawSprite(t, e, r = 0, i = 0,
|
|
1893
|
-
const f = e * 6,
|
|
1906
|
+
drawSprite(t, e, r = 0, i = 0, s = 1, a = 1, o = 4294967295, h = 0, c = 0, u = !1, l = !1, d = !1) {
|
|
1907
|
+
const f = e * 6, m = this.matrixStore.data;
|
|
1894
1908
|
this.drawSpriteAffine(
|
|
1895
1909
|
t,
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1910
|
+
m[f],
|
|
1911
|
+
m[f + 1],
|
|
1912
|
+
m[f + 2],
|
|
1913
|
+
m[f + 3],
|
|
1914
|
+
m[f + 4],
|
|
1915
|
+
m[f + 5],
|
|
1902
1916
|
r,
|
|
1903
1917
|
i,
|
|
1904
|
-
|
|
1918
|
+
s,
|
|
1905
1919
|
a,
|
|
1906
|
-
c,
|
|
1907
|
-
h,
|
|
1908
1920
|
o,
|
|
1921
|
+
h,
|
|
1922
|
+
c,
|
|
1909
1923
|
u,
|
|
1910
1924
|
l,
|
|
1911
1925
|
d
|
|
1912
1926
|
);
|
|
1913
1927
|
}
|
|
1914
|
-
drawSpriteAffine(t, e, r, i,
|
|
1915
|
-
const R = t.base,
|
|
1928
|
+
drawSpriteAffine(t, e, r, i, s, a, o, h = 0, c = 0, u = 1, l = 1, d = 4294967295, f = 0, m = 0, g = !1, v = !1, y = !1) {
|
|
1929
|
+
const R = t.base, A = t.rawWidth, C = t.rawHeight, S = t.offsetX, L = t.offsetY, X = this.useTexture(
|
|
1916
1930
|
t.glTexture,
|
|
1917
|
-
f /
|
|
1918
|
-
|
|
1919
|
-
),
|
|
1920
|
-
|
|
1921
|
-
const
|
|
1922
|
-
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1931
|
+
f / R.width,
|
|
1932
|
+
m / R.height
|
|
1933
|
+
), I = this.instanceBuffer, w = I.usedElemNum;
|
|
1934
|
+
I.resize(12);
|
|
1935
|
+
const _ = I.float32, D = I.uint32, k = y ? C : A, G = y ? A : C, O = k + 2 * f, F = G + 2 * m, b = S - f, N = L - m, T = this.localSpriteMatrix;
|
|
1936
|
+
y ? (T[0] = 0, T[1] = v ? F : -F, T[2] = g ? -O : O, T[3] = 0, T[4] = b + (g ? O : 0), T[5] = N + (v ? 0 : F)) : (T[0] = g ? -O : O, T[1] = 0, T[2] = 0, T[3] = v ? -F : F, T[4] = b + (g ? O : 0), T[5] = N + (v ? F : 0));
|
|
1937
|
+
const M = this.worldSpriteMatrix;
|
|
1938
|
+
M[0] = e * T[0] + i * T[1], M[1] = r * T[0] + s * T[1], M[2] = e * T[2] + i * T[3], M[3] = r * T[2] + s * T[3], M[4] = a + e * T[4] + i * T[5], M[5] = o + r * T[4] + s * T[5], _[w + 6] = h, _[w + 7] = c, _[w + 8] = u, _[w + 9] = l, D[w + 10] = d, D[w + 11] = X, this.rapid.roundPixels && (M[4] = Math.round(M[4]), M[5] = Math.round(M[5])), _[w] = M[0], _[w + 1] = M[2], _[w + 2] = M[4], _[w + 3] = M[1], _[w + 4] = M[3], _[w + 5] = M[5], I.usedElemNum += 12, I.makeDirty(), this.instanceCount++;
|
|
1925
1939
|
}
|
|
1926
1940
|
render() {
|
|
1927
1941
|
if (this.instanceCount === 0) return;
|
|
1928
1942
|
this.prepareRender();
|
|
1929
1943
|
const t = this.gl, e = this.currentShader;
|
|
1930
|
-
this.instanceBuffer.bindBuffer(), this.instanceBuffer.bufferData(), e.bindVAO(),
|
|
1944
|
+
this.instanceBuffer.bindBuffer(), this.instanceBuffer.bufferData(), e.bindVAO(), yt(t, t.TRIANGLE_STRIP, 0, 4, this.instanceCount), this.rapid.drawcallCount++;
|
|
1931
1945
|
}
|
|
1932
1946
|
resetRender() {
|
|
1933
1947
|
super.resetRender(), this.instanceBuffer.clear(), this.instanceCount = 0;
|
|
@@ -1936,7 +1950,7 @@ class it extends yt {
|
|
|
1936
1950
|
return this.instanceCount > 0;
|
|
1937
1951
|
}
|
|
1938
1952
|
}
|
|
1939
|
-
const
|
|
1953
|
+
const Bt = `#version 300 es\r
|
|
1940
1954
|
precision highp float;\r
|
|
1941
1955
|
\r
|
|
1942
1956
|
in vec2 aPosition;\r
|
|
@@ -1967,7 +1981,7 @@ void main(void) {\r
|
|
|
1967
1981
|
// CUSTOM_CODE_CALL\r
|
|
1968
1982
|
gl_Position = u_projection * position;\r
|
|
1969
1983
|
}\r
|
|
1970
|
-
`,
|
|
1984
|
+
`, Dt = `#version 300 es\r
|
|
1971
1985
|
precision mediump float;\r
|
|
1972
1986
|
\r
|
|
1973
1987
|
in vec4 vColor;\r
|
|
@@ -2056,8 +2070,8 @@ void main(void) {\r
|
|
|
2056
2070
|
discard;\r
|
|
2057
2071
|
}\r
|
|
2058
2072
|
}\r
|
|
2059
|
-
`,
|
|
2060
|
-
class Ht extends
|
|
2073
|
+
`, $ = 20;
|
|
2074
|
+
class Ht extends Et {
|
|
2061
2075
|
vertexBuffer;
|
|
2062
2076
|
vertexCount = 0;
|
|
2063
2077
|
matrixIndex = -1;
|
|
@@ -2070,24 +2084,24 @@ class Ht extends yt {
|
|
|
2070
2084
|
}
|
|
2071
2085
|
createBuffer() {
|
|
2072
2086
|
const t = this.gl;
|
|
2073
|
-
this.vertexBuffer = new
|
|
2087
|
+
this.vertexBuffer = new et(t, U.Float32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW), this.maskShader = this.createMaskShader(kt, Gt);
|
|
2074
2088
|
}
|
|
2075
2089
|
createDefaultShader() {
|
|
2076
|
-
return this.vs =
|
|
2090
|
+
return this.vs = Bt, this.fs = Dt, this.defaultShader = this.createShader(this.vs, this.fs), this.defaultShader;
|
|
2077
2091
|
}
|
|
2078
2092
|
createMaskShader(t, e) {
|
|
2079
2093
|
const r = this.gl, i = new Tt(r, t, e);
|
|
2080
2094
|
return i.use(), i.bindVAO(), this.vertexBuffer.bindBuffer(), i.setAttributes([
|
|
2081
|
-
{ name: "aPosition", size: 2, type: r.FLOAT, stride:
|
|
2082
|
-
{ name: "aUV", size: 2, type: r.FLOAT, stride:
|
|
2095
|
+
{ name: "aPosition", size: 2, type: r.FLOAT, stride: $ - 4, offset: 0, divisor: 0 },
|
|
2096
|
+
{ name: "aUV", size: 2, type: r.FLOAT, stride: $ - 4, offset: 8, divisor: 0 }
|
|
2083
2097
|
]), i.unbindVAO(), this.currentShader && this.currentShader.use(), i;
|
|
2084
2098
|
}
|
|
2085
2099
|
createShader(t, e) {
|
|
2086
2100
|
const r = this.gl, i = super.createShader(t, e);
|
|
2087
2101
|
return i.use(), i.bindVAO(), this.vertexBuffer.bindBuffer(), i.setAttributes([
|
|
2088
|
-
{ name: "aPosition", size: 2, type: r.FLOAT, stride:
|
|
2089
|
-
{ name: "aColor", size: 4, type: r.UNSIGNED_BYTE, normalized: !0, stride:
|
|
2090
|
-
{ name: "aUV", size: 2, type: r.FLOAT, stride:
|
|
2102
|
+
{ name: "aPosition", size: 2, type: r.FLOAT, stride: $, offset: 0, divisor: 0 },
|
|
2103
|
+
{ name: "aColor", size: 4, type: r.UNSIGNED_BYTE, normalized: !0, stride: $, offset: 8, divisor: 0 },
|
|
2104
|
+
{ name: "aUV", size: 2, type: r.FLOAT, stride: $, offset: 12, divisor: 0 }
|
|
2091
2105
|
]), i.unbindVAO(), this.currentShader && this.currentShader.use(), i;
|
|
2092
2106
|
}
|
|
2093
2107
|
/**
|
|
@@ -2107,22 +2121,22 @@ class Ht extends yt {
|
|
|
2107
2121
|
* @param v UV mapped Y value (0-1, default 0).
|
|
2108
2122
|
* @param color Pre-multiplied hex color combined using ABGR byte order (default 0xFFFFFFFF).
|
|
2109
2123
|
*/
|
|
2110
|
-
addVertex(t, e, r = 0, i = 0,
|
|
2124
|
+
addVertex(t, e, r = 0, i = 0, s = 4294967295) {
|
|
2111
2125
|
const a = this.vertexBuffer;
|
|
2112
|
-
a.pushFloat32(t), a.pushFloat32(e), this.currentShader != this.maskShader && a.pushUint32(
|
|
2126
|
+
a.pushFloat32(t), a.pushFloat32(e), this.currentShader != this.maskShader && a.pushUint32(s), a.pushFloat32(r), a.pushFloat32(i), this.vertexCount++, this.vertexBuffer.makeDirty();
|
|
2113
2127
|
}
|
|
2114
2128
|
/**
|
|
2115
2129
|
* Finishes the graphic construction and dispatches the rendering call immediately.
|
|
2116
2130
|
*/
|
|
2117
2131
|
endGraphic() {
|
|
2118
|
-
this.
|
|
2132
|
+
this.flush();
|
|
2119
2133
|
}
|
|
2120
2134
|
render() {
|
|
2121
2135
|
if (this.vertexCount === 0) return;
|
|
2122
2136
|
this.prepareRender();
|
|
2123
2137
|
const t = this.gl, e = this.currentShader, r = this.matrixIndex * 6, i = this.matrixStore.data;
|
|
2124
|
-
let
|
|
2125
|
-
this.rapid.roundPixels && (
|
|
2138
|
+
let s = i[r + 4], a = i[r + 5];
|
|
2139
|
+
this.rapid.roundPixels && (s = Math.round(s), a = Math.round(a)), e.setUniform("uMatrixRow0", [i[r], i[r + 2], s]), e.setUniform("uMatrixRow1", [i[r + 1], i[r + 3], a]), e.setUniform(
|
|
2126
2140
|
"uUVRect",
|
|
2127
2141
|
this.texture ? [this.texture.uvX, this.texture.uvY, this.texture.uvW, this.texture.uvH] : [0, 0, 1, 1]
|
|
2128
2142
|
), this.texture?.glTexture ? (t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.texture.glTexture), e.setUniform("uTexture", 0), e.setUniform("uUseTexture", 1)) : e.setUniform("uUseTexture", 0), this.vertexBuffer.bindBuffer(), this.vertexBuffer.bufferData(), e.bindVAO(), t.drawArrays(this.drawMode, 0, this.vertexCount), this.rapid.drawcallCount++, this.texture = void 0;
|
|
@@ -2131,15 +2145,15 @@ class Ht extends yt {
|
|
|
2131
2145
|
return !1;
|
|
2132
2146
|
}
|
|
2133
2147
|
}
|
|
2134
|
-
class
|
|
2148
|
+
class p {
|
|
2135
2149
|
x;
|
|
2136
2150
|
y;
|
|
2137
|
-
static ZERO = new
|
|
2138
|
-
static ONE = new
|
|
2139
|
-
static UP = new
|
|
2140
|
-
static DOWN = new
|
|
2141
|
-
static LEFT = new
|
|
2142
|
-
static RIGHT = new
|
|
2151
|
+
static ZERO = new p(0, 0);
|
|
2152
|
+
static ONE = new p(1, 1);
|
|
2153
|
+
static UP = new p(0, 1);
|
|
2154
|
+
static DOWN = new p(0, -1);
|
|
2155
|
+
static LEFT = new p(-1, 0);
|
|
2156
|
+
static RIGHT = new p(1, 0);
|
|
2143
2157
|
constructor(t, e) {
|
|
2144
2158
|
this.x = t !== void 0 ? t : 0, this.y = e !== void 0 ? e : 0;
|
|
2145
2159
|
}
|
|
@@ -2147,22 +2161,22 @@ class m {
|
|
|
2147
2161
|
return e === void 0 ? (this.x = t, this.y = t) : (this.x = t, this.y = e), this;
|
|
2148
2162
|
}
|
|
2149
2163
|
add(t) {
|
|
2150
|
-
return new
|
|
2164
|
+
return new p(this.x + t.x, this.y + t.y);
|
|
2151
2165
|
}
|
|
2152
2166
|
subtract(t) {
|
|
2153
|
-
return new
|
|
2167
|
+
return new p(this.x - t.x, this.y - t.y);
|
|
2154
2168
|
}
|
|
2155
2169
|
sub(t) {
|
|
2156
|
-
return new
|
|
2170
|
+
return new p(this.x - t.x, this.y - t.y);
|
|
2157
2171
|
}
|
|
2158
2172
|
multiply(t) {
|
|
2159
|
-
return t instanceof
|
|
2173
|
+
return t instanceof p ? new p(this.x * t.x, this.y * t.y) : new p(this.x * t, this.y * t);
|
|
2160
2174
|
}
|
|
2161
2175
|
mul(t) {
|
|
2162
2176
|
return this.multiply(t);
|
|
2163
2177
|
}
|
|
2164
2178
|
divide(t) {
|
|
2165
|
-
return t instanceof
|
|
2179
|
+
return t instanceof p ? new p(this.x / t.x, this.y / t.y) : new p(this.x / t, this.y / t);
|
|
2166
2180
|
}
|
|
2167
2181
|
dot(t) {
|
|
2168
2182
|
return this.x * t.x + this.y * t.y;
|
|
@@ -2175,13 +2189,13 @@ class m {
|
|
|
2175
2189
|
return Math.sqrt(e * e + r * r);
|
|
2176
2190
|
}
|
|
2177
2191
|
clone() {
|
|
2178
|
-
return new
|
|
2192
|
+
return new p(this.x, this.y);
|
|
2179
2193
|
}
|
|
2180
2194
|
to(t) {
|
|
2181
2195
|
this.x = t.x, this.y = t.y;
|
|
2182
2196
|
}
|
|
2183
2197
|
copy() {
|
|
2184
|
-
return new
|
|
2198
|
+
return new p(this.x, this.y);
|
|
2185
2199
|
}
|
|
2186
2200
|
equals(t) {
|
|
2187
2201
|
return t.x == this.x && t.y == this.y;
|
|
@@ -2194,7 +2208,7 @@ class m {
|
|
|
2194
2208
|
return this.x = -this.x, this.y = -this.y, this;
|
|
2195
2209
|
}
|
|
2196
2210
|
inverted() {
|
|
2197
|
-
return new
|
|
2211
|
+
return new p(this.x * -1, this.y * -1);
|
|
2198
2212
|
}
|
|
2199
2213
|
length() {
|
|
2200
2214
|
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
@@ -2208,13 +2222,13 @@ class m {
|
|
|
2208
2222
|
}
|
|
2209
2223
|
normalized() {
|
|
2210
2224
|
const t = this.length();
|
|
2211
|
-
return new
|
|
2225
|
+
return new p(this.x / t || 0, this.y / t || 0);
|
|
2212
2226
|
}
|
|
2213
2227
|
fix(t = 1e-13) {
|
|
2214
2228
|
this.x = Math.abs(this.x) < t ? 0 : this.x, this.y = Math.abs(this.y) < t ? 0 : this.y;
|
|
2215
2229
|
}
|
|
2216
2230
|
fixed(t = 1e-13) {
|
|
2217
|
-
return new
|
|
2231
|
+
return new p(
|
|
2218
2232
|
Math.abs(this.x) < t ? 0 : this.x,
|
|
2219
2233
|
Math.abs(this.y) < t ? 0 : this.y
|
|
2220
2234
|
);
|
|
@@ -2223,13 +2237,13 @@ class m {
|
|
|
2223
2237
|
return Math.atan2(this.y, this.x);
|
|
2224
2238
|
}
|
|
2225
2239
|
abs() {
|
|
2226
|
-
return new
|
|
2240
|
+
return new p(Math.abs(this.x), Math.abs(this.y));
|
|
2227
2241
|
}
|
|
2228
2242
|
floor() {
|
|
2229
|
-
return new
|
|
2243
|
+
return new p(Math.floor(this.x), Math.floor(this.y));
|
|
2230
2244
|
}
|
|
2231
2245
|
ceil() {
|
|
2232
|
-
return new
|
|
2246
|
+
return new p(Math.ceil(this.x), Math.ceil(this.y));
|
|
2233
2247
|
}
|
|
2234
2248
|
stringify() {
|
|
2235
2249
|
return `Vec2(${this.x}, ${this.y})`;
|
|
@@ -2250,174 +2264,165 @@ class m {
|
|
|
2250
2264
|
return this.x = Math.cos(t) * e, this.y = Math.sin(t) * e, this;
|
|
2251
2265
|
}
|
|
2252
2266
|
static FromArray(t) {
|
|
2253
|
-
return t.map((e) => new
|
|
2267
|
+
return t.map((e) => new p(e[0], e[1]));
|
|
2254
2268
|
}
|
|
2255
2269
|
static fromAngle(t) {
|
|
2256
|
-
return new
|
|
2270
|
+
return new p(Math.cos(t), Math.sin(t));
|
|
2257
2271
|
}
|
|
2258
2272
|
}
|
|
2259
|
-
const Vt = (
|
|
2260
|
-
const [e, r, i,
|
|
2273
|
+
const Vt = (n, t) => {
|
|
2274
|
+
const [e, r, i, s, a, o] = t, h = new Float32Array([
|
|
2261
2275
|
e,
|
|
2262
|
-
|
|
2276
|
+
i,
|
|
2263
2277
|
0,
|
|
2264
2278
|
0,
|
|
2265
2279
|
r,
|
|
2266
|
-
|
|
2280
|
+
s,
|
|
2267
2281
|
0,
|
|
2268
2282
|
0,
|
|
2269
|
-
i,
|
|
2270
|
-
c,
|
|
2271
|
-
1,
|
|
2272
2283
|
0,
|
|
2273
2284
|
0,
|
|
2285
|
+
1,
|
|
2274
2286
|
0,
|
|
2287
|
+
a,
|
|
2288
|
+
o,
|
|
2275
2289
|
0,
|
|
2276
2290
|
1
|
|
2277
2291
|
]);
|
|
2278
|
-
return
|
|
2279
|
-
},
|
|
2292
|
+
return Yt(h, n);
|
|
2293
|
+
}, Yt = (n, t) => {
|
|
2280
2294
|
const e = new Float32Array(16);
|
|
2281
2295
|
for (let r = 0; r < 4; r++)
|
|
2282
2296
|
for (let i = 0; i < 4; i++) {
|
|
2283
|
-
let
|
|
2297
|
+
let s = 0;
|
|
2284
2298
|
for (let a = 0; a < 4; a++)
|
|
2285
|
-
|
|
2286
|
-
e[i * 4 + r] =
|
|
2299
|
+
s += n[i * 4 + a] * t[a * 4 + r];
|
|
2300
|
+
e[i * 4 + r] = s;
|
|
2287
2301
|
}
|
|
2288
2302
|
return e;
|
|
2289
2303
|
};
|
|
2290
|
-
var
|
|
2291
|
-
const
|
|
2292
|
-
const a = [],
|
|
2293
|
-
for (let l = 0; l <
|
|
2294
|
-
const d = l /
|
|
2295
|
-
a.push(
|
|
2296
|
-
}
|
|
2297
|
-
return { vertices: a, uv:
|
|
2298
|
-
}, Xt = (
|
|
2304
|
+
var zt = /* @__PURE__ */ ((n) => (n[n.STRETCH = 0] = "STRETCH", n[n.REPEAT = 1] = "REPEAT", n))(zt || {});
|
|
2305
|
+
const tt = 10, lt = (n, t, e, r, i, s) => {
|
|
2306
|
+
const a = [], o = [], h = r ? Math.atan2(t.y, t.x) : Math.atan2(-t.y, -t.x), c = Math.PI, u = new p(t.y, -t.x);
|
|
2307
|
+
for (let l = 0; l < tt; l++) {
|
|
2308
|
+
const d = l / tt, f = (l + 1) / tt, m = h + d * c, g = h + f * c, v = new p(Math.cos(m) * e, Math.sin(m) * e), y = new p(Math.cos(g) * e, Math.sin(g) * e);
|
|
2309
|
+
a.push(n), o.push(new p(i, 0.5)), a.push(n.add(v)), o.push(new p(i + v.dot(u) * s, 0.5 - 0.5 * v.dot(t) / e)), a.push(n.add(y)), o.push(new p(i + y.dot(u) * s, 0.5 - 0.5 * y.dot(t) / e));
|
|
2310
|
+
}
|
|
2311
|
+
return { vertices: a, uv: o };
|
|
2312
|
+
}, Xt = (n, t = !1) => {
|
|
2299
2313
|
const e = [];
|
|
2300
|
-
if (
|
|
2301
|
-
const r = 4, i = 1e-3,
|
|
2314
|
+
if (n.length < 2 || t && n.length < 3) return { normals: e, length: 0 };
|
|
2315
|
+
const r = 4, i = 1e-3, s = n.length;
|
|
2302
2316
|
let a = 0;
|
|
2303
2317
|
if (t)
|
|
2304
|
-
for (let h = 0; h <
|
|
2305
|
-
const
|
|
2306
|
-
a +=
|
|
2318
|
+
for (let h = 0; h < s; h++) {
|
|
2319
|
+
const c = n[h], u = n[(h + 1) % s];
|
|
2320
|
+
a += c.distanceTo(u);
|
|
2307
2321
|
}
|
|
2308
2322
|
else
|
|
2309
|
-
for (let h = 0; h <
|
|
2310
|
-
a +=
|
|
2311
|
-
const
|
|
2312
|
-
const l =
|
|
2323
|
+
for (let h = 0; h < s - 1; h++)
|
|
2324
|
+
a += n[h].distanceTo(n[h + 1]);
|
|
2325
|
+
const o = (h, c, u) => {
|
|
2326
|
+
const l = c.subtract(h).normalize(), d = c.subtract(u).normalize(), f = d.dot(l);
|
|
2313
2327
|
if (f < -1 + i)
|
|
2314
2328
|
return { normal: l.perpendicular(), miters: 1 };
|
|
2315
2329
|
{
|
|
2316
|
-
let
|
|
2317
|
-
l.cross(d) < 0 && (
|
|
2330
|
+
let m = d.add(l).normalize();
|
|
2331
|
+
l.cross(d) < 0 && (m = m.multiply(-1));
|
|
2318
2332
|
let g = 1 / Math.sqrt((1 - f) / 2);
|
|
2319
|
-
return { normal:
|
|
2333
|
+
return { normal: m, miters: Math.min(g, r) };
|
|
2320
2334
|
}
|
|
2321
2335
|
};
|
|
2322
2336
|
if (t)
|
|
2323
|
-
for (let h = 0; h <
|
|
2324
|
-
const
|
|
2325
|
-
e.push(c
|
|
2337
|
+
for (let h = 0; h < s; h++) {
|
|
2338
|
+
const c = h === 0 ? n[s - 1] : n[h - 1], u = n[h], l = h === s - 1 ? n[0] : n[h + 1];
|
|
2339
|
+
e.push(o(c, u, l));
|
|
2326
2340
|
}
|
|
2327
2341
|
else
|
|
2328
|
-
for (let h = 0; h <
|
|
2342
|
+
for (let h = 0; h < s; h++)
|
|
2329
2343
|
if (h === 0) {
|
|
2330
|
-
const
|
|
2331
|
-
e.push({ normal:
|
|
2332
|
-
} else if (h ===
|
|
2333
|
-
const
|
|
2334
|
-
e.push({ normal:
|
|
2344
|
+
const c = n[1].subtract(n[0]).normalize();
|
|
2345
|
+
e.push({ normal: c.perpendicular(), miters: 1 });
|
|
2346
|
+
} else if (h === s - 1) {
|
|
2347
|
+
const c = n[h].subtract(n[h - 1]).normalize();
|
|
2348
|
+
e.push({ normal: c.perpendicular(), miters: 1 });
|
|
2335
2349
|
} else
|
|
2336
|
-
e.push(
|
|
2350
|
+
e.push(o(n[h - 1], n[h], n[h + 1]));
|
|
2337
2351
|
return { normals: e, length: a };
|
|
2338
|
-
}, jt = (
|
|
2339
|
-
const t =
|
|
2352
|
+
}, jt = (n) => {
|
|
2353
|
+
const t = n.points;
|
|
2340
2354
|
if (t.length < 2) return { vertices: [], uv: [] };
|
|
2341
|
-
const { normals: e, length: r } = Xt(t,
|
|
2342
|
-
let
|
|
2343
|
-
const u =
|
|
2355
|
+
const { normals: e, length: r } = Xt(t, n.closed), i = (n.width || 1) / 2, s = [], a = [], o = n.roundCap || !1, h = n.textureMode || 0;
|
|
2356
|
+
let c = 0;
|
|
2357
|
+
const u = n.texture?.rawWidth || 1, l = n.closed ? t.length : t.length - 1;
|
|
2344
2358
|
for (let d = 0; d < l; d++) {
|
|
2345
|
-
const f = t[d],
|
|
2346
|
-
let w = 0,
|
|
2347
|
-
h === 0 ? (w =
|
|
2348
|
-
const
|
|
2349
|
-
|
|
2350
|
-
}
|
|
2351
|
-
if (
|
|
2352
|
-
const d = t[0], f = e[0].normal,
|
|
2353
|
-
|
|
2354
|
-
const v = t[t.length - 1],
|
|
2355
|
-
|
|
2356
|
-
}
|
|
2357
|
-
return { vertices:
|
|
2358
|
-
},
|
|
2359
|
+
const f = t[d], m = e[d].normal, g = e[d].miters, v = (d + 1) % t.length, y = t[v], R = e[v].normal, A = e[v].miters, C = f.add(m.multiply(g * i)), S = f.subtract(m.multiply(g * i)), L = y.add(R.multiply(A * i)), X = y.subtract(R.multiply(A * i)), I = f.distanceTo(y);
|
|
2360
|
+
let w = 0, _ = 0;
|
|
2361
|
+
h === 0 ? (w = c / r, _ = (c + I) / r) : (w = c / u, _ = w + I / u);
|
|
2362
|
+
const D = new p(w, 0), k = new p(w, 1), G = new p(_, 0), O = new p(_, 1);
|
|
2363
|
+
s.push(C), a.push(D), s.push(S), a.push(k), s.push(L), a.push(G), s.push(L), a.push(G), s.push(X), a.push(O), s.push(S), a.push(k), c += I;
|
|
2364
|
+
}
|
|
2365
|
+
if (o && !n.closed) {
|
|
2366
|
+
const d = t[0], f = e[0].normal, m = h === 0 ? r > 0 ? 1 / r : 0 : 1 / u, g = lt(d, f, i, !0, 0, m);
|
|
2367
|
+
s.push(...g.vertices), a.push(...g.uv);
|
|
2368
|
+
const v = t[t.length - 1], y = e[t.length - 1].normal, R = h === 0 ? 1 : c / u, A = h === 0 ? r > 0 ? 1 / r : 0 : 1 / u, C = lt(v, y, i, !1, R, A);
|
|
2369
|
+
s.push(...C.vertices), a.push(...C.uv);
|
|
2370
|
+
}
|
|
2371
|
+
return { vertices: s, uv: a };
|
|
2372
|
+
}, Q = (n, t, e, r) => {
|
|
2359
2373
|
if (t.customMatrix !== void 0)
|
|
2360
2374
|
return t.customMatrix;
|
|
2361
2375
|
if (t.modifyStack) {
|
|
2362
|
-
|
|
2376
|
+
n.matrixStack.applyTransform(
|
|
2363
2377
|
t,
|
|
2364
2378
|
e,
|
|
2365
2379
|
r
|
|
2366
2380
|
);
|
|
2367
2381
|
return;
|
|
2368
2382
|
} else {
|
|
2369
|
-
const i =
|
|
2370
|
-
return
|
|
2383
|
+
const i = n.matrix.temporary;
|
|
2384
|
+
return n.matrixStack.applyTransform(
|
|
2371
2385
|
t,
|
|
2372
2386
|
e,
|
|
2373
2387
|
r,
|
|
2374
2388
|
i
|
|
2375
2389
|
), i;
|
|
2376
2390
|
}
|
|
2377
|
-
},
|
|
2378
|
-
const r = t.texture;
|
|
2379
|
-
if (!r?.base ||
|
|
2391
|
+
}, $t = (n, t) => t ? n ? t.premultipliedUint32 : t.uint32 : 4294967295, Kt = 2, qt = (n, t) => {
|
|
2392
|
+
const e = Q(n, t, t.texture.rawWidth, t.texture.rawHeight), r = t.texture;
|
|
2393
|
+
if (!r?.base || n.inCreateMask)
|
|
2380
2394
|
return;
|
|
2381
|
-
const i = r.isAtlas ?
|
|
2382
|
-
|
|
2383
|
-
let
|
|
2384
|
-
const
|
|
2395
|
+
const i = r.isAtlas ? n.atlasSpriteRegion : n.spriteRegion;
|
|
2396
|
+
n.enterRegion(i, t.shader);
|
|
2397
|
+
let s = r.uvX, a = r.uvY, o = r.uvW, h = r.uvH;
|
|
2398
|
+
const c = !!t.flipX, u = !!t.flipY != !!r.flipY;
|
|
2385
2399
|
let l = t.padding ?? i.currentShader.padding;
|
|
2386
|
-
r.isAtlas && (l +=
|
|
2387
|
-
const d =
|
|
2400
|
+
r.isAtlas && (l += Kt);
|
|
2401
|
+
const d = s <= o ? l : -l, f = a <= h ? l : -l;
|
|
2388
2402
|
i.drawSprite(
|
|
2389
2403
|
r,
|
|
2390
|
-
e ?? t.customMatrix ??
|
|
2391
|
-
|
|
2404
|
+
e ?? t.customMatrix ?? n.matrixStack.curWorldM,
|
|
2405
|
+
s,
|
|
2392
2406
|
a,
|
|
2393
|
-
|
|
2407
|
+
o,
|
|
2394
2408
|
h,
|
|
2395
|
-
|
|
2409
|
+
n.getColorUint32(t.color),
|
|
2396
2410
|
d,
|
|
2397
2411
|
f,
|
|
2398
|
-
|
|
2412
|
+
c,
|
|
2399
2413
|
u,
|
|
2400
2414
|
r.isRotated
|
|
2401
2415
|
);
|
|
2402
|
-
},
|
|
2403
|
-
const e =
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
const e = s.particleRegion;
|
|
2407
|
-
s.enterRegion(e, t.shader);
|
|
2408
|
-
const r = t.texture, i = t.count ?? t.x.length, n = t.color, a = n.length, c = new Array(a);
|
|
2409
|
-
if (s.premultipliedAlpha)
|
|
2410
|
-
for (let h = 0; h < a; h++)
|
|
2411
|
-
c[h] = n[h].premultipliedUint32;
|
|
2412
|
-
else
|
|
2413
|
-
for (let h = 0; h < a; h++)
|
|
2414
|
-
c[h] = n[h].uint32;
|
|
2416
|
+
}, Qt = (n, t) => {
|
|
2417
|
+
const e = n.particleRegion;
|
|
2418
|
+
n.enterRegion(e, t.shader);
|
|
2419
|
+
const r = t.texture, i = t.count ?? t.x.length, s = t.color;
|
|
2415
2420
|
e.drawParticles(
|
|
2416
2421
|
r,
|
|
2417
2422
|
t.x,
|
|
2418
2423
|
t.y,
|
|
2419
2424
|
t.rotation,
|
|
2420
|
-
|
|
2425
|
+
s,
|
|
2421
2426
|
i,
|
|
2422
2427
|
t.scaleX,
|
|
2423
2428
|
t.scaleY,
|
|
@@ -2427,71 +2432,74 @@ const Z = 10, ut = (s, t, e, r, i, n) => {
|
|
|
2427
2432
|
r.uvH,
|
|
2428
2433
|
t.flipX,
|
|
2429
2434
|
t.flipY,
|
|
2430
|
-
|
|
2435
|
+
r.isRotated,
|
|
2431
2436
|
t.originX,
|
|
2432
|
-
t.originY
|
|
2437
|
+
t.originY,
|
|
2438
|
+
n.premultipliedAlpha,
|
|
2439
|
+
t.reverseOrder,
|
|
2440
|
+
t.customMatrix
|
|
2433
2441
|
);
|
|
2434
|
-
},
|
|
2442
|
+
}, Rt = (n, t) => {
|
|
2435
2443
|
if (t.points.length === 0) return;
|
|
2436
|
-
const e =
|
|
2437
|
-
|
|
2438
|
-
t.drawMode ??
|
|
2444
|
+
const e = Q(n, t, 0, 0);
|
|
2445
|
+
n.startGraphic(
|
|
2446
|
+
t.drawMode ?? n.gl.TRIANGLES,
|
|
2439
2447
|
t.texture,
|
|
2440
2448
|
t.shader,
|
|
2441
2449
|
e ?? t.customMatrix
|
|
2442
2450
|
);
|
|
2443
2451
|
for (let r = 0; r < t.points.length; r++) {
|
|
2444
|
-
const i = t.points[r],
|
|
2445
|
-
|
|
2452
|
+
const i = t.points[r], s = t.uv?.[r], a = Array.isArray(t.color) ? t.color[r] : t.color;
|
|
2453
|
+
n.addGraphicVertex(
|
|
2446
2454
|
i.x,
|
|
2447
2455
|
i.y,
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2456
|
+
s?.x ?? 0,
|
|
2457
|
+
s?.y ?? 0,
|
|
2458
|
+
n.getColorUint32(a)
|
|
2451
2459
|
);
|
|
2452
2460
|
}
|
|
2453
|
-
|
|
2454
|
-
}, Zt = (
|
|
2455
|
-
if (
|
|
2461
|
+
n.endGraphic();
|
|
2462
|
+
}, Zt = (n, t) => {
|
|
2463
|
+
if (n.inCreateMask)
|
|
2456
2464
|
return;
|
|
2457
2465
|
const { vertices: e, uv: r } = jt(t);
|
|
2458
|
-
|
|
2466
|
+
Rt(n, {
|
|
2459
2467
|
...t,
|
|
2460
2468
|
points: e,
|
|
2461
2469
|
uv: r,
|
|
2462
|
-
drawMode:
|
|
2470
|
+
drawMode: n.gl.TRIANGLES
|
|
2463
2471
|
});
|
|
2464
|
-
},
|
|
2465
|
-
const e =
|
|
2466
|
-
|
|
2472
|
+
}, Jt = (n, t) => {
|
|
2473
|
+
const e = Q(
|
|
2474
|
+
n,
|
|
2467
2475
|
t,
|
|
2468
2476
|
t.texture.rawWidth,
|
|
2469
2477
|
t.texture.rawHeight
|
|
2470
2478
|
);
|
|
2471
|
-
|
|
2472
|
-
|
|
2479
|
+
n.startMaskGraphic(
|
|
2480
|
+
n.gl.TRIANGLE_FAN,
|
|
2473
2481
|
t.texture,
|
|
2474
2482
|
e ?? t.customMatrix
|
|
2475
|
-
),
|
|
2476
|
-
},
|
|
2477
|
-
const e =
|
|
2478
|
-
|
|
2479
|
-
|
|
2483
|
+
), n.addRectVertex(t.texture.rawWidth, t.texture.rawHeight), n.endGraphic();
|
|
2484
|
+
}, te = (n, t) => {
|
|
2485
|
+
const e = Q(n, t, t.width, t.height);
|
|
2486
|
+
n.startGraphic(
|
|
2487
|
+
n.gl.TRIANGLE_FAN,
|
|
2480
2488
|
t.texture,
|
|
2481
2489
|
t.shader,
|
|
2482
2490
|
e ?? t.customMatrix
|
|
2483
|
-
),
|
|
2484
|
-
},
|
|
2485
|
-
const e = t.segments ?? 32, r =
|
|
2486
|
-
|
|
2487
|
-
|
|
2491
|
+
), n.addRectVertex(t.width, t.height, t.color), n.endGraphic();
|
|
2492
|
+
}, ee = (n, t) => {
|
|
2493
|
+
const e = t.segments ?? 32, r = Q(n, t, 0, 0);
|
|
2494
|
+
n.startGraphic(
|
|
2495
|
+
n.gl.TRIANGLE_FAN,
|
|
2488
2496
|
void 0,
|
|
2489
2497
|
t.shader,
|
|
2490
2498
|
r ?? t.customMatrix
|
|
2491
2499
|
);
|
|
2492
|
-
const i =
|
|
2493
|
-
|
|
2494
|
-
},
|
|
2500
|
+
const i = n.getColorUint32(t.color);
|
|
2501
|
+
n.addGraphicVertex(0, 0, 0.5, 0.5, i), n.addCircleVertex(t.radius, t.color, e), n.addGraphicVertex(t.radius, 0, 1, 0.5, i), n.endGraphic();
|
|
2502
|
+
}, dt = `#version 300 es\r
|
|
2495
2503
|
precision mediump float;\r
|
|
2496
2504
|
\r
|
|
2497
2505
|
uniform sampler2D uTextures[%TEXTURE_NUM%];\r
|
|
@@ -2541,21 +2549,21 @@ void main(void) {\r
|
|
|
2541
2549
|
// CUSTOM_CODE_CALL\r
|
|
2542
2550
|
}\r
|
|
2543
2551
|
`;
|
|
2544
|
-
class
|
|
2552
|
+
class re extends at {
|
|
2545
2553
|
KEY = "AtlasSprite";
|
|
2546
2554
|
constructor(t) {
|
|
2547
2555
|
super(t);
|
|
2548
2556
|
}
|
|
2549
2557
|
createCustomShader(t) {
|
|
2550
|
-
const e =
|
|
2558
|
+
const e = H(dt, this.rapid.maxTextureUnits - t.usedTextureUnitNum), r = H(Z, this.rapid.maxTextureUnits - t.usedTextureUnitNum);
|
|
2551
2559
|
return t.getGLShader(this, this.KEY, r, e);
|
|
2552
2560
|
}
|
|
2553
2561
|
createDefaultShader() {
|
|
2554
|
-
const t = this.rapid, e =
|
|
2562
|
+
const t = this.rapid, e = H(dt, t.maxTextureUnits), r = H(Z, t.maxTextureUnits);
|
|
2555
2563
|
return this.vs = r, this.fs = e, this.defaultShader = this.createShader(r, e), this.defaultShader;
|
|
2556
2564
|
}
|
|
2557
2565
|
}
|
|
2558
|
-
const
|
|
2566
|
+
const ft = `#version 300 es\r
|
|
2559
2567
|
precision highp float;\r
|
|
2560
2568
|
\r
|
|
2561
2569
|
// per-vertex\r
|
|
@@ -2596,7 +2604,7 @@ void main(void) {\r
|
|
|
2596
2604
|
\r
|
|
2597
2605
|
gl_Position = u_projection * vec4(v, 0.0, 1.0);\r
|
|
2598
2606
|
}\r
|
|
2599
|
-
`,
|
|
2607
|
+
`, mt = `#version 300 es\r
|
|
2600
2608
|
precision mediump float;\r
|
|
2601
2609
|
\r
|
|
2602
2610
|
uniform sampler2D uTexture;\r
|
|
@@ -2612,18 +2620,19 @@ void main(void) {\r
|
|
|
2612
2620
|
\r
|
|
2613
2621
|
// CUSTOM_CODE_CALL\r
|
|
2614
2622
|
}\r
|
|
2615
|
-
`,
|
|
2616
|
-
class
|
|
2623
|
+
`, Y = 48, xt = Y / 4;
|
|
2624
|
+
class ie extends at {
|
|
2617
2625
|
KEY = "ParticleSprite";
|
|
2618
2626
|
texture;
|
|
2627
|
+
customMatrix;
|
|
2619
2628
|
constructor(t) {
|
|
2620
2629
|
super(t);
|
|
2621
2630
|
}
|
|
2622
2631
|
createCustomShader(t) {
|
|
2623
|
-
return t.getGLShader(this, this.KEY,
|
|
2632
|
+
return t.getGLShader(this, this.KEY, ft, mt);
|
|
2624
2633
|
}
|
|
2625
2634
|
createDefaultShader() {
|
|
2626
|
-
const t =
|
|
2635
|
+
const t = mt, e = ft;
|
|
2627
2636
|
return this.vs = e, this.fs = t, this.defaultShader = this.createShader(e, t), this.defaultShader;
|
|
2628
2637
|
}
|
|
2629
2638
|
enter(t) {
|
|
@@ -2632,32 +2641,46 @@ class re extends it {
|
|
|
2632
2641
|
createShader(t, e) {
|
|
2633
2642
|
const r = super.createShader(t, e);
|
|
2634
2643
|
return r.use(), r.bindVAO(), this.instanceBuffer.bindBuffer(), r.setAttributes([
|
|
2635
|
-
{ name: "aPosition", size: 2, stride:
|
|
2636
|
-
{ name: "aScale", size: 2, stride:
|
|
2637
|
-
{ name: "aRotation", size: 1, stride:
|
|
2638
|
-
{ name: "aUVRect", size: 4, stride:
|
|
2639
|
-
{ name: "aColor", size: 4, type:
|
|
2640
|
-
{ name: "aOrigin", size: 2, stride:
|
|
2644
|
+
{ name: "aPosition", size: 2, stride: Y, offset: 0, divisor: 1 },
|
|
2645
|
+
{ name: "aScale", size: 2, stride: Y, offset: 8, divisor: 1 },
|
|
2646
|
+
{ name: "aRotation", size: 1, stride: Y, offset: 16, divisor: 1 },
|
|
2647
|
+
{ name: "aUVRect", size: 4, stride: Y, offset: 20, divisor: 1 },
|
|
2648
|
+
{ name: "aColor", size: 4, type: st, normalized: !0, stride: Y, offset: 36, divisor: 1 },
|
|
2649
|
+
{ name: "aOrigin", size: 2, stride: Y, offset: 40, divisor: 1 }
|
|
2641
2650
|
]), this.quadBuffer.bindBuffer(), r.setAttributes([
|
|
2642
2651
|
{ name: "aVertex", size: 2, stride: 8, offset: 0, divisor: 0 }
|
|
2643
2652
|
]), r.unbindVAO(), this.currentShader && this.currentShader.use(), r;
|
|
2644
2653
|
}
|
|
2645
|
-
drawParticles(t, e, r, i,
|
|
2654
|
+
drawParticles(t, e, r, i = 0, s = 4294967295, a, o = 1, h = 1, c = 0, u = 0, l = 1, d = 1, f = !1, m = !1, g = !1, v = 0.5, y = 0.5, R, A = !1, C) {
|
|
2646
2655
|
if (!t.glTexture || a <= 0) return;
|
|
2647
|
-
let
|
|
2648
|
-
const
|
|
2649
|
-
|
|
2656
|
+
let S = 0;
|
|
2657
|
+
const L = typeof o == "number", X = typeof h == "number", I = typeof i == "number", w = typeof s == "number", _ = !w && typeof s[0] == "number";
|
|
2658
|
+
let D = t.rawWidth * (f ? -1 : 1);
|
|
2659
|
+
L && (D *= o);
|
|
2660
|
+
let k = t.rawHeight * (m ? -1 : 1);
|
|
2661
|
+
X && (k *= h);
|
|
2662
|
+
let G = g ? Math.PI / 2 : 0;
|
|
2663
|
+
for (I && (G += i); S < a; ) {
|
|
2650
2664
|
this.texture && t !== this.texture && this.flush(), this.texture || (this.texture = t, this.useTexture(t.glTexture, 0, 0));
|
|
2651
|
-
const
|
|
2652
|
-
let
|
|
2653
|
-
|
|
2654
|
-
const
|
|
2655
|
-
for (let
|
|
2656
|
-
const
|
|
2657
|
-
|
|
2665
|
+
const O = a - S, F = this.instanceBuffer;
|
|
2666
|
+
let b = F.usedElemNum;
|
|
2667
|
+
F.resize(O * xt);
|
|
2668
|
+
const N = F.float32, T = F.uint32;
|
|
2669
|
+
for (let M = 0; M < O; M++) {
|
|
2670
|
+
const V = A ? a - 1 - S - M : S + M;
|
|
2671
|
+
if (N[b] = e[V], N[b + 1] = r[V], N[b + 2] = L ? D : D * o[V], N[b + 3] = X ? k : k * h[V], N[b + 4] = I ? G : i[V] + G, N[b + 5] = c, N[b + 6] = u, N[b + 7] = l, N[b + 8] = d, w)
|
|
2672
|
+
T[b + 9] = 4294967295;
|
|
2673
|
+
else if (_)
|
|
2674
|
+
T[b + 9] = s[V];
|
|
2675
|
+
else {
|
|
2676
|
+
const ht = s[V];
|
|
2677
|
+
T[b + 9] = R ? ht.premultipliedUint32 : ht.uint32;
|
|
2678
|
+
}
|
|
2679
|
+
N[b + 10] = v, N[b + 11] = y, b += xt;
|
|
2658
2680
|
}
|
|
2659
|
-
|
|
2681
|
+
F.usedElemNum = b, F.makeDirty(), this.instanceCount += O, S += O;
|
|
2660
2682
|
}
|
|
2683
|
+
this.customMatrix = C, this.flush();
|
|
2661
2684
|
}
|
|
2662
2685
|
render() {
|
|
2663
2686
|
if (this.instanceCount === 0) return;
|
|
@@ -2666,11 +2689,11 @@ class re extends it {
|
|
|
2666
2689
|
this.texture && (t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.texture.glTexture));
|
|
2667
2690
|
const e = this.currentShader;
|
|
2668
2691
|
this.instanceBuffer.bindBuffer(), this.instanceBuffer.bufferData(), e.bindVAO();
|
|
2669
|
-
const r = this.rapid.matrixStack,
|
|
2670
|
-
this.currentShader.setUniform("u_projection", a),
|
|
2692
|
+
const r = this.rapid.matrixStack, s = this.rapid.matrix.getMatrix(this.customMatrix ?? r.curWorldM), a = Vt(this.rapid.projection, s);
|
|
2693
|
+
this.currentShader.setUniform("u_projection", a), yt(t, t.TRIANGLE_STRIP, 0, 4, this.instanceCount), this.rapid.drawcallCount++, this.texture = void 0, this.customMatrix = void 0;
|
|
2671
2694
|
}
|
|
2672
2695
|
}
|
|
2673
|
-
var
|
|
2696
|
+
var se = /* @__PURE__ */ ((n) => (n[n.EQUAL = 0] = "EQUAL", n[n.NOT_EQUAL = 1] = "NOT_EQUAL", n))(se || {}), ne = /* @__PURE__ */ ((n) => (n[n.NORMAL = 0] = "NORMAL", n[n.ADD = 1] = "ADD", n[n.MULTIPLY = 2] = "MULTIPLY", n[n.SCREEN = 3] = "SCREEN", n[n.ERASE = 4] = "ERASE", n))(ne || {}), nt = /* @__PURE__ */ ((n) => (n[n.LINEAR = 0] = "LINEAR", n[n.NEAREST = 1] = "NEAREST", n))(nt || {}), ae = /* @__PURE__ */ ((n) => (n[n.CanvasItem = 0] = "CanvasItem", n[n.Viewport = 1] = "Viewport", n))(ae || {});
|
|
2674
2697
|
class ce {
|
|
2675
2698
|
/** The active WebGL context. */
|
|
2676
2699
|
gl;
|
|
@@ -2683,7 +2706,7 @@ class ce {
|
|
|
2683
2706
|
/** The current device pixel ratio. */
|
|
2684
2707
|
dpr;
|
|
2685
2708
|
/** Background clear color [r, g, b, a], values range from 0 to 255. */
|
|
2686
|
-
backgroundColor =
|
|
2709
|
+
backgroundColor = x.Black;
|
|
2687
2710
|
/** Logical width in CSS pixels, used for coordinate system and projection matrix. */
|
|
2688
2711
|
logicWidth = 0;
|
|
2689
2712
|
/** Logical height in CSS pixels, used for coordinate system and projection matrix. */
|
|
@@ -2697,7 +2720,7 @@ class ce {
|
|
|
2697
2720
|
/** Maximum number of texture units supported by the device. */
|
|
2698
2721
|
maxTextureUnits = 0;
|
|
2699
2722
|
/** Matrix stack for hierarchical transformations. */
|
|
2700
|
-
matrixStack = new
|
|
2723
|
+
matrixStack = new At(this);
|
|
2701
2724
|
/** Direct access to the underlying matrix store. */
|
|
2702
2725
|
matrix;
|
|
2703
2726
|
/** Region dedicated to fast sprite rendering. */
|
|
@@ -2722,7 +2745,7 @@ class ce {
|
|
|
2722
2745
|
scaleMode;
|
|
2723
2746
|
/** Internal ping-pong RenderTextures for multi-filter chains. */
|
|
2724
2747
|
_filterRT = [null, null];
|
|
2725
|
-
_filterInput = new
|
|
2748
|
+
_filterInput = new B();
|
|
2726
2749
|
get height() {
|
|
2727
2750
|
return this.logicHeight;
|
|
2728
2751
|
}
|
|
@@ -2735,10 +2758,10 @@ class ce {
|
|
|
2735
2758
|
*/
|
|
2736
2759
|
constructor(t) {
|
|
2737
2760
|
this.canvas = t.canvas, this.dpr = window.devicePixelRatio || 1, this.antialias = t.antialias ?? !1, this.textureFilter = t.textureFilter ?? 1, this.premultipliedAlpha = t.premultipliedAlpha ?? !0, this.roundPixels = t.roundPixels ?? !1, this.scaleMode = t.scaleMode ?? 0;
|
|
2738
|
-
const e =
|
|
2739
|
-
this.gl = e, this.maxTextureUnits = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), this.matrix = this.matrixStack.matrix, this.spriteRegion = new
|
|
2761
|
+
const e = _t(this.canvas, this.antialias, this.premultipliedAlpha);
|
|
2762
|
+
this.gl = e, this.maxTextureUnits = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), this.matrix = this.matrixStack.matrix, this.spriteRegion = new at(this), this.graphicRegion = new Ht(this), this.atlasSpriteRegion = new re(this), this.particleRegion = new ie(this);
|
|
2740
2763
|
const r = this.canvas.clientWidth || this.canvas.width, i = this.canvas.clientHeight || this.canvas.height;
|
|
2741
|
-
this.physicsWidth = t.physicsWidth || Math.round(r * this.dpr), this.physicsHeight = t.physicsHeight || Math.round(i * this.dpr), this.logicWidth = t.logicWidth || t.width || this.physicsWidth / this.dpr, this.logicHeight = t.logicHeight || t.height || this.physicsHeight / this.dpr, this.resize(this.logicWidth, this.logicHeight, this.physicsWidth, this.physicsHeight), this.texture = new
|
|
2764
|
+
this.physicsWidth = t.physicsWidth || Math.round(r * this.dpr), this.physicsHeight = t.physicsHeight || Math.round(i * this.dpr), this.logicWidth = t.logicWidth || t.width || this.physicsWidth / this.dpr, this.logicHeight = t.logicHeight || t.height || this.physicsHeight / this.dpr, this.resize(this.logicWidth, this.logicHeight, this.physicsWidth, this.physicsHeight), this.texture = new St(this), t.backgroundColor && (this.backgroundColor = t.backgroundColor), e.enable(e.BLEND), this.premultipliedAlpha ? e.blendFunc(e.ONE, e.ONE_MINUS_SRC_ALPHA) : e.blendFunc(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA), e.enable(e.STENCIL_TEST), e.stencilFunc(e.ALWAYS, 1, 255), e.stencilOp(e.KEEP, e.KEEP, e.KEEP);
|
|
2742
2765
|
}
|
|
2743
2766
|
setTextureFilter(t) {
|
|
2744
2767
|
this.textureFilter = t;
|
|
@@ -2747,7 +2770,7 @@ class ce {
|
|
|
2747
2770
|
this.antialias = t;
|
|
2748
2771
|
}
|
|
2749
2772
|
getColorUint32(t) {
|
|
2750
|
-
return t
|
|
2773
|
+
return $t(this.premultipliedAlpha, t);
|
|
2751
2774
|
}
|
|
2752
2775
|
/**
|
|
2753
2776
|
* Enters a specific rendering region, flushing the previous one if necessary.
|
|
@@ -2758,22 +2781,22 @@ class ce {
|
|
|
2758
2781
|
this.currentRegion === t && this.currentRegion.isSameShader(e) || (this.flush(), this.currentRegion = t, t.enter(e));
|
|
2759
2782
|
}
|
|
2760
2783
|
drawParticles(t) {
|
|
2761
|
-
|
|
2784
|
+
Qt(this, t);
|
|
2762
2785
|
}
|
|
2763
2786
|
drawSprite(t) {
|
|
2764
|
-
|
|
2787
|
+
qt(this, t);
|
|
2765
2788
|
}
|
|
2766
2789
|
drawLine(t) {
|
|
2767
2790
|
Zt(this, t);
|
|
2768
2791
|
}
|
|
2769
2792
|
drawGraphic(t) {
|
|
2770
|
-
|
|
2793
|
+
Rt(this, t);
|
|
2771
2794
|
}
|
|
2772
2795
|
drawRect(t) {
|
|
2773
|
-
|
|
2796
|
+
te(this, t);
|
|
2774
2797
|
}
|
|
2775
2798
|
drawCircle(t) {
|
|
2776
|
-
|
|
2799
|
+
ee(this, t);
|
|
2777
2800
|
}
|
|
2778
2801
|
/**
|
|
2779
2802
|
* Starts rendering arbitrary graphics geometries.
|
|
@@ -2797,7 +2820,7 @@ class ce {
|
|
|
2797
2820
|
* @param texture The texture to be used as a mask.
|
|
2798
2821
|
*/
|
|
2799
2822
|
drawMaskImage(t) {
|
|
2800
|
-
|
|
2823
|
+
Jt(this, t);
|
|
2801
2824
|
}
|
|
2802
2825
|
/**
|
|
2803
2826
|
* Pushes vertices for a rectangle geometry. Should be enclosed by startGraphic and endGraphic.
|
|
@@ -2816,10 +2839,10 @@ class ce {
|
|
|
2816
2839
|
* @param segments The number of segments (polygons) used to approximate the circle.
|
|
2817
2840
|
*/
|
|
2818
2841
|
addCircleVertex(t, e, r = 32) {
|
|
2819
|
-
const i = Math.PI * 2 / r,
|
|
2842
|
+
const i = Math.PI * 2 / r, s = this.getColorUint32(e);
|
|
2820
2843
|
for (let a = 0; a < r; a++) {
|
|
2821
|
-
const
|
|
2822
|
-
this.addGraphicVertex(h,
|
|
2844
|
+
const o = i * a, h = Math.cos(o) * t, c = Math.sin(o) * t, u = 0.5 + Math.cos(o) * 0.5, l = 0.5 + Math.sin(o) * 0.5;
|
|
2845
|
+
this.addGraphicVertex(h, c, u, l, s);
|
|
2823
2846
|
}
|
|
2824
2847
|
}
|
|
2825
2848
|
/**
|
|
@@ -2830,8 +2853,8 @@ class ce {
|
|
|
2830
2853
|
* @param v The V texture coordinate (0 to 1).
|
|
2831
2854
|
* @param color The vertex color as a 32-bit unsigned integer.
|
|
2832
2855
|
*/
|
|
2833
|
-
addGraphicVertex(t, e, r = 0, i = 0,
|
|
2834
|
-
this.graphicRegion.addVertex(t, e, r, i,
|
|
2856
|
+
addGraphicVertex(t, e, r = 0, i = 0, s) {
|
|
2857
|
+
this.graphicRegion.addVertex(t, e, r, i, typeof s == "number" ? s : this.getColorUint32(s));
|
|
2835
2858
|
}
|
|
2836
2859
|
/**
|
|
2837
2860
|
* Ends the current graphics geometry definition, readying it for rendering.
|
|
@@ -2848,8 +2871,8 @@ class ce {
|
|
|
2848
2871
|
*/
|
|
2849
2872
|
resize(t, e, r, i) {
|
|
2850
2873
|
this.flush();
|
|
2851
|
-
const
|
|
2852
|
-
switch (r !== void 0 && (this.canvas.style.width =
|
|
2874
|
+
const s = r ?? this.canvas.clientWidth ?? this.canvas.width, a = i ?? this.canvas.clientHeight ?? this.canvas.height;
|
|
2875
|
+
switch (r !== void 0 && (this.canvas.style.width = s + "px"), i !== void 0 && (this.canvas.style.height = a + "px"), this.physicsWidth = s * this.dpr, this.physicsHeight = a * this.dpr, this.logicWidth = t, this.logicHeight = e, this.scaleMode) {
|
|
2853
2876
|
case 1:
|
|
2854
2877
|
this.canvas.width = t, this.canvas.height = e, this.canvas.style.imageRendering = "pixelated", this.gl.viewport(0, 0, t, e);
|
|
2855
2878
|
break;
|
|
@@ -2879,8 +2902,8 @@ class ce {
|
|
|
2879
2902
|
* Populates an orthographic projection matrix in place.
|
|
2880
2903
|
* Avoids continuous Float32Array allocations for performance reasons.
|
|
2881
2904
|
*/
|
|
2882
|
-
updateOrthMatrix(t, e, r, i,
|
|
2883
|
-
t[0] = 2 / (r - e), t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = 2 / (
|
|
2905
|
+
updateOrthMatrix(t, e, r, i, s) {
|
|
2906
|
+
t[0] = 2 / (r - e), t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = 2 / (s - i), t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = -1, t[11] = 0, t[12] = -(r + e) / (r - e), t[13] = -(s + i) / (s - i), t[14] = 0, t[15] = 1;
|
|
2884
2907
|
}
|
|
2885
2908
|
/**
|
|
2886
2909
|
* Flushes currently buffered rendering operations across all active regions.
|
|
@@ -2905,23 +2928,23 @@ class ce {
|
|
|
2905
2928
|
applyFilters(t, e) {
|
|
2906
2929
|
if (e.length === 0)
|
|
2907
2930
|
throw new Error("applyFilters: shaders array must not be empty.");
|
|
2908
|
-
const r = Math.max(...e.map((
|
|
2909
|
-
for (let
|
|
2910
|
-
this._filterRT[
|
|
2911
|
-
let
|
|
2931
|
+
const r = Math.max(...e.map((c) => c.padding)), i = r, s = t.rawWidth + r * 2, a = t.rawHeight + r * 2;
|
|
2932
|
+
for (let c = 0; c < 2; c++)
|
|
2933
|
+
this._filterRT[c] ? this._filterRT[c].resize(s, a) : this._filterRT[c] = this.texture.createRenderTexture({ width: s, height: a });
|
|
2934
|
+
let o = t.clone(this._filterInput), h = 0;
|
|
2912
2935
|
this.matrixStack.save(), this.matrixStack.identity();
|
|
2913
|
-
for (let
|
|
2936
|
+
for (let c = 0; c < e.length; c++) {
|
|
2914
2937
|
const u = this._filterRT[h % 2];
|
|
2915
2938
|
u.offsetX = 0, u.offsetY = 0, this.enterRenderTexture(u), this.clearRenderTexture(), this.drawSprite({
|
|
2916
|
-
texture:
|
|
2917
|
-
shader: e[
|
|
2918
|
-
offsetX:
|
|
2939
|
+
texture: o,
|
|
2940
|
+
shader: e[c],
|
|
2941
|
+
offsetX: c == 0 ? i : 0,
|
|
2919
2942
|
// padding back
|
|
2920
|
-
offsetY:
|
|
2943
|
+
offsetY: c == 0 ? i : 0,
|
|
2921
2944
|
padding: r
|
|
2922
|
-
}), this.leaveRenderTexture(),
|
|
2945
|
+
}), this.leaveRenderTexture(), o = u, h++;
|
|
2923
2946
|
}
|
|
2924
|
-
return this.matrixStack.restore(),
|
|
2947
|
+
return this.matrixStack.restore(), o.offsetX = -i, o.offsetY = -i, o;
|
|
2925
2948
|
}
|
|
2926
2949
|
enterRenderTexture(t) {
|
|
2927
2950
|
this.flush(), t.activate(), this.gl.viewport(0, 0, t.rawWidth, t.rawHeight), this.updateProjection(0, t.rawWidth, t.rawHeight, 0);
|
|
@@ -2933,7 +2956,7 @@ class ce {
|
|
|
2933
2956
|
* @param rt The render texture to clear.
|
|
2934
2957
|
* @param color Clear color. Defaults to transparent black (0, 0, 0, 0).
|
|
2935
2958
|
*/
|
|
2936
|
-
clearRenderTexture(t = new
|
|
2959
|
+
clearRenderTexture(t = new x(0, 0, 0, 0)) {
|
|
2937
2960
|
this.flush();
|
|
2938
2961
|
const e = this.gl;
|
|
2939
2962
|
t.setClearColor(e), e.clear(e.COLOR_BUFFER_BIT);
|
|
@@ -2955,7 +2978,7 @@ class ce {
|
|
|
2955
2978
|
* rapid.drawSprite({ texture: mySprite });
|
|
2956
2979
|
* });
|
|
2957
2980
|
*/
|
|
2958
|
-
drawToRenderTexture(t, e, r = new
|
|
2981
|
+
drawToRenderTexture(t, e, r = new x(0, 0, 0, 0)) {
|
|
2959
2982
|
this.enterRenderTexture(t);
|
|
2960
2983
|
try {
|
|
2961
2984
|
r !== null && this.clearRenderTexture(r), e();
|
|
@@ -3033,10 +3056,10 @@ class ce {
|
|
|
3033
3056
|
* rapid.drawSprite({ texture: myTexture });
|
|
3034
3057
|
* });
|
|
3035
3058
|
*/
|
|
3036
|
-
withScissor(t, e, r, i,
|
|
3059
|
+
withScissor(t, e, r, i, s) {
|
|
3037
3060
|
this.startScissor(t, e, r, i);
|
|
3038
3061
|
try {
|
|
3039
|
-
|
|
3062
|
+
s();
|
|
3040
3063
|
} finally {
|
|
3041
3064
|
this.endScissor();
|
|
3042
3065
|
}
|
|
@@ -3144,8 +3167,8 @@ class ce {
|
|
|
3144
3167
|
*/
|
|
3145
3168
|
startScissor(t, e, r, i) {
|
|
3146
3169
|
this.flush();
|
|
3147
|
-
const
|
|
3148
|
-
|
|
3170
|
+
const s = this.gl, a = this.physicsWidth / this.logicWidth, o = this.physicsHeight / this.logicHeight, h = Math.round(t * a), c = Math.round(this.physicsHeight - (e + i) * o), u = Math.round(r * a), l = Math.round(i * o);
|
|
3171
|
+
s.enable(s.SCISSOR_TEST), s.scissor(h, c, u, l);
|
|
3149
3172
|
}
|
|
3150
3173
|
/**
|
|
3151
3174
|
* Disables scissor clipping, restoring full-canvas rendering.
|
|
@@ -3159,13 +3182,13 @@ class ce {
|
|
|
3159
3182
|
this.matrix.invert(e);
|
|
3160
3183
|
}
|
|
3161
3184
|
logicToPhysics(t) {
|
|
3162
|
-
return t.multiply(new
|
|
3185
|
+
return t.multiply(new p(
|
|
3163
3186
|
this.physicsWidth / this.logicWidth,
|
|
3164
3187
|
this.physicsHeight / this.logicHeight
|
|
3165
3188
|
));
|
|
3166
3189
|
}
|
|
3167
3190
|
physicsToLogic(t) {
|
|
3168
|
-
return t.multiply(new
|
|
3191
|
+
return t.multiply(new p(
|
|
3169
3192
|
this.logicWidth / this.physicsWidth,
|
|
3170
3193
|
this.logicHeight / this.physicsHeight
|
|
3171
3194
|
));
|
|
@@ -3193,10 +3216,10 @@ class ce {
|
|
|
3193
3216
|
return this.matrix.toCSSMatrix(t ?? this.matrixStack.curWorldM, e, r);
|
|
3194
3217
|
}
|
|
3195
3218
|
}
|
|
3196
|
-
function
|
|
3197
|
-
return !(
|
|
3219
|
+
function he(n) {
|
|
3220
|
+
return !(n === null || typeof n != "object" || Array.isArray(n) || n instanceof p || n instanceof x);
|
|
3198
3221
|
}
|
|
3199
|
-
class
|
|
3222
|
+
class W {
|
|
3200
3223
|
/** Random float in [min, max). */
|
|
3201
3224
|
static float(t, e) {
|
|
3202
3225
|
return Math.random() * (e - t) + t;
|
|
@@ -3211,20 +3234,20 @@ class C {
|
|
|
3211
3234
|
}
|
|
3212
3235
|
/** Random Vec2 with components in the supplied per-axis ranges. */
|
|
3213
3236
|
static vector(t, e, r, i) {
|
|
3214
|
-
return new
|
|
3237
|
+
return new p(W.float(t, e), W.float(r, i));
|
|
3215
3238
|
}
|
|
3216
3239
|
/** Random Color with each component interpolated between minColor and maxColor. */
|
|
3217
3240
|
static randomColor(t, e) {
|
|
3218
|
-
return new
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3241
|
+
return new x(
|
|
3242
|
+
W.float(t.r, e.r),
|
|
3243
|
+
W.float(t.g, e.g),
|
|
3244
|
+
W.float(t.b, e.b),
|
|
3245
|
+
W.float(t.a, e.a)
|
|
3223
3246
|
);
|
|
3224
3247
|
}
|
|
3225
3248
|
/** Pick a random element from an array with uniform probability. */
|
|
3226
3249
|
static pick(t) {
|
|
3227
|
-
return t[
|
|
3250
|
+
return t[W.int(0, t.length - 1)];
|
|
3228
3251
|
}
|
|
3229
3252
|
/**
|
|
3230
3253
|
* Pick a random element using weighted probability.
|
|
@@ -3235,8 +3258,8 @@ class C {
|
|
|
3235
3258
|
let e = 0;
|
|
3236
3259
|
for (const [, i] of t) e += i;
|
|
3237
3260
|
let r = Math.random() * e;
|
|
3238
|
-
for (const [i,
|
|
3239
|
-
if (r -=
|
|
3261
|
+
for (const [i, s] of t)
|
|
3262
|
+
if (r -= s, r <= 0) return i;
|
|
3240
3263
|
return t[t.length - 1][0];
|
|
3241
3264
|
}
|
|
3242
3265
|
/**
|
|
@@ -3250,125 +3273,115 @@ class C {
|
|
|
3250
3273
|
if (Array.isArray(t)) {
|
|
3251
3274
|
const [r, i] = t;
|
|
3252
3275
|
if (typeof r == "number")
|
|
3253
|
-
return
|
|
3254
|
-
if (r instanceof m)
|
|
3255
|
-
return C.vector(r.x, i.x, r.y, i.y);
|
|
3276
|
+
return W.float(r, i);
|
|
3256
3277
|
if (r instanceof p)
|
|
3257
|
-
return
|
|
3278
|
+
return W.vector(r.x, i.x, r.y, i.y);
|
|
3279
|
+
if (r instanceof x)
|
|
3280
|
+
return W.randomColor(r, i);
|
|
3258
3281
|
}
|
|
3259
3282
|
return typeof t == "number" ? t : t.clone();
|
|
3260
3283
|
}
|
|
3261
3284
|
}
|
|
3262
|
-
var
|
|
3263
|
-
const
|
|
3264
|
-
class
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
color: this.processAttribute(e.animation.color, p.White.clone()),
|
|
3278
|
-
velocity: this.processAttribute(e.animation.velocity, m.ZERO)
|
|
3279
|
-
}, this.position = m.ZERO, this.initializePosition();
|
|
3280
|
-
}
|
|
3281
|
-
processAttribute(t, e) {
|
|
3282
|
-
if (t == null)
|
|
3283
|
-
return { value: e };
|
|
3284
|
-
if (ae(t)) {
|
|
3285
|
-
const r = t, i = C.scalarOrRange(r.start, e), n = r.end === void 0 ? i : C.scalarOrRange(r.end, e);
|
|
3286
|
-
return {
|
|
3287
|
-
delta: r.delta ?? this.getDelta(i, n, this.maxLife),
|
|
3288
|
-
value: i,
|
|
3289
|
-
damping: r.damping
|
|
3290
|
-
};
|
|
3291
|
-
} else
|
|
3292
|
-
return this.processAttribute({ start: t }, e);
|
|
3293
|
-
}
|
|
3294
|
-
updateNumberAttribute(t, e) {
|
|
3295
|
-
t.damping !== void 0 && (t.value *= Math.pow(t.damping, e)), t.delta !== void 0 && (t.value += t.delta * e);
|
|
3296
|
-
}
|
|
3297
|
-
updateVec2Attribute(t, e) {
|
|
3298
|
-
t.damping !== void 0 && (t.value = t.value.multiply(Math.pow(t.damping, e))), t.delta !== void 0 && (t.value = t.value.add(t.delta.multiply(e)));
|
|
3299
|
-
}
|
|
3300
|
-
updateColorAttribute(t, e) {
|
|
3301
|
-
t.damping !== void 0 && (t.value = t.value.multiply(Math.pow(t.damping, e))), t.delta !== void 0 && (t.value = t.value.add(t.delta.multiply(e))), t.value.clamp();
|
|
3302
|
-
}
|
|
3303
|
-
updateAttributes(t) {
|
|
3304
|
-
const e = this.datas;
|
|
3305
|
-
this.updateNumberAttribute(e.speed, t), this.updateNumberAttribute(e.rotation, t), this.updateNumberAttribute(e.scale, t), this.updateColorAttribute(e.color, t), this.updateVec2Attribute(e.velocity, t);
|
|
3306
|
-
const i = m.fromAngle(e.rotation.value).multiply(e.speed.value * t);
|
|
3307
|
-
this.position = this.position.add(i).add(e.velocity.value.multiply(t));
|
|
3308
|
-
}
|
|
3309
|
-
getDelta(t, e, r) {
|
|
3310
|
-
return typeof t == "number" && typeof e == "number" ? (e - t) / r : t instanceof m && e instanceof m || t instanceof p && e instanceof p ? e.subtract(t).divide(r) : t;
|
|
3311
|
-
}
|
|
3312
|
-
/**
|
|
3313
|
-
* Updates particle state.
|
|
3314
|
-
* @param deltaTime - Seconds elapsed since last frame
|
|
3315
|
-
* @returns `true` while the particle is alive, `false` when it should be removed
|
|
3316
|
-
*/
|
|
3317
|
-
update(t) {
|
|
3318
|
-
return this.life += t, this.life >= this.maxLife ? !1 : (this.updateAttributes(t), !0);
|
|
3319
|
-
}
|
|
3320
|
-
/**
|
|
3321
|
-
* Renders the particle using the Rapid engine's matrixStack + drawSprite.
|
|
3322
|
-
* The emitter is responsible for calling save/restore around a batch of particles.
|
|
3323
|
-
*/
|
|
3324
|
-
render() {
|
|
3325
|
-
const t = this.rapid.matrixStack, e = this.datas.scale.value, r = this.datas.rotation.value, i = this.datas.color.value;
|
|
3326
|
-
t.save(), t.translate(this.position.x, this.position.y), r !== 0 && t.rotate(r), e !== 1 && t.scale(e, e);
|
|
3327
|
-
const n = this.options.origin ? this.options.origin.x : 0.5, a = this.options.origin ? this.options.origin.y : 0.5;
|
|
3328
|
-
(n !== 0 || a !== 0) && t.translate(-n * this.texture.rawWidth, -a * this.texture.rawHeight), Rt(this.rapid, { texture: this.texture, color: i }), t.restore();
|
|
3285
|
+
var oe = /* @__PURE__ */ ((n) => (n.POINT = "point", n.CIRCLE = "circle", n.RECT = "rect", n))(oe || {});
|
|
3286
|
+
const pt = 10, gt = 0, vt = !0;
|
|
3287
|
+
class K {
|
|
3288
|
+
components;
|
|
3289
|
+
constructor(t = 1) {
|
|
3290
|
+
if (!Number.isInteger(t) || t <= 0)
|
|
3291
|
+
throw new RangeError("ParticleAttributeStore size must be a positive integer");
|
|
3292
|
+
this.components = Array.from({ length: t }, () => ({
|
|
3293
|
+
value: new P(U.Float32),
|
|
3294
|
+
delta: new P(U.Float32),
|
|
3295
|
+
damping: new P(U.Float32)
|
|
3296
|
+
}));
|
|
3297
|
+
}
|
|
3298
|
+
getArrayBuffer() {
|
|
3299
|
+
return this.components.flatMap(({ value: t, delta: e, damping: r }) => [t, e, r]);
|
|
3329
3300
|
}
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3301
|
+
update(t) {
|
|
3302
|
+
for (const { value: e, delta: r, damping: i } of this.components)
|
|
3303
|
+
for (let s = 0; s < e.usedElemNum; s++)
|
|
3304
|
+
e.typedArray[s] *= Math.pow(i.get(s), t), e.typedArray[s] += r.get(s) * t;
|
|
3305
|
+
}
|
|
3306
|
+
get(t, e = 0) {
|
|
3307
|
+
return this.components[e].value.get(t);
|
|
3308
|
+
}
|
|
3309
|
+
getComponent(t, e) {
|
|
3310
|
+
if (typeof t == "number")
|
|
3311
|
+
return t;
|
|
3312
|
+
if (t instanceof p)
|
|
3313
|
+
return e === 0 ? t.x : t.y;
|
|
3314
|
+
switch (e) {
|
|
3315
|
+
case 0:
|
|
3316
|
+
return t.r;
|
|
3317
|
+
case 1:
|
|
3318
|
+
return t.g;
|
|
3319
|
+
case 2:
|
|
3320
|
+
return t.b;
|
|
3321
|
+
case 3:
|
|
3322
|
+
return t.a;
|
|
3344
3323
|
default:
|
|
3345
|
-
|
|
3346
|
-
|
|
3324
|
+
return 0;
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
resolveComponent(t, e, r) {
|
|
3328
|
+
return t === void 0 ? r : Array.isArray(t) ? W.float(
|
|
3329
|
+
this.getComponent(t[0], e),
|
|
3330
|
+
this.getComponent(t[1], e)
|
|
3331
|
+
) : this.getComponent(t, e);
|
|
3332
|
+
}
|
|
3333
|
+
create(t, e, r = 1) {
|
|
3334
|
+
const i = he(t) ? t : void 0, s = i === void 0 ? t : void 0, a = r > 0 ? r : 1;
|
|
3335
|
+
let o = 0;
|
|
3336
|
+
for (let h = 0; h < this.components.length; h++) {
|
|
3337
|
+
const { value: c, delta: u, damping: l } = this.components[h], d = this.getComponent(e, h), f = s === void 0 ? this.resolveComponent(i?.start, h, d) : this.getComponent(s, h), m = i?.end === void 0 ? f : this.resolveComponent(i.end, h, d);
|
|
3338
|
+
c.push(f), u.push(i?.delta === void 0 ? (m - f) / a : this.getComponent(i.delta, h)), l.push(i?.damping ?? 1), h === 0 && (o = f);
|
|
3347
3339
|
}
|
|
3348
|
-
|
|
3340
|
+
return o;
|
|
3349
3341
|
}
|
|
3350
3342
|
}
|
|
3351
3343
|
class wt {
|
|
3352
|
-
particles = [];
|
|
3353
3344
|
options;
|
|
3354
3345
|
emitting = !1;
|
|
3355
3346
|
emitTimer = 0;
|
|
3356
|
-
emitRate =
|
|
3357
|
-
emitTime =
|
|
3347
|
+
emitRate = pt;
|
|
3348
|
+
emitTime = gt;
|
|
3358
3349
|
emitTimeCounter = 0;
|
|
3359
3350
|
/** Whether spawned particles are positioned in local emitter space (default: true). */
|
|
3360
|
-
localSpace =
|
|
3361
|
-
/** World position of the emitter. Used for both local-space transform and world-space spawn offset. */
|
|
3362
|
-
position = m.ZERO;
|
|
3351
|
+
localSpace = vt;
|
|
3363
3352
|
rapid;
|
|
3364
|
-
|
|
3353
|
+
x = new P(U.Float32);
|
|
3354
|
+
y = new P(U.Float32);
|
|
3355
|
+
scaleX = new P(U.Float32);
|
|
3356
|
+
scaleY = new P(U.Float32);
|
|
3357
|
+
rotation = new P(U.Float32);
|
|
3358
|
+
color = new P(U.Uint32);
|
|
3359
|
+
animations = {
|
|
3360
|
+
speed: new K(),
|
|
3361
|
+
rotation: new K(),
|
|
3362
|
+
scale: new K(),
|
|
3363
|
+
color: new K(4),
|
|
3364
|
+
velocity: new K(2)
|
|
3365
|
+
};
|
|
3366
|
+
count = 0;
|
|
3365
3367
|
/**
|
|
3366
3368
|
* Creates a new particle emitter.
|
|
3367
3369
|
* @param rapid - The Rapid renderer instance
|
|
3368
3370
|
* @param options - Emitter configuration options
|
|
3369
3371
|
*/
|
|
3370
3372
|
constructor(t, e) {
|
|
3371
|
-
this.rapid = t, this.options = e, this.emitRate = e.emitRate
|
|
3373
|
+
this.rapid = t, this.options = e, this.emitRate = e.emitRate ?? pt, this.emitTime = e.emitTime ?? gt, this.localSpace = e.localSpace ?? vt;
|
|
3374
|
+
}
|
|
3375
|
+
getAllArrayBuffer() {
|
|
3376
|
+
return [
|
|
3377
|
+
this.x,
|
|
3378
|
+
this.y,
|
|
3379
|
+
this.scaleX,
|
|
3380
|
+
this.scaleY,
|
|
3381
|
+
this.rotation,
|
|
3382
|
+
this.color,
|
|
3383
|
+
...Object.values(this.animations).flatMap((t) => t.getArrayBuffer())
|
|
3384
|
+
];
|
|
3372
3385
|
}
|
|
3373
3386
|
/** Replaces the emitter's texture at runtime. */
|
|
3374
3387
|
setTexture(t) {
|
|
@@ -3399,16 +3412,48 @@ class wt {
|
|
|
3399
3412
|
}
|
|
3400
3413
|
/** Removes all particles and resets timers. */
|
|
3401
3414
|
clear() {
|
|
3402
|
-
|
|
3415
|
+
for (const t of this.getAllArrayBuffer())
|
|
3416
|
+
t.clear();
|
|
3417
|
+
this.count = 0, this.emitTimeCounter = 0;
|
|
3403
3418
|
}
|
|
3404
3419
|
/**
|
|
3405
3420
|
* Spawns `count` particles immediately.
|
|
3406
3421
|
* Respects `maxParticles` if set.
|
|
3407
3422
|
*/
|
|
3408
3423
|
emit(t) {
|
|
3409
|
-
const e = this.options.maxParticles ?? 1 / 0, r = Math.min(t, e - this.
|
|
3424
|
+
const e = this.options.maxParticles ?? 1 / 0, r = Math.min(t, e - this.count);
|
|
3410
3425
|
for (let i = 0; i < r; i++)
|
|
3411
|
-
this.
|
|
3426
|
+
this.createParticle();
|
|
3427
|
+
}
|
|
3428
|
+
createParticle() {
|
|
3429
|
+
const t = W.scalarOrRange(this.options.life, 1);
|
|
3430
|
+
let e = 0, r = 0;
|
|
3431
|
+
switch (this.options.emitShape) {
|
|
3432
|
+
case "circle": {
|
|
3433
|
+
const c = Math.random() * Math.PI * 2, u = (this.options.emitRadius ?? 0) * Math.sqrt(Math.random());
|
|
3434
|
+
e = Math.cos(c) * u, r = Math.sin(c) * u;
|
|
3435
|
+
break;
|
|
3436
|
+
}
|
|
3437
|
+
case "rect": {
|
|
3438
|
+
e = (Math.random() - 0.5) * (this.options.emitRect?.width ?? 0), r = (Math.random() - 0.5) * (this.options.emitRect?.height ?? 0);
|
|
3439
|
+
break;
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
const i = this.rapid.matrixStack;
|
|
3443
|
+
if (this.localSpace)
|
|
3444
|
+
this.x.push(e), this.y.push(r);
|
|
3445
|
+
else {
|
|
3446
|
+
const { x: c, y: u } = i.localToWorld(e, r);
|
|
3447
|
+
this.x.push(c), this.y.push(u);
|
|
3448
|
+
}
|
|
3449
|
+
const s = this.options.animation, a = this.animations, o = a.scale.create(s.scale, 1, t), h = a.rotation.create(s.rotation, 0, t);
|
|
3450
|
+
a.speed.create(s.speed, 0, t), a.velocity.create(s.velocity, p.ZERO, t), a.color.create(s.color, x.White, t), this.rotation.push(h), this.scaleX.push(o), this.scaleY.push(o), this.color.pushUint32(x.packColor(
|
|
3451
|
+
a.color.get(this.count, 0),
|
|
3452
|
+
a.color.get(this.count, 1),
|
|
3453
|
+
a.color.get(this.count, 2),
|
|
3454
|
+
a.color.get(this.count, 3),
|
|
3455
|
+
this.rapid.premultipliedAlpha
|
|
3456
|
+
)), this.count += 1;
|
|
3412
3457
|
}
|
|
3413
3458
|
/**
|
|
3414
3459
|
* Updates the emitter and all live particles.
|
|
@@ -3418,35 +3463,57 @@ class wt {
|
|
|
3418
3463
|
if (this.emitting && this.emitRate > 0)
|
|
3419
3464
|
if (this.emitTime > 0) {
|
|
3420
3465
|
if (this.emitTimeCounter += t, this.emitTimeCounter >= this.emitTime) {
|
|
3421
|
-
const
|
|
3422
|
-
this.emit(this.emitRate *
|
|
3466
|
+
const r = Math.floor(this.emitTimeCounter / this.emitTime);
|
|
3467
|
+
this.emit(this.emitRate * r), this.emitTimeCounter -= r * this.emitTime;
|
|
3423
3468
|
}
|
|
3424
3469
|
} else {
|
|
3425
3470
|
this.emitTimer += t;
|
|
3426
|
-
const
|
|
3427
|
-
|
|
3471
|
+
const r = Math.floor(this.emitTimer * this.emitRate);
|
|
3472
|
+
r > 0 && (this.emit(r), this.emitTimer -= r / this.emitRate);
|
|
3428
3473
|
}
|
|
3429
|
-
|
|
3430
|
-
|
|
3474
|
+
const e = this.updateParticle(t);
|
|
3475
|
+
this.count -= e.length, P.removeAtIndices(e, this.getAllArrayBuffer());
|
|
3476
|
+
}
|
|
3477
|
+
updateParticle(t) {
|
|
3478
|
+
const e = [], r = this.animations;
|
|
3479
|
+
Object.values(r).forEach((i) => i.update(t));
|
|
3480
|
+
for (let i = 0; i < this.count; i++) {
|
|
3481
|
+
const s = r.rotation.get(i), a = r.scale.get(i), o = r.speed.get(i);
|
|
3482
|
+
this.rotation.typedArray[i] = s, this.scaleX.typedArray[i] = a, this.scaleY.typedArray[i] = a, this.color.uint32[i] = x.packColor(
|
|
3483
|
+
r.color.get(i, 0),
|
|
3484
|
+
r.color.get(i, 1),
|
|
3485
|
+
r.color.get(i, 2),
|
|
3486
|
+
r.color.get(i, 3),
|
|
3487
|
+
this.rapid.premultipliedAlpha
|
|
3488
|
+
), this.x.typedArray[i] += (o * Math.cos(s) + r.velocity.get(i, 0)) * t, this.y.typedArray[i] += (o * Math.sin(s) + r.velocity.get(i, 1)) * t;
|
|
3489
|
+
}
|
|
3490
|
+
return e;
|
|
3431
3491
|
}
|
|
3432
3492
|
/**
|
|
3433
3493
|
* Renders all live particles.
|
|
3434
3494
|
* In local-space mode the emitter's own transform is applied around the batch.
|
|
3435
3495
|
*/
|
|
3436
3496
|
render() {
|
|
3437
|
-
const t = this.rapid.
|
|
3438
|
-
this.
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3497
|
+
const t = this.options, e = this.localSpace ? void 0 : this.rapid.matrix.alloc();
|
|
3498
|
+
this.rapid.drawParticles({
|
|
3499
|
+
texture: t.texture,
|
|
3500
|
+
shader: t.shader,
|
|
3501
|
+
x: this.x.typedArray,
|
|
3502
|
+
y: this.y.typedArray,
|
|
3503
|
+
scaleX: this.scaleX.typedArray,
|
|
3504
|
+
scaleY: this.scaleY.typedArray,
|
|
3505
|
+
rotation: this.rotation.typedArray,
|
|
3506
|
+
color: this.color.typedArray,
|
|
3507
|
+
count: this.count,
|
|
3508
|
+
reverseOrder: !0,
|
|
3509
|
+
originX: t.origin?.x ?? 0.5,
|
|
3510
|
+
originY: t.origin?.y ?? 0.5,
|
|
3511
|
+
customMatrix: e
|
|
3512
|
+
});
|
|
3446
3513
|
}
|
|
3447
3514
|
/** Returns `true` if the emitter is running or still has live particles. */
|
|
3448
3515
|
isActive() {
|
|
3449
|
-
return this.emitting || this.
|
|
3516
|
+
return this.emitting || this.count > 0;
|
|
3450
3517
|
}
|
|
3451
3518
|
/**
|
|
3452
3519
|
* Convenience: emit `emitRate` particles in one shot (fire-and-forget burst).
|
|
@@ -3456,42 +3523,41 @@ class wt {
|
|
|
3456
3523
|
}
|
|
3457
3524
|
}
|
|
3458
3525
|
export {
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3526
|
+
U as ArrayType,
|
|
3527
|
+
z as BaseTexture,
|
|
3528
|
+
ne as BlendMode,
|
|
3529
|
+
ae as CanvasScaleMode,
|
|
3530
|
+
x as Color,
|
|
3531
|
+
ct as CustomGlShader,
|
|
3532
|
+
P as DynamicArrayBuffer,
|
|
3466
3533
|
Tt as GLShader,
|
|
3467
3534
|
Ht as GraphicRegion,
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3535
|
+
zt as LineTextureMode,
|
|
3536
|
+
se as MaskType,
|
|
3537
|
+
At as MatrixStack,
|
|
3471
3538
|
Mt as MatrixStore,
|
|
3472
|
-
oe as Particle,
|
|
3473
3539
|
wt as ParticleEmitter,
|
|
3474
|
-
|
|
3475
|
-
|
|
3540
|
+
oe as ParticleShape,
|
|
3541
|
+
Wt as QUAD_VERTICES,
|
|
3476
3542
|
ce as Rapid,
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3543
|
+
Et as Region,
|
|
3544
|
+
bt as RenderTexture,
|
|
3545
|
+
at as SpriteRegion,
|
|
3546
|
+
Ct as TextTexture,
|
|
3547
|
+
B as Texture,
|
|
3548
|
+
nt as TextureFilterMode,
|
|
3549
|
+
St as TextureManager,
|
|
3550
|
+
q as TextureWrapMode,
|
|
3551
|
+
p as Vec2,
|
|
3552
|
+
et as WebglBufferArray,
|
|
3487
3553
|
Vt as composeProjectionWithAffine,
|
|
3488
|
-
|
|
3489
|
-
|
|
3554
|
+
ee as drawCircle,
|
|
3555
|
+
Rt as drawGraphic,
|
|
3490
3556
|
Zt as drawLine,
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3557
|
+
Jt as drawMaskImage,
|
|
3558
|
+
Qt as drawParticles,
|
|
3559
|
+
te as drawRect,
|
|
3560
|
+
qt as drawSprite,
|
|
3561
|
+
$t as getColorUint32,
|
|
3562
|
+
Yt as multiplyMat4
|
|
3497
3563
|
};
|