rapid-render 1.0.6 → 1.0.8
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 +2 -3
- package/dist/buffer.d.ts +1 -0
- package/dist/color.d.ts +2 -0
- package/dist/draw.d.ts +12 -11
- package/dist/matrix-engine.d.ts +5 -5
- package/dist/particle.d.ts +38 -39
- package/dist/rapid-render.js +977 -877
- package/dist/rapid-render.umd.cjs +22 -22
- package/dist/region/particleRegion.d.ts +3 -1
- package/dist/render.d.ts +1 -1
- package/package.json +5 -4
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 C {
|
|
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 C {
|
|
155
176
|
/** The actual WebGLBuffer object maintained by this instance. */
|
|
156
177
|
buffer;
|
|
157
178
|
/** The related WebGL rendering context. */
|
|
@@ -171,8 +192,8 @@ class Q extends B {
|
|
|
171
192
|
* @param type - Determines the type of WebGLBuffer (defaults to gl.ARRAY_BUFFER).
|
|
172
193
|
* @param usage - Determines the data usage pattern (defaults to gl.DYNAMIC_DRAW).
|
|
173
194
|
*/
|
|
174
|
-
constructor(t, e,
|
|
175
|
-
super(e), this.gl = t, this.buffer = t.createBuffer(), this.type =
|
|
195
|
+
constructor(t, e, r = t.ARRAY_BUFFER, i = t.DYNAMIC_DRAW) {
|
|
196
|
+
super(e), this.gl = t, this.buffer = t.createBuffer(), this.type = r, this.usage = i;
|
|
176
197
|
}
|
|
177
198
|
/**
|
|
178
199
|
* Flags the buffer as dirty, marking it for future data synchronization.
|
|
@@ -219,8 +240,8 @@ class m {
|
|
|
219
240
|
* @param b - The blue component (0-255).
|
|
220
241
|
* @param a - The alpha component (0-255).
|
|
221
242
|
*/
|
|
222
|
-
constructor(t, e,
|
|
223
|
-
this._r = t, this._g = e, this._b =
|
|
243
|
+
constructor(t, e, r, i = 255) {
|
|
244
|
+
this._r = t, this._g = e, this._b = r, this._a = i, this.updateUint();
|
|
224
245
|
}
|
|
225
246
|
setClearColor(t) {
|
|
226
247
|
t.clearColor(this.r / 255, this.g / 255, this.b / 255, this.a / 255);
|
|
@@ -283,8 +304,8 @@ class m {
|
|
|
283
304
|
*/
|
|
284
305
|
updateUint() {
|
|
285
306
|
this.uint32 = (this._a << 24 | this._b << 16 | this._g << 8 | this._r) >>> 0;
|
|
286
|
-
const t = m.clampByte(this._a), e = m.clampByte(this._r * t / 255),
|
|
287
|
-
this.premultipliedUint32 = (t << 24 |
|
|
307
|
+
const t = m.clampByte(this._a), e = m.clampByte(this._r * t / 255), r = m.clampByte(this._g * t / 255), i = m.clampByte(this._b * t / 255);
|
|
308
|
+
this.premultipliedUint32 = (t << 24 | i << 16 | r << 8 | e) >>> 0;
|
|
288
309
|
}
|
|
289
310
|
reset() {
|
|
290
311
|
this._r = 0, this._g = 0, this._b = 0, this._a = 255, this.updateUint();
|
|
@@ -296,14 +317,14 @@ class m {
|
|
|
296
317
|
* @param b - The blue component (0-255).
|
|
297
318
|
* @param a - The alpha component (0-255).
|
|
298
319
|
*/
|
|
299
|
-
setRGBA(t, e,
|
|
300
|
-
this.r = t, this.g = e, this.b =
|
|
320
|
+
setRGBA(t, e, r, i) {
|
|
321
|
+
this.r = t, this.g = e, this.b = r, this.a = i, this.updateUint();
|
|
301
322
|
}
|
|
302
|
-
setHSL(t, e,
|
|
303
|
-
t = (t % 360 + 360) % 360, e = Math.max(0, Math.min(100, e)) / 100,
|
|
304
|
-
const
|
|
323
|
+
setHSL(t, e, r) {
|
|
324
|
+
t = (t % 360 + 360) % 360, e = Math.max(0, Math.min(100, e)) / 100, r = Math.max(0, Math.min(100, r)) / 100;
|
|
325
|
+
const i = (1 - Math.abs(2 * r - 1)) * e, s = i * (1 - Math.abs(t / 60 % 2 - 1)), a = r - i / 2;
|
|
305
326
|
let o = 0, h = 0, c = 0;
|
|
306
|
-
return t < 60 ? [o, h, c] = [
|
|
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");
|
|
@@ -329,8 +350,8 @@ class m {
|
|
|
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"),
|
|
333
|
-
return `#${e}${
|
|
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.
|
|
@@ -354,20 +375,27 @@ class m {
|
|
|
354
375
|
* @example
|
|
355
376
|
* Color.fromNorm(0.9, 0.87, 0.55, 0.1) // moon glow
|
|
356
377
|
*/
|
|
357
|
-
static FromHSL(t, e,
|
|
358
|
-
return new m(0, 0, 0).setHSL(t, e,
|
|
378
|
+
static FromHSL(t, e, r) {
|
|
379
|
+
return new m(0, 0, 0).setHSL(t, e, r);
|
|
359
380
|
}
|
|
360
|
-
static FromRGB(t, e,
|
|
361
|
-
return new m(t, e,
|
|
381
|
+
static FromRGB(t, e, r) {
|
|
382
|
+
return new m(t, e, r);
|
|
362
383
|
}
|
|
363
|
-
static fromNorm(t, e,
|
|
384
|
+
static fromNorm(t, e, r, i = 1) {
|
|
364
385
|
return new m(
|
|
365
386
|
Math.round(t * 255),
|
|
366
387
|
Math.round(e * 255),
|
|
367
|
-
Math.round(
|
|
368
|
-
Math.round(
|
|
388
|
+
Math.round(r * 255),
|
|
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 = m.clampColorByte(i), o = s ? a / 255 : 1, h = m.clampColorByte(t * o), c = m.clampColorByte(e * o), u = m.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'.
|
|
@@ -375,9 +403,9 @@ class m {
|
|
|
375
403
|
*/
|
|
376
404
|
static fromHex(t) {
|
|
377
405
|
t.startsWith("#") && (t = t.slice(1));
|
|
378
|
-
const e = parseInt(t.slice(0, 2), 16),
|
|
379
|
-
let
|
|
380
|
-
return t.length >= 8 && (
|
|
406
|
+
const e = parseInt(t.slice(0, 2), 16), r = parseInt(t.slice(2, 4), 16), i = parseInt(t.slice(4, 6), 16);
|
|
407
|
+
let s = 255;
|
|
408
|
+
return t.length >= 8 && (s = parseInt(t.slice(6, 8), 16)), new m(e, r, i, s);
|
|
381
409
|
}
|
|
382
410
|
/**
|
|
383
411
|
* Adds the components of another color to this color, clamping the result to 255.
|
|
@@ -451,7 +479,7 @@ class m {
|
|
|
451
479
|
static Transparent = new m(0, 0, 0, 0);
|
|
452
480
|
static TRANSPARENT = new m(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;
|
|
@@ -459,12 +487,13 @@ class Mt {
|
|
|
459
487
|
buffer;
|
|
460
488
|
/** The raw floating-point data of all matrices. */
|
|
461
489
|
data;
|
|
490
|
+
temporary = -1;
|
|
462
491
|
/**
|
|
463
492
|
* Creates a new MatrixStore.
|
|
464
493
|
* @param capacity - The initial capacity of the matrix store (default is 10).
|
|
465
494
|
*/
|
|
466
495
|
constructor(t = 10) {
|
|
467
|
-
this.buffer = new
|
|
496
|
+
this.buffer = new C(U.Float32), this.buffer.resize(t * E), this.data = this.buffer.getArray(), this.reset();
|
|
468
497
|
}
|
|
469
498
|
/**
|
|
470
499
|
* Allocates a new matrix and initializes it to the identity matrix.
|
|
@@ -479,21 +508,21 @@ class Mt {
|
|
|
479
508
|
* @returns The index of the newly allocated matrix.
|
|
480
509
|
*/
|
|
481
510
|
allocDirty() {
|
|
482
|
-
return this.buffer.resize(
|
|
511
|
+
return this.buffer.resize(E) && (this.data = this.buffer.getArray()), this.buffer.usedElemNum += E, this.matrixCount++;
|
|
483
512
|
}
|
|
484
513
|
/**
|
|
485
514
|
* Resets the store, clearing all allocated matrices.
|
|
486
515
|
*/
|
|
487
516
|
reset() {
|
|
488
|
-
this.matrixCount = 0, this.buffer.usedElemNum = 0;
|
|
517
|
+
this.matrixCount = 0, this.buffer.usedElemNum = 0, this.temporary = this.alloc();
|
|
489
518
|
}
|
|
490
519
|
/**
|
|
491
520
|
* Sets the matrix at the given index to the identity matrix.
|
|
492
521
|
* @param index - The index of the matrix to modify.
|
|
493
522
|
*/
|
|
494
523
|
identity(t) {
|
|
495
|
-
const e = t *
|
|
496
|
-
|
|
524
|
+
const e = t * E, r = this.data;
|
|
525
|
+
r[e] = 1, r[e + 1] = 0, r[e + 2] = 0, r[e + 3] = 1, r[e + 4] = 0, r[e + 5] = 0;
|
|
497
526
|
}
|
|
498
527
|
/**
|
|
499
528
|
* Translates the matrix at the given index by x and y.
|
|
@@ -501,9 +530,9 @@ class Mt {
|
|
|
501
530
|
* @param x - The x translation.
|
|
502
531
|
* @param y - The y translation.
|
|
503
532
|
*/
|
|
504
|
-
translate(t, e,
|
|
505
|
-
const
|
|
506
|
-
|
|
533
|
+
translate(t, e, r) {
|
|
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];
|
|
507
536
|
}
|
|
508
537
|
/**
|
|
509
538
|
* Scales the matrix at the given index by scaleX and scaleY.
|
|
@@ -511,9 +540,9 @@ class Mt {
|
|
|
511
540
|
* @param scaleX - The scale factor along the x-axis.
|
|
512
541
|
* @param scaleY - The scale factor along the y-axis.
|
|
513
542
|
*/
|
|
514
|
-
scale(t, e,
|
|
515
|
-
const
|
|
516
|
-
|
|
543
|
+
scale(t, e, r) {
|
|
544
|
+
const i = t * E, s = this.data;
|
|
545
|
+
s[i] *= e, s[i + 1] *= e, s[i + 2] *= r, s[i + 3] *= r;
|
|
517
546
|
}
|
|
518
547
|
/**
|
|
519
548
|
* Rotates the matrix at the given index by the specified radians.
|
|
@@ -521,8 +550,8 @@ class Mt {
|
|
|
521
550
|
* @param radians - The rotation angle in radians.
|
|
522
551
|
*/
|
|
523
552
|
rotate(t, e) {
|
|
524
|
-
const
|
|
525
|
-
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;
|
|
526
555
|
}
|
|
527
556
|
/**
|
|
528
557
|
* Rotates the matrix at the given index around a local offset point (pivot).
|
|
@@ -540,8 +569,8 @@ class Mt {
|
|
|
540
569
|
* @param offsetX - The x component of the pivot point in local space.
|
|
541
570
|
* @param offsetY - The y component of the pivot point in local space.
|
|
542
571
|
*/
|
|
543
|
-
rotateWithOffset(t, e,
|
|
544
|
-
this.translate(t,
|
|
572
|
+
rotateWithOffset(t, e, r, i) {
|
|
573
|
+
this.translate(t, r, i), this.rotate(t, e), this.translate(t, -r, -i);
|
|
545
574
|
}
|
|
546
575
|
/**
|
|
547
576
|
* Copies the elements from the source matrix to the destination matrix.
|
|
@@ -549,8 +578,8 @@ class Mt {
|
|
|
549
578
|
* @param src - The index of the source matrix.
|
|
550
579
|
*/
|
|
551
580
|
copy(t, e) {
|
|
552
|
-
const
|
|
553
|
-
|
|
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];
|
|
554
583
|
}
|
|
555
584
|
/**
|
|
556
585
|
* Multiplies the destination matrix by the source matrix and stores the result in the destination.
|
|
@@ -566,22 +595,22 @@ class Mt {
|
|
|
566
595
|
* @param aIdx - The index of matrix A.
|
|
567
596
|
* @param bIdx - The index of matrix B.
|
|
568
597
|
*/
|
|
569
|
-
multiplyOut(t, e,
|
|
570
|
-
const
|
|
571
|
-
o[
|
|
598
|
+
multiplyOut(t, e, r) {
|
|
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], x = o[a], g = o[a + 1], v = o[a + 2], T = o[a + 3], A = o[a + 4], R = o[a + 5];
|
|
600
|
+
o[i] = h * x + u * g, o[i + 1] = c * x + l * g, o[i + 2] = h * v + u * T, o[i + 3] = c * v + l * T, o[i + 4] = h * A + u * R + d, o[i + 5] = c * A + l * R + f;
|
|
572
601
|
}
|
|
573
602
|
/**
|
|
574
603
|
* Inverts the matrix at the given index. If the matrix is not invertible, it defaults to the identity matrix.
|
|
575
604
|
* @param index - The index of the matrix to invert.
|
|
576
605
|
*/
|
|
577
606
|
invert(t) {
|
|
578
|
-
const e = t *
|
|
579
|
-
let u =
|
|
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;
|
|
580
609
|
if (!u) {
|
|
581
610
|
this.identity(t);
|
|
582
611
|
return;
|
|
583
612
|
}
|
|
584
|
-
u = 1 / u,
|
|
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;
|
|
585
614
|
}
|
|
586
615
|
/**
|
|
587
616
|
* Transforms a point by the matrix at the given index.
|
|
@@ -590,11 +619,11 @@ class Mt {
|
|
|
590
619
|
* @param y - The y coordinate of the point.
|
|
591
620
|
* @returns The transformed point {x, y}.
|
|
592
621
|
*/
|
|
593
|
-
transformPoint(t, e,
|
|
594
|
-
const
|
|
622
|
+
transformPoint(t, e, r) {
|
|
623
|
+
const i = t * E, s = this.data;
|
|
595
624
|
return {
|
|
596
|
-
x: e *
|
|
597
|
-
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]
|
|
598
627
|
};
|
|
599
628
|
}
|
|
600
629
|
/**
|
|
@@ -605,11 +634,11 @@ class Mt {
|
|
|
605
634
|
* @param y - World y coordinate.
|
|
606
635
|
* @returns The transformed point in local coordinates.
|
|
607
636
|
*/
|
|
608
|
-
worldToLocal(t, e,
|
|
609
|
-
const
|
|
610
|
-
this.copy(
|
|
611
|
-
const
|
|
612
|
-
return this.matrixCount--, this.buffer.usedElemNum -=
|
|
637
|
+
worldToLocal(t, e, r) {
|
|
638
|
+
const i = this.allocDirty();
|
|
639
|
+
this.copy(i, t), this.invert(i);
|
|
640
|
+
const s = this.transformPoint(i, e, r);
|
|
641
|
+
return this.matrixCount--, this.buffer.usedElemNum -= E, s;
|
|
613
642
|
}
|
|
614
643
|
/**
|
|
615
644
|
* Transforms a point from local coordinates to world coordinates.
|
|
@@ -618,8 +647,8 @@ class Mt {
|
|
|
618
647
|
* @param y - Local y coordinate.
|
|
619
648
|
* @returns The transformed point in world coordinates.
|
|
620
649
|
*/
|
|
621
|
-
localToWorld(t, e,
|
|
622
|
-
return this.transformPoint(t, e,
|
|
650
|
+
localToWorld(t, e, r) {
|
|
651
|
+
return this.transformPoint(t, e, r);
|
|
623
652
|
}
|
|
624
653
|
/**
|
|
625
654
|
* Extracts the global position (translation) from the matrix at the given index.
|
|
@@ -627,8 +656,8 @@ class Mt {
|
|
|
627
656
|
* @returns An object containing `x` and `y` global coordinates.
|
|
628
657
|
*/
|
|
629
658
|
getPosition(t) {
|
|
630
|
-
const e = t *
|
|
631
|
-
return { x:
|
|
659
|
+
const e = t * E, r = this.data;
|
|
660
|
+
return { x: r[e + 4], y: r[e + 5] };
|
|
632
661
|
}
|
|
633
662
|
/**
|
|
634
663
|
* Extracts the global scale from the matrix at the given index.
|
|
@@ -636,8 +665,8 @@ class Mt {
|
|
|
636
665
|
* @returns An object containing `x` and `y` global scale factors.
|
|
637
666
|
*/
|
|
638
667
|
getScale(t) {
|
|
639
|
-
const e = t *
|
|
640
|
-
return { x:
|
|
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 };
|
|
641
670
|
}
|
|
642
671
|
/**
|
|
643
672
|
* Extracts the global rotation (in radians) from the matrix at the given index.
|
|
@@ -645,8 +674,8 @@ class Mt {
|
|
|
645
674
|
* @returns The global rotation in radians.
|
|
646
675
|
*/
|
|
647
676
|
getRotation(t) {
|
|
648
|
-
const e = t *
|
|
649
|
-
return Math.atan2(
|
|
677
|
+
const e = t * E, r = this.data;
|
|
678
|
+
return Math.atan2(r[e + 1], r[e]);
|
|
650
679
|
}
|
|
651
680
|
/**
|
|
652
681
|
* Converts the matrix at the given index to a CSS matrix string.
|
|
@@ -655,9 +684,9 @@ class Mt {
|
|
|
655
684
|
* @param scaleY - Extra scale applied to the b/d/ty components.
|
|
656
685
|
* @returns A CSS matrix string.
|
|
657
686
|
*/
|
|
658
|
-
toCSSMatrix(t, e = 1,
|
|
659
|
-
const
|
|
660
|
-
return `matrix(${
|
|
687
|
+
toCSSMatrix(t, e = 1, r = 1) {
|
|
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})`;
|
|
661
690
|
}
|
|
662
691
|
/**
|
|
663
692
|
* Retrieves a copy of the 6 elements [a, b, c, d, tx, ty] for the matrix at the specified index.
|
|
@@ -667,8 +696,8 @@ class Mt {
|
|
|
667
696
|
* @returns A new Float32Array containing the 6 elements of the matrix.
|
|
668
697
|
*/
|
|
669
698
|
getMatrix(t) {
|
|
670
|
-
const e = t *
|
|
671
|
-
return this.data.slice(e, e +
|
|
699
|
+
const e = t * E;
|
|
700
|
+
return this.data.slice(e, e + E);
|
|
672
701
|
}
|
|
673
702
|
/**
|
|
674
703
|
* Retrieves a direct reference (view) to the 6 elements [a, b, c, d, tx, ty] for the matrix at the specified index.
|
|
@@ -678,8 +707,8 @@ class Mt {
|
|
|
678
707
|
* @returns A Float32Array view pointing directly to the matrix's data in memory.
|
|
679
708
|
*/
|
|
680
709
|
getMatrixRef(t) {
|
|
681
|
-
const e = t *
|
|
682
|
-
return this.data.subarray(e, e +
|
|
710
|
+
const e = t * E;
|
|
711
|
+
return this.data.subarray(e, e + E);
|
|
683
712
|
}
|
|
684
713
|
/**
|
|
685
714
|
* Overwrites the matrix at the specified index with the provided 6 elements [a, b, c, d, tx, ty].
|
|
@@ -688,29 +717,33 @@ class Mt {
|
|
|
688
717
|
* @param f - An array (Float32Array or standard number array) containing the 6 new elements.
|
|
689
718
|
*/
|
|
690
719
|
setMatrix(t, e) {
|
|
691
|
-
const
|
|
692
|
-
r
|
|
720
|
+
const r = t * E, i = this.data;
|
|
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];
|
|
693
722
|
}
|
|
694
|
-
multiplyAffineInPlace(t, e,
|
|
695
|
-
const h = t * 6, c = this.data, u = c[h],
|
|
696
|
-
c[h] = u * e +
|
|
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], x = 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 + x, c[h + 5] = l * a + f * o + g;
|
|
726
|
+
}
|
|
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], x = l[c + 2], g = l[c + 3], v = l[c + 4], T = l[c + 5];
|
|
729
|
+
l[u] = d * r + x * i, l[u + 1] = f * r + g * i, l[u + 2] = d * s + x * a, l[u + 3] = f * s + g * a, l[u + 4] = d * o + x * h + v, l[u + 5] = f * o + g * h + T;
|
|
697
730
|
}
|
|
698
731
|
}
|
|
699
|
-
class
|
|
732
|
+
class At {
|
|
700
733
|
/** The underlying store for matrices. */
|
|
701
734
|
matrix = new Mt();
|
|
702
735
|
/** The current step or depth in the transformation hierarchy. */
|
|
703
736
|
step = 0;
|
|
704
737
|
/** Internal stack maintaining structural information. */
|
|
705
|
-
stack = new
|
|
738
|
+
stack = new C(U.Uint32);
|
|
706
739
|
/** Records the world matrices generated at each step. */
|
|
707
|
-
stepWorldM = new
|
|
740
|
+
stepWorldM = new C(U.Uint32);
|
|
708
741
|
/** Records actions (push/pop) taken during the traversal. */
|
|
709
|
-
stepAction = new
|
|
742
|
+
stepAction = new C(U.Uint32);
|
|
710
743
|
/** Records the parent world matrix for each step (used by updateMatrix). */
|
|
711
|
-
stepParentM = new
|
|
744
|
+
stepParentM = new C(U.Uint32);
|
|
712
745
|
/** Buffer used during hierarchy traversal updates. */
|
|
713
|
-
parentStack = new
|
|
746
|
+
parentStack = new C(U.Uint32);
|
|
714
747
|
/** The index of the current local matrix in the matrix store. */
|
|
715
748
|
curLocalM = -1;
|
|
716
749
|
/** The index of the current world matrix in the matrix store. */
|
|
@@ -744,16 +777,16 @@ class St {
|
|
|
744
777
|
* @param step - The initial step to update matrices from.
|
|
745
778
|
*/
|
|
746
779
|
updateMatrix(t) {
|
|
747
|
-
const e = (typeof t == "number" ? t : t.step) - 1,
|
|
748
|
-
let
|
|
780
|
+
const e = (typeof t == "number" ? t : t.step) - 1, r = this.stepParentM.get(e);
|
|
781
|
+
let i = 0, s = e;
|
|
749
782
|
const a = this.parentStack;
|
|
750
|
-
for (a.reset(), a.push(
|
|
751
|
-
if (this.stepAction.get(
|
|
752
|
-
const h = this.stepWorldM.get(
|
|
753
|
-
this.matrix.multiplyOut(h, u, c), a.push(h),
|
|
754
|
-
} else if (a.pop(),
|
|
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++;
|
|
787
|
+
} else if (a.pop(), i--, i === 0)
|
|
755
788
|
break;
|
|
756
|
-
|
|
789
|
+
s++;
|
|
757
790
|
}
|
|
758
791
|
}
|
|
759
792
|
/**
|
|
@@ -796,8 +829,8 @@ class St {
|
|
|
796
829
|
* @param offsetX - The x component of the pivot point in local space.
|
|
797
830
|
* @param offsetY - The y component of the pivot point in local space.
|
|
798
831
|
*/
|
|
799
|
-
rotateWithOffset(t, e,
|
|
800
|
-
this.matrix.rotateWithOffset(this.curLocalM, t, e,
|
|
832
|
+
rotateWithOffset(t, e, r) {
|
|
833
|
+
this.matrix.rotateWithOffset(this.curLocalM, t, e, r), this.matrix.rotateWithOffset(this.curWorldM, t, e, r);
|
|
801
834
|
}
|
|
802
835
|
/**
|
|
803
836
|
* Sets the current local and world matrices to the identity matrix.
|
|
@@ -859,57 +892,69 @@ class St {
|
|
|
859
892
|
* Returns the current world matrix as Float32Array [a, b, c, d, tx, ty].
|
|
860
893
|
*/
|
|
861
894
|
getTransform() {
|
|
862
|
-
const t = this.curWorldM *
|
|
863
|
-
return this.matrix.data.slice(t, t +
|
|
895
|
+
const t = this.curWorldM * E;
|
|
896
|
+
return this.matrix.data.slice(t, t + E);
|
|
864
897
|
}
|
|
865
898
|
/**
|
|
866
899
|
* Directly overwrites the current world matrix with the given 6-element 2D transform.
|
|
867
900
|
*/
|
|
868
901
|
setTransform(t) {
|
|
869
|
-
const e = this.curWorldM *
|
|
870
|
-
|
|
902
|
+
const e = this.curWorldM * E, r = this.matrix.data;
|
|
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];
|
|
871
904
|
}
|
|
872
905
|
transformPoint(t, e) {
|
|
873
906
|
return this.matrix.transformPoint(this.curLocalM, t, e);
|
|
874
907
|
}
|
|
875
908
|
/**
|
|
876
909
|
* Applies a transform options object to the current matrix state.
|
|
877
|
-
* Optionally saves the matrix first
|
|
878
|
-
*/
|
|
879
|
-
applyTransform(t, e = 0, i =
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
910
|
+
* Optionally saves the matrix first
|
|
911
|
+
*/
|
|
912
|
+
applyTransform(t, e = 0, r = 0, i = -1) {
|
|
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));
|
|
918
|
+
const u = t.rotation ?? 0;
|
|
919
|
+
let l = t.offsetX ?? 0, d = t.offsetY ?? 0;
|
|
920
|
+
t.offset && (l += t.offset.x, d += t.offset.y);
|
|
921
|
+
const f = t.origin;
|
|
922
|
+
f !== void 0 && (typeof f == "number" ? (l -= f * e, d -= f * r) : (l -= f.x * e, d -= f.y * r));
|
|
923
|
+
const x = u ? Math.cos(u) : 1, g = u ? Math.sin(u) : 0, v = x * o, T = g * o, A = -g * h, R = x * h, S = s + v * l + A * d, P = a + T * l + R * d;
|
|
924
|
+
if (i !== -1) {
|
|
925
|
+
this.matrix.multiplyAffine(
|
|
926
|
+
this.curWorldM,
|
|
927
|
+
i,
|
|
928
|
+
v,
|
|
929
|
+
T,
|
|
930
|
+
A,
|
|
931
|
+
R,
|
|
932
|
+
S,
|
|
933
|
+
P
|
|
934
|
+
);
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
this.matrix.multiplyAffineInPlace(
|
|
893
938
|
this.curLocalM,
|
|
894
|
-
|
|
939
|
+
v,
|
|
895
940
|
T,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
941
|
+
A,
|
|
942
|
+
R,
|
|
943
|
+
S,
|
|
944
|
+
P
|
|
900
945
|
), this.matrix.multiplyAffineInPlace(
|
|
901
946
|
this.curWorldM,
|
|
902
|
-
|
|
947
|
+
v,
|
|
903
948
|
T,
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
)
|
|
949
|
+
A,
|
|
950
|
+
R,
|
|
951
|
+
S,
|
|
952
|
+
P
|
|
953
|
+
);
|
|
909
954
|
}
|
|
910
955
|
}
|
|
911
|
-
var
|
|
912
|
-
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 {
|
|
913
958
|
render;
|
|
914
959
|
cache = /* @__PURE__ */ new Map();
|
|
915
960
|
constructor(t) {
|
|
@@ -922,14 +967,14 @@ class bt {
|
|
|
922
967
|
* @returns A promise that resolves to the loaded Texture.
|
|
923
968
|
*/
|
|
924
969
|
async load(t, e) {
|
|
925
|
-
let
|
|
926
|
-
if (
|
|
927
|
-
return new
|
|
970
|
+
let r = this.cache.get(t);
|
|
971
|
+
if (r)
|
|
972
|
+
return new F(r);
|
|
928
973
|
try {
|
|
929
|
-
const
|
|
930
|
-
return
|
|
931
|
-
} catch (
|
|
932
|
-
throw console.error(`[TextureManager] Failed to load: ${t}`,
|
|
974
|
+
const i = await this._fetchImage(t);
|
|
975
|
+
return r = Y.fromSource(this.render, i, e), r.uid = t, this.cache.set(t, r), new F(r);
|
|
976
|
+
} catch (i) {
|
|
977
|
+
throw console.error(`[TextureManager] Failed to load: ${t}`, i), i;
|
|
933
978
|
}
|
|
934
979
|
}
|
|
935
980
|
/**
|
|
@@ -940,9 +985,9 @@ class bt {
|
|
|
940
985
|
*/
|
|
941
986
|
create(t, e) {
|
|
942
987
|
if (e?.key && this.cache.has(e.key))
|
|
943
|
-
return new
|
|
944
|
-
const
|
|
945
|
-
return e?.key && (
|
|
988
|
+
return new F(this.cache.get(e.key));
|
|
989
|
+
const r = Y.fromSource(this.render, t, e);
|
|
990
|
+
return e?.key && (r.uid = e.key, this.cache.set(e.key, r)), new F(r);
|
|
946
991
|
}
|
|
947
992
|
/**
|
|
948
993
|
* Creates a generic Render Texture (FrameBuffer).
|
|
@@ -952,7 +997,7 @@ class bt {
|
|
|
952
997
|
* @returns The newly created RenderTexture.
|
|
953
998
|
*/
|
|
954
999
|
createRenderTexture(t) {
|
|
955
|
-
return new
|
|
1000
|
+
return new bt(this.render, t);
|
|
956
1001
|
}
|
|
957
1002
|
/**
|
|
958
1003
|
* Creates a TextTexture for rendering text.
|
|
@@ -960,7 +1005,7 @@ class bt {
|
|
|
960
1005
|
* @returns The newly created TextTexture.
|
|
961
1006
|
*/
|
|
962
1007
|
createTextTexture(t) {
|
|
963
|
-
return new
|
|
1008
|
+
return new Ct(this.render, t);
|
|
964
1009
|
}
|
|
965
1010
|
/**
|
|
966
1011
|
* Destroys a texture and potentially removes its BaseTexture from the cache.
|
|
@@ -970,8 +1015,8 @@ class bt {
|
|
|
970
1015
|
* @param force - If true, destroys the underlying BaseTexture immediately regardless of reference count.
|
|
971
1016
|
*/
|
|
972
1017
|
destroy(t, e = !1) {
|
|
973
|
-
let
|
|
974
|
-
typeof t == "string" ? (
|
|
1018
|
+
let r, i;
|
|
1019
|
+
typeof t == "string" ? (i = t, r = this.cache.get(i)) : t instanceof F ? (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));
|
|
975
1020
|
}
|
|
976
1021
|
/**
|
|
977
1022
|
* Destroys all cached textures and clears the cache, ignoring reference counts.
|
|
@@ -982,20 +1027,20 @@ class bt {
|
|
|
982
1027
|
this.cache.clear();
|
|
983
1028
|
}
|
|
984
1029
|
_fetchImage(t) {
|
|
985
|
-
return new Promise((e,
|
|
986
|
-
const
|
|
987
|
-
|
|
1030
|
+
return new Promise((e, r) => {
|
|
1031
|
+
const i = new Image();
|
|
1032
|
+
i.crossOrigin = "anonymous", i.onload = () => e(i), i.onerror = () => r(new Error(`Failed to load image resource: ${t}`)), i.src = t;
|
|
988
1033
|
});
|
|
989
1034
|
}
|
|
990
1035
|
}
|
|
991
|
-
class
|
|
1036
|
+
class Y {
|
|
992
1037
|
glTexture = null;
|
|
993
1038
|
width;
|
|
994
1039
|
height;
|
|
995
1040
|
uid;
|
|
996
1041
|
refCount = 0;
|
|
997
|
-
constructor(t, e,
|
|
998
|
-
this.glTexture = t, this.width = e, this.height =
|
|
1042
|
+
constructor(t, e, r) {
|
|
1043
|
+
this.glTexture = t, this.width = e, this.height = r;
|
|
999
1044
|
}
|
|
1000
1045
|
/**
|
|
1001
1046
|
* Creates a BaseTexture from an image source.
|
|
@@ -1004,9 +1049,9 @@ class k {
|
|
|
1004
1049
|
* @param options - Optional configuration.
|
|
1005
1050
|
* @returns The created BaseTexture.
|
|
1006
1051
|
*/
|
|
1007
|
-
static fromSource(t, e,
|
|
1008
|
-
const
|
|
1009
|
-
return new
|
|
1052
|
+
static fromSource(t, e, r = {}) {
|
|
1053
|
+
const i = J(t, e, r);
|
|
1054
|
+
return new Y(i, e.width, e.height);
|
|
1010
1055
|
}
|
|
1011
1056
|
/**
|
|
1012
1057
|
* Updates the content of the existing texture (e.g. for Video or dynamic Canvas).
|
|
@@ -1014,20 +1059,20 @@ class k {
|
|
|
1014
1059
|
* @param gl - The WebGL rendering context.
|
|
1015
1060
|
* @param source - The new image source.
|
|
1016
1061
|
*/
|
|
1017
|
-
updateSource(t, e,
|
|
1018
|
-
this.glTexture && (t.bindTexture(t.TEXTURE_2D, this.glTexture),
|
|
1062
|
+
updateSource(t, e, r = {}) {
|
|
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));
|
|
1019
1064
|
}
|
|
1020
1065
|
/**
|
|
1021
1066
|
* Dynamically updates the texture filtering mode.
|
|
1022
1067
|
*/
|
|
1023
1068
|
setFilterMode(t, e) {
|
|
1024
|
-
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));
|
|
1025
1070
|
}
|
|
1026
1071
|
/**
|
|
1027
1072
|
* Dynamically updates the texture wrap mode.
|
|
1028
1073
|
*/
|
|
1029
1074
|
setWrapMode(t, e) {
|
|
1030
|
-
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));
|
|
1031
1076
|
}
|
|
1032
1077
|
/**
|
|
1033
1078
|
* Destroys the WebGL texture resource.
|
|
@@ -1037,7 +1082,7 @@ class k {
|
|
|
1037
1082
|
this.glTexture && (t.deleteTexture(this.glTexture), this.glTexture = null);
|
|
1038
1083
|
}
|
|
1039
1084
|
}
|
|
1040
|
-
class
|
|
1085
|
+
class F {
|
|
1041
1086
|
base;
|
|
1042
1087
|
uvX = 0;
|
|
1043
1088
|
uvY = 0;
|
|
@@ -1082,8 +1127,8 @@ class P {
|
|
|
1082
1127
|
* @param h - The height in pixels.
|
|
1083
1128
|
* @returns The current Texture instance.
|
|
1084
1129
|
*/
|
|
1085
|
-
setRegion(t, e,
|
|
1086
|
-
return this.base ? (this._px = t, this._py = e, this._pw =
|
|
1130
|
+
setRegion(t, e, r, i) {
|
|
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.rawHeight = i, this) : this;
|
|
1087
1132
|
}
|
|
1088
1133
|
/**
|
|
1089
1134
|
* Creates a new Texture representing a sub-region of this Texture.
|
|
@@ -1093,17 +1138,17 @@ class P {
|
|
|
1093
1138
|
* @param height - The height of the sub-texture in pixels.
|
|
1094
1139
|
* @returns A new Texture pointing to the sub-region.
|
|
1095
1140
|
*/
|
|
1096
|
-
getSubTexture(t, e,
|
|
1097
|
-
if (!this.base) return new
|
|
1098
|
-
const
|
|
1099
|
-
return
|
|
1141
|
+
getSubTexture(t, e, r, i) {
|
|
1142
|
+
if (!this.base) return new F();
|
|
1143
|
+
const s = this.clone(), a = this._px, o = this._py;
|
|
1144
|
+
return s.setRegion(a + t, o + e, r, i), s;
|
|
1100
1145
|
}
|
|
1101
1146
|
/**
|
|
1102
1147
|
* Creates a shallow copy of this Texture, sharing the same BaseTexture.
|
|
1103
1148
|
* @returns A new Texture instance.
|
|
1104
1149
|
*/
|
|
1105
1150
|
clone(t) {
|
|
1106
|
-
const e = t ?? new
|
|
1151
|
+
const e = t ?? new F(this.base);
|
|
1107
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;
|
|
1108
1153
|
}
|
|
1109
1154
|
/**
|
|
@@ -1116,12 +1161,12 @@ class P {
|
|
|
1116
1161
|
* @param gap - Optional pixel gap between cells.
|
|
1117
1162
|
* @returns An array of split Textures.
|
|
1118
1163
|
*/
|
|
1119
|
-
splitGrid(t, e,
|
|
1164
|
+
splitGrid(t, e, r, i, s = 0) {
|
|
1120
1165
|
if (!this.base) return [];
|
|
1121
|
-
const a = [], o = this.rawWidth, h = this.rawHeight, c = Math.max(0,
|
|
1122
|
-
for (let x = 0; x <
|
|
1123
|
-
for (let g = 0; g <
|
|
1124
|
-
a.push(this.getSubTexture(g * u, x *
|
|
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 x = 0; x < f; x++)
|
|
1168
|
+
for (let g = 0; g < d; g++)
|
|
1169
|
+
a.push(this.getSubTexture(g * u, x * l, t, e));
|
|
1125
1170
|
return a;
|
|
1126
1171
|
}
|
|
1127
1172
|
/**
|
|
@@ -1129,9 +1174,9 @@ class P {
|
|
|
1129
1174
|
* @param source - The image element, canvas, video, or bitmap.
|
|
1130
1175
|
* @param options - Optional antialias and wrap mode settings.
|
|
1131
1176
|
*/
|
|
1132
|
-
static fromImageSource(t, e,
|
|
1133
|
-
const
|
|
1134
|
-
return new
|
|
1177
|
+
static fromImageSource(t, e, r = {}) {
|
|
1178
|
+
const i = J(t, e, r);
|
|
1179
|
+
return new F(new Y(i, e.width, e.height));
|
|
1135
1180
|
}
|
|
1136
1181
|
/**
|
|
1137
1182
|
* Marks this Texture as destroyed, decrementing the BaseTexture reference count.
|
|
@@ -1140,7 +1185,7 @@ class P {
|
|
|
1140
1185
|
this.base && (this.base.refCount--, this.base = void 0), this.glTexture = null;
|
|
1141
1186
|
}
|
|
1142
1187
|
}
|
|
1143
|
-
class
|
|
1188
|
+
class bt extends F {
|
|
1144
1189
|
framebuffer;
|
|
1145
1190
|
renderbuffer;
|
|
1146
1191
|
gl;
|
|
@@ -1151,10 +1196,10 @@ class At extends P {
|
|
|
1151
1196
|
_allocH = 0;
|
|
1152
1197
|
constructor(t, e) {
|
|
1153
1198
|
super(), this.gl = t.gl, this.clearColor = e.clearColor ?? m.Black;
|
|
1154
|
-
const
|
|
1155
|
-
if (this.setBase(new
|
|
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 Y(a, r, i)), this.framebuffer = this.gl.createFramebuffer(), this.renderbuffer = this.gl.createRenderbuffer(), !this.framebuffer || !this.renderbuffer)
|
|
1156
1201
|
throw new Error("Failed to create Framebuffer or Renderbuffer");
|
|
1157
|
-
this.resize(
|
|
1202
|
+
this.resize(r, i, !0);
|
|
1158
1203
|
}
|
|
1159
1204
|
/**
|
|
1160
1205
|
* Resizes the render texture using a grow-only GPU allocation strategy.
|
|
@@ -1168,12 +1213,12 @@ class At extends P {
|
|
|
1168
1213
|
* @param height - New logical height.
|
|
1169
1214
|
* @param force - Force full GPU reallocation regardless of current allocation size.
|
|
1170
1215
|
*/
|
|
1171
|
-
resize(t, e,
|
|
1216
|
+
resize(t, e, r = !1) {
|
|
1172
1217
|
t = Math.max(Math.round(t), 1), e = Math.max(Math.round(e), 1);
|
|
1173
|
-
const
|
|
1174
|
-
if (!
|
|
1175
|
-
const
|
|
1176
|
-
(
|
|
1218
|
+
const i = this.rawWidth === t && this.rawHeight === e;
|
|
1219
|
+
if (!r && i) return;
|
|
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;
|
|
1177
1222
|
}
|
|
1178
1223
|
/**
|
|
1179
1224
|
* Activates this texture as the current render target.
|
|
@@ -1186,8 +1231,8 @@ class At extends P {
|
|
|
1186
1231
|
}
|
|
1187
1232
|
clear(t) {
|
|
1188
1233
|
if (!this.framebuffer) return;
|
|
1189
|
-
const e = this.gl,
|
|
1190
|
-
|
|
1234
|
+
const e = this.gl, r = t ?? this.clearColor;
|
|
1235
|
+
r && (r.setClearColor(e), e.clear(e.COLOR_BUFFER_BIT | e.STENCIL_BUFFER_BIT));
|
|
1191
1236
|
}
|
|
1192
1237
|
/**
|
|
1193
1238
|
* Deactivates this texture, returning rendering to the default frame buffer.
|
|
@@ -1203,16 +1248,16 @@ class At extends P {
|
|
|
1203
1248
|
* @param width - Width of the region to read.
|
|
1204
1249
|
* @param height - Height of the region to read.
|
|
1205
1250
|
*/
|
|
1206
|
-
GetPixels(t = 0, e = 0,
|
|
1251
|
+
GetPixels(t = 0, e = 0, r = this.rawWidth, i = this.rawHeight) {
|
|
1207
1252
|
if (!this.framebuffer) return new Uint8Array(0);
|
|
1208
|
-
const
|
|
1253
|
+
const s = Math.floor(t), a = Math.floor(e), o = Math.floor(r), h = Math.floor(i);
|
|
1209
1254
|
if (o <= 0 || h <= 0) return new Uint8Array(0);
|
|
1210
|
-
if (
|
|
1255
|
+
if (s < 0 || a < 0 || s >= this.rawWidth || a >= this.rawHeight)
|
|
1211
1256
|
return new Uint8Array(0);
|
|
1212
|
-
const c = Math.min(o, this.rawWidth -
|
|
1213
|
-
|
|
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);
|
|
1258
|
+
d.bindFramebuffer(d.FRAMEBUFFER, this.framebuffer);
|
|
1214
1259
|
const x = new Uint8Array(c * u * 4);
|
|
1215
|
-
return
|
|
1260
|
+
return d.readPixels(s, l, c, u, d.RGBA, d.UNSIGNED_BYTE, x), d.bindFramebuffer(d.FRAMEBUFFER, f), x;
|
|
1216
1261
|
}
|
|
1217
1262
|
/**
|
|
1218
1263
|
* Get the color at a pixel in the render texture.
|
|
@@ -1220,8 +1265,8 @@ class At extends P {
|
|
|
1220
1265
|
* @param y - Y coordinate in logical pixel space (top-left origin).
|
|
1221
1266
|
*/
|
|
1222
1267
|
GetColorAt(t, e) {
|
|
1223
|
-
const
|
|
1224
|
-
return
|
|
1268
|
+
const r = this.GetPixels(t, e, 1, 1);
|
|
1269
|
+
return r.length < 4 ? new m(0, 0, 0, 0) : new m(r[0], r[1], r[2], r[3]);
|
|
1225
1270
|
}
|
|
1226
1271
|
/**
|
|
1227
1272
|
* Destroys the framebuffer, renderbuffer, and base texture.
|
|
@@ -1239,7 +1284,7 @@ const Ut = {
|
|
|
1239
1284
|
align: "left",
|
|
1240
1285
|
baseline: "top"
|
|
1241
1286
|
};
|
|
1242
|
-
class
|
|
1287
|
+
class Ct extends F {
|
|
1243
1288
|
canvas;
|
|
1244
1289
|
ctx;
|
|
1245
1290
|
render;
|
|
@@ -1249,11 +1294,11 @@ class _t extends P {
|
|
|
1249
1294
|
flipY = !0;
|
|
1250
1295
|
constructor(t, e) {
|
|
1251
1296
|
super(), this.render = t, this._style = { ...Ut, ...e }, this._text = e?.text ?? "", this.options = { premultipliedAlpha: t.premultipliedAlpha, ...e }, this.scale = 1 / t.dpr, this.canvas = document.createElement("canvas");
|
|
1252
|
-
const
|
|
1253
|
-
if (!
|
|
1254
|
-
this.ctx =
|
|
1255
|
-
const
|
|
1256
|
-
this.setBase(new
|
|
1297
|
+
const r = this.canvas.getContext("2d", { willReadFrequently: !0 });
|
|
1298
|
+
if (!r) throw new Error("Failed to get 2d context for TextTexture");
|
|
1299
|
+
this.ctx = r, this.canvas.width = 1, this.canvas.height = 1;
|
|
1300
|
+
const i = J(t, this.canvas, this.options);
|
|
1301
|
+
this.setBase(new Y(i, 1, 1)), this.update();
|
|
1257
1302
|
}
|
|
1258
1303
|
get text() {
|
|
1259
1304
|
return this._text;
|
|
@@ -1301,97 +1346,97 @@ class _t extends P {
|
|
|
1301
1346
|
* Updates the internal canvas and uploads it to WebGL
|
|
1302
1347
|
*/
|
|
1303
1348
|
update() {
|
|
1304
|
-
const t = this.ctx, e = this._style.fontSize,
|
|
1305
|
-
t.font =
|
|
1349
|
+
const t = this.ctx, e = this._style.fontSize, r = this._style.fontWeight, i = this._style.fontFamily, s = `${r} ${e}px ${i}`, a = this.render.dpr;
|
|
1350
|
+
t.font = s;
|
|
1306
1351
|
const o = this._text.split(`
|
|
1307
1352
|
`);
|
|
1308
1353
|
let h = 0, c = 0;
|
|
1309
1354
|
t.textBaseline = "alphabetic";
|
|
1310
|
-
const u = t.measureText(o[0]),
|
|
1311
|
-
for (const
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1355
|
+
const u = t.measureText(o[0]), l = u.fontBoundingBoxAscent, d = u.fontBoundingBoxDescent;
|
|
1356
|
+
for (const R of o) {
|
|
1357
|
+
const S = t.measureText(R);
|
|
1358
|
+
S.width > h && (h = S.width), c += l + d;
|
|
1314
1359
|
}
|
|
1315
|
-
c -=
|
|
1316
|
-
const
|
|
1317
|
-
(this.canvas.width !==
|
|
1318
|
-
let
|
|
1319
|
-
for (const
|
|
1320
|
-
let
|
|
1321
|
-
this._style.stroke && this._style.strokeThickness > 0 && (t.lineWidth = this._style.strokeThickness, t.strokeStyle = this._style.stroke, t.strokeText(
|
|
1360
|
+
c -= d;
|
|
1361
|
+
const f = (this._style.strokeThickness || 0) * 2, x = Math.ceil(h + f) || 1, g = Math.ceil(c + f) || 1, v = x * a, T = g * a;
|
|
1362
|
+
(this.canvas.width !== v || this.canvas.height !== T) && (this.canvas.width = v, this.canvas.height = T), t.setTransform(a, 0, 0, a, 0, 0), t.clearRect(0, 0, x, g), t.font = s, t.textBaseline = "top", t.textAlign = "left", this.updateOffset(x, g);
|
|
1363
|
+
let A = f / 2;
|
|
1364
|
+
for (const R of o) {
|
|
1365
|
+
let S = f / 2;
|
|
1366
|
+
this._style.stroke && this._style.strokeThickness > 0 && (t.lineWidth = this._style.strokeThickness, t.strokeStyle = this._style.stroke, t.strokeText(R, S, A)), this._style.fill && (t.fillStyle = this._style.fill, t.fillText(R, S, A)), A += l + d;
|
|
1322
1367
|
}
|
|
1323
1368
|
this.base?.updateSource(this.render.gl, this.canvas, this.options), this.setRegion(0, 0, this.canvas.width, this.canvas.height);
|
|
1324
1369
|
}
|
|
1325
1370
|
}
|
|
1326
|
-
const
|
|
1327
|
-
const
|
|
1328
|
-
if (!
|
|
1371
|
+
const _t = (n, t = !1, e = !0) => {
|
|
1372
|
+
const r = n.getContext("webgl2", { stencil: !0, antialias: t, premultipliedAlpha: e });
|
|
1373
|
+
if (!r)
|
|
1329
1374
|
throw new Error("WebGL2 is not supported in this browser.");
|
|
1330
|
-
return
|
|
1331
|
-
},
|
|
1332
|
-
const
|
|
1333
|
-
if (!
|
|
1375
|
+
return r;
|
|
1376
|
+
}, ot = (n, t, e) => {
|
|
1377
|
+
const r = n.createShader(e);
|
|
1378
|
+
if (!r)
|
|
1334
1379
|
throw new Error("Unable to create webgl shader");
|
|
1335
|
-
if (
|
|
1336
|
-
const
|
|
1337
|
-
throw console.error("Shader compilation failed:",
|
|
1380
|
+
if (n.shaderSource(r, t), n.compileShader(r), !n.getShaderParameter(r, n.COMPILE_STATUS)) {
|
|
1381
|
+
const s = n.getShaderInfoLog(r);
|
|
1382
|
+
throw console.error("Shader compilation failed:", s), new Error("Unable to compile shader: " + s + t);
|
|
1338
1383
|
}
|
|
1339
|
-
return
|
|
1340
|
-
}, Pt = (
|
|
1341
|
-
var
|
|
1342
|
-
if (!
|
|
1384
|
+
return r;
|
|
1385
|
+
}, Pt = (n, t, e) => {
|
|
1386
|
+
var r = n.createProgram(), i = ot(n, t, 35633), s = ot(n, e, 35632);
|
|
1387
|
+
if (!r)
|
|
1343
1388
|
throw new Error("Unable to create program shader");
|
|
1344
|
-
if (
|
|
1345
|
-
const o =
|
|
1389
|
+
if (n.attachShader(r, i), n.attachShader(r, s), n.linkProgram(r), !n.getProgramParameter(r, n.LINK_STATUS)) {
|
|
1390
|
+
const o = n.getProgramInfoLog(r);
|
|
1346
1391
|
throw new Error("Unable to link shader program: " + o);
|
|
1347
1392
|
}
|
|
1348
|
-
return
|
|
1393
|
+
return r;
|
|
1349
1394
|
};
|
|
1350
|
-
function
|
|
1395
|
+
function rt(n, t) {
|
|
1351
1396
|
const e = {
|
|
1352
|
-
[
|
|
1353
|
-
[
|
|
1354
|
-
[
|
|
1355
|
-
}[t] ||
|
|
1356
|
-
|
|
1397
|
+
[q.CLAMP]: n.CLAMP_TO_EDGE,
|
|
1398
|
+
[q.REPEAT]: n.REPEAT,
|
|
1399
|
+
[q.MIRRORED_REPEAT]: n.MIRRORED_REPEAT
|
|
1400
|
+
}[t] || n.CLAMP_TO_EDGE;
|
|
1401
|
+
n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, e), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, e);
|
|
1357
1402
|
}
|
|
1358
|
-
function
|
|
1403
|
+
function it(n, t) {
|
|
1359
1404
|
const e = {
|
|
1360
|
-
[
|
|
1361
|
-
[
|
|
1362
|
-
}[t] ??
|
|
1363
|
-
|
|
1405
|
+
[nt.LINEAR]: n.LINEAR,
|
|
1406
|
+
[nt.NEAREST]: n.NEAREST
|
|
1407
|
+
}[t] ?? n.NEAREST;
|
|
1408
|
+
n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, e), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, e);
|
|
1364
1409
|
}
|
|
1365
|
-
function
|
|
1366
|
-
const
|
|
1367
|
-
if (!
|
|
1410
|
+
function J(n, t, e) {
|
|
1411
|
+
const r = n.gl, i = r.createTexture();
|
|
1412
|
+
if (!i)
|
|
1368
1413
|
throw new Error("Unable to create WebGL texture");
|
|
1369
|
-
if (
|
|
1370
|
-
const
|
|
1371
|
-
|
|
1414
|
+
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) {
|
|
1415
|
+
const s = t;
|
|
1416
|
+
r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, s.width, s.height, 0, r.RGBA, r.UNSIGNED_BYTE, null);
|
|
1372
1417
|
} else {
|
|
1373
|
-
const
|
|
1374
|
-
|
|
1418
|
+
const s = e.premultipliedAlpha ?? n.premultipliedAlpha;
|
|
1419
|
+
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);
|
|
1375
1420
|
}
|
|
1376
|
-
return
|
|
1421
|
+
return r.bindTexture(r.TEXTURE_2D, null), i;
|
|
1377
1422
|
}
|
|
1378
|
-
function
|
|
1379
|
-
if (
|
|
1423
|
+
function G(n, t) {
|
|
1424
|
+
if (n.includes("%TEXTURE_NUM%") && (n = n.replace("%TEXTURE_NUM%", t.toString())), n.includes("%GET_COLOR%")) {
|
|
1380
1425
|
let e = "";
|
|
1381
|
-
for (let
|
|
1382
|
-
|
|
1383
|
-
|
|
1426
|
+
for (let r = 0; r < t; r++)
|
|
1427
|
+
r == 0 ? e += `if(vTextureId == ${r})` : r == t - 1 ? e += "else" : e += `else if(vTextureId == ${r})`, e += `{return texture(uTextures[${r}], uv);}`;
|
|
1428
|
+
n = n.replace("%GET_COLOR%", e);
|
|
1384
1429
|
}
|
|
1385
|
-
return
|
|
1430
|
+
return n;
|
|
1386
1431
|
}
|
|
1387
|
-
const Nt = 5126,
|
|
1388
|
-
function Lt(
|
|
1389
|
-
|
|
1432
|
+
const Nt = 5126, st = 5121;
|
|
1433
|
+
function Lt(n, t, e) {
|
|
1434
|
+
n.vertexAttribDivisor(t, e);
|
|
1390
1435
|
}
|
|
1391
|
-
function
|
|
1392
|
-
|
|
1436
|
+
function yt(n, t, e, r, i) {
|
|
1437
|
+
n.drawArraysInstanced(t, e, r, i);
|
|
1393
1438
|
}
|
|
1394
|
-
let
|
|
1439
|
+
let It = 0;
|
|
1395
1440
|
class Tt {
|
|
1396
1441
|
program;
|
|
1397
1442
|
attributeLoc = {};
|
|
@@ -1404,11 +1449,11 @@ class Tt {
|
|
|
1404
1449
|
/** Whether the uniform is an array (e.g. sampler2D uTextures[8]) */
|
|
1405
1450
|
uniformIsArray = {};
|
|
1406
1451
|
gl;
|
|
1407
|
-
shaderId =
|
|
1452
|
+
shaderId = It++;
|
|
1408
1453
|
// for debug
|
|
1409
1454
|
vao;
|
|
1410
|
-
constructor(t, e,
|
|
1411
|
-
this.gl = t, this.program = Pt(t, e,
|
|
1455
|
+
constructor(t, e, r, i) {
|
|
1456
|
+
this.gl = t, this.program = Pt(t, e, r), this.parseShader(e), this.parseShader(r), this.vao = t.createVertexArray(), i && this.setAttributes(i);
|
|
1412
1457
|
}
|
|
1413
1458
|
/** Switch GPU to use this shader program */
|
|
1414
1459
|
use() {
|
|
@@ -1431,10 +1476,10 @@ class Tt {
|
|
|
1431
1476
|
* shader.setUniform("uMVP", mat4array);
|
|
1432
1477
|
*/
|
|
1433
1478
|
setUniform(t, e) {
|
|
1434
|
-
const
|
|
1435
|
-
if (
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1479
|
+
const r = this.uniformLoc[t];
|
|
1480
|
+
if (r === void 0) return;
|
|
1481
|
+
const i = this.uniformType[t], s = this.uniformIsArray[t];
|
|
1482
|
+
Ot(this.gl, r, i, e, s);
|
|
1438
1483
|
}
|
|
1439
1484
|
/**
|
|
1440
1485
|
* Batch-set uniforms via a plain value map.
|
|
@@ -1457,15 +1502,15 @@ class Tt {
|
|
|
1457
1502
|
setAttribute(t) {
|
|
1458
1503
|
const e = this.attributeLoc[t.name];
|
|
1459
1504
|
if (e === void 0) return;
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1505
|
+
const r = this.gl;
|
|
1506
|
+
r.vertexAttribPointer(
|
|
1462
1507
|
e,
|
|
1463
1508
|
t.size,
|
|
1464
1509
|
t.type ?? Nt,
|
|
1465
1510
|
t.normalized ?? !1,
|
|
1466
1511
|
t.stride,
|
|
1467
1512
|
t.offset ?? 0
|
|
1468
|
-
),
|
|
1513
|
+
), r.enableVertexAttribArray(e), Lt(r, e, t.divisor ?? 0);
|
|
1469
1514
|
}
|
|
1470
1515
|
/** Bind all vertex attribute pointers at once */
|
|
1471
1516
|
setAttributes(t) {
|
|
@@ -1479,79 +1524,79 @@ class Tt {
|
|
|
1479
1524
|
}
|
|
1480
1525
|
/** Parse attribute/uniform names and GLSL types from raw shader source */
|
|
1481
1526
|
parseShader(t) {
|
|
1482
|
-
const e = this.gl,
|
|
1483
|
-
if (
|
|
1484
|
-
for (const
|
|
1485
|
-
const o =
|
|
1527
|
+
const e = this.gl, r = t.match(/(?:in|attribute)\s+\w+\s+\w+/g);
|
|
1528
|
+
if (r)
|
|
1529
|
+
for (const s of r) {
|
|
1530
|
+
const o = s.split(/\s+/)[2], h = e.getAttribLocation(this.program, o);
|
|
1486
1531
|
h !== -1 && (this.attributeLoc[o] = h);
|
|
1487
1532
|
}
|
|
1488
|
-
const
|
|
1489
|
-
if (
|
|
1490
|
-
for (const
|
|
1491
|
-
const a =
|
|
1533
|
+
const i = t.match(/uniform\s+\w+\s+\w+(?:\[\d+\])?/g);
|
|
1534
|
+
if (i)
|
|
1535
|
+
for (const s of i) {
|
|
1536
|
+
const a = s.split(/\s+/), o = a[1], h = a[2].replace(/\[\d+\]$/, ""), c = e.getUniformLocation(this.program, h);
|
|
1492
1537
|
c !== null && (this.uniformLoc[h] = c, this.uniformType[h] = o, this.uniformIsArray[h] = /\[\d+\]$/.test(a[2]));
|
|
1493
1538
|
}
|
|
1494
1539
|
}
|
|
1495
1540
|
}
|
|
1496
|
-
function
|
|
1541
|
+
function Ot(n, t, e, r, i = !1) {
|
|
1497
1542
|
switch (e) {
|
|
1498
1543
|
// scalars
|
|
1499
1544
|
case "float":
|
|
1500
|
-
return
|
|
1545
|
+
return n.uniform1f(t, r);
|
|
1501
1546
|
case "int":
|
|
1502
1547
|
case "bool":
|
|
1503
1548
|
case "sampler2D":
|
|
1504
1549
|
case "samplerCube":
|
|
1505
|
-
return
|
|
1550
|
+
return i ? n.uniform1iv(t, r) : n.uniform1i(t, r);
|
|
1506
1551
|
// float vectors
|
|
1507
1552
|
case "vec2":
|
|
1508
|
-
return
|
|
1553
|
+
return n.uniform2fv(t, r);
|
|
1509
1554
|
case "vec3":
|
|
1510
|
-
return
|
|
1555
|
+
return n.uniform3fv(t, r);
|
|
1511
1556
|
case "vec4":
|
|
1512
|
-
return
|
|
1557
|
+
return n.uniform4fv(t, r);
|
|
1513
1558
|
// int / bool vectors
|
|
1514
1559
|
case "ivec2":
|
|
1515
1560
|
case "bvec2":
|
|
1516
|
-
return
|
|
1561
|
+
return n.uniform2iv(t, r);
|
|
1517
1562
|
case "ivec3":
|
|
1518
1563
|
case "bvec3":
|
|
1519
|
-
return
|
|
1564
|
+
return n.uniform3iv(t, r);
|
|
1520
1565
|
case "ivec4":
|
|
1521
1566
|
case "bvec4":
|
|
1522
|
-
return
|
|
1567
|
+
return n.uniform4iv(t, r);
|
|
1523
1568
|
// matrices (column-major, transpose = false)
|
|
1524
1569
|
case "mat2":
|
|
1525
|
-
return
|
|
1570
|
+
return n.uniformMatrix2fv(t, !1, r);
|
|
1526
1571
|
case "mat3":
|
|
1527
|
-
return
|
|
1572
|
+
return n.uniformMatrix3fv(t, !1, r);
|
|
1528
1573
|
case "mat4":
|
|
1529
|
-
return
|
|
1574
|
+
return n.uniformMatrix4fv(t, !1, r);
|
|
1530
1575
|
// fallback: guess by value shape
|
|
1531
1576
|
default:
|
|
1532
|
-
return
|
|
1577
|
+
return Ft(n, t, r);
|
|
1533
1578
|
}
|
|
1534
1579
|
}
|
|
1535
|
-
function
|
|
1580
|
+
function Ft(n, t, e) {
|
|
1536
1581
|
if (typeof e == "number")
|
|
1537
|
-
return
|
|
1538
|
-
const
|
|
1539
|
-
switch (
|
|
1582
|
+
return n.uniform1f(t, e);
|
|
1583
|
+
const r = e;
|
|
1584
|
+
switch (r.length) {
|
|
1540
1585
|
case 2:
|
|
1541
|
-
return
|
|
1586
|
+
return n.uniform2fv(t, r);
|
|
1542
1587
|
case 3:
|
|
1543
|
-
return
|
|
1588
|
+
return n.uniform3fv(t, r);
|
|
1544
1589
|
case 4:
|
|
1545
|
-
return
|
|
1590
|
+
return n.uniform4fv(t, r);
|
|
1546
1591
|
case 9:
|
|
1547
|
-
return
|
|
1592
|
+
return n.uniformMatrix3fv(t, !1, r);
|
|
1548
1593
|
case 16:
|
|
1549
|
-
return
|
|
1594
|
+
return n.uniformMatrix4fv(t, !1, r);
|
|
1550
1595
|
default:
|
|
1551
|
-
return
|
|
1596
|
+
return n.uniform1fv(t, r);
|
|
1552
1597
|
}
|
|
1553
1598
|
}
|
|
1554
|
-
class
|
|
1599
|
+
class ct {
|
|
1555
1600
|
/** Custom vertex shader code */
|
|
1556
1601
|
vs;
|
|
1557
1602
|
/** Custom fragment shader code */
|
|
@@ -1569,8 +1614,8 @@ class ot {
|
|
|
1569
1614
|
/** Padding in pixels this shader needs beyond the sprite bounds (for outline/glow effects) */
|
|
1570
1615
|
padding = 0;
|
|
1571
1616
|
rapid;
|
|
1572
|
-
constructor(t, e,
|
|
1573
|
-
this.vs = e, this.fs =
|
|
1617
|
+
constructor(t, e, r, i = 0, s) {
|
|
1618
|
+
this.vs = e, this.fs = r, this.rapid = t, this.uniforms = s ?? {}, this.usedTextureUnitNum = i;
|
|
1574
1619
|
}
|
|
1575
1620
|
/**
|
|
1576
1621
|
* Updates uniform values or textures for the custom shader.
|
|
@@ -1578,12 +1623,12 @@ class ot {
|
|
|
1578
1623
|
*/
|
|
1579
1624
|
setUniforms(t) {
|
|
1580
1625
|
this.rapid.flush();
|
|
1581
|
-
const e = {},
|
|
1582
|
-
for (const [
|
|
1583
|
-
|
|
1584
|
-
Object.assign(this.uniforms, e), Object.assign(this.uniformTextures,
|
|
1585
|
-
for (const
|
|
1586
|
-
this.uniformDirty.add(
|
|
1626
|
+
const e = {}, r = {};
|
|
1627
|
+
for (const [i, s] of Object.entries(t))
|
|
1628
|
+
s instanceof WebGLTexture ? r[i] = s : e[i] = s;
|
|
1629
|
+
Object.assign(this.uniforms, e), Object.assign(this.uniformTextures, r);
|
|
1630
|
+
for (const i of this.glshader.keys())
|
|
1631
|
+
this.uniformDirty.add(i);
|
|
1587
1632
|
}
|
|
1588
1633
|
/**
|
|
1589
1634
|
* Sets the padding (in pixels) for this shader and propagates to all compiled GLShaders.
|
|
@@ -1602,8 +1647,8 @@ class ot {
|
|
|
1602
1647
|
* @param textureUniforms Map of texture uniform names to assigned texture unit indices.
|
|
1603
1648
|
*/
|
|
1604
1649
|
applyUniform(t, e) {
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1650
|
+
const r = this.glshader.get(t);
|
|
1651
|
+
r && (Object.keys(e).length > 0 && r.setUniforms(e), this.uniformDirty.has(t) && (r.setUniforms(this.uniforms), this.uniformDirty.delete(t)));
|
|
1607
1652
|
}
|
|
1608
1653
|
/**
|
|
1609
1654
|
* Retrieves or compiles a customized GLShader for a specific region.
|
|
@@ -1613,17 +1658,17 @@ class ot {
|
|
|
1613
1658
|
* @param baseFS The base fragment shader template.
|
|
1614
1659
|
* @returns The combined and compiled GLShader.
|
|
1615
1660
|
*/
|
|
1616
|
-
getGLShader(t, e,
|
|
1661
|
+
getGLShader(t, e, r, i) {
|
|
1617
1662
|
if (this.glshader.has(e))
|
|
1618
1663
|
return this.glshader.get(e);
|
|
1619
|
-
if (
|
|
1664
|
+
if (i == null || r == null)
|
|
1620
1665
|
return console.warn("CustomGlShader: missing base shader for " + e), null;
|
|
1621
|
-
|
|
1622
|
-
const
|
|
1623
|
-
return
|
|
1666
|
+
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);
|
|
1667
|
+
const s = t.createShader(r, i);
|
|
1668
|
+
return s.isCustom = !0, s.padding = this.padding, this.glshader.set(e, s), this.uniformDirty.add(e), s;
|
|
1624
1669
|
}
|
|
1625
1670
|
}
|
|
1626
|
-
class
|
|
1671
|
+
class Et {
|
|
1627
1672
|
constructor(t) {
|
|
1628
1673
|
this.rapid = t, this.gl = t.gl, this.maxTextureUnits = t.maxTextureUnits, this.matrixStore = t.matrix;
|
|
1629
1674
|
}
|
|
@@ -1653,17 +1698,17 @@ class yt {
|
|
|
1653
1698
|
(t, e) => e
|
|
1654
1699
|
);
|
|
1655
1700
|
}
|
|
1656
|
-
findTextureUnit(t, e = 0,
|
|
1657
|
-
for (let
|
|
1658
|
-
const
|
|
1659
|
-
if (this.usedTextures[
|
|
1660
|
-
return
|
|
1701
|
+
findTextureUnit(t, e = 0, r = 0) {
|
|
1702
|
+
for (let i = 0; i < this.usedTextures.length; i++) {
|
|
1703
|
+
const s = i * 2;
|
|
1704
|
+
if (this.usedTextures[i] === t && this.usedTexturePadding[s] === e && this.usedTexturePadding[s + 1] === r)
|
|
1705
|
+
return i;
|
|
1661
1706
|
}
|
|
1662
1707
|
return -1;
|
|
1663
1708
|
}
|
|
1664
|
-
useTexture(t, e = 0,
|
|
1665
|
-
const
|
|
1666
|
-
return
|
|
1709
|
+
useTexture(t, e = 0, r = 0) {
|
|
1710
|
+
const i = this.findTextureUnit(t, e, r);
|
|
1711
|
+
return i == -1 ? (this.freeTextureUnitNum === 0 && this.flush(), this.usedTextures.push(t), this.usedTexturePadding.push(e), this.usedTexturePadding.push(r), this.usedTextures.length - 1) : i;
|
|
1667
1712
|
}
|
|
1668
1713
|
createShader(t, e) {
|
|
1669
1714
|
return new Tt(this.gl, t, e);
|
|
@@ -1674,7 +1719,7 @@ class yt {
|
|
|
1674
1719
|
getCustomShader(t) {
|
|
1675
1720
|
if (!t)
|
|
1676
1721
|
return this.defaultShader;
|
|
1677
|
-
if (t instanceof
|
|
1722
|
+
if (t instanceof ct) {
|
|
1678
1723
|
const e = this.createCustomShader(t);
|
|
1679
1724
|
return e ?? this.defaultShader;
|
|
1680
1725
|
}
|
|
@@ -1689,7 +1734,7 @@ class yt {
|
|
|
1689
1734
|
return this.isDefaultShader && !t ? !0 : this.getCustomShader(t) == this.currentShader;
|
|
1690
1735
|
}
|
|
1691
1736
|
enter(t) {
|
|
1692
|
-
this.resetRender(), this.currentShader = this.getCustomShader(t), t instanceof
|
|
1737
|
+
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);
|
|
1693
1738
|
}
|
|
1694
1739
|
exit() {
|
|
1695
1740
|
this.hasPendingContent() && this.flush(), this.gl.bindVertexArray(null);
|
|
@@ -1703,20 +1748,20 @@ class yt {
|
|
|
1703
1748
|
prepareRender() {
|
|
1704
1749
|
const t = this.currentShader;
|
|
1705
1750
|
if (t.use(), this.customShader) {
|
|
1706
|
-
const
|
|
1707
|
-
for (const
|
|
1708
|
-
|
|
1709
|
-
this.customShader.applyUniform(this.KEY,
|
|
1751
|
+
const r = this.customShader, i = {};
|
|
1752
|
+
for (const s in r.uniformTextures)
|
|
1753
|
+
i[s] = this.useTexture(r.uniformTextures[s]);
|
|
1754
|
+
this.customShader.applyUniform(this.KEY, i);
|
|
1710
1755
|
}
|
|
1711
1756
|
const e = this.gl;
|
|
1712
|
-
for (let
|
|
1713
|
-
e.activeTexture(e.TEXTURE0 +
|
|
1757
|
+
for (let r = 0; r < this.usedTextures.length; r++)
|
|
1758
|
+
e.activeTexture(e.TEXTURE0 + r), e.bindTexture(e.TEXTURE_2D, this.usedTextures[r]);
|
|
1714
1759
|
t.setUniform("uTextures", Int32Array.from(
|
|
1715
1760
|
{ length: this.usedTextures.length },
|
|
1716
|
-
(
|
|
1761
|
+
(r, i) => i
|
|
1717
1762
|
)), t.setUniform("uPadding", Float32Array.from(
|
|
1718
1763
|
{ length: this.usedTexturePadding.length },
|
|
1719
|
-
(
|
|
1764
|
+
(r, i) => this.usedTexturePadding[i]
|
|
1720
1765
|
));
|
|
1721
1766
|
}
|
|
1722
1767
|
resetRender() {
|
|
@@ -1726,8 +1771,8 @@ class yt {
|
|
|
1726
1771
|
return !1;
|
|
1727
1772
|
}
|
|
1728
1773
|
}
|
|
1729
|
-
const
|
|
1730
|
-
precision
|
|
1774
|
+
const Z = `#version 300 es\r
|
|
1775
|
+
precision highp float;\r
|
|
1731
1776
|
\r
|
|
1732
1777
|
// per-vertex\r
|
|
1733
1778
|
in vec2 aVertex;\r
|
|
@@ -1774,7 +1819,7 @@ void main(void) {\r
|
|
|
1774
1819
|
\r
|
|
1775
1820
|
gl_Position = u_projection * position;\r
|
|
1776
1821
|
}\r
|
|
1777
|
-
`,
|
|
1822
|
+
`, ut = `#version 300 es\r
|
|
1778
1823
|
precision mediump float;\r
|
|
1779
1824
|
\r
|
|
1780
1825
|
uniform sampler2D uTextures[%TEXTURE_NUM%];\r
|
|
@@ -1814,7 +1859,7 @@ vec4 sampleTextureLocal(vec2 uv){\r
|
|
|
1814
1859
|
// CUSTOM_CODE\r
|
|
1815
1860
|
\r
|
|
1816
1861
|
void main(void) {\r
|
|
1817
|
-
fragColor = sampleTexture(vRegion);\r
|
|
1862
|
+
fragColor = sampleTexture(vRegion) * vColor;\r
|
|
1818
1863
|
// if (vPadding.x != 0.0) {\r
|
|
1819
1864
|
// if (clampUV(vRegion)) {\r
|
|
1820
1865
|
// fragColor = vec4(0.0, 0.0, 0.0, 0.0);\r
|
|
@@ -1823,8 +1868,8 @@ void main(void) {\r
|
|
|
1823
1868
|
\r
|
|
1824
1869
|
// CUSTOM_CODE_CALL\r
|
|
1825
1870
|
}\r
|
|
1826
|
-
`,
|
|
1827
|
-
class
|
|
1871
|
+
`, j = 48, Wt = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
|
|
1872
|
+
class at extends Et {
|
|
1828
1873
|
instanceBuffer;
|
|
1829
1874
|
quadBuffer;
|
|
1830
1875
|
instanceCount = 0;
|
|
@@ -1836,29 +1881,29 @@ class rt extends yt {
|
|
|
1836
1881
|
}
|
|
1837
1882
|
createBuffer() {
|
|
1838
1883
|
const t = this.gl;
|
|
1839
|
-
this.quadBuffer = new
|
|
1840
|
-
for (const e of
|
|
1841
|
-
this.quadBuffer.makeDirty(), this.quadBuffer.bufferData(), this.instanceBuffer = new
|
|
1884
|
+
this.quadBuffer = new et(t, U.Float32, t.ARRAY_BUFFER, t.STATIC_DRAW), this.quadBuffer.bindBuffer();
|
|
1885
|
+
for (const e of Wt) this.quadBuffer.pushFloat32(e);
|
|
1886
|
+
this.quadBuffer.makeDirty(), this.quadBuffer.bufferData(), this.instanceBuffer = new et(t, U.Uint32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW);
|
|
1842
1887
|
}
|
|
1843
1888
|
createDefaultShader() {
|
|
1844
|
-
const t = this.rapid, e =
|
|
1845
|
-
return this.vs =
|
|
1889
|
+
const t = this.rapid, e = G(ut, t.maxTextureUnits), r = G(Z, t.maxTextureUnits);
|
|
1890
|
+
return this.vs = r, this.fs = e, this.defaultShader = this.createShader(r, e), this.defaultShader;
|
|
1846
1891
|
}
|
|
1847
1892
|
createShader(t, e) {
|
|
1848
|
-
const
|
|
1849
|
-
return
|
|
1850
|
-
{ name: "aMatrixRow0", size: 3, stride:
|
|
1851
|
-
{ name: "aMatrixRow1", size: 3, stride:
|
|
1852
|
-
{ name: "aUVRect", size: 4, stride:
|
|
1853
|
-
{ name: "aColor", size: 4, type:
|
|
1854
|
-
{ name: "aTextureId", size: 1, type:
|
|
1855
|
-
]), this.quadBuffer.bindBuffer(),
|
|
1893
|
+
const r = super.createShader(t, e);
|
|
1894
|
+
return r.use(), r.bindVAO(), this.instanceBuffer.bindBuffer(), r.setAttributes([
|
|
1895
|
+
{ name: "aMatrixRow0", size: 3, stride: j, offset: 0, divisor: 1 },
|
|
1896
|
+
{ name: "aMatrixRow1", size: 3, stride: j, offset: 12, divisor: 1 },
|
|
1897
|
+
{ name: "aUVRect", size: 4, stride: j, offset: 24, divisor: 1 },
|
|
1898
|
+
{ name: "aColor", size: 4, type: st, normalized: !0, stride: j, offset: 40, divisor: 1 },
|
|
1899
|
+
{ name: "aTextureId", size: 1, type: st, stride: j, offset: 44, divisor: 1 }
|
|
1900
|
+
]), this.quadBuffer.bindBuffer(), r.setAttributes([
|
|
1856
1901
|
{ name: "aVertex", size: 2, stride: 8, offset: 0, divisor: 0 }
|
|
1857
|
-
]),
|
|
1902
|
+
]), r.unbindVAO(), this.currentShader && this.currentShader.use(), r;
|
|
1858
1903
|
}
|
|
1859
1904
|
createCustomShader(t) {
|
|
1860
|
-
const e =
|
|
1861
|
-
return t.getGLShader(this, this.KEY,
|
|
1905
|
+
const e = G(ut, this.rapid.maxTextureUnits - t.usedTextureUnitNum), r = G(Z, this.rapid.maxTextureUnits - t.usedTextureUnitNum);
|
|
1906
|
+
return t.getGLShader(this, this.KEY, r, e);
|
|
1862
1907
|
}
|
|
1863
1908
|
/**
|
|
1864
1909
|
* Draws a textured sprite via instanced rendering to significantly improve performance.
|
|
@@ -1872,45 +1917,45 @@ class rt extends yt {
|
|
|
1872
1917
|
* @param v1 Bottom UV mapped coordinate (default 1).
|
|
1873
1918
|
* @param color The tint color as packed ABGR uniform uint32 (default 0xFFFFFFFF).
|
|
1874
1919
|
*/
|
|
1875
|
-
drawSprite(t, e,
|
|
1876
|
-
const
|
|
1920
|
+
drawSprite(t, e, r = 0, i = 0, s = 1, a = 1, o = 4294967295, h = 0, c = 0, u = !1, l = !1, d = !1) {
|
|
1921
|
+
const f = e * 6, x = this.matrixStore.data;
|
|
1877
1922
|
this.drawSpriteAffine(
|
|
1878
1923
|
t,
|
|
1879
|
-
x[
|
|
1880
|
-
x[
|
|
1881
|
-
x[
|
|
1882
|
-
x[
|
|
1883
|
-
x[
|
|
1884
|
-
x[
|
|
1885
|
-
i,
|
|
1924
|
+
x[f],
|
|
1925
|
+
x[f + 1],
|
|
1926
|
+
x[f + 2],
|
|
1927
|
+
x[f + 3],
|
|
1928
|
+
x[f + 4],
|
|
1929
|
+
x[f + 5],
|
|
1886
1930
|
r,
|
|
1887
|
-
|
|
1931
|
+
i,
|
|
1932
|
+
s,
|
|
1888
1933
|
a,
|
|
1889
1934
|
o,
|
|
1890
1935
|
h,
|
|
1891
1936
|
c,
|
|
1892
1937
|
u,
|
|
1893
|
-
|
|
1894
|
-
|
|
1938
|
+
l,
|
|
1939
|
+
d
|
|
1895
1940
|
);
|
|
1896
1941
|
}
|
|
1897
|
-
drawSpriteAffine(t, e,
|
|
1898
|
-
const
|
|
1942
|
+
drawSpriteAffine(t, e, r, i, s, a, o, h = 0, c = 0, u = 1, l = 1, d = 4294967295, f = 0, x = 0, g = !1, v = !1, T = !1) {
|
|
1943
|
+
const A = t.base, R = t.scale ?? 1, S = t.rawWidth, P = t.rawHeight, H = t.offsetX, X = t.offsetY, B = this.useTexture(
|
|
1899
1944
|
t.glTexture,
|
|
1900
|
-
|
|
1901
|
-
x /
|
|
1902
|
-
),
|
|
1903
|
-
|
|
1904
|
-
const
|
|
1905
|
-
|
|
1906
|
-
const
|
|
1907
|
-
|
|
1945
|
+
f / R / A.width,
|
|
1946
|
+
x / R / A.height
|
|
1947
|
+
), N = this.instanceBuffer, b = N.usedElemNum;
|
|
1948
|
+
N.resize(12);
|
|
1949
|
+
const _ = N.float32, W = N.uint32, D = (T ? P : S) * R, k = (T ? S : P) * R, I = D + 2 * f, M = k + 2 * x, L = H - f, z = X - x, y = this.localSpriteMatrix;
|
|
1950
|
+
T ? (y[0] = 0, y[1] = v ? M : -M, y[2] = g ? -I : I, y[3] = 0, y[4] = L + (g ? I : 0), y[5] = z + (v ? 0 : M)) : (y[0] = g ? -I : I, y[1] = 0, y[2] = 0, y[3] = v ? -M : M, y[4] = L + (g ? I : 0), y[5] = z + (v ? M : 0));
|
|
1951
|
+
const w = this.worldSpriteMatrix;
|
|
1952
|
+
w[0] = e * y[0] + i * y[1], w[1] = r * y[0] + s * y[1], w[2] = e * y[2] + i * y[3], w[3] = r * y[2] + s * y[3], w[4] = a + e * y[4] + i * y[5], w[5] = o + r * y[4] + s * y[5], _[b + 6] = h, _[b + 7] = c, _[b + 8] = u, _[b + 9] = l, W[b + 10] = d, W[b + 11] = B, this.rapid.roundPixels && (w[4] = Math.round(w[4]), w[5] = Math.round(w[5])), _[b] = w[0], _[b + 1] = w[2], _[b + 2] = w[4], _[b + 3] = w[1], _[b + 4] = w[3], _[b + 5] = w[5], N.usedElemNum += 12, N.makeDirty(), this.instanceCount++;
|
|
1908
1953
|
}
|
|
1909
1954
|
render() {
|
|
1910
1955
|
if (this.instanceCount === 0) return;
|
|
1911
1956
|
this.prepareRender();
|
|
1912
1957
|
const t = this.gl, e = this.currentShader;
|
|
1913
|
-
this.instanceBuffer.bindBuffer(), this.instanceBuffer.bufferData(), e.bindVAO(),
|
|
1958
|
+
this.instanceBuffer.bindBuffer(), this.instanceBuffer.bufferData(), e.bindVAO(), yt(t, t.TRIANGLE_STRIP, 0, 4, this.instanceCount), this.rapid.drawcallCount++;
|
|
1914
1959
|
}
|
|
1915
1960
|
resetRender() {
|
|
1916
1961
|
super.resetRender(), this.instanceBuffer.clear(), this.instanceCount = 0;
|
|
@@ -1919,8 +1964,8 @@ class rt extends yt {
|
|
|
1919
1964
|
return this.instanceCount > 0;
|
|
1920
1965
|
}
|
|
1921
1966
|
}
|
|
1922
|
-
const
|
|
1923
|
-
precision
|
|
1967
|
+
const Bt = `#version 300 es\r
|
|
1968
|
+
precision highp float;\r
|
|
1924
1969
|
\r
|
|
1925
1970
|
in vec2 aPosition;\r
|
|
1926
1971
|
in vec4 aColor;\r
|
|
@@ -1950,7 +1995,7 @@ void main(void) {\r
|
|
|
1950
1995
|
// CUSTOM_CODE_CALL\r
|
|
1951
1996
|
gl_Position = u_projection * position;\r
|
|
1952
1997
|
}\r
|
|
1953
|
-
`,
|
|
1998
|
+
`, Dt = `#version 300 es\r
|
|
1954
1999
|
precision mediump float;\r
|
|
1955
2000
|
\r
|
|
1956
2001
|
in vec4 vColor;\r
|
|
@@ -1970,9 +2015,9 @@ bool clampUV(vec2 uv) {\r
|
|
|
1970
2015
|
\r
|
|
1971
2016
|
vec4 sampleTexture(vec2 uv) {\r
|
|
1972
2017
|
if (uUseTexture > 0) {\r
|
|
1973
|
-
return texture(uTexture, uv)
|
|
2018
|
+
return texture(uTexture, uv);\r
|
|
1974
2019
|
}\r
|
|
1975
|
-
return
|
|
2020
|
+
return vec4(1,1,1,1);\r
|
|
1976
2021
|
}\r
|
|
1977
2022
|
\r
|
|
1978
2023
|
vec4 sampleClampTexture(vec2 uv) {\r
|
|
@@ -1993,11 +2038,11 @@ vec4 sampleTextureLocal(vec2 uv) {\r
|
|
|
1993
2038
|
// CUSTOM_CODE\r
|
|
1994
2039
|
\r
|
|
1995
2040
|
void main(void) {\r
|
|
1996
|
-
fragColor = sampleTexture(vRegion);\r
|
|
2041
|
+
fragColor = sampleTexture(vRegion) * vColor;\r
|
|
1997
2042
|
// CUSTOM_CODE_CALL\r
|
|
1998
2043
|
}\r
|
|
1999
2044
|
`, kt = `#version 300 es\r
|
|
2000
|
-
precision
|
|
2045
|
+
precision highp float;\r
|
|
2001
2046
|
\r
|
|
2002
2047
|
in vec2 aPosition;\r
|
|
2003
2048
|
in vec2 aUV;\r
|
|
@@ -2039,8 +2084,8 @@ void main(void) {\r
|
|
|
2039
2084
|
discard;\r
|
|
2040
2085
|
}\r
|
|
2041
2086
|
}\r
|
|
2042
|
-
`,
|
|
2043
|
-
class Ht extends
|
|
2087
|
+
`, $ = 20;
|
|
2088
|
+
class Ht extends Et {
|
|
2044
2089
|
vertexBuffer;
|
|
2045
2090
|
vertexCount = 0;
|
|
2046
2091
|
matrixIndex = -1;
|
|
@@ -2053,25 +2098,25 @@ class Ht extends yt {
|
|
|
2053
2098
|
}
|
|
2054
2099
|
createBuffer() {
|
|
2055
2100
|
const t = this.gl;
|
|
2056
|
-
this.vertexBuffer = new
|
|
2101
|
+
this.vertexBuffer = new et(t, U.Float32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW), this.maskShader = this.createMaskShader(kt, Gt);
|
|
2057
2102
|
}
|
|
2058
2103
|
createDefaultShader() {
|
|
2059
|
-
return this.vs =
|
|
2104
|
+
return this.vs = Bt, this.fs = Dt, this.defaultShader = this.createShader(this.vs, this.fs), this.defaultShader;
|
|
2060
2105
|
}
|
|
2061
2106
|
createMaskShader(t, e) {
|
|
2062
|
-
const
|
|
2063
|
-
return
|
|
2064
|
-
{ name: "aPosition", size: 2, type:
|
|
2065
|
-
{ name: "aUV", size: 2, type:
|
|
2066
|
-
]),
|
|
2107
|
+
const r = this.gl, i = new Tt(r, t, e);
|
|
2108
|
+
return i.use(), i.bindVAO(), this.vertexBuffer.bindBuffer(), i.setAttributes([
|
|
2109
|
+
{ name: "aPosition", size: 2, type: r.FLOAT, stride: $ - 4, offset: 0, divisor: 0 },
|
|
2110
|
+
{ name: "aUV", size: 2, type: r.FLOAT, stride: $ - 4, offset: 8, divisor: 0 }
|
|
2111
|
+
]), i.unbindVAO(), this.currentShader && this.currentShader.use(), i;
|
|
2067
2112
|
}
|
|
2068
2113
|
createShader(t, e) {
|
|
2069
|
-
const
|
|
2070
|
-
return
|
|
2071
|
-
{ name: "aPosition", size: 2, type:
|
|
2072
|
-
{ name: "aColor", size: 4, type:
|
|
2073
|
-
{ name: "aUV", size: 2, type:
|
|
2074
|
-
]),
|
|
2114
|
+
const r = this.gl, i = super.createShader(t, e);
|
|
2115
|
+
return i.use(), i.bindVAO(), this.vertexBuffer.bindBuffer(), i.setAttributes([
|
|
2116
|
+
{ name: "aPosition", size: 2, type: r.FLOAT, stride: $, offset: 0, divisor: 0 },
|
|
2117
|
+
{ name: "aColor", size: 4, type: r.UNSIGNED_BYTE, normalized: !0, stride: $, offset: 8, divisor: 0 },
|
|
2118
|
+
{ name: "aUV", size: 2, type: r.FLOAT, stride: $, offset: 12, divisor: 0 }
|
|
2119
|
+
]), i.unbindVAO(), this.currentShader && this.currentShader.use(), i;
|
|
2075
2120
|
}
|
|
2076
2121
|
/**
|
|
2077
2122
|
* Begins a new polygon drawing sequence. Must be followed by addVertex() calls and endGraphic().
|
|
@@ -2079,8 +2124,8 @@ class Ht extends yt {
|
|
|
2079
2124
|
* @param drawMode The WebGL drawing primitive mode (e.g., gl.TRIANGLES).
|
|
2080
2125
|
* @param texture Optional texture to apply over the polygon.
|
|
2081
2126
|
*/
|
|
2082
|
-
startGraphic(t, e = this.gl.TRIANGLES,
|
|
2083
|
-
this.vertexBuffer.clear(), this.vertexCount = 0, this.matrixIndex = t, this.drawMode = e, this.texture =
|
|
2127
|
+
startGraphic(t, e = this.gl.TRIANGLES, r) {
|
|
2128
|
+
this.vertexBuffer.clear(), this.vertexCount = 0, this.matrixIndex = t, this.drawMode = e, this.texture = r, this.texture?.glTexture && this.useTexture(this.texture.glTexture, 0, 0);
|
|
2084
2129
|
}
|
|
2085
2130
|
/**
|
|
2086
2131
|
* Adds a vertex to the current polygon. Local coordinates and color settings.
|
|
@@ -2090,22 +2135,22 @@ class Ht extends yt {
|
|
|
2090
2135
|
* @param v UV mapped Y value (0-1, default 0).
|
|
2091
2136
|
* @param color Pre-multiplied hex color combined using ABGR byte order (default 0xFFFFFFFF).
|
|
2092
2137
|
*/
|
|
2093
|
-
addVertex(t, e,
|
|
2138
|
+
addVertex(t, e, r = 0, i = 0, s = 4294967295) {
|
|
2094
2139
|
const a = this.vertexBuffer;
|
|
2095
|
-
a.pushFloat32(t), a.pushFloat32(e), this.currentShader != this.maskShader && a.pushUint32(
|
|
2140
|
+
a.pushFloat32(t), a.pushFloat32(e), this.currentShader != this.maskShader && a.pushUint32(s), a.pushFloat32(r), a.pushFloat32(i), this.vertexCount++, this.vertexBuffer.makeDirty();
|
|
2096
2141
|
}
|
|
2097
2142
|
/**
|
|
2098
2143
|
* Finishes the graphic construction and dispatches the rendering call immediately.
|
|
2099
2144
|
*/
|
|
2100
2145
|
endGraphic() {
|
|
2101
|
-
this.
|
|
2146
|
+
this.flush();
|
|
2102
2147
|
}
|
|
2103
2148
|
render() {
|
|
2104
2149
|
if (this.vertexCount === 0) return;
|
|
2105
2150
|
this.prepareRender();
|
|
2106
|
-
const t = this.gl, e = this.currentShader,
|
|
2107
|
-
let
|
|
2108
|
-
this.rapid.roundPixels && (
|
|
2151
|
+
const t = this.gl, e = this.currentShader, r = this.matrixIndex * 6, i = this.matrixStore.data;
|
|
2152
|
+
let s = i[r + 4], a = i[r + 5];
|
|
2153
|
+
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(
|
|
2109
2154
|
"uUVRect",
|
|
2110
2155
|
this.texture ? [this.texture.uvX, this.texture.uvY, this.texture.uvW, this.texture.uvH] : [0, 0, 1, 1]
|
|
2111
2156
|
), 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;
|
|
@@ -2114,15 +2159,15 @@ class Ht extends yt {
|
|
|
2114
2159
|
return !1;
|
|
2115
2160
|
}
|
|
2116
2161
|
}
|
|
2117
|
-
class
|
|
2162
|
+
class p {
|
|
2118
2163
|
x;
|
|
2119
2164
|
y;
|
|
2120
|
-
static ZERO = new
|
|
2121
|
-
static ONE = new
|
|
2122
|
-
static UP = new
|
|
2123
|
-
static DOWN = new
|
|
2124
|
-
static LEFT = new
|
|
2125
|
-
static RIGHT = new
|
|
2165
|
+
static ZERO = new p(0, 0);
|
|
2166
|
+
static ONE = new p(1, 1);
|
|
2167
|
+
static UP = new p(0, 1);
|
|
2168
|
+
static DOWN = new p(0, -1);
|
|
2169
|
+
static LEFT = new p(-1, 0);
|
|
2170
|
+
static RIGHT = new p(1, 0);
|
|
2126
2171
|
constructor(t, e) {
|
|
2127
2172
|
this.x = t !== void 0 ? t : 0, this.y = e !== void 0 ? e : 0;
|
|
2128
2173
|
}
|
|
@@ -2130,22 +2175,22 @@ class d {
|
|
|
2130
2175
|
return e === void 0 ? (this.x = t, this.y = t) : (this.x = t, this.y = e), this;
|
|
2131
2176
|
}
|
|
2132
2177
|
add(t) {
|
|
2133
|
-
return new
|
|
2178
|
+
return new p(this.x + t.x, this.y + t.y);
|
|
2134
2179
|
}
|
|
2135
2180
|
subtract(t) {
|
|
2136
|
-
return new
|
|
2181
|
+
return new p(this.x - t.x, this.y - t.y);
|
|
2137
2182
|
}
|
|
2138
2183
|
sub(t) {
|
|
2139
|
-
return new
|
|
2184
|
+
return new p(this.x - t.x, this.y - t.y);
|
|
2140
2185
|
}
|
|
2141
2186
|
multiply(t) {
|
|
2142
|
-
return t instanceof
|
|
2187
|
+
return t instanceof p ? new p(this.x * t.x, this.y * t.y) : new p(this.x * t, this.y * t);
|
|
2143
2188
|
}
|
|
2144
2189
|
mul(t) {
|
|
2145
2190
|
return this.multiply(t);
|
|
2146
2191
|
}
|
|
2147
2192
|
divide(t) {
|
|
2148
|
-
return t instanceof
|
|
2193
|
+
return t instanceof p ? new p(this.x / t.x, this.y / t.y) : new p(this.x / t, this.y / t);
|
|
2149
2194
|
}
|
|
2150
2195
|
dot(t) {
|
|
2151
2196
|
return this.x * t.x + this.y * t.y;
|
|
@@ -2154,17 +2199,17 @@ class d {
|
|
|
2154
2199
|
return this.x * t.y - this.y * t.x;
|
|
2155
2200
|
}
|
|
2156
2201
|
distanceTo(t) {
|
|
2157
|
-
const e = this.x - t.x,
|
|
2158
|
-
return Math.sqrt(e * e +
|
|
2202
|
+
const e = this.x - t.x, r = this.y - t.y;
|
|
2203
|
+
return Math.sqrt(e * e + r * r);
|
|
2159
2204
|
}
|
|
2160
2205
|
clone() {
|
|
2161
|
-
return new
|
|
2206
|
+
return new p(this.x, this.y);
|
|
2162
2207
|
}
|
|
2163
2208
|
to(t) {
|
|
2164
2209
|
this.x = t.x, this.y = t.y;
|
|
2165
2210
|
}
|
|
2166
2211
|
copy() {
|
|
2167
|
-
return new
|
|
2212
|
+
return new p(this.x, this.y);
|
|
2168
2213
|
}
|
|
2169
2214
|
equals(t) {
|
|
2170
2215
|
return t.x == this.x && t.y == this.y;
|
|
@@ -2177,7 +2222,7 @@ class d {
|
|
|
2177
2222
|
return this.x = -this.x, this.y = -this.y, this;
|
|
2178
2223
|
}
|
|
2179
2224
|
inverted() {
|
|
2180
|
-
return new
|
|
2225
|
+
return new p(this.x * -1, this.y * -1);
|
|
2181
2226
|
}
|
|
2182
2227
|
length() {
|
|
2183
2228
|
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
@@ -2191,13 +2236,13 @@ class d {
|
|
|
2191
2236
|
}
|
|
2192
2237
|
normalized() {
|
|
2193
2238
|
const t = this.length();
|
|
2194
|
-
return new
|
|
2239
|
+
return new p(this.x / t || 0, this.y / t || 0);
|
|
2195
2240
|
}
|
|
2196
2241
|
fix(t = 1e-13) {
|
|
2197
2242
|
this.x = Math.abs(this.x) < t ? 0 : this.x, this.y = Math.abs(this.y) < t ? 0 : this.y;
|
|
2198
2243
|
}
|
|
2199
2244
|
fixed(t = 1e-13) {
|
|
2200
|
-
return new
|
|
2245
|
+
return new p(
|
|
2201
2246
|
Math.abs(this.x) < t ? 0 : this.x,
|
|
2202
2247
|
Math.abs(this.y) < t ? 0 : this.y
|
|
2203
2248
|
);
|
|
@@ -2206,13 +2251,13 @@ class d {
|
|
|
2206
2251
|
return Math.atan2(this.y, this.x);
|
|
2207
2252
|
}
|
|
2208
2253
|
abs() {
|
|
2209
|
-
return new
|
|
2254
|
+
return new p(Math.abs(this.x), Math.abs(this.y));
|
|
2210
2255
|
}
|
|
2211
2256
|
floor() {
|
|
2212
|
-
return new
|
|
2257
|
+
return new p(Math.floor(this.x), Math.floor(this.y));
|
|
2213
2258
|
}
|
|
2214
2259
|
ceil() {
|
|
2215
|
-
return new
|
|
2260
|
+
return new p(Math.ceil(this.x), Math.ceil(this.y));
|
|
2216
2261
|
}
|
|
2217
2262
|
stringify() {
|
|
2218
2263
|
return `Vec2(${this.x}, ${this.y})`;
|
|
@@ -2233,236 +2278,242 @@ class d {
|
|
|
2233
2278
|
return this.x = Math.cos(t) * e, this.y = Math.sin(t) * e, this;
|
|
2234
2279
|
}
|
|
2235
2280
|
static FromArray(t) {
|
|
2236
|
-
return t.map((e) => new
|
|
2281
|
+
return t.map((e) => new p(e[0], e[1]));
|
|
2237
2282
|
}
|
|
2238
2283
|
static fromAngle(t) {
|
|
2239
|
-
return new
|
|
2284
|
+
return new p(Math.cos(t), Math.sin(t));
|
|
2240
2285
|
}
|
|
2241
2286
|
}
|
|
2242
|
-
const Vt = (
|
|
2243
|
-
const [e,
|
|
2287
|
+
const Vt = (n, t) => {
|
|
2288
|
+
const [e, r, i, s, a, o] = t, h = new Float32Array([
|
|
2244
2289
|
e,
|
|
2245
|
-
n,
|
|
2246
|
-
0,
|
|
2247
|
-
0,
|
|
2248
2290
|
i,
|
|
2249
|
-
a,
|
|
2250
2291
|
0,
|
|
2251
2292
|
0,
|
|
2252
2293
|
r,
|
|
2253
|
-
|
|
2254
|
-
1,
|
|
2294
|
+
s,
|
|
2255
2295
|
0,
|
|
2256
2296
|
0,
|
|
2257
2297
|
0,
|
|
2258
2298
|
0,
|
|
2299
|
+
1,
|
|
2300
|
+
0,
|
|
2301
|
+
a,
|
|
2302
|
+
o,
|
|
2303
|
+
0,
|
|
2259
2304
|
1
|
|
2260
2305
|
]);
|
|
2261
|
-
return
|
|
2262
|
-
},
|
|
2306
|
+
return Yt(h, n);
|
|
2307
|
+
}, Yt = (n, t) => {
|
|
2263
2308
|
const e = new Float32Array(16);
|
|
2264
|
-
for (let
|
|
2265
|
-
for (let
|
|
2266
|
-
let
|
|
2309
|
+
for (let r = 0; r < 4; r++)
|
|
2310
|
+
for (let i = 0; i < 4; i++) {
|
|
2311
|
+
let s = 0;
|
|
2267
2312
|
for (let a = 0; a < 4; a++)
|
|
2268
|
-
|
|
2269
|
-
e[
|
|
2313
|
+
s += n[i * 4 + a] * t[a * 4 + r];
|
|
2314
|
+
e[i * 4 + r] = s;
|
|
2270
2315
|
}
|
|
2271
2316
|
return e;
|
|
2272
2317
|
};
|
|
2273
|
-
var
|
|
2274
|
-
const
|
|
2275
|
-
const a = [], o = [], h =
|
|
2276
|
-
for (let
|
|
2277
|
-
const
|
|
2278
|
-
a.push(
|
|
2318
|
+
var Xt = /* @__PURE__ */ ((n) => (n[n.STRETCH = 0] = "STRETCH", n[n.REPEAT = 1] = "REPEAT", n))(Xt || {});
|
|
2319
|
+
const tt = 10, lt = (n, t, e, r, i, s) => {
|
|
2320
|
+
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);
|
|
2321
|
+
for (let l = 0; l < tt; l++) {
|
|
2322
|
+
const d = l / tt, f = (l + 1) / tt, x = h + d * c, g = h + f * c, v = new p(Math.cos(x) * e, Math.sin(x) * e), T = new p(Math.cos(g) * e, Math.sin(g) * e);
|
|
2323
|
+
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(T)), o.push(new p(i + T.dot(u) * s, 0.5 - 0.5 * T.dot(t) / e));
|
|
2279
2324
|
}
|
|
2280
2325
|
return { vertices: a, uv: o };
|
|
2281
|
-
},
|
|
2326
|
+
}, zt = (n, t = !1) => {
|
|
2282
2327
|
const e = [];
|
|
2283
|
-
if (
|
|
2284
|
-
const
|
|
2328
|
+
if (n.length < 2 || t && n.length < 3) return { normals: e, length: 0 };
|
|
2329
|
+
const r = 4, i = 1e-3, s = n.length;
|
|
2285
2330
|
let a = 0;
|
|
2286
2331
|
if (t)
|
|
2287
|
-
for (let h = 0; h <
|
|
2288
|
-
const c =
|
|
2332
|
+
for (let h = 0; h < s; h++) {
|
|
2333
|
+
const c = n[h], u = n[(h + 1) % s];
|
|
2289
2334
|
a += c.distanceTo(u);
|
|
2290
2335
|
}
|
|
2291
2336
|
else
|
|
2292
|
-
for (let h = 0; h <
|
|
2293
|
-
a +=
|
|
2337
|
+
for (let h = 0; h < s - 1; h++)
|
|
2338
|
+
a += n[h].distanceTo(n[h + 1]);
|
|
2294
2339
|
const o = (h, c, u) => {
|
|
2295
|
-
const
|
|
2296
|
-
if (
|
|
2297
|
-
return { normal:
|
|
2340
|
+
const l = c.subtract(h).normalize(), d = c.subtract(u).normalize(), f = d.dot(l);
|
|
2341
|
+
if (f < -1 + i)
|
|
2342
|
+
return { normal: l.perpendicular(), miters: 1 };
|
|
2298
2343
|
{
|
|
2299
|
-
let x =
|
|
2300
|
-
|
|
2301
|
-
let g = 1 / Math.sqrt((1 -
|
|
2302
|
-
return { normal: x, miters: Math.min(g,
|
|
2344
|
+
let x = d.add(l).normalize();
|
|
2345
|
+
l.cross(d) < 0 && (x = x.multiply(-1));
|
|
2346
|
+
let g = 1 / Math.sqrt((1 - f) / 2);
|
|
2347
|
+
return { normal: x, miters: Math.min(g, r) };
|
|
2303
2348
|
}
|
|
2304
2349
|
};
|
|
2305
2350
|
if (t)
|
|
2306
|
-
for (let h = 0; h <
|
|
2307
|
-
const c = h === 0 ? s
|
|
2308
|
-
e.push(o(c, u,
|
|
2351
|
+
for (let h = 0; h < s; h++) {
|
|
2352
|
+
const c = h === 0 ? n[s - 1] : n[h - 1], u = n[h], l = h === s - 1 ? n[0] : n[h + 1];
|
|
2353
|
+
e.push(o(c, u, l));
|
|
2309
2354
|
}
|
|
2310
2355
|
else
|
|
2311
|
-
for (let h = 0; h <
|
|
2356
|
+
for (let h = 0; h < s; h++)
|
|
2312
2357
|
if (h === 0) {
|
|
2313
|
-
const c =
|
|
2358
|
+
const c = n[1].subtract(n[0]).normalize();
|
|
2314
2359
|
e.push({ normal: c.perpendicular(), miters: 1 });
|
|
2315
|
-
} else if (h ===
|
|
2316
|
-
const c =
|
|
2360
|
+
} else if (h === s - 1) {
|
|
2361
|
+
const c = n[h].subtract(n[h - 1]).normalize();
|
|
2317
2362
|
e.push({ normal: c.perpendicular(), miters: 1 });
|
|
2318
2363
|
} else
|
|
2319
|
-
e.push(o(
|
|
2364
|
+
e.push(o(n[h - 1], n[h], n[h + 1]));
|
|
2320
2365
|
return { normals: e, length: a };
|
|
2321
|
-
}, jt = (
|
|
2322
|
-
const t =
|
|
2366
|
+
}, jt = (n) => {
|
|
2367
|
+
const t = n.points;
|
|
2323
2368
|
if (t.length < 2) return { vertices: [], uv: [] };
|
|
2324
|
-
const { normals: e, length:
|
|
2369
|
+
const { normals: e, length: r } = zt(t, n.closed), i = (n.width || 1) / 2, s = [], a = [], o = n.roundCap || !1, h = n.textureMode || 0;
|
|
2325
2370
|
let c = 0;
|
|
2326
|
-
const u =
|
|
2327
|
-
for (let
|
|
2328
|
-
const
|
|
2329
|
-
let
|
|
2330
|
-
h === 0 ? (
|
|
2331
|
-
const
|
|
2332
|
-
|
|
2333
|
-
}
|
|
2334
|
-
if (o && !
|
|
2335
|
-
const
|
|
2336
|
-
|
|
2337
|
-
const
|
|
2338
|
-
|
|
2339
|
-
}
|
|
2340
|
-
return { vertices:
|
|
2341
|
-
},
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
if (!e?.base || s.inCreateMask)
|
|
2371
|
+
const u = n.texture?.rawWidth || 1, l = n.closed ? t.length : t.length - 1;
|
|
2372
|
+
for (let d = 0; d < l; d++) {
|
|
2373
|
+
const f = t[d], x = e[d].normal, g = e[d].miters, v = (d + 1) % t.length, T = t[v], A = e[v].normal, R = e[v].miters, S = f.add(x.multiply(g * i)), P = f.subtract(x.multiply(g * i)), H = T.add(A.multiply(R * i)), X = T.subtract(A.multiply(R * i)), B = f.distanceTo(T);
|
|
2374
|
+
let N = 0, b = 0;
|
|
2375
|
+
h === 0 ? (N = c / r, b = (c + B) / r) : (N = c / u, b = N + B / u);
|
|
2376
|
+
const _ = new p(N, 0), W = new p(N, 1), D = new p(b, 0), k = new p(b, 1);
|
|
2377
|
+
s.push(S), a.push(_), s.push(P), a.push(W), s.push(H), a.push(D), s.push(H), a.push(D), s.push(X), a.push(k), s.push(P), a.push(W), c += B;
|
|
2378
|
+
}
|
|
2379
|
+
if (o && !n.closed) {
|
|
2380
|
+
const d = t[0], f = e[0].normal, x = h === 0 ? r > 0 ? 1 / r : 0 : 1 / u, g = lt(d, f, i, !0, 0, x);
|
|
2381
|
+
s.push(...g.vertices), a.push(...g.uv);
|
|
2382
|
+
const v = t[t.length - 1], T = e[t.length - 1].normal, A = h === 0 ? 1 : c / u, R = h === 0 ? r > 0 ? 1 / r : 0 : 1 / u, S = lt(v, T, i, !1, A, R);
|
|
2383
|
+
s.push(...S.vertices), a.push(...S.uv);
|
|
2384
|
+
}
|
|
2385
|
+
return { vertices: s, uv: a };
|
|
2386
|
+
}, Q = (n, t, e, r) => {
|
|
2387
|
+
if (t.customMatrix !== void 0)
|
|
2388
|
+
return t.customMatrix;
|
|
2389
|
+
if (t.modifyStack) {
|
|
2390
|
+
n.matrixStack.applyTransform(
|
|
2391
|
+
t,
|
|
2392
|
+
e,
|
|
2393
|
+
r
|
|
2394
|
+
);
|
|
2351
2395
|
return;
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2396
|
+
} else {
|
|
2397
|
+
const i = n.matrix.temporary;
|
|
2398
|
+
return n.matrixStack.applyTransform(
|
|
2399
|
+
t,
|
|
2400
|
+
e,
|
|
2401
|
+
r,
|
|
2402
|
+
i
|
|
2403
|
+
), i;
|
|
2404
|
+
}
|
|
2405
|
+
}, $t = (n, t) => t ? n ? t.premultipliedUint32 : t.uint32 : 4294967295, Kt = 2, qt = (n, t) => {
|
|
2406
|
+
const e = Q(n, t, t.texture.rawWidth, t.texture.rawHeight), r = t.texture;
|
|
2407
|
+
if (!r?.base || n.inCreateMask)
|
|
2408
|
+
return;
|
|
2409
|
+
const i = r.isAtlas ? n.atlasSpriteRegion : n.spriteRegion;
|
|
2410
|
+
n.enterRegion(i, t.shader);
|
|
2411
|
+
let s = r.uvX, a = r.uvY, o = r.uvW, h = r.uvH;
|
|
2412
|
+
const c = !!t.flipX, u = !!t.flipY != !!r.flipY;
|
|
2413
|
+
let l = t.padding ?? i.currentShader.padding;
|
|
2414
|
+
r.isAtlas && (l += Kt);
|
|
2415
|
+
const d = s <= o ? l : -l, f = a <= h ? l : -l;
|
|
2359
2416
|
i.drawSprite(
|
|
2360
|
-
e,
|
|
2361
|
-
t.customMatrix ?? s.matrixStack.curWorldM,
|
|
2362
2417
|
r,
|
|
2363
|
-
n,
|
|
2418
|
+
e ?? t.customMatrix ?? n.matrixStack.curWorldM,
|
|
2419
|
+
s,
|
|
2364
2420
|
a,
|
|
2365
2421
|
o,
|
|
2366
|
-
st(s, t.color),
|
|
2367
|
-
f,
|
|
2368
|
-
l,
|
|
2369
2422
|
h,
|
|
2423
|
+
n.getColorUint32(t.color),
|
|
2424
|
+
d,
|
|
2425
|
+
f,
|
|
2370
2426
|
c,
|
|
2371
|
-
|
|
2427
|
+
u,
|
|
2428
|
+
r.isRotated
|
|
2372
2429
|
);
|
|
2373
|
-
},
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
}, qt = (s, t) => {
|
|
2378
|
-
const e = s.particleRegion;
|
|
2379
|
-
s.enterRegion(e, t.shader);
|
|
2380
|
-
const i = t.texture, r = t.count ?? t.x.length, n = t.color, a = n.length, o = new Array(a);
|
|
2381
|
-
if (s.premultipliedAlpha)
|
|
2382
|
-
for (let h = 0; h < a; h++)
|
|
2383
|
-
o[h] = n[h].premultipliedUint32;
|
|
2384
|
-
else
|
|
2385
|
-
for (let h = 0; h < a; h++)
|
|
2386
|
-
o[h] = n[h].uint32;
|
|
2430
|
+
}, Qt = (n, t) => {
|
|
2431
|
+
const e = n.particleRegion;
|
|
2432
|
+
n.enterRegion(e, t.shader);
|
|
2433
|
+
const r = t.texture, i = t.count ?? t.x.length, s = t.color;
|
|
2387
2434
|
e.drawParticles(
|
|
2388
|
-
|
|
2435
|
+
r,
|
|
2389
2436
|
t.x,
|
|
2390
2437
|
t.y,
|
|
2391
2438
|
t.rotation,
|
|
2392
|
-
|
|
2393
|
-
|
|
2439
|
+
s,
|
|
2440
|
+
i,
|
|
2394
2441
|
t.scaleX,
|
|
2395
2442
|
t.scaleY,
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2443
|
+
r.uvX,
|
|
2444
|
+
r.uvY,
|
|
2445
|
+
r.uvW,
|
|
2446
|
+
r.uvH,
|
|
2400
2447
|
t.flipX,
|
|
2401
2448
|
t.flipY,
|
|
2402
|
-
|
|
2449
|
+
r.isRotated,
|
|
2403
2450
|
t.originX,
|
|
2404
|
-
t.originY
|
|
2451
|
+
t.originY,
|
|
2452
|
+
n.premultipliedAlpha,
|
|
2453
|
+
t.reverseOrder,
|
|
2454
|
+
t.customMatrix
|
|
2455
|
+
);
|
|
2456
|
+
}, Rt = (n, t) => {
|
|
2457
|
+
if (t.points.length === 0) return;
|
|
2458
|
+
const e = Q(n, t, 0, 0);
|
|
2459
|
+
n.startGraphic(
|
|
2460
|
+
t.drawMode ?? n.gl.TRIANGLES,
|
|
2461
|
+
t.texture,
|
|
2462
|
+
t.shader,
|
|
2463
|
+
e ?? t.customMatrix
|
|
2405
2464
|
);
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2465
|
+
for (let r = 0; r < t.points.length; r++) {
|
|
2466
|
+
const i = t.points[r], s = t.uv?.[r], a = Array.isArray(t.color) ? t.color[r] : t.color;
|
|
2467
|
+
n.addGraphicVertex(
|
|
2468
|
+
i.x,
|
|
2469
|
+
i.y,
|
|
2470
|
+
s?.x ?? 0,
|
|
2471
|
+
s?.y ?? 0,
|
|
2472
|
+
n.getColorUint32(a)
|
|
2413
2473
|
);
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
i.y,
|
|
2419
|
-
r?.x ?? 0,
|
|
2420
|
-
r?.y ?? 0,
|
|
2421
|
-
st(s, n)
|
|
2422
|
-
);
|
|
2423
|
-
}
|
|
2424
|
-
s.endGraphic();
|
|
2425
|
-
});
|
|
2426
|
-
}, Zt = (s, t) => {
|
|
2427
|
-
if (s.inCreateMask)
|
|
2474
|
+
}
|
|
2475
|
+
n.endGraphic();
|
|
2476
|
+
}, Zt = (n, t) => {
|
|
2477
|
+
if (n.inCreateMask)
|
|
2428
2478
|
return;
|
|
2429
|
-
const { vertices: e, uv:
|
|
2430
|
-
|
|
2479
|
+
const { vertices: e, uv: r } = jt(t);
|
|
2480
|
+
Rt(n, {
|
|
2431
2481
|
...t,
|
|
2432
2482
|
points: e,
|
|
2433
|
-
uv:
|
|
2434
|
-
drawMode:
|
|
2435
|
-
});
|
|
2436
|
-
}, Qt = (s, t) => {
|
|
2437
|
-
X(s, t, t.texture.rawWidth, t.texture.rawHeight, () => {
|
|
2438
|
-
s.startMaskGraphic(
|
|
2439
|
-
s.gl.TRIANGLE_FAN,
|
|
2440
|
-
t.texture,
|
|
2441
|
-
t.customMatrix
|
|
2442
|
-
), s.addRectVertex(t.texture.rawWidth, t.texture.rawHeight), s.endGraphic();
|
|
2443
|
-
});
|
|
2444
|
-
}, Jt = (s, t) => {
|
|
2445
|
-
X(s, t, t.width, t.height, () => {
|
|
2446
|
-
s.startGraphic(
|
|
2447
|
-
s.gl.TRIANGLE_FAN,
|
|
2448
|
-
t.texture,
|
|
2449
|
-
t.shader,
|
|
2450
|
-
t.customMatrix
|
|
2451
|
-
), s.addRectVertex(t.width, t.height, t.color), s.endGraphic();
|
|
2452
|
-
});
|
|
2453
|
-
}, te = (s, t) => {
|
|
2454
|
-
const e = t.segments ?? 32;
|
|
2455
|
-
X(s, t, 0, 0, () => {
|
|
2456
|
-
s.startGraphic(
|
|
2457
|
-
s.gl.TRIANGLE_FAN,
|
|
2458
|
-
void 0,
|
|
2459
|
-
t.shader,
|
|
2460
|
-
t.customMatrix
|
|
2461
|
-
);
|
|
2462
|
-
const i = st(s, t.color);
|
|
2463
|
-
s.addGraphicVertex(0, 0, 0.5, 0.5, i), s.addCircleVertex(t.radius, t.color, e), s.addGraphicVertex(t.radius, 0, 1, 0.5, i), s.endGraphic();
|
|
2483
|
+
uv: r,
|
|
2484
|
+
drawMode: n.gl.TRIANGLES
|
|
2464
2485
|
});
|
|
2465
|
-
},
|
|
2486
|
+
}, Jt = (n, t) => {
|
|
2487
|
+
const e = Q(
|
|
2488
|
+
n,
|
|
2489
|
+
t,
|
|
2490
|
+
t.texture.rawWidth,
|
|
2491
|
+
t.texture.rawHeight
|
|
2492
|
+
);
|
|
2493
|
+
n.startMaskGraphic(
|
|
2494
|
+
n.gl.TRIANGLE_FAN,
|
|
2495
|
+
t.texture,
|
|
2496
|
+
e ?? t.customMatrix
|
|
2497
|
+
), n.addRectVertex(t.texture.rawWidth, t.texture.rawHeight), n.endGraphic();
|
|
2498
|
+
}, te = (n, t) => {
|
|
2499
|
+
const e = Q(n, t, t.width, t.height);
|
|
2500
|
+
n.startGraphic(
|
|
2501
|
+
n.gl.TRIANGLE_FAN,
|
|
2502
|
+
t.texture,
|
|
2503
|
+
t.shader,
|
|
2504
|
+
e ?? t.customMatrix
|
|
2505
|
+
), n.addRectVertex(t.width, t.height, t.color), n.endGraphic();
|
|
2506
|
+
}, ee = (n, t) => {
|
|
2507
|
+
const e = t.segments ?? 32, r = Q(n, t, 0, 0);
|
|
2508
|
+
n.startGraphic(
|
|
2509
|
+
n.gl.TRIANGLE_FAN,
|
|
2510
|
+
void 0,
|
|
2511
|
+
t.shader,
|
|
2512
|
+
r ?? t.customMatrix
|
|
2513
|
+
);
|
|
2514
|
+
const i = n.getColorUint32(t.color);
|
|
2515
|
+
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();
|
|
2516
|
+
}, dt = `#version 300 es\r
|
|
2466
2517
|
precision mediump float;\r
|
|
2467
2518
|
\r
|
|
2468
2519
|
uniform sampler2D uTextures[%TEXTURE_NUM%];\r
|
|
@@ -2502,7 +2553,7 @@ vec4 sampleTextureLocal(vec2 uv){\r
|
|
|
2502
2553
|
// CUSTOM_CODE\r
|
|
2503
2554
|
\r
|
|
2504
2555
|
void main(void) {\r
|
|
2505
|
-
fragColor = sampleClampTexture(vRegion);\r
|
|
2556
|
+
fragColor = sampleClampTexture(vRegion) * vColor;\r
|
|
2506
2557
|
// if (vPadding.x != 0.0) {\r
|
|
2507
2558
|
// if (clampUV(vRegion)) {\r
|
|
2508
2559
|
// fragColor = vec4(0.0, 0.0, 0.0, 0.0);\r
|
|
@@ -2512,31 +2563,31 @@ void main(void) {\r
|
|
|
2512
2563
|
// CUSTOM_CODE_CALL\r
|
|
2513
2564
|
}\r
|
|
2514
2565
|
`;
|
|
2515
|
-
class
|
|
2566
|
+
class re extends at {
|
|
2516
2567
|
KEY = "AtlasSprite";
|
|
2517
2568
|
constructor(t) {
|
|
2518
2569
|
super(t);
|
|
2519
2570
|
}
|
|
2520
2571
|
createCustomShader(t) {
|
|
2521
|
-
const e =
|
|
2522
|
-
return t.getGLShader(this, this.KEY,
|
|
2572
|
+
const e = G(dt, this.rapid.maxTextureUnits - t.usedTextureUnitNum), r = G(Z, this.rapid.maxTextureUnits - t.usedTextureUnitNum);
|
|
2573
|
+
return t.getGLShader(this, this.KEY, r, e);
|
|
2523
2574
|
}
|
|
2524
2575
|
createDefaultShader() {
|
|
2525
|
-
const t = this.rapid, e =
|
|
2526
|
-
return this.vs =
|
|
2576
|
+
const t = this.rapid, e = G(dt, t.maxTextureUnits), r = G(Z, t.maxTextureUnits);
|
|
2577
|
+
return this.vs = r, this.fs = e, this.defaultShader = this.createShader(r, e), this.defaultShader;
|
|
2527
2578
|
}
|
|
2528
2579
|
}
|
|
2529
|
-
const
|
|
2530
|
-
precision
|
|
2580
|
+
const ft = `#version 300 es\r
|
|
2581
|
+
precision highp float;\r
|
|
2531
2582
|
\r
|
|
2532
2583
|
// per-vertex\r
|
|
2533
2584
|
in vec2 aVertex;\r
|
|
2534
2585
|
\r
|
|
2535
2586
|
// per-instance: 变换\r
|
|
2536
2587
|
in vec2 aPosition;\r
|
|
2537
|
-
in vec2 aScale
|
|
2538
|
-
in float aRotation
|
|
2539
|
-
in vec2 aOrigin
|
|
2588
|
+
in vec2 aScale;\r
|
|
2589
|
+
in float aRotation;\r
|
|
2590
|
+
in vec2 aOrigin;\r
|
|
2540
2591
|
\r
|
|
2541
2592
|
// per-instance:UV 区域 (u0, v0, u1, v1)\r
|
|
2542
2593
|
in vec4 aUVRect;\r
|
|
@@ -2556,7 +2607,7 @@ void main(void) {\r
|
|
|
2556
2607
|
vRegion = aUVRect.xy + aVertex * (aUVRect.zw - aUVRect.xy);\r
|
|
2557
2608
|
// CUSTOM_CODE_CALL\r
|
|
2558
2609
|
\r
|
|
2559
|
-
vec2 scaled = (aVertex - aOrigin) * aScale
|
|
2610
|
+
vec2 scaled = (aVertex - aOrigin) * aScale;\r
|
|
2560
2611
|
float c = cos(aRotation);\r
|
|
2561
2612
|
float s = sin(aRotation);\r
|
|
2562
2613
|
\r
|
|
@@ -2567,7 +2618,7 @@ void main(void) {\r
|
|
|
2567
2618
|
\r
|
|
2568
2619
|
gl_Position = u_projection * vec4(v, 0.0, 1.0);\r
|
|
2569
2620
|
}\r
|
|
2570
|
-
`,
|
|
2621
|
+
`, mt = `#version 300 es\r
|
|
2571
2622
|
precision mediump float;\r
|
|
2572
2623
|
\r
|
|
2573
2624
|
uniform sampler2D uTexture;\r
|
|
@@ -2583,52 +2634,67 @@ void main(void) {\r
|
|
|
2583
2634
|
\r
|
|
2584
2635
|
// CUSTOM_CODE_CALL\r
|
|
2585
2636
|
}\r
|
|
2586
|
-
`,
|
|
2587
|
-
class ie extends
|
|
2637
|
+
`, V = 48, xt = V / 4;
|
|
2638
|
+
class ie extends at {
|
|
2588
2639
|
KEY = "ParticleSprite";
|
|
2589
2640
|
texture;
|
|
2641
|
+
customMatrix;
|
|
2590
2642
|
constructor(t) {
|
|
2591
2643
|
super(t);
|
|
2592
2644
|
}
|
|
2593
2645
|
createCustomShader(t) {
|
|
2594
|
-
return t.getGLShader(this, this.KEY,
|
|
2646
|
+
return t.getGLShader(this, this.KEY, ft, mt);
|
|
2595
2647
|
}
|
|
2596
2648
|
createDefaultShader() {
|
|
2597
|
-
const t =
|
|
2649
|
+
const t = mt, e = ft;
|
|
2598
2650
|
return this.vs = e, this.fs = t, this.defaultShader = this.createShader(e, t), this.defaultShader;
|
|
2599
2651
|
}
|
|
2600
2652
|
enter(t) {
|
|
2601
2653
|
super.enter(t), this.currentShader.setUniform("u_projection", this.rapid.projection);
|
|
2602
2654
|
}
|
|
2603
2655
|
createShader(t, e) {
|
|
2604
|
-
const
|
|
2605
|
-
return
|
|
2606
|
-
{ name: "aPosition", size: 2, stride:
|
|
2607
|
-
{ name: "aScale", size: 2, stride:
|
|
2608
|
-
{ name: "aRotation", size: 1, stride:
|
|
2609
|
-
{ name: "aUVRect", size: 4, stride:
|
|
2610
|
-
{ name: "aColor", size: 4, type:
|
|
2611
|
-
{ name: "aOrigin", size: 2, stride:
|
|
2612
|
-
]), this.quadBuffer.bindBuffer(),
|
|
2656
|
+
const r = super.createShader(t, e);
|
|
2657
|
+
return r.use(), r.bindVAO(), this.instanceBuffer.bindBuffer(), r.setAttributes([
|
|
2658
|
+
{ name: "aPosition", size: 2, stride: V, offset: 0, divisor: 1 },
|
|
2659
|
+
{ name: "aScale", size: 2, stride: V, offset: 8, divisor: 1 },
|
|
2660
|
+
{ name: "aRotation", size: 1, stride: V, offset: 16, divisor: 1 },
|
|
2661
|
+
{ name: "aUVRect", size: 4, stride: V, offset: 20, divisor: 1 },
|
|
2662
|
+
{ name: "aColor", size: 4, type: st, normalized: !0, stride: V, offset: 36, divisor: 1 },
|
|
2663
|
+
{ name: "aOrigin", size: 2, stride: V, offset: 40, divisor: 1 }
|
|
2664
|
+
]), this.quadBuffer.bindBuffer(), r.setAttributes([
|
|
2613
2665
|
{ name: "aVertex", size: 2, stride: 8, offset: 0, divisor: 0 }
|
|
2614
|
-
]),
|
|
2666
|
+
]), r.unbindVAO(), this.currentShader && this.currentShader.use(), r;
|
|
2615
2667
|
}
|
|
2616
|
-
drawParticles(t, e,
|
|
2668
|
+
drawParticles(t, e, r, i = 0, s = 4294967295, a, o = 1, h = 1, c = 0, u = 0, l = 1, d = 1, f = !1, x = !1, g = !1, v = 0.5, T = 0.5, A, R = !1, S) {
|
|
2617
2669
|
if (!t.glTexture || a <= 0) return;
|
|
2618
|
-
let
|
|
2619
|
-
const
|
|
2620
|
-
|
|
2670
|
+
let P = 0;
|
|
2671
|
+
const H = typeof o == "number", X = typeof h == "number", B = typeof i == "number", N = typeof s == "number", b = !N && typeof s[0] == "number";
|
|
2672
|
+
let _ = t.rawWidth * (f ? -1 : 1);
|
|
2673
|
+
H && (_ *= o);
|
|
2674
|
+
let W = t.rawHeight * (x ? -1 : 1);
|
|
2675
|
+
X && (W *= h);
|
|
2676
|
+
let D = g ? Math.PI / 2 : 0;
|
|
2677
|
+
for (B && (D += i); P < a; ) {
|
|
2621
2678
|
this.texture && t !== this.texture && this.flush(), this.texture || (this.texture = t, this.useTexture(t.glTexture, 0, 0));
|
|
2622
|
-
const
|
|
2623
|
-
let
|
|
2624
|
-
|
|
2625
|
-
const
|
|
2626
|
-
for (let
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2679
|
+
const k = a - P, I = this.instanceBuffer;
|
|
2680
|
+
let M = I.usedElemNum;
|
|
2681
|
+
I.resize(k * xt);
|
|
2682
|
+
const L = I.float32, z = I.uint32;
|
|
2683
|
+
for (let y = 0; y < k; y++) {
|
|
2684
|
+
const w = R ? a - 1 - P - y : P + y;
|
|
2685
|
+
if (L[M] = e[w], L[M + 1] = r[w], L[M + 2] = H ? _ : _ * o[w], L[M + 3] = X ? W : W * h[w], L[M + 4] = B ? D : i[w] + D, L[M + 5] = c, L[M + 6] = u, L[M + 7] = l, L[M + 8] = d, N)
|
|
2686
|
+
z[M + 9] = 4294967295;
|
|
2687
|
+
else if (b)
|
|
2688
|
+
z[M + 9] = s[w];
|
|
2689
|
+
else {
|
|
2690
|
+
const ht = s[w];
|
|
2691
|
+
z[M + 9] = A ? ht.premultipliedUint32 : ht.uint32;
|
|
2692
|
+
}
|
|
2693
|
+
L[M + 10] = v, L[M + 11] = T, M += xt;
|
|
2629
2694
|
}
|
|
2630
|
-
|
|
2695
|
+
I.usedElemNum = M, I.makeDirty(), this.instanceCount += k, P += k;
|
|
2631
2696
|
}
|
|
2697
|
+
this.customMatrix = S, this.flush();
|
|
2632
2698
|
}
|
|
2633
2699
|
render() {
|
|
2634
2700
|
if (this.instanceCount === 0) return;
|
|
@@ -2637,11 +2703,11 @@ class ie extends rt {
|
|
|
2637
2703
|
this.texture && (t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.texture.glTexture));
|
|
2638
2704
|
const e = this.currentShader;
|
|
2639
2705
|
this.instanceBuffer.bindBuffer(), this.instanceBuffer.bufferData(), e.bindVAO();
|
|
2640
|
-
const
|
|
2641
|
-
this.currentShader.setUniform("u_projection", a),
|
|
2706
|
+
const r = this.rapid.matrixStack, s = this.rapid.matrix.getMatrix(this.customMatrix ?? r.curWorldM), a = Vt(this.rapid.projection, s);
|
|
2707
|
+
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;
|
|
2642
2708
|
}
|
|
2643
2709
|
}
|
|
2644
|
-
var
|
|
2710
|
+
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 || {});
|
|
2645
2711
|
class ce {
|
|
2646
2712
|
/** The active WebGL context. */
|
|
2647
2713
|
gl;
|
|
@@ -2668,7 +2734,7 @@ class ce {
|
|
|
2668
2734
|
/** Maximum number of texture units supported by the device. */
|
|
2669
2735
|
maxTextureUnits = 0;
|
|
2670
2736
|
/** Matrix stack for hierarchical transformations. */
|
|
2671
|
-
matrixStack = new
|
|
2737
|
+
matrixStack = new At(this);
|
|
2672
2738
|
/** Direct access to the underlying matrix store. */
|
|
2673
2739
|
matrix;
|
|
2674
2740
|
/** Region dedicated to fast sprite rendering. */
|
|
@@ -2693,7 +2759,7 @@ class ce {
|
|
|
2693
2759
|
scaleMode;
|
|
2694
2760
|
/** Internal ping-pong RenderTextures for multi-filter chains. */
|
|
2695
2761
|
_filterRT = [null, null];
|
|
2696
|
-
_filterInput = new
|
|
2762
|
+
_filterInput = new F();
|
|
2697
2763
|
get height() {
|
|
2698
2764
|
return this.logicHeight;
|
|
2699
2765
|
}
|
|
@@ -2706,10 +2772,10 @@ class ce {
|
|
|
2706
2772
|
*/
|
|
2707
2773
|
constructor(t) {
|
|
2708
2774
|
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;
|
|
2709
|
-
const e =
|
|
2710
|
-
this.gl = e, this.maxTextureUnits = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), this.matrix = this.matrixStack.matrix, this.spriteRegion = new
|
|
2711
|
-
const
|
|
2712
|
-
this.physicsWidth = t.physicsWidth || Math.round(
|
|
2775
|
+
const e = _t(this.canvas, this.antialias, this.premultipliedAlpha);
|
|
2776
|
+
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);
|
|
2777
|
+
const r = this.canvas.clientWidth || this.canvas.width, i = this.canvas.clientHeight || this.canvas.height;
|
|
2778
|
+
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);
|
|
2713
2779
|
}
|
|
2714
2780
|
setTextureFilter(t) {
|
|
2715
2781
|
this.textureFilter = t;
|
|
@@ -2718,7 +2784,7 @@ class ce {
|
|
|
2718
2784
|
this.antialias = t;
|
|
2719
2785
|
}
|
|
2720
2786
|
getColorUint32(t) {
|
|
2721
|
-
return t
|
|
2787
|
+
return $t(this.premultipliedAlpha, t);
|
|
2722
2788
|
}
|
|
2723
2789
|
/**
|
|
2724
2790
|
* Enters a specific rendering region, flushing the previous one if necessary.
|
|
@@ -2729,22 +2795,22 @@ class ce {
|
|
|
2729
2795
|
this.currentRegion === t && this.currentRegion.isSameShader(e) || (this.flush(), this.currentRegion = t, t.enter(e));
|
|
2730
2796
|
}
|
|
2731
2797
|
drawParticles(t) {
|
|
2732
|
-
|
|
2798
|
+
Qt(this, t);
|
|
2733
2799
|
}
|
|
2734
2800
|
drawSprite(t) {
|
|
2735
|
-
|
|
2801
|
+
qt(this, t);
|
|
2736
2802
|
}
|
|
2737
2803
|
drawLine(t) {
|
|
2738
2804
|
Zt(this, t);
|
|
2739
2805
|
}
|
|
2740
2806
|
drawGraphic(t) {
|
|
2741
|
-
|
|
2807
|
+
Rt(this, t);
|
|
2742
2808
|
}
|
|
2743
2809
|
drawRect(t) {
|
|
2744
|
-
|
|
2810
|
+
te(this, t);
|
|
2745
2811
|
}
|
|
2746
2812
|
drawCircle(t) {
|
|
2747
|
-
|
|
2813
|
+
ee(this, t);
|
|
2748
2814
|
}
|
|
2749
2815
|
/**
|
|
2750
2816
|
* Starts rendering arbitrary graphics geometries.
|
|
@@ -2752,23 +2818,23 @@ class ce {
|
|
|
2752
2818
|
* @param texture An optional texture applied to the graphic vertices.
|
|
2753
2819
|
* @param customShader An optional custom shader overriding the region's default shader.
|
|
2754
2820
|
*/
|
|
2755
|
-
startGraphic(t = this.gl.TRIANGLES, e,
|
|
2756
|
-
this.enterRegion(this.graphicRegion,
|
|
2821
|
+
startGraphic(t = this.gl.TRIANGLES, e, r, i) {
|
|
2822
|
+
this.enterRegion(this.graphicRegion, r), this.graphicRegion.startGraphic(i ?? this.matrixStack.curWorldM, t, e);
|
|
2757
2823
|
}
|
|
2758
2824
|
/**
|
|
2759
2825
|
* Starts rendering graphics explicitly for use as a mask, overriding the shader.
|
|
2760
2826
|
* @param drawMode The WebGL drawing mode (e.g., gl.TRIANGLES).
|
|
2761
2827
|
* @param texture An optional texture whose alpha channel may dictate masking rules.
|
|
2762
2828
|
*/
|
|
2763
|
-
startMaskGraphic(t = this.gl.TRIANGLES, e,
|
|
2764
|
-
this.startGraphic(t, e, this.graphicRegion.maskShader,
|
|
2829
|
+
startMaskGraphic(t = this.gl.TRIANGLES, e, r) {
|
|
2830
|
+
this.startGraphic(t, e, this.graphicRegion.maskShader, r);
|
|
2765
2831
|
}
|
|
2766
2832
|
/**
|
|
2767
2833
|
* Utility method: Draws an image directly as a mask using a generic rectangle geometry.
|
|
2768
2834
|
* @param texture The texture to be used as a mask.
|
|
2769
2835
|
*/
|
|
2770
2836
|
drawMaskImage(t) {
|
|
2771
|
-
|
|
2837
|
+
Jt(this, t);
|
|
2772
2838
|
}
|
|
2773
2839
|
/**
|
|
2774
2840
|
* Pushes vertices for a rectangle geometry. Should be enclosed by startGraphic and endGraphic.
|
|
@@ -2776,9 +2842,9 @@ class ce {
|
|
|
2776
2842
|
* @param h The height of the rectangle.
|
|
2777
2843
|
* @param color An optional tint color.
|
|
2778
2844
|
*/
|
|
2779
|
-
addRectVertex(t, e,
|
|
2780
|
-
const
|
|
2781
|
-
this.addGraphicVertex(0, 0, 0, 0,
|
|
2845
|
+
addRectVertex(t, e, r) {
|
|
2846
|
+
const i = this.getColorUint32(r);
|
|
2847
|
+
this.addGraphicVertex(0, 0, 0, 0, i), this.addGraphicVertex(t, 0, 1, 0, i), this.addGraphicVertex(t, e, 1, 1, i), this.addGraphicVertex(0, e, 0, 1, i);
|
|
2782
2848
|
}
|
|
2783
2849
|
/**
|
|
2784
2850
|
* Pushes vertices for a circle geometry using TRIANGLES or similar primitives.
|
|
@@ -2786,11 +2852,11 @@ class ce {
|
|
|
2786
2852
|
* @param color An optional tint color.
|
|
2787
2853
|
* @param segments The number of segments (polygons) used to approximate the circle.
|
|
2788
2854
|
*/
|
|
2789
|
-
addCircleVertex(t, e,
|
|
2790
|
-
const
|
|
2791
|
-
for (let a = 0; a <
|
|
2792
|
-
const o =
|
|
2793
|
-
this.addGraphicVertex(h, c, u,
|
|
2855
|
+
addCircleVertex(t, e, r = 32) {
|
|
2856
|
+
const i = Math.PI * 2 / r, s = this.getColorUint32(e);
|
|
2857
|
+
for (let a = 0; a < r; a++) {
|
|
2858
|
+
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;
|
|
2859
|
+
this.addGraphicVertex(h, c, u, l, s);
|
|
2794
2860
|
}
|
|
2795
2861
|
}
|
|
2796
2862
|
/**
|
|
@@ -2801,8 +2867,8 @@ class ce {
|
|
|
2801
2867
|
* @param v The V texture coordinate (0 to 1).
|
|
2802
2868
|
* @param color The vertex color as a 32-bit unsigned integer.
|
|
2803
2869
|
*/
|
|
2804
|
-
addGraphicVertex(t, e,
|
|
2805
|
-
this.graphicRegion.addVertex(t, e,
|
|
2870
|
+
addGraphicVertex(t, e, r = 0, i = 0, s = 4294967295) {
|
|
2871
|
+
this.graphicRegion.addVertex(t, e, r, i, s);
|
|
2806
2872
|
}
|
|
2807
2873
|
/**
|
|
2808
2874
|
* Ends the current graphics geometry definition, readying it for rendering.
|
|
@@ -2817,10 +2883,10 @@ class ce {
|
|
|
2817
2883
|
* @param cssWidth Optional CSS display width.
|
|
2818
2884
|
* @param cssHeight Optional CSS display height.
|
|
2819
2885
|
*/
|
|
2820
|
-
resize(t, e,
|
|
2886
|
+
resize(t, e, r, i) {
|
|
2821
2887
|
this.flush();
|
|
2822
|
-
const
|
|
2823
|
-
switch (
|
|
2888
|
+
const s = r ?? this.canvas.clientWidth ?? this.canvas.width, a = i ?? this.canvas.clientHeight ?? this.canvas.height;
|
|
2889
|
+
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) {
|
|
2824
2890
|
case 1:
|
|
2825
2891
|
this.canvas.width = t, this.canvas.height = e, this.canvas.style.imageRendering = "pixelated", this.gl.viewport(0, 0, t, e);
|
|
2826
2892
|
break;
|
|
@@ -2836,8 +2902,8 @@ class ce {
|
|
|
2836
2902
|
* Updates the projection matrix using an orthographic mapping.
|
|
2837
2903
|
* Automatically sets local flag projectionDirty.
|
|
2838
2904
|
*/
|
|
2839
|
-
updateProjection(t, e,
|
|
2840
|
-
this.updateOrthMatrix(this.projection, t, e,
|
|
2905
|
+
updateProjection(t, e, r, i) {
|
|
2906
|
+
this.updateOrthMatrix(this.projection, t, e, r, i), this.projectionDirty = !0;
|
|
2841
2907
|
}
|
|
2842
2908
|
/**
|
|
2843
2909
|
* Clears the active framebuffer applying the default background color.
|
|
@@ -2850,8 +2916,8 @@ class ce {
|
|
|
2850
2916
|
* Populates an orthographic projection matrix in place.
|
|
2851
2917
|
* Avoids continuous Float32Array allocations for performance reasons.
|
|
2852
2918
|
*/
|
|
2853
|
-
updateOrthMatrix(t, e,
|
|
2854
|
-
t[0] = 2 / (
|
|
2919
|
+
updateOrthMatrix(t, e, r, i, s) {
|
|
2920
|
+
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;
|
|
2855
2921
|
}
|
|
2856
2922
|
/**
|
|
2857
2923
|
* Flushes currently buffered rendering operations across all active regions.
|
|
@@ -2876,9 +2942,9 @@ class ce {
|
|
|
2876
2942
|
applyFilters(t, e) {
|
|
2877
2943
|
if (e.length === 0)
|
|
2878
2944
|
throw new Error("applyFilters: shaders array must not be empty.");
|
|
2879
|
-
const
|
|
2945
|
+
const r = Math.max(...e.map((c) => c.padding)), i = r, s = t.rawWidth + r * 2, a = t.rawHeight + r * 2;
|
|
2880
2946
|
for (let c = 0; c < 2; c++)
|
|
2881
|
-
this._filterRT[c] ? this._filterRT[c].resize(
|
|
2947
|
+
this._filterRT[c] ? this._filterRT[c].resize(s, a) : this._filterRT[c] = this.texture.createRenderTexture({ width: s, height: a });
|
|
2882
2948
|
let o = t.clone(this._filterInput), h = 0;
|
|
2883
2949
|
this.matrixStack.save(), this.matrixStack.identity();
|
|
2884
2950
|
for (let c = 0; c < e.length; c++) {
|
|
@@ -2886,13 +2952,13 @@ class ce {
|
|
|
2886
2952
|
u.offsetX = 0, u.offsetY = 0, this.enterRenderTexture(u), this.clearRenderTexture(), this.drawSprite({
|
|
2887
2953
|
texture: o,
|
|
2888
2954
|
shader: e[c],
|
|
2889
|
-
offsetX: c == 0 ?
|
|
2955
|
+
offsetX: c == 0 ? i : 0,
|
|
2890
2956
|
// padding back
|
|
2891
|
-
offsetY: c == 0 ?
|
|
2892
|
-
padding:
|
|
2957
|
+
offsetY: c == 0 ? i : 0,
|
|
2958
|
+
padding: r
|
|
2893
2959
|
}), this.leaveRenderTexture(), o = u, h++;
|
|
2894
2960
|
}
|
|
2895
|
-
return this.matrixStack.restore(), o.offsetX = -
|
|
2961
|
+
return this.matrixStack.restore(), o.offsetX = -i, o.offsetY = -i, o;
|
|
2896
2962
|
}
|
|
2897
2963
|
enterRenderTexture(t) {
|
|
2898
2964
|
this.flush(), t.activate(), this.gl.viewport(0, 0, t.rawWidth, t.rawHeight), this.updateProjection(0, t.rawWidth, t.rawHeight, 0);
|
|
@@ -2926,10 +2992,10 @@ class ce {
|
|
|
2926
2992
|
* rapid.drawSprite({ texture: mySprite });
|
|
2927
2993
|
* });
|
|
2928
2994
|
*/
|
|
2929
|
-
drawToRenderTexture(t, e,
|
|
2995
|
+
drawToRenderTexture(t, e, r = new m(0, 0, 0, 0)) {
|
|
2930
2996
|
this.enterRenderTexture(t);
|
|
2931
2997
|
try {
|
|
2932
|
-
|
|
2998
|
+
r !== null && this.clearRenderTexture(r), e();
|
|
2933
2999
|
} finally {
|
|
2934
3000
|
this.leaveRenderTexture();
|
|
2935
3001
|
}
|
|
@@ -2947,14 +3013,14 @@ class ce {
|
|
|
2947
3013
|
* () => rapid.drawSprite({ texture: myTexture }),
|
|
2948
3014
|
* );
|
|
2949
3015
|
*/
|
|
2950
|
-
withMask(t, e,
|
|
2951
|
-
this.clearMask(), this.startDrawMask(
|
|
3016
|
+
withMask(t, e, r = 0, i = 1) {
|
|
3017
|
+
this.clearMask(), this.startDrawMask(i);
|
|
2952
3018
|
try {
|
|
2953
3019
|
t();
|
|
2954
3020
|
} finally {
|
|
2955
3021
|
this.endDrawMask();
|
|
2956
3022
|
}
|
|
2957
|
-
this.enterMask(
|
|
3023
|
+
this.enterMask(r, i);
|
|
2958
3024
|
try {
|
|
2959
3025
|
e();
|
|
2960
3026
|
} finally {
|
|
@@ -2983,21 +3049,12 @@ class ce {
|
|
|
2983
3049
|
* rapid.drawSprite({ texture: myTexture });
|
|
2984
3050
|
* }, { x: 100, y: 50, rotation: Math.PI / 4, origin: 0.5 }, myTexture.width, myTexture.height);
|
|
2985
3051
|
*/
|
|
2986
|
-
withTransform(t, e,
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
n && this.matrixStack.restore();
|
|
2993
|
-
}
|
|
2994
|
-
} else {
|
|
2995
|
-
this.matrixStack.save();
|
|
2996
|
-
try {
|
|
2997
|
-
t();
|
|
2998
|
-
} finally {
|
|
2999
|
-
this.matrixStack.restore();
|
|
3000
|
-
}
|
|
3052
|
+
withTransform(t, e, r = 0, i = 0) {
|
|
3053
|
+
this.matrixStack.save();
|
|
3054
|
+
try {
|
|
3055
|
+
e && this.matrixStack.applyTransform(e, r, i), t();
|
|
3056
|
+
} finally {
|
|
3057
|
+
this.matrixStack.restore();
|
|
3001
3058
|
}
|
|
3002
3059
|
}
|
|
3003
3060
|
/**
|
|
@@ -3013,10 +3070,10 @@ class ce {
|
|
|
3013
3070
|
* rapid.drawSprite({ texture: myTexture });
|
|
3014
3071
|
* });
|
|
3015
3072
|
*/
|
|
3016
|
-
withScissor(t, e,
|
|
3017
|
-
this.startScissor(t, e,
|
|
3073
|
+
withScissor(t, e, r, i, s) {
|
|
3074
|
+
this.startScissor(t, e, r, i);
|
|
3018
3075
|
try {
|
|
3019
|
-
|
|
3076
|
+
s();
|
|
3020
3077
|
} finally {
|
|
3021
3078
|
this.endScissor();
|
|
3022
3079
|
}
|
|
@@ -3049,8 +3106,8 @@ class ce {
|
|
|
3049
3106
|
*/
|
|
3050
3107
|
startDrawMask(t = 1, e = 255) {
|
|
3051
3108
|
this.flush();
|
|
3052
|
-
const
|
|
3053
|
-
|
|
3109
|
+
const r = this.gl;
|
|
3110
|
+
r.stencilMask(e), r.colorMask(!1, !1, !1, !1), r.stencilFunc(r.ALWAYS, t, e), r.stencilOp(r.KEEP, r.KEEP, r.REPLACE), this.enterRegion(this.graphicRegion, this.graphicRegion.maskShader), this.inCreateMask = !0;
|
|
3054
3111
|
}
|
|
3055
3112
|
/**
|
|
3056
3113
|
* Finishes the mask drawing phase and restores color buffer writing.
|
|
@@ -3075,10 +3132,10 @@ class ce {
|
|
|
3075
3132
|
* @param ref The reference value to test against.
|
|
3076
3133
|
* @param mask The bitmask specifying which stencil bits to consider.
|
|
3077
3134
|
*/
|
|
3078
|
-
enterMask(t, e = 1,
|
|
3135
|
+
enterMask(t, e = 1, r = 255) {
|
|
3079
3136
|
this.flush();
|
|
3080
|
-
const
|
|
3081
|
-
|
|
3137
|
+
const i = this.gl;
|
|
3138
|
+
i.colorMask(!0, !0, !0, !0), i.stencilMask(0), i.stencilFunc(t === 0 ? i.EQUAL : i.NOTEQUAL, e, r), i.stencilOp(i.KEEP, i.KEEP, i.KEEP), this.inCreateMask = !1;
|
|
3082
3139
|
}
|
|
3083
3140
|
/**
|
|
3084
3141
|
* Exits the masked rendering phase, restoring default full-screen stencil values tests.
|
|
@@ -3122,10 +3179,10 @@ class ce {
|
|
|
3122
3179
|
* @param width Width in logical pixels.
|
|
3123
3180
|
* @param height Height in logical pixels.
|
|
3124
3181
|
*/
|
|
3125
|
-
startScissor(t, e,
|
|
3182
|
+
startScissor(t, e, r, i) {
|
|
3126
3183
|
this.flush();
|
|
3127
|
-
const
|
|
3128
|
-
|
|
3184
|
+
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);
|
|
3185
|
+
s.enable(s.SCISSOR_TEST), s.scissor(h, c, u, l);
|
|
3129
3186
|
}
|
|
3130
3187
|
/**
|
|
3131
3188
|
* Disables scissor clipping, restoring full-canvas rendering.
|
|
@@ -3139,13 +3196,13 @@ class ce {
|
|
|
3139
3196
|
this.matrix.invert(e);
|
|
3140
3197
|
}
|
|
3141
3198
|
logicToPhysics(t) {
|
|
3142
|
-
return t.multiply(new
|
|
3199
|
+
return t.multiply(new p(
|
|
3143
3200
|
this.physicsWidth / this.logicWidth,
|
|
3144
3201
|
this.physicsHeight / this.logicHeight
|
|
3145
3202
|
));
|
|
3146
3203
|
}
|
|
3147
3204
|
physicsToLogic(t) {
|
|
3148
|
-
return t.multiply(new
|
|
3205
|
+
return t.multiply(new p(
|
|
3149
3206
|
this.logicWidth / this.physicsWidth,
|
|
3150
3207
|
this.logicHeight / this.physicsHeight
|
|
3151
3208
|
));
|
|
@@ -3169,14 +3226,14 @@ class ce {
|
|
|
3169
3226
|
* @param index - Matrix index to export. Defaults to the current world matrix.
|
|
3170
3227
|
*/
|
|
3171
3228
|
toCSSMatrix(t) {
|
|
3172
|
-
const e = this.physicsWidth / this.dpr / this.logicWidth,
|
|
3173
|
-
return this.matrix.toCSSMatrix(t ?? this.matrixStack.curWorldM, e,
|
|
3229
|
+
const e = this.physicsWidth / this.dpr / this.logicWidth, r = this.physicsHeight / this.dpr / this.logicHeight;
|
|
3230
|
+
return this.matrix.toCSSMatrix(t ?? this.matrixStack.curWorldM, e, r);
|
|
3174
3231
|
}
|
|
3175
3232
|
}
|
|
3176
|
-
function
|
|
3177
|
-
return !(
|
|
3233
|
+
function he(n) {
|
|
3234
|
+
return !(n === null || typeof n != "object" || Array.isArray(n) || n instanceof p || n instanceof m);
|
|
3178
3235
|
}
|
|
3179
|
-
class
|
|
3236
|
+
class O {
|
|
3180
3237
|
/** Random float in [min, max). */
|
|
3181
3238
|
static float(t, e) {
|
|
3182
3239
|
return Math.random() * (e - t) + t;
|
|
@@ -3190,21 +3247,21 @@ class C {
|
|
|
3190
3247
|
return Math.random() * Math.PI * 2;
|
|
3191
3248
|
}
|
|
3192
3249
|
/** Random Vec2 with components in the supplied per-axis ranges. */
|
|
3193
|
-
static vector(t, e,
|
|
3194
|
-
return new
|
|
3250
|
+
static vector(t, e, r, i) {
|
|
3251
|
+
return new p(O.float(t, e), O.float(r, i));
|
|
3195
3252
|
}
|
|
3196
3253
|
/** Random Color with each component interpolated between minColor and maxColor. */
|
|
3197
3254
|
static randomColor(t, e) {
|
|
3198
3255
|
return new m(
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3256
|
+
O.float(t.r, e.r),
|
|
3257
|
+
O.float(t.g, e.g),
|
|
3258
|
+
O.float(t.b, e.b),
|
|
3259
|
+
O.float(t.a, e.a)
|
|
3203
3260
|
);
|
|
3204
3261
|
}
|
|
3205
3262
|
/** Pick a random element from an array with uniform probability. */
|
|
3206
3263
|
static pick(t) {
|
|
3207
|
-
return t[
|
|
3264
|
+
return t[O.int(0, t.length - 1)];
|
|
3208
3265
|
}
|
|
3209
3266
|
/**
|
|
3210
3267
|
* Pick a random element using weighted probability.
|
|
@@ -3213,10 +3270,10 @@ class C {
|
|
|
3213
3270
|
static pickWeight(t) {
|
|
3214
3271
|
if (!t || t.length === 0) return null;
|
|
3215
3272
|
let e = 0;
|
|
3216
|
-
for (const [,
|
|
3217
|
-
let
|
|
3218
|
-
for (const [
|
|
3219
|
-
if (
|
|
3273
|
+
for (const [, i] of t) e += i;
|
|
3274
|
+
let r = Math.random() * e;
|
|
3275
|
+
for (const [i, s] of t)
|
|
3276
|
+
if (r -= s, r <= 0) return i;
|
|
3220
3277
|
return t[t.length - 1][0];
|
|
3221
3278
|
}
|
|
3222
3279
|
/**
|
|
@@ -3228,127 +3285,117 @@ class C {
|
|
|
3228
3285
|
static scalarOrRange(t, e) {
|
|
3229
3286
|
if (t == null) return e;
|
|
3230
3287
|
if (Array.isArray(t)) {
|
|
3231
|
-
const [
|
|
3232
|
-
if (typeof
|
|
3233
|
-
return
|
|
3234
|
-
if (
|
|
3235
|
-
return
|
|
3236
|
-
if (
|
|
3237
|
-
return
|
|
3288
|
+
const [r, i] = t;
|
|
3289
|
+
if (typeof r == "number")
|
|
3290
|
+
return O.float(r, i);
|
|
3291
|
+
if (r instanceof p)
|
|
3292
|
+
return O.vector(r.x, i.x, r.y, i.y);
|
|
3293
|
+
if (r instanceof m)
|
|
3294
|
+
return O.randomColor(r, i);
|
|
3238
3295
|
}
|
|
3239
3296
|
return typeof t == "number" ? t : t.clone();
|
|
3240
3297
|
}
|
|
3241
3298
|
}
|
|
3242
|
-
var
|
|
3243
|
-
const
|
|
3244
|
-
class
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
color: this.processAttribute(e.animation.color, m.White.clone()),
|
|
3258
|
-
velocity: this.processAttribute(e.animation.velocity, d.ZERO)
|
|
3259
|
-
}, this.position = d.ZERO, this.initializePosition();
|
|
3260
|
-
}
|
|
3261
|
-
processAttribute(t, e) {
|
|
3262
|
-
if (t == null)
|
|
3263
|
-
return { value: e };
|
|
3264
|
-
if (ae(t)) {
|
|
3265
|
-
const i = t, r = C.scalarOrRange(i.start, e), n = i.end === void 0 ? r : C.scalarOrRange(i.end, e);
|
|
3266
|
-
return {
|
|
3267
|
-
delta: i.delta ?? this.getDelta(r, n, this.maxLife),
|
|
3268
|
-
value: r,
|
|
3269
|
-
damping: i.damping
|
|
3270
|
-
};
|
|
3271
|
-
} else
|
|
3272
|
-
return this.processAttribute({ start: t }, e);
|
|
3273
|
-
}
|
|
3274
|
-
updateNumberAttribute(t, e) {
|
|
3275
|
-
t.damping !== void 0 && (t.value *= Math.pow(t.damping, e)), t.delta !== void 0 && (t.value += t.delta * e);
|
|
3276
|
-
}
|
|
3277
|
-
updateVec2Attribute(t, e) {
|
|
3278
|
-
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)));
|
|
3279
|
-
}
|
|
3280
|
-
updateColorAttribute(t, e) {
|
|
3281
|
-
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();
|
|
3282
|
-
}
|
|
3283
|
-
updateAttributes(t) {
|
|
3284
|
-
const e = this.datas;
|
|
3285
|
-
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);
|
|
3286
|
-
const r = d.fromAngle(e.rotation.value).multiply(e.speed.value * t);
|
|
3287
|
-
this.position = this.position.add(r).add(e.velocity.value.multiply(t));
|
|
3288
|
-
}
|
|
3289
|
-
getDelta(t, e, i) {
|
|
3290
|
-
return typeof t == "number" && typeof e == "number" ? (e - t) / i : t instanceof d && e instanceof d || t instanceof m && e instanceof m ? e.subtract(t).divide(i) : t;
|
|
3291
|
-
}
|
|
3292
|
-
/**
|
|
3293
|
-
* Updates particle state.
|
|
3294
|
-
* @param deltaTime - Seconds elapsed since last frame
|
|
3295
|
-
* @returns `true` while the particle is alive, `false` when it should be removed
|
|
3296
|
-
*/
|
|
3297
|
-
update(t) {
|
|
3298
|
-
return this.life += t, this.life >= this.maxLife ? !1 : (this.updateAttributes(t), !0);
|
|
3299
|
+
var oe = /* @__PURE__ */ ((n) => (n.POINT = "point", n.CIRCLE = "circle", n.RECT = "rect", n))(oe || {});
|
|
3300
|
+
const pt = 10, gt = 0, vt = !0;
|
|
3301
|
+
class K {
|
|
3302
|
+
components;
|
|
3303
|
+
constructor(t = 1) {
|
|
3304
|
+
if (!Number.isInteger(t) || t <= 0)
|
|
3305
|
+
throw new RangeError("ParticleAttributeStore size must be a positive integer");
|
|
3306
|
+
this.components = Array.from({ length: t }, () => ({
|
|
3307
|
+
value: new C(U.Float32),
|
|
3308
|
+
delta: new C(U.Float32),
|
|
3309
|
+
damping: new C(U.Float32)
|
|
3310
|
+
}));
|
|
3311
|
+
}
|
|
3312
|
+
getArrayBuffer() {
|
|
3313
|
+
return this.components.flatMap(({ value: t, delta: e, damping: r }) => [t, e, r]);
|
|
3299
3314
|
}
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
break;
|
|
3323
|
-
}
|
|
3315
|
+
update(t) {
|
|
3316
|
+
for (const { value: e, delta: r, damping: i } of this.components)
|
|
3317
|
+
for (let s = 0; s < e.usedElemNum; s++)
|
|
3318
|
+
e.typedArray[s] *= Math.pow(i.get(s), t), e.typedArray[s] += r.get(s) * t;
|
|
3319
|
+
}
|
|
3320
|
+
get(t, e = 0) {
|
|
3321
|
+
return this.components[e].value.get(t);
|
|
3322
|
+
}
|
|
3323
|
+
getComponent(t, e) {
|
|
3324
|
+
if (typeof t == "number")
|
|
3325
|
+
return t;
|
|
3326
|
+
if (t instanceof p)
|
|
3327
|
+
return e === 0 ? t.x : t.y;
|
|
3328
|
+
switch (e) {
|
|
3329
|
+
case 0:
|
|
3330
|
+
return t.r;
|
|
3331
|
+
case 1:
|
|
3332
|
+
return t.g;
|
|
3333
|
+
case 2:
|
|
3334
|
+
return t.b;
|
|
3335
|
+
case 3:
|
|
3336
|
+
return t.a;
|
|
3324
3337
|
default:
|
|
3325
|
-
|
|
3326
|
-
break;
|
|
3338
|
+
return 0;
|
|
3327
3339
|
}
|
|
3328
|
-
|
|
3340
|
+
}
|
|
3341
|
+
resolveComponent(t, e, r) {
|
|
3342
|
+
return t === void 0 ? r : Array.isArray(t) ? O.float(
|
|
3343
|
+
this.getComponent(t[0], e),
|
|
3344
|
+
this.getComponent(t[1], e)
|
|
3345
|
+
) : this.getComponent(t, e);
|
|
3346
|
+
}
|
|
3347
|
+
create(t, e, r = 1) {
|
|
3348
|
+
const i = he(t) ? t : void 0, s = i === void 0 ? t : void 0, a = r > 0 ? r : 1;
|
|
3349
|
+
let o = 0;
|
|
3350
|
+
for (let h = 0; h < this.components.length; h++) {
|
|
3351
|
+
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), x = i?.end === void 0 ? f : this.resolveComponent(i.end, h, d);
|
|
3352
|
+
c.push(f), u.push(i?.delta === void 0 ? (x - f) / a : this.getComponent(i.delta, h)), l.push(i?.damping ?? 1), h === 0 && (o = f);
|
|
3353
|
+
}
|
|
3354
|
+
return o;
|
|
3329
3355
|
}
|
|
3330
3356
|
}
|
|
3331
3357
|
class wt {
|
|
3332
|
-
particles = [];
|
|
3333
3358
|
options;
|
|
3334
3359
|
emitting = !1;
|
|
3335
3360
|
emitTimer = 0;
|
|
3336
|
-
emitRate =
|
|
3337
|
-
emitTime =
|
|
3361
|
+
emitRate = pt;
|
|
3362
|
+
emitTime = gt;
|
|
3338
3363
|
emitTimeCounter = 0;
|
|
3339
3364
|
/** Whether spawned particles are positioned in local emitter space (default: true). */
|
|
3340
|
-
localSpace =
|
|
3341
|
-
/** World position of the emitter. Used for both local-space transform and world-space spawn offset. */
|
|
3342
|
-
position = d.ZERO;
|
|
3365
|
+
localSpace = vt;
|
|
3343
3366
|
rapid;
|
|
3344
|
-
|
|
3367
|
+
x = new C(U.Float32);
|
|
3368
|
+
y = new C(U.Float32);
|
|
3369
|
+
scaleX = new C(U.Float32);
|
|
3370
|
+
scaleY = new C(U.Float32);
|
|
3371
|
+
rotation = new C(U.Float32);
|
|
3372
|
+
color = new C(U.Uint32);
|
|
3373
|
+
animations = {
|
|
3374
|
+
speed: new K(),
|
|
3375
|
+
rotation: new K(),
|
|
3376
|
+
scale: new K(),
|
|
3377
|
+
color: new K(4),
|
|
3378
|
+
velocity: new K(2)
|
|
3379
|
+
};
|
|
3380
|
+
count = 0;
|
|
3345
3381
|
/**
|
|
3346
3382
|
* Creates a new particle emitter.
|
|
3347
3383
|
* @param rapid - The Rapid renderer instance
|
|
3348
3384
|
* @param options - Emitter configuration options
|
|
3349
3385
|
*/
|
|
3350
3386
|
constructor(t, e) {
|
|
3351
|
-
this.rapid = t, this.options = e, this.emitRate = e.emitRate
|
|
3387
|
+
this.rapid = t, this.options = e, this.emitRate = e.emitRate ?? pt, this.emitTime = e.emitTime ?? gt, this.localSpace = e.localSpace ?? vt;
|
|
3388
|
+
}
|
|
3389
|
+
getAllArrayBuffer() {
|
|
3390
|
+
return [
|
|
3391
|
+
this.x,
|
|
3392
|
+
this.y,
|
|
3393
|
+
this.scaleX,
|
|
3394
|
+
this.scaleY,
|
|
3395
|
+
this.rotation,
|
|
3396
|
+
this.color,
|
|
3397
|
+
...Object.values(this.animations).flatMap((t) => t.getArrayBuffer())
|
|
3398
|
+
];
|
|
3352
3399
|
}
|
|
3353
3400
|
/** Replaces the emitter's texture at runtime. */
|
|
3354
3401
|
setTexture(t) {
|
|
@@ -3379,16 +3426,48 @@ class wt {
|
|
|
3379
3426
|
}
|
|
3380
3427
|
/** Removes all particles and resets timers. */
|
|
3381
3428
|
clear() {
|
|
3382
|
-
|
|
3429
|
+
for (const t of this.getAllArrayBuffer())
|
|
3430
|
+
t.clear();
|
|
3431
|
+
this.count = 0, this.emitTimeCounter = 0;
|
|
3383
3432
|
}
|
|
3384
3433
|
/**
|
|
3385
3434
|
* Spawns `count` particles immediately.
|
|
3386
3435
|
* Respects `maxParticles` if set.
|
|
3387
3436
|
*/
|
|
3388
3437
|
emit(t) {
|
|
3389
|
-
const e = this.options.maxParticles ?? 1 / 0,
|
|
3390
|
-
for (let
|
|
3391
|
-
this.
|
|
3438
|
+
const e = this.options.maxParticles ?? 1 / 0, r = Math.min(t, e - this.count);
|
|
3439
|
+
for (let i = 0; i < r; i++)
|
|
3440
|
+
this.createParticle();
|
|
3441
|
+
}
|
|
3442
|
+
createParticle() {
|
|
3443
|
+
const t = O.scalarOrRange(this.options.life, 1);
|
|
3444
|
+
let e = 0, r = 0;
|
|
3445
|
+
switch (this.options.emitShape) {
|
|
3446
|
+
case "circle": {
|
|
3447
|
+
const c = Math.random() * Math.PI * 2, u = (this.options.emitRadius ?? 0) * Math.sqrt(Math.random());
|
|
3448
|
+
e = Math.cos(c) * u, r = Math.sin(c) * u;
|
|
3449
|
+
break;
|
|
3450
|
+
}
|
|
3451
|
+
case "rect": {
|
|
3452
|
+
e = (Math.random() - 0.5) * (this.options.emitRect?.width ?? 0), r = (Math.random() - 0.5) * (this.options.emitRect?.height ?? 0);
|
|
3453
|
+
break;
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
const i = this.rapid.matrixStack;
|
|
3457
|
+
if (this.localSpace)
|
|
3458
|
+
this.x.push(e), this.y.push(r);
|
|
3459
|
+
else {
|
|
3460
|
+
const { x: c, y: u } = i.localToWorld(e, r);
|
|
3461
|
+
this.x.push(c), this.y.push(u);
|
|
3462
|
+
}
|
|
3463
|
+
const s = this.options.animation, a = this.animations, o = a.scale.create(s.scale, 1, t), h = a.rotation.create(s.rotation, 0, t);
|
|
3464
|
+
a.speed.create(s.speed, 0, t), a.velocity.create(s.velocity, p.ZERO, t), a.color.create(s.color, m.White, t), this.rotation.push(h), this.scaleX.push(o), this.scaleY.push(o), this.color.pushUint32(m.packColor(
|
|
3465
|
+
a.color.get(this.count, 0),
|
|
3466
|
+
a.color.get(this.count, 1),
|
|
3467
|
+
a.color.get(this.count, 2),
|
|
3468
|
+
a.color.get(this.count, 3),
|
|
3469
|
+
this.rapid.premultipliedAlpha
|
|
3470
|
+
)), this.count += 1;
|
|
3392
3471
|
}
|
|
3393
3472
|
/**
|
|
3394
3473
|
* Updates the emitter and all live particles.
|
|
@@ -3398,35 +3477,57 @@ class wt {
|
|
|
3398
3477
|
if (this.emitting && this.emitRate > 0)
|
|
3399
3478
|
if (this.emitTime > 0) {
|
|
3400
3479
|
if (this.emitTimeCounter += t, this.emitTimeCounter >= this.emitTime) {
|
|
3401
|
-
const
|
|
3402
|
-
this.emit(this.emitRate *
|
|
3480
|
+
const r = Math.floor(this.emitTimeCounter / this.emitTime);
|
|
3481
|
+
this.emit(this.emitRate * r), this.emitTimeCounter -= r * this.emitTime;
|
|
3403
3482
|
}
|
|
3404
3483
|
} else {
|
|
3405
3484
|
this.emitTimer += t;
|
|
3406
|
-
const
|
|
3407
|
-
|
|
3485
|
+
const r = Math.floor(this.emitTimer * this.emitRate);
|
|
3486
|
+
r > 0 && (this.emit(r), this.emitTimer -= r / this.emitRate);
|
|
3408
3487
|
}
|
|
3409
|
-
|
|
3410
|
-
|
|
3488
|
+
const e = this.updateParticle(t);
|
|
3489
|
+
this.count -= e.length, C.removeAtIndices(e, this.getAllArrayBuffer());
|
|
3490
|
+
}
|
|
3491
|
+
updateParticle(t) {
|
|
3492
|
+
const e = [], r = this.animations;
|
|
3493
|
+
Object.values(r).forEach((i) => i.update(t));
|
|
3494
|
+
for (let i = 0; i < this.count; i++) {
|
|
3495
|
+
const s = r.rotation.get(i), a = r.scale.get(i), o = r.speed.get(i);
|
|
3496
|
+
this.rotation.typedArray[i] = s, this.scaleX.typedArray[i] = a, this.scaleY.typedArray[i] = a, this.color.uint32[i] = m.packColor(
|
|
3497
|
+
r.color.get(i, 0),
|
|
3498
|
+
r.color.get(i, 1),
|
|
3499
|
+
r.color.get(i, 2),
|
|
3500
|
+
r.color.get(i, 3),
|
|
3501
|
+
this.rapid.premultipliedAlpha
|
|
3502
|
+
), 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;
|
|
3503
|
+
}
|
|
3504
|
+
return e;
|
|
3411
3505
|
}
|
|
3412
3506
|
/**
|
|
3413
3507
|
* Renders all live particles.
|
|
3414
3508
|
* In local-space mode the emitter's own transform is applied around the batch.
|
|
3415
3509
|
*/
|
|
3416
3510
|
render() {
|
|
3417
|
-
const t = this.rapid.
|
|
3418
|
-
this.
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3511
|
+
const t = this.options, e = this.localSpace ? void 0 : this.rapid.matrix.alloc();
|
|
3512
|
+
this.rapid.drawParticles({
|
|
3513
|
+
texture: t.texture,
|
|
3514
|
+
shader: t.shader,
|
|
3515
|
+
x: this.x.typedArray,
|
|
3516
|
+
y: this.y.typedArray,
|
|
3517
|
+
scaleX: this.scaleX.typedArray,
|
|
3518
|
+
scaleY: this.scaleY.typedArray,
|
|
3519
|
+
rotation: this.rotation.typedArray,
|
|
3520
|
+
color: this.color.typedArray,
|
|
3521
|
+
count: this.count,
|
|
3522
|
+
reverseOrder: !0,
|
|
3523
|
+
originX: t.origin?.x ?? 0.5,
|
|
3524
|
+
originY: t.origin?.y ?? 0.5,
|
|
3525
|
+
customMatrix: e
|
|
3526
|
+
});
|
|
3426
3527
|
}
|
|
3427
3528
|
/** Returns `true` if the emitter is running or still has live particles. */
|
|
3428
3529
|
isActive() {
|
|
3429
|
-
return this.emitting || this.
|
|
3530
|
+
return this.emitting || this.count > 0;
|
|
3430
3531
|
}
|
|
3431
3532
|
/**
|
|
3432
3533
|
* Convenience: emit `emitRate` particles in one shot (fire-and-forget burst).
|
|
@@ -3436,42 +3537,41 @@ class wt {
|
|
|
3436
3537
|
}
|
|
3437
3538
|
}
|
|
3438
3539
|
export {
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3540
|
+
U as ArrayType,
|
|
3541
|
+
Y as BaseTexture,
|
|
3542
|
+
ne as BlendMode,
|
|
3543
|
+
ae as CanvasScaleMode,
|
|
3443
3544
|
m as Color,
|
|
3444
|
-
|
|
3445
|
-
|
|
3545
|
+
ct as CustomGlShader,
|
|
3546
|
+
C as DynamicArrayBuffer,
|
|
3446
3547
|
Tt as GLShader,
|
|
3447
3548
|
Ht as GraphicRegion,
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3549
|
+
Xt as LineTextureMode,
|
|
3550
|
+
se as MaskType,
|
|
3551
|
+
At as MatrixStack,
|
|
3451
3552
|
Mt as MatrixStore,
|
|
3452
|
-
oe as Particle,
|
|
3453
3553
|
wt as ParticleEmitter,
|
|
3454
|
-
|
|
3455
|
-
|
|
3554
|
+
oe as ParticleShape,
|
|
3555
|
+
Wt as QUAD_VERTICES,
|
|
3456
3556
|
ce as Rapid,
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3557
|
+
Et as Region,
|
|
3558
|
+
bt as RenderTexture,
|
|
3559
|
+
at as SpriteRegion,
|
|
3560
|
+
Ct as TextTexture,
|
|
3561
|
+
F as Texture,
|
|
3562
|
+
nt as TextureFilterMode,
|
|
3563
|
+
St as TextureManager,
|
|
3564
|
+
q as TextureWrapMode,
|
|
3565
|
+
p as Vec2,
|
|
3566
|
+
et as WebglBufferArray,
|
|
3467
3567
|
Vt as composeProjectionWithAffine,
|
|
3468
|
-
|
|
3469
|
-
|
|
3568
|
+
ee as drawCircle,
|
|
3569
|
+
Rt as drawGraphic,
|
|
3470
3570
|
Zt as drawLine,
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3571
|
+
Jt as drawMaskImage,
|
|
3572
|
+
Qt as drawParticles,
|
|
3573
|
+
te as drawRect,
|
|
3574
|
+
qt as drawSprite,
|
|
3575
|
+
$t as getColorUint32,
|
|
3576
|
+
Yt as multiplyMat4
|
|
3477
3577
|
};
|