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.
- package/dist/{SharedSystems-CSQMnjAX.mjs → SharedSystems-Cg8IHJ_7.mjs} +255 -282
- package/dist/{WebGLRenderer-BEHsY4sC.mjs → WebGLRenderer-ZzGpXHX0.mjs} +95 -93
- package/dist/{WebGPURenderer-CCVe8UsG.mjs → WebGPURenderer-DZd11EXZ.mjs} +11 -10
- package/dist/{browserAll-C01bQ6ak.mjs → browserAll-CCzzqYhK.mjs} +73 -57
- package/dist/{colorToUniform-zJcCVLeu.mjs → colorToUniform-CSn0Emyh.mjs} +88 -34
- package/dist/{index-CyClmTrp.mjs → index-qbfgPm_j.mjs} +24363 -23959
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +16 -16
- package/dist/index.umd.js +251 -156
- package/dist/{init-kuY9xSth.mjs → init-D-ioxIiP.mjs} +974 -732
- package/dist/webworkerAll-BNKXYog5.mjs +2 -0
- package/package.json +2 -2
- package/dist/webworkerAll-BuoBp6F6.mjs +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { S as j, c as $, a as
|
|
3
|
-
class
|
|
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:
|
|
34
|
-
t =
|
|
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
|
-
|
|
48
|
-
class
|
|
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,
|
|
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 ?
|
|
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
|
-
|
|
87
|
-
class
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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 = { ...
|
|
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 =
|
|
144
|
-
const
|
|
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
|
|
147
|
-
t.overrideSize ? r._stroke && (r._stroke.width *= this.baseRenderedFontSize /
|
|
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
|
|
151
|
-
const t = D.graphemeSegmenter(e).filter((
|
|
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:
|
|
157
|
+
let { canvas: i, context: s } = r.canvasAndContext, n = r.texture.source;
|
|
158
158
|
const a = this._style;
|
|
159
|
-
let
|
|
160
|
-
const
|
|
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
|
|
163
|
-
for (let
|
|
164
|
-
const
|
|
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
|
|
167
|
-
if (f = !1,
|
|
168
|
-
` &&
|
|
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
|
|
171
|
-
|
|
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
|
|
174
|
-
if (this.chars[
|
|
175
|
-
id:
|
|
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:
|
|
178
|
+
xAdvance: ut,
|
|
179
179
|
kerning: {}
|
|
180
180
|
}, f) {
|
|
181
181
|
this._drawGlyph(
|
|
182
|
-
|
|
182
|
+
s,
|
|
183
183
|
v,
|
|
184
|
-
l + h,
|
|
185
184
|
u + h,
|
|
186
|
-
|
|
185
|
+
l + h,
|
|
186
|
+
c,
|
|
187
187
|
a
|
|
188
188
|
);
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
E /
|
|
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[
|
|
195
|
+
this.chars[p].texture = new C({
|
|
196
196
|
source: n,
|
|
197
|
-
frame:
|
|
198
|
-
}),
|
|
197
|
+
frame: lt
|
|
198
|
+
}), u += Math.ceil(M);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
n.update(), this._currentX =
|
|
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(
|
|
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
|
|
213
|
-
const
|
|
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
|
|
217
|
-
|
|
218
|
-
let
|
|
219
|
-
|
|
220
|
-
let
|
|
221
|
-
|
|
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 =
|
|
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),
|
|
234
|
-
source: new
|
|
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 && (
|
|
242
|
-
const
|
|
241
|
+
this._textureStyle && (i.source.style = this._textureStyle);
|
|
242
|
+
const s = {
|
|
243
243
|
canvasAndContext: t,
|
|
244
|
-
texture:
|
|
244
|
+
texture: i
|
|
245
245
|
};
|
|
246
|
-
return this.pages[this._currentPageIndex] =
|
|
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
|
|
252
|
-
if (
|
|
253
|
-
const n = t.dropShadow, a =
|
|
254
|
-
e.shadowColor = `rgba(${a[0] * 255},${a[1] * 255},${a[2] * 255},${n.alpha})`, e.shadowBlur =
|
|
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,
|
|
259
|
-
const a = t.text,
|
|
260
|
-
let
|
|
261
|
-
n.stroke &&
|
|
262
|
-
const { shadowBlur:
|
|
263
|
-
n._fill && (
|
|
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
|
-
|
|
269
|
+
Y.returnCanvasAndContext(t), r.destroy(!0);
|
|
270
270
|
}
|
|
271
271
|
this.pages = null;
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
|
-
|
|
274
|
+
Oe.defaultOptions = {
|
|
275
275
|
textureSize: 512,
|
|
276
|
-
style: new
|
|
276
|
+
style: new W(),
|
|
277
277
|
mipmap: !0
|
|
278
278
|
};
|
|
279
|
-
let pe =
|
|
280
|
-
function
|
|
281
|
-
const
|
|
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
|
-
|
|
295
|
-
let
|
|
296
|
-
const
|
|
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
|
-
},
|
|
304
|
-
const
|
|
305
|
-
for (let
|
|
306
|
-
const v =
|
|
307
|
-
|
|
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
|
-
|
|
310
|
-
},
|
|
311
|
-
let
|
|
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
|
|
314
|
-
for (;
|
|
315
|
-
|
|
313
|
+
let g = s.chars[x];
|
|
314
|
+
for (; g === " "; )
|
|
315
|
+
s.width -= t.chars[g].xAdvance, g = s.chars[--x];
|
|
316
316
|
}
|
|
317
|
-
|
|
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,
|
|
324
|
-
},
|
|
325
|
-
for (let
|
|
326
|
-
let
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
const v = t.chars[
|
|
330
|
-
if (/(?:\s)/.test(
|
|
331
|
-
` ||
|
|
332
|
-
if (!a && e.wordWrap &&
|
|
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
|
-
|
|
335
|
-
else if (!
|
|
336
|
-
const
|
|
337
|
-
|
|
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,
|
|
341
|
-
f &&
|
|
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
|
|
345
|
+
return _(), e.align === "center" ? Bt(i) : e.align === "right" ? Rt(i) : e.align === "justify" && Mt(i), i;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
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
|
|
351
|
-
t.charPositions[
|
|
350
|
+
for (let i = 0; i < t.charPositions.length; i++)
|
|
351
|
+
t.charPositions[i] += r;
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
function
|
|
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
|
|
358
|
-
t.charPositions[
|
|
357
|
+
for (let i = 0; i < t.charPositions.length; i++)
|
|
358
|
+
t.charPositions[i] += r;
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
function
|
|
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
|
|
366
|
-
const a = r.spacesIndex.length,
|
|
367
|
-
for (let
|
|
368
|
-
|
|
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
|
|
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
|
|
378
|
-
if (Array.isArray(
|
|
379
|
-
if (
|
|
380
|
-
throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${
|
|
381
|
-
if (
|
|
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
|
|
384
|
-
if (n <
|
|
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 =
|
|
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(
|
|
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
|
|
396
|
-
class
|
|
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`,
|
|
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
|
|
417
|
+
const u = new pe({
|
|
424
418
|
style: a,
|
|
425
|
-
overrideFill:
|
|
419
|
+
overrideFill: i,
|
|
426
420
|
overrideSize: !0,
|
|
427
421
|
...this.defaultOptions
|
|
428
422
|
});
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}),
|
|
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
|
-
|
|
427
|
+
u
|
|
434
428
|
);
|
|
435
429
|
}
|
|
436
|
-
const
|
|
437
|
-
return (n =
|
|
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
|
|
447
|
-
|
|
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
|
|
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: (
|
|
466
|
-
resolution: (
|
|
467
|
-
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(
|
|
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
|
|
475
|
-
style:
|
|
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
|
-
}),
|
|
483
|
-
return a.ensureCharacters(
|
|
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 =
|
|
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
|
|
505
|
-
|
|
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
|
-
|
|
629
|
+
Ee.extension = {
|
|
533
630
|
type: [
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
631
|
+
m.WebGLPipes,
|
|
632
|
+
m.WebGPUPipes,
|
|
633
|
+
m.CanvasPipes
|
|
537
634
|
],
|
|
538
635
|
name: "filter"
|
|
539
636
|
};
|
|
540
|
-
|
|
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
|
|
545
|
-
|
|
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
|
|
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
|
|
661
|
+
class Wt {
|
|
561
662
|
constructor() {
|
|
562
|
-
this.skip = !1, this.inputTexture = null, this.backTexture = null, this.filters = null, this.bounds = new
|
|
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
|
|
666
|
+
class Ve {
|
|
566
667
|
constructor(e) {
|
|
567
|
-
this._filterStackIndex = 0, this._filterStack = [], this._filterGlobalUniforms = new
|
|
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
|
|
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,
|
|
591
|
-
|
|
592
|
-
const
|
|
593
|
-
if (r.
|
|
594
|
-
|
|
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
|
|
598
|
-
if (this._calculateFilterArea(e,
|
|
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
|
|
601
|
-
let
|
|
602
|
-
|
|
603
|
-
|
|
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
|
-
|
|
608
|
-
|
|
609
|
-
|
|
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
|
|
642
|
-
if (t.
|
|
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,
|
|
746
|
+
if (a.addRect(e.frame), this._calculateFilterBounds(r, a.rectangle, n, s, 0), r.skip)
|
|
646
747
|
return e;
|
|
647
|
-
const
|
|
748
|
+
const u = s;
|
|
648
749
|
this._calculateGlobalFrame(
|
|
649
750
|
r,
|
|
650
751
|
0,
|
|
651
752
|
0,
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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 =
|
|
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
|
|
777
|
+
const i = e.colorTexture.source._resolution, s = F.getOptimalTexture(
|
|
677
778
|
t.width,
|
|
678
779
|
t.height,
|
|
679
|
-
|
|
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 *
|
|
684
|
-
const
|
|
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
|
-
|
|
788
|
+
s,
|
|
688
789
|
{ x: n, y: a },
|
|
689
|
-
{ width:
|
|
790
|
+
{ width: u, height: l },
|
|
690
791
|
{ x: 0, y: 0 }
|
|
691
|
-
),
|
|
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,
|
|
701
|
-
const
|
|
702
|
-
let
|
|
703
|
-
if (
|
|
704
|
-
const
|
|
705
|
-
|
|
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,
|
|
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,
|
|
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
|
-
),
|
|
726
|
-
return n && n.cacheToLocalTransform &&
|
|
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
|
-
),
|
|
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
|
|
742
|
-
this._globalFilterBindGroup.setResource(
|
|
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:
|
|
854
|
+
geometry: It,
|
|
747
855
|
shader: e,
|
|
748
856
|
state: e._state,
|
|
749
857
|
topology: "triangle-list"
|
|
750
|
-
}), r.type ===
|
|
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,
|
|
760
|
-
if (e.backTexture =
|
|
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
|
-
),
|
|
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,
|
|
891
|
+
_calculateGlobalFrame(e, t, r, i, s, n) {
|
|
784
892
|
const a = e.globalFrame;
|
|
785
|
-
a.x = t *
|
|
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,
|
|
799
|
-
const
|
|
800
|
-
a ? (
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
const
|
|
804
|
-
this.renderer.renderTarget.bind(t, !!
|
|
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
|
|
826
|
-
if (!
|
|
827
|
-
e =
|
|
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 ?
|
|
840
|
-
const
|
|
841
|
-
|
|
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,
|
|
846
|
-
if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(e.backTexture.source, 3),
|
|
847
|
-
|
|
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
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
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
|
|
857
|
-
for (
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
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
|
-
|
|
973
|
+
s[a].apply(this, u, e.outputRenderSurface, t), F.returnTexture(l);
|
|
863
974
|
}
|
|
864
975
|
}
|
|
865
|
-
_calculateFilterBounds(e, t, r,
|
|
866
|
-
var
|
|
867
|
-
const n = this.renderer, a = e.bounds,
|
|
868
|
-
let
|
|
869
|
-
for (let
|
|
870
|
-
const p =
|
|
871
|
-
if (
|
|
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 && !(((
|
|
876
|
-
|
|
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 =
|
|
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 (
|
|
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 =
|
|
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 >
|
|
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
|
|
1015
|
+
return e || (e = this._filterStack[this._filterStackIndex] = new Wt()), this._filterStackIndex++, e;
|
|
903
1016
|
}
|
|
904
1017
|
}
|
|
905
|
-
|
|
1018
|
+
Ve.extension = {
|
|
906
1019
|
type: [
|
|
907
|
-
|
|
908
|
-
|
|
1020
|
+
m.WebGLSystem,
|
|
1021
|
+
m.WebGPUSystem
|
|
909
1022
|
],
|
|
910
1023
|
name: "filter"
|
|
911
1024
|
};
|
|
912
|
-
const
|
|
1025
|
+
const Le = class He extends ie {
|
|
913
1026
|
constructor(...e) {
|
|
914
1027
|
let t = e[0] ?? {};
|
|
915
|
-
t instanceof Float32Array && (w(
|
|
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 = { ...
|
|
1032
|
+
}), t = { ...He.defaultOptions, ...t };
|
|
920
1033
|
const r = t.positions || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
|
|
921
|
-
let
|
|
922
|
-
|
|
923
|
-
const
|
|
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
|
-
}),
|
|
929
|
-
data:
|
|
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
|
-
}),
|
|
934
|
-
data:
|
|
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:
|
|
1061
|
+
buffer: u,
|
|
949
1062
|
format: "float32x2",
|
|
950
1063
|
stride: 2 * 4,
|
|
951
1064
|
offset: 0
|
|
952
1065
|
}
|
|
953
1066
|
},
|
|
954
|
-
indexBuffer:
|
|
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
|
-
|
|
1105
|
+
Le.defaultOptions = {
|
|
993
1106
|
topology: "triangle-list",
|
|
994
1107
|
shrinkBuffersToFit: !1
|
|
995
1108
|
};
|
|
996
|
-
let
|
|
997
|
-
const
|
|
998
|
-
class
|
|
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(
|
|
1001
|
-
const { foreignObject: e, svgRoot: t, styleElement: r, domElement:
|
|
1002
|
-
e.setAttribute("width", "10000"), e.setAttribute("height", "10000"), e.style.overflow = "hidden", t.appendChild(e), e.appendChild(r), e.appendChild(
|
|
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
|
|
1006
|
-
function
|
|
1007
|
-
r || (r =
|
|
1008
|
-
const { domElement:
|
|
1009
|
-
|
|
1010
|
-
const a =
|
|
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
|
|
1128
|
+
const u = e.padding * 2;
|
|
1013
1129
|
return {
|
|
1014
|
-
width: a.width -
|
|
1015
|
-
height: a.height -
|
|
1130
|
+
width: a.width - u,
|
|
1131
|
+
height: a.height - u
|
|
1016
1132
|
};
|
|
1017
1133
|
}
|
|
1018
|
-
class
|
|
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
|
-
|
|
1140
|
+
K.return(e);
|
|
1025
1141
|
}), this.batches.length = 0;
|
|
1026
1142
|
}
|
|
1027
1143
|
}
|
|
1028
|
-
class
|
|
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,
|
|
1037
|
-
return !!(
|
|
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
|
|
1046
|
-
const
|
|
1047
|
-
|
|
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
|
|
1172
|
+
const s = r.customShader || this._adaptor.shader;
|
|
1057
1173
|
this.state.blendMode = e.groupBlendMode;
|
|
1058
|
-
const n =
|
|
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,
|
|
1071
|
-
for (let
|
|
1072
|
-
const n = s
|
|
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
|
|
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,
|
|
1085
|
-
t.batches =
|
|
1086
|
-
const a =
|
|
1087
|
-
return n.copyTo(a), a.renderable = e, a.roundPixels =
|
|
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
|
-
|
|
1210
|
+
Xe.extension = {
|
|
1095
1211
|
type: [
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1212
|
+
m.WebGLPipes,
|
|
1213
|
+
m.WebGPUPipes,
|
|
1214
|
+
m.CanvasPipes
|
|
1099
1215
|
],
|
|
1100
1216
|
name: "graphics"
|
|
1101
1217
|
};
|
|
1102
|
-
const
|
|
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(
|
|
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 = { ...
|
|
1119
|
-
const t = this.verticesX * this.verticesY, r = [],
|
|
1120
|
-
for (let
|
|
1121
|
-
const h =
|
|
1122
|
-
r.push(h *
|
|
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
|
|
1125
|
-
for (let
|
|
1126
|
-
const h =
|
|
1127
|
-
|
|
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
|
-
|
|
1247
|
+
_,
|
|
1130
1248
|
x,
|
|
1131
|
-
|
|
1132
|
-
p,
|
|
1133
|
-
x
|
|
1249
|
+
b
|
|
1134
1250
|
);
|
|
1135
1251
|
}
|
|
1136
|
-
this.buffers[0].data = new Float32Array(r), this.buffers[1].data = new Float32Array(
|
|
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
|
-
|
|
1255
|
+
Ke.defaultOptions = {
|
|
1140
1256
|
width: 100,
|
|
1141
1257
|
height: 100,
|
|
1142
1258
|
verticesX: 10,
|
|
1143
1259
|
verticesY: 10
|
|
1144
1260
|
};
|
|
1145
|
-
let
|
|
1146
|
-
class
|
|
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
|
|
1174
|
-
const
|
|
1175
|
-
return
|
|
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
|
|
1312
|
+
class be {
|
|
1197
1313
|
destroy() {
|
|
1198
1314
|
}
|
|
1199
1315
|
}
|
|
1200
|
-
class
|
|
1316
|
+
class $e {
|
|
1201
1317
|
constructor(e, t) {
|
|
1202
|
-
this.localUniforms = new
|
|
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
|
|
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,
|
|
1212
|
-
if (t.batched =
|
|
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 (
|
|
1215
|
-
const
|
|
1216
|
-
if (
|
|
1217
|
-
return t.indexSize =
|
|
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
|
|
1228
|
-
const r = this.renderer.renderPipes.batch,
|
|
1229
|
-
if (e.didViewUpdate && (
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
1391
|
+
$e.extension = {
|
|
1276
1392
|
type: [
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1393
|
+
m.WebGLPipes,
|
|
1394
|
+
m.WebGPUPipes,
|
|
1395
|
+
m.CanvasPipes
|
|
1280
1396
|
],
|
|
1281
1397
|
name: "mesh"
|
|
1282
1398
|
};
|
|
1283
|
-
class
|
|
1399
|
+
class Ht {
|
|
1284
1400
|
execute(e, t) {
|
|
1285
|
-
const r = e.state,
|
|
1286
|
-
|
|
1287
|
-
const n =
|
|
1288
|
-
|
|
1289
|
-
const
|
|
1290
|
-
n.drawElements(n.TRIANGLES, t.particleChildren.length * 6,
|
|
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
|
|
1409
|
+
class Yt {
|
|
1294
1410
|
execute(e, t) {
|
|
1295
|
-
const r = e.renderer,
|
|
1296
|
-
|
|
1297
|
-
const
|
|
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:
|
|
1417
|
+
state: s,
|
|
1302
1418
|
size: t.particleChildren.length * 6
|
|
1303
1419
|
});
|
|
1304
1420
|
}
|
|
1305
1421
|
}
|
|
1306
|
-
function
|
|
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,
|
|
1311
|
-
e[r + 0] =
|
|
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
|
|
1430
|
+
function Xt(o) {
|
|
1315
1431
|
return {
|
|
1316
|
-
dynamicUpdate:
|
|
1317
|
-
staticUpdate:
|
|
1432
|
+
dynamicUpdate: Te(o, !0),
|
|
1433
|
+
staticUpdate: Te(o, !1)
|
|
1318
1434
|
};
|
|
1319
1435
|
}
|
|
1320
|
-
function
|
|
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
|
|
1333
|
-
const n = o[
|
|
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 =
|
|
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
|
|
1462
|
+
const i = t.join(`
|
|
1347
1463
|
`);
|
|
1348
|
-
return new Function("ps", "f32v", "u32v",
|
|
1464
|
+
return new Function("ps", "f32v", "u32v", i);
|
|
1349
1465
|
}
|
|
1350
|
-
class
|
|
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
|
|
1355
|
-
for (const
|
|
1356
|
-
const
|
|
1357
|
-
|
|
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 =
|
|
1360
|
-
const n = new
|
|
1361
|
-
let a = 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
|
|
1374
|
-
const
|
|
1375
|
-
|
|
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:
|
|
1380
|
-
}), a += h.size) : (n.addAttribute(
|
|
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:
|
|
1384
|
-
format:
|
|
1385
|
-
}),
|
|
1499
|
+
offset: u * 4,
|
|
1500
|
+
format: c.format
|
|
1501
|
+
}), u += h.size);
|
|
1386
1502
|
}
|
|
1387
1503
|
n.addIndex(this.indexBuffer);
|
|
1388
|
-
const
|
|
1389
|
-
this._dynamicUpload =
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
1411
|
-
this._staticUpload(e,
|
|
1412
|
-
|
|
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
|
|
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
|
|
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
|
-
}`,
|
|
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
|
-
`,
|
|
1593
|
+
`, we = `
|
|
1478
1594
|
struct ParticleUniforms {
|
|
1479
|
-
|
|
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
|
-
|
|
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
|
|
1656
|
+
class qt extends oe {
|
|
1532
1657
|
constructor() {
|
|
1533
|
-
const e =
|
|
1534
|
-
vertex:
|
|
1535
|
-
fragment:
|
|
1536
|
-
}), t =
|
|
1658
|
+
const e = Fe.from({
|
|
1659
|
+
vertex: Nt,
|
|
1660
|
+
fragment: $t
|
|
1661
|
+
}), t = Pe.from({
|
|
1537
1662
|
fragment: {
|
|
1538
|
-
source:
|
|
1663
|
+
source: we,
|
|
1539
1664
|
entryPoint: "mainFragment"
|
|
1540
1665
|
},
|
|
1541
1666
|
vertex: {
|
|
1542
|
-
source:
|
|
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:
|
|
1676
|
+
uTexture: C.WHITE.source,
|
|
1552
1677
|
// this will be replaced with the texture style from the particle container
|
|
1553
|
-
uSampler: new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
1724
|
+
const r = this.renderer, i = this.getBuffers(e);
|
|
1600
1725
|
e.texture || (e.texture = t[0].texture);
|
|
1601
|
-
const
|
|
1602
|
-
|
|
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
|
|
1740
|
+
class qe extends Ne {
|
|
1616
1741
|
constructor(e) {
|
|
1617
|
-
super(e, new
|
|
1742
|
+
super(e, new Ht());
|
|
1618
1743
|
}
|
|
1619
1744
|
}
|
|
1620
|
-
|
|
1745
|
+
qe.extension = {
|
|
1621
1746
|
type: [
|
|
1622
|
-
|
|
1747
|
+
m.WebGLPipes
|
|
1623
1748
|
],
|
|
1624
1749
|
name: "particle"
|
|
1625
1750
|
};
|
|
1626
|
-
class
|
|
1751
|
+
class Qe extends Ne {
|
|
1627
1752
|
constructor(e) {
|
|
1628
|
-
super(e, new
|
|
1753
|
+
super(e, new Yt());
|
|
1629
1754
|
}
|
|
1630
1755
|
}
|
|
1631
|
-
|
|
1756
|
+
Qe.extension = {
|
|
1632
1757
|
type: [
|
|
1633
|
-
|
|
1758
|
+
m.WebGPUPipes
|
|
1634
1759
|
],
|
|
1635
1760
|
name: "particle"
|
|
1636
1761
|
};
|
|
1637
|
-
const
|
|
1762
|
+
const Je = class Ze extends Lt {
|
|
1638
1763
|
constructor(e = {}) {
|
|
1639
|
-
e = { ...
|
|
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:
|
|
1660
|
-
_rightWidth:
|
|
1784
|
+
_leftWidth: i,
|
|
1785
|
+
_rightWidth: s,
|
|
1661
1786
|
_topHeight: n,
|
|
1662
1787
|
_bottomHeight: a,
|
|
1663
|
-
_anchorX:
|
|
1664
|
-
_anchorY:
|
|
1665
|
-
} = this,
|
|
1666
|
-
e[0] = e[8] = e[16] = e[24] = -
|
|
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
|
-
|
|
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
|
|
1695
|
-
class
|
|
1819
|
+
let Qt = Je;
|
|
1820
|
+
class Jt extends le {
|
|
1696
1821
|
constructor() {
|
|
1697
|
-
super(), this.geometry = new
|
|
1822
|
+
super(), this.geometry = new Qt();
|
|
1698
1823
|
}
|
|
1699
1824
|
destroy() {
|
|
1700
1825
|
this.geometry.destroy();
|
|
1701
1826
|
}
|
|
1702
1827
|
}
|
|
1703
|
-
class
|
|
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
|
|
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
|
-
|
|
1861
|
+
et.extension = {
|
|
1737
1862
|
type: [
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1863
|
+
m.WebGLPipes,
|
|
1864
|
+
m.WebGPUPipes,
|
|
1865
|
+
m.CanvasPipes
|
|
1741
1866
|
],
|
|
1742
1867
|
name: "nineSliceSprite"
|
|
1743
1868
|
};
|
|
1744
|
-
const
|
|
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
|
-
},
|
|
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,
|
|
1855
|
-
class
|
|
1979
|
+
let q, Q;
|
|
1980
|
+
class tr extends oe {
|
|
1856
1981
|
constructor() {
|
|
1857
|
-
q ?? (q =
|
|
1982
|
+
q ?? (q = Me({
|
|
1858
1983
|
name: "tiling-sprite-shader",
|
|
1859
1984
|
bits: [
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1985
|
+
St,
|
|
1986
|
+
Zt,
|
|
1987
|
+
Ue
|
|
1863
1988
|
]
|
|
1864
|
-
})),
|
|
1989
|
+
})), Q ?? (Q = Ge({
|
|
1865
1990
|
name: "tiling-sprite-shader",
|
|
1866
1991
|
bits: [
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1992
|
+
Pt,
|
|
1993
|
+
er,
|
|
1994
|
+
ze
|
|
1870
1995
|
]
|
|
1871
1996
|
}));
|
|
1872
|
-
const e = new
|
|
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:
|
|
2005
|
+
glProgram: Q,
|
|
1881
2006
|
gpuProgram: q,
|
|
1882
2007
|
resources: {
|
|
1883
|
-
localUniforms: new
|
|
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:
|
|
1890
|
-
uSampler:
|
|
2014
|
+
uTexture: C.EMPTY.source,
|
|
2015
|
+
uSampler: C.EMPTY.source.style
|
|
1891
2016
|
}
|
|
1892
2017
|
});
|
|
1893
2018
|
}
|
|
1894
|
-
updateUniforms(e, t, r,
|
|
1895
|
-
const a = this.resources.tilingUniforms,
|
|
1896
|
-
|
|
1897
|
-
r.a *
|
|
1898
|
-
r.b *
|
|
1899
|
-
r.c *
|
|
1900
|
-
r.d *
|
|
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
|
-
),
|
|
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
|
|
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
|
|
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
|
|
1920
|
-
let
|
|
1921
|
-
const
|
|
1922
|
-
for (t *= e;
|
|
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 +
|
|
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
|
|
1928
|
-
const t = o.texture, r = t.frame.width,
|
|
1929
|
-
let
|
|
1930
|
-
o.applyAnchorToTexture && (
|
|
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 /
|
|
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
|
|
1935
|
-
class
|
|
2059
|
+
const H = new rr();
|
|
2060
|
+
class ar {
|
|
1936
2061
|
constructor() {
|
|
1937
|
-
this.canBatch = !0, this.geometry = new
|
|
1938
|
-
indices:
|
|
1939
|
-
positions:
|
|
1940
|
-
uvs:
|
|
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
|
|
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
|
|
1956
|
-
if (
|
|
1957
|
-
const { batchableMesh:
|
|
1958
|
-
return !
|
|
1959
|
-
|
|
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 !==
|
|
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
|
|
2093
|
+
const i = this._getTilingSpriteData(e), { geometry: s, canBatch: n } = i;
|
|
1969
2094
|
if (n) {
|
|
1970
|
-
|
|
1971
|
-
const a =
|
|
1972
|
-
e.didViewUpdate && (this._updateBatchableMesh(e), a.geometry =
|
|
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),
|
|
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:
|
|
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:
|
|
1994
|
-
e.didViewUpdate && this._updateBatchableMesh(e),
|
|
2118
|
+
const { batchableMesh: i } = t;
|
|
2119
|
+
e.didViewUpdate && this._updateBatchableMesh(e), i._batcher.updateElement(i);
|
|
1995
2120
|
} else if (e.didViewUpdate) {
|
|
1996
|
-
const { shader:
|
|
1997
|
-
|
|
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
|
|
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,
|
|
2016
|
-
|
|
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
|
|
2024
|
-
return this._renderer.type ===
|
|
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
|
-
|
|
2152
|
+
tt.extension = {
|
|
2028
2153
|
type: [
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2154
|
+
m.WebGLPipes,
|
|
2155
|
+
m.WebGPUPipes,
|
|
2156
|
+
m.CanvasPipes
|
|
2032
2157
|
],
|
|
2033
2158
|
name: "tilingSprite"
|
|
2034
2159
|
};
|
|
2035
|
-
const
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
|
2202
|
-
class
|
|
2326
|
+
let J, Z;
|
|
2327
|
+
class dr extends oe {
|
|
2203
2328
|
constructor(e) {
|
|
2204
|
-
const t = new
|
|
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
|
-
|
|
2335
|
+
J ?? (J = Me({
|
|
2211
2336
|
name: "sdf-shader",
|
|
2212
2337
|
bits: [
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2338
|
+
mt,
|
|
2339
|
+
xt(e),
|
|
2340
|
+
or,
|
|
2341
|
+
lr,
|
|
2342
|
+
Ue
|
|
2218
2343
|
]
|
|
2219
|
-
})),
|
|
2344
|
+
})), Z ?? (Z = Ge({
|
|
2220
2345
|
name: "sdf-shader",
|
|
2221
2346
|
bits: [
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2347
|
+
_t,
|
|
2348
|
+
yt(e),
|
|
2349
|
+
ur,
|
|
2350
|
+
cr,
|
|
2351
|
+
ze
|
|
2227
2352
|
]
|
|
2228
2353
|
})), super({
|
|
2229
|
-
glProgram:
|
|
2230
|
-
gpuProgram:
|
|
2354
|
+
glProgram: Z,
|
|
2355
|
+
gpuProgram: J,
|
|
2231
2356
|
resources: {
|
|
2232
2357
|
localUniforms: t,
|
|
2233
|
-
batchSamplers:
|
|
2358
|
+
batchSamplers: bt(e)
|
|
2234
2359
|
}
|
|
2235
2360
|
});
|
|
2236
2361
|
}
|
|
2237
2362
|
}
|
|
2238
|
-
class
|
|
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
|
|
2368
|
+
class rt {
|
|
2244
2369
|
constructor(e) {
|
|
2245
|
-
this._renderer = e
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
2261
|
-
r.clear(),
|
|
2262
|
-
const
|
|
2263
|
-
let a =
|
|
2264
|
-
const
|
|
2265
|
-
let
|
|
2266
|
-
n._stroke && (
|
|
2267
|
-
const f =
|
|
2268
|
-
let
|
|
2269
|
-
n.lineHeight && (
|
|
2270
|
-
let
|
|
2271
|
-
|
|
2272
|
-
for (let
|
|
2273
|
-
const
|
|
2274
|
-
for (let
|
|
2275
|
-
const v =
|
|
2276
|
-
if (
|
|
2277
|
-
const G =
|
|
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(
|
|
2282
|
-
Math.round(a +
|
|
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 +=
|
|
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
|
|
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,
|
|
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
|
-
|
|
2431
|
+
rt.extension = {
|
|
2307
2432
|
type: [
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2433
|
+
m.WebGLPipes,
|
|
2434
|
+
m.WebGPUPipes,
|
|
2435
|
+
m.CanvasPipes
|
|
2311
2436
|
],
|
|
2312
2437
|
name: "bitmapText"
|
|
2313
2438
|
};
|
|
2314
|
-
function
|
|
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
|
|
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
|
-
|
|
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
|
|
2336
|
-
const { texture: t, bounds: r } = o,
|
|
2337
|
-
|
|
2338
|
-
const
|
|
2339
|
-
r.minX -=
|
|
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
|
|
2467
|
+
class it {
|
|
2342
2468
|
constructor(e) {
|
|
2343
2469
|
this._renderer = e;
|
|
2344
2470
|
}
|
|
2345
2471
|
validateRenderable(e) {
|
|
2346
|
-
|
|
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
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
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
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
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,
|
|
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
|
|
2374
|
-
return t.renderable = e, t.transform = e.groupTransform, t.texture =
|
|
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
|
-
|
|
2514
|
+
it.extension = {
|
|
2381
2515
|
type: [
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2516
|
+
m.WebGLPipes,
|
|
2517
|
+
m.WebGPUPipes,
|
|
2518
|
+
m.CanvasPipes
|
|
2385
2519
|
],
|
|
2386
2520
|
name: "htmlText"
|
|
2387
2521
|
};
|
|
2388
|
-
function
|
|
2522
|
+
function pr() {
|
|
2389
2523
|
const { userAgent: o } = ne.get().getNavigator();
|
|
2390
2524
|
return /^((?!chrome|android).)*safari/i.test(o);
|
|
2391
2525
|
}
|
|
2392
|
-
const
|
|
2393
|
-
function
|
|
2394
|
-
const
|
|
2395
|
-
|
|
2396
|
-
const
|
|
2397
|
-
|
|
2398
|
-
|
|
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
|
|
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
|
|
2405
|
-
const t = e.fontFamily, r = [],
|
|
2406
|
-
function a(
|
|
2407
|
-
|
|
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
|
|
2411
|
-
a(t[
|
|
2544
|
+
for (let u = 0; u < t.length; u++)
|
|
2545
|
+
a(t[u]);
|
|
2412
2546
|
else
|
|
2413
2547
|
a(t);
|
|
2414
|
-
n && n.forEach((
|
|
2415
|
-
const
|
|
2416
|
-
a(
|
|
2548
|
+
n && n.forEach((u) => {
|
|
2549
|
+
const l = u.split(":")[1].trim();
|
|
2550
|
+
a(l);
|
|
2417
2551
|
});
|
|
2418
|
-
for (const
|
|
2419
|
-
const
|
|
2420
|
-
a(
|
|
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
|
|
2558
|
+
async function xr(o) {
|
|
2425
2559
|
const t = await (await ne.get().fetch(o)).blob(), r = new FileReader();
|
|
2426
|
-
return await new Promise((
|
|
2427
|
-
r.onloadend = () =>
|
|
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
|
|
2431
|
-
const t = await
|
|
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
|
|
2440
|
-
async function
|
|
2441
|
-
const e = o.filter((t) =>
|
|
2442
|
-
if (!
|
|
2443
|
-
const { entries: r } =
|
|
2444
|
-
r.forEach((
|
|
2445
|
-
const n =
|
|
2446
|
-
|
|
2447
|
-
...
|
|
2448
|
-
(
|
|
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:
|
|
2451
|
-
fontStyle:
|
|
2584
|
+
fontWeight: l.weight,
|
|
2585
|
+
fontStyle: l.style,
|
|
2452
2586
|
fontFamily: t
|
|
2453
2587
|
},
|
|
2454
2588
|
n
|
|
2455
2589
|
)
|
|
2456
2590
|
)
|
|
2457
2591
|
);
|
|
2458
|
-
}),
|
|
2592
|
+
}), ee.set(
|
|
2459
2593
|
t,
|
|
2460
|
-
Promise.all(
|
|
2594
|
+
Promise.all(i).then((s) => s.join(`
|
|
2461
2595
|
`))
|
|
2462
2596
|
);
|
|
2463
2597
|
}
|
|
2464
|
-
return
|
|
2598
|
+
return ee.get(t);
|
|
2465
2599
|
});
|
|
2466
2600
|
return (await Promise.all(e)).join(`
|
|
2467
2601
|
`);
|
|
2468
2602
|
}
|
|
2469
|
-
function
|
|
2470
|
-
const { domElement:
|
|
2471
|
-
|
|
2472
|
-
const { width:
|
|
2473
|
-
return a.setAttribute("width",
|
|
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
|
|
2476
|
-
const t =
|
|
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
|
|
2617
|
+
function Tr(o, e, t) {
|
|
2484
2618
|
return new Promise(async (r) => {
|
|
2485
|
-
t && await new Promise((
|
|
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
|
|
2624
|
+
class nt {
|
|
2491
2625
|
constructor(e) {
|
|
2492
|
-
this._renderer = e, this._createCanvas = e.type ===
|
|
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:
|
|
2506
|
-
h.width = (
|
|
2507
|
-
const
|
|
2508
|
-
await
|
|
2509
|
-
const
|
|
2510
|
-
let
|
|
2511
|
-
this._createCanvas && (
|
|
2512
|
-
const
|
|
2513
|
-
|
|
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
|
-
|
|
2695
|
+
i
|
|
2517
2696
|
);
|
|
2518
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
2716
|
+
nt.extension = {
|
|
2535
2717
|
type: [
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2718
|
+
m.WebGLSystem,
|
|
2719
|
+
m.WebGPUSystem,
|
|
2720
|
+
m.CanvasSystem
|
|
2539
2721
|
],
|
|
2540
2722
|
name: "htmlText"
|
|
2541
2723
|
};
|
|
2542
|
-
class
|
|
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
|
-
|
|
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
|
|
2737
|
+
class at {
|
|
2555
2738
|
constructor(e) {
|
|
2556
2739
|
this._renderer = e;
|
|
2557
2740
|
}
|
|
2558
2741
|
validateRenderable(e) {
|
|
2559
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
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
|
-
|
|
2772
|
+
at.extension = {
|
|
2585
2773
|
type: [
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2774
|
+
m.WebGLPipes,
|
|
2775
|
+
m.WebGPUPipes,
|
|
2776
|
+
m.CanvasPipes
|
|
2589
2777
|
],
|
|
2590
2778
|
name: "text"
|
|
2591
2779
|
};
|
|
2592
|
-
class
|
|
2780
|
+
class ot {
|
|
2593
2781
|
constructor(e) {
|
|
2594
|
-
this._renderer = e;
|
|
2782
|
+
this._activeTextures = {}, this._renderer = e;
|
|
2595
2783
|
}
|
|
2596
|
-
getTexture(e, t, r,
|
|
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
|
|
2602
|
-
const { text:
|
|
2603
|
-
text:
|
|
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:
|
|
2606
|
-
}),
|
|
2607
|
-
if (a && (
|
|
2608
|
-
const h = this._applyFilters(
|
|
2609
|
-
return this.returnTexture(
|
|
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(
|
|
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,
|
|
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),
|
|
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
|
-
|
|
2895
|
+
ot.extension = {
|
|
2654
2896
|
type: [
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2897
|
+
m.WebGLSystem,
|
|
2898
|
+
m.WebGPUSystem,
|
|
2899
|
+
m.CanvasSystem
|
|
2658
2900
|
],
|
|
2659
2901
|
name: "canvasText"
|
|
2660
2902
|
};
|
|
2661
|
-
T.add(
|
|
2662
|
-
T.add(
|
|
2663
|
-
T.add(
|
|
2664
|
-
T.add(
|
|
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(
|
|
2908
|
+
T.add(qe);
|
|
2909
|
+
T.add(Qe);
|
|
2910
|
+
T.add(ot);
|
|
2911
|
+
T.add(at);
|
|
2669
2912
|
T.add(rt);
|
|
2670
|
-
T.add(
|
|
2913
|
+
T.add(nt);
|
|
2914
|
+
T.add(it);
|
|
2671
2915
|
T.add(tt);
|
|
2672
|
-
T.add(
|
|
2673
|
-
T.add(
|
|
2674
|
-
T.add(
|
|
2675
|
-
T.add(Oe);
|
|
2676
|
-
T.add(De);
|
|
2916
|
+
T.add(et);
|
|
2917
|
+
T.add(Ve);
|
|
2918
|
+
T.add(Ee);
|