openvideo 0.0.4 → 0.1.0
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-CbOvgzCC.js → SharedSystems-BukQJH1h.js} +1 -1
- package/dist/{WebGLRenderer-BytNn1OJ.js → WebGLRenderer-BuRbEm0g.js} +2 -2
- package/dist/{WebGPURenderer-BAGe_F9Z.js → WebGPURenderer-CTm7Kg4-.js} +2 -2
- package/dist/animation/easings.d.ts +3 -0
- package/dist/animation/gsap-animation.d.ts +29 -0
- package/dist/animation/index.d.ts +5 -0
- package/dist/animation/keyframe-animation.d.ts +11 -0
- package/dist/animation/presets.d.ts +34 -0
- package/dist/animation/registry.d.ts +11 -0
- package/dist/animation/types.d.ts +118 -0
- package/dist/{browserAll-D2WDRHjP.js → browserAll-NQ4Ztn0h.js} +2 -2
- package/dist/clips/base-clip.d.ts +2 -2
- package/dist/clips/caption-clip.d.ts +42 -41
- package/dist/clips/iclip.d.ts +19 -0
- package/dist/clips/placeholder-clip.d.ts +4 -0
- package/dist/clips/text-clip.d.ts +38 -17
- package/dist/{index-BdiiyukT.js → index-C7b-H3n2.js} +9660 -5456
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +28 -22
- package/dist/index.umd.js +348 -176
- package/dist/json-serialization.d.ts +5 -0
- package/dist/sprite/base-sprite.d.ts +36 -4
- package/dist/sprite/pixi-sprite-renderer.d.ts +3 -0
- package/dist/studio.d.ts +16 -16
- package/dist/{webworkerAll-BuYW7nlg.js → webworkerAll-B_y2Hkt4.js} +241 -268
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as p, U as dt, T as ce, F as ht, G as Fe, v as Re, M as P, l as M, d as Ue, I as w, t as R, a8 as te, R as re, w as N, H as Be, a5 as O, a6 as Me, c as D, B as C, D as W,
|
|
2
|
-
import { c as L, a as
|
|
1
|
+
import { E as p, U as dt, T as ce, F as ht, G as Fe, v as Re, af as ft, M as P, l as M, d as Ue, I as w, t as R, a8 as te, R as re, w as N, H as Be, a5 as O, a6 as Me, c as D, B as C, D as W, ag as de, V as q, ah as B, m as I, ai as pt, a0 as Ge, aj as he, S as E, y as V, ak as mt, al as ne, L as Q, am as k, s as se, $ as J, n as De, q as Ae, aa as ke, ad as ze, o as gt, p as xt, ab as _t, ac as bt, ae as vt, an as yt, ao as Tt, ap as Z, aq as wt, ar as Ct, as as fe, e as y, at as Pt } from "./index-C7b-H3n2.js";
|
|
2
|
+
import { c as L, a as St, b as Ft, B as Oe } from "./colorToUniform-C2jGzNe1.js";
|
|
3
3
|
class Ie {
|
|
4
4
|
/**
|
|
5
5
|
* Initialize the plugin with scope of application instance
|
|
@@ -31,8 +31,8 @@ class Ie {
|
|
|
31
31
|
if (this._resizeTo === globalThis.window)
|
|
32
32
|
t = globalThis.innerWidth, r = globalThis.innerHeight;
|
|
33
33
|
else {
|
|
34
|
-
const { clientWidth: n, clientHeight:
|
|
35
|
-
t = n, r =
|
|
34
|
+
const { clientWidth: n, clientHeight: s } = this._resizeTo;
|
|
35
|
+
t = n, r = s;
|
|
36
36
|
}
|
|
37
37
|
this.renderer.resize(t, r), this.render();
|
|
38
38
|
}, this._resizeId = null, this._resizeTo = null, this.resizeTo = e.resizeTo || null;
|
|
@@ -86,34 +86,7 @@ class Ee {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
Ee.extension = p.Application;
|
|
89
|
-
var
|
|
90
|
-
out vec2 vTextureCoord;
|
|
91
|
-
|
|
92
|
-
uniform vec4 uInputSize;
|
|
93
|
-
uniform vec4 uOutputFrame;
|
|
94
|
-
uniform vec4 uOutputTexture;
|
|
95
|
-
|
|
96
|
-
vec4 filterVertexPosition( void )
|
|
97
|
-
{
|
|
98
|
-
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
99
|
-
|
|
100
|
-
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
101
|
-
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
102
|
-
|
|
103
|
-
return vec4(position, 0.0, 1.0);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
vec2 filterTextureCoord( void )
|
|
107
|
-
{
|
|
108
|
-
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
void main(void)
|
|
112
|
-
{
|
|
113
|
-
gl_Position = filterVertexPosition();
|
|
114
|
-
vTextureCoord = filterTextureCoord();
|
|
115
|
-
}
|
|
116
|
-
`, Rt = `in vec2 vTextureCoord;
|
|
89
|
+
var Rt = `in vec2 vTextureCoord;
|
|
117
90
|
out vec4 finalColor;
|
|
118
91
|
uniform sampler2D uTexture;
|
|
119
92
|
void main() {
|
|
@@ -176,7 +149,7 @@ class Ut extends ht {
|
|
|
176
149
|
fragment: { source: pe, entryPoint: "mainFragment" },
|
|
177
150
|
name: "passthrough-filter"
|
|
178
151
|
}), t = Re.from({
|
|
179
|
-
vertex:
|
|
152
|
+
vertex: ft,
|
|
180
153
|
fragment: Rt,
|
|
181
154
|
name: "passthrough-filter"
|
|
182
155
|
});
|
|
@@ -229,8 +202,8 @@ function Bt(o, e) {
|
|
|
229
202
|
const n = o[r];
|
|
230
203
|
if (n.globalDisplayStatus < 7)
|
|
231
204
|
continue;
|
|
232
|
-
const
|
|
233
|
-
|
|
205
|
+
const s = n.renderGroup ?? n.parentRenderGroup;
|
|
206
|
+
s?.isCachedAsTexture ? e.matrix = me.copyFrom(s.textureOffsetInverseTransform).append(n.worldTransform) : s?._parentCacheAsTextureRenderGroup ? e.matrix = me.copyFrom(s._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(n.groupTransform) : e.matrix = n.worldTransform, e.addBounds(n.bounds);
|
|
234
207
|
}
|
|
235
208
|
return e.matrix = t, e;
|
|
236
209
|
}
|
|
@@ -276,23 +249,23 @@ class We {
|
|
|
276
249
|
push(e) {
|
|
277
250
|
const t = this.renderer, r = e.filterEffect.filters, n = this._pushFilterData();
|
|
278
251
|
n.skip = !1, n.filters = r, n.container = e.container, n.outputRenderSurface = t.renderTarget.renderSurface;
|
|
279
|
-
const
|
|
252
|
+
const s = t.renderTarget.renderTarget.colorTexture.source, i = s.resolution, a = s.antialias;
|
|
280
253
|
if (r.every((f) => !f.enabled)) {
|
|
281
254
|
n.skip = !0;
|
|
282
255
|
return;
|
|
283
256
|
}
|
|
284
257
|
const l = n.bounds;
|
|
285
|
-
if (this._calculateFilterArea(e, l), this._calculateFilterBounds(n, t.renderTarget.rootViewPort, a,
|
|
258
|
+
if (this._calculateFilterArea(e, l), this._calculateFilterBounds(n, t.renderTarget.rootViewPort, a, i, 1), n.skip)
|
|
286
259
|
return;
|
|
287
|
-
const u = this._getPreviousFilterData(), h = this._findFilterResolution(
|
|
260
|
+
const u = this._getPreviousFilterData(), h = this._findFilterResolution(i);
|
|
288
261
|
let c = 0, d = 0;
|
|
289
262
|
u && (c = u.bounds.minX, d = u.bounds.minY), this._calculateGlobalFrame(
|
|
290
263
|
n,
|
|
291
264
|
c,
|
|
292
265
|
d,
|
|
293
266
|
h,
|
|
294
|
-
|
|
295
|
-
|
|
267
|
+
s.width,
|
|
268
|
+
s.height
|
|
296
269
|
), this._setupFilterTextures(n, l, t, u);
|
|
297
270
|
}
|
|
298
271
|
/**
|
|
@@ -325,13 +298,13 @@ class We {
|
|
|
325
298
|
generateFilteredTexture({ texture: e, filters: t }) {
|
|
326
299
|
const r = this._pushFilterData();
|
|
327
300
|
this._activeFilterData = r, r.skip = !1, r.filters = t;
|
|
328
|
-
const n = e.source,
|
|
301
|
+
const n = e.source, s = n.resolution, i = n.antialias;
|
|
329
302
|
if (t.every((f) => !f.enabled))
|
|
330
303
|
return r.skip = !0, e;
|
|
331
304
|
const a = r.bounds;
|
|
332
|
-
if (a.addRect(e.frame), this._calculateFilterBounds(r, a.rectangle,
|
|
305
|
+
if (a.addRect(e.frame), this._calculateFilterBounds(r, a.rectangle, i, s, 0), r.skip)
|
|
333
306
|
return e;
|
|
334
|
-
const l =
|
|
307
|
+
const l = s;
|
|
335
308
|
this._calculateGlobalFrame(
|
|
336
309
|
r,
|
|
337
310
|
0,
|
|
@@ -360,22 +333,22 @@ class We {
|
|
|
360
333
|
* @param previousBounds - The previous bounds to use for offsetting the copy.
|
|
361
334
|
*/
|
|
362
335
|
getBackTexture(e, t, r) {
|
|
363
|
-
const n = e.colorTexture.source._resolution,
|
|
336
|
+
const n = e.colorTexture.source._resolution, s = w.getOptimalTexture(
|
|
364
337
|
t.width,
|
|
365
338
|
t.height,
|
|
366
339
|
n,
|
|
367
340
|
!1
|
|
368
341
|
);
|
|
369
|
-
let
|
|
370
|
-
r && (
|
|
342
|
+
let i = t.minX, a = t.minY;
|
|
343
|
+
r && (i -= r.minX, a -= r.minY), i = Math.floor(i * n), a = Math.floor(a * n);
|
|
371
344
|
const l = Math.ceil(t.width * n), u = Math.ceil(t.height * n);
|
|
372
345
|
return this.renderer.renderTarget.copyToTexture(
|
|
373
346
|
e,
|
|
374
|
-
|
|
375
|
-
{ x:
|
|
347
|
+
s,
|
|
348
|
+
{ x: i, y: a },
|
|
376
349
|
{ width: l, height: u },
|
|
377
350
|
{ x: 0, y: 0 }
|
|
378
|
-
),
|
|
351
|
+
), s;
|
|
379
352
|
}
|
|
380
353
|
/**
|
|
381
354
|
* Applies a filter to a texture.
|
|
@@ -385,15 +358,15 @@ class We {
|
|
|
385
358
|
* @param clear - Whether to clear the output surface before applying the filter.
|
|
386
359
|
*/
|
|
387
360
|
applyFilter(e, t, r, n) {
|
|
388
|
-
const
|
|
361
|
+
const s = this.renderer, i = this._activeFilterData, l = i.outputRenderSurface === r, u = s.renderTarget.rootRenderTarget.colorTexture.source._resolution, h = this._findFilterResolution(u);
|
|
389
362
|
let c = 0, d = 0;
|
|
390
363
|
if (l) {
|
|
391
364
|
const m = this._findPreviousFilterOffset();
|
|
392
365
|
c = m.x, d = m.y;
|
|
393
366
|
}
|
|
394
|
-
this._updateFilterUniforms(t, r,
|
|
367
|
+
this._updateFilterUniforms(t, r, i, c, d, h, l, n);
|
|
395
368
|
const f = e.enabled ? e : this._getPassthroughFilter();
|
|
396
|
-
this._setupBindGroupsAndRender(f, t,
|
|
369
|
+
this._setupBindGroupsAndRender(f, t, s);
|
|
397
370
|
}
|
|
398
371
|
/**
|
|
399
372
|
* Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_.
|
|
@@ -411,8 +384,8 @@ class We {
|
|
|
411
384
|
r.inputTexture._source.height,
|
|
412
385
|
r.bounds.minX,
|
|
413
386
|
r.bounds.minY
|
|
414
|
-
),
|
|
415
|
-
return
|
|
387
|
+
), s = t.worldTransform.copyTo(P.shared), i = t.renderGroup || t.parentRenderGroup;
|
|
388
|
+
return i && i.cacheToLocalTransform && s.prepend(i.cacheToLocalTransform), s.invert(), n.prepend(s), n.scale(
|
|
416
389
|
1 / t.texture.orig.width,
|
|
417
390
|
1 / t.texture.orig.height
|
|
418
391
|
), n.translate(t.anchor.x, t.anchor.y), n;
|
|
@@ -457,8 +430,8 @@ class We {
|
|
|
457
430
|
e.antialias
|
|
458
431
|
), e.blendRequired) {
|
|
459
432
|
r.renderTarget.finishRenderPass();
|
|
460
|
-
const
|
|
461
|
-
e.backTexture = this.getBackTexture(
|
|
433
|
+
const s = r.renderTarget.getRenderTarget(e.outputRenderSurface);
|
|
434
|
+
e.backTexture = this.getBackTexture(s, t, n?.bounds);
|
|
462
435
|
}
|
|
463
436
|
r.renderTarget.bind(e.inputTexture, !0), r.globalUniforms.push({
|
|
464
437
|
offset: t
|
|
@@ -473,9 +446,9 @@ class We {
|
|
|
473
446
|
* @param sourceWidth - The source texture width
|
|
474
447
|
* @param sourceHeight - The source texture height
|
|
475
448
|
*/
|
|
476
|
-
_calculateGlobalFrame(e, t, r, n,
|
|
449
|
+
_calculateGlobalFrame(e, t, r, n, s, i) {
|
|
477
450
|
const a = e.globalFrame;
|
|
478
|
-
a.x = t * n, a.y = r * n, a.width =
|
|
451
|
+
a.x = t * n, a.y = r * n, a.width = s * n, a.height = i * n;
|
|
479
452
|
}
|
|
480
453
|
/**
|
|
481
454
|
* Updates the filter uniforms with the current filter state.
|
|
@@ -488,11 +461,11 @@ class We {
|
|
|
488
461
|
* @param isFinalTarget - Whether this is the final render target
|
|
489
462
|
* @param clear - Whether to clear the output surface
|
|
490
463
|
*/
|
|
491
|
-
_updateFilterUniforms(e, t, r, n,
|
|
464
|
+
_updateFilterUniforms(e, t, r, n, s, i, a, l) {
|
|
492
465
|
const u = this._filterGlobalUniforms.uniforms, h = u.uOutputFrame, c = u.uInputSize, d = u.uInputPixel, f = u.uInputClamp, m = u.uGlobalFrame, x = u.uOutputTexture;
|
|
493
|
-
a ? (h[0] = r.bounds.minX - n, h[1] = r.bounds.minY -
|
|
466
|
+
a ? (h[0] = r.bounds.minX - n, h[1] = r.bounds.minY - s) : (h[0] = 0, h[1] = 0), h[2] = e.frame.width, h[3] = e.frame.height, c[0] = e.source.width, c[1] = e.source.height, c[2] = 1 / c[0], c[3] = 1 / c[1], d[0] = e.source.pixelWidth, d[1] = e.source.pixelHeight, d[2] = 1 / d[0], d[3] = 1 / d[1], f[0] = 0.5 * d[2], f[1] = 0.5 * d[3], f[2] = e.frame.width * c[2] - 0.5 * d[2], f[3] = e.frame.height * c[3] - 0.5 * d[3];
|
|
494
467
|
const g = this.renderer.renderTarget.rootRenderTarget.colorTexture;
|
|
495
|
-
m[0] = n *
|
|
468
|
+
m[0] = n * i, m[1] = s * i, m[2] = g.source.width * i, m[3] = g.source.height * i, t instanceof R && (t.source.resource = null);
|
|
496
469
|
const _ = this.renderer.renderTarget.getRenderTarget(t);
|
|
497
470
|
this.renderer.renderTarget.bind(t, !!l), t instanceof R ? (x[0] = t.frame.width, x[1] = t.frame.height) : (x[0] = _.width, x[1] = _.height), x[2] = _.isRoot ? -1 : 1, this._filterGlobalUniforms.update();
|
|
498
471
|
}
|
|
@@ -535,9 +508,9 @@ class We {
|
|
|
535
508
|
}
|
|
536
509
|
}
|
|
537
510
|
_applyFiltersToTexture(e, t) {
|
|
538
|
-
const r = e.inputTexture, n = e.bounds,
|
|
539
|
-
if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(e.backTexture.source, 3),
|
|
540
|
-
i
|
|
511
|
+
const r = e.inputTexture, n = e.bounds, s = e.filters, i = e.firstEnabledIndex, a = e.lastEnabledIndex;
|
|
512
|
+
if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(e.backTexture.source, 3), i === a)
|
|
513
|
+
s[i].apply(this, r, e.outputRenderSurface, t);
|
|
541
514
|
else {
|
|
542
515
|
let l = e.inputTexture;
|
|
543
516
|
const u = w.getOptimalTexture(
|
|
@@ -547,39 +520,39 @@ class We {
|
|
|
547
520
|
!1
|
|
548
521
|
);
|
|
549
522
|
let h = u;
|
|
550
|
-
for (let c =
|
|
551
|
-
const d =
|
|
523
|
+
for (let c = i; c < a; c++) {
|
|
524
|
+
const d = s[c];
|
|
552
525
|
if (!d.enabled)
|
|
553
526
|
continue;
|
|
554
527
|
d.apply(this, l, h, !0);
|
|
555
528
|
const f = l;
|
|
556
529
|
l = h, h = f;
|
|
557
530
|
}
|
|
558
|
-
|
|
531
|
+
s[a].apply(this, l, e.outputRenderSurface, t), w.returnTexture(u);
|
|
559
532
|
}
|
|
560
533
|
}
|
|
561
|
-
_calculateFilterBounds(e, t, r, n,
|
|
562
|
-
const
|
|
534
|
+
_calculateFilterBounds(e, t, r, n, s) {
|
|
535
|
+
const i = this.renderer, a = e.bounds, l = e.filters;
|
|
563
536
|
let u = 1 / 0, h = 0, c = !0, d = !1, f = !1, m = !0, x = -1, g = -1;
|
|
564
537
|
for (let _ = 0; _ < l.length; _++) {
|
|
565
|
-
const
|
|
566
|
-
if (!
|
|
538
|
+
const b = l[_];
|
|
539
|
+
if (!b.enabled)
|
|
567
540
|
continue;
|
|
568
|
-
if (x === -1 && (x = _), g = _, u = Math.min(u,
|
|
541
|
+
if (x === -1 && (x = _), g = _, u = Math.min(u, b.resolution === "inherit" ? n : b.resolution), h += b.padding, b.antialias === "off" ? c = !1 : b.antialias === "inherit" && c && (c = r), b.clipToViewport || (m = !1), !!!(b.compatibleRenderers & i.type)) {
|
|
569
542
|
f = !1;
|
|
570
543
|
break;
|
|
571
544
|
}
|
|
572
|
-
if (
|
|
545
|
+
if (b.blendRequired && !(i.backBuffer?.useBackBuffer ?? !0)) {
|
|
573
546
|
N("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."), f = !1;
|
|
574
547
|
break;
|
|
575
548
|
}
|
|
576
|
-
f = !0, d || (d =
|
|
549
|
+
f = !0, d || (d = b.blendRequired);
|
|
577
550
|
}
|
|
578
551
|
if (!f) {
|
|
579
552
|
e.skip = !0;
|
|
580
553
|
return;
|
|
581
554
|
}
|
|
582
|
-
if (m && a.fitBounds(0, t.width / n, 0, t.height / n), a.scale(u).ceil().scale(1 / u).pad((h | 0) *
|
|
555
|
+
if (m && a.fitBounds(0, t.width / n, 0, t.height / n), a.scale(u).ceil().scale(1 / u).pad((h | 0) * s), !a.isPositive) {
|
|
583
556
|
e.skip = !0;
|
|
584
557
|
return;
|
|
585
558
|
}
|
|
@@ -617,20 +590,20 @@ const Le = class Ye extends te {
|
|
|
617
590
|
const r = t.positions || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
|
|
618
591
|
let n = t.uvs;
|
|
619
592
|
n || (t.positions ? n = new Float32Array(r.length) : n = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]));
|
|
620
|
-
const
|
|
593
|
+
const s = t.indices || new Uint32Array([0, 1, 2, 0, 2, 3]), i = t.shrinkBuffersToFit, a = new D({
|
|
621
594
|
data: r,
|
|
622
595
|
label: "attribute-mesh-positions",
|
|
623
|
-
shrinkToFit:
|
|
596
|
+
shrinkToFit: i,
|
|
624
597
|
usage: C.VERTEX | C.COPY_DST
|
|
625
598
|
}), l = new D({
|
|
626
599
|
data: n,
|
|
627
600
|
label: "attribute-mesh-uvs",
|
|
628
|
-
shrinkToFit:
|
|
601
|
+
shrinkToFit: i,
|
|
629
602
|
usage: C.VERTEX | C.COPY_DST
|
|
630
603
|
}), u = new D({
|
|
631
|
-
data:
|
|
604
|
+
data: s,
|
|
632
605
|
label: "index-mesh-buffer",
|
|
633
|
-
shrinkToFit:
|
|
606
|
+
shrinkToFit: i,
|
|
634
607
|
usage: C.INDEX | C.COPY_DST
|
|
635
608
|
});
|
|
636
609
|
super({
|
|
@@ -690,7 +663,7 @@ Le.defaultOptions = {
|
|
|
690
663
|
topology: "triangle-list",
|
|
691
664
|
shrinkBuffersToFit: !1
|
|
692
665
|
};
|
|
693
|
-
let
|
|
666
|
+
let ie = Le, U = null, S = null;
|
|
694
667
|
function Dt(o, e) {
|
|
695
668
|
U || (U = W.get().createCanvas(256, 128), S = U.getContext("2d", { willReadFrequently: !0 }), S.globalCompositeOperation = "copy", S.globalAlpha = 1), (U.width < o || U.height < e) && (U.width = de(o), U.height = de(e));
|
|
696
669
|
}
|
|
@@ -701,8 +674,8 @@ function ge(o, e, t) {
|
|
|
701
674
|
return !0;
|
|
702
675
|
}
|
|
703
676
|
function xe(o, e, t, r, n) {
|
|
704
|
-
const
|
|
705
|
-
for (let
|
|
677
|
+
const s = 4 * e;
|
|
678
|
+
for (let i = r, a = r * s + 4 * t; i <= n; ++i, a += s)
|
|
706
679
|
if (o[a + 3] !== 0)
|
|
707
680
|
return !1;
|
|
708
681
|
return !0;
|
|
@@ -710,26 +683,26 @@ function xe(o, e, t, r, n) {
|
|
|
710
683
|
function At(...o) {
|
|
711
684
|
let e = o[0];
|
|
712
685
|
e.canvas || (e = { canvas: o[0], resolution: o[1] });
|
|
713
|
-
const { canvas: t } = e, r = Math.min(e.resolution ?? 1, 1), n = e.width ?? t.width,
|
|
714
|
-
let
|
|
715
|
-
if (Dt(n,
|
|
686
|
+
const { canvas: t } = e, r = Math.min(e.resolution ?? 1, 1), n = e.width ?? t.width, s = e.height ?? t.height;
|
|
687
|
+
let i = e.output;
|
|
688
|
+
if (Dt(n, s), !S)
|
|
716
689
|
throw new TypeError("Failed to get canvas 2D context");
|
|
717
690
|
S.drawImage(
|
|
718
691
|
t,
|
|
719
692
|
0,
|
|
720
693
|
0,
|
|
721
694
|
n,
|
|
722
|
-
|
|
695
|
+
s,
|
|
723
696
|
0,
|
|
724
697
|
0,
|
|
725
698
|
n * r,
|
|
726
|
-
|
|
699
|
+
s * r
|
|
727
700
|
);
|
|
728
|
-
const l = S.getImageData(0, 0, n,
|
|
729
|
-
let u = 0, h = 0, c = n - 1, d =
|
|
730
|
-
for (; h <
|
|
701
|
+
const l = S.getImageData(0, 0, n, s).data;
|
|
702
|
+
let u = 0, h = 0, c = n - 1, d = s - 1;
|
|
703
|
+
for (; h < s && ge(l, n, h); )
|
|
731
704
|
++h;
|
|
732
|
-
if (h ===
|
|
705
|
+
if (h === s)
|
|
733
706
|
return q.EMPTY;
|
|
734
707
|
for (; ge(l, n, d); )
|
|
735
708
|
--d;
|
|
@@ -737,10 +710,10 @@ function At(...o) {
|
|
|
737
710
|
++u;
|
|
738
711
|
for (; xe(l, n, c, h, d); )
|
|
739
712
|
--c;
|
|
740
|
-
return ++c, ++d, S.globalCompositeOperation = "source-over", S.strokeRect(u, h, c - u, d - h), S.globalCompositeOperation = "copy",
|
|
713
|
+
return ++c, ++d, S.globalCompositeOperation = "source-over", S.strokeRect(u, h, c - u, d - h), S.globalCompositeOperation = "copy", i ?? (i = new q()), i.set(u / r, h / r, (c - u) / r, (d - h) / r), i;
|
|
741
714
|
}
|
|
742
715
|
const _e = new q();
|
|
743
|
-
class
|
|
716
|
+
class kt {
|
|
744
717
|
/**
|
|
745
718
|
* Creates a canvas with the specified text rendered to it.
|
|
746
719
|
*
|
|
@@ -757,8 +730,8 @@ class zt {
|
|
|
757
730
|
* @returns An object containing the canvas/context and the frame (bounds) of the text
|
|
758
731
|
*/
|
|
759
732
|
getCanvasAndContext(e) {
|
|
760
|
-
const { text: t, style: r, resolution: n = 1 } = e,
|
|
761
|
-
this._renderTextToCanvas(t, r,
|
|
733
|
+
const { text: t, style: r, resolution: n = 1 } = e, s = r._getFinalPadding(), i = B.measureText(t || " ", r), a = Math.ceil(Math.ceil(Math.max(1, i.width) + s * 2) * n), l = Math.ceil(Math.ceil(Math.max(1, i.height) + s * 2) * n), u = I.getOptimalCanvasAndContext(a, l);
|
|
734
|
+
this._renderTextToCanvas(t, r, s, n, u);
|
|
762
735
|
const h = r.trim ? At({ canvas: u.canvas, width: a, height: l, resolution: 1, output: _e }) : _e.set(0, 0, a, l);
|
|
763
736
|
return {
|
|
764
737
|
canvasAndContext: u,
|
|
@@ -783,45 +756,45 @@ class zt {
|
|
|
783
756
|
* @param resolution - The resolution of the text
|
|
784
757
|
* @param canvasAndContext - The canvas and context to render the text to
|
|
785
758
|
*/
|
|
786
|
-
_renderTextToCanvas(e, t, r, n,
|
|
787
|
-
const { canvas:
|
|
759
|
+
_renderTextToCanvas(e, t, r, n, s) {
|
|
760
|
+
const { canvas: i, context: a } = s, l = pt(t), u = B.measureText(e || " ", t), h = u.lines, c = u.lineHeight, d = u.lineWidths, f = u.maxLineWidth, m = u.fontProperties, x = i.height;
|
|
788
761
|
if (a.resetTransform(), a.scale(n, n), a.textBaseline = t.textBaseline, t._stroke?.width) {
|
|
789
762
|
const T = t._stroke;
|
|
790
763
|
a.lineWidth = T.width, a.miterLimit = T.miterLimit, a.lineJoin = T.join, a.lineCap = T.cap;
|
|
791
764
|
}
|
|
792
765
|
a.font = l;
|
|
793
766
|
let g, _;
|
|
794
|
-
const
|
|
795
|
-
for (let T = 0; T <
|
|
767
|
+
const b = t.dropShadow ? 2 : 1;
|
|
768
|
+
for (let T = 0; T < b; ++T) {
|
|
796
769
|
const A = t.dropShadow && T === 0, F = A ? Math.ceil(Math.max(1, x) + r * 2) : 0, G = F * n;
|
|
797
770
|
if (A) {
|
|
798
771
|
a.fillStyle = "black", a.strokeStyle = "black";
|
|
799
|
-
const
|
|
772
|
+
const v = t.dropShadow, ut = v.color, lt = v.alpha;
|
|
800
773
|
a.shadowColor = Ge.shared.setValue(ut).setAlpha(lt).toRgbaString();
|
|
801
|
-
const ct =
|
|
802
|
-
a.shadowBlur = ct, a.shadowOffsetX = Math.cos(
|
|
774
|
+
const ct = v.blur * n, le = v.distance * n;
|
|
775
|
+
a.shadowBlur = ct, a.shadowOffsetX = Math.cos(v.angle) * le, a.shadowOffsetY = Math.sin(v.angle) * le + G;
|
|
803
776
|
} else {
|
|
804
777
|
if (a.fillStyle = t._fill ? he(t._fill, a, u, r * 2) : null, t._stroke?.width) {
|
|
805
|
-
const
|
|
806
|
-
a.strokeStyle = he(t._stroke, a, u,
|
|
778
|
+
const v = t._stroke.width * 0.5 + r * 2;
|
|
779
|
+
a.strokeStyle = he(t._stroke, a, u, v);
|
|
807
780
|
}
|
|
808
781
|
a.shadowColor = "black";
|
|
809
782
|
}
|
|
810
783
|
let oe = (c - m.fontSize) / 2;
|
|
811
784
|
c - m.fontSize < 0 && (oe = 0);
|
|
812
785
|
const ue = t._stroke?.width ?? 0;
|
|
813
|
-
for (let
|
|
814
|
-
g = ue / 2, _ = ue / 2 +
|
|
815
|
-
h[
|
|
786
|
+
for (let v = 0; v < h.length; v++)
|
|
787
|
+
g = ue / 2, _ = ue / 2 + v * c + m.ascent + oe, t.align === "right" ? g += f - d[v] : t.align === "center" && (g += (f - d[v]) / 2), t._stroke?.width && this._drawLetterSpacing(
|
|
788
|
+
h[v],
|
|
816
789
|
t,
|
|
817
|
-
|
|
790
|
+
s,
|
|
818
791
|
g + r,
|
|
819
792
|
_ + r - F,
|
|
820
793
|
!0
|
|
821
794
|
), t._fill !== void 0 && this._drawLetterSpacing(
|
|
822
|
-
h[
|
|
795
|
+
h[v],
|
|
823
796
|
t,
|
|
824
|
-
|
|
797
|
+
s,
|
|
825
798
|
g + r,
|
|
826
799
|
_ + r - F
|
|
827
800
|
);
|
|
@@ -844,11 +817,11 @@ class zt {
|
|
|
844
817
|
* @param isStroke - Whether to render the stroke (true) or fill (false)
|
|
845
818
|
* @private
|
|
846
819
|
*/
|
|
847
|
-
_drawLetterSpacing(e, t, r, n,
|
|
820
|
+
_drawLetterSpacing(e, t, r, n, s, i = !1) {
|
|
848
821
|
const { context: a } = r, l = t.letterSpacing;
|
|
849
822
|
let u = !1;
|
|
850
823
|
if (B.experimentalLetterSpacingSupported && (B.experimentalLetterSpacing ? (a.letterSpacing = `${l}px`, a.textLetterSpacing = `${l}px`, u = !0) : (a.letterSpacing = "0px", a.textLetterSpacing = "0px")), l === 0 || u) {
|
|
851
|
-
|
|
824
|
+
i ? a.strokeText(e, n, s) : a.fillText(e, n, s);
|
|
852
825
|
return;
|
|
853
826
|
}
|
|
854
827
|
let h = n;
|
|
@@ -856,7 +829,7 @@ class zt {
|
|
|
856
829
|
let d = a.measureText(e).width, f = 0;
|
|
857
830
|
for (let m = 0; m < c.length; ++m) {
|
|
858
831
|
const x = c[m];
|
|
859
|
-
|
|
832
|
+
i ? a.strokeText(x, h, s) : a.fillText(x, h, s);
|
|
860
833
|
let g = "";
|
|
861
834
|
for (let _ = m + 1; _ < c.length; ++_)
|
|
862
835
|
g += c[_];
|
|
@@ -864,10 +837,10 @@ class zt {
|
|
|
864
837
|
}
|
|
865
838
|
}
|
|
866
839
|
}
|
|
867
|
-
const Y = new
|
|
840
|
+
const Y = new kt(), be = "http://www.w3.org/2000/svg", ve = "http://www.w3.org/1999/xhtml";
|
|
868
841
|
class Xe {
|
|
869
842
|
constructor() {
|
|
870
|
-
this.svgRoot = document.createElementNS(
|
|
843
|
+
this.svgRoot = document.createElementNS(be, "svg"), this.foreignObject = document.createElementNS(be, "foreignObject"), this.domElement = document.createElementNS(ve, "div"), this.styleElement = document.createElementNS(ve, "style");
|
|
871
844
|
const { foreignObject: e, svgRoot: t, styleElement: r, domElement: n } = this;
|
|
872
845
|
e.setAttribute("width", "10000"), e.setAttribute("height", "10000"), e.style.overflow = "hidden", t.appendChild(e), e.appendChild(r), e.appendChild(n), this.image = W.get().createImage();
|
|
873
846
|
}
|
|
@@ -876,12 +849,12 @@ class Xe {
|
|
|
876
849
|
}
|
|
877
850
|
}
|
|
878
851
|
let ye;
|
|
879
|
-
function
|
|
852
|
+
function zt(o, e, t, r) {
|
|
880
853
|
r || (r = ye || (ye = new Xe()));
|
|
881
|
-
const { domElement: n, styleElement:
|
|
882
|
-
n.innerHTML = `<style>${e.cssStyle};</style><div style='padding:0'>${o}</div>`, n.setAttribute("style", "transform-origin: top left; display: inline-block"), t && (
|
|
854
|
+
const { domElement: n, styleElement: s, svgRoot: i } = r;
|
|
855
|
+
n.innerHTML = `<style>${e.cssStyle};</style><div style='padding:0'>${o}</div>`, n.setAttribute("style", "transform-origin: top left; display: inline-block"), t && (s.textContent = t), document.body.appendChild(i);
|
|
883
856
|
const a = n.getBoundingClientRect();
|
|
884
|
-
|
|
857
|
+
i.remove();
|
|
885
858
|
const l = e.padding * 2;
|
|
886
859
|
return {
|
|
887
860
|
width: a.width - l,
|
|
@@ -916,8 +889,8 @@ class He {
|
|
|
916
889
|
updateRenderable(e) {
|
|
917
890
|
const r = this._getGpuDataForRenderable(e).batches;
|
|
918
891
|
for (let n = 0; n < r.length; n++) {
|
|
919
|
-
const
|
|
920
|
-
|
|
892
|
+
const s = r[n];
|
|
893
|
+
s._batcher.updateElement(s);
|
|
921
894
|
}
|
|
922
895
|
}
|
|
923
896
|
execute(e) {
|
|
@@ -926,12 +899,12 @@ class He {
|
|
|
926
899
|
const t = this.renderer, r = e.context;
|
|
927
900
|
if (!t.graphicsContext.getGpuContext(r).batches.length)
|
|
928
901
|
return;
|
|
929
|
-
const
|
|
902
|
+
const s = r.customShader || this._adaptor.shader;
|
|
930
903
|
this.state.blendMode = e.groupBlendMode;
|
|
931
|
-
const
|
|
932
|
-
|
|
904
|
+
const i = s.resources.localUniforms.uniforms;
|
|
905
|
+
i.uTransformMatrix = e.groupTransform, i.uRound = t._roundPixels | e._roundPixels, L(
|
|
933
906
|
e.groupColorAlpha,
|
|
934
|
-
|
|
907
|
+
i.uColor,
|
|
935
908
|
0
|
|
936
909
|
), this._adaptor.execute(this, e);
|
|
937
910
|
}
|
|
@@ -941,9 +914,9 @@ class He {
|
|
|
941
914
|
}
|
|
942
915
|
_addToBatcher(e, t) {
|
|
943
916
|
const r = this.renderer.renderPipes.batch, n = this._getGpuDataForRenderable(e).batches;
|
|
944
|
-
for (let
|
|
945
|
-
const
|
|
946
|
-
r.addToBatch(
|
|
917
|
+
for (let s = 0; s < n.length; s++) {
|
|
918
|
+
const i = n[s];
|
|
919
|
+
r.addToBatch(i, t);
|
|
947
920
|
}
|
|
948
921
|
}
|
|
949
922
|
_getGpuDataForRenderable(e) {
|
|
@@ -954,10 +927,10 @@ class He {
|
|
|
954
927
|
return e._gpuData[this.renderer.uid] = t, t;
|
|
955
928
|
}
|
|
956
929
|
_updateBatchesForRenderable(e, t) {
|
|
957
|
-
const r = e.context, n = this.renderer.graphicsContext.getGpuContext(r),
|
|
958
|
-
t.batches = n.batches.map((
|
|
959
|
-
const a = V.get(
|
|
960
|
-
return
|
|
930
|
+
const r = e.context, n = this.renderer.graphicsContext.getGpuContext(r), s = this.renderer._roundPixels | e._roundPixels;
|
|
931
|
+
t.batches = n.batches.map((i) => {
|
|
932
|
+
const a = V.get(mt);
|
|
933
|
+
return i.copyTo(a), a.renderable = e, a.roundPixels = s, a;
|
|
961
934
|
});
|
|
962
935
|
}
|
|
963
936
|
destroy() {
|
|
@@ -972,7 +945,7 @@ He.extension = {
|
|
|
972
945
|
],
|
|
973
946
|
name: "graphics"
|
|
974
947
|
};
|
|
975
|
-
const Ke = class $e extends
|
|
948
|
+
const Ke = class $e extends ie {
|
|
976
949
|
constructor(...e) {
|
|
977
950
|
super({});
|
|
978
951
|
let t = e[0] ?? {};
|
|
@@ -989,15 +962,15 @@ const Ke = class $e extends se {
|
|
|
989
962
|
*/
|
|
990
963
|
build(e) {
|
|
991
964
|
e = { ...$e.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;
|
|
992
|
-
const t = this.verticesX * this.verticesY, r = [], n = [],
|
|
965
|
+
const t = this.verticesX * this.verticesY, r = [], n = [], s = [], i = this.verticesX - 1, a = this.verticesY - 1, l = this.width / i, u = this.height / a;
|
|
993
966
|
for (let c = 0; c < t; c++) {
|
|
994
967
|
const d = c % this.verticesX, f = c / this.verticesX | 0;
|
|
995
|
-
r.push(d * l, f * u), n.push(d /
|
|
968
|
+
r.push(d * l, f * u), n.push(d / i, f / a);
|
|
996
969
|
}
|
|
997
|
-
const h =
|
|
970
|
+
const h = i * a;
|
|
998
971
|
for (let c = 0; c < h; c++) {
|
|
999
|
-
const d = c %
|
|
1000
|
-
|
|
972
|
+
const d = c % i, f = c / i | 0, m = f * this.verticesX + d, x = f * this.verticesX + d + 1, g = (f + 1) * this.verticesX + d, _ = (f + 1) * this.verticesX + d + 1;
|
|
973
|
+
s.push(
|
|
1001
974
|
m,
|
|
1002
975
|
x,
|
|
1003
976
|
g,
|
|
@@ -1006,7 +979,7 @@ const Ke = class $e extends se {
|
|
|
1006
979
|
g
|
|
1007
980
|
);
|
|
1008
981
|
}
|
|
1009
|
-
this.buffers[0].data = new Float32Array(r), this.buffers[1].data = new Float32Array(n), this.indexBuffer.data = new Uint32Array(
|
|
982
|
+
this.buffers[0].data = new Float32Array(r), this.buffers[1].data = new Float32Array(n), this.indexBuffer.data = new Uint32Array(s), this.buffers[0].update(), this.buffers[1].update(), this.indexBuffer.update();
|
|
1010
983
|
}
|
|
1011
984
|
};
|
|
1012
985
|
Ke.defaultOptions = {
|
|
@@ -1044,8 +1017,8 @@ class ae {
|
|
|
1044
1017
|
get uvs() {
|
|
1045
1018
|
const t = this.geometry.getBuffer("aUV"), r = t.data;
|
|
1046
1019
|
let n = r;
|
|
1047
|
-
const
|
|
1048
|
-
return
|
|
1020
|
+
const s = this.texture.textureMatrix;
|
|
1021
|
+
return s.isSimple || (n = this._transformedUvs, (this._textureMatrixUpdateId !== s._updateID || this._uvUpdateId !== t._updateID) && ((!n || n.length < r.length) && (n = this._transformedUvs = new Float32Array(r.length)), this._textureMatrixUpdateId = s._updateID, this._uvUpdateId = t._updateID, s.multiplyUvs(r, n))), n;
|
|
1049
1022
|
}
|
|
1050
1023
|
get positions() {
|
|
1051
1024
|
return this.geometry.positions;
|
|
@@ -1085,12 +1058,12 @@ class je {
|
|
|
1085
1058
|
if (t.batched = n, r !== n)
|
|
1086
1059
|
return !0;
|
|
1087
1060
|
if (n) {
|
|
1088
|
-
const
|
|
1089
|
-
if (
|
|
1090
|
-
return t.indexSize =
|
|
1091
|
-
const
|
|
1092
|
-
return
|
|
1093
|
-
|
|
1061
|
+
const s = e._geometry;
|
|
1062
|
+
if (s.indices.length !== t.indexSize || s.positions.length !== t.vertexSize)
|
|
1063
|
+
return t.indexSize = s.indices.length, t.vertexSize = s.positions.length, !0;
|
|
1064
|
+
const i = this._getBatchableMesh(e);
|
|
1065
|
+
return i.texture.uid !== e._texture.uid && (i._textureMatrixUpdateId = -1), !i._batcher.checkAndUpdateTexture(
|
|
1066
|
+
i,
|
|
1094
1067
|
e._texture
|
|
1095
1068
|
);
|
|
1096
1069
|
}
|
|
@@ -1099,8 +1072,8 @@ class je {
|
|
|
1099
1072
|
addRenderable(e, t) {
|
|
1100
1073
|
const r = this.renderer.renderPipes.batch, n = this._getMeshData(e);
|
|
1101
1074
|
if (e.didViewUpdate && (n.indexSize = e._geometry.indices?.length, n.vertexSize = e._geometry.positions?.length), n.batched) {
|
|
1102
|
-
const
|
|
1103
|
-
|
|
1075
|
+
const s = this._getBatchableMesh(e);
|
|
1076
|
+
s.setTexture(e._texture), s.geometry = e._geometry, r.addToBatch(s, t);
|
|
1104
1077
|
} else
|
|
1105
1078
|
r.break(t), t.add(e);
|
|
1106
1079
|
}
|
|
@@ -1154,23 +1127,23 @@ je.extension = {
|
|
|
1154
1127
|
};
|
|
1155
1128
|
class Et {
|
|
1156
1129
|
execute(e, t) {
|
|
1157
|
-
const r = e.state, n = e.renderer,
|
|
1158
|
-
|
|
1159
|
-
const
|
|
1160
|
-
n.shader.bind(
|
|
1161
|
-
const u = a.geometry.indexBuffer.data.BYTES_PER_ELEMENT === 2 ?
|
|
1162
|
-
|
|
1130
|
+
const r = e.state, n = e.renderer, s = t.shader || e.defaultShader;
|
|
1131
|
+
s.resources.uTexture = t.texture._source, s.resources.uniforms = e.localUniforms;
|
|
1132
|
+
const i = n.gl, a = e.getBuffers(t);
|
|
1133
|
+
n.shader.bind(s), n.state.set(r), n.geometry.bind(a.geometry, s.glProgram);
|
|
1134
|
+
const u = a.geometry.indexBuffer.data.BYTES_PER_ELEMENT === 2 ? i.UNSIGNED_SHORT : i.UNSIGNED_INT;
|
|
1135
|
+
i.drawElements(i.TRIANGLES, t.particleChildren.length * 6, u, 0);
|
|
1163
1136
|
}
|
|
1164
1137
|
}
|
|
1165
1138
|
class Vt {
|
|
1166
1139
|
execute(e, t) {
|
|
1167
1140
|
const r = e.renderer, n = t.shader || e.defaultShader;
|
|
1168
1141
|
n.groups[0] = r.renderPipes.uniformBatch.getUniformBindGroup(e.localUniforms, !0), n.groups[1] = r.texture.getTextureBindGroup(t.texture);
|
|
1169
|
-
const
|
|
1142
|
+
const s = e.state, i = e.getBuffers(t);
|
|
1170
1143
|
r.encoder.draw({
|
|
1171
|
-
geometry:
|
|
1144
|
+
geometry: i.geometry,
|
|
1172
1145
|
shader: t.shader || e.defaultShader,
|
|
1173
|
-
state:
|
|
1146
|
+
state: s,
|
|
1174
1147
|
size: t.particleChildren.length * 6
|
|
1175
1148
|
});
|
|
1176
1149
|
}
|
|
@@ -1201,12 +1174,12 @@ function Ce(o, e) {
|
|
|
1201
1174
|
|
|
1202
1175
|
`);
|
|
1203
1176
|
let r = 0;
|
|
1204
|
-
for (const
|
|
1205
|
-
const
|
|
1206
|
-
if (e !==
|
|
1177
|
+
for (const s in o) {
|
|
1178
|
+
const i = o[s];
|
|
1179
|
+
if (e !== i.dynamic)
|
|
1207
1180
|
continue;
|
|
1208
|
-
t.push(`offset = index + ${r}`), t.push(
|
|
1209
|
-
const a = Q(
|
|
1181
|
+
t.push(`offset = index + ${r}`), t.push(i.code);
|
|
1182
|
+
const a = Q(i.format);
|
|
1210
1183
|
r += a.stride / 4;
|
|
1211
1184
|
}
|
|
1212
1185
|
t.push(`
|
|
@@ -1223,13 +1196,13 @@ class Lt {
|
|
|
1223
1196
|
constructor(e) {
|
|
1224
1197
|
this._size = 0, this._generateParticleUpdateCache = {};
|
|
1225
1198
|
const t = this._size = e.size ?? 1e3, r = e.properties;
|
|
1226
|
-
let n = 0,
|
|
1199
|
+
let n = 0, s = 0;
|
|
1227
1200
|
for (const h in r) {
|
|
1228
1201
|
const c = r[h], d = Q(c.format);
|
|
1229
|
-
c.dynamic ?
|
|
1202
|
+
c.dynamic ? s += d.stride : n += d.stride;
|
|
1230
1203
|
}
|
|
1231
|
-
this._dynamicStride =
|
|
1232
|
-
const
|
|
1204
|
+
this._dynamicStride = s / 4, this._staticStride = n / 4, this.staticAttributeBuffer = new k(t * 4 * n), this.dynamicAttributeBuffer = new k(t * 4 * s), this.indexBuffer = we(t);
|
|
1205
|
+
const i = new te();
|
|
1233
1206
|
let a = 0, l = 0;
|
|
1234
1207
|
this._staticBuffer = new D({
|
|
1235
1208
|
data: new Float32Array(1),
|
|
@@ -1244,21 +1217,21 @@ class Lt {
|
|
|
1244
1217
|
});
|
|
1245
1218
|
for (const h in r) {
|
|
1246
1219
|
const c = r[h], d = Q(c.format);
|
|
1247
|
-
c.dynamic ? (
|
|
1220
|
+
c.dynamic ? (i.addAttribute(c.attributeName, {
|
|
1248
1221
|
buffer: this._dynamicBuffer,
|
|
1249
1222
|
stride: this._dynamicStride * 4,
|
|
1250
1223
|
offset: a * 4,
|
|
1251
1224
|
format: c.format
|
|
1252
|
-
}), a += d.size) : (
|
|
1225
|
+
}), a += d.size) : (i.addAttribute(c.attributeName, {
|
|
1253
1226
|
buffer: this._staticBuffer,
|
|
1254
1227
|
stride: this._staticStride * 4,
|
|
1255
1228
|
offset: l * 4,
|
|
1256
1229
|
format: c.format
|
|
1257
1230
|
}), l += d.size);
|
|
1258
1231
|
}
|
|
1259
|
-
|
|
1232
|
+
i.addIndex(this.indexBuffer);
|
|
1260
1233
|
const u = this.getParticleUpdate(r);
|
|
1261
|
-
this._dynamicUpload = u.dynamicUpdate, this._staticUpload = u.staticUpdate, this.geometry =
|
|
1234
|
+
this._dynamicUpload = u.dynamicUpdate, this._staticUpload = u.staticUpdate, this.geometry = i;
|
|
1262
1235
|
}
|
|
1263
1236
|
getParticleUpdate(e) {
|
|
1264
1237
|
const t = Yt(e);
|
|
@@ -1268,7 +1241,7 @@ class Lt {
|
|
|
1268
1241
|
return Wt(e);
|
|
1269
1242
|
}
|
|
1270
1243
|
update(e, t) {
|
|
1271
|
-
e.length > this._size && (t = !0, this._size = Math.max(e.length, this._size * 1.5 | 0), this.staticAttributeBuffer = new
|
|
1244
|
+
e.length > this._size && (t = !0, this._size = Math.max(e.length, this._size * 1.5 | 0), this.staticAttributeBuffer = new k(this._size * this._staticStride * 4 * 4), this.dynamicAttributeBuffer = new k(this._size * this._dynamicStride * 4 * 4), this.indexBuffer = we(this._size), this.geometry.indexBuffer.setDataWithSize(
|
|
1272
1245
|
this.indexBuffer,
|
|
1273
1246
|
this.indexBuffer.byteLength,
|
|
1274
1247
|
!0
|
|
@@ -1409,7 +1382,7 @@ fn mainFragment(
|
|
|
1409
1382
|
|
|
1410
1383
|
return sample;
|
|
1411
1384
|
}`;
|
|
1412
|
-
class Kt extends
|
|
1385
|
+
class Kt extends se {
|
|
1413
1386
|
constructor() {
|
|
1414
1387
|
const e = Re.from({
|
|
1415
1388
|
vertex: Ht,
|
|
@@ -1479,12 +1452,12 @@ class Ne {
|
|
|
1479
1452
|
return;
|
|
1480
1453
|
const r = this.renderer, n = this.getBuffers(e);
|
|
1481
1454
|
e.texture || (e.texture = t[0].texture);
|
|
1482
|
-
const
|
|
1483
|
-
n.update(t, e._childrenDirty), e._childrenDirty = !1,
|
|
1484
|
-
const
|
|
1485
|
-
e.worldTransform.copyTo(a), a.prepend(r.globalUniforms.globalUniformData.projectionMatrix),
|
|
1455
|
+
const s = this.state;
|
|
1456
|
+
n.update(t, e._childrenDirty), e._childrenDirty = !1, s.blendMode = ne(e.blendMode, e.texture._source);
|
|
1457
|
+
const i = this.localUniforms.uniforms, a = i.uTranslationMatrix;
|
|
1458
|
+
e.worldTransform.copyTo(a), a.prepend(r.globalUniforms.globalUniformData.projectionMatrix), i.uResolution = r.globalUniforms.globalUniformData.resolution, i.uRound = r._roundPixels | e._roundPixels, L(
|
|
1486
1459
|
e.groupColorAlpha,
|
|
1487
|
-
|
|
1460
|
+
i.uColor,
|
|
1488
1461
|
0
|
|
1489
1462
|
), this.adaptor.execute(this, e);
|
|
1490
1463
|
}
|
|
@@ -1537,13 +1510,13 @@ const Je = class Ze extends It {
|
|
|
1537
1510
|
width: t,
|
|
1538
1511
|
height: r,
|
|
1539
1512
|
_leftWidth: n,
|
|
1540
|
-
_rightWidth:
|
|
1541
|
-
_topHeight:
|
|
1513
|
+
_rightWidth: s,
|
|
1514
|
+
_topHeight: i,
|
|
1542
1515
|
_bottomHeight: a,
|
|
1543
1516
|
_anchorX: l,
|
|
1544
1517
|
_anchorY: u
|
|
1545
|
-
} = this, h = n +
|
|
1546
|
-
e[0] = e[8] = e[16] = e[24] = -x, e[2] = e[10] = e[18] = e[26] = n * m - x, e[4] = e[12] = e[20] = e[28] = t -
|
|
1518
|
+
} = this, h = n + s, c = t > h ? 1 : t / h, d = i + a, f = r > d ? 1 : r / d, m = Math.min(c, f), x = l * t, g = u * r;
|
|
1519
|
+
e[0] = e[8] = e[16] = e[24] = -x, e[2] = e[10] = e[18] = e[26] = n * m - x, e[4] = e[12] = e[20] = e[28] = t - s * m - x, e[6] = e[14] = e[22] = e[30] = t - x, e[1] = e[3] = e[5] = e[7] = -g, e[9] = e[11] = e[13] = e[15] = i * m - g, e[17] = e[19] = e[21] = e[23] = r - a * m - g, e[25] = e[27] = e[29] = e[31] = r - g, this.getBuffer("aPosition").update();
|
|
1547
1520
|
}
|
|
1548
1521
|
/** Updates the UVs of the vertices. */
|
|
1549
1522
|
updateUvs() {
|
|
@@ -1732,21 +1705,21 @@ const Nt = {
|
|
|
1732
1705
|
}
|
|
1733
1706
|
};
|
|
1734
1707
|
let X, H;
|
|
1735
|
-
class Qt extends
|
|
1708
|
+
class Qt extends se {
|
|
1736
1709
|
constructor() {
|
|
1737
1710
|
X ?? (X = De({
|
|
1738
1711
|
name: "tiling-sprite-shader",
|
|
1739
1712
|
bits: [
|
|
1740
|
-
|
|
1713
|
+
St,
|
|
1741
1714
|
Nt,
|
|
1742
1715
|
Ae
|
|
1743
1716
|
]
|
|
1744
|
-
})), H ?? (H =
|
|
1717
|
+
})), H ?? (H = ke({
|
|
1745
1718
|
name: "tiling-sprite-shader",
|
|
1746
1719
|
bits: [
|
|
1747
|
-
|
|
1720
|
+
Ft,
|
|
1748
1721
|
qt,
|
|
1749
|
-
|
|
1722
|
+
ze
|
|
1750
1723
|
]
|
|
1751
1724
|
}));
|
|
1752
1725
|
const e = new M({
|
|
@@ -1771,8 +1744,8 @@ class Qt extends ie {
|
|
|
1771
1744
|
}
|
|
1772
1745
|
});
|
|
1773
1746
|
}
|
|
1774
|
-
updateUniforms(e, t, r, n,
|
|
1775
|
-
const a = this.resources.tilingUniforms, l =
|
|
1747
|
+
updateUniforms(e, t, r, n, s, i) {
|
|
1748
|
+
const a = this.resources.tilingUniforms, l = i.width, u = i.height, h = i.textureMatrix, c = a.uniforms.uTextureTransform;
|
|
1776
1749
|
c.set(
|
|
1777
1750
|
r.a * l / e,
|
|
1778
1751
|
r.b * l / t,
|
|
@@ -1780,10 +1753,10 @@ class Qt extends ie {
|
|
|
1780
1753
|
r.d * u / t,
|
|
1781
1754
|
r.tx / e,
|
|
1782
1755
|
r.ty / t
|
|
1783
|
-
), c.invert(), a.uniforms.uMapCoord = h.mapCoord, a.uniforms.uClampFrame = h.uClampFrame, a.uniforms.uClampOffset = h.uClampOffset, a.uniforms.uTextureTransform = c, a.uniforms.uSizeAnchor[0] = e, a.uniforms.uSizeAnchor[1] = t, a.uniforms.uSizeAnchor[2] = n, a.uniforms.uSizeAnchor[3] =
|
|
1756
|
+
), c.invert(), a.uniforms.uMapCoord = h.mapCoord, a.uniforms.uClampFrame = h.uClampFrame, a.uniforms.uClampOffset = h.uClampOffset, a.uniforms.uTextureTransform = c, a.uniforms.uSizeAnchor[0] = e, a.uniforms.uSizeAnchor[1] = t, a.uniforms.uSizeAnchor[2] = n, a.uniforms.uSizeAnchor[3] = s, i && (this.resources.uTexture = i.source, this.resources.uSampler = i.source.style);
|
|
1784
1757
|
}
|
|
1785
1758
|
}
|
|
1786
|
-
class Jt extends
|
|
1759
|
+
class Jt extends ie {
|
|
1787
1760
|
constructor() {
|
|
1788
1761
|
super({
|
|
1789
1762
|
positions: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
|
|
@@ -1798,26 +1771,26 @@ function Zt(o, e) {
|
|
|
1798
1771
|
}
|
|
1799
1772
|
function er(o, e, t, r) {
|
|
1800
1773
|
let n = 0;
|
|
1801
|
-
const
|
|
1802
|
-
for (t *= e; n <
|
|
1774
|
+
const s = o.length / e, i = r.a, a = r.b, l = r.c, u = r.d, h = r.tx, c = r.ty;
|
|
1775
|
+
for (t *= e; n < s; ) {
|
|
1803
1776
|
const d = o[t], f = o[t + 1];
|
|
1804
|
-
o[t] =
|
|
1777
|
+
o[t] = i * d + l * f + h, o[t + 1] = a * d + u * f + c, t += e, n++;
|
|
1805
1778
|
}
|
|
1806
1779
|
}
|
|
1807
1780
|
function tr(o, e) {
|
|
1808
1781
|
const t = o.texture, r = t.frame.width, n = t.frame.height;
|
|
1809
|
-
let
|
|
1810
|
-
o.applyAnchorToTexture && (
|
|
1782
|
+
let s = 0, i = 0;
|
|
1783
|
+
o.applyAnchorToTexture && (s = o.anchor.x, i = o.anchor.y), e[0] = e[6] = -s, e[2] = e[4] = 1 - s, e[1] = e[3] = -i, e[5] = e[7] = 1 - i;
|
|
1811
1784
|
const a = P.shared;
|
|
1812
1785
|
a.copyFrom(o._tileTransform.matrix), a.tx /= o.width, a.ty /= o.height, a.invert(), a.scale(o.width / r, o.height / n), er(e, 2, 0, a);
|
|
1813
1786
|
}
|
|
1814
|
-
const
|
|
1787
|
+
const z = new Jt();
|
|
1815
1788
|
class rr {
|
|
1816
1789
|
constructor() {
|
|
1817
|
-
this.canBatch = !0, this.geometry = new
|
|
1818
|
-
indices:
|
|
1819
|
-
positions:
|
|
1820
|
-
uvs:
|
|
1790
|
+
this.canBatch = !0, this.geometry = new ie({
|
|
1791
|
+
indices: z.indices.slice(),
|
|
1792
|
+
positions: z.positions.slice(),
|
|
1793
|
+
uvs: z.uvs.slice()
|
|
1821
1794
|
});
|
|
1822
1795
|
}
|
|
1823
1796
|
destroy() {
|
|
@@ -1833,9 +1806,9 @@ class tt {
|
|
|
1833
1806
|
this._updateCanBatch(e);
|
|
1834
1807
|
const n = t.canBatch;
|
|
1835
1808
|
if (n && n === r) {
|
|
1836
|
-
const { batchableMesh:
|
|
1837
|
-
return !
|
|
1838
|
-
|
|
1809
|
+
const { batchableMesh: s } = t;
|
|
1810
|
+
return !s._batcher.checkAndUpdateTexture(
|
|
1811
|
+
s,
|
|
1839
1812
|
e.texture
|
|
1840
1813
|
);
|
|
1841
1814
|
}
|
|
@@ -1844,11 +1817,11 @@ class tt {
|
|
|
1844
1817
|
addRenderable(e, t) {
|
|
1845
1818
|
const r = this._renderer.renderPipes.batch;
|
|
1846
1819
|
this._updateCanBatch(e);
|
|
1847
|
-
const n = this._getTilingSpriteData(e), { geometry:
|
|
1848
|
-
if (
|
|
1820
|
+
const n = this._getTilingSpriteData(e), { geometry: s, canBatch: i } = n;
|
|
1821
|
+
if (i) {
|
|
1849
1822
|
n.batchableMesh || (n.batchableMesh = new ae());
|
|
1850
1823
|
const a = n.batchableMesh;
|
|
1851
|
-
e.didViewUpdate && (this._updateBatchableMesh(e), a.geometry =
|
|
1824
|
+
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);
|
|
1852
1825
|
} else
|
|
1853
1826
|
r.break(t), n.shader || (n.shader = new Qt()), this.updateRenderable(e), t.add(e);
|
|
1854
1827
|
}
|
|
@@ -1861,7 +1834,7 @@ class tt {
|
|
|
1861
1834
|
r.uColor,
|
|
1862
1835
|
0
|
|
1863
1836
|
), this._state.blendMode = ne(e.groupBlendMode, e.texture._source), this._renderer.encoder.draw({
|
|
1864
|
-
geometry:
|
|
1837
|
+
geometry: z,
|
|
1865
1838
|
shader: t,
|
|
1866
1839
|
state: this._state
|
|
1867
1840
|
});
|
|
@@ -1964,7 +1937,7 @@ const nr = {
|
|
|
1964
1937
|
`
|
|
1965
1938
|
)
|
|
1966
1939
|
}
|
|
1967
|
-
},
|
|
1940
|
+
}, sr = {
|
|
1968
1941
|
name: "local-uniform-msdf-bit",
|
|
1969
1942
|
vertex: {
|
|
1970
1943
|
header: (
|
|
@@ -2006,7 +1979,7 @@ const nr = {
|
|
|
2006
1979
|
`
|
|
2007
1980
|
)
|
|
2008
1981
|
}
|
|
2009
|
-
},
|
|
1982
|
+
}, ir = {
|
|
2010
1983
|
name: "msdf-bit",
|
|
2011
1984
|
fragment: {
|
|
2012
1985
|
header: (
|
|
@@ -2078,7 +2051,7 @@ const nr = {
|
|
|
2078
2051
|
}
|
|
2079
2052
|
};
|
|
2080
2053
|
let K, $;
|
|
2081
|
-
class or extends
|
|
2054
|
+
class or extends se {
|
|
2082
2055
|
constructor(e) {
|
|
2083
2056
|
const t = new M({
|
|
2084
2057
|
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
|
|
@@ -2089,20 +2062,20 @@ class or extends ie {
|
|
|
2089
2062
|
K ?? (K = De({
|
|
2090
2063
|
name: "sdf-shader",
|
|
2091
2064
|
bits: [
|
|
2092
|
-
|
|
2093
|
-
|
|
2065
|
+
gt,
|
|
2066
|
+
xt(e),
|
|
2094
2067
|
nr,
|
|
2095
|
-
|
|
2068
|
+
ir,
|
|
2096
2069
|
Ae
|
|
2097
2070
|
]
|
|
2098
|
-
})), $ ?? ($ =
|
|
2071
|
+
})), $ ?? ($ = ke({
|
|
2099
2072
|
name: "sdf-shader",
|
|
2100
2073
|
bits: [
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2074
|
+
_t,
|
|
2075
|
+
bt(e),
|
|
2076
|
+
sr,
|
|
2104
2077
|
ar,
|
|
2105
|
-
|
|
2078
|
+
ze
|
|
2106
2079
|
]
|
|
2107
2080
|
})), super({
|
|
2108
2081
|
glProgram: $,
|
|
@@ -2114,7 +2087,7 @@ class or extends ie {
|
|
|
2114
2087
|
});
|
|
2115
2088
|
}
|
|
2116
2089
|
}
|
|
2117
|
-
class ur extends
|
|
2090
|
+
class ur extends wt {
|
|
2118
2091
|
destroy() {
|
|
2119
2092
|
this.context.customShader && this.context.customShader.destroy(), super.destroy();
|
|
2120
2093
|
}
|
|
@@ -2136,28 +2109,28 @@ class rt {
|
|
|
2136
2109
|
Se(e, t), this._renderer.renderPipes.graphics.updateRenderable(t), t.context.customShader && this._updateDistanceField(e);
|
|
2137
2110
|
}
|
|
2138
2111
|
_updateContext(e, t) {
|
|
2139
|
-
const { context: r } = t, n =
|
|
2112
|
+
const { context: r } = t, n = yt.getFont(e.text, e._style);
|
|
2140
2113
|
r.clear(), n.distanceField.type !== "none" && (r.customShader || (r.customShader = new or(this._renderer.limits.maxBatchableTextures)));
|
|
2141
|
-
const
|
|
2114
|
+
const s = B.graphemeSegmenter(e.text), i = e._style;
|
|
2142
2115
|
let a = n.baseLineOffset;
|
|
2143
|
-
const l =
|
|
2116
|
+
const l = Tt(s, i, n, !0), u = i.padding, h = l.scale;
|
|
2144
2117
|
let c = l.width, d = l.height + l.offsetY;
|
|
2145
|
-
|
|
2146
|
-
const f = n.applyFillAsTint ?
|
|
2118
|
+
i._stroke && (c += i._stroke.width / h, d += i._stroke.width / h), r.translate(-e._anchor._x * c - u, -e._anchor._y * d - u).scale(h, h);
|
|
2119
|
+
const f = n.applyFillAsTint ? i._fill.color : 16777215;
|
|
2147
2120
|
let m = n.fontMetrics.fontSize, x = n.lineHeight;
|
|
2148
|
-
|
|
2121
|
+
i.lineHeight && (m = i.fontSize / h, x = i.lineHeight / h);
|
|
2149
2122
|
let g = (x - m) / 2;
|
|
2150
2123
|
g - n.baseLineOffset < 0 && (g = 0);
|
|
2151
2124
|
for (let _ = 0; _ < l.lines.length; _++) {
|
|
2152
|
-
const
|
|
2153
|
-
for (let T = 0; T <
|
|
2154
|
-
const A =
|
|
2125
|
+
const b = l.lines[_];
|
|
2126
|
+
for (let T = 0; T < b.charPositions.length; T++) {
|
|
2127
|
+
const A = b.chars[T], F = n.chars[A];
|
|
2155
2128
|
if (F?.texture) {
|
|
2156
2129
|
const G = F.texture;
|
|
2157
2130
|
r.texture(
|
|
2158
2131
|
G,
|
|
2159
2132
|
f || "black",
|
|
2160
|
-
Math.round(
|
|
2133
|
+
Math.round(b.charPositions[T] + F.xOffset),
|
|
2161
2134
|
Math.round(a + F.yOffset + g),
|
|
2162
2135
|
G.orig.width,
|
|
2163
2136
|
G.orig.height
|
|
@@ -2175,7 +2148,7 @@ class rt {
|
|
|
2175
2148
|
return e._gpuData[this._renderer.uid] = t, this._updateContext(e, t), t;
|
|
2176
2149
|
}
|
|
2177
2150
|
_updateDistanceField(e) {
|
|
2178
|
-
const t = this._getGpuBitmapText(e).context, r = e._style.fontFamily, n = Z.get(`${r}-bitmap`), { a:
|
|
2151
|
+
const t = this._getGpuBitmapText(e).context, r = e._style.fontFamily, n = Z.get(`${r}-bitmap`), { a: s, b: i, c: a, d: l } = e.groupTransform, u = Math.sqrt(s * s + i * i), h = Math.sqrt(a * a + l * l), c = (Math.abs(u) + Math.abs(h)) / 2, d = n.baseRenderedFontSize / e._style.fontSize, f = c * n.distanceField.range * (1 / d);
|
|
2179
2152
|
t.customShader.resources.localUniforms.uniforms.uDistance = f;
|
|
2180
2153
|
}
|
|
2181
2154
|
destroy() {
|
|
@@ -2214,9 +2187,9 @@ class lr extends Oe {
|
|
|
2214
2187
|
}
|
|
2215
2188
|
function ee(o, e) {
|
|
2216
2189
|
const { texture: t, bounds: r } = o, n = e._style._getFinalPadding();
|
|
2217
|
-
|
|
2218
|
-
const
|
|
2219
|
-
r.minX -= n -
|
|
2190
|
+
Ct(r, e._anchor, t);
|
|
2191
|
+
const s = e._anchor._x * n * 2, i = e._anchor._y * n * 2;
|
|
2192
|
+
r.minX -= n - s, r.minY -= n - i, r.maxX -= n - s, r.maxY -= n - i;
|
|
2220
2193
|
}
|
|
2221
2194
|
class nt {
|
|
2222
2195
|
constructor(e) {
|
|
@@ -2230,8 +2203,8 @@ class nt {
|
|
|
2230
2203
|
const r = this._getGpuText(e);
|
|
2231
2204
|
if (e._didTextUpdate) {
|
|
2232
2205
|
const n = e._autoResolution ? this._renderer.resolution : e.resolution;
|
|
2233
|
-
(r.currentKey !== e.styleKey || e.resolution !== n) && this._updateGpuText(e).catch((
|
|
2234
|
-
console.error(
|
|
2206
|
+
(r.currentKey !== e.styleKey || e.resolution !== n) && this._updateGpuText(e).catch((s) => {
|
|
2207
|
+
console.error(s);
|
|
2235
2208
|
}), e._didTextUpdate = !1, ee(r, e);
|
|
2236
2209
|
}
|
|
2237
2210
|
this._renderer.renderPipes.batch.addToBatch(r, t);
|
|
@@ -2251,8 +2224,8 @@ class nt {
|
|
|
2251
2224
|
r && (n = n.finally(() => {
|
|
2252
2225
|
this._renderer.htmlText.decreaseReferenceCount(t.currentKey), this._renderer.htmlText.returnTexturePromise(r);
|
|
2253
2226
|
})), t.texturePromise = n, t.currentKey = e.styleKey, t.texture = await n;
|
|
2254
|
-
const
|
|
2255
|
-
|
|
2227
|
+
const s = e.renderGroup || e.parentRenderGroup;
|
|
2228
|
+
s && (s.structureDidChange = !0), t.generatingTexture = !1, ee(t, e);
|
|
2256
2229
|
}
|
|
2257
2230
|
_getGpuText(e) {
|
|
2258
2231
|
return e._gpuData[this._renderer.uid] || this.initGpuText(e);
|
|
@@ -2278,19 +2251,19 @@ function cr() {
|
|
|
2278
2251
|
return /^((?!chrome|android).)*safari/i.test(o);
|
|
2279
2252
|
}
|
|
2280
2253
|
const dr = new Be();
|
|
2281
|
-
function
|
|
2254
|
+
function st(o, e, t, r) {
|
|
2282
2255
|
const n = dr;
|
|
2283
2256
|
n.minX = 0, n.minY = 0, n.maxX = o.width / r | 0, n.maxY = o.height / r | 0;
|
|
2284
|
-
const
|
|
2257
|
+
const s = w.getOptimalTexture(
|
|
2285
2258
|
n.width,
|
|
2286
2259
|
n.height,
|
|
2287
2260
|
r,
|
|
2288
2261
|
!1
|
|
2289
2262
|
);
|
|
2290
|
-
return
|
|
2263
|
+
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;
|
|
2291
2264
|
}
|
|
2292
2265
|
function hr(o, e) {
|
|
2293
|
-
const t = e.fontFamily, r = [], n = {},
|
|
2266
|
+
const t = e.fontFamily, r = [], n = {}, s = /font-family:([^;"\s]+)/g, i = o.match(s);
|
|
2294
2267
|
function a(l) {
|
|
2295
2268
|
n[l] || (r.push(l), n[l] = !0);
|
|
2296
2269
|
}
|
|
@@ -2299,7 +2272,7 @@ function hr(o, e) {
|
|
|
2299
2272
|
a(t[l]);
|
|
2300
2273
|
else
|
|
2301
2274
|
a(t);
|
|
2302
|
-
|
|
2275
|
+
i && i.forEach((l) => {
|
|
2303
2276
|
const u = l.split(":")[1].trim();
|
|
2304
2277
|
a(u);
|
|
2305
2278
|
});
|
|
@@ -2311,8 +2284,8 @@ function hr(o, e) {
|
|
|
2311
2284
|
}
|
|
2312
2285
|
async function fr(o) {
|
|
2313
2286
|
const t = await (await W.get().fetch(o)).blob(), r = new FileReader();
|
|
2314
|
-
return await new Promise((
|
|
2315
|
-
r.onloadend = () =>
|
|
2287
|
+
return await new Promise((s, i) => {
|
|
2288
|
+
r.onloadend = () => s(r.result), r.onerror = i, r.readAsDataURL(t);
|
|
2316
2289
|
});
|
|
2317
2290
|
}
|
|
2318
2291
|
async function pr(o, e) {
|
|
@@ -2329,8 +2302,8 @@ async function mr(o) {
|
|
|
2329
2302
|
const e = o.filter((t) => Z.has(`${t}-and-url`)).map((t) => {
|
|
2330
2303
|
if (!j.has(t)) {
|
|
2331
2304
|
const { entries: r } = Z.get(`${t}-and-url`), n = [];
|
|
2332
|
-
r.forEach((
|
|
2333
|
-
const
|
|
2305
|
+
r.forEach((s) => {
|
|
2306
|
+
const i = s.url, l = s.faces.map((u) => ({ weight: u.weight, style: u.style }));
|
|
2334
2307
|
n.push(
|
|
2335
2308
|
...l.map(
|
|
2336
2309
|
(u) => pr(
|
|
@@ -2339,13 +2312,13 @@ async function mr(o) {
|
|
|
2339
2312
|
fontStyle: u.style,
|
|
2340
2313
|
fontFamily: t
|
|
2341
2314
|
},
|
|
2342
|
-
|
|
2315
|
+
i
|
|
2343
2316
|
)
|
|
2344
2317
|
)
|
|
2345
2318
|
);
|
|
2346
2319
|
}), j.set(
|
|
2347
2320
|
t,
|
|
2348
|
-
Promise.all(n).then((
|
|
2321
|
+
Promise.all(n).then((s) => s.join(`
|
|
2349
2322
|
`))
|
|
2350
2323
|
);
|
|
2351
2324
|
}
|
|
@@ -2355,8 +2328,8 @@ async function mr(o) {
|
|
|
2355
2328
|
`);
|
|
2356
2329
|
}
|
|
2357
2330
|
function gr(o, e, t, r, n) {
|
|
2358
|
-
const { domElement:
|
|
2359
|
-
|
|
2331
|
+
const { domElement: s, styleElement: i, svgRoot: a } = n;
|
|
2332
|
+
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`), i.textContent = r;
|
|
2360
2333
|
const { width: l, height: u } = n.image;
|
|
2361
2334
|
return a.setAttribute("width", l.toString()), a.setAttribute("height", u.toString()), new XMLSerializer().serializeToString(a);
|
|
2362
2335
|
}
|
|
@@ -2375,7 +2348,7 @@ function _r(o, e, t) {
|
|
|
2375
2348
|
}, o.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`, o.crossOrigin = "anonymous";
|
|
2376
2349
|
});
|
|
2377
2350
|
}
|
|
2378
|
-
class
|
|
2351
|
+
class it {
|
|
2379
2352
|
constructor(e) {
|
|
2380
2353
|
this._activeTextures = {}, this._renderer = e, this._createCanvas = e.type === re.WEBGPU;
|
|
2381
2354
|
}
|
|
@@ -2434,20 +2407,20 @@ class st {
|
|
|
2434
2407
|
return this._buildTexturePromise(e);
|
|
2435
2408
|
}
|
|
2436
2409
|
async _buildTexturePromise(e) {
|
|
2437
|
-
const { text: t, style: r, resolution: n, textureStyle:
|
|
2410
|
+
const { text: t, style: r, resolution: n, textureStyle: s } = e, i = V.get(Xe), a = hr(t, r), l = await mr(a), u = zt(t, r, l, i), h = Math.ceil(Math.ceil(Math.max(1, u.width) + r.padding * 2) * n), c = Math.ceil(Math.ceil(Math.max(1, u.height) + r.padding * 2) * n), d = i.image, f = 2;
|
|
2438
2411
|
d.width = (h | 0) + f, d.height = (c | 0) + f;
|
|
2439
|
-
const m = gr(t, r, n, l,
|
|
2412
|
+
const m = gr(t, r, n, l, i);
|
|
2440
2413
|
await _r(d, m, cr() && a.length > 0);
|
|
2441
2414
|
const x = d;
|
|
2442
2415
|
let g;
|
|
2443
2416
|
this._createCanvas && (g = xr(d, n));
|
|
2444
|
-
const _ =
|
|
2417
|
+
const _ = st(
|
|
2445
2418
|
g ? g.canvas : x,
|
|
2446
2419
|
d.width - f,
|
|
2447
2420
|
d.height - f,
|
|
2448
2421
|
n
|
|
2449
2422
|
);
|
|
2450
|
-
return
|
|
2423
|
+
return s && (_.source.style = s), this._createCanvas && (this._renderer.texture.initSource(_.source), I.returnCanvasAndContext(g)), V.return(i), _;
|
|
2451
2424
|
}
|
|
2452
2425
|
returnTexturePromise(e) {
|
|
2453
2426
|
e.then((t) => {
|
|
@@ -2466,7 +2439,7 @@ class st {
|
|
|
2466
2439
|
this._activeTextures = null;
|
|
2467
2440
|
}
|
|
2468
2441
|
}
|
|
2469
|
-
|
|
2442
|
+
it.extension = {
|
|
2470
2443
|
type: [
|
|
2471
2444
|
p.WebGLSystem,
|
|
2472
2445
|
p.WebGPUSystem,
|
|
@@ -2474,7 +2447,7 @@ st.extension = {
|
|
|
2474
2447
|
],
|
|
2475
2448
|
name: "htmlText"
|
|
2476
2449
|
};
|
|
2477
|
-
class
|
|
2450
|
+
class br extends Oe {
|
|
2478
2451
|
constructor(e) {
|
|
2479
2452
|
super(), this._renderer = e, e.runners.resolutionChange.add(this);
|
|
2480
2453
|
}
|
|
@@ -2515,7 +2488,7 @@ class at {
|
|
|
2515
2488
|
return e._gpuData[this._renderer.uid] || this.initGpuText(e);
|
|
2516
2489
|
}
|
|
2517
2490
|
initGpuText(e) {
|
|
2518
|
-
const t = new
|
|
2491
|
+
const t = new br(this._renderer);
|
|
2519
2492
|
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;
|
|
2520
2493
|
}
|
|
2521
2494
|
destroy() {
|
|
@@ -2540,13 +2513,13 @@ class ot {
|
|
|
2540
2513
|
style: r,
|
|
2541
2514
|
resolution: t
|
|
2542
2515
|
}), e.style instanceof fe || (e.style = new fe(e.style)), e.textureStyle instanceof J || (e.textureStyle = new J(e.textureStyle)), typeof e.text != "string" && (e.text = e.text.toString());
|
|
2543
|
-
const { text:
|
|
2544
|
-
text:
|
|
2545
|
-
style:
|
|
2516
|
+
const { text: s, style: i, textureStyle: a } = e, l = e.resolution ?? this._renderer.resolution, { frame: u, canvasAndContext: h } = Y.getCanvasAndContext({
|
|
2517
|
+
text: s,
|
|
2518
|
+
style: i,
|
|
2546
2519
|
resolution: l
|
|
2547
|
-
}), c =
|
|
2548
|
-
if (a && (c.source.style = a),
|
|
2549
|
-
const d = this._applyFilters(c,
|
|
2520
|
+
}), c = st(h.canvas, u.width, u.height, l);
|
|
2521
|
+
if (a && (c.source.style = a), i.trim && (u.pad(i.padding), c.frame.copyFrom(u), c.frame.scale(1 / l), c.updateUvs()), i.filters) {
|
|
2522
|
+
const d = this._applyFilters(c, i.filters);
|
|
2550
2523
|
return this.returnTexture(c), Y.returnCanvasAndContext(h), d;
|
|
2551
2524
|
}
|
|
2552
2525
|
return this._renderer.texture.initSource(c._source), Y.returnCanvasAndContext(h), c;
|
|
@@ -2655,14 +2628,14 @@ ot.extension = {
|
|
|
2655
2628
|
y.add(Ie);
|
|
2656
2629
|
y.add(Ee);
|
|
2657
2630
|
y.add(He);
|
|
2658
|
-
y.add(
|
|
2631
|
+
y.add(Pt);
|
|
2659
2632
|
y.add(je);
|
|
2660
2633
|
y.add(qe);
|
|
2661
2634
|
y.add(Qe);
|
|
2662
2635
|
y.add(ot);
|
|
2663
2636
|
y.add(at);
|
|
2664
2637
|
y.add(rt);
|
|
2665
|
-
y.add(
|
|
2638
|
+
y.add(it);
|
|
2666
2639
|
y.add(nt);
|
|
2667
2640
|
y.add(tt);
|
|
2668
2641
|
y.add(et);
|