rapid-render 1.0.3 → 1.0.5

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.
@@ -1,5 +1,5 @@
1
- var I = /* @__PURE__ */ ((s) => (s[s.Float32 = 0] = "Float32", s[s.Uint32 = 1] = "Uint32", s[s.Uint16 = 2] = "Uint16", s))(I || {});
2
- class D {
1
+ var L = /* @__PURE__ */ ((s) => (s[s.Float32 = 0] = "Float32", s[s.Uint32 = 1] = "Uint32", s[s.Uint16 = 2] = "Uint16", s))(L || {});
2
+ class k {
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. */
@@ -151,7 +151,7 @@ class D {
151
151
  this.usedElemNum = 0;
152
152
  }
153
153
  }
154
- class et extends D {
154
+ class et extends k {
155
155
  /** The actual WebGLBuffer object maintained by this instance. */
156
156
  buffer;
157
157
  /** The related WebGL rendering context. */
@@ -451,7 +451,7 @@ class m {
451
451
  static Transparent = new m(0, 0, 0, 0);
452
452
  static TRANSPARENT = new m(0, 0, 0, 0);
453
453
  }
454
- const R = 6;
454
+ const E = 6;
455
455
  class St {
456
456
  /** Total number of matrices currently allocated in the store. */
457
457
  matrixCount = 0;
@@ -464,7 +464,7 @@ class St {
464
464
  * @param capacity - The initial capacity of the matrix store (default is 10).
465
465
  */
466
466
  constructor(t = 10) {
467
- this.buffer = new D(I.Float32), this.buffer.resize(t * R), this.data = this.buffer.getArray();
467
+ this.buffer = new k(L.Float32), this.buffer.resize(t * E), this.data = this.buffer.getArray();
468
468
  }
469
469
  /**
470
470
  * Allocates a new matrix and initializes it to the identity matrix.
@@ -479,7 +479,7 @@ class St {
479
479
  * @returns The index of the newly allocated matrix.
480
480
  */
481
481
  allocDirty() {
482
- return this.buffer.resize(R) && (this.data = this.buffer.getArray()), this.buffer.usedElemNum += R, this.matrixCount++;
482
+ return this.buffer.resize(E) && (this.data = this.buffer.getArray()), this.buffer.usedElemNum += E, this.matrixCount++;
483
483
  }
484
484
  /**
485
485
  * Resets the store, clearing all allocated matrices.
@@ -492,7 +492,7 @@ class St {
492
492
  * @param index - The index of the matrix to modify.
493
493
  */
494
494
  identity(t) {
495
- const e = t * R, i = this.data;
495
+ const e = t * E, i = this.data;
496
496
  i[e] = 1, i[e + 1] = 0, i[e + 2] = 0, i[e + 3] = 1, i[e + 4] = 0, i[e + 5] = 0;
497
497
  }
498
498
  /**
@@ -502,7 +502,7 @@ class St {
502
502
  * @param y - The y translation.
503
503
  */
504
504
  translate(t, e, i) {
505
- const r = t * R, n = this.data;
505
+ const r = t * E, n = this.data;
506
506
  n[r + 4] = n[r] * e + n[r + 2] * i + n[r + 4], n[r + 5] = n[r + 1] * e + n[r + 3] * i + n[r + 5];
507
507
  }
508
508
  /**
@@ -512,7 +512,7 @@ class St {
512
512
  * @param scaleY - The scale factor along the y-axis.
513
513
  */
514
514
  scale(t, e, i) {
515
- const r = t * R, n = this.data;
515
+ const r = t * E, n = this.data;
516
516
  n[r] *= e, n[r + 1] *= e, n[r + 2] *= i, n[r + 3] *= i;
517
517
  }
518
518
  /**
@@ -521,7 +521,7 @@ class St {
521
521
  * @param radians - The rotation angle in radians.
522
522
  */
523
523
  rotate(t, e) {
524
- const i = t * R, r = this.data, n = Math.cos(e), a = Math.sin(e), o = r[i], h = r[i + 1], c = r[i + 2], u = r[i + 3];
524
+ const i = t * E, r = this.data, n = Math.cos(e), a = Math.sin(e), o = r[i], h = r[i + 1], c = r[i + 2], u = r[i + 3];
525
525
  r[i] = o * n + c * a, r[i + 1] = h * n + u * a, r[i + 2] = o * -a + c * n, r[i + 3] = h * -a + u * n;
526
526
  }
527
527
  /**
@@ -549,7 +549,7 @@ class St {
549
549
  * @param src - The index of the source matrix.
550
550
  */
551
551
  copy(t, e) {
552
- const i = t * R, r = e * R, n = this.data;
552
+ const i = t * E, r = e * E, n = this.data;
553
553
  n[i] = n[r], n[i + 1] = n[r + 1], n[i + 2] = n[r + 2], n[i + 3] = n[r + 3], n[i + 4] = n[r + 4], n[i + 5] = n[r + 5];
554
554
  }
555
555
  /**
@@ -567,15 +567,15 @@ class St {
567
567
  * @param bIdx - The index of matrix B.
568
568
  */
569
569
  multiplyOut(t, e, i) {
570
- const r = t * R, n = e * R, a = i * R, o = this.data, h = o[n], c = o[n + 1], u = o[n + 2], f = o[n + 3], l = o[n + 4], p = o[n + 5], x = o[a], g = o[a + 1], v = o[a + 2], y = o[a + 3], w = o[a + 4], T = o[a + 5];
571
- o[r] = h * x + u * g, o[r + 1] = c * x + f * g, o[r + 2] = h * v + u * y, o[r + 3] = c * v + f * y, o[r + 4] = h * w + u * T + l, o[r + 5] = c * w + f * T + p;
570
+ const r = t * E, n = e * E, a = i * E, o = this.data, h = o[n], c = o[n + 1], u = o[n + 2], f = o[n + 3], l = o[n + 4], p = o[n + 5], x = o[a], v = o[a + 1], R = o[a + 2], T = o[a + 3], g = o[a + 4], w = o[a + 5];
571
+ o[r] = h * x + u * v, o[r + 1] = c * x + f * v, o[r + 2] = h * R + u * T, o[r + 3] = c * R + f * T, o[r + 4] = h * g + u * w + l, o[r + 5] = c * g + f * w + p;
572
572
  }
573
573
  /**
574
574
  * Inverts the matrix at the given index. If the matrix is not invertible, it defaults to the identity matrix.
575
575
  * @param index - The index of the matrix to invert.
576
576
  */
577
577
  invert(t) {
578
- const e = t * R, i = this.data, r = i[e], n = i[e + 1], a = i[e + 2], o = i[e + 3], h = i[e + 4], c = i[e + 5];
578
+ const e = t * E, i = this.data, r = i[e], n = i[e + 1], a = i[e + 2], o = i[e + 3], h = i[e + 4], c = i[e + 5];
579
579
  let u = r * o - n * a;
580
580
  if (!u) {
581
581
  this.identity(t);
@@ -591,7 +591,7 @@ class St {
591
591
  * @returns The transformed point {x, y}.
592
592
  */
593
593
  transformPoint(t, e, i) {
594
- const r = t * R, n = this.data;
594
+ const r = t * E, n = this.data;
595
595
  return {
596
596
  x: e * n[r] + i * n[r + 2] + n[r + 4],
597
597
  y: e * n[r + 1] + i * n[r + 3] + n[r + 5]
@@ -609,7 +609,7 @@ class St {
609
609
  const r = this.allocDirty();
610
610
  this.copy(r, t), this.invert(r);
611
611
  const n = this.transformPoint(r, e, i);
612
- return this.matrixCount--, this.buffer.usedElemNum -= R, n;
612
+ return this.matrixCount--, this.buffer.usedElemNum -= E, n;
613
613
  }
614
614
  /**
615
615
  * Transforms a point from local coordinates to world coordinates.
@@ -627,7 +627,7 @@ class St {
627
627
  * @returns An object containing `x` and `y` global coordinates.
628
628
  */
629
629
  getPosition(t) {
630
- const e = t * R, i = this.data;
630
+ const e = t * E, i = this.data;
631
631
  return { x: i[e + 4], y: i[e + 5] };
632
632
  }
633
633
  /**
@@ -636,7 +636,7 @@ class St {
636
636
  * @returns An object containing `x` and `y` global scale factors.
637
637
  */
638
638
  getScale(t) {
639
- const e = t * R, i = this.data, r = Math.sqrt(i[e] * i[e] + i[e + 1] * i[e + 1]), n = Math.sqrt(i[e + 2] * i[e + 2] + i[e + 3] * i[e + 3]);
639
+ const e = t * E, i = this.data, r = Math.sqrt(i[e] * i[e] + i[e + 1] * i[e + 1]), n = Math.sqrt(i[e + 2] * i[e + 2] + i[e + 3] * i[e + 3]);
640
640
  return { x: r, y: n };
641
641
  }
642
642
  /**
@@ -645,7 +645,7 @@ class St {
645
645
  * @returns The global rotation in radians.
646
646
  */
647
647
  getRotation(t) {
648
- const e = t * R, i = this.data;
648
+ const e = t * E, i = this.data;
649
649
  return Math.atan2(i[e + 1], i[e]);
650
650
  }
651
651
  /**
@@ -656,7 +656,7 @@ class St {
656
656
  * @returns A CSS matrix string.
657
657
  */
658
658
  toCSSMatrix(t, e = 1, i = 1) {
659
- const r = t * R, n = this.data;
659
+ const r = t * E, n = this.data;
660
660
  return `matrix(${n[r] * e}, ${n[r + 1] * i}, ${n[r + 2] * e}, ${n[r + 3] * i}, ${n[r + 4] * e}, ${n[r + 5] * i})`;
661
661
  }
662
662
  /**
@@ -667,8 +667,8 @@ class St {
667
667
  * @returns A new Float32Array containing the 6 elements of the matrix.
668
668
  */
669
669
  getMatrix(t) {
670
- const e = t * R;
671
- return this.data.slice(e, e + R);
670
+ const e = t * E;
671
+ return this.data.slice(e, e + E);
672
672
  }
673
673
  /**
674
674
  * Retrieves a direct reference (view) to the 6 elements [a, b, c, d, tx, ty] for the matrix at the specified index.
@@ -678,8 +678,8 @@ class St {
678
678
  * @returns A Float32Array view pointing directly to the matrix's data in memory.
679
679
  */
680
680
  getMatrixRef(t) {
681
- const e = t * R;
682
- return this.data.subarray(e, e + R);
681
+ const e = t * E;
682
+ return this.data.subarray(e, e + E);
683
683
  }
684
684
  /**
685
685
  * Overwrites the matrix at the specified index with the provided 6 elements [a, b, c, d, tx, ty].
@@ -688,12 +688,12 @@ class St {
688
688
  * @param f - An array (Float32Array or standard number array) containing the 6 new elements.
689
689
  */
690
690
  setMatrix(t, e) {
691
- const i = t * R, r = this.data;
691
+ const i = t * E, r = this.data;
692
692
  r[i] = e[0], r[i + 1] = e[1], r[i + 2] = e[2], r[i + 3] = e[3], r[i + 4] = e[4], r[i + 5] = e[5];
693
693
  }
694
694
  multiplyAffineInPlace(t, e, i, r, n, a, o) {
695
- const h = t * 6, c = this.data, u = c[h], f = c[h + 1], l = c[h + 2], p = c[h + 3], x = c[h + 4], g = c[h + 5];
696
- c[h] = u * e + l * i, c[h + 1] = f * e + p * i, c[h + 2] = u * r + l * n, c[h + 3] = f * r + p * n, c[h + 4] = u * a + l * o + x, c[h + 5] = f * a + p * o + g;
695
+ const h = t * 6, c = this.data, u = c[h], f = c[h + 1], l = c[h + 2], p = c[h + 3], x = c[h + 4], v = c[h + 5];
696
+ c[h] = u * e + l * i, c[h + 1] = f * e + p * i, c[h + 2] = u * r + l * n, c[h + 3] = f * r + p * n, c[h + 4] = u * a + l * o + x, c[h + 5] = f * a + p * o + v;
697
697
  }
698
698
  }
699
699
  class bt {
@@ -702,15 +702,15 @@ class bt {
702
702
  /** The current step or depth in the transformation hierarchy. */
703
703
  step = 0;
704
704
  /** Internal stack maintaining structural information. */
705
- stack = new D(I.Uint32);
705
+ stack = new k(L.Uint32);
706
706
  /** Records the world matrices generated at each step. */
707
- stepWorldM = new D(I.Uint32);
707
+ stepWorldM = new k(L.Uint32);
708
708
  /** Records actions (push/pop) taken during the traversal. */
709
- stepAction = new D(I.Uint32);
709
+ stepAction = new k(L.Uint32);
710
710
  /** Records the parent world matrix for each step (used by updateMatrix). */
711
- stepParentM = new D(I.Uint32);
711
+ stepParentM = new k(L.Uint32);
712
712
  /** Buffer used during hierarchy traversal updates. */
713
- parentStack = new D(I.Uint32);
713
+ parentStack = new k(L.Uint32);
714
714
  /** The index of the current local matrix in the matrix store. */
715
715
  curLocalM = -1;
716
716
  /** The index of the current world matrix in the matrix store. */
@@ -859,14 +859,14 @@ class bt {
859
859
  * Returns the current world matrix as Float32Array [a, b, c, d, tx, ty].
860
860
  */
861
861
  getTransform() {
862
- const t = this.curWorldM * R;
863
- return this.matrix.data.slice(t, t + R);
862
+ const t = this.curWorldM * E;
863
+ return this.matrix.data.slice(t, t + E);
864
864
  }
865
865
  /**
866
866
  * Directly overwrites the current world matrix with the given 6-element 2D transform.
867
867
  */
868
868
  setTransform(t) {
869
- const e = this.curWorldM * R, i = this.matrix.data;
869
+ const e = this.curWorldM * E, i = this.matrix.data;
870
870
  i[e] = t[0], i[e + 1] = t[1], i[e + 2] = t[2], i[e + 3] = t[3], i[e + 4] = t[4], i[e + 5] = t[5];
871
871
  }
872
872
  transformPoint(t, e) {
@@ -888,27 +888,27 @@ class bt {
888
888
  t.offset && (u += t.offset.x, f += t.offset.y);
889
889
  const l = t.origin;
890
890
  l !== void 0 && (typeof l == "number" ? (u -= l * e, f -= l * i) : (u -= l.x * e, f -= l.y * i));
891
- const p = c ? Math.cos(c) : 1, x = c ? Math.sin(c) : 0, g = p * a, v = x * a, y = -x * o, w = p * o, T = r + g * u + y * f, S = n + v * u + w * f;
891
+ const p = c ? Math.cos(c) : 1, x = c ? Math.sin(c) : 0, v = p * a, R = x * a, T = -x * o, g = p * o, w = r + v * u + T * f, b = n + R * u + g * f;
892
892
  (t.afterSave !== void 0 || t.saveTransform === !1) && this.matrix.multiplyAffineInPlace(
893
893
  this.curLocalM,
894
- g,
895
894
  v,
896
- y,
897
- w,
895
+ R,
898
896
  T,
899
- S
897
+ g,
898
+ w,
899
+ b
900
900
  ), this.matrix.multiplyAffineInPlace(
901
901
  this.curWorldM,
902
- g,
903
902
  v,
904
- y,
905
- w,
903
+ R,
906
904
  T,
907
- S
905
+ g,
906
+ w,
907
+ b
908
908
  ), t.afterSave?.();
909
909
  }
910
910
  }
911
- var z = /* @__PURE__ */ ((s) => (s[s.REPEAT = 0] = "REPEAT", s[s.CLAMP = 1] = "CLAMP", s[s.MIRRORED_REPEAT = 2] = "MIRRORED_REPEAT", s))(z || {});
911
+ var $ = /* @__PURE__ */ ((s) => (s[s.REPEAT = 0] = "REPEAT", s[s.CLAMP = 1] = "CLAMP", s[s.MIRRORED_REPEAT = 2] = "MIRRORED_REPEAT", s))($ || {});
912
912
  class At {
913
913
  render;
914
914
  cache = /* @__PURE__ */ new Map();
@@ -927,7 +927,7 @@ class At {
927
927
  return new P(i);
928
928
  try {
929
929
  const r = await this._fetchImage(t);
930
- return i = B.fromSource(this.render, r, e), i.uid = t, this.cache.set(t, i), new P(i);
930
+ return i = G.fromSource(this.render, r, e), i.uid = t, this.cache.set(t, i), new P(i);
931
931
  } catch (r) {
932
932
  throw console.error(`[TextureManager] Failed to load: ${t}`, r), r;
933
933
  }
@@ -941,7 +941,7 @@ class At {
941
941
  create(t, e) {
942
942
  if (e?.key && this.cache.has(e.key))
943
943
  return new P(this.cache.get(e.key));
944
- const i = B.fromSource(this.render, t, e);
944
+ const i = G.fromSource(this.render, t, e);
945
945
  return e?.key && (i.uid = e.key, this.cache.set(e.key, i)), new P(i);
946
946
  }
947
947
  /**
@@ -988,7 +988,7 @@ class At {
988
988
  });
989
989
  }
990
990
  }
991
- class B {
991
+ class G {
992
992
  glTexture = null;
993
993
  width;
994
994
  height;
@@ -1005,8 +1005,8 @@ class B {
1005
1005
  * @returns The created BaseTexture.
1006
1006
  */
1007
1007
  static fromSource(t, e, i = {}) {
1008
- const r = Z(t, e, i);
1009
- return new B(r, e.width, e.height);
1008
+ const r = Q(t, e, i);
1009
+ return new G(r, e.width, e.height);
1010
1010
  }
1011
1011
  /**
1012
1012
  * Updates the content of the existing texture (e.g. for Video or dynamic Canvas).
@@ -1120,8 +1120,8 @@ class P {
1120
1120
  if (!this.base) return [];
1121
1121
  const a = [], o = this.rawWidth, h = this.rawHeight, c = Math.max(0, n), u = t + c, f = e + c, l = i ?? Math.floor((o + c) / u), p = r ?? Math.floor((h + c) / f);
1122
1122
  for (let x = 0; x < p; x++)
1123
- for (let g = 0; g < l; g++)
1124
- a.push(this.getSubTexture(g * u, x * f, t, e));
1123
+ for (let v = 0; v < l; v++)
1124
+ a.push(this.getSubTexture(v * u, x * f, t, e));
1125
1125
  return a;
1126
1126
  }
1127
1127
  /**
@@ -1130,8 +1130,8 @@ class P {
1130
1130
  * @param options - Optional antialias and wrap mode settings.
1131
1131
  */
1132
1132
  static fromImageSource(t, e, i = {}) {
1133
- const r = Z(t, e, i);
1134
- return new P(new B(r, e.width, e.height));
1133
+ const r = Q(t, e, i);
1134
+ return new P(new G(r, e.width, e.height));
1135
1135
  }
1136
1136
  /**
1137
1137
  * Marks this Texture as destroyed, decrementing the BaseTexture reference count.
@@ -1151,8 +1151,8 @@ class Ut extends P {
1151
1151
  _allocH = 0;
1152
1152
  constructor(t, e) {
1153
1153
  super(), this.gl = t.gl, this.clearColor = e.clearColor ?? m.Black;
1154
- const i = Math.max(Math.round(e.width), 1), r = Math.max(Math.round(e.height), 1), a = Z(t, { width: i, height: r }, { ...e, onlySize: !0 });
1155
- if (this.setBase(new B(a, i, r)), this.framebuffer = this.gl.createFramebuffer(), this.renderbuffer = this.gl.createRenderbuffer(), !this.framebuffer || !this.renderbuffer)
1154
+ const i = Math.max(Math.round(e.width), 1), r = Math.max(Math.round(e.height), 1), a = Q(t, { width: i, height: r }, { ...e, onlySize: !0 });
1155
+ if (this.setBase(new G(a, i, r)), this.framebuffer = this.gl.createFramebuffer(), this.renderbuffer = this.gl.createRenderbuffer(), !this.framebuffer || !this.renderbuffer)
1156
1156
  throw new Error("Failed to create Framebuffer or Renderbuffer");
1157
1157
  this.resize(i, r, !0);
1158
1158
  }
@@ -1252,8 +1252,8 @@ class Ct extends P {
1252
1252
  const i = this.canvas.getContext("2d", { willReadFrequently: !0 });
1253
1253
  if (!i) throw new Error("Failed to get 2d context for TextTexture");
1254
1254
  this.ctx = i, this.canvas.width = 1, this.canvas.height = 1;
1255
- const r = Z(t, this.canvas, this.options);
1256
- this.setBase(new B(r, 1, 1)), this.update();
1255
+ const r = Q(t, this.canvas, this.options);
1256
+ this.setBase(new G(r, 1, 1)), this.update();
1257
1257
  }
1258
1258
  get text() {
1259
1259
  return this._text;
@@ -1308,17 +1308,17 @@ class Ct extends P {
1308
1308
  let h = 0, c = 0;
1309
1309
  t.textBaseline = "alphabetic";
1310
1310
  const u = t.measureText(o[0]), f = u.fontBoundingBoxAscent, l = u.fontBoundingBoxDescent;
1311
- for (const T of o) {
1312
- const S = t.measureText(T);
1313
- S.width > h && (h = S.width), c += f + l;
1311
+ for (const w of o) {
1312
+ const b = t.measureText(w);
1313
+ b.width > h && (h = b.width), c += f + l;
1314
1314
  }
1315
1315
  c -= l;
1316
- const p = (this._style.strokeThickness || 0) * 2, x = Math.ceil(h + p) || 1, g = Math.ceil(c + p) || 1, v = x * a, y = g * a;
1317
- (this.canvas.width !== v || this.canvas.height !== y) && (this.canvas.width = v, this.canvas.height = y), t.setTransform(a, 0, 0, a, 0, 0), t.clearRect(0, 0, x, g), t.font = n, t.textBaseline = "top", t.textAlign = "left", this.updateOffset(x, g);
1318
- let w = p / 2;
1319
- for (const T of o) {
1320
- let S = p / 2;
1321
- this._style.stroke && this._style.strokeThickness > 0 && (t.lineWidth = this._style.strokeThickness, t.strokeStyle = this._style.stroke, t.strokeText(T, S, w)), this._style.fill && (t.fillStyle = this._style.fill, t.fillText(T, S, w)), w += f + l;
1316
+ const p = (this._style.strokeThickness || 0) * 2, x = Math.ceil(h + p) || 1, v = Math.ceil(c + p) || 1, R = x * a, T = v * a;
1317
+ (this.canvas.width !== R || this.canvas.height !== T) && (this.canvas.width = R, this.canvas.height = T), t.setTransform(a, 0, 0, a, 0, 0), t.clearRect(0, 0, x, v), t.font = n, t.textBaseline = "top", t.textAlign = "left", this.updateOffset(x, v);
1318
+ let g = p / 2;
1319
+ for (const w of o) {
1320
+ let b = p / 2;
1321
+ this._style.stroke && this._style.strokeThickness > 0 && (t.lineWidth = this._style.strokeThickness, t.strokeStyle = this._style.stroke, t.strokeText(w, b, g)), this._style.fill && (t.fillStyle = this._style.fill, t.fillText(w, b, g)), g += f + l;
1322
1322
  }
1323
1323
  this.base?.updateSource(this.render.gl, this.canvas, this.options), this.setRegion(0, 0, this.canvas.width, this.canvas.height);
1324
1324
  }
@@ -1349,9 +1349,9 @@ const Pt = (s, t = !1, e = !0) => {
1349
1349
  };
1350
1350
  function it(s, t) {
1351
1351
  const e = {
1352
- [z.CLAMP]: s.CLAMP_TO_EDGE,
1353
- [z.REPEAT]: s.REPEAT,
1354
- [z.MIRRORED_REPEAT]: s.MIRRORED_REPEAT
1352
+ [$.CLAMP]: s.CLAMP_TO_EDGE,
1353
+ [$.REPEAT]: s.REPEAT,
1354
+ [$.MIRRORED_REPEAT]: s.MIRRORED_REPEAT
1355
1355
  }[t] || s.CLAMP_TO_EDGE;
1356
1356
  s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_S, e), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_T, e);
1357
1357
  }
@@ -1362,11 +1362,11 @@ function rt(s, t) {
1362
1362
  }[t] ?? s.NEAREST;
1363
1363
  s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MIN_FILTER, e), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MAG_FILTER, e);
1364
1364
  }
1365
- function Z(s, t, e) {
1365
+ function Q(s, t, e) {
1366
1366
  const i = s.gl, r = i.createTexture();
1367
1367
  if (!r)
1368
1368
  throw new Error("Unable to create WebGL texture");
1369
- if (i.bindTexture(i.TEXTURE_2D, r), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0), i.pixelStorei(i.UNPACK_ALIGNMENT, 1), it(i, e.wrap ?? z.CLAMP), rt(i, e.textureFilter ?? s.textureFilter), e.onlySize) {
1369
+ if (i.bindTexture(i.TEXTURE_2D, r), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0), i.pixelStorei(i.UNPACK_ALIGNMENT, 1), it(i, e.wrap ?? $.CLAMP), rt(i, e.textureFilter ?? s.textureFilter), e.onlySize) {
1370
1370
  const n = t;
1371
1371
  i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, n.width, n.height, 0, i.RGBA, i.UNSIGNED_BYTE, null);
1372
1372
  } else {
@@ -1375,7 +1375,7 @@ function Z(s, t, e) {
1375
1375
  }
1376
1376
  return i.bindTexture(i.TEXTURE_2D, null), r;
1377
1377
  }
1378
- function W(s, t) {
1378
+ function F(s, t) {
1379
1379
  if (s.includes("%TEXTURE_NUM%") && (s = s.replace("%TEXTURE_NUM%", t.toString())), s.includes("%GET_COLOR%")) {
1380
1380
  let e = "";
1381
1381
  for (let i = 0; i < t; i++)
@@ -1623,7 +1623,7 @@ class ut {
1623
1623
  return n.isCustom = !0, n.padding = this.padding, this.glshader.set(e, n), this.uniformDirty.add(e), n;
1624
1624
  }
1625
1625
  }
1626
- const K = 1 / 0;
1626
+ const q = 1 / 0;
1627
1627
  class Rt {
1628
1628
  constructor(t) {
1629
1629
  this.rapid = t, this.gl = t.gl, this.maxTextureUnits = t.maxTextureUnits, this.matrixStore = t.matrix;
@@ -1664,7 +1664,7 @@ class Rt {
1664
1664
  }
1665
1665
  useTexture(t, e = 0, i = 0) {
1666
1666
  const r = this.findTextureUnit(t, e, i);
1667
- return r == -1 ? (this.usedTextures.push(t), this.usedTexturePadding.push(e), this.usedTexturePadding.push(i), this.usedTextures.length - 1) : r;
1667
+ return r == -1 ? (this.freeTextureUnitNum === 0 && this.flush(), this.usedTextures.push(t), this.usedTexturePadding.push(e), this.usedTexturePadding.push(i), this.usedTextures.length - 1) : r;
1668
1668
  }
1669
1669
  createShader(t, e) {
1670
1670
  return new yt(this.gl, t, e);
@@ -1724,7 +1724,7 @@ class Rt {
1724
1724
  return !1;
1725
1725
  }
1726
1726
  }
1727
- const q = `#version 300 es\r
1727
+ const Z = `#version 300 es\r
1728
1728
  precision mediump float;\r
1729
1729
  \r
1730
1730
  // per-vertex\r
@@ -1821,7 +1821,7 @@ void main(void) {\r
1821
1821
  \r
1822
1822
  // CUSTOM_CODE_CALL\r
1823
1823
  }\r
1824
- `, V = 48, Dt = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
1824
+ `, z = 48, Dt = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
1825
1825
  class at extends Rt {
1826
1826
  instanceBuffer;
1827
1827
  quadBuffer;
@@ -1834,28 +1834,28 @@ class at extends Rt {
1834
1834
  }
1835
1835
  createBuffer() {
1836
1836
  const t = this.gl;
1837
- this.quadBuffer = new et(t, I.Float32, t.ARRAY_BUFFER, t.STATIC_DRAW), this.quadBuffer.bindBuffer();
1837
+ this.quadBuffer = new et(t, L.Float32, t.ARRAY_BUFFER, t.STATIC_DRAW), this.quadBuffer.bindBuffer();
1838
1838
  for (const e of Dt) this.quadBuffer.pushFloat32(e);
1839
- this.quadBuffer.makeDirty(), this.quadBuffer.bufferData(), this.instanceBuffer = new et(t, I.Uint32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW);
1839
+ this.quadBuffer.makeDirty(), this.quadBuffer.bufferData(), this.instanceBuffer = new et(t, L.Uint32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW);
1840
1840
  }
1841
1841
  createDefaultShader() {
1842
- const t = this.rapid, e = W(lt, t.maxTextureUnits), i = W(q, t.maxTextureUnits);
1842
+ const t = this.rapid, e = F(lt, t.maxTextureUnits), i = F(Z, t.maxTextureUnits);
1843
1843
  return this.vs = i, this.fs = e, this.defaultShader = this.createShader(i, e), this.defaultShader;
1844
1844
  }
1845
1845
  createShader(t, e) {
1846
1846
  const i = super.createShader(t, e);
1847
1847
  return i.use(), i.bindVAO(), this.instanceBuffer.bindBuffer(), i.setAttributes([
1848
- { name: "aMatrixRow0", size: 3, stride: V, offset: 0, divisor: 1 },
1849
- { name: "aMatrixRow1", size: 3, stride: V, offset: 12, divisor: 1 },
1850
- { name: "aUVRect", size: 4, stride: V, offset: 24, divisor: 1 },
1851
- { name: "aColor", size: 4, type: st, normalized: !0, stride: V, offset: 40, divisor: 1 },
1852
- { name: "aTextureId", size: 1, type: st, stride: V, offset: 44, divisor: 1 }
1848
+ { name: "aMatrixRow0", size: 3, stride: z, offset: 0, divisor: 1 },
1849
+ { name: "aMatrixRow1", size: 3, stride: z, offset: 12, divisor: 1 },
1850
+ { name: "aUVRect", size: 4, stride: z, offset: 24, divisor: 1 },
1851
+ { name: "aColor", size: 4, type: st, normalized: !0, stride: z, offset: 40, divisor: 1 },
1852
+ { name: "aTextureId", size: 1, type: st, stride: z, offset: 44, divisor: 1 }
1853
1853
  ]), this.quadBuffer.bindBuffer(), i.setAttributes([
1854
1854
  { name: "aVertex", size: 2, stride: 8, offset: 0, divisor: 0 }
1855
1855
  ]), i.unbindVAO(), this.currentShader && this.currentShader.use(), i;
1856
1856
  }
1857
1857
  createCustomShader(t) {
1858
- const e = W(lt, this.rapid.maxTextureUnits - t.usedTextureUnitNum), i = W(q, this.rapid.maxTextureUnits - t.usedTextureUnitNum);
1858
+ const e = F(lt, this.rapid.maxTextureUnits - t.usedTextureUnitNum), i = F(Z, this.rapid.maxTextureUnits - t.usedTextureUnitNum);
1859
1859
  return t.getGLShader(this, this.KEY, i, e);
1860
1860
  }
1861
1861
  /**
@@ -1892,18 +1892,18 @@ class at extends Rt {
1892
1892
  l
1893
1893
  );
1894
1894
  }
1895
- drawSpriteAffine(t, e, i, r, n, a, o, h = 0, c = 0, u = 1, f = 1, l = 4294967295, p = 0, x = 0, g = !1, v = !1, y = !1) {
1896
- (this.freeTextureUnitNum === 0 || this.instanceCount > K) && this.flush();
1897
- const w = t.base, T = t.scale ?? 1, S = t.rawWidth, F = t.rawHeight, O = t.offsetX, N = t.offsetY, A = this.useTexture(
1895
+ drawSpriteAffine(t, e, i, r, n, a, o, h = 0, c = 0, u = 1, f = 1, l = 4294967295, p = 0, x = 0, v = !1, R = !1, T = !1) {
1896
+ this.instanceCount > q && this.flush();
1897
+ const g = t.base, w = t.scale ?? 1, b = t.rawWidth, A = t.rawHeight, I = t.offsetX, Y = t.offsetY, N = this.useTexture(
1898
1898
  t.glTexture,
1899
- p / T / w.width,
1900
- x / T / w.height
1901
- ), M = this.instanceBuffer, b = M.usedElemNum;
1902
- M.resize(12);
1903
- const U = M.float32, L = M.uint32, $ = (y ? F : S) * T, J = (y ? S : F) * T, k = $ + 2 * p, G = J + 2 * x, ht = O - p, ot = N - x, E = this.localSpriteMatrix;
1904
- y ? (E[0] = 0, E[1] = v ? G : -G, E[2] = g ? -k : k, E[3] = 0, E[4] = ht + (g ? k : 0), E[5] = ot + (v ? 0 : G)) : (E[0] = g ? -k : k, E[1] = 0, E[2] = 0, E[3] = v ? -G : G, E[4] = ht + (g ? k : 0), E[5] = ot + (v ? G : 0));
1899
+ p / w / g.width,
1900
+ x / w / g.height
1901
+ ), U = this.instanceBuffer, y = U.usedElemNum;
1902
+ U.resize(12);
1903
+ const M = U.float32, D = U.uint32, O = (T ? A : b) * w, W = (T ? b : A) * w, H = O + 2 * p, V = W + 2 * x, ht = I - p, ot = Y - x, S = this.localSpriteMatrix;
1904
+ T ? (S[0] = 0, S[1] = R ? V : -V, S[2] = v ? -H : H, S[3] = 0, S[4] = ht + (v ? H : 0), S[5] = ot + (R ? 0 : V)) : (S[0] = v ? -H : H, S[1] = 0, S[2] = 0, S[3] = R ? -V : V, S[4] = ht + (v ? H : 0), S[5] = ot + (R ? V : 0));
1905
1905
  const _ = this.worldSpriteMatrix;
1906
- _[0] = e * E[0] + r * E[1], _[1] = i * E[0] + n * E[1], _[2] = e * E[2] + r * E[3], _[3] = i * E[2] + n * E[3], _[4] = a + e * E[4] + r * E[5], _[5] = o + i * E[4] + n * E[5], U[b + 6] = h, U[b + 7] = c, U[b + 8] = u, U[b + 9] = f, L[b + 10] = l, L[b + 11] = A, this.rapid.roundPixels && (_[4] = Math.round(_[4]), _[5] = Math.round(_[5])), U[b] = _[0], U[b + 1] = _[2], U[b + 2] = _[4], U[b + 3] = _[1], U[b + 4] = _[3], U[b + 5] = _[5], M.usedElemNum += 12, M.makeDirty(), this.instanceCount++;
1906
+ _[0] = e * S[0] + r * S[1], _[1] = i * S[0] + n * S[1], _[2] = e * S[2] + r * S[3], _[3] = i * S[2] + n * S[3], _[4] = a + e * S[4] + r * S[5], _[5] = o + i * S[4] + n * S[5], M[y + 6] = h, M[y + 7] = c, M[y + 8] = u, M[y + 9] = f, D[y + 10] = l, D[y + 11] = N, this.rapid.roundPixels && (_[4] = Math.round(_[4]), _[5] = Math.round(_[5])), M[y] = _[0], M[y + 1] = _[2], M[y + 2] = _[4], M[y + 3] = _[1], M[y + 4] = _[3], M[y + 5] = _[5], U.usedElemNum += 12, U.makeDirty(), this.instanceCount++;
1907
1907
  }
1908
1908
  render() {
1909
1909
  if (this.instanceCount === 0) return;
@@ -2038,7 +2038,7 @@ void main(void) {\r
2038
2038
  discard;\r
2039
2039
  }\r
2040
2040
  }\r
2041
- `, Y = 20;
2041
+ `, X = 20;
2042
2042
  class Vt extends Rt {
2043
2043
  vertexBuffer;
2044
2044
  vertexCount = 0;
@@ -2052,7 +2052,7 @@ class Vt extends Rt {
2052
2052
  }
2053
2053
  createBuffer() {
2054
2054
  const t = this.gl;
2055
- this.vertexBuffer = new et(t, I.Float32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW), this.maskShader = this.createMaskShader(Gt, Ht);
2055
+ this.vertexBuffer = new et(t, L.Float32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW), this.maskShader = this.createMaskShader(Gt, Ht);
2056
2056
  }
2057
2057
  createDefaultShader() {
2058
2058
  return this.vs = Bt, this.fs = kt, this.defaultShader = this.createShader(this.vs, this.fs), this.defaultShader;
@@ -2060,16 +2060,16 @@ class Vt extends Rt {
2060
2060
  createMaskShader(t, e) {
2061
2061
  const i = this.gl, r = new yt(i, t, e);
2062
2062
  return r.use(), r.bindVAO(), this.vertexBuffer.bindBuffer(), r.setAttributes([
2063
- { name: "aPosition", size: 2, type: i.FLOAT, stride: Y - 4, offset: 0, divisor: 0 },
2064
- { name: "aUV", size: 2, type: i.FLOAT, stride: Y - 4, offset: 8, divisor: 0 }
2063
+ { name: "aPosition", size: 2, type: i.FLOAT, stride: X - 4, offset: 0, divisor: 0 },
2064
+ { name: "aUV", size: 2, type: i.FLOAT, stride: X - 4, offset: 8, divisor: 0 }
2065
2065
  ]), r.unbindVAO(), this.currentShader && this.currentShader.use(), r;
2066
2066
  }
2067
2067
  createShader(t, e) {
2068
2068
  const i = this.gl, r = super.createShader(t, e);
2069
2069
  return r.use(), r.bindVAO(), this.vertexBuffer.bindBuffer(), r.setAttributes([
2070
- { name: "aPosition", size: 2, type: i.FLOAT, stride: Y, offset: 0, divisor: 0 },
2071
- { name: "aColor", size: 4, type: i.UNSIGNED_BYTE, normalized: !0, stride: Y, offset: 8, divisor: 0 },
2072
- { name: "aUV", size: 2, type: i.FLOAT, stride: Y, offset: 12, divisor: 0 }
2070
+ { name: "aPosition", size: 2, type: i.FLOAT, stride: X, offset: 0, divisor: 0 },
2071
+ { name: "aColor", size: 4, type: i.UNSIGNED_BYTE, normalized: !0, stride: X, offset: 8, divisor: 0 },
2072
+ { name: "aUV", size: 2, type: i.FLOAT, stride: X, offset: 12, divisor: 0 }
2073
2073
  ]), r.unbindVAO(), this.currentShader && this.currentShader.use(), r;
2074
2074
  }
2075
2075
  /**
@@ -2273,8 +2273,8 @@ var Xt = /* @__PURE__ */ ((s) => (s[s.STRETCH = 0] = "STRETCH", s[s.REPEAT = 1]
2273
2273
  const tt = 10, dt = (s, t, e, i, r, n) => {
2274
2274
  const a = [], o = [], h = i ? Math.atan2(t.y, t.x) : Math.atan2(-t.y, -t.x), c = Math.PI, u = new d(t.y, -t.x);
2275
2275
  for (let f = 0; f < tt; f++) {
2276
- const l = f / tt, p = (f + 1) / tt, x = h + l * c, g = h + p * c, v = new d(Math.cos(x) * e, Math.sin(x) * e), y = new d(Math.cos(g) * e, Math.sin(g) * e);
2277
- a.push(s), o.push(new d(r, 0.5)), a.push(s.add(v)), o.push(new d(r + v.dot(u) * n, 0.5 - 0.5 * v.dot(t) / e)), a.push(s.add(y)), o.push(new d(r + y.dot(u) * n, 0.5 - 0.5 * y.dot(t) / e));
2276
+ const l = f / tt, p = (f + 1) / tt, x = h + l * c, v = h + p * c, R = new d(Math.cos(x) * e, Math.sin(x) * e), T = new d(Math.cos(v) * e, Math.sin(v) * e);
2277
+ a.push(s), o.push(new d(r, 0.5)), a.push(s.add(R)), o.push(new d(r + R.dot(u) * n, 0.5 - 0.5 * R.dot(t) / e)), a.push(s.add(T)), o.push(new d(r + T.dot(u) * n, 0.5 - 0.5 * T.dot(t) / e));
2278
2278
  }
2279
2279
  return { vertices: a, uv: o };
2280
2280
  }, $t = (s, t = !1) => {
@@ -2297,8 +2297,8 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2297
2297
  {
2298
2298
  let x = l.add(f).normalize();
2299
2299
  f.cross(l) < 0 && (x = x.multiply(-1));
2300
- let g = 1 / Math.sqrt((1 - p) / 2);
2301
- return { normal: x, miters: Math.min(g, i) };
2300
+ let v = 1 / Math.sqrt((1 - p) / 2);
2301
+ return { normal: x, miters: Math.min(v, i) };
2302
2302
  }
2303
2303
  };
2304
2304
  if (t)
@@ -2324,27 +2324,27 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2324
2324
  let c = 0;
2325
2325
  const u = s.texture?.rawWidth || 1, f = s.closed ? t.length : t.length - 1;
2326
2326
  for (let l = 0; l < f; l++) {
2327
- const p = t[l], x = e[l].normal, g = e[l].miters, v = (l + 1) % t.length, y = t[v], w = e[v].normal, T = e[v].miters, S = p.add(x.multiply(g * r)), F = p.subtract(x.multiply(g * r)), O = y.add(w.multiply(T * r)), N = y.subtract(w.multiply(T * r)), A = p.distanceTo(y);
2328
- let M = 0, b = 0;
2329
- h === 0 ? (M = c / i, b = (c + A) / i) : (M = c / u, b = M + A / u);
2330
- const U = new d(M, 0), L = new d(M, 1), $ = new d(b, 0), J = new d(b, 1);
2331
- n.push(S), a.push(U), n.push(F), a.push(L), n.push(O), a.push($), n.push(O), a.push($), n.push(N), a.push(J), n.push(F), a.push(L), c += A;
2327
+ const p = t[l], x = e[l].normal, v = e[l].miters, R = (l + 1) % t.length, T = t[R], g = e[R].normal, w = e[R].miters, b = p.add(x.multiply(v * r)), A = p.subtract(x.multiply(v * r)), I = T.add(g.multiply(w * r)), Y = T.subtract(g.multiply(w * r)), N = p.distanceTo(T);
2328
+ let U = 0, y = 0;
2329
+ h === 0 ? (U = c / i, y = (c + N) / i) : (U = c / u, y = U + N / u);
2330
+ const M = new d(U, 0), D = new d(U, 1), O = new d(y, 0), W = new d(y, 1);
2331
+ n.push(b), a.push(M), n.push(A), a.push(D), n.push(I), a.push(O), n.push(I), a.push(O), n.push(Y), a.push(W), n.push(A), a.push(D), c += N;
2332
2332
  }
2333
2333
  if (o && !s.closed) {
2334
- const l = t[0], p = e[0].normal, x = h === 0 ? i > 0 ? 1 / i : 0 : 1 / u, g = dt(l, p, r, !0, 0, x);
2335
- n.push(...g.vertices), a.push(...g.uv);
2336
- const v = t[t.length - 1], y = e[t.length - 1].normal, w = h === 0 ? 1 : c / u, T = h === 0 ? i > 0 ? 1 / i : 0 : 1 / u, S = dt(v, y, r, !1, w, T);
2337
- n.push(...S.vertices), a.push(...S.uv);
2334
+ const l = t[0], p = e[0].normal, x = h === 0 ? i > 0 ? 1 / i : 0 : 1 / u, v = dt(l, p, r, !0, 0, x);
2335
+ n.push(...v.vertices), a.push(...v.uv);
2336
+ const R = t[t.length - 1], T = e[t.length - 1].normal, g = h === 0 ? 1 : c / u, w = h === 0 ? i > 0 ? 1 / i : 0 : 1 / u, b = dt(R, T, r, !1, g, w);
2337
+ n.push(...b.vertices), a.push(...b.uv);
2338
2338
  }
2339
2339
  return { vertices: n, uv: a };
2340
- }, X = (s, t, e, i, r) => {
2340
+ }, j = (s, t, e, i, r) => {
2341
2341
  s.matrixStack.applyTransform(t, e, i);
2342
2342
  try {
2343
2343
  r();
2344
2344
  } finally {
2345
2345
  t.saveTransform !== !1 && s.matrixStack.restore();
2346
2346
  }
2347
- }, Q = (s, t) => t ? s.premultipliedAlpha ? t.premultipliedUint32 : t.uint32 : 4294967295, Kt = 2, Et = (s, t) => {
2347
+ }, J = (s, t) => t ? s.premultipliedAlpha ? t.premultipliedUint32 : t.uint32 : 4294967295, Kt = 2, Et = (s, t) => {
2348
2348
  const e = t.texture;
2349
2349
  if (!e?.base || s.inCreateMask)
2350
2350
  return;
@@ -2362,7 +2362,7 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2362
2362
  n,
2363
2363
  a,
2364
2364
  o,
2365
- Q(s, t.color),
2365
+ J(s, t.color),
2366
2366
  f,
2367
2367
  l,
2368
2368
  h,
@@ -2370,7 +2370,7 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2370
2370
  e.isRotated
2371
2371
  );
2372
2372
  }, qt = (s, t) => {
2373
- X(s, t, t.texture.rawWidth, t.texture.rawHeight, () => {
2373
+ j(s, t, t.texture.rawWidth, t.texture.rawHeight, () => {
2374
2374
  Et(s, t);
2375
2375
  });
2376
2376
  }, Zt = (s, t) => {
@@ -2388,10 +2388,12 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2388
2388
  n,
2389
2389
  a,
2390
2390
  o,
2391
- Q(s, t.color),
2391
+ J(s, t.color),
2392
2392
  t.flipX,
2393
2393
  t.flipY,
2394
- t.isRotated
2394
+ t.isRotated,
2395
+ t.originX,
2396
+ t.originY
2395
2397
  );
2396
2398
  }, Qt = (s, t) => {
2397
2399
  const e = s.particleRegion;
@@ -2418,10 +2420,12 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2418
2420
  i.uvH,
2419
2421
  t.flipX,
2420
2422
  t.flipY,
2421
- t.isRotated
2423
+ t.isRotated,
2424
+ t.originX,
2425
+ t.originY
2422
2426
  );
2423
2427
  }, wt = (s, t) => {
2424
- t.points.length !== 0 && X(s, t, 0, 0, () => {
2428
+ t.points.length !== 0 && j(s, t, 0, 0, () => {
2425
2429
  s.startGraphic(
2426
2430
  t.drawMode ?? s.gl.TRIANGLES,
2427
2431
  t.texture,
@@ -2435,7 +2439,7 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2435
2439
  i.y,
2436
2440
  r?.x ?? 0,
2437
2441
  r?.y ?? 0,
2438
- Q(s, n)
2442
+ J(s, n)
2439
2443
  );
2440
2444
  }
2441
2445
  s.endGraphic();
@@ -2451,7 +2455,7 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2451
2455
  drawMode: s.gl.TRIANGLES
2452
2456
  });
2453
2457
  }, te = (s, t) => {
2454
- X(s, t, t.texture.rawWidth, t.texture.rawHeight, () => {
2458
+ j(s, t, t.texture.rawWidth, t.texture.rawHeight, () => {
2455
2459
  s.startMaskGraphic(
2456
2460
  s.gl.TRIANGLE_FAN,
2457
2461
  t.texture,
@@ -2459,7 +2463,7 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2459
2463
  ), s.addRectVertex(t.texture.rawWidth, t.texture.rawHeight), s.endGraphic();
2460
2464
  });
2461
2465
  }, ee = (s, t) => {
2462
- X(s, t, t.width, t.height, () => {
2466
+ j(s, t, t.width, t.height, () => {
2463
2467
  s.startGraphic(
2464
2468
  s.gl.TRIANGLE_FAN,
2465
2469
  t.texture,
@@ -2469,14 +2473,14 @@ const tt = 10, dt = (s, t, e, i, r, n) => {
2469
2473
  });
2470
2474
  }, ie = (s, t) => {
2471
2475
  const e = t.segments ?? 32;
2472
- X(s, t, 0, 0, () => {
2476
+ j(s, t, 0, 0, () => {
2473
2477
  s.startGraphic(
2474
2478
  s.gl.TRIANGLE_FAN,
2475
2479
  void 0,
2476
2480
  t.shader,
2477
2481
  t.customMatrix
2478
2482
  );
2479
- const i = Q(s, t.color);
2483
+ const i = J(s, t.color);
2480
2484
  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();
2481
2485
  });
2482
2486
  }, ft = `#version 300 es\r
@@ -2535,11 +2539,11 @@ class re extends at {
2535
2539
  super(t);
2536
2540
  }
2537
2541
  createCustomShader(t) {
2538
- const e = W(ft, this.rapid.maxTextureUnits - t.usedTextureUnitNum), i = W(q, this.rapid.maxTextureUnits - t.usedTextureUnitNum);
2542
+ const e = F(ft, this.rapid.maxTextureUnits - t.usedTextureUnitNum), i = F(Z, this.rapid.maxTextureUnits - t.usedTextureUnitNum);
2539
2543
  return t.getGLShader(this, this.KEY, i, e);
2540
2544
  }
2541
2545
  createDefaultShader() {
2542
- const t = this.rapid, e = W(ft, t.maxTextureUnits), i = W(q, t.maxTextureUnits);
2546
+ const t = this.rapid, e = F(ft, t.maxTextureUnits), i = F(Z, t.maxTextureUnits);
2543
2547
  return this.vs = i, this.fs = e, this.defaultShader = this.createShader(i, e), this.defaultShader;
2544
2548
  }
2545
2549
  }
@@ -2551,8 +2555,9 @@ in vec2 aVertex;\r
2551
2555
  \r
2552
2556
  // per-instance: 变换\r
2553
2557
  in vec2 aPosition;\r
2554
- in vec2 aScale;\r
2555
- in float aRotation;\r
2558
+ in vec2 aScale;
2559
+ in float aRotation;
2560
+ in vec2 aOrigin;
2556
2561
  \r
2557
2562
  // per-instance:UV 区域 (u0, v0, u1, v1)\r
2558
2563
  in vec4 aUVRect;\r
@@ -2572,10 +2577,15 @@ void main(void) {\r
2572
2577
  vRegion = aUVRect.xy + aVertex * (aUVRect.zw - aUVRect.xy);\r
2573
2578
  // CUSTOM_CODE_CALL\r
2574
2579
  \r
2575
- vec2 v;\r
2576
- v.x = (aVertex.x) * cos(aRotation) - (aVertex.y) * sin(aRotation);\r
2577
- v.y = (aVertex.x) * sin(aRotation) + (aVertex.y) * cos(aRotation);\r
2578
- v = v * aScale + aPosition;\r
2580
+ vec2 scaled = (aVertex - aOrigin) * aScale;
2581
+ float c = cos(aRotation);\r
2582
+ float s = sin(aRotation);\r
2583
+ \r
2584
+ vec2 v = vec2(\r
2585
+ scaled.x * c - scaled.y * s,\r
2586
+ scaled.x * s + scaled.y * c\r
2587
+ ) + aPosition;\r
2588
+ \r
2579
2589
  gl_Position = u_projection * vec4(v, 0.0, 1.0);\r
2580
2590
  }\r
2581
2591
  `, xt = `#version 300 es\r
@@ -2594,7 +2604,7 @@ void main(void) {\r
2594
2604
  \r
2595
2605
  // CUSTOM_CODE_CALL\r
2596
2606
  }\r
2597
- `, H = 40, j = H / 4;
2607
+ `, B = 48, K = B / 4;
2598
2608
  class se extends at {
2599
2609
  KEY = "ParticleSprite";
2600
2610
  texture;
@@ -2614,37 +2624,38 @@ class se extends at {
2614
2624
  createShader(t, e) {
2615
2625
  const i = super.createShader(t, e);
2616
2626
  return i.use(), i.bindVAO(), this.instanceBuffer.bindBuffer(), i.setAttributes([
2617
- { name: "aPosition", size: 2, stride: H, offset: 0, divisor: 1 },
2618
- { name: "aScale", size: 2, stride: H, offset: 8, divisor: 1 },
2619
- { name: "aRotation", size: 1, stride: H, offset: 16, divisor: 1 },
2620
- { name: "aUVRect", size: 4, stride: H, offset: 20, divisor: 1 },
2621
- { name: "aColor", size: 4, type: st, normalized: !0, stride: H, offset: 36, divisor: 1 }
2627
+ { name: "aPosition", size: 2, stride: B, offset: 0, divisor: 1 },
2628
+ { name: "aScale", size: 2, stride: B, offset: 8, divisor: 1 },
2629
+ { name: "aRotation", size: 1, stride: B, offset: 16, divisor: 1 },
2630
+ { name: "aUVRect", size: 4, stride: B, offset: 20, divisor: 1 },
2631
+ { name: "aColor", size: 4, type: st, normalized: !0, stride: B, offset: 36, divisor: 1 },
2632
+ { name: "aOrigin", size: 2, stride: B, offset: 40, divisor: 1 }
2622
2633
  ]), this.quadBuffer.bindBuffer(), i.setAttributes([
2623
2634
  { name: "aVertex", size: 2, stride: 8, offset: 0, divisor: 0 }
2624
2635
  ]), i.unbindVAO(), this.currentShader && this.currentShader.use(), i;
2625
2636
  }
2626
- drawParticle(t, e = 0, i = 0, r = 1, n = 1, a = 0, o = 0, h = 0, c = 1, u = 1, f = 4294967295, l = !1, p = !1, x = !1) {
2627
- (this.instanceCount >= K || this.texture && t != this.texture) && this.flush(), t.glTexture && (this.texture = t, this.useTexture(t.glTexture, 0, 0));
2628
- const g = this.instanceBuffer, v = g.usedElemNum, y = t.rawWidth, w = t.rawHeight;
2629
- g.resize(j);
2630
- const T = g.float32, S = g.uint32;
2631
- T[v] = e, T[v + 1] = i, T[v + 2] = r * (l ? -1 : 1) * y, T[v + 3] = n * (p ? -1 : 1) * w, T[v + 4] = a, x && (T[v + 4] += Math.PI / 2), T[v + 5] = o, T[v + 6] = h, T[v + 7] = c, T[v + 8] = u, S[v + 9] = f, g.usedElemNum += j, g.makeDirty(), this.instanceCount++;
2637
+ drawParticle(t, e = 0, i = 0, r = 1, n = 1, a = 0, o = 0, h = 0, c = 1, u = 1, f = 4294967295, l = !1, p = !1, x = !1, v = 0.5, R = 0.5) {
2638
+ (this.instanceCount >= q || this.texture && t != this.texture) && this.flush(), t.glTexture && (this.texture = t, this.useTexture(t.glTexture, 0, 0));
2639
+ const T = this.instanceBuffer, g = T.usedElemNum, w = t.rawWidth, b = t.rawHeight;
2640
+ T.resize(K);
2641
+ const A = T.float32, I = T.uint32;
2642
+ A[g] = e, A[g + 1] = i, A[g + 2] = r * (l ? -1 : 1) * w, A[g + 3] = n * (p ? -1 : 1) * b, A[g + 4] = a, x && (A[g + 4] += Math.PI / 2), A[g + 5] = o, A[g + 6] = h, A[g + 7] = c, A[g + 8] = u, I[g + 9] = f, A[g + 10] = v, A[g + 11] = R, T.usedElemNum += K, T.makeDirty(), this.instanceCount++;
2632
2643
  }
2633
- drawParticles(t, e, i, r, n, a, o = 1, h = 1, c = 0, u = 0, f = 1, l = 1, p = !1, x = !1, g = !1) {
2644
+ drawParticles(t, e, i, r, n, a, o = 1, h = 1, c = 0, u = 0, f = 1, l = 1, p = !1, x = !1, v = !1, R = 0.5, T = 0.5) {
2634
2645
  if (!t.glTexture || a <= 0) return;
2635
- let v = 0;
2636
- const y = t.rawWidth * o * (p ? -1 : 1), w = t.rawHeight * h * (x ? -1 : 1), T = g ? Math.PI / 2 : 0;
2637
- for (; v < a; ) {
2646
+ let g = 0;
2647
+ const w = t.rawWidth * o * (p ? -1 : 1), b = t.rawHeight * h * (x ? -1 : 1), A = v ? Math.PI / 2 : 0;
2648
+ for (; g < a; ) {
2638
2649
  this.texture && t !== this.texture && this.flush(), this.texture || (this.texture = t, this.useTexture(t.glTexture, 0, 0));
2639
- const S = a - v, F = K - this.instanceCount, O = Math.min(S, F), N = this.instanceBuffer;
2640
- let A = N.usedElemNum;
2641
- N.resize(O * j);
2642
- const M = N.float32, b = N.uint32;
2643
- for (let U = 0; U < O; U++) {
2644
- const L = v + U;
2645
- M[A] = e[L], M[A + 1] = i[L], M[A + 2] = y, M[A + 3] = w, M[A + 4] = r[L] + T, M[A + 5] = c, M[A + 6] = u, M[A + 7] = f, M[A + 8] = l, b[A + 9] = n[L], A += j;
2650
+ const I = a - g, Y = q - this.instanceCount, N = Math.min(I, Y), U = this.instanceBuffer;
2651
+ let y = U.usedElemNum;
2652
+ U.resize(N * K);
2653
+ const M = U.float32, D = U.uint32;
2654
+ for (let O = 0; O < N; O++) {
2655
+ const W = g + O;
2656
+ M[y] = e[W], M[y + 1] = i[W], M[y + 2] = w, M[y + 3] = b, M[y + 4] = r[W] + A, M[y + 5] = c, M[y + 6] = u, M[y + 7] = f, M[y + 8] = l, D[y + 9] = n[W], M[y + 10] = R, M[y + 11] = T, y += K;
2646
2657
  }
2647
- N.usedElemNum = A, N.makeDirty(), this.instanceCount += O, v += O, this.instanceCount >= K && this.flush();
2658
+ U.usedElemNum = y, U.makeDirty(), this.instanceCount += N, g += N, this.instanceCount >= q && this.flush();
2648
2659
  }
2649
2660
  }
2650
2661
  render() {
@@ -3456,17 +3467,17 @@ class Mt {
3456
3467
  }
3457
3468
  }
3458
3469
  export {
3459
- I as ArrayType,
3460
- B as BaseTexture,
3470
+ L as ArrayType,
3471
+ G as BaseTexture,
3461
3472
  ae as BlendMode,
3462
3473
  he as CanvasScaleMode,
3463
3474
  m as Color,
3464
3475
  ut as CustomGlShader,
3465
- D as DynamicArrayBuffer,
3476
+ k as DynamicArrayBuffer,
3466
3477
  yt as GLShader,
3467
3478
  Vt as GraphicRegion,
3468
3479
  Xt as LineTextureMode,
3469
- K as MAX_INSTANCES,
3480
+ q as MAX_INSTANCES,
3470
3481
  ne as MaskType,
3471
3482
  bt as MatrixStack,
3472
3483
  St as MatrixStore,
@@ -3482,7 +3493,7 @@ export {
3482
3493
  P as Texture,
3483
3494
  nt as TextureFilterMode,
3484
3495
  At as TextureManager,
3485
- z as TextureWrapMode,
3496
+ $ as TextureWrapMode,
3486
3497
  d as Vec2,
3487
3498
  et as WebglBufferArray,
3488
3499
  Yt as composeProjectionWithAffine,