wuepgg3-track 2.0.4 → 2.0.6

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,6 +1,6 @@
1
- import { E as g, U as at, T as ce, a as ot, a0 as w, a1 as M, s as S, aa as he, Y as W, ab as D, N as lt, l as V, ac as ut, ad as fe, Z as we, ae as I, af as C, w as re, k as z, c as Se, F, M as R, a3 as se, R as ie, z as Pe, b as O, B, D as ne, x as X, ag as dt, ah as ae, J as ee, ai as L, q as oe, t as ct, G as ht, m as Ce, p as Fe, a5 as Be, a8 as Ue, n as ft, o as pt, a6 as gt, a7 as mt, a9 as xt, aj as _t, ak as bt, al as N, e as T, am as yt } from "./index-CyClmTrp.mjs";
2
- import { S as j, c as $, a as vt, b as Tt, B as Me } from "./colorToUniform-zJcCVLeu.mjs";
3
- class Re {
1
+ import { E as m, U as ct, T as de, b as dt, a2 as w, a3 as U, t as C, ac as he, Z as I, ad as D, O as ht, n as Y, ae as ft, af as fe, _ as Se, ag as W, ah as pt, ai as P, w as X, G as Pe, a as Fe, M as R, m as A, h as Be, F, a5 as ie, R as se, z as Re, d as O, B, D as ne, x as K, aj as gt, ak as ae, J as te, al as V, S as oe, o as Me, s as Ue, a7 as Ge, aa as ze, p as mt, q as xt, a8 as _t, a9 as yt, ab as bt, am as vt, an as Tt, ao as N, e as T, ap as wt } from "./index-qbfgPm_j.mjs";
2
+ import { F as Ct, S as j, c as $, a as St, b as Pt, B as Ae } from "./colorToUniform-CSn0Emyh.mjs";
3
+ class ke {
4
4
  /**
5
5
  * Initialize the plugin with scope of application instance
6
6
  * @private
@@ -30,8 +30,8 @@ class Re {
30
30
  if (this._resizeTo === globalThis.window)
31
31
  t = globalThis.innerWidth, r = globalThis.innerHeight;
32
32
  else {
33
- const { clientWidth: s, clientHeight: i } = this._resizeTo;
34
- t = s, r = i;
33
+ const { clientWidth: i, clientHeight: s } = this._resizeTo;
34
+ t = i, r = s;
35
35
  }
36
36
  this.renderer.resize(t, r), this.render();
37
37
  }, this._resizeId = null, this._resizeTo = null, this.resizeTo = e.resizeTo || null;
@@ -44,8 +44,8 @@ class Re {
44
44
  globalThis.removeEventListener("resize", this.queueResize), this._cancelResize(), this._cancelResize = null, this.queueResize = null, this.resizeTo = null, this.resize = null;
45
45
  }
46
46
  }
47
- Re.extension = g.Application;
48
- class Ge {
47
+ ke.extension = m.Application;
48
+ class De {
49
49
  /**
50
50
  * Initialize the plugin with scope of application instance
51
51
  * @private
@@ -60,7 +60,7 @@ class Ge {
60
60
  "ticker",
61
61
  {
62
62
  set(t) {
63
- this._ticker && this._ticker.remove(this.render, this), this._ticker = t, t && t.add(this.render, this, at.LOW);
63
+ this._ticker && this._ticker.remove(this.render, this), this._ticker = t, t && t.add(this.render, this, ct.LOW);
64
64
  },
65
65
  get() {
66
66
  return this._ticker;
@@ -70,7 +70,7 @@ class Ge {
70
70
  this._ticker.stop();
71
71
  }, this.start = () => {
72
72
  this._ticker.start();
73
- }, this._ticker = null, this.ticker = e.sharedTicker ? ce.shared : new ce(), e.autoStart && this.start();
73
+ }, this._ticker = null, this.ticker = e.sharedTicker ? de.shared : new de(), e.autoStart && this.start();
74
74
  }
75
75
  /**
76
76
  * Clean up the ticker, scoped to application.
@@ -83,8 +83,8 @@ class Ge {
83
83
  }
84
84
  }
85
85
  }
86
- Ge.extension = g.Application;
87
- class wt extends ot {
86
+ De.extension = m.Application;
87
+ class Ft extends dt {
88
88
  constructor() {
89
89
  super(...arguments), this.chars = /* @__PURE__ */ Object.create(null), this.lineHeight = 0, this.fontFamily = "", this.fontMetrics = { fontSize: 0, ascent: 0, descent: 0 }, this.baseLineOffset = 0, this.distanceField = { type: "none", range: 0 }, this.pages = [], this.applyFillAsTint = !0, this.baseMeasurementFontSize = 100, this.baseRenderedFontSize = 100;
90
90
  }
@@ -93,35 +93,35 @@ class wt extends ot {
93
93
  * @deprecated since 8.0.0 Use `fontFamily` instead.
94
94
  */
95
95
  get font() {
96
- return w(M, "BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."), this.fontFamily;
96
+ return w(U, "BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."), this.fontFamily;
97
97
  }
98
98
  /**
99
99
  * The map of base page textures (i.e., sheets of glyphs).
100
100
  * @deprecated since 8.0.0 Use `pages` instead.
101
101
  */
102
102
  get pageTextures() {
103
- return w(M, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
103
+ return w(U, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
104
104
  }
105
105
  /**
106
106
  * The size of the font face in pixels.
107
107
  * @deprecated since 8.0.0 Use `fontMetrics.fontSize` instead.
108
108
  */
109
109
  get size() {
110
- return w(M, "BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."), this.fontMetrics.fontSize;
110
+ return w(U, "BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."), this.fontMetrics.fontSize;
111
111
  }
112
112
  /**
113
113
  * The kind of distance field for this font or "none".
114
114
  * @deprecated since 8.0.0 Use `distanceField.type` instead.
115
115
  */
116
116
  get distanceFieldRange() {
117
- return w(M, "BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."), this.distanceField.range;
117
+ return w(U, "BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."), this.distanceField.range;
118
118
  }
119
119
  /**
120
120
  * The range of the distance field in pixels.
121
121
  * @deprecated since 8.0.0 Use `distanceField.range` instead.
122
122
  */
123
123
  get distanceFieldType() {
124
- return w(M, "BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."), this.distanceField.type;
124
+ return w(U, "BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."), this.distanceField.type;
125
125
  }
126
126
  destroy(e = !1) {
127
127
  var t;
@@ -131,154 +131,154 @@ class wt extends ot {
131
131
  this.chars = null, e && (this.pages.forEach((r) => r.texture.destroy(!0)), this.pages = null);
132
132
  }
133
133
  }
134
- const Ae = class ze extends wt {
134
+ const Oe = class Ie extends Ft {
135
135
  /**
136
136
  * @param options - The options for the dynamic bitmap font.
137
137
  */
138
138
  constructor(e) {
139
139
  super(), this.resolution = 1, this.pages = [], this._padding = 0, this._measureCache = /* @__PURE__ */ Object.create(null), this._currentChars = [], this._currentX = 0, this._currentY = 0, this._currentMaxCharHeight = 0, this._currentPageIndex = -1, this._skipKerning = !1;
140
- const t = { ...ze.defaultOptions, ...e };
140
+ const t = { ...Ie.defaultOptions, ...e };
141
141
  this._textureSize = t.textureSize, this._mipmap = t.mipmap;
142
142
  const r = t.style.clone();
143
- t.overrideFill && (r._fill.color = 16777215, r._fill.alpha = 1, r._fill.texture = S.WHITE, r._fill.fill = null), this.applyFillAsTint = t.overrideFill;
144
- const s = r.fontSize;
143
+ t.overrideFill && (r._fill.color = 16777215, r._fill.alpha = 1, r._fill.texture = C.WHITE, r._fill.fill = null), this.applyFillAsTint = t.overrideFill;
144
+ const i = r.fontSize;
145
145
  r.fontSize = this.baseMeasurementFontSize;
146
- const i = he(r);
147
- t.overrideSize ? r._stroke && (r._stroke.width *= this.baseRenderedFontSize / s) : r.fontSize = this.baseRenderedFontSize = s, this._style = r, this._skipKerning = t.skipKerning ?? !1, this.resolution = t.resolution ?? 1, this._padding = t.padding ?? 4, t.textureStyle && (this._textureStyle = t.textureStyle instanceof W ? t.textureStyle : new W(t.textureStyle)), this.fontMetrics = D.measureFont(i), this.lineHeight = r.lineHeight || this.fontMetrics.fontSize || r.fontSize;
146
+ const s = he(r);
147
+ t.overrideSize ? r._stroke && (r._stroke.width *= this.baseRenderedFontSize / i) : r.fontSize = this.baseRenderedFontSize = i, this._style = r, this._skipKerning = t.skipKerning ?? !1, this.resolution = t.resolution ?? 1, this._padding = t.padding ?? 4, t.textureStyle && (this._textureStyle = t.textureStyle instanceof I ? t.textureStyle : new I(t.textureStyle)), this.fontMetrics = D.measureFont(s), this.lineHeight = r.lineHeight || this.fontMetrics.fontSize || r.fontSize;
148
148
  }
149
149
  ensureCharacters(e) {
150
- var x, p;
151
- const t = D.graphemeSegmenter(e).filter((_) => !this._currentChars.includes(_)).filter((_, y, v) => v.indexOf(_) === y);
150
+ var b, x;
151
+ const t = D.graphemeSegmenter(e).filter((g) => !this._currentChars.includes(g)).filter((g, p, v) => v.indexOf(g) === p);
152
152
  if (!t.length)
153
153
  return;
154
154
  this._currentChars = [...this._currentChars, ...t];
155
155
  let r;
156
156
  this._currentPageIndex === -1 ? r = this._nextPage() : r = this.pages[this._currentPageIndex];
157
- let { canvas: s, context: i } = r.canvasAndContext, n = r.texture.source;
157
+ let { canvas: i, context: s } = r.canvasAndContext, n = r.texture.source;
158
158
  const a = this._style;
159
- let l = this._currentX, u = this._currentY, c = this._currentMaxCharHeight;
160
- const d = this.baseRenderedFontSize / this.baseMeasurementFontSize, h = this._padding * d;
159
+ let u = this._currentX, l = this._currentY, d = this._currentMaxCharHeight;
160
+ const c = this.baseRenderedFontSize / this.baseMeasurementFontSize, h = this._padding * c;
161
161
  let f = !1;
162
- const b = s.width / this.resolution, m = s.height / this.resolution;
163
- for (let _ = 0; _ < t.length; _++) {
164
- const y = t[_], v = D.measureText(y, a, s, !1);
162
+ const y = i.width / this.resolution, _ = i.height / this.resolution;
163
+ for (let g = 0; g < t.length; g++) {
164
+ const p = t[g], v = D.measureText(p, a, i, !1);
165
165
  v.lineHeight = v.height;
166
- const P = v.width * d, G = Math.ceil((a.fontStyle === "italic" ? 2 : 1) * P), k = v.height * d, U = G + h * 2, E = k + h * 2;
167
- if (f = !1, y !== `
168
- ` && y !== "\r" && y !== " " && y !== " " && (f = !0, c = Math.ceil(Math.max(E, c))), l + U > b && (u += c, c = E, l = 0, u + c > m)) {
166
+ const S = v.width * c, G = Math.ceil((a.fontStyle === "italic" ? 2 : 1) * S), k = v.height * c, M = G + h * 2, E = k + h * 2;
167
+ if (f = !1, p !== `
168
+ ` && p !== "\r" && p !== " " && p !== " " && (f = !0, d = Math.ceil(Math.max(E, d))), u + M > y && (l += d, d = E, u = 0, l + d > _)) {
169
169
  n.update();
170
- const A = this._nextPage();
171
- s = A.canvasAndContext.canvas, i = A.canvasAndContext.context, n = A.texture.source, l = 0, u = 0, c = 0;
170
+ const z = this._nextPage();
171
+ i = z.canvasAndContext.canvas, s = z.canvasAndContext.context, n = z.texture.source, u = 0, l = 0, d = 0;
172
172
  }
173
- const it = P / d - (((x = a.dropShadow) == null ? void 0 : x.distance) ?? 0) - (((p = a._stroke) == null ? void 0 : p.width) ?? 0);
174
- if (this.chars[y] = {
175
- id: y.codePointAt(0),
173
+ const ut = S / c - (((b = a.dropShadow) == null ? void 0 : b.distance) ?? 0) - (((x = a._stroke) == null ? void 0 : x.width) ?? 0);
174
+ if (this.chars[p] = {
175
+ id: p.codePointAt(0),
176
176
  xOffset: -this._padding,
177
177
  yOffset: -this._padding,
178
- xAdvance: it,
178
+ xAdvance: ut,
179
179
  kerning: {}
180
180
  }, f) {
181
181
  this._drawGlyph(
182
- i,
182
+ s,
183
183
  v,
184
- l + h,
185
184
  u + h,
186
- d,
185
+ l + h,
186
+ c,
187
187
  a
188
188
  );
189
- const A = n.width * d, de = n.height * d, nt = new lt(
190
- l / A * n.width,
191
- u / de * n.height,
192
- U / A * n.width,
193
- E / de * n.height
189
+ const z = n.width * c, ce = n.height * c, lt = new ht(
190
+ u / z * n.width,
191
+ l / ce * n.height,
192
+ M / z * n.width,
193
+ E / ce * n.height
194
194
  );
195
- this.chars[y].texture = new S({
195
+ this.chars[p].texture = new C({
196
196
  source: n,
197
- frame: nt
198
- }), l += Math.ceil(U);
197
+ frame: lt
198
+ }), u += Math.ceil(M);
199
199
  }
200
200
  }
201
- n.update(), this._currentX = l, this._currentY = u, this._currentMaxCharHeight = c, this._skipKerning && this._applyKerning(t, i);
201
+ n.update(), this._currentX = u, this._currentY = l, this._currentMaxCharHeight = d, this._skipKerning && this._applyKerning(t, s);
202
202
  }
203
203
  /**
204
204
  * @deprecated since 8.0.0
205
205
  * The map of base page textures (i.e., sheets of glyphs).
206
206
  */
207
207
  get pageTextures() {
208
- return w(M, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
208
+ return w(U, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
209
209
  }
210
210
  _applyKerning(e, t) {
211
211
  const r = this._measureCache;
212
- for (let s = 0; s < e.length; s++) {
213
- const i = e[s];
212
+ for (let i = 0; i < e.length; i++) {
213
+ const s = e[i];
214
214
  for (let n = 0; n < this._currentChars.length; n++) {
215
215
  const a = this._currentChars[n];
216
- let l = r[i];
217
- l || (l = r[i] = t.measureText(i).width);
218
- let u = r[a];
219
- u || (u = r[a] = t.measureText(a).width);
220
- let c = t.measureText(i + a).width, d = c - (l + u);
221
- d && (this.chars[i].kerning[a] = d), c = t.measureText(i + a).width, d = c - (l + u), d && (this.chars[a].kerning[i] = d);
216
+ let u = r[s];
217
+ u || (u = r[s] = t.measureText(s).width);
218
+ let l = r[a];
219
+ l || (l = r[a] = t.measureText(a).width);
220
+ let d = t.measureText(s + a).width, c = d - (u + l);
221
+ c && (this.chars[s].kerning[a] = c), d = t.measureText(s + a).width, c = d - (u + l), c && (this.chars[a].kerning[s] = c);
222
222
  }
223
223
  }
224
224
  }
225
225
  _nextPage() {
226
226
  this._currentPageIndex++;
227
- const e = this.resolution, t = V.getOptimalCanvasAndContext(
227
+ const e = this.resolution, t = Y.getOptimalCanvasAndContext(
228
228
  this._textureSize,
229
229
  this._textureSize,
230
230
  e
231
231
  );
232
232
  this._setupContext(t.context, this._style, e);
233
- const r = e * (this.baseRenderedFontSize / this.baseMeasurementFontSize), s = new S({
234
- source: new ut({
233
+ const r = e * (this.baseRenderedFontSize / this.baseMeasurementFontSize), i = new C({
234
+ source: new ft({
235
235
  resource: t.canvas,
236
236
  resolution: r,
237
237
  alphaMode: "premultiply-alpha-on-upload",
238
238
  autoGenerateMipmaps: this._mipmap
239
239
  })
240
240
  });
241
- this._textureStyle && (s.source.style = this._textureStyle);
242
- const i = {
241
+ this._textureStyle && (i.source.style = this._textureStyle);
242
+ const s = {
243
243
  canvasAndContext: t,
244
- texture: s
244
+ texture: i
245
245
  };
246
- return this.pages[this._currentPageIndex] = i, i;
246
+ return this.pages[this._currentPageIndex] = s, s;
247
247
  }
248
248
  // canvas style!
249
249
  _setupContext(e, t, r) {
250
250
  t.fontSize = this.baseRenderedFontSize, e.scale(r, r), e.font = he(t), t.fontSize = this.baseMeasurementFontSize, e.textBaseline = t.textBaseline;
251
- const s = t._stroke, i = (s == null ? void 0 : s.width) ?? 0;
252
- if (s && (e.lineWidth = i, e.lineJoin = s.join, e.miterLimit = s.miterLimit, e.strokeStyle = fe(s, e)), t._fill && (e.fillStyle = fe(t._fill, e)), t.dropShadow) {
253
- const n = t.dropShadow, a = we.shared.setValue(n.color).toArray(), l = n.blur * r, u = n.distance * r;
254
- e.shadowColor = `rgba(${a[0] * 255},${a[1] * 255},${a[2] * 255},${n.alpha})`, e.shadowBlur = l, e.shadowOffsetX = Math.cos(n.angle) * u, e.shadowOffsetY = Math.sin(n.angle) * u;
251
+ const i = t._stroke, s = (i == null ? void 0 : i.width) ?? 0;
252
+ if (i && (e.lineWidth = s, e.lineJoin = i.join, e.miterLimit = i.miterLimit, e.strokeStyle = fe(i, e)), t._fill && (e.fillStyle = fe(t._fill, e)), t.dropShadow) {
253
+ const n = t.dropShadow, a = Se.shared.setValue(n.color).toArray(), u = n.blur * r, l = n.distance * r;
254
+ e.shadowColor = `rgba(${a[0] * 255},${a[1] * 255},${a[2] * 255},${n.alpha})`, e.shadowBlur = u, e.shadowOffsetX = Math.cos(n.angle) * l, e.shadowOffsetY = Math.sin(n.angle) * l;
255
255
  } else
256
256
  e.shadowColor = "black", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0;
257
257
  }
258
- _drawGlyph(e, t, r, s, i, n) {
259
- const a = t.text, l = t.fontProperties, u = n._stroke, c = ((u == null ? void 0 : u.width) ?? 0) * i, d = r + c / 2, h = s - c / 2, f = l.descent * i, b = t.lineHeight * i;
260
- let m = !1;
261
- n.stroke && c && (m = !0, e.strokeText(a, d, h + b - f));
262
- const { shadowBlur: x, shadowOffsetX: p, shadowOffsetY: _ } = e;
263
- n._fill && (m && (e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0), e.fillText(a, d, h + b - f)), m && (e.shadowBlur = x, e.shadowOffsetX = p, e.shadowOffsetY = _);
258
+ _drawGlyph(e, t, r, i, s, n) {
259
+ const a = t.text, u = t.fontProperties, l = n._stroke, d = ((l == null ? void 0 : l.width) ?? 0) * s, c = r + d / 2, h = i - d / 2, f = u.descent * s, y = t.lineHeight * s;
260
+ let _ = !1;
261
+ n.stroke && d && (_ = !0, e.strokeText(a, c, h + y - f));
262
+ const { shadowBlur: b, shadowOffsetX: x, shadowOffsetY: g } = e;
263
+ n._fill && (_ && (e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0), e.fillText(a, c, h + y - f)), _ && (e.shadowBlur = b, e.shadowOffsetX = x, e.shadowOffsetY = g);
264
264
  }
265
265
  destroy() {
266
266
  super.destroy();
267
267
  for (let e = 0; e < this.pages.length; e++) {
268
268
  const { canvasAndContext: t, texture: r } = this.pages[e];
269
- V.returnCanvasAndContext(t), r.destroy(!0);
269
+ Y.returnCanvasAndContext(t), r.destroy(!0);
270
270
  }
271
271
  this.pages = null;
272
272
  }
273
273
  };
274
- Ae.defaultOptions = {
274
+ Oe.defaultOptions = {
275
275
  textureSize: 512,
276
- style: new I(),
276
+ style: new W(),
277
277
  mipmap: !0
278
278
  };
279
- let pe = Ae;
280
- function ke(o, e, t, r) {
281
- const s = {
279
+ let pe = Oe;
280
+ function We(o, e, t, r) {
281
+ const i = {
282
282
  width: 0,
283
283
  height: 0,
284
284
  offsetY: 0,
@@ -291,109 +291,109 @@ function ke(o, e, t, r) {
291
291
  chars: []
292
292
  }]
293
293
  };
294
- s.offsetY = t.baseLineOffset;
295
- let i = s.lines[0], n = null, a = !0;
296
- const l = {
294
+ i.offsetY = t.baseLineOffset;
295
+ let s = i.lines[0], n = null, a = !0;
296
+ const u = {
297
297
  width: 0,
298
298
  start: 0,
299
299
  index: 0,
300
300
  // use index to not modify the array as we use it a lot!
301
301
  positions: [],
302
302
  chars: []
303
- }, u = t.baseMeasurementFontSize / e.fontSize, c = e.letterSpacing * u, d = e.wordWrapWidth * u, h = e.lineHeight ? e.lineHeight * u : t.lineHeight, f = e.wordWrap && e.breakWords, b = (p) => {
304
- const _ = i.width;
305
- for (let y = 0; y < l.index; y++) {
306
- const v = p.positions[y];
307
- i.chars.push(p.chars[y]), i.charPositions.push(v + _);
303
+ }, l = t.baseMeasurementFontSize / e.fontSize, d = e.letterSpacing * l, c = e.wordWrapWidth * l, h = e.lineHeight ? e.lineHeight * l : t.lineHeight, f = e.wordWrap && e.breakWords, y = (x) => {
304
+ const g = s.width;
305
+ for (let p = 0; p < u.index; p++) {
306
+ const v = x.positions[p];
307
+ s.chars.push(x.chars[p]), s.charPositions.push(v + g);
308
308
  }
309
- i.width += p.width, a = !1, l.width = 0, l.index = 0, l.chars.length = 0;
310
- }, m = () => {
311
- let p = i.chars.length - 1;
309
+ s.width += x.width, a = !1, u.width = 0, u.index = 0, u.chars.length = 0;
310
+ }, _ = () => {
311
+ let x = s.chars.length - 1;
312
312
  if (r) {
313
- let _ = i.chars[p];
314
- for (; _ === " "; )
315
- i.width -= t.chars[_].xAdvance, _ = i.chars[--p];
313
+ let g = s.chars[x];
314
+ for (; g === " "; )
315
+ s.width -= t.chars[g].xAdvance, g = s.chars[--x];
316
316
  }
317
- s.width = Math.max(s.width, i.width), i = {
317
+ i.width = Math.max(i.width, s.width), s = {
318
318
  width: 0,
319
319
  charPositions: [],
320
320
  chars: [],
321
321
  spaceWidth: 0,
322
322
  spacesIndex: []
323
- }, a = !0, s.lines.push(i), s.height += h;
324
- }, x = (p) => p - c > d;
325
- for (let p = 0; p < o.length + 1; p++) {
326
- let _;
327
- const y = p === o.length;
328
- y || (_ = o[p]);
329
- const v = t.chars[_] || t.chars[" "];
330
- if (/(?:\s)/.test(_) || _ === "\r" || _ === `
331
- ` || y) {
332
- if (!a && e.wordWrap && x(i.width + l.width) ? (m(), b(l), y || i.charPositions.push(0)) : (l.start = i.width, b(l), y || i.charPositions.push(0)), _ === "\r" || _ === `
323
+ }, a = !0, i.lines.push(s), i.height += h;
324
+ }, b = (x) => x - d > c;
325
+ for (let x = 0; x < o.length + 1; x++) {
326
+ let g;
327
+ const p = x === o.length;
328
+ p || (g = o[x]);
329
+ const v = t.chars[g] || t.chars[" "];
330
+ if (/(?:\s)/.test(g) || g === "\r" || g === `
331
+ ` || p) {
332
+ if (!a && e.wordWrap && b(s.width + u.width) ? (_(), y(u), p || s.charPositions.push(0)) : (u.start = s.width, y(u), p || s.charPositions.push(0)), g === "\r" || g === `
333
333
  `)
334
- i.width !== 0 && m();
335
- else if (!y) {
336
- const U = v.xAdvance + (v.kerning[n] || 0) + c;
337
- i.width += U, i.spaceWidth = U, i.spacesIndex.push(i.charPositions.length), i.chars.push(_);
334
+ _();
335
+ else if (!p) {
336
+ const M = v.xAdvance + (v.kerning[n] || 0) + d;
337
+ s.width += M, s.spaceWidth = M, s.spacesIndex.push(s.charPositions.length), s.chars.push(g);
338
338
  }
339
339
  } else {
340
- const k = v.kerning[n] || 0, U = v.xAdvance + k + c;
341
- f && x(i.width + l.width + U) && (b(l), m()), l.positions[l.index++] = l.width + k, l.chars.push(_), l.width += U;
340
+ const k = v.kerning[n] || 0, M = v.xAdvance + k + d;
341
+ f && b(s.width + u.width + M) && (y(u), _()), u.positions[u.index++] = u.width + k, u.chars.push(g), u.width += M;
342
342
  }
343
- n = _;
343
+ n = g;
344
344
  }
345
- return m(), e.align === "center" ? St(s) : e.align === "right" ? Pt(s) : e.align === "justify" && Ct(s), s;
345
+ return _(), e.align === "center" ? Bt(i) : e.align === "right" ? Rt(i) : e.align === "justify" && Mt(i), i;
346
346
  }
347
- function St(o) {
347
+ function Bt(o) {
348
348
  for (let e = 0; e < o.lines.length; e++) {
349
349
  const t = o.lines[e], r = o.width / 2 - t.width / 2;
350
- for (let s = 0; s < t.charPositions.length; s++)
351
- t.charPositions[s] += r;
350
+ for (let i = 0; i < t.charPositions.length; i++)
351
+ t.charPositions[i] += r;
352
352
  }
353
353
  }
354
- function Pt(o) {
354
+ function Rt(o) {
355
355
  for (let e = 0; e < o.lines.length; e++) {
356
356
  const t = o.lines[e], r = o.width - t.width;
357
- for (let s = 0; s < t.charPositions.length; s++)
358
- t.charPositions[s] += r;
357
+ for (let i = 0; i < t.charPositions.length; i++)
358
+ t.charPositions[i] += r;
359
359
  }
360
360
  }
361
- function Ct(o) {
361
+ function Mt(o) {
362
362
  const e = o.width;
363
363
  for (let t = 0; t < o.lines.length; t++) {
364
364
  const r = o.lines[t];
365
- let s = 0, i = r.spacesIndex[s++], n = 0;
366
- const a = r.spacesIndex.length, u = (e - r.width) / a;
367
- for (let c = 0; c < r.charPositions.length; c++)
368
- c === i && (i = r.spacesIndex[s++], n += u), r.charPositions[c] += n;
365
+ let i = 0, s = r.spacesIndex[i++], n = 0;
366
+ const a = r.spacesIndex.length, l = (e - r.width) / a;
367
+ for (let d = 0; d < r.charPositions.length; d++)
368
+ d === s && (s = r.spacesIndex[i++], n += l), r.charPositions[d] += n;
369
369
  }
370
370
  }
371
- function Ft(o) {
371
+ function Ut(o) {
372
372
  if (o === "")
373
373
  return [];
374
374
  typeof o == "string" && (o = [o]);
375
375
  const e = [];
376
376
  for (let t = 0, r = o.length; t < r; t++) {
377
- const s = o[t];
378
- if (Array.isArray(s)) {
379
- if (s.length !== 2)
380
- throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);
381
- if (s[0].length === 0 || s[1].length === 0)
377
+ const i = o[t];
378
+ if (Array.isArray(i)) {
379
+ if (i.length !== 2)
380
+ throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${i.length}.`);
381
+ if (i[0].length === 0 || i[1].length === 0)
382
382
  throw new Error("[BitmapFont]: Invalid character delimiter.");
383
- const i = s[0].charCodeAt(0), n = s[1].charCodeAt(0);
384
- if (n < i)
383
+ const s = i[0].charCodeAt(0), n = i[1].charCodeAt(0);
384
+ if (n < s)
385
385
  throw new Error("[BitmapFont]: Invalid character range.");
386
- for (let a = i, l = n; a <= l; a++)
386
+ for (let a = s, u = n; a <= u; a++)
387
387
  e.push(String.fromCharCode(a));
388
388
  } else
389
- e.push(...Array.from(s));
389
+ e.push(...Array.from(i));
390
390
  }
391
391
  if (e.length === 0)
392
392
  throw new Error("[BitmapFont]: Empty set when resolving characters.");
393
393
  return e;
394
394
  }
395
- let H = 0;
396
- class Bt {
395
+ let L = 0;
396
+ class Gt {
397
397
  constructor() {
398
398
  this.ALPHA = [["a", "z"], ["A", "Z"], " "], this.NUMERIC = [["0", "9"]], this.ALPHANUMERIC = [["a", "z"], ["A", "Z"], ["0", "9"], " "], this.ASCII = [[" ", "~"]], this.defaultOptions = {
399
399
  chars: this.ALPHANUMERIC,
@@ -401,7 +401,7 @@ class Bt {
401
401
  padding: 4,
402
402
  skipKerning: !1,
403
403
  textureStyle: null
404
- };
404
+ }, this.measureCache = pt(1e3);
405
405
  }
406
406
  /**
407
407
  * Get a font for the specified text and style.
@@ -410,31 +410,25 @@ class Bt {
410
410
  */
411
411
  getFont(e, t) {
412
412
  var n;
413
- let r = `${t.fontFamily}-bitmap`, s = !0;
414
- if (t._fill.fill && !t._stroke)
415
- r += t._fill.fill.styleKey, s = !1;
416
- else if (t._stroke || t.dropShadow) {
417
- let a = t.styleKey;
418
- a = a.substring(0, a.lastIndexOf("-")), r = `${a}-bitmap`, s = !1;
419
- }
420
- if (!C.has(r)) {
413
+ let r = `${t.fontFamily}-bitmap`, i = !0;
414
+ if (t._fill.fill && !t._stroke ? (r += t._fill.fill.styleKey, i = !1) : (t._stroke || t.dropShadow) && (r = `${t.styleKey}-bitmap`, i = !1), !P.has(r)) {
421
415
  const a = Object.create(t);
422
416
  a.lineHeight = 0;
423
- const l = new pe({
417
+ const u = new pe({
424
418
  style: a,
425
- overrideFill: s,
419
+ overrideFill: i,
426
420
  overrideSize: !0,
427
421
  ...this.defaultOptions
428
422
  });
429
- H++, H > 50 && re("BitmapText", `You have dynamically created ${H} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``), l.once("destroy", () => {
430
- H--, C.remove(r);
431
- }), C.set(
423
+ L++, L > 50 && X("BitmapText", `You have dynamically created ${L} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``), u.once("destroy", () => {
424
+ L--, P.remove(r);
425
+ }), P.set(
432
426
  r,
433
- l
427
+ u
434
428
  );
435
429
  }
436
- const i = C.get(r);
437
- return (n = i.ensureCharacters) == null || n.call(i, e), i;
430
+ const s = P.get(r);
431
+ return (n = s.ensureCharacters) == null || n.call(s, e), s;
438
432
  }
439
433
  /**
440
434
  * Get the layout of a text for the specified style.
@@ -443,8 +437,11 @@ class Bt {
443
437
  * @param trimEnd - Whether to ignore whitespaces at the end of each line
444
438
  */
445
439
  getLayout(e, t, r = !0) {
446
- const s = this.getFont(e, t), i = D.graphemeSegmenter(e);
447
- return ke(i, t, s, r);
440
+ const i = this.getFont(e, t), s = `${e}-${t.styleKey}-${r}`;
441
+ if (this.measureCache.has(s))
442
+ return this.measureCache.get(s);
443
+ const n = D.graphemeSegmenter(e), a = We(n, t, i, r);
444
+ return this.measureCache.set(s, a), a;
448
445
  }
449
446
  /**
450
447
  * Measure the text using the specified style.
@@ -457,37 +454,37 @@ class Bt {
457
454
  }
458
455
  // eslint-disable-next-line max-len
459
456
  install(...e) {
460
- var u, c, d, h;
457
+ var l, d, c, h;
461
458
  let t = e[0];
462
459
  typeof t == "string" && (t = {
463
460
  name: t,
464
461
  style: e[1],
465
- chars: (u = e[2]) == null ? void 0 : u.chars,
466
- resolution: (c = e[2]) == null ? void 0 : c.resolution,
467
- padding: (d = e[2]) == null ? void 0 : d.padding,
462
+ chars: (l = e[2]) == null ? void 0 : l.chars,
463
+ resolution: (d = e[2]) == null ? void 0 : d.resolution,
464
+ padding: (c = e[2]) == null ? void 0 : c.padding,
468
465
  skipKerning: (h = e[2]) == null ? void 0 : h.skipKerning
469
- }, w(M, "BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));
466
+ }, w(U, "BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));
470
467
  const r = t == null ? void 0 : t.name;
471
468
  if (!r)
472
469
  throw new Error("[BitmapFontManager] Property `name` is required.");
473
470
  t = { ...this.defaultOptions, ...t };
474
- const s = t.style, i = s instanceof I ? s : new I(s), n = t.dynamicFill ?? this._canUseTintForStyle(i), a = new pe({
475
- style: i,
471
+ const i = t.style, s = i instanceof W ? i : new W(i), n = t.dynamicFill ?? this._canUseTintForStyle(s), a = new pe({
472
+ style: s,
476
473
  overrideFill: n,
477
474
  skipKerning: t.skipKerning,
478
475
  padding: t.padding,
479
476
  resolution: t.resolution,
480
477
  overrideSize: !1,
481
478
  textureStyle: t.textureStyle
482
- }), l = Ft(t.chars);
483
- return a.ensureCharacters(l.join("")), C.set(`${r}-bitmap`, a), a.once("destroy", () => C.remove(`${r}-bitmap`)), a;
479
+ }), u = Ut(t.chars);
480
+ return a.ensureCharacters(u.join("")), P.set(`${r}-bitmap`, a), a.once("destroy", () => P.remove(`${r}-bitmap`)), a;
484
481
  }
485
482
  /**
486
483
  * Uninstalls a bitmap font from the cache.
487
484
  * @param {string} name - The name of the bitmap font to uninstall.
488
485
  */
489
486
  uninstall(e) {
490
- const t = `${e}-bitmap`, r = C.get(t);
487
+ const t = `${e}-bitmap`, r = P.get(t);
491
488
  r && r.destroy();
492
489
  }
493
490
  /**
@@ -501,8 +498,108 @@ class Bt {
501
498
  return !e._stroke && (!e.dropShadow || e.dropShadow.color === 0) && !e._fill.fill && e._fill.color === 16777215;
502
499
  }
503
500
  }
504
- const Ut = new Bt();
505
- class De {
501
+ const zt = new Gt();
502
+ var At = `in vec2 aPosition;
503
+ out vec2 vTextureCoord;
504
+
505
+ uniform vec4 uInputSize;
506
+ uniform vec4 uOutputFrame;
507
+ uniform vec4 uOutputTexture;
508
+
509
+ vec4 filterVertexPosition( void )
510
+ {
511
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
512
+
513
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
514
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
515
+
516
+ return vec4(position, 0.0, 1.0);
517
+ }
518
+
519
+ vec2 filterTextureCoord( void )
520
+ {
521
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
522
+ }
523
+
524
+ void main(void)
525
+ {
526
+ gl_Position = filterVertexPosition();
527
+ vTextureCoord = filterTextureCoord();
528
+ }
529
+ `, kt = `in vec2 vTextureCoord;
530
+ out vec4 finalColor;
531
+ uniform sampler2D uTexture;
532
+ void main() {
533
+ finalColor = texture(uTexture, vTextureCoord);
534
+ }
535
+ `, ge = `struct GlobalFilterUniforms {
536
+ uInputSize: vec4<f32>,
537
+ uInputPixel: vec4<f32>,
538
+ uInputClamp: vec4<f32>,
539
+ uOutputFrame: vec4<f32>,
540
+ uGlobalFrame: vec4<f32>,
541
+ uOutputTexture: vec4<f32>,
542
+ };
543
+
544
+ @group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
545
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
546
+ @group(0) @binding(2) var uSampler: sampler;
547
+
548
+ struct VSOutput {
549
+ @builtin(position) position: vec4<f32>,
550
+ @location(0) uv: vec2<f32>
551
+ };
552
+
553
+ fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
554
+ {
555
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
556
+
557
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
558
+ position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
559
+
560
+ return vec4(position, 0.0, 1.0);
561
+ }
562
+
563
+ fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
564
+ {
565
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
566
+ }
567
+
568
+ @vertex
569
+ fn mainVertex(
570
+ @location(0) aPosition: vec2<f32>,
571
+ ) -> VSOutput {
572
+ return VSOutput(
573
+ filterVertexPosition(aPosition),
574
+ filterTextureCoord(aPosition)
575
+ );
576
+ }
577
+
578
+ @fragment
579
+ fn mainFragment(
580
+ @location(0) uv: vec2<f32>,
581
+ ) -> @location(0) vec4<f32> {
582
+ return textureSample(uTexture, uSampler, uv);
583
+ }
584
+ `;
585
+ class Dt extends Ct {
586
+ constructor() {
587
+ const e = Pe.from({
588
+ vertex: { source: ge, entryPoint: "mainVertex" },
589
+ fragment: { source: ge, entryPoint: "mainFragment" },
590
+ name: "passthrough-filter"
591
+ }), t = Fe.from({
592
+ vertex: At,
593
+ fragment: kt,
594
+ name: "passthrough-filter"
595
+ });
596
+ super({
597
+ gpuProgram: e,
598
+ glProgram: t
599
+ });
600
+ }
601
+ }
602
+ class Ee {
506
603
  constructor(e) {
507
604
  this._renderer = e;
508
605
  }
@@ -529,24 +626,28 @@ class De {
529
626
  this._renderer = null;
530
627
  }
531
628
  }
532
- De.extension = {
629
+ Ee.extension = {
533
630
  type: [
534
- g.WebGLPipes,
535
- g.WebGPUPipes,
536
- g.CanvasPipes
631
+ m.WebGLPipes,
632
+ m.WebGPUPipes,
633
+ m.CanvasPipes
537
634
  ],
538
635
  name: "filter"
539
636
  };
540
- function Mt(o, e) {
637
+ const me = new R();
638
+ function Ot(o, e) {
541
639
  e.clear();
542
640
  const t = e.matrix;
543
641
  for (let r = 0; r < o.length; r++) {
544
- const s = o[r];
545
- s.globalDisplayStatus < 7 || (e.matrix = s.worldTransform, e.addBounds(s.bounds));
642
+ const i = o[r];
643
+ if (i.globalDisplayStatus < 7)
644
+ continue;
645
+ const s = i.renderGroup ?? i.parentRenderGroup;
646
+ s != null && s.isCachedAsTexture ? e.matrix = me.copyFrom(s.textureOffsetInverseTransform).append(i.worldTransform) : s != null && s._parentCacheAsTextureRenderGroup ? e.matrix = me.copyFrom(s._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform) : e.matrix = i.worldTransform, e.addBounds(i.bounds);
546
647
  }
547
648
  return e.matrix = t, e;
548
649
  }
549
- const Rt = new se({
650
+ const It = new ie({
550
651
  attributes: {
551
652
  aPosition: {
552
653
  buffer: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
@@ -557,21 +658,21 @@ const Rt = new se({
557
658
  },
558
659
  indexBuffer: new Uint32Array([0, 1, 2, 0, 2, 3])
559
660
  });
560
- class Gt {
661
+ class Wt {
561
662
  constructor() {
562
- this.skip = !1, this.inputTexture = null, this.backTexture = null, this.filters = null, this.bounds = new Pe(), this.container = null, this.blendRequired = !1, this.outputRenderSurface = null, this.globalFrame = { x: 0, y: 0, width: 0, height: 0 };
663
+ this.skip = !1, this.inputTexture = null, this.backTexture = null, this.filters = null, this.bounds = new Re(), this.container = null, this.blendRequired = !1, this.outputRenderSurface = null, this.globalFrame = { x: 0, y: 0, width: 0, height: 0 }, this.firstEnabledIndex = -1, this.lastEnabledIndex = -1;
563
664
  }
564
665
  }
565
- class Oe {
666
+ class Ve {
566
667
  constructor(e) {
567
- this._filterStackIndex = 0, this._filterStack = [], this._filterGlobalUniforms = new z({
668
+ this._filterStackIndex = 0, this._filterStack = [], this._filterGlobalUniforms = new A({
568
669
  uInputSize: { value: new Float32Array(4), type: "vec4<f32>" },
569
670
  uInputPixel: { value: new Float32Array(4), type: "vec4<f32>" },
570
671
  uInputClamp: { value: new Float32Array(4), type: "vec4<f32>" },
571
672
  uOutputFrame: { value: new Float32Array(4), type: "vec4<f32>" },
572
673
  uGlobalFrame: { value: new Float32Array(4), type: "vec4<f32>" },
573
674
  uOutputTexture: { value: new Float32Array(4), type: "vec4<f32>" }
574
- }), this._globalFilterBindGroup = new Se({}), this.renderer = e;
675
+ }), this._globalFilterBindGroup = new Be({}), this.renderer = e;
575
676
  }
576
677
  /**
577
678
  * The back texture of the currently active filter. Requires the filter to have `blendRequired` set to true.
@@ -587,26 +688,26 @@ class Oe {
587
688
  * @internal
588
689
  */
589
690
  push(e) {
590
- const t = this.renderer, r = e.filterEffect.filters, s = this._pushFilterData();
591
- s.skip = !1, s.filters = r, s.container = e.container, s.outputRenderSurface = t.renderTarget.renderSurface;
592
- const i = t.renderTarget.renderTarget.colorTexture.source, n = i.resolution, a = i.antialias;
593
- if (r.length === 0) {
594
- s.skip = !0;
691
+ const t = this.renderer, r = e.filterEffect.filters, i = this._pushFilterData();
692
+ i.skip = !1, i.filters = r, i.container = e.container, i.outputRenderSurface = t.renderTarget.renderSurface;
693
+ const s = t.renderTarget.renderTarget.colorTexture.source, n = s.resolution, a = s.antialias;
694
+ if (r.every((f) => !f.enabled)) {
695
+ i.skip = !0;
595
696
  return;
596
697
  }
597
- const l = s.bounds;
598
- if (this._calculateFilterArea(e, l), this._calculateFilterBounds(s, t.renderTarget.rootViewPort, a, n, 1), s.skip)
698
+ const u = i.bounds;
699
+ if (this._calculateFilterArea(e, u), this._calculateFilterBounds(i, t.renderTarget.rootViewPort, a, n, 1), i.skip)
599
700
  return;
600
- const u = this._getPreviousFilterData(), c = this._findFilterResolution(n);
601
- let d = 0, h = 0;
602
- u && (d = u.bounds.minX, h = u.bounds.minY), this._calculateGlobalFrame(
603
- s,
604
- d,
605
- h,
701
+ const l = this._getPreviousFilterData(), d = this._findFilterResolution(n);
702
+ let c = 0, h = 0;
703
+ l && (c = l.bounds.minX, h = l.bounds.minY), this._calculateGlobalFrame(
704
+ i,
606
705
  c,
607
- i.width,
608
- i.height
609
- ), this._setupFilterTextures(s, l, t, u);
706
+ h,
707
+ d,
708
+ s.width,
709
+ s.height
710
+ ), this._setupFilterTextures(i, u, t, l);
610
711
  }
611
712
  /**
612
713
  * Applies filters to a texture.
@@ -638,26 +739,26 @@ class Oe {
638
739
  generateFilteredTexture({ texture: e, filters: t }) {
639
740
  const r = this._pushFilterData();
640
741
  this._activeFilterData = r, r.skip = !1, r.filters = t;
641
- const s = e.source, i = s.resolution, n = s.antialias;
642
- if (t.length === 0)
742
+ const i = e.source, s = i.resolution, n = i.antialias;
743
+ if (t.every((f) => !f.enabled))
643
744
  return r.skip = !0, e;
644
745
  const a = r.bounds;
645
- if (a.addRect(e.frame), this._calculateFilterBounds(r, a.rectangle, n, i, 0), r.skip)
746
+ if (a.addRect(e.frame), this._calculateFilterBounds(r, a.rectangle, n, s, 0), r.skip)
646
747
  return e;
647
- const l = i;
748
+ const u = s;
648
749
  this._calculateGlobalFrame(
649
750
  r,
650
751
  0,
651
752
  0,
652
- l,
653
- s.width,
654
- s.height
753
+ u,
754
+ i.width,
755
+ i.height
655
756
  ), r.outputRenderSurface = F.getOptimalTexture(
656
757
  a.width,
657
758
  a.height,
658
759
  r.resolution,
659
760
  r.antialias
660
- ), r.backTexture = S.EMPTY, r.inputTexture = e, this.renderer.renderTarget.finishRenderPass(), this._applyFiltersToTexture(r, !0);
761
+ ), r.backTexture = C.EMPTY, r.inputTexture = e, this.renderer.renderTarget.finishRenderPass(), this._applyFiltersToTexture(r, !0);
661
762
  const h = r.outputRenderSurface;
662
763
  return h.source.alphaMode = "premultiplied-alpha", h;
663
764
  }
@@ -673,22 +774,22 @@ class Oe {
673
774
  * @param previousBounds - The previous bounds to use for offsetting the copy.
674
775
  */
675
776
  getBackTexture(e, t, r) {
676
- const s = e.colorTexture.source._resolution, i = F.getOptimalTexture(
777
+ const i = e.colorTexture.source._resolution, s = F.getOptimalTexture(
677
778
  t.width,
678
779
  t.height,
679
- s,
780
+ i,
680
781
  !1
681
782
  );
682
783
  let n = t.minX, a = t.minY;
683
- r && (n -= r.minX, a -= r.minY), n = Math.floor(n * s), a = Math.floor(a * s);
684
- const l = Math.ceil(t.width * s), u = Math.ceil(t.height * s);
784
+ r && (n -= r.minX, a -= r.minY), n = Math.floor(n * i), a = Math.floor(a * i);
785
+ const u = Math.ceil(t.width * i), l = Math.ceil(t.height * i);
685
786
  return this.renderer.renderTarget.copyToTexture(
686
787
  e,
687
- i,
788
+ s,
688
789
  { x: n, y: a },
689
- { width: l, height: u },
790
+ { width: u, height: l },
690
791
  { x: 0, y: 0 }
691
- ), i;
792
+ ), s;
692
793
  }
693
794
  /**
694
795
  * Applies a filter to a texture.
@@ -697,14 +798,16 @@ class Oe {
697
798
  * @param output - The output render surface.
698
799
  * @param clear - Whether to clear the output surface before applying the filter.
699
800
  */
700
- applyFilter(e, t, r, s) {
701
- const i = this.renderer, n = this._activeFilterData, l = n.outputRenderSurface === r, u = i.renderTarget.rootRenderTarget.colorTexture.source._resolution, c = this._findFilterResolution(u);
702
- let d = 0, h = 0;
703
- if (l) {
704
- const f = this._findPreviousFilterOffset();
705
- d = f.x, h = f.y;
801
+ applyFilter(e, t, r, i) {
802
+ const s = this.renderer, n = this._activeFilterData, u = n.outputRenderSurface === r, l = s.renderTarget.rootRenderTarget.colorTexture.source._resolution, d = this._findFilterResolution(l);
803
+ let c = 0, h = 0;
804
+ if (u) {
805
+ const y = this._findPreviousFilterOffset();
806
+ c = y.x, h = y.y;
706
807
  }
707
- this._updateFilterUniforms(t, r, n, d, h, c, l, s), this._setupBindGroupsAndRender(e, t, i);
808
+ this._updateFilterUniforms(t, r, n, c, h, d, u, i);
809
+ const f = e.enabled ? e : this._getPassthroughFilter();
810
+ this._setupBindGroupsAndRender(f, t, s);
708
811
  }
709
812
  /**
710
813
  * Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_.
@@ -715,20 +818,25 @@ class Oe {
715
818
  * @returns The mapped matrix.
716
819
  */
717
820
  calculateSpriteMatrix(e, t) {
718
- const r = this._activeFilterData, s = e.set(
821
+ const r = this._activeFilterData, i = e.set(
719
822
  r.inputTexture._source.width,
720
823
  0,
721
824
  0,
722
825
  r.inputTexture._source.height,
723
826
  r.bounds.minX,
724
827
  r.bounds.minY
725
- ), i = t.worldTransform.copyTo(R.shared), n = t.renderGroup || t.parentRenderGroup;
726
- return n && n.cacheToLocalTransform && i.prepend(n.cacheToLocalTransform), i.invert(), s.prepend(i), s.scale(
828
+ ), s = t.worldTransform.copyTo(R.shared), n = t.renderGroup || t.parentRenderGroup;
829
+ return n && n.cacheToLocalTransform && s.prepend(n.cacheToLocalTransform), s.invert(), i.prepend(s), i.scale(
727
830
  1 / t.texture.orig.width,
728
831
  1 / t.texture.orig.height
729
- ), s.translate(t.anchor.x, t.anchor.y), s;
832
+ ), i.translate(t.anchor.x, t.anchor.y), i;
730
833
  }
731
834
  destroy() {
835
+ var e;
836
+ (e = this._passthroughFilter) == null || e.destroy(!0), this._passthroughFilter = null;
837
+ }
838
+ _getPassthroughFilter() {
839
+ return this._passthroughFilter ?? (this._passthroughFilter = new Dt()), this._passthroughFilter;
732
840
  }
733
841
  /**
734
842
  * Sets up the bind groups and renders the filter.
@@ -738,16 +846,16 @@ class Oe {
738
846
  */
739
847
  _setupBindGroupsAndRender(e, t, r) {
740
848
  if (r.renderPipes.uniformBatch) {
741
- const s = r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);
742
- this._globalFilterBindGroup.setResource(s, 0);
849
+ const i = r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);
850
+ this._globalFilterBindGroup.setResource(i, 0);
743
851
  } else
744
852
  this._globalFilterBindGroup.setResource(this._filterGlobalUniforms, 0);
745
853
  this._globalFilterBindGroup.setResource(t.source, 1), this._globalFilterBindGroup.setResource(t.source.style, 2), e.groups[0] = this._globalFilterBindGroup, r.encoder.draw({
746
- geometry: Rt,
854
+ geometry: It,
747
855
  shader: e,
748
856
  state: e._state,
749
857
  topology: "triangle-list"
750
- }), r.type === ie.WEBGL && r.renderTarget.finishRenderPass();
858
+ }), r.type === se.WEBGL && r.renderTarget.finishRenderPass();
751
859
  }
752
860
  /**
753
861
  * Sets up the filter textures including input texture and back texture if needed.
@@ -756,18 +864,18 @@ class Oe {
756
864
  * @param renderer - The renderer instance
757
865
  * @param previousFilterData - The previous filter data for back texture calculation
758
866
  */
759
- _setupFilterTextures(e, t, r, s) {
760
- if (e.backTexture = S.EMPTY, e.blendRequired) {
761
- r.renderTarget.finishRenderPass();
762
- const i = r.renderTarget.getRenderTarget(e.outputRenderSurface);
763
- e.backTexture = this.getBackTexture(i, t, s == null ? void 0 : s.bounds);
764
- }
765
- e.inputTexture = F.getOptimalTexture(
867
+ _setupFilterTextures(e, t, r, i) {
868
+ if (e.backTexture = C.EMPTY, e.inputTexture = F.getOptimalTexture(
766
869
  t.width,
767
870
  t.height,
768
871
  e.resolution,
769
872
  e.antialias
770
- ), r.renderTarget.bind(e.inputTexture, !0), r.globalUniforms.push({
873
+ ), e.blendRequired) {
874
+ r.renderTarget.finishRenderPass();
875
+ const s = r.renderTarget.getRenderTarget(e.outputRenderSurface);
876
+ e.backTexture = this.getBackTexture(s, t, i == null ? void 0 : i.bounds);
877
+ }
878
+ r.renderTarget.bind(e.inputTexture, !0), r.globalUniforms.push({
771
879
  offset: t
772
880
  });
773
881
  }
@@ -780,9 +888,9 @@ class Oe {
780
888
  * @param sourceWidth - The source texture width
781
889
  * @param sourceHeight - The source texture height
782
890
  */
783
- _calculateGlobalFrame(e, t, r, s, i, n) {
891
+ _calculateGlobalFrame(e, t, r, i, s, n) {
784
892
  const a = e.globalFrame;
785
- a.x = t * s, a.y = r * s, a.width = i * s, a.height = n * s;
893
+ a.x = t * i, a.y = r * i, a.width = s * i, a.height = n * i;
786
894
  }
787
895
  /**
788
896
  * Updates the filter uniforms with the current filter state.
@@ -795,13 +903,13 @@ class Oe {
795
903
  * @param isFinalTarget - Whether this is the final render target
796
904
  * @param clear - Whether to clear the output surface
797
905
  */
798
- _updateFilterUniforms(e, t, r, s, i, n, a, l) {
799
- const u = this._filterGlobalUniforms.uniforms, c = u.uOutputFrame, d = u.uInputSize, h = u.uInputPixel, f = u.uInputClamp, b = u.uGlobalFrame, m = u.uOutputTexture;
800
- a ? (c[0] = r.bounds.minX - s, c[1] = r.bounds.minY - i) : (c[0] = 0, c[1] = 0), c[2] = e.frame.width, c[3] = e.frame.height, d[0] = e.source.width, d[1] = e.source.height, d[2] = 1 / d[0], d[3] = 1 / d[1], h[0] = e.source.pixelWidth, h[1] = e.source.pixelHeight, h[2] = 1 / h[0], h[3] = 1 / h[1], f[0] = 0.5 * h[2], f[1] = 0.5 * h[3], f[2] = e.frame.width * d[2] - 0.5 * h[2], f[3] = e.frame.height * d[3] - 0.5 * h[3];
801
- const x = this.renderer.renderTarget.rootRenderTarget.colorTexture;
802
- b[0] = s * n, b[1] = i * n, b[2] = x.source.width * n, b[3] = x.source.height * n, t instanceof S && (t.source.resource = null);
803
- const p = this.renderer.renderTarget.getRenderTarget(t);
804
- this.renderer.renderTarget.bind(t, !!l), t instanceof S ? (m[0] = t.frame.width, m[1] = t.frame.height) : (m[0] = p.width, m[1] = p.height), m[2] = p.isRoot ? -1 : 1, this._filterGlobalUniforms.update();
906
+ _updateFilterUniforms(e, t, r, i, s, n, a, u) {
907
+ const l = this._filterGlobalUniforms.uniforms, d = l.uOutputFrame, c = l.uInputSize, h = l.uInputPixel, f = l.uInputClamp, y = l.uGlobalFrame, _ = l.uOutputTexture;
908
+ a ? (d[0] = r.bounds.minX - i, d[1] = r.bounds.minY - s) : (d[0] = 0, d[1] = 0), d[2] = e.frame.width, d[3] = e.frame.height, c[0] = e.source.width, c[1] = e.source.height, c[2] = 1 / c[0], c[3] = 1 / c[1], h[0] = e.source.pixelWidth, h[1] = e.source.pixelHeight, h[2] = 1 / h[0], h[3] = 1 / h[1], f[0] = 0.5 * h[2], f[1] = 0.5 * h[3], f[2] = e.frame.width * c[2] - 0.5 * h[2], f[3] = e.frame.height * c[3] - 0.5 * h[3];
909
+ const b = this.renderer.renderTarget.rootRenderTarget.colorTexture;
910
+ y[0] = i * n, y[1] = s * n, y[2] = b.source.width * n, y[3] = b.source.height * n, t instanceof C && (t.source.resource = null);
911
+ const x = this.renderer.renderTarget.getRenderTarget(t);
912
+ this.renderer.renderTarget.bind(t, !!u), t instanceof C ? (_[0] = t.frame.width, _[1] = t.frame.height) : (_[0] = x.width, _[1] = x.height), _[2] = x.isRoot ? -1 : 1, this._filterGlobalUniforms.update();
805
913
  }
806
914
  /**
807
915
  * Finds the correct resolution by looking back through the filter stack.
@@ -822,9 +930,9 @@ class Oe {
822
930
  let e = 0, t = 0, r = this._filterStackIndex;
823
931
  for (; r > 0; ) {
824
932
  r--;
825
- const s = this._filterStack[r];
826
- if (!s.skip) {
827
- e = s.bounds.minX, t = s.bounds.minY;
933
+ const i = this._filterStack[r];
934
+ if (!i.skip) {
935
+ e = i.bounds.minX, t = i.bounds.minY;
828
936
  break;
829
937
  }
830
938
  }
@@ -836,102 +944,107 @@ class Oe {
836
944
  * @param bounds - The bounds object to populate
837
945
  */
838
946
  _calculateFilterArea(e, t) {
839
- if (e.renderables ? Mt(e.renderables, t) : e.filterEffect.filterArea ? (t.clear(), t.addRect(e.filterEffect.filterArea), t.applyMatrix(e.container.worldTransform)) : e.container.getFastGlobalBounds(!0, t), e.container) {
840
- const s = (e.container.renderGroup || e.container.parentRenderGroup).cacheToLocalTransform;
841
- s && t.applyMatrix(s);
947
+ if (e.renderables ? Ot(e.renderables, t) : e.filterEffect.filterArea ? (t.clear(), t.addRect(e.filterEffect.filterArea), t.applyMatrix(e.container.worldTransform)) : e.container.getFastGlobalBounds(!0, t), e.container) {
948
+ const i = (e.container.renderGroup || e.container.parentRenderGroup).cacheToLocalTransform;
949
+ i && t.applyMatrix(i);
842
950
  }
843
951
  }
844
952
  _applyFiltersToTexture(e, t) {
845
- const r = e.inputTexture, s = e.bounds, i = e.filters;
846
- if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(e.backTexture.source, 3), i.length === 1)
847
- i[0].apply(this, r, e.outputRenderSurface, t);
953
+ const r = e.inputTexture, i = e.bounds, s = e.filters, n = e.firstEnabledIndex, a = e.lastEnabledIndex;
954
+ if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(e.backTexture.source, 3), n === a)
955
+ s[n].apply(this, r, e.outputRenderSurface, t);
848
956
  else {
849
- let n = e.inputTexture;
850
- const a = F.getOptimalTexture(
851
- s.width,
852
- s.height,
853
- n.source._resolution,
957
+ let u = e.inputTexture;
958
+ const l = F.getOptimalTexture(
959
+ i.width,
960
+ i.height,
961
+ u.source._resolution,
854
962
  !1
855
963
  );
856
- let l = a, u = 0;
857
- for (u = 0; u < i.length - 1; ++u) {
858
- i[u].apply(this, n, l, !0);
859
- const d = n;
860
- n = l, l = d;
964
+ let d = l;
965
+ for (let c = n; c < a; c++) {
966
+ const h = s[c];
967
+ if (!h.enabled)
968
+ continue;
969
+ h.apply(this, u, d, !0);
970
+ const f = u;
971
+ u = d, d = f;
861
972
  }
862
- i[u].apply(this, n, e.outputRenderSurface, t), F.returnTexture(a);
973
+ s[a].apply(this, u, e.outputRenderSurface, t), F.returnTexture(l);
863
974
  }
864
975
  }
865
- _calculateFilterBounds(e, t, r, s, i) {
866
- var m;
867
- const n = this.renderer, a = e.bounds, l = e.filters;
868
- let u = 1 / 0, c = 0, d = !0, h = !1, f = !1, b = !0;
869
- for (let x = 0; x < l.length; x++) {
870
- const p = l[x];
871
- if (u = Math.min(u, p.resolution === "inherit" ? s : p.resolution), c += p.padding, p.antialias === "off" ? d = !1 : p.antialias === "inherit" && d && (d = r), p.clipToViewport || (b = !1), !!!(p.compatibleRenderers & n.type)) {
976
+ _calculateFilterBounds(e, t, r, i, s) {
977
+ var x;
978
+ const n = this.renderer, a = e.bounds, u = e.filters;
979
+ let l = 1 / 0, d = 0, c = !0, h = !1, f = !1, y = !0, _ = -1, b = -1;
980
+ for (let g = 0; g < u.length; g++) {
981
+ const p = u[g];
982
+ if (!p.enabled)
983
+ continue;
984
+ if (_ === -1 && (_ = g), b = g, l = Math.min(l, p.resolution === "inherit" ? i : p.resolution), d += p.padding, p.antialias === "off" ? c = !1 : p.antialias === "inherit" && c && (c = r), p.clipToViewport || (y = !1), !!!(p.compatibleRenderers & n.type)) {
872
985
  f = !1;
873
986
  break;
874
987
  }
875
- if (p.blendRequired && !(((m = n.backBuffer) == null ? void 0 : m.useBackBuffer) ?? !0)) {
876
- re("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."), f = !1;
988
+ if (p.blendRequired && !(((x = n.backBuffer) == null ? void 0 : x.useBackBuffer) ?? !0)) {
989
+ X("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."), f = !1;
877
990
  break;
878
991
  }
879
- f = p.enabled || f, h || (h = p.blendRequired);
992
+ f = !0, h || (h = p.blendRequired);
880
993
  }
881
994
  if (!f) {
882
995
  e.skip = !0;
883
996
  return;
884
997
  }
885
- if (b && a.fitBounds(0, t.width / s, 0, t.height / s), a.scale(u).ceil().scale(1 / u).pad((c | 0) * i), !a.isPositive) {
998
+ if (y && a.fitBounds(0, t.width / i, 0, t.height / i), a.scale(l).ceil().scale(1 / l).pad((d | 0) * s), !a.isPositive) {
886
999
  e.skip = !0;
887
1000
  return;
888
1001
  }
889
- e.antialias = d, e.resolution = u, e.blendRequired = h;
1002
+ e.antialias = c, e.resolution = l, e.blendRequired = h, e.firstEnabledIndex = _, e.lastEnabledIndex = b;
890
1003
  }
891
1004
  _popFilterData() {
892
1005
  return this._filterStackIndex--, this._filterStack[this._filterStackIndex];
893
1006
  }
894
1007
  _getPreviousFilterData() {
895
1008
  let e, t = this._filterStackIndex - 1;
896
- for (; t > 1 && (t--, e = this._filterStack[t], !!e.skip); )
1009
+ for (; t > 0 && (t--, e = this._filterStack[t], !!e.skip); )
897
1010
  ;
898
1011
  return e;
899
1012
  }
900
1013
  _pushFilterData() {
901
1014
  let e = this._filterStack[this._filterStackIndex];
902
- return e || (e = this._filterStack[this._filterStackIndex] = new Gt()), this._filterStackIndex++, e;
1015
+ return e || (e = this._filterStack[this._filterStackIndex] = new Wt()), this._filterStackIndex++, e;
903
1016
  }
904
1017
  }
905
- Oe.extension = {
1018
+ Ve.extension = {
906
1019
  type: [
907
- g.WebGLSystem,
908
- g.WebGPUSystem
1020
+ m.WebGLSystem,
1021
+ m.WebGPUSystem
909
1022
  ],
910
1023
  name: "filter"
911
1024
  };
912
- const We = class Ie extends se {
1025
+ const Le = class He extends ie {
913
1026
  constructor(...e) {
914
1027
  let t = e[0] ?? {};
915
- t instanceof Float32Array && (w(M, "use new MeshGeometry({ positions, uvs, indices }) instead"), t = {
1028
+ t instanceof Float32Array && (w(U, "use new MeshGeometry({ positions, uvs, indices }) instead"), t = {
916
1029
  positions: t,
917
1030
  uvs: e[1],
918
1031
  indices: e[2]
919
- }), t = { ...Ie.defaultOptions, ...t };
1032
+ }), t = { ...He.defaultOptions, ...t };
920
1033
  const r = t.positions || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
921
- let s = t.uvs;
922
- s || (t.positions ? s = new Float32Array(r.length) : s = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]));
923
- const i = t.indices || new Uint32Array([0, 1, 2, 0, 2, 3]), n = t.shrinkBuffersToFit, a = new O({
1034
+ let i = t.uvs;
1035
+ i || (t.positions ? i = new Float32Array(r.length) : i = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]));
1036
+ const s = t.indices || new Uint32Array([0, 1, 2, 0, 2, 3]), n = t.shrinkBuffersToFit, a = new O({
924
1037
  data: r,
925
1038
  label: "attribute-mesh-positions",
926
1039
  shrinkToFit: n,
927
1040
  usage: B.VERTEX | B.COPY_DST
928
- }), l = new O({
929
- data: s,
1041
+ }), u = new O({
1042
+ data: i,
930
1043
  label: "attribute-mesh-uvs",
931
1044
  shrinkToFit: n,
932
1045
  usage: B.VERTEX | B.COPY_DST
933
- }), u = new O({
934
- data: i,
1046
+ }), l = new O({
1047
+ data: s,
935
1048
  label: "index-mesh-buffer",
936
1049
  shrinkToFit: n,
937
1050
  usage: B.INDEX | B.COPY_DST
@@ -945,13 +1058,13 @@ const We = class Ie extends se {
945
1058
  offset: 0
946
1059
  },
947
1060
  aUV: {
948
- buffer: l,
1061
+ buffer: u,
949
1062
  format: "float32x2",
950
1063
  stride: 2 * 4,
951
1064
  offset: 0
952
1065
  }
953
1066
  },
954
- indexBuffer: u,
1067
+ indexBuffer: l,
955
1068
  topology: t.topology
956
1069
  }), this.batchMode = "auto";
957
1070
  }
@@ -989,43 +1102,46 @@ const We = class Ie extends se {
989
1102
  this.indexBuffer.data = e;
990
1103
  }
991
1104
  };
992
- We.defaultOptions = {
1105
+ Le.defaultOptions = {
993
1106
  topology: "triangle-list",
994
1107
  shrinkBuffersToFit: !1
995
1108
  };
996
- let le = We;
997
- const ge = "http://www.w3.org/2000/svg", me = "http://www.w3.org/1999/xhtml";
998
- class Ee {
1109
+ let ue = Le;
1110
+ const xe = "http://www.w3.org/2000/svg", _e = "http://www.w3.org/1999/xhtml";
1111
+ class Ye {
999
1112
  constructor() {
1000
- this.svgRoot = document.createElementNS(ge, "svg"), this.foreignObject = document.createElementNS(ge, "foreignObject"), this.domElement = document.createElementNS(me, "div"), this.styleElement = document.createElementNS(me, "style");
1001
- const { foreignObject: e, svgRoot: t, styleElement: r, domElement: s } = this;
1002
- e.setAttribute("width", "10000"), e.setAttribute("height", "10000"), e.style.overflow = "hidden", t.appendChild(e), e.appendChild(r), e.appendChild(s), this.image = ne.get().createImage();
1113
+ this.svgRoot = document.createElementNS(xe, "svg"), this.foreignObject = document.createElementNS(xe, "foreignObject"), this.domElement = document.createElementNS(_e, "div"), this.styleElement = document.createElementNS(_e, "style");
1114
+ const { foreignObject: e, svgRoot: t, styleElement: r, domElement: i } = this;
1115
+ e.setAttribute("width", "10000"), e.setAttribute("height", "10000"), e.style.overflow = "hidden", t.appendChild(e), e.appendChild(r), e.appendChild(i), this.image = ne.get().createImage();
1116
+ }
1117
+ destroy() {
1118
+ this.svgRoot.remove(), this.foreignObject.remove(), this.styleElement.remove(), this.domElement.remove(), this.image.src = "", this.image.remove(), this.svgRoot = null, this.foreignObject = null, this.styleElement = null, this.domElement = null, this.image = null, this.canvasAndContext = null;
1003
1119
  }
1004
1120
  }
1005
- let xe;
1006
- function At(o, e, t, r) {
1007
- r || (r = xe || (xe = new Ee()));
1008
- const { domElement: s, styleElement: i, svgRoot: n } = r;
1009
- s.innerHTML = `<style>${e.cssStyle};</style><div style='padding:0'>${o}</div>`, s.setAttribute("style", "transform-origin: top left; display: inline-block"), t && (i.textContent = t), document.body.appendChild(n);
1010
- const a = s.getBoundingClientRect();
1121
+ let ye;
1122
+ function Et(o, e, t, r) {
1123
+ r || (r = ye || (ye = new Ye()));
1124
+ const { domElement: i, styleElement: s, svgRoot: n } = r;
1125
+ i.innerHTML = `<style>${e.cssStyle};</style><div style='padding:0'>${o}</div>`, i.setAttribute("style", "transform-origin: top left; display: inline-block"), t && (s.textContent = t), document.body.appendChild(n);
1126
+ const a = i.getBoundingClientRect();
1011
1127
  n.remove();
1012
- const l = e.padding * 2;
1128
+ const u = e.padding * 2;
1013
1129
  return {
1014
- width: a.width - l,
1015
- height: a.height - l
1130
+ width: a.width - u,
1131
+ height: a.height - u
1016
1132
  };
1017
1133
  }
1018
- class zt {
1134
+ class Vt {
1019
1135
  constructor() {
1020
1136
  this.batches = [], this.batched = !1;
1021
1137
  }
1022
1138
  destroy() {
1023
1139
  this.batches.forEach((e) => {
1024
- X.return(e);
1140
+ K.return(e);
1025
1141
  }), this.batches.length = 0;
1026
1142
  }
1027
1143
  }
1028
- class Le {
1144
+ class Xe {
1029
1145
  constructor(e, t) {
1030
1146
  this.state = j.for2d(), this.renderer = e, this._adaptor = t, this.renderer.runners.contextChange.add(this);
1031
1147
  }
@@ -1033,8 +1149,8 @@ class Le {
1033
1149
  this._adaptor.contextChange(this.renderer);
1034
1150
  }
1035
1151
  validateRenderable(e) {
1036
- const t = e.context, r = !!e._gpuData, s = this.renderer.graphicsContext.updateGpuContext(t);
1037
- return !!(s.isBatchable || r !== s.isBatchable);
1152
+ const t = e.context, r = !!e._gpuData, i = this.renderer.graphicsContext.updateGpuContext(t);
1153
+ return !!(i.isBatchable || r !== i.isBatchable);
1038
1154
  }
1039
1155
  addRenderable(e, t) {
1040
1156
  const r = this.renderer.graphicsContext.updateGpuContext(e.context);
@@ -1042,9 +1158,9 @@ class Le {
1042
1158
  }
1043
1159
  updateRenderable(e) {
1044
1160
  const r = this._getGpuDataForRenderable(e).batches;
1045
- for (let s = 0; s < r.length; s++) {
1046
- const i = r[s];
1047
- i._batcher.updateElement(i);
1161
+ for (let i = 0; i < r.length; i++) {
1162
+ const s = r[i];
1163
+ s._batcher.updateElement(s);
1048
1164
  }
1049
1165
  }
1050
1166
  execute(e) {
@@ -1053,9 +1169,9 @@ class Le {
1053
1169
  const t = this.renderer, r = e.context;
1054
1170
  if (!t.graphicsContext.getGpuContext(r).batches.length)
1055
1171
  return;
1056
- const i = r.customShader || this._adaptor.shader;
1172
+ const s = r.customShader || this._adaptor.shader;
1057
1173
  this.state.blendMode = e.groupBlendMode;
1058
- const n = i.resources.localUniforms.uniforms;
1174
+ const n = s.resources.localUniforms.uniforms;
1059
1175
  n.uTransformMatrix = e.groupTransform, n.uRound = t._roundPixels | e._roundPixels, $(
1060
1176
  e.groupColorAlpha,
1061
1177
  n.uColor,
@@ -1067,9 +1183,9 @@ class Le {
1067
1183
  t.destroy(), r.isBatchable && this._updateBatchesForRenderable(e, t);
1068
1184
  }
1069
1185
  _addToBatcher(e, t) {
1070
- const r = this.renderer.renderPipes.batch, s = this._getGpuDataForRenderable(e).batches;
1071
- for (let i = 0; i < s.length; i++) {
1072
- const n = s[i];
1186
+ const r = this.renderer.renderPipes.batch, i = this._getGpuDataForRenderable(e).batches;
1187
+ for (let s = 0; s < i.length; s++) {
1188
+ const n = i[s];
1073
1189
  r.addToBatch(n, t);
1074
1190
  }
1075
1191
  }
@@ -1077,33 +1193,33 @@ class Le {
1077
1193
  return e._gpuData[this.renderer.uid] || this._initGpuDataForRenderable(e);
1078
1194
  }
1079
1195
  _initGpuDataForRenderable(e) {
1080
- const t = new zt();
1196
+ const t = new Vt();
1081
1197
  return e._gpuData[this.renderer.uid] = t, t;
1082
1198
  }
1083
1199
  _updateBatchesForRenderable(e, t) {
1084
- const r = e.context, s = this.renderer.graphicsContext.getGpuContext(r), i = this.renderer._roundPixels | e._roundPixels;
1085
- t.batches = s.batches.map((n) => {
1086
- const a = X.get(dt);
1087
- return n.copyTo(a), a.renderable = e, a.roundPixels = i, a;
1200
+ const r = e.context, i = this.renderer.graphicsContext.getGpuContext(r), s = this.renderer._roundPixels | e._roundPixels;
1201
+ t.batches = i.batches.map((n) => {
1202
+ const a = K.get(gt);
1203
+ return n.copyTo(a), a.renderable = e, a.roundPixels = s, a;
1088
1204
  });
1089
1205
  }
1090
1206
  destroy() {
1091
1207
  this.renderer = null, this._adaptor.destroy(), this._adaptor = null, this.state = null;
1092
1208
  }
1093
1209
  }
1094
- Le.extension = {
1210
+ Xe.extension = {
1095
1211
  type: [
1096
- g.WebGLPipes,
1097
- g.WebGPUPipes,
1098
- g.CanvasPipes
1212
+ m.WebGLPipes,
1213
+ m.WebGPUPipes,
1214
+ m.CanvasPipes
1099
1215
  ],
1100
1216
  name: "graphics"
1101
1217
  };
1102
- const He = class Ye extends le {
1218
+ const Ke = class je extends ue {
1103
1219
  constructor(...e) {
1104
1220
  super({});
1105
1221
  let t = e[0] ?? {};
1106
- typeof t == "number" && (w(M, "PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"), t = {
1222
+ typeof t == "number" && (w(U, "PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"), t = {
1107
1223
  width: t,
1108
1224
  height: e[1],
1109
1225
  verticesX: e[2],
@@ -1115,35 +1231,35 @@ const He = class Ye extends le {
1115
1231
  * @param options - Options to be applied to plane geometry
1116
1232
  */
1117
1233
  build(e) {
1118
- e = { ...Ye.defaultOptions, ...e }, this.verticesX = this.verticesX ?? e.verticesX, this.verticesY = this.verticesY ?? e.verticesY, this.width = this.width ?? e.width, this.height = this.height ?? e.height;
1119
- const t = this.verticesX * this.verticesY, r = [], s = [], i = [], n = this.verticesX - 1, a = this.verticesY - 1, l = this.width / n, u = this.height / a;
1120
- for (let d = 0; d < t; d++) {
1121
- const h = d % this.verticesX, f = d / this.verticesX | 0;
1122
- r.push(h * l, f * u), s.push(h / n, f / a);
1234
+ e = { ...je.defaultOptions, ...e }, this.verticesX = this.verticesX ?? e.verticesX, this.verticesY = this.verticesY ?? e.verticesY, this.width = this.width ?? e.width, this.height = this.height ?? e.height;
1235
+ const t = this.verticesX * this.verticesY, r = [], i = [], s = [], n = this.verticesX - 1, a = this.verticesY - 1, u = this.width / n, l = this.height / a;
1236
+ for (let c = 0; c < t; c++) {
1237
+ const h = c % this.verticesX, f = c / this.verticesX | 0;
1238
+ r.push(h * u, f * l), i.push(h / n, f / a);
1123
1239
  }
1124
- const c = n * a;
1125
- for (let d = 0; d < c; d++) {
1126
- const h = d % n, f = d / n | 0, b = f * this.verticesX + h, m = f * this.verticesX + h + 1, x = (f + 1) * this.verticesX + h, p = (f + 1) * this.verticesX + h + 1;
1127
- i.push(
1240
+ const d = n * a;
1241
+ for (let c = 0; c < d; c++) {
1242
+ const h = c % n, f = c / n | 0, y = f * this.verticesX + h, _ = f * this.verticesX + h + 1, b = (f + 1) * this.verticesX + h, x = (f + 1) * this.verticesX + h + 1;
1243
+ s.push(
1244
+ y,
1245
+ _,
1128
1246
  b,
1129
- m,
1247
+ _,
1130
1248
  x,
1131
- m,
1132
- p,
1133
- x
1249
+ b
1134
1250
  );
1135
1251
  }
1136
- this.buffers[0].data = new Float32Array(r), this.buffers[1].data = new Float32Array(s), this.indexBuffer.data = new Uint32Array(i), this.buffers[0].update(), this.buffers[1].update(), this.indexBuffer.update();
1252
+ this.buffers[0].data = new Float32Array(r), this.buffers[1].data = new Float32Array(i), this.indexBuffer.data = new Uint32Array(s), this.buffers[0].update(), this.buffers[1].update(), this.indexBuffer.update();
1137
1253
  }
1138
1254
  };
1139
- He.defaultOptions = {
1255
+ Ke.defaultOptions = {
1140
1256
  width: 100,
1141
1257
  height: 100,
1142
1258
  verticesX: 10,
1143
1259
  verticesY: 10
1144
1260
  };
1145
- let kt = He;
1146
- class ue {
1261
+ let Lt = Ke;
1262
+ class le {
1147
1263
  constructor() {
1148
1264
  this.batcherName = "default", this.packAsQuad = !1, this.indexOffset = 0, this.attributeOffset = 0, this.roundPixels = 0, this._batcher = null, this._batch = null, this._textureMatrixUpdateId = -1, this._uvUpdateId = -1;
1149
1265
  }
@@ -1170,9 +1286,9 @@ class ue {
1170
1286
  }
1171
1287
  get uvs() {
1172
1288
  const t = this.geometry.getBuffer("aUV"), r = t.data;
1173
- let s = r;
1174
- const i = this.texture.textureMatrix;
1175
- return i.isSimple || (s = this._transformedUvs, (this._textureMatrixUpdateId !== i._updateID || this._uvUpdateId !== t._updateID) && ((!s || s.length < r.length) && (s = this._transformedUvs = new Float32Array(r.length)), this._textureMatrixUpdateId = i._updateID, this._uvUpdateId = t._updateID, i.multiplyUvs(r, s))), s;
1289
+ let i = r;
1290
+ const s = this.texture.textureMatrix;
1291
+ return s.isSimple || (i = this._transformedUvs, (this._textureMatrixUpdateId !== s._updateID || this._uvUpdateId !== t._updateID) && ((!i || i.length < r.length) && (i = this._transformedUvs = new Float32Array(r.length)), this._textureMatrixUpdateId = s._updateID, this._uvUpdateId = t._updateID, s.multiplyUvs(r, i))), i;
1176
1292
  }
1177
1293
  get positions() {
1178
1294
  return this.geometry.positions;
@@ -1193,28 +1309,28 @@ class ue {
1193
1309
  return this.geometry.indices.length;
1194
1310
  }
1195
1311
  }
1196
- class _e {
1312
+ class be {
1197
1313
  destroy() {
1198
1314
  }
1199
1315
  }
1200
- class Ve {
1316
+ class $e {
1201
1317
  constructor(e, t) {
1202
- this.localUniforms = new z({
1318
+ this.localUniforms = new A({
1203
1319
  uTransformMatrix: { value: new R(), type: "mat3x3<f32>" },
1204
1320
  uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
1205
1321
  uRound: { value: 0, type: "f32" }
1206
- }), this.localUniformsBindGroup = new Se({
1322
+ }), this.localUniformsBindGroup = new Be({
1207
1323
  0: this.localUniforms
1208
1324
  }), this.renderer = e, this._adaptor = t, this._adaptor.init();
1209
1325
  }
1210
1326
  validateRenderable(e) {
1211
- const t = this._getMeshData(e), r = t.batched, s = e.batched;
1212
- if (t.batched = s, r !== s)
1327
+ const t = this._getMeshData(e), r = t.batched, i = e.batched;
1328
+ if (t.batched = i, r !== i)
1213
1329
  return !0;
1214
- if (s) {
1215
- const i = e._geometry;
1216
- if (i.indices.length !== t.indexSize || i.positions.length !== t.vertexSize)
1217
- return t.indexSize = i.indices.length, t.vertexSize = i.positions.length, !0;
1330
+ if (i) {
1331
+ const s = e._geometry;
1332
+ if (s.indices.length !== t.indexSize || s.positions.length !== t.vertexSize)
1333
+ return t.indexSize = s.indices.length, t.vertexSize = s.positions.length, !0;
1218
1334
  const n = this._getBatchableMesh(e);
1219
1335
  return n.texture.uid !== e._texture.uid && (n._textureMatrixUpdateId = -1), !n._batcher.checkAndUpdateTexture(
1220
1336
  n,
@@ -1224,9 +1340,9 @@ class Ve {
1224
1340
  return !1;
1225
1341
  }
1226
1342
  addRenderable(e, t) {
1227
- var i, n;
1228
- const r = this.renderer.renderPipes.batch, s = this._getMeshData(e);
1229
- if (e.didViewUpdate && (s.indexSize = (i = e._geometry.indices) == null ? void 0 : i.length, s.vertexSize = (n = e._geometry.positions) == null ? void 0 : n.length), s.batched) {
1343
+ var s, n;
1344
+ const r = this.renderer.renderPipes.batch, i = this._getMeshData(e);
1345
+ if (e.didViewUpdate && (i.indexSize = (s = e._geometry.indices) == null ? void 0 : s.length, i.vertexSize = (n = e._geometry.positions) == null ? void 0 : n.length), i.batched) {
1230
1346
  const a = this._getBatchableMesh(e);
1231
1347
  a.setTexture(e._texture), a.geometry = e._geometry, r.addToBatch(a, t);
1232
1348
  } else
@@ -1251,7 +1367,7 @@ class Ve {
1251
1367
  }
1252
1368
  _getMeshData(e) {
1253
1369
  var t, r;
1254
- return (t = e._gpuData)[r = this.renderer.uid] || (t[r] = new _e()), e._gpuData[this.renderer.uid].meshData || this._initMeshData(e);
1370
+ return (t = e._gpuData)[r = this.renderer.uid] || (t[r] = new be()), e._gpuData[this.renderer.uid].meshData || this._initMeshData(e);
1255
1371
  }
1256
1372
  _initMeshData(e) {
1257
1373
  return e._gpuData[this.renderer.uid].meshData = {
@@ -1262,62 +1378,62 @@ class Ve {
1262
1378
  }
1263
1379
  _getBatchableMesh(e) {
1264
1380
  var t, r;
1265
- return (t = e._gpuData)[r = this.renderer.uid] || (t[r] = new _e()), e._gpuData[this.renderer.uid].batchableMesh || this._initBatchableMesh(e);
1381
+ return (t = e._gpuData)[r = this.renderer.uid] || (t[r] = new be()), e._gpuData[this.renderer.uid].batchableMesh || this._initBatchableMesh(e);
1266
1382
  }
1267
1383
  _initBatchableMesh(e) {
1268
- const t = new ue();
1384
+ const t = new le();
1269
1385
  return t.renderable = e, t.setTexture(e._texture), t.transform = e.groupTransform, t.roundPixels = this.renderer._roundPixels | e._roundPixels, e._gpuData[this.renderer.uid].batchableMesh = t, t;
1270
1386
  }
1271
1387
  destroy() {
1272
1388
  this.localUniforms = null, this.localUniformsBindGroup = null, this._adaptor.destroy(), this._adaptor = null, this.renderer = null;
1273
1389
  }
1274
1390
  }
1275
- Ve.extension = {
1391
+ $e.extension = {
1276
1392
  type: [
1277
- g.WebGLPipes,
1278
- g.WebGPUPipes,
1279
- g.CanvasPipes
1393
+ m.WebGLPipes,
1394
+ m.WebGPUPipes,
1395
+ m.CanvasPipes
1280
1396
  ],
1281
1397
  name: "mesh"
1282
1398
  };
1283
- class Dt {
1399
+ class Ht {
1284
1400
  execute(e, t) {
1285
- const r = e.state, s = e.renderer, i = t.shader || e.defaultShader;
1286
- i.resources.uTexture = t.texture._source, i.resources.uniforms = e.localUniforms;
1287
- const n = s.gl, a = e.getBuffers(t);
1288
- s.shader.bind(i), s.state.set(r), s.geometry.bind(a.geometry, i.glProgram);
1289
- const u = a.geometry.indexBuffer.data.BYTES_PER_ELEMENT === 2 ? n.UNSIGNED_SHORT : n.UNSIGNED_INT;
1290
- n.drawElements(n.TRIANGLES, t.particleChildren.length * 6, u, 0);
1401
+ const r = e.state, i = e.renderer, s = t.shader || e.defaultShader;
1402
+ s.resources.uTexture = t.texture._source, s.resources.uniforms = e.localUniforms;
1403
+ const n = i.gl, a = e.getBuffers(t);
1404
+ i.shader.bind(s), i.state.set(r), i.geometry.bind(a.geometry, s.glProgram);
1405
+ const l = a.geometry.indexBuffer.data.BYTES_PER_ELEMENT === 2 ? n.UNSIGNED_SHORT : n.UNSIGNED_INT;
1406
+ n.drawElements(n.TRIANGLES, t.particleChildren.length * 6, l, 0);
1291
1407
  }
1292
1408
  }
1293
- class Ot {
1409
+ class Yt {
1294
1410
  execute(e, t) {
1295
- const r = e.renderer, s = t.shader || e.defaultShader;
1296
- s.groups[0] = r.renderPipes.uniformBatch.getUniformBindGroup(e.localUniforms, !0), s.groups[1] = r.texture.getTextureBindGroup(t.texture);
1297
- const i = e.state, n = e.getBuffers(t);
1411
+ const r = e.renderer, i = t.shader || e.defaultShader;
1412
+ i.groups[0] = r.renderPipes.uniformBatch.getUniformBindGroup(e.localUniforms, !0), i.groups[1] = r.texture.getTextureBindGroup(t.texture);
1413
+ const s = e.state, n = e.getBuffers(t);
1298
1414
  r.encoder.draw({
1299
1415
  geometry: n.geometry,
1300
1416
  shader: t.shader || e.defaultShader,
1301
- state: i,
1417
+ state: s,
1302
1418
  size: t.particleChildren.length * 6
1303
1419
  });
1304
1420
  }
1305
1421
  }
1306
- function be(o, e = null) {
1422
+ function ve(o, e = null) {
1307
1423
  const t = o * 6;
1308
1424
  if (t > 65535 ? e || (e = new Uint32Array(t)) : e || (e = new Uint16Array(t)), e.length !== t)
1309
1425
  throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);
1310
- for (let r = 0, s = 0; r < t; r += 6, s += 4)
1311
- e[r + 0] = s + 0, e[r + 1] = s + 1, e[r + 2] = s + 2, e[r + 3] = s + 0, e[r + 4] = s + 2, e[r + 5] = s + 3;
1426
+ for (let r = 0, i = 0; r < t; r += 6, i += 4)
1427
+ e[r + 0] = i + 0, e[r + 1] = i + 1, e[r + 2] = i + 2, e[r + 3] = i + 0, e[r + 4] = i + 2, e[r + 5] = i + 3;
1312
1428
  return e;
1313
1429
  }
1314
- function Wt(o) {
1430
+ function Xt(o) {
1315
1431
  return {
1316
- dynamicUpdate: ye(o, !0),
1317
- staticUpdate: ye(o, !1)
1432
+ dynamicUpdate: Te(o, !0),
1433
+ staticUpdate: Te(o, !1)
1318
1434
  };
1319
1435
  }
1320
- function ye(o, e) {
1436
+ function Te(o, e) {
1321
1437
  const t = [];
1322
1438
  t.push(`
1323
1439
 
@@ -1329,12 +1445,12 @@ function ye(o, e) {
1329
1445
 
1330
1446
  `);
1331
1447
  let r = 0;
1332
- for (const i in o) {
1333
- const n = o[i];
1448
+ for (const s in o) {
1449
+ const n = o[s];
1334
1450
  if (e !== n.dynamic)
1335
1451
  continue;
1336
1452
  t.push(`offset = index + ${r}`), t.push(n.code);
1337
- const a = ee(n.format);
1453
+ const a = te(n.format);
1338
1454
  r += a.stride / 4;
1339
1455
  }
1340
1456
  t.push(`
@@ -1343,22 +1459,22 @@ function ye(o, e) {
1343
1459
  `), t.unshift(`
1344
1460
  var stride = ${r};
1345
1461
  `);
1346
- const s = t.join(`
1462
+ const i = t.join(`
1347
1463
  `);
1348
- return new Function("ps", "f32v", "u32v", s);
1464
+ return new Function("ps", "f32v", "u32v", i);
1349
1465
  }
1350
- class It {
1466
+ class Kt {
1351
1467
  constructor(e) {
1352
1468
  this._size = 0, this._generateParticleUpdateCache = {};
1353
1469
  const t = this._size = e.size ?? 1e3, r = e.properties;
1354
- let s = 0, i = 0;
1355
- for (const c in r) {
1356
- const d = r[c], h = ee(d.format);
1357
- d.dynamic ? i += h.stride : s += h.stride;
1470
+ let i = 0, s = 0;
1471
+ for (const d in r) {
1472
+ const c = r[d], h = te(c.format);
1473
+ c.dynamic ? s += h.stride : i += h.stride;
1358
1474
  }
1359
- this._dynamicStride = i / 4, this._staticStride = s / 4, this.staticAttributeBuffer = new L(t * 4 * s), this.dynamicAttributeBuffer = new L(t * 4 * i), this.indexBuffer = be(t);
1360
- const n = new se();
1361
- let a = 0, l = 0;
1475
+ this._dynamicStride = s / 4, this._staticStride = i / 4, this.staticAttributeBuffer = new V(t * 4 * i), this.dynamicAttributeBuffer = new V(t * 4 * s), this.indexBuffer = ve(t);
1476
+ const n = new ie();
1477
+ let a = 0, u = 0;
1362
1478
  this._staticBuffer = new O({
1363
1479
  data: new Float32Array(1),
1364
1480
  label: "static-particle-buffer",
@@ -1370,33 +1486,33 @@ class It {
1370
1486
  shrinkToFit: !1,
1371
1487
  usage: B.VERTEX | B.COPY_DST
1372
1488
  });
1373
- for (const c in r) {
1374
- const d = r[c], h = ee(d.format);
1375
- d.dynamic ? (n.addAttribute(d.attributeName, {
1489
+ for (const d in r) {
1490
+ const c = r[d], h = te(c.format);
1491
+ c.dynamic ? (n.addAttribute(c.attributeName, {
1376
1492
  buffer: this._dynamicBuffer,
1377
1493
  stride: this._dynamicStride * 4,
1378
1494
  offset: a * 4,
1379
- format: d.format
1380
- }), a += h.size) : (n.addAttribute(d.attributeName, {
1495
+ format: c.format
1496
+ }), a += h.size) : (n.addAttribute(c.attributeName, {
1381
1497
  buffer: this._staticBuffer,
1382
1498
  stride: this._staticStride * 4,
1383
- offset: l * 4,
1384
- format: d.format
1385
- }), l += h.size);
1499
+ offset: u * 4,
1500
+ format: c.format
1501
+ }), u += h.size);
1386
1502
  }
1387
1503
  n.addIndex(this.indexBuffer);
1388
- const u = this.getParticleUpdate(r);
1389
- this._dynamicUpload = u.dynamicUpdate, this._staticUpload = u.staticUpdate, this.geometry = n;
1504
+ const l = this.getParticleUpdate(r);
1505
+ this._dynamicUpload = l.dynamicUpdate, this._staticUpload = l.staticUpdate, this.geometry = n;
1390
1506
  }
1391
1507
  getParticleUpdate(e) {
1392
- const t = Et(e);
1508
+ const t = jt(e);
1393
1509
  return this._generateParticleUpdateCache[t] ? this._generateParticleUpdateCache[t] : (this._generateParticleUpdateCache[t] = this.generateParticleUpdate(e), this._generateParticleUpdateCache[t]);
1394
1510
  }
1395
1511
  generateParticleUpdate(e) {
1396
- return Wt(e);
1512
+ return Xt(e);
1397
1513
  }
1398
1514
  update(e, t) {
1399
- e.length > this._size && (t = !0, this._size = Math.max(e.length, this._size * 1.5 | 0), this.staticAttributeBuffer = new L(this._size * this._staticStride * 4 * 4), this.dynamicAttributeBuffer = new L(this._size * this._dynamicStride * 4 * 4), this.indexBuffer = be(this._size), this.geometry.indexBuffer.setDataWithSize(
1515
+ e.length > this._size && (t = !0, this._size = Math.max(e.length, this._size * 1.5 | 0), this.staticAttributeBuffer = new V(this._size * this._staticStride * 4 * 4), this.dynamicAttributeBuffer = new V(this._size * this._dynamicStride * 4 * 4), this.indexBuffer = ve(this._size), this.geometry.indexBuffer.setDataWithSize(
1400
1516
  this.indexBuffer,
1401
1517
  this.indexBuffer.byteLength,
1402
1518
  !0
@@ -1407,9 +1523,9 @@ class It {
1407
1523
  e.length * this._dynamicStride * 4,
1408
1524
  !0
1409
1525
  ), t) {
1410
- const s = this.staticAttributeBuffer;
1411
- this._staticUpload(e, s.float32View, s.uint32View), this._staticBuffer.setDataWithSize(
1412
- s.float32View,
1526
+ const i = this.staticAttributeBuffer;
1527
+ this._staticUpload(e, i.float32View, i.uint32View), this._staticBuffer.setDataWithSize(
1528
+ i.float32View,
1413
1529
  e.length * this._staticStride * 4,
1414
1530
  !0
1415
1531
  );
@@ -1419,7 +1535,7 @@ class It {
1419
1535
  this._staticBuffer.destroy(), this._dynamicBuffer.destroy(), this.geometry.destroy();
1420
1536
  }
1421
1537
  }
1422
- function Et(o) {
1538
+ function jt(o) {
1423
1539
  const e = [];
1424
1540
  for (const t in o) {
1425
1541
  const r = o[t];
@@ -1427,7 +1543,7 @@ function Et(o) {
1427
1543
  }
1428
1544
  return e.join("_");
1429
1545
  }
1430
- var Lt = `varying vec2 vUV;
1546
+ var $t = `varying vec2 vUV;
1431
1547
  varying vec4 vColor;
1432
1548
 
1433
1549
  uniform sampler2D uTexture;
@@ -1435,7 +1551,7 @@ uniform sampler2D uTexture;
1435
1551
  void main(void){
1436
1552
  vec4 color = texture2D(uTexture, vUV) * vColor;
1437
1553
  gl_FragColor = color;
1438
- }`, Ht = `attribute vec2 aVertex;
1554
+ }`, Nt = `attribute vec2 aVertex;
1439
1555
  attribute vec2 aUV;
1440
1556
  attribute vec4 aColor;
1441
1557
 
@@ -1474,14 +1590,19 @@ void main(void){
1474
1590
  vUV = aUV;
1475
1591
  vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
1476
1592
  }
1477
- `, ve = `
1593
+ `, we = `
1478
1594
  struct ParticleUniforms {
1479
- uProjectionMatrix:mat3x3<f32>,
1595
+ uTranslationMatrix:mat3x3<f32>,
1480
1596
  uColor:vec4<f32>,
1597
+ uRound:f32,
1481
1598
  uResolution:vec2<f32>,
1482
- uRoundPixels:f32,
1483
1599
  };
1484
1600
 
1601
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
1602
+ {
1603
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
1604
+ }
1605
+
1485
1606
  @group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;
1486
1607
 
1487
1608
  @group(1) @binding(0) var uTexture: texture_2d<f32>;
@@ -1506,7 +1627,11 @@ fn mainVertex(
1506
1627
  aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
1507
1628
  ) + aPosition;
1508
1629
 
1509
- let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
1630
+ var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
1631
+
1632
+ if(uniforms.uRound == 1.0) {
1633
+ position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);
1634
+ }
1510
1635
 
1511
1636
  let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;
1512
1637
 
@@ -1528,18 +1653,18 @@ fn mainFragment(
1528
1653
 
1529
1654
  return sample;
1530
1655
  }`;
1531
- class Yt extends oe {
1656
+ class qt extends oe {
1532
1657
  constructor() {
1533
- const e = ct.from({
1534
- vertex: Ht,
1535
- fragment: Lt
1536
- }), t = ht.from({
1658
+ const e = Fe.from({
1659
+ vertex: Nt,
1660
+ fragment: $t
1661
+ }), t = Pe.from({
1537
1662
  fragment: {
1538
- source: ve,
1663
+ source: we,
1539
1664
  entryPoint: "mainFragment"
1540
1665
  },
1541
1666
  vertex: {
1542
- source: ve,
1667
+ source: we,
1543
1668
  entryPoint: "mainVertex"
1544
1669
  }
1545
1670
  });
@@ -1548,13 +1673,13 @@ class Yt extends oe {
1548
1673
  gpuProgram: t,
1549
1674
  resources: {
1550
1675
  // this will be replaced with the texture from the particle container
1551
- uTexture: S.WHITE.source,
1676
+ uTexture: C.WHITE.source,
1552
1677
  // this will be replaced with the texture style from the particle container
1553
- uSampler: new W({}),
1678
+ uSampler: new I({}),
1554
1679
  // this will be replaced with the local uniforms from the particle container
1555
1680
  uniforms: {
1556
1681
  uTranslationMatrix: { value: new R(), type: "mat3x3<f32>" },
1557
- uColor: { value: new we(16777215), type: "vec4<f32>" },
1682
+ uColor: { value: new Se(16777215), type: "vec4<f32>" },
1558
1683
  uRound: { value: 1, type: "f32" },
1559
1684
  uResolution: { value: [0, 0], type: "vec2<f32>" }
1560
1685
  }
@@ -1562,18 +1687,18 @@ class Yt extends oe {
1562
1687
  });
1563
1688
  }
1564
1689
  }
1565
- class Xe {
1690
+ class Ne {
1566
1691
  /**
1567
1692
  * @param renderer - The renderer this sprite batch works for.
1568
1693
  * @param adaptor
1569
1694
  */
1570
1695
  constructor(e, t) {
1571
- this.state = j.for2d(), this.localUniforms = new z({
1696
+ this.state = j.for2d(), this.localUniforms = new A({
1572
1697
  uTranslationMatrix: { value: new R(), type: "mat3x3<f32>" },
1573
1698
  uColor: { value: new Float32Array(4), type: "vec4<f32>" },
1574
1699
  uRound: { value: 1, type: "f32" },
1575
1700
  uResolution: { value: [0, 0], type: "vec2<f32>" }
1576
- }), this.renderer = e, this.adaptor = t, this.defaultShader = new Yt(), this.state = j.for2d();
1701
+ }), this.renderer = e, this.adaptor = t, this.defaultShader = new qt(), this.state = j.for2d();
1577
1702
  }
1578
1703
  validateRenderable(e) {
1579
1704
  return !1;
@@ -1585,7 +1710,7 @@ class Xe {
1585
1710
  return e._gpuData[this.renderer.uid] || this._initBuffer(e);
1586
1711
  }
1587
1712
  _initBuffer(e) {
1588
- return e._gpuData[this.renderer.uid] = new It({
1713
+ return e._gpuData[this.renderer.uid] = new Kt({
1589
1714
  size: e.particleChildren.length,
1590
1715
  properties: e._properties
1591
1716
  }), e._gpuData[this.renderer.uid];
@@ -1596,10 +1721,10 @@ class Xe {
1596
1721
  const t = e.particleChildren;
1597
1722
  if (t.length === 0)
1598
1723
  return;
1599
- const r = this.renderer, s = this.getBuffers(e);
1724
+ const r = this.renderer, i = this.getBuffers(e);
1600
1725
  e.texture || (e.texture = t[0].texture);
1601
- const i = this.state;
1602
- s.update(t, e._childrenDirty), e._childrenDirty = !1, i.blendMode = ae(e.blendMode, e.texture._source);
1726
+ const s = this.state;
1727
+ i.update(t, e._childrenDirty), e._childrenDirty = !1, s.blendMode = ae(e.blendMode, e.texture._source);
1603
1728
  const n = this.localUniforms.uniforms, a = n.uTranslationMatrix;
1604
1729
  e.worldTransform.copyTo(a), a.prepend(r.globalUniforms.globalUniformData.projectionMatrix), n.uResolution = r.globalUniforms.globalUniformData.resolution, n.uRound = r._roundPixels | e._roundPixels, $(
1605
1730
  e.groupColorAlpha,
@@ -1609,34 +1734,34 @@ class Xe {
1609
1734
  }
1610
1735
  /** Destroys the ParticleRenderer. */
1611
1736
  destroy() {
1612
- this.defaultShader && (this.defaultShader.destroy(), this.defaultShader = null);
1737
+ this.renderer = null, this.defaultShader && (this.defaultShader.destroy(), this.defaultShader = null);
1613
1738
  }
1614
1739
  }
1615
- class je extends Xe {
1740
+ class qe extends Ne {
1616
1741
  constructor(e) {
1617
- super(e, new Dt());
1742
+ super(e, new Ht());
1618
1743
  }
1619
1744
  }
1620
- je.extension = {
1745
+ qe.extension = {
1621
1746
  type: [
1622
- g.WebGLPipes
1747
+ m.WebGLPipes
1623
1748
  ],
1624
1749
  name: "particle"
1625
1750
  };
1626
- class $e extends Xe {
1751
+ class Qe extends Ne {
1627
1752
  constructor(e) {
1628
- super(e, new Ot());
1753
+ super(e, new Yt());
1629
1754
  }
1630
1755
  }
1631
- $e.extension = {
1756
+ Qe.extension = {
1632
1757
  type: [
1633
- g.WebGPUPipes
1758
+ m.WebGPUPipes
1634
1759
  ],
1635
1760
  name: "particle"
1636
1761
  };
1637
- const Ne = class qe extends kt {
1762
+ const Je = class Ze extends Lt {
1638
1763
  constructor(e = {}) {
1639
- e = { ...qe.defaultOptions, ...e }, super({
1764
+ e = { ...Ze.defaultOptions, ...e }, super({
1640
1765
  width: e.width,
1641
1766
  height: e.height,
1642
1767
  verticesX: 4,
@@ -1656,14 +1781,14 @@ const Ne = class qe extends kt {
1656
1781
  const e = this.positions, {
1657
1782
  width: t,
1658
1783
  height: r,
1659
- _leftWidth: s,
1660
- _rightWidth: i,
1784
+ _leftWidth: i,
1785
+ _rightWidth: s,
1661
1786
  _topHeight: n,
1662
1787
  _bottomHeight: a,
1663
- _anchorX: l,
1664
- _anchorY: u
1665
- } = this, c = s + i, d = t > c ? 1 : t / c, h = n + a, f = r > h ? 1 : r / h, b = Math.min(d, f), m = l * t, x = u * r;
1666
- e[0] = e[8] = e[16] = e[24] = -m, e[2] = e[10] = e[18] = e[26] = s * b - m, e[4] = e[12] = e[20] = e[28] = t - i * b - m, e[6] = e[14] = e[22] = e[30] = t - m, e[1] = e[3] = e[5] = e[7] = -x, e[9] = e[11] = e[13] = e[15] = n * b - x, e[17] = e[19] = e[21] = e[23] = r - a * b - x, e[25] = e[27] = e[29] = e[31] = r - x, this.getBuffer("aPosition").update();
1788
+ _anchorX: u,
1789
+ _anchorY: l
1790
+ } = this, d = i + s, c = t > d ? 1 : t / d, h = n + a, f = r > h ? 1 : r / h, y = Math.min(c, f), _ = u * t, b = l * r;
1791
+ e[0] = e[8] = e[16] = e[24] = -_, e[2] = e[10] = e[18] = e[26] = i * y - _, e[4] = e[12] = e[20] = e[28] = t - s * y - _, e[6] = e[14] = e[22] = e[30] = t - _, e[1] = e[3] = e[5] = e[7] = -b, e[9] = e[11] = e[13] = e[15] = n * y - b, e[17] = e[19] = e[21] = e[23] = r - a * y - b, e[25] = e[27] = e[29] = e[31] = r - b, this.getBuffer("aPosition").update();
1667
1792
  }
1668
1793
  /** Updates the UVs of the vertices. */
1669
1794
  updateUvs() {
@@ -1673,7 +1798,7 @@ const Ne = class qe extends kt {
1673
1798
  e[2] = e[10] = e[18] = e[26] = t * this._leftWidth, e[9] = e[11] = e[13] = e[15] = r * this._topHeight, e[4] = e[12] = e[20] = e[28] = 1 - t * this._rightWidth, e[17] = e[19] = e[21] = e[23] = 1 - r * this._bottomHeight, this.getBuffer("aUV").update();
1674
1799
  }
1675
1800
  };
1676
- Ne.defaultOptions = {
1801
+ Je.defaultOptions = {
1677
1802
  /** The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */
1678
1803
  width: 100,
1679
1804
  /** The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */
@@ -1691,16 +1816,16 @@ Ne.defaultOptions = {
1691
1816
  /** The original height of the texture */
1692
1817
  originalHeight: 100
1693
1818
  };
1694
- let Vt = Ne;
1695
- class Xt extends ue {
1819
+ let Qt = Je;
1820
+ class Jt extends le {
1696
1821
  constructor() {
1697
- super(), this.geometry = new Vt();
1822
+ super(), this.geometry = new Qt();
1698
1823
  }
1699
1824
  destroy() {
1700
1825
  this.geometry.destroy();
1701
1826
  }
1702
1827
  }
1703
- class Ke {
1828
+ class et {
1704
1829
  constructor(e) {
1705
1830
  this._renderer = e;
1706
1831
  }
@@ -1726,22 +1851,22 @@ class Ke {
1726
1851
  return e._gpuData[this._renderer.uid] || this._initGPUSprite(e);
1727
1852
  }
1728
1853
  _initGPUSprite(e) {
1729
- const t = e._gpuData[this._renderer.uid] = new Xt(), r = t;
1854
+ const t = e._gpuData[this._renderer.uid] = new Jt(), r = t;
1730
1855
  return r.renderable = e, r.transform = e.groupTransform, r.texture = e._texture, r.roundPixels = this._renderer._roundPixels | e._roundPixels, e.didViewUpdate || this._updateBatchableSprite(e, r), t;
1731
1856
  }
1732
1857
  destroy() {
1733
1858
  this._renderer = null;
1734
1859
  }
1735
1860
  }
1736
- Ke.extension = {
1861
+ et.extension = {
1737
1862
  type: [
1738
- g.WebGLPipes,
1739
- g.WebGPUPipes,
1740
- g.CanvasPipes
1863
+ m.WebGLPipes,
1864
+ m.WebGPUPipes,
1865
+ m.CanvasPipes
1741
1866
  ],
1742
1867
  name: "nineSliceSprite"
1743
1868
  };
1744
- const jt = {
1869
+ const Zt = {
1745
1870
  name: "tiling-bit",
1746
1871
  vertex: {
1747
1872
  header: (
@@ -1806,7 +1931,7 @@ const jt = {
1806
1931
  `
1807
1932
  )
1808
1933
  }
1809
- }, $t = {
1934
+ }, er = {
1810
1935
  name: "tiling-bit",
1811
1936
  vertex: {
1812
1937
  header: (
@@ -1851,25 +1976,25 @@ const jt = {
1851
1976
  )
1852
1977
  }
1853
1978
  };
1854
- let q, K;
1855
- class Nt extends oe {
1979
+ let q, Q;
1980
+ class tr extends oe {
1856
1981
  constructor() {
1857
- q ?? (q = Ce({
1982
+ q ?? (q = Me({
1858
1983
  name: "tiling-sprite-shader",
1859
1984
  bits: [
1860
- vt,
1861
- jt,
1862
- Fe
1985
+ St,
1986
+ Zt,
1987
+ Ue
1863
1988
  ]
1864
- })), K ?? (K = Be({
1989
+ })), Q ?? (Q = Ge({
1865
1990
  name: "tiling-sprite-shader",
1866
1991
  bits: [
1867
- Tt,
1868
- $t,
1869
- Ue
1992
+ Pt,
1993
+ er,
1994
+ ze
1870
1995
  ]
1871
1996
  }));
1872
- const e = new z({
1997
+ const e = new A({
1873
1998
  uMapCoord: { value: new R(), type: "mat3x3<f32>" },
1874
1999
  uClampFrame: { value: new Float32Array([0, 0, 1, 1]), type: "vec4<f32>" },
1875
2000
  uClampOffset: { value: new Float32Array([0, 0]), type: "vec2<f32>" },
@@ -1877,33 +2002,33 @@ class Nt extends oe {
1877
2002
  uSizeAnchor: { value: new Float32Array([100, 100, 0.5, 0.5]), type: "vec4<f32>" }
1878
2003
  });
1879
2004
  super({
1880
- glProgram: K,
2005
+ glProgram: Q,
1881
2006
  gpuProgram: q,
1882
2007
  resources: {
1883
- localUniforms: new z({
2008
+ localUniforms: new A({
1884
2009
  uTransformMatrix: { value: new R(), type: "mat3x3<f32>" },
1885
2010
  uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
1886
2011
  uRound: { value: 0, type: "f32" }
1887
2012
  }),
1888
2013
  tilingUniforms: e,
1889
- uTexture: S.EMPTY.source,
1890
- uSampler: S.EMPTY.source.style
2014
+ uTexture: C.EMPTY.source,
2015
+ uSampler: C.EMPTY.source.style
1891
2016
  }
1892
2017
  });
1893
2018
  }
1894
- updateUniforms(e, t, r, s, i, n) {
1895
- const a = this.resources.tilingUniforms, l = n.width, u = n.height, c = n.textureMatrix, d = a.uniforms.uTextureTransform;
1896
- d.set(
1897
- r.a * l / e,
1898
- r.b * l / t,
1899
- r.c * u / e,
1900
- r.d * u / t,
2019
+ updateUniforms(e, t, r, i, s, n) {
2020
+ const a = this.resources.tilingUniforms, u = n.width, l = n.height, d = n.textureMatrix, c = a.uniforms.uTextureTransform;
2021
+ c.set(
2022
+ r.a * u / e,
2023
+ r.b * u / t,
2024
+ r.c * l / e,
2025
+ r.d * l / t,
1901
2026
  r.tx / e,
1902
2027
  r.ty / t
1903
- ), d.invert(), a.uniforms.uMapCoord = c.mapCoord, a.uniforms.uClampFrame = c.uClampFrame, a.uniforms.uClampOffset = c.uClampOffset, a.uniforms.uTextureTransform = d, a.uniforms.uSizeAnchor[0] = e, a.uniforms.uSizeAnchor[1] = t, a.uniforms.uSizeAnchor[2] = s, a.uniforms.uSizeAnchor[3] = i, n && (this.resources.uTexture = n.source, this.resources.uSampler = n.source.style);
2028
+ ), c.invert(), a.uniforms.uMapCoord = d.mapCoord, a.uniforms.uClampFrame = d.uClampFrame, a.uniforms.uClampOffset = d.uClampOffset, a.uniforms.uTextureTransform = c, a.uniforms.uSizeAnchor[0] = e, a.uniforms.uSizeAnchor[1] = t, a.uniforms.uSizeAnchor[2] = i, a.uniforms.uSizeAnchor[3] = s, n && (this.resources.uTexture = n.source, this.resources.uSampler = n.source.style);
1904
2029
  }
1905
2030
  }
1906
- class qt extends le {
2031
+ class rr extends ue {
1907
2032
  constructor() {
1908
2033
  super({
1909
2034
  positions: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
@@ -1912,32 +2037,32 @@ class qt extends le {
1912
2037
  });
1913
2038
  }
1914
2039
  }
1915
- function Kt(o, e) {
2040
+ function ir(o, e) {
1916
2041
  const t = o.anchor.x, r = o.anchor.y;
1917
2042
  e[0] = -t * o.width, e[1] = -r * o.height, e[2] = (1 - t) * o.width, e[3] = -r * o.height, e[4] = (1 - t) * o.width, e[5] = (1 - r) * o.height, e[6] = -t * o.width, e[7] = (1 - r) * o.height;
1918
2043
  }
1919
- function Qt(o, e, t, r) {
1920
- let s = 0;
1921
- const i = o.length / e, n = r.a, a = r.b, l = r.c, u = r.d, c = r.tx, d = r.ty;
1922
- for (t *= e; s < i; ) {
2044
+ function sr(o, e, t, r) {
2045
+ let i = 0;
2046
+ const s = o.length / e, n = r.a, a = r.b, u = r.c, l = r.d, d = r.tx, c = r.ty;
2047
+ for (t *= e; i < s; ) {
1923
2048
  const h = o[t], f = o[t + 1];
1924
- o[t] = n * h + l * f + c, o[t + 1] = a * h + u * f + d, t += e, s++;
2049
+ o[t] = n * h + u * f + d, o[t + 1] = a * h + l * f + c, t += e, i++;
1925
2050
  }
1926
2051
  }
1927
- function Jt(o, e) {
1928
- const t = o.texture, r = t.frame.width, s = t.frame.height;
1929
- let i = 0, n = 0;
1930
- o.applyAnchorToTexture && (i = o.anchor.x, n = o.anchor.y), e[0] = e[6] = -i, e[2] = e[4] = 1 - i, e[1] = e[3] = -n, e[5] = e[7] = 1 - n;
2052
+ function nr(o, e) {
2053
+ const t = o.texture, r = t.frame.width, i = t.frame.height;
2054
+ let s = 0, n = 0;
2055
+ o.applyAnchorToTexture && (s = o.anchor.x, n = o.anchor.y), e[0] = e[6] = -s, e[2] = e[4] = 1 - s, e[1] = e[3] = -n, e[5] = e[7] = 1 - n;
1931
2056
  const a = R.shared;
1932
- a.copyFrom(o._tileTransform.matrix), a.tx /= o.width, a.ty /= o.height, a.invert(), a.scale(o.width / r, o.height / s), Qt(e, 2, 0, a);
2057
+ a.copyFrom(o._tileTransform.matrix), a.tx /= o.width, a.ty /= o.height, a.invert(), a.scale(o.width / r, o.height / i), sr(e, 2, 0, a);
1933
2058
  }
1934
- const Y = new qt();
1935
- class Zt {
2059
+ const H = new rr();
2060
+ class ar {
1936
2061
  constructor() {
1937
- this.canBatch = !0, this.geometry = new le({
1938
- indices: Y.indices.slice(),
1939
- positions: Y.positions.slice(),
1940
- uvs: Y.uvs.slice()
2062
+ this.canBatch = !0, this.geometry = new ue({
2063
+ indices: H.indices.slice(),
2064
+ positions: H.positions.slice(),
2065
+ uvs: H.uvs.slice()
1941
2066
  });
1942
2067
  }
1943
2068
  destroy() {
@@ -1945,33 +2070,33 @@ class Zt {
1945
2070
  this.geometry.destroy(), (e = this.shader) == null || e.destroy();
1946
2071
  }
1947
2072
  }
1948
- class Qe {
2073
+ class tt {
1949
2074
  constructor(e) {
1950
2075
  this._state = j.default2d, this._renderer = e;
1951
2076
  }
1952
2077
  validateRenderable(e) {
1953
2078
  const t = this._getTilingSpriteData(e), r = t.canBatch;
1954
2079
  this._updateCanBatch(e);
1955
- const s = t.canBatch;
1956
- if (s && s === r) {
1957
- const { batchableMesh: i } = t;
1958
- return !i._batcher.checkAndUpdateTexture(
1959
- i,
2080
+ const i = t.canBatch;
2081
+ if (i && i === r) {
2082
+ const { batchableMesh: s } = t;
2083
+ return !s._batcher.checkAndUpdateTexture(
2084
+ s,
1960
2085
  e.texture
1961
2086
  );
1962
2087
  }
1963
- return r !== s;
2088
+ return r !== i;
1964
2089
  }
1965
2090
  addRenderable(e, t) {
1966
2091
  const r = this._renderer.renderPipes.batch;
1967
2092
  this._updateCanBatch(e);
1968
- const s = this._getTilingSpriteData(e), { geometry: i, canBatch: n } = s;
2093
+ const i = this._getTilingSpriteData(e), { geometry: s, canBatch: n } = i;
1969
2094
  if (n) {
1970
- s.batchableMesh || (s.batchableMesh = new ue());
1971
- const a = s.batchableMesh;
1972
- e.didViewUpdate && (this._updateBatchableMesh(e), a.geometry = i, a.renderable = e, a.transform = e.groupTransform, a.setTexture(e._texture)), a.roundPixels = this._renderer._roundPixels | e._roundPixels, r.addToBatch(a, t);
2095
+ i.batchableMesh || (i.batchableMesh = new le());
2096
+ const a = i.batchableMesh;
2097
+ e.didViewUpdate && (this._updateBatchableMesh(e), a.geometry = s, a.renderable = e, a.transform = e.groupTransform, a.setTexture(e._texture)), a.roundPixels = this._renderer._roundPixels | e._roundPixels, r.addToBatch(a, t);
1973
2098
  } else
1974
- r.break(t), s.shader || (s.shader = new Nt()), this.updateRenderable(e), t.add(e);
2099
+ r.break(t), i.shader || (i.shader = new tr()), this.updateRenderable(e), t.add(e);
1975
2100
  }
1976
2101
  execute(e) {
1977
2102
  const { shader: t } = this._getTilingSpriteData(e);
@@ -1982,7 +2107,7 @@ class Qe {
1982
2107
  r.uColor,
1983
2108
  0
1984
2109
  ), this._state.blendMode = ae(e.groupBlendMode, e.texture._source), this._renderer.encoder.draw({
1985
- geometry: Y,
2110
+ geometry: H,
1986
2111
  shader: t,
1987
2112
  state: this._state
1988
2113
  });
@@ -1990,11 +2115,11 @@ class Qe {
1990
2115
  updateRenderable(e) {
1991
2116
  const t = this._getTilingSpriteData(e), { canBatch: r } = t;
1992
2117
  if (r) {
1993
- const { batchableMesh: s } = t;
1994
- e.didViewUpdate && this._updateBatchableMesh(e), s._batcher.updateElement(s);
2118
+ const { batchableMesh: i } = t;
2119
+ e.didViewUpdate && this._updateBatchableMesh(e), i._batcher.updateElement(i);
1995
2120
  } else if (e.didViewUpdate) {
1996
- const { shader: s } = t;
1997
- s.updateUniforms(
2121
+ const { shader: i } = t;
2122
+ i.updateUniforms(
1998
2123
  e.width,
1999
2124
  e.height,
2000
2125
  e._tileTransform.matrix,
@@ -2008,31 +2133,31 @@ class Qe {
2008
2133
  return e._gpuData[this._renderer.uid] || this._initTilingSpriteData(e);
2009
2134
  }
2010
2135
  _initTilingSpriteData(e) {
2011
- const t = new Zt();
2136
+ const t = new ar();
2012
2137
  return t.renderable = e, e._gpuData[this._renderer.uid] = t, t;
2013
2138
  }
2014
2139
  _updateBatchableMesh(e) {
2015
- const t = this._getTilingSpriteData(e), { geometry: r } = t, s = e.texture.source.style;
2016
- s.addressMode !== "repeat" && (s.addressMode = "repeat", s.update()), Jt(e, r.uvs), Kt(e, r.positions);
2140
+ const t = this._getTilingSpriteData(e), { geometry: r } = t, i = e.texture.source.style;
2141
+ i.addressMode !== "repeat" && (i.addressMode = "repeat", i.update()), nr(e, r.uvs), ir(e, r.positions);
2017
2142
  }
2018
2143
  destroy() {
2019
2144
  this._renderer = null;
2020
2145
  }
2021
2146
  _updateCanBatch(e) {
2022
2147
  const t = this._getTilingSpriteData(e), r = e.texture;
2023
- let s = !0;
2024
- return this._renderer.type === ie.WEBGL && (s = this._renderer.context.supports.nonPowOf2wrapping), t.canBatch = r.textureMatrix.isSimple && (s || r.source.isPowerOfTwo), t.canBatch;
2148
+ let i = !0;
2149
+ return this._renderer.type === se.WEBGL && (i = this._renderer.context.supports.nonPowOf2wrapping), t.canBatch = r.textureMatrix.isSimple && (i || r.source.isPowerOfTwo), t.canBatch;
2025
2150
  }
2026
2151
  }
2027
- Qe.extension = {
2152
+ tt.extension = {
2028
2153
  type: [
2029
- g.WebGLPipes,
2030
- g.WebGPUPipes,
2031
- g.CanvasPipes
2154
+ m.WebGLPipes,
2155
+ m.WebGPUPipes,
2156
+ m.CanvasPipes
2032
2157
  ],
2033
2158
  name: "tilingSprite"
2034
2159
  };
2035
- const er = {
2160
+ const or = {
2036
2161
  name: "local-uniform-msdf-bit",
2037
2162
  vertex: {
2038
2163
  header: (
@@ -2085,7 +2210,7 @@ const er = {
2085
2210
  `
2086
2211
  )
2087
2212
  }
2088
- }, tr = {
2213
+ }, ur = {
2089
2214
  name: "local-uniform-msdf-bit",
2090
2215
  vertex: {
2091
2216
  header: (
@@ -2127,7 +2252,7 @@ const er = {
2127
2252
  `
2128
2253
  )
2129
2254
  }
2130
- }, rr = {
2255
+ }, lr = {
2131
2256
  name: "msdf-bit",
2132
2257
  fragment: {
2133
2258
  header: (
@@ -2162,7 +2287,7 @@ const er = {
2162
2287
  `
2163
2288
  )
2164
2289
  }
2165
- }, sr = {
2290
+ }, cr = {
2166
2291
  name: "msdf-bit",
2167
2292
  fragment: {
2168
2293
  header: (
@@ -2198,51 +2323,51 @@ const er = {
2198
2323
  )
2199
2324
  }
2200
2325
  };
2201
- let Q, J;
2202
- class ir extends oe {
2326
+ let J, Z;
2327
+ class dr extends oe {
2203
2328
  constructor(e) {
2204
- const t = new z({
2329
+ const t = new A({
2205
2330
  uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
2206
2331
  uTransformMatrix: { value: new R(), type: "mat3x3<f32>" },
2207
2332
  uDistance: { value: 4, type: "f32" },
2208
2333
  uRound: { value: 0, type: "f32" }
2209
2334
  });
2210
- Q ?? (Q = Ce({
2335
+ J ?? (J = Me({
2211
2336
  name: "sdf-shader",
2212
2337
  bits: [
2213
- ft,
2214
- pt(e),
2215
- er,
2216
- rr,
2217
- Fe
2338
+ mt,
2339
+ xt(e),
2340
+ or,
2341
+ lr,
2342
+ Ue
2218
2343
  ]
2219
- })), J ?? (J = Be({
2344
+ })), Z ?? (Z = Ge({
2220
2345
  name: "sdf-shader",
2221
2346
  bits: [
2222
- gt,
2223
- mt(e),
2224
- tr,
2225
- sr,
2226
- Ue
2347
+ _t,
2348
+ yt(e),
2349
+ ur,
2350
+ cr,
2351
+ ze
2227
2352
  ]
2228
2353
  })), super({
2229
- glProgram: J,
2230
- gpuProgram: Q,
2354
+ glProgram: Z,
2355
+ gpuProgram: J,
2231
2356
  resources: {
2232
2357
  localUniforms: t,
2233
- batchSamplers: xt(e)
2358
+ batchSamplers: bt(e)
2234
2359
  }
2235
2360
  });
2236
2361
  }
2237
2362
  }
2238
- class nr extends _t {
2363
+ class hr extends vt {
2239
2364
  destroy() {
2240
2365
  this.context.customShader && this.context.customShader.destroy(), super.destroy();
2241
2366
  }
2242
2367
  }
2243
- class Je {
2368
+ class rt {
2244
2369
  constructor(e) {
2245
- this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_gpuBitmapText");
2370
+ this._renderer = e;
2246
2371
  }
2247
2372
  validateRenderable(e) {
2248
2373
  const t = this._getGpuBitmapText(e);
@@ -2250,77 +2375,77 @@ class Je {
2250
2375
  }
2251
2376
  addRenderable(e, t) {
2252
2377
  const r = this._getGpuBitmapText(e);
2253
- Te(e, r), e._didTextUpdate && (e._didTextUpdate = !1, this._updateContext(e, r)), this._renderer.renderPipes.graphics.addRenderable(r, t), r.context.customShader && this._updateDistanceField(e);
2378
+ Ce(e, r), e._didTextUpdate && (e._didTextUpdate = !1, this._updateContext(e, r)), this._renderer.renderPipes.graphics.addRenderable(r, t), r.context.customShader && this._updateDistanceField(e);
2254
2379
  }
2255
2380
  updateRenderable(e) {
2256
2381
  const t = this._getGpuBitmapText(e);
2257
- Te(e, t), this._renderer.renderPipes.graphics.updateRenderable(t), t.context.customShader && this._updateDistanceField(e);
2382
+ Ce(e, t), this._renderer.renderPipes.graphics.updateRenderable(t), t.context.customShader && this._updateDistanceField(e);
2258
2383
  }
2259
2384
  _updateContext(e, t) {
2260
- const { context: r } = t, s = Ut.getFont(e.text, e._style);
2261
- r.clear(), s.distanceField.type !== "none" && (r.customShader || (r.customShader = new ir(this._renderer.limits.maxBatchableTextures)));
2262
- const i = D.graphemeSegmenter(e.text), n = e._style;
2263
- let a = s.baseLineOffset;
2264
- const l = ke(i, n, s, !0), u = n.padding, c = l.scale;
2265
- let d = l.width, h = l.height + l.offsetY;
2266
- n._stroke && (d += n._stroke.width / c, h += n._stroke.width / c), r.translate(-e._anchor._x * d - u, -e._anchor._y * h - u).scale(c, c);
2267
- const f = s.applyFillAsTint ? n._fill.color : 16777215;
2268
- let b = s.fontMetrics.fontSize, m = s.lineHeight;
2269
- n.lineHeight && (b = n.fontSize / c, m = n.lineHeight / c);
2270
- let x = (m - b) / 2;
2271
- x - s.baseLineOffset < 0 && (x = 0);
2272
- for (let p = 0; p < l.lines.length; p++) {
2273
- const _ = l.lines[p];
2274
- for (let y = 0; y < _.charPositions.length; y++) {
2275
- const v = _.chars[y], P = s.chars[v];
2276
- if (P != null && P.texture) {
2277
- const G = P.texture;
2385
+ const { context: r } = t, i = zt.getFont(e.text, e._style);
2386
+ r.clear(), i.distanceField.type !== "none" && (r.customShader || (r.customShader = new dr(this._renderer.limits.maxBatchableTextures)));
2387
+ const s = D.graphemeSegmenter(e.text), n = e._style;
2388
+ let a = i.baseLineOffset;
2389
+ const u = We(s, n, i, !0), l = n.padding, d = u.scale;
2390
+ let c = u.width, h = u.height + u.offsetY;
2391
+ n._stroke && (c += n._stroke.width / d, h += n._stroke.width / d), r.translate(-e._anchor._x * c - l, -e._anchor._y * h - l).scale(d, d);
2392
+ const f = i.applyFillAsTint ? n._fill.color : 16777215;
2393
+ let y = i.fontMetrics.fontSize, _ = i.lineHeight;
2394
+ n.lineHeight && (y = n.fontSize / d, _ = n.lineHeight / d);
2395
+ let b = (_ - y) / 2;
2396
+ b - i.baseLineOffset < 0 && (b = 0);
2397
+ for (let x = 0; x < u.lines.length; x++) {
2398
+ const g = u.lines[x];
2399
+ for (let p = 0; p < g.charPositions.length; p++) {
2400
+ const v = g.chars[p], S = i.chars[v];
2401
+ if (S != null && S.texture) {
2402
+ const G = S.texture;
2278
2403
  r.texture(
2279
2404
  G,
2280
2405
  f || "black",
2281
- Math.round(_.charPositions[y] + P.xOffset),
2282
- Math.round(a + P.yOffset + x),
2406
+ Math.round(g.charPositions[p] + S.xOffset),
2407
+ Math.round(a + S.yOffset + b),
2283
2408
  G.orig.width,
2284
2409
  G.orig.height
2285
2410
  );
2286
2411
  }
2287
2412
  }
2288
- a += m;
2413
+ a += _;
2289
2414
  }
2290
2415
  }
2291
2416
  _getGpuBitmapText(e) {
2292
2417
  return e._gpuData[this._renderer.uid] || this.initGpuText(e);
2293
2418
  }
2294
2419
  initGpuText(e) {
2295
- const t = new nr();
2420
+ const t = new hr();
2296
2421
  return e._gpuData[this._renderer.uid] = t, this._updateContext(e, t), t;
2297
2422
  }
2298
2423
  _updateDistanceField(e) {
2299
- const t = this._getGpuBitmapText(e).context, r = e._style.fontFamily, s = C.get(`${r}-bitmap`), { a: i, b: n, c: a, d: l } = e.groupTransform, u = Math.sqrt(i * i + n * n), c = Math.sqrt(a * a + l * l), d = (Math.abs(u) + Math.abs(c)) / 2, h = s.baseRenderedFontSize / e._style.fontSize, f = d * s.distanceField.range * (1 / h);
2424
+ const t = this._getGpuBitmapText(e).context, r = e._style.fontFamily, i = P.get(`${r}-bitmap`), { a: s, b: n, c: a, d: u } = e.groupTransform, l = Math.sqrt(s * s + n * n), d = Math.sqrt(a * a + u * u), c = (Math.abs(l) + Math.abs(d)) / 2, h = i.baseRenderedFontSize / e._style.fontSize, f = c * i.distanceField.range * (1 / h);
2300
2425
  t.customShader.resources.localUniforms.uniforms.uDistance = f;
2301
2426
  }
2302
2427
  destroy() {
2303
2428
  this._renderer = null;
2304
2429
  }
2305
2430
  }
2306
- Je.extension = {
2431
+ rt.extension = {
2307
2432
  type: [
2308
- g.WebGLPipes,
2309
- g.WebGPUPipes,
2310
- g.CanvasPipes
2433
+ m.WebGLPipes,
2434
+ m.WebGPUPipes,
2435
+ m.CanvasPipes
2311
2436
  ],
2312
2437
  name: "bitmapText"
2313
2438
  };
2314
- function Te(o, e) {
2439
+ function Ce(o, e) {
2315
2440
  e.groupTransform = o.groupTransform, e.groupColorAlpha = o.groupColorAlpha, e.groupColor = o.groupColor, e.groupBlendMode = o.groupBlendMode, e.globalDisplayStatus = o.globalDisplayStatus, e.groupTransform = o.groupTransform, e.localDisplayStatus = o.localDisplayStatus, e.groupAlpha = o.groupAlpha, e._roundPixels = o._roundPixels;
2316
2441
  }
2317
- class ar extends Me {
2442
+ class fr extends Ae {
2318
2443
  /**
2319
2444
  * Creates an instance of BatchableHTMLText.
2320
2445
  * @param renderer - The renderer instance to be used.
2321
2446
  */
2322
2447
  constructor(e) {
2323
- super(), this.generatingTexture = !1, this._renderer = e, e.runners.resolutionChange.add(this);
2448
+ super(), this.generatingTexture = !1, this.currentKey = "--", this._renderer = e, e.runners.resolutionChange.add(this);
2324
2449
  }
2325
2450
  /** Handles resolution changes for the HTML text. If the text has auto resolution enabled, it triggers a view update. */
2326
2451
  resolutionChange() {
@@ -2329,27 +2454,33 @@ class ar extends Me {
2329
2454
  }
2330
2455
  /** Destroys the BatchableHTMLText instance. Returns the texture promise to the renderer and cleans up references. */
2331
2456
  destroy() {
2332
- this._renderer.htmlText.returnTexturePromise(this.texturePromise), this.texturePromise = null, this._renderer = null;
2457
+ const { htmlText: e } = this._renderer;
2458
+ e.getReferenceCount(this.currentKey) === null ? e.returnTexturePromise(this.texturePromise) : e.decreaseReferenceCount(this.currentKey), this._renderer.runners.resolutionChange.remove(this), this.texturePromise = null, this._renderer = null;
2333
2459
  }
2334
2460
  }
2335
- function te(o, e) {
2336
- const { texture: t, bounds: r } = o, s = e._style._getFinalPadding();
2337
- bt(r, e._anchor, t);
2338
- const i = e._anchor._x * s * 2, n = e._anchor._y * s * 2;
2339
- r.minX -= s - i, r.minY -= s - n, r.maxX -= s - i, r.maxY -= s - n;
2461
+ function re(o, e) {
2462
+ const { texture: t, bounds: r } = o, i = e._style._getFinalPadding();
2463
+ Tt(r, e._anchor, t);
2464
+ const s = e._anchor._x * i * 2, n = e._anchor._y * i * 2;
2465
+ r.minX -= i - s, r.minY -= i - n, r.maxX -= i - s, r.maxY -= i - n;
2340
2466
  }
2341
- class Ze {
2467
+ class it {
2342
2468
  constructor(e) {
2343
2469
  this._renderer = e;
2344
2470
  }
2345
2471
  validateRenderable(e) {
2346
- return e._didTextUpdate;
2472
+ const t = this._getGpuText(e), r = e.styleKey;
2473
+ return t.currentKey !== r;
2347
2474
  }
2348
2475
  addRenderable(e, t) {
2349
2476
  const r = this._getGpuText(e);
2350
- e._didTextUpdate && (this._updateGpuText(e).catch((s) => {
2351
- console.error(s);
2352
- }), e._didTextUpdate = !1, te(r, e)), this._renderer.renderPipes.batch.addToBatch(r, t);
2477
+ if (e._didTextUpdate) {
2478
+ const i = e._autoResolution ? this._renderer.resolution : e.resolution;
2479
+ (r.currentKey !== e.styleKey || e.resolution !== i) && this._updateGpuText(e).catch((s) => {
2480
+ console.error(s);
2481
+ }), e._didTextUpdate = !1, re(r, e);
2482
+ }
2483
+ this._renderer.renderPipes.batch.addToBatch(r, t);
2353
2484
  }
2354
2485
  updateRenderable(e) {
2355
2486
  const t = this._getGpuText(e);
@@ -2360,75 +2491,78 @@ class Ze {
2360
2491
  const t = this._getGpuText(e);
2361
2492
  if (t.generatingTexture)
2362
2493
  return;
2363
- t.texturePromise && (this._renderer.htmlText.returnTexturePromise(t.texturePromise), t.texturePromise = null), t.generatingTexture = !0, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution;
2364
- const r = this._renderer.htmlText.getTexturePromise(e);
2365
- t.texturePromise = r, t.texture = await r;
2494
+ const r = t.texturePromise;
2495
+ t.texturePromise = null, t.generatingTexture = !0, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution;
2496
+ let i = this._renderer.htmlText.getTexturePromise(e);
2497
+ r && (i = i.finally(() => {
2498
+ this._renderer.htmlText.decreaseReferenceCount(t.currentKey), this._renderer.htmlText.returnTexturePromise(r);
2499
+ })), t.texturePromise = i, t.currentKey = e.styleKey, t.texture = await i;
2366
2500
  const s = e.renderGroup || e.parentRenderGroup;
2367
- s && (s.structureDidChange = !0), t.generatingTexture = !1, te(t, e);
2501
+ s && (s.structureDidChange = !0), t.generatingTexture = !1, re(t, e);
2368
2502
  }
2369
2503
  _getGpuText(e) {
2370
2504
  return e._gpuData[this._renderer.uid] || this.initGpuText(e);
2371
2505
  }
2372
2506
  initGpuText(e) {
2373
- const t = new ar(this._renderer);
2374
- return t.renderable = e, t.transform = e.groupTransform, t.texture = S.EMPTY, t.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, e._gpuData[this._renderer.uid] = t, t;
2507
+ const t = new fr(this._renderer);
2508
+ return t.renderable = e, t.transform = e.groupTransform, t.texture = C.EMPTY, t.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, e._gpuData[this._renderer.uid] = t, t;
2375
2509
  }
2376
2510
  destroy() {
2377
2511
  this._renderer = null;
2378
2512
  }
2379
2513
  }
2380
- Ze.extension = {
2514
+ it.extension = {
2381
2515
  type: [
2382
- g.WebGLPipes,
2383
- g.WebGPUPipes,
2384
- g.CanvasPipes
2516
+ m.WebGLPipes,
2517
+ m.WebGPUPipes,
2518
+ m.CanvasPipes
2385
2519
  ],
2386
2520
  name: "htmlText"
2387
2521
  };
2388
- function or() {
2522
+ function pr() {
2389
2523
  const { userAgent: o } = ne.get().getNavigator();
2390
2524
  return /^((?!chrome|android).)*safari/i.test(o);
2391
2525
  }
2392
- const lr = new Pe();
2393
- function et(o, e, t, r) {
2394
- const s = lr;
2395
- s.minX = 0, s.minY = 0, s.maxX = o.width / r | 0, s.maxY = o.height / r | 0;
2396
- const i = F.getOptimalTexture(
2397
- s.width,
2398
- s.height,
2526
+ const gr = new Re();
2527
+ function st(o, e, t, r) {
2528
+ const i = gr;
2529
+ i.minX = 0, i.minY = 0, i.maxX = o.width / r | 0, i.maxY = o.height / r | 0;
2530
+ const s = F.getOptimalTexture(
2531
+ i.width,
2532
+ i.height,
2399
2533
  r,
2400
2534
  !1
2401
2535
  );
2402
- return i.source.uploadMethodId = "image", i.source.resource = o, i.source.alphaMode = "premultiply-alpha-on-upload", i.frame.width = e / r, i.frame.height = t / r, i.source.emit("update", i.source), i.updateUvs(), i;
2536
+ return s.source.uploadMethodId = "image", s.source.resource = o, s.source.alphaMode = "premultiply-alpha-on-upload", s.frame.width = e / r, s.frame.height = t / r, s.source.emit("update", s.source), s.updateUvs(), s;
2403
2537
  }
2404
- function ur(o, e) {
2405
- const t = e.fontFamily, r = [], s = {}, i = /font-family:([^;"\s]+)/g, n = o.match(i);
2406
- function a(l) {
2407
- s[l] || (r.push(l), s[l] = !0);
2538
+ function mr(o, e) {
2539
+ const t = e.fontFamily, r = [], i = {}, s = /font-family:([^;"\s]+)/g, n = o.match(s);
2540
+ function a(u) {
2541
+ i[u] || (r.push(u), i[u] = !0);
2408
2542
  }
2409
2543
  if (Array.isArray(t))
2410
- for (let l = 0; l < t.length; l++)
2411
- a(t[l]);
2544
+ for (let u = 0; u < t.length; u++)
2545
+ a(t[u]);
2412
2546
  else
2413
2547
  a(t);
2414
- n && n.forEach((l) => {
2415
- const u = l.split(":")[1].trim();
2416
- a(u);
2548
+ n && n.forEach((u) => {
2549
+ const l = u.split(":")[1].trim();
2550
+ a(l);
2417
2551
  });
2418
- for (const l in e.tagStyles) {
2419
- const u = e.tagStyles[l].fontFamily;
2420
- a(u);
2552
+ for (const u in e.tagStyles) {
2553
+ const l = e.tagStyles[u].fontFamily;
2554
+ a(l);
2421
2555
  }
2422
2556
  return r;
2423
2557
  }
2424
- async function dr(o) {
2558
+ async function xr(o) {
2425
2559
  const t = await (await ne.get().fetch(o)).blob(), r = new FileReader();
2426
- return await new Promise((i, n) => {
2427
- r.onloadend = () => i(r.result), r.onerror = n, r.readAsDataURL(t);
2560
+ return await new Promise((s, n) => {
2561
+ r.onloadend = () => s(r.result), r.onerror = n, r.readAsDataURL(t);
2428
2562
  });
2429
2563
  }
2430
- async function cr(o, e) {
2431
- const t = await dr(e);
2564
+ async function _r(o, e) {
2565
+ const t = await xr(e);
2432
2566
  return `@font-face {
2433
2567
  font-family: "${o.fontFamily}";
2434
2568
  font-weight: ${o.fontWeight};
@@ -2436,60 +2570,60 @@ async function cr(o, e) {
2436
2570
  src: url('${t}');
2437
2571
  }`;
2438
2572
  }
2439
- const Z = /* @__PURE__ */ new Map();
2440
- async function hr(o) {
2441
- const e = o.filter((t) => C.has(`${t}-and-url`)).map((t) => {
2442
- if (!Z.has(t)) {
2443
- const { entries: r } = C.get(`${t}-and-url`), s = [];
2444
- r.forEach((i) => {
2445
- const n = i.url, l = i.faces.map((u) => ({ weight: u.weight, style: u.style }));
2446
- s.push(
2447
- ...l.map(
2448
- (u) => cr(
2573
+ const ee = /* @__PURE__ */ new Map();
2574
+ async function yr(o) {
2575
+ const e = o.filter((t) => P.has(`${t}-and-url`)).map((t) => {
2576
+ if (!ee.has(t)) {
2577
+ const { entries: r } = P.get(`${t}-and-url`), i = [];
2578
+ r.forEach((s) => {
2579
+ const n = s.url, u = s.faces.map((l) => ({ weight: l.weight, style: l.style }));
2580
+ i.push(
2581
+ ...u.map(
2582
+ (l) => _r(
2449
2583
  {
2450
- fontWeight: u.weight,
2451
- fontStyle: u.style,
2584
+ fontWeight: l.weight,
2585
+ fontStyle: l.style,
2452
2586
  fontFamily: t
2453
2587
  },
2454
2588
  n
2455
2589
  )
2456
2590
  )
2457
2591
  );
2458
- }), Z.set(
2592
+ }), ee.set(
2459
2593
  t,
2460
- Promise.all(s).then((i) => i.join(`
2594
+ Promise.all(i).then((s) => s.join(`
2461
2595
  `))
2462
2596
  );
2463
2597
  }
2464
- return Z.get(t);
2598
+ return ee.get(t);
2465
2599
  });
2466
2600
  return (await Promise.all(e)).join(`
2467
2601
  `);
2468
2602
  }
2469
- function fr(o, e, t, r, s) {
2470
- const { domElement: i, styleElement: n, svgRoot: a } = s;
2471
- i.innerHTML = `<style>${e.cssStyle}</style><div style='padding:0;'>${o}</div>`, i.setAttribute("style", `transform: scale(${t});transform-origin: top left; display: inline-block`), n.textContent = r;
2472
- const { width: l, height: u } = s.image;
2473
- return a.setAttribute("width", l.toString()), a.setAttribute("height", u.toString()), new XMLSerializer().serializeToString(a);
2603
+ function br(o, e, t, r, i) {
2604
+ const { domElement: s, styleElement: n, svgRoot: a } = i;
2605
+ s.innerHTML = `<style>${e.cssStyle}</style><div style='padding:0;'>${o}</div>`, s.setAttribute("style", `transform: scale(${t});transform-origin: top left; display: inline-block`), n.textContent = r;
2606
+ const { width: u, height: l } = i.image;
2607
+ return a.setAttribute("width", u.toString()), a.setAttribute("height", l.toString()), new XMLSerializer().serializeToString(a);
2474
2608
  }
2475
- function pr(o, e) {
2476
- const t = V.getOptimalCanvasAndContext(
2609
+ function vr(o, e) {
2610
+ const t = Y.getOptimalCanvasAndContext(
2477
2611
  o.width,
2478
2612
  o.height,
2479
2613
  e
2480
2614
  ), { context: r } = t;
2481
2615
  return r.clearRect(0, 0, o.width, o.height), r.drawImage(o, 0, 0), t;
2482
2616
  }
2483
- function gr(o, e, t) {
2617
+ function Tr(o, e, t) {
2484
2618
  return new Promise(async (r) => {
2485
- t && await new Promise((s) => setTimeout(s, 100)), o.onload = () => {
2619
+ t && await new Promise((i) => setTimeout(i, 100)), o.onload = () => {
2486
2620
  r();
2487
2621
  }, o.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`, o.crossOrigin = "anonymous";
2488
2622
  });
2489
2623
  }
2490
- class tt {
2624
+ class nt {
2491
2625
  constructor(e) {
2492
- this._renderer = e, this._createCanvas = e.type === ie.WEBGPU;
2626
+ this._activeTextures = {}, this._renderer = e, this._createCanvas = e.type === se.WEBGPU;
2493
2627
  }
2494
2628
  /**
2495
2629
  * @param options
@@ -2498,30 +2632,75 @@ class tt {
2498
2632
  getTexture(e) {
2499
2633
  return this.getTexturePromise(e);
2500
2634
  }
2635
+ /**
2636
+ * Increases the reference count for a texture.
2637
+ * @param text - The HTMLText instance associated with the texture.
2638
+ */
2639
+ getManagedTexture(e) {
2640
+ const t = e.styleKey;
2641
+ if (this._activeTextures[t])
2642
+ return this._increaseReferenceCount(t), this._activeTextures[t].promise;
2643
+ const r = this._buildTexturePromise(e).then((i) => (this._activeTextures[t].texture = i, i));
2644
+ return this._activeTextures[t] = {
2645
+ texture: null,
2646
+ promise: r,
2647
+ usageCount: 1
2648
+ }, r;
2649
+ }
2650
+ /**
2651
+ * Gets the current reference count for a texture associated with a text key.
2652
+ * @param textKey - The unique key identifying the text style configuration
2653
+ * @returns The number of Text instances currently using this texture
2654
+ */
2655
+ getReferenceCount(e) {
2656
+ var t;
2657
+ return ((t = this._activeTextures[e]) == null ? void 0 : t.usageCount) ?? null;
2658
+ }
2659
+ _increaseReferenceCount(e) {
2660
+ this._activeTextures[e].usageCount++;
2661
+ }
2662
+ /**
2663
+ * Decreases the reference count for a texture.
2664
+ * If the count reaches zero, the texture is cleaned up.
2665
+ * @param textKey - The key associated with the HTMLText instance.
2666
+ */
2667
+ decreaseReferenceCount(e) {
2668
+ const t = this._activeTextures[e];
2669
+ t && (t.usageCount--, t.usageCount === 0 && (t.texture ? this._cleanUp(t.texture) : t.promise.then((r) => {
2670
+ t.texture = r, this._cleanUp(t.texture);
2671
+ }).catch(() => {
2672
+ X("HTMLTextSystem: Failed to clean texture");
2673
+ }), this._activeTextures[e] = null));
2674
+ }
2675
+ /**
2676
+ * Returns a promise that resolves to a texture for the given HTMLText options.
2677
+ * @param options - The options for the HTMLText.
2678
+ * @returns A promise that resolves to a Texture.
2679
+ */
2501
2680
  getTexturePromise(e) {
2502
2681
  return this._buildTexturePromise(e);
2503
2682
  }
2504
2683
  async _buildTexturePromise(e) {
2505
- const { text: t, style: r, resolution: s, textureStyle: i } = e, n = X.get(Ee), a = ur(t, r), l = await hr(a), u = At(t, r, l, n), c = Math.ceil(Math.ceil(Math.max(1, u.width) + r.padding * 2) * s), d = Math.ceil(Math.ceil(Math.max(1, u.height) + r.padding * 2) * s), h = n.image, f = 2;
2506
- h.width = (c | 0) + f, h.height = (d | 0) + f;
2507
- const b = fr(t, r, s, l, n);
2508
- await gr(h, b, or() && a.length > 0);
2509
- const m = h;
2510
- let x;
2511
- this._createCanvas && (x = pr(h, s));
2512
- const p = et(
2513
- x ? x.canvas : m,
2684
+ const { text: t, style: r, resolution: i, textureStyle: s } = e, n = K.get(Ye), a = mr(t, r), u = await yr(a), l = Et(t, r, u, n), d = Math.ceil(Math.ceil(Math.max(1, l.width) + r.padding * 2) * i), c = Math.ceil(Math.ceil(Math.max(1, l.height) + r.padding * 2) * i), h = n.image, f = 2;
2685
+ h.width = (d | 0) + f, h.height = (c | 0) + f;
2686
+ const y = br(t, r, i, u, n);
2687
+ await Tr(h, y, pr() && a.length > 0);
2688
+ const _ = h;
2689
+ let b;
2690
+ this._createCanvas && (b = vr(h, i));
2691
+ const x = st(
2692
+ b ? b.canvas : _,
2514
2693
  h.width - f,
2515
2694
  h.height - f,
2516
- s
2695
+ i
2517
2696
  );
2518
- return i && (p.source.style = i), this._createCanvas && (this._renderer.texture.initSource(p.source), V.returnCanvasAndContext(x)), X.return(n), p;
2697
+ return s && (x.source.style = s), this._createCanvas && (this._renderer.texture.initSource(x.source), Y.returnCanvasAndContext(b)), K.return(n), x;
2519
2698
  }
2520
2699
  returnTexturePromise(e) {
2521
2700
  e.then((t) => {
2522
2701
  this._cleanUp(t);
2523
2702
  }).catch(() => {
2524
- re("HTMLTextSystem: Failed to clean texture");
2703
+ X("HTMLTextSystem: Failed to clean texture");
2525
2704
  });
2526
2705
  }
2527
2706
  _cleanUp(e) {
@@ -2529,17 +2708,20 @@ class tt {
2529
2708
  }
2530
2709
  destroy() {
2531
2710
  this._renderer = null;
2711
+ for (const e in this._activeTextures)
2712
+ this._activeTextures[e] && this.returnTexturePromise(this._activeTextures[e].promise);
2713
+ this._activeTextures = null;
2532
2714
  }
2533
2715
  }
2534
- tt.extension = {
2716
+ nt.extension = {
2535
2717
  type: [
2536
- g.WebGLSystem,
2537
- g.WebGPUSystem,
2538
- g.CanvasSystem
2718
+ m.WebGLSystem,
2719
+ m.WebGPUSystem,
2720
+ m.CanvasSystem
2539
2721
  ],
2540
2722
  name: "htmlText"
2541
2723
  };
2542
- class mr extends Me {
2724
+ class wr extends Ae {
2543
2725
  constructor(e) {
2544
2726
  super(), this._renderer = e, e.runners.resolutionChange.add(this);
2545
2727
  }
@@ -2548,19 +2730,25 @@ class mr extends Me {
2548
2730
  e._autoResolution && e.onViewUpdate();
2549
2731
  }
2550
2732
  destroy() {
2551
- this._renderer.canvasText.returnTexture(this.texture), this._renderer = null;
2733
+ const { canvasText: e } = this._renderer;
2734
+ e.getReferenceCount(this.currentKey) > 0 ? e.decreaseReferenceCount(this.currentKey) : this.texture && e.returnTexture(this.texture), this._renderer.runners.resolutionChange.remove(this), this._renderer = null;
2552
2735
  }
2553
2736
  }
2554
- class rt {
2737
+ class at {
2555
2738
  constructor(e) {
2556
2739
  this._renderer = e;
2557
2740
  }
2558
2741
  validateRenderable(e) {
2559
- return e._didTextUpdate;
2742
+ const t = this._getGpuText(e), r = e.styleKey;
2743
+ return t.currentKey !== r ? !0 : e._didTextUpdate;
2560
2744
  }
2561
2745
  addRenderable(e, t) {
2562
2746
  const r = this._getGpuText(e);
2563
- e._didTextUpdate && (this._updateGpuText(e), e._didTextUpdate = !1), this._renderer.renderPipes.batch.addToBatch(r, t);
2747
+ if (e._didTextUpdate) {
2748
+ const i = e._autoResolution ? this._renderer.resolution : e.resolution;
2749
+ (r.currentKey !== e.styleKey || e.resolution !== i) && this._updateGpuText(e), e._didTextUpdate = !1, re(r, e);
2750
+ }
2751
+ this._renderer.renderPipes.batch.addToBatch(r, t);
2564
2752
  }
2565
2753
  updateRenderable(e) {
2566
2754
  const t = this._getGpuText(e);
@@ -2568,47 +2756,47 @@ class rt {
2568
2756
  }
2569
2757
  _updateGpuText(e) {
2570
2758
  const t = this._getGpuText(e);
2571
- t.texture && this._renderer.canvasText.returnTexture(t.texture), e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, t.texture = this._renderer.canvasText.getTexture(e), te(t, e);
2759
+ t.texture && this._renderer.canvasText.decreaseReferenceCount(t.currentKey), e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, t.texture = this._renderer.canvasText.getManagedTexture(e), t.currentKey = e.styleKey;
2572
2760
  }
2573
2761
  _getGpuText(e) {
2574
2762
  return e._gpuData[this._renderer.uid] || this.initGpuText(e);
2575
2763
  }
2576
2764
  initGpuText(e) {
2577
- const t = new mr(this._renderer);
2578
- return t.renderable = e, t.transform = e.groupTransform, t.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._gpuData[this._renderer.uid] = t, t;
2765
+ const t = new wr(this._renderer);
2766
+ return t.currentKey = "--", t.renderable = e, t.transform = e.groupTransform, t.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._gpuData[this._renderer.uid] = t, t;
2579
2767
  }
2580
2768
  destroy() {
2581
2769
  this._renderer = null;
2582
2770
  }
2583
2771
  }
2584
- rt.extension = {
2772
+ at.extension = {
2585
2773
  type: [
2586
- g.WebGLPipes,
2587
- g.WebGPUPipes,
2588
- g.CanvasPipes
2774
+ m.WebGLPipes,
2775
+ m.WebGPUPipes,
2776
+ m.CanvasPipes
2589
2777
  ],
2590
2778
  name: "text"
2591
2779
  };
2592
- class st {
2780
+ class ot {
2593
2781
  constructor(e) {
2594
- this._renderer = e;
2782
+ this._activeTextures = {}, this._renderer = e;
2595
2783
  }
2596
- getTexture(e, t, r, s) {
2784
+ getTexture(e, t, r, i) {
2597
2785
  typeof e == "string" && (w("8.0.0", "CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"), e = {
2598
2786
  text: e,
2599
2787
  style: r,
2600
2788
  resolution: t
2601
- }), e.style instanceof I || (e.style = new I(e.style)), e.textureStyle instanceof W || (e.textureStyle = new W(e.textureStyle)), typeof e.text != "string" && (e.text = e.text.toString());
2602
- const { text: i, style: n, textureStyle: a } = e, l = e.resolution ?? this._renderer.resolution, { frame: u, canvasAndContext: c } = N.getCanvasAndContext({
2603
- text: i,
2789
+ }), e.style instanceof W || (e.style = new W(e.style)), e.textureStyle instanceof I || (e.textureStyle = new I(e.textureStyle)), typeof e.text != "string" && (e.text = e.text.toString());
2790
+ const { text: s, style: n, textureStyle: a } = e, u = e.resolution ?? this._renderer.resolution, { frame: l, canvasAndContext: d } = N.getCanvasAndContext({
2791
+ text: s,
2604
2792
  style: n,
2605
- resolution: l
2606
- }), d = et(c.canvas, u.width, u.height, l);
2607
- if (a && (d.source.style = a), n.trim && (u.pad(n.padding), d.frame.copyFrom(u), d.frame.scale(1 / l), d.updateUvs()), n.filters) {
2608
- const h = this._applyFilters(d, n.filters);
2609
- return this.returnTexture(d), N.returnCanvasAndContext(c), h;
2793
+ resolution: u
2794
+ }), c = st(d.canvas, l.width, l.height, u);
2795
+ if (a && (c.source.style = a), n.trim && (l.pad(n.padding), c.frame.copyFrom(l), c.frame.scale(1 / u), c.updateUvs()), n.filters) {
2796
+ const h = this._applyFilters(c, n.filters);
2797
+ return this.returnTexture(c), N.returnCanvasAndContext(d), h;
2610
2798
  }
2611
- return this._renderer.texture.initSource(d._source), N.returnCanvasAndContext(c), d;
2799
+ return this._renderer.texture.initSource(c._source), N.returnCanvasAndContext(d), c;
2612
2800
  }
2613
2801
  /**
2614
2802
  * Returns a texture that was created wit the above `getTexture` function.
@@ -2629,6 +2817,57 @@ class st {
2629
2817
  "CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead"
2630
2818
  );
2631
2819
  }
2820
+ /**
2821
+ * Gets or creates a managed texture for a Text object. This method handles texture reuse and reference counting.
2822
+ * @param text - The Text object that needs a texture
2823
+ * @returns A Texture instance that represents the rendered text
2824
+ * @remarks
2825
+ * This method performs the following:
2826
+ * 1. Sets the appropriate resolution based on auto-resolution settings
2827
+ * 2. Checks if a texture already exists for the text's style
2828
+ * 3. Creates a new texture if needed or returns an existing one
2829
+ * 4. Manages reference counting for texture reuse
2830
+ */
2831
+ getManagedTexture(e) {
2832
+ e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution;
2833
+ const t = e.styleKey;
2834
+ if (this._activeTextures[t])
2835
+ return this._increaseReferenceCount(t), this._activeTextures[t].texture;
2836
+ const r = this.getTexture({
2837
+ text: e.text,
2838
+ style: e.style,
2839
+ resolution: e._resolution,
2840
+ textureStyle: e.textureStyle
2841
+ });
2842
+ return this._activeTextures[t] = {
2843
+ texture: r,
2844
+ usageCount: 1
2845
+ }, r;
2846
+ }
2847
+ /**
2848
+ * Decreases the reference count for a texture associated with a text key.
2849
+ * When the reference count reaches zero, the texture is returned to the pool.
2850
+ * @param textKey - The unique key identifying the text style configuration
2851
+ * @remarks
2852
+ * This method is crucial for memory management, ensuring textures are properly
2853
+ * cleaned up when they are no longer needed by any Text instances.
2854
+ */
2855
+ decreaseReferenceCount(e) {
2856
+ const t = this._activeTextures[e];
2857
+ t.usageCount--, t.usageCount === 0 && (this.returnTexture(t.texture), this._activeTextures[e] = null);
2858
+ }
2859
+ /**
2860
+ * Gets the current reference count for a texture associated with a text key.
2861
+ * @param textKey - The unique key identifying the text style configuration
2862
+ * @returns The number of Text instances currently using this texture
2863
+ */
2864
+ getReferenceCount(e) {
2865
+ var t;
2866
+ return ((t = this._activeTextures[e]) == null ? void 0 : t.usageCount) ?? 0;
2867
+ }
2868
+ _increaseReferenceCount(e) {
2869
+ this._activeTextures[e].usageCount++;
2870
+ }
2632
2871
  /**
2633
2872
  * Applies the specified filters to the given texture.
2634
2873
  *
@@ -2640,37 +2879,40 @@ class st {
2640
2879
  * @returns {Texture} The resulting texture after all filters have been applied.
2641
2880
  */
2642
2881
  _applyFilters(e, t) {
2643
- const r = this._renderer.renderTarget.renderTarget, s = this._renderer.filter.generateFilteredTexture({
2882
+ const r = this._renderer.renderTarget.renderTarget, i = this._renderer.filter.generateFilteredTexture({
2644
2883
  texture: e,
2645
2884
  filters: t
2646
2885
  });
2647
- return this._renderer.renderTarget.bind(r, !1), s;
2886
+ return this._renderer.renderTarget.bind(r, !1), i;
2648
2887
  }
2649
2888
  destroy() {
2650
2889
  this._renderer = null;
2890
+ for (const e in this._activeTextures)
2891
+ this._activeTextures[e] && this.returnTexture(this._activeTextures[e].texture);
2892
+ this._activeTextures = null;
2651
2893
  }
2652
2894
  }
2653
- st.extension = {
2895
+ ot.extension = {
2654
2896
  type: [
2655
- g.WebGLSystem,
2656
- g.WebGPUSystem,
2657
- g.CanvasSystem
2897
+ m.WebGLSystem,
2898
+ m.WebGPUSystem,
2899
+ m.CanvasSystem
2658
2900
  ],
2659
2901
  name: "canvasText"
2660
2902
  };
2661
- T.add(Re);
2662
- T.add(Ge);
2663
- T.add(Le);
2664
- T.add(yt);
2665
- T.add(Ve);
2666
- T.add(je);
2903
+ T.add(ke);
2904
+ T.add(De);
2905
+ T.add(Xe);
2906
+ T.add(wt);
2667
2907
  T.add($e);
2668
- T.add(st);
2908
+ T.add(qe);
2909
+ T.add(Qe);
2910
+ T.add(ot);
2911
+ T.add(at);
2669
2912
  T.add(rt);
2670
- T.add(Je);
2913
+ T.add(nt);
2914
+ T.add(it);
2671
2915
  T.add(tt);
2672
- T.add(Ze);
2673
- T.add(Qe);
2674
- T.add(Ke);
2675
- T.add(Oe);
2676
- T.add(De);
2916
+ T.add(et);
2917
+ T.add(Ve);
2918
+ T.add(Ee);