@designcombo/video 0.0.1 → 0.0.2
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-BhqLJf5z.js → SharedSystems-BWe03l6N.js} +20 -20
- package/dist/{WebGLRenderer-BzdmWLtP.js → WebGLRenderer-CKduQ9yw.js} +22 -22
- package/dist/{WebGPURenderer-Cypu9NWE.js → WebGPURenderer-BSX8DZj-.js} +19 -19
- package/dist/{browserAll-7OZQazmn.js → browserAll-CwPYLzJJ.js} +2 -2
- package/dist/clips/caption-clip.d.ts +33 -7
- package/dist/clips/image-clip.d.ts +26 -0
- package/dist/clips/text-clip.d.ts +34 -8
- package/dist/clips/video-clip.d.ts +30 -4
- package/dist/colorToUniform-C2jGzNe1.js +97 -0
- package/dist/effect/effect.d.ts +6 -0
- package/dist/effect/glsl/custom-glsl.d.ts +523 -0
- package/dist/effect/glsl/gl-effect.d.ts +14 -0
- package/dist/effect/types.d.ts +24 -0
- package/dist/effect/vertex.d.ts +1 -0
- package/dist/event-emitter.d.ts +47 -0
- package/dist/{index-BuRTeJh6.js → index-C333riU-.js} +8996 -6701
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +18 -16
- package/dist/index.umd.js +1492 -105
- package/dist/json-serialization.d.ts +14 -0
- package/dist/sprite/base-sprite.d.ts +7 -0
- package/dist/sprite/pixi-sprite-renderer.d.ts +1 -1
- package/dist/studio.d.ts +41 -2
- package/dist/{webworkerAll-DChKIQQa.js → webworkerAll-aNnyDpl9.js} +49 -49
- package/package.json +1 -1
- package/dist/colorToUniform-B0NRe8Du.js +0 -274
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { IClip } from './clips';
|
|
2
2
|
interface BaseClipJSON {
|
|
3
|
+
id?: string;
|
|
4
|
+
effects?: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
key: string;
|
|
7
|
+
startTime: number;
|
|
8
|
+
duration: number;
|
|
9
|
+
targets?: number[];
|
|
10
|
+
}>;
|
|
3
11
|
src: string;
|
|
4
12
|
display: {
|
|
5
13
|
from: number;
|
|
@@ -124,6 +132,12 @@ export interface CaptionClipJSON extends BaseClipJSON {
|
|
|
124
132
|
export type ClipJSON = VideoClipJSON | AudioClipJSON | ImageClipJSON | TextClipJSON | CaptionClipJSON;
|
|
125
133
|
export interface ProjectJSON {
|
|
126
134
|
clips: ClipJSON[];
|
|
135
|
+
globalEffects?: Array<{
|
|
136
|
+
id: string;
|
|
137
|
+
key: string;
|
|
138
|
+
startTime: number;
|
|
139
|
+
duration: number;
|
|
140
|
+
}>;
|
|
127
141
|
settings?: {
|
|
128
142
|
width?: number;
|
|
129
143
|
height?: number;
|
|
@@ -104,6 +104,13 @@ export declare abstract class BaseSprite {
|
|
|
104
104
|
* Flip clip horizontally or vertically
|
|
105
105
|
*/
|
|
106
106
|
flip: 'horizontal' | 'vertical' | null;
|
|
107
|
+
effects: Array<{
|
|
108
|
+
id: string;
|
|
109
|
+
key: string;
|
|
110
|
+
startTime: number;
|
|
111
|
+
duration: number;
|
|
112
|
+
targets?: number[];
|
|
113
|
+
}>;
|
|
107
114
|
private animatKeyFrame;
|
|
108
115
|
private animatOpts;
|
|
109
116
|
/**
|
|
@@ -19,7 +19,7 @@ export declare class PixiSpriteRenderer {
|
|
|
19
19
|
private canvas;
|
|
20
20
|
private context;
|
|
21
21
|
private destroyed;
|
|
22
|
-
constructor(
|
|
22
|
+
constructor(_pixiApp: Application | null, sprite: IClip, targetContainer?: Container | null);
|
|
23
23
|
/**
|
|
24
24
|
* Update the sprite with a new video frame or Texture
|
|
25
25
|
* @param frame ImageBitmap, Texture, or null to render
|
package/dist/studio.d.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { IClip } from './clips/iclip';
|
|
2
2
|
import { ProjectJSON } from './json-serialization';
|
|
3
|
+
import { EffectKey } from './effect/glsl/gl-effect';
|
|
4
|
+
import { default as EventEmitter } from './event-emitter';
|
|
3
5
|
export interface IStudioOpts {
|
|
4
6
|
width: number;
|
|
5
7
|
height: number;
|
|
6
8
|
fps?: number;
|
|
7
9
|
bgColor?: string;
|
|
8
10
|
canvas?: HTMLCanvasElement;
|
|
11
|
+
interactivity?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface StudioEvents {
|
|
14
|
+
"selection:created": {
|
|
15
|
+
selected: IClip[];
|
|
16
|
+
};
|
|
17
|
+
"selection:updated": {
|
|
18
|
+
selected: IClip[];
|
|
19
|
+
};
|
|
20
|
+
"selection:cleared": {
|
|
21
|
+
deselected: IClip[];
|
|
22
|
+
};
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
[key: symbol]: any;
|
|
9
25
|
}
|
|
10
26
|
/**
|
|
11
27
|
* Interactive preview studio for clips with playback controls
|
|
@@ -22,8 +38,12 @@ export interface IStudioOpts {
|
|
|
22
38
|
* await studio.addClip(spr1);
|
|
23
39
|
* await studio.addClip(spr2);
|
|
24
40
|
* studio.play();
|
|
41
|
+
*
|
|
42
|
+
* studio.on('selection:created', ({ selected }) => {
|
|
43
|
+
* console.log('Selection created', selected);
|
|
44
|
+
* });
|
|
25
45
|
*/
|
|
26
|
-
export declare class Studio {
|
|
46
|
+
export declare class Studio extends EventEmitter<StudioEvents> {
|
|
27
47
|
private pixiApp;
|
|
28
48
|
private clips;
|
|
29
49
|
private spriteRenderers;
|
|
@@ -44,11 +64,17 @@ export declare class Studio {
|
|
|
44
64
|
private maxDuration;
|
|
45
65
|
private opts;
|
|
46
66
|
private destroyed;
|
|
67
|
+
private globalEffects;
|
|
68
|
+
private activeGlobalEffect;
|
|
69
|
+
private postProcessContainer;
|
|
70
|
+
private effectFilters;
|
|
71
|
+
private scale;
|
|
72
|
+
private clipsNormalContainer;
|
|
73
|
+
private clipsEffectContainer;
|
|
47
74
|
/**
|
|
48
75
|
* Convert hex color string to number
|
|
49
76
|
*/
|
|
50
77
|
private hexToNumber;
|
|
51
|
-
ready: Promise<void>;
|
|
52
78
|
/**
|
|
53
79
|
* Create a new Studio instance
|
|
54
80
|
*/
|
|
@@ -115,6 +141,19 @@ export declare class Studio {
|
|
|
115
141
|
private renderLoop;
|
|
116
142
|
private updateFrame;
|
|
117
143
|
private recalculateMaxDuration;
|
|
144
|
+
/**
|
|
145
|
+
* Apply global effect to the current scene
|
|
146
|
+
*/
|
|
147
|
+
moveClipToEffectContainer(clip: IClip, toEffect?: boolean): void;
|
|
148
|
+
applyGlobalEffect(key: EffectKey, options: {
|
|
149
|
+
startTime: number;
|
|
150
|
+
duration?: number;
|
|
151
|
+
id?: string;
|
|
152
|
+
}, clips: IClip[]): string;
|
|
153
|
+
removeGlobalEffect(id: string): void;
|
|
154
|
+
clearGlobalEffects(): void;
|
|
155
|
+
private updateActiveGlobalEffect;
|
|
156
|
+
private applyGlobalEffectIfNeeded;
|
|
118
157
|
/**
|
|
119
158
|
* Destroy the studio and clean up resources
|
|
120
159
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as p, U as
|
|
2
|
-
import {
|
|
1
|
+
import { E as p, U as Ne, T as ee, F as je, G as he, v as fe, M as P, l as C, d as pe, I as v, t as w, a8 as $, R as N, w as L, H as me, a5 as G, a6 as ge, c as F, B as T, D as j, S as M, y as D, af as qe, ag as q, L as Y, ah as U, s as Q, a0 as Qe, $ as X, n as xe, q as _e, aa as be, ad as ye, o as Je, p as Ze, ab as et, ac as tt, ae as rt, ai as nt, aj as st, ak as it, al as H, am as at, an as ot, m as ve, ao as te, ap as k, e as b, aq as ut } from "./index-C333riU-.js";
|
|
2
|
+
import { c as z, a as lt, b as ct, B as Te } from "./colorToUniform-C2jGzNe1.js";
|
|
3
3
|
class Pe {
|
|
4
4
|
/**
|
|
5
5
|
* Initialize the plugin with scope of application instance
|
|
@@ -62,7 +62,7 @@ class we {
|
|
|
62
62
|
{
|
|
63
63
|
configurable: !0,
|
|
64
64
|
set(t) {
|
|
65
|
-
this._ticker && this._ticker.remove(this.render, this), this._ticker = t, t && t.add(this.render, this,
|
|
65
|
+
this._ticker && this._ticker.remove(this.render, this), this._ticker = t, t && t.add(this.render, this, Ne.LOW);
|
|
66
66
|
},
|
|
67
67
|
get() {
|
|
68
68
|
return this._ticker;
|
|
@@ -169,7 +169,7 @@ fn mainFragment(
|
|
|
169
169
|
return textureSample(uTexture, uSampler, uv);
|
|
170
170
|
}
|
|
171
171
|
`;
|
|
172
|
-
class ft extends
|
|
172
|
+
class ft extends je {
|
|
173
173
|
constructor() {
|
|
174
174
|
const e = he.from({
|
|
175
175
|
vertex: { source: re, entryPoint: "mainVertex" },
|
|
@@ -234,7 +234,7 @@ function pt(a, e) {
|
|
|
234
234
|
}
|
|
235
235
|
return e.matrix = t, e;
|
|
236
236
|
}
|
|
237
|
-
const mt = new
|
|
237
|
+
const mt = new $({
|
|
238
238
|
attributes: {
|
|
239
239
|
aPosition: {
|
|
240
240
|
buffer: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
|
|
@@ -440,7 +440,7 @@ class Se {
|
|
|
440
440
|
shader: e,
|
|
441
441
|
state: e._state,
|
|
442
442
|
topology: "triangle-list"
|
|
443
|
-
}), r.type ===
|
|
443
|
+
}), r.type === N.WEBGL && r.renderTarget.finishRenderPass();
|
|
444
444
|
}
|
|
445
445
|
/**
|
|
446
446
|
* Sets up the filter textures including input texture and back texture if needed.
|
|
@@ -570,7 +570,7 @@ class Se {
|
|
|
570
570
|
break;
|
|
571
571
|
}
|
|
572
572
|
if (y.blendRequired && !(i.backBuffer?.useBackBuffer ?? !0)) {
|
|
573
|
-
|
|
573
|
+
L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."), f = !1;
|
|
574
574
|
break;
|
|
575
575
|
}
|
|
576
576
|
f = !0, d || (d = y.blendRequired);
|
|
@@ -606,7 +606,7 @@ Se.extension = {
|
|
|
606
606
|
],
|
|
607
607
|
name: "filter"
|
|
608
608
|
};
|
|
609
|
-
const Fe = class Re extends
|
|
609
|
+
const Fe = class Re extends $ {
|
|
610
610
|
constructor(...e) {
|
|
611
611
|
let t = e[0] ?? {};
|
|
612
612
|
t instanceof Float32Array && (G(ge, "use new MeshGeometry({ positions, uvs, indices }) instead"), t = {
|
|
@@ -721,13 +721,13 @@ class _t {
|
|
|
721
721
|
}
|
|
722
722
|
destroy() {
|
|
723
723
|
this.batches.forEach((e) => {
|
|
724
|
-
|
|
724
|
+
D.return(e);
|
|
725
725
|
}), this.batches.length = 0;
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
728
|
class Be {
|
|
729
729
|
constructor(e, t) {
|
|
730
|
-
this.state =
|
|
730
|
+
this.state = M.for2d(), this.renderer = e, this._adaptor = t, this.renderer.runners.contextChange.add(this);
|
|
731
731
|
}
|
|
732
732
|
contextChange() {
|
|
733
733
|
this._adaptor.contextChange(this.renderer);
|
|
@@ -783,7 +783,7 @@ class Be {
|
|
|
783
783
|
_updateBatchesForRenderable(e, t) {
|
|
784
784
|
const r = e.context, n = this.renderer.graphicsContext.getGpuContext(r), s = this.renderer._roundPixels | e._roundPixels;
|
|
785
785
|
t.batches = n.batches.map((i) => {
|
|
786
|
-
const o =
|
|
786
|
+
const o = D.get(qe);
|
|
787
787
|
return i.copyTo(o), o.renderable = e, o.roundPixels = s, o;
|
|
788
788
|
});
|
|
789
789
|
}
|
|
@@ -1033,7 +1033,7 @@ function le(a, e) {
|
|
|
1033
1033
|
if (e !== i.dynamic)
|
|
1034
1034
|
continue;
|
|
1035
1035
|
t.push(`offset = index + ${r}`), t.push(i.code);
|
|
1036
|
-
const o =
|
|
1036
|
+
const o = Y(i.format);
|
|
1037
1037
|
r += o.stride / 4;
|
|
1038
1038
|
}
|
|
1039
1039
|
t.push(`
|
|
@@ -1052,11 +1052,11 @@ class Pt {
|
|
|
1052
1052
|
const t = this._size = e.size ?? 1e3, r = e.properties;
|
|
1053
1053
|
let n = 0, s = 0;
|
|
1054
1054
|
for (const h in r) {
|
|
1055
|
-
const l = r[h], d =
|
|
1055
|
+
const l = r[h], d = Y(l.format);
|
|
1056
1056
|
l.dynamic ? s += d.stride : n += d.stride;
|
|
1057
1057
|
}
|
|
1058
1058
|
this._dynamicStride = s / 4, this._staticStride = n / 4, this.staticAttributeBuffer = new U(t * 4 * n), this.dynamicAttributeBuffer = new U(t * 4 * s), this.indexBuffer = ue(t);
|
|
1059
|
-
const i = new
|
|
1059
|
+
const i = new $();
|
|
1060
1060
|
let o = 0, u = 0;
|
|
1061
1061
|
this._staticBuffer = new F({
|
|
1062
1062
|
data: new Float32Array(1),
|
|
@@ -1070,7 +1070,7 @@ class Pt {
|
|
|
1070
1070
|
usage: T.VERTEX | T.COPY_DST
|
|
1071
1071
|
});
|
|
1072
1072
|
for (const h in r) {
|
|
1073
|
-
const l = r[h], d =
|
|
1073
|
+
const l = r[h], d = Y(l.format);
|
|
1074
1074
|
l.dynamic ? (i.addAttribute(l.attributeName, {
|
|
1075
1075
|
buffer: this._dynamicBuffer,
|
|
1076
1076
|
stride: this._dynamicStride * 4,
|
|
@@ -1262,7 +1262,7 @@ class Ft extends Q {
|
|
|
1262
1262
|
// this will be replaced with the local uniforms from the particle container
|
|
1263
1263
|
uniforms: {
|
|
1264
1264
|
uTranslationMatrix: { value: new P(), type: "mat3x3<f32>" },
|
|
1265
|
-
uColor: { value: new
|
|
1265
|
+
uColor: { value: new Qe(16777215), type: "vec4<f32>" },
|
|
1266
1266
|
uRound: { value: 1, type: "f32" },
|
|
1267
1267
|
uResolution: { value: [0, 0], type: "vec2<f32>" }
|
|
1268
1268
|
}
|
|
@@ -1276,12 +1276,12 @@ class ze {
|
|
|
1276
1276
|
* @param adaptor
|
|
1277
1277
|
*/
|
|
1278
1278
|
constructor(e, t) {
|
|
1279
|
-
this.state =
|
|
1279
|
+
this.state = M.for2d(), this.localUniforms = new C({
|
|
1280
1280
|
uTranslationMatrix: { value: new P(), type: "mat3x3<f32>" },
|
|
1281
1281
|
uColor: { value: new Float32Array(4), type: "vec4<f32>" },
|
|
1282
1282
|
uRound: { value: 1, type: "f32" },
|
|
1283
1283
|
uResolution: { value: [0, 0], type: "vec2<f32>" }
|
|
1284
|
-
}), this.renderer = e, this.adaptor = t, this.defaultShader = new Ft(), this.state =
|
|
1284
|
+
}), this.renderer = e, this.adaptor = t, this.defaultShader = new Ft(), this.state = M.for2d();
|
|
1285
1285
|
}
|
|
1286
1286
|
validateRenderable(e) {
|
|
1287
1287
|
return !1;
|
|
@@ -1653,7 +1653,7 @@ class Ot {
|
|
|
1653
1653
|
}
|
|
1654
1654
|
class Ve {
|
|
1655
1655
|
constructor(e) {
|
|
1656
|
-
this._state =
|
|
1656
|
+
this._state = M.default2d, this._renderer = e;
|
|
1657
1657
|
}
|
|
1658
1658
|
validateRenderable(e) {
|
|
1659
1659
|
const t = this._getTilingSpriteData(e), r = t.canBatch;
|
|
@@ -1727,7 +1727,7 @@ class Ve {
|
|
|
1727
1727
|
_updateCanBatch(e) {
|
|
1728
1728
|
const t = this._getTilingSpriteData(e), r = e.texture;
|
|
1729
1729
|
let n = !0;
|
|
1730
|
-
return this._renderer.type ===
|
|
1730
|
+
return this._renderer.type === N.WEBGL && (n = this._renderer.context.supports.nonPowOf2wrapping), t.canBatch = r.textureMatrix.isSimple && (n || r.source.isPowerOfTwo), t.canBatch;
|
|
1731
1731
|
}
|
|
1732
1732
|
}
|
|
1733
1733
|
Ve.extension = {
|
|
@@ -1905,7 +1905,7 @@ const It = {
|
|
|
1905
1905
|
}
|
|
1906
1906
|
};
|
|
1907
1907
|
let E, V;
|
|
1908
|
-
class
|
|
1908
|
+
class Lt extends Q {
|
|
1909
1909
|
constructor(e) {
|
|
1910
1910
|
const t = new C({
|
|
1911
1911
|
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
|
|
@@ -1916,8 +1916,8 @@ class Yt extends Q {
|
|
|
1916
1916
|
E ?? (E = xe({
|
|
1917
1917
|
name: "sdf-shader",
|
|
1918
1918
|
bits: [
|
|
1919
|
-
|
|
1920
|
-
|
|
1919
|
+
Je,
|
|
1920
|
+
Ze(e),
|
|
1921
1921
|
It,
|
|
1922
1922
|
Vt,
|
|
1923
1923
|
_e
|
|
@@ -1925,8 +1925,8 @@ class Yt extends Q {
|
|
|
1925
1925
|
})), V ?? (V = be({
|
|
1926
1926
|
name: "sdf-shader",
|
|
1927
1927
|
bits: [
|
|
1928
|
-
|
|
1929
|
-
|
|
1928
|
+
et,
|
|
1929
|
+
tt(e),
|
|
1930
1930
|
Et,
|
|
1931
1931
|
Wt,
|
|
1932
1932
|
ye
|
|
@@ -1936,12 +1936,12 @@ class Yt extends Q {
|
|
|
1936
1936
|
gpuProgram: E,
|
|
1937
1937
|
resources: {
|
|
1938
1938
|
localUniforms: t,
|
|
1939
|
-
batchSamplers:
|
|
1939
|
+
batchSamplers: rt(e)
|
|
1940
1940
|
}
|
|
1941
1941
|
});
|
|
1942
1942
|
}
|
|
1943
1943
|
}
|
|
1944
|
-
class
|
|
1944
|
+
class Yt extends at {
|
|
1945
1945
|
destroy() {
|
|
1946
1946
|
this.context.customShader && this.context.customShader.destroy(), super.destroy();
|
|
1947
1947
|
}
|
|
@@ -1963,11 +1963,11 @@ class We {
|
|
|
1963
1963
|
de(e, t), this._renderer.renderPipes.graphics.updateRenderable(t), t.context.customShader && this._updateDistanceField(e);
|
|
1964
1964
|
}
|
|
1965
1965
|
_updateContext(e, t) {
|
|
1966
|
-
const { context: r } = t, n =
|
|
1967
|
-
r.clear(), n.distanceField.type !== "none" && (r.customShader || (r.customShader = new
|
|
1968
|
-
const s =
|
|
1966
|
+
const { context: r } = t, n = nt.getFont(e.text, e._style);
|
|
1967
|
+
r.clear(), n.distanceField.type !== "none" && (r.customShader || (r.customShader = new Lt(this._renderer.limits.maxBatchableTextures)));
|
|
1968
|
+
const s = st.graphemeSegmenter(e.text), i = e._style;
|
|
1969
1969
|
let o = n.baseLineOffset;
|
|
1970
|
-
const u =
|
|
1970
|
+
const u = it(s, i, n, !0), c = i.padding, h = u.scale;
|
|
1971
1971
|
let l = u.width, d = u.height + u.offsetY;
|
|
1972
1972
|
i._stroke && (l += i._stroke.width / h, d += i._stroke.width / h), r.translate(-e._anchor._x * l - c, -e._anchor._y * d - c).scale(h, h);
|
|
1973
1973
|
const f = n.applyFillAsTint ? i._fill.color : 16777215;
|
|
@@ -1978,7 +1978,7 @@ class We {
|
|
|
1978
1978
|
for (let _ = 0; _ < u.lines.length; _++) {
|
|
1979
1979
|
const y = u.lines[_];
|
|
1980
1980
|
for (let S = 0; S < y.charPositions.length; S++) {
|
|
1981
|
-
const
|
|
1981
|
+
const $e = y.chars[S], R = n.chars[$e];
|
|
1982
1982
|
if (R?.texture) {
|
|
1983
1983
|
const A = R.texture;
|
|
1984
1984
|
r.texture(
|
|
@@ -1998,7 +1998,7 @@ class We {
|
|
|
1998
1998
|
return e._gpuData[this._renderer.uid] || this.initGpuText(e);
|
|
1999
1999
|
}
|
|
2000
2000
|
initGpuText(e) {
|
|
2001
|
-
const t = new
|
|
2001
|
+
const t = new Yt();
|
|
2002
2002
|
return e._gpuData[this._renderer.uid] = t, this._updateContext(e, t), t;
|
|
2003
2003
|
}
|
|
2004
2004
|
_updateDistanceField(e) {
|
|
@@ -2041,11 +2041,11 @@ class Xt extends Te {
|
|
|
2041
2041
|
}
|
|
2042
2042
|
function K(a, e) {
|
|
2043
2043
|
const { texture: t, bounds: r } = a, n = e._style._getFinalPadding();
|
|
2044
|
-
|
|
2044
|
+
ot(r, e._anchor, t);
|
|
2045
2045
|
const s = e._anchor._x * n * 2, i = e._anchor._y * n * 2;
|
|
2046
2046
|
r.minX -= n - s, r.minY -= n - i, r.maxX -= n - s, r.maxY -= n - i;
|
|
2047
2047
|
}
|
|
2048
|
-
class
|
|
2048
|
+
class Le {
|
|
2049
2049
|
constructor(e) {
|
|
2050
2050
|
this._renderer = e;
|
|
2051
2051
|
}
|
|
@@ -2092,7 +2092,7 @@ class Ye {
|
|
|
2092
2092
|
this._renderer = null;
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
|
-
|
|
2095
|
+
Le.extension = {
|
|
2096
2096
|
type: [
|
|
2097
2097
|
p.WebGLPipes,
|
|
2098
2098
|
p.WebGPUPipes,
|
|
@@ -2105,7 +2105,7 @@ function Ht() {
|
|
|
2105
2105
|
return /^((?!chrome|android).)*safari/i.test(a);
|
|
2106
2106
|
}
|
|
2107
2107
|
const Kt = new me();
|
|
2108
|
-
function
|
|
2108
|
+
function Ye(a, e, t, r) {
|
|
2109
2109
|
const n = Kt;
|
|
2110
2110
|
n.minX = 0, n.minY = 0, n.maxX = a.width / r | 0, n.maxY = a.height / r | 0;
|
|
2111
2111
|
const s = v.getOptimalTexture(
|
|
@@ -2116,7 +2116,7 @@ function Le(a, e, t, r) {
|
|
|
2116
2116
|
);
|
|
2117
2117
|
return s.source.uploadMethodId = "image", s.source.resource = a, 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;
|
|
2118
2118
|
}
|
|
2119
|
-
function
|
|
2119
|
+
function $t(a, e) {
|
|
2120
2120
|
const t = e.fontFamily, r = [], n = {}, s = /font-family:([^;"\s]+)/g, i = a.match(s);
|
|
2121
2121
|
function o(u) {
|
|
2122
2122
|
n[u] || (r.push(u), n[u] = !0);
|
|
@@ -2136,14 +2136,14 @@ function Nt(a, e) {
|
|
|
2136
2136
|
}
|
|
2137
2137
|
return r;
|
|
2138
2138
|
}
|
|
2139
|
-
async function
|
|
2139
|
+
async function Nt(a) {
|
|
2140
2140
|
const t = await (await j.get().fetch(a)).blob(), r = new FileReader();
|
|
2141
2141
|
return await new Promise((s, i) => {
|
|
2142
2142
|
r.onloadend = () => s(r.result), r.onerror = i, r.readAsDataURL(t);
|
|
2143
2143
|
});
|
|
2144
2144
|
}
|
|
2145
2145
|
async function jt(a, e) {
|
|
2146
|
-
const t = await
|
|
2146
|
+
const t = await Nt(e);
|
|
2147
2147
|
return `@font-face {
|
|
2148
2148
|
font-family: "${a.fontFamily}";
|
|
2149
2149
|
font-weight: ${a.fontWeight};
|
|
@@ -2204,7 +2204,7 @@ function Zt(a, e, t) {
|
|
|
2204
2204
|
}
|
|
2205
2205
|
class Xe {
|
|
2206
2206
|
constructor(e) {
|
|
2207
|
-
this._activeTextures = {}, this._renderer = e, this._createCanvas = e.type ===
|
|
2207
|
+
this._activeTextures = {}, this._renderer = e, this._createCanvas = e.type === N.WEBGPU;
|
|
2208
2208
|
}
|
|
2209
2209
|
/**
|
|
2210
2210
|
* @param options
|
|
@@ -2249,7 +2249,7 @@ class Xe {
|
|
|
2249
2249
|
t && (t.usageCount--, t.usageCount === 0 && (t.texture ? this._cleanUp(t.texture) : t.promise.then((r) => {
|
|
2250
2250
|
t.texture = r, this._cleanUp(t.texture);
|
|
2251
2251
|
}).catch(() => {
|
|
2252
|
-
|
|
2252
|
+
L("HTMLTextSystem: Failed to clean texture");
|
|
2253
2253
|
}), this._activeTextures[e] = null));
|
|
2254
2254
|
}
|
|
2255
2255
|
/**
|
|
@@ -2261,26 +2261,26 @@ class Xe {
|
|
|
2261
2261
|
return this._buildTexturePromise(e);
|
|
2262
2262
|
}
|
|
2263
2263
|
async _buildTexturePromise(e) {
|
|
2264
|
-
const { text: t, style: r, resolution: n, textureStyle: s } = e, i =
|
|
2264
|
+
const { text: t, style: r, resolution: n, textureStyle: s } = e, i = D.get(Ue), o = $t(t, r), u = await qt(o), c = xt(t, r, u, i), h = Math.ceil(Math.ceil(Math.max(1, c.width) + r.padding * 2) * n), l = Math.ceil(Math.ceil(Math.max(1, c.height) + r.padding * 2) * n), d = i.image, f = 2;
|
|
2265
2265
|
d.width = (h | 0) + f, d.height = (l | 0) + f;
|
|
2266
2266
|
const g = Qt(t, r, n, u, i);
|
|
2267
2267
|
await Zt(d, g, Ht() && o.length > 0);
|
|
2268
2268
|
const m = d;
|
|
2269
2269
|
let x;
|
|
2270
2270
|
this._createCanvas && (x = Jt(d, n));
|
|
2271
|
-
const _ =
|
|
2271
|
+
const _ = Ye(
|
|
2272
2272
|
x ? x.canvas : m,
|
|
2273
2273
|
d.width - f,
|
|
2274
2274
|
d.height - f,
|
|
2275
2275
|
n
|
|
2276
2276
|
);
|
|
2277
|
-
return s && (_.source.style = s), this._createCanvas && (this._renderer.texture.initSource(_.source), ve.returnCanvasAndContext(x)),
|
|
2277
|
+
return s && (_.source.style = s), this._createCanvas && (this._renderer.texture.initSource(_.source), ve.returnCanvasAndContext(x)), D.return(i), _;
|
|
2278
2278
|
}
|
|
2279
2279
|
returnTexturePromise(e) {
|
|
2280
2280
|
e.then((t) => {
|
|
2281
2281
|
this._cleanUp(t);
|
|
2282
2282
|
}).catch(() => {
|
|
2283
|
-
|
|
2283
|
+
L("HTMLTextSystem: Failed to clean texture");
|
|
2284
2284
|
});
|
|
2285
2285
|
}
|
|
2286
2286
|
_cleanUp(e) {
|
|
@@ -2371,7 +2371,7 @@ class Ke {
|
|
|
2371
2371
|
text: s,
|
|
2372
2372
|
style: i,
|
|
2373
2373
|
resolution: u
|
|
2374
|
-
}), l =
|
|
2374
|
+
}), l = Ye(h.canvas, c.width, c.height, u);
|
|
2375
2375
|
if (o && (l.source.style = o), i.trim && (c.pad(i.padding), l.frame.copyFrom(c), l.frame.scale(1 / u), l.updateUvs()), i.filters) {
|
|
2376
2376
|
const d = this._applyFilters(l, i.filters);
|
|
2377
2377
|
return this.returnTexture(l), k.returnCanvasAndContext(h), d;
|
|
@@ -2482,7 +2482,7 @@ Ke.extension = {
|
|
|
2482
2482
|
b.add(Pe);
|
|
2483
2483
|
b.add(we);
|
|
2484
2484
|
b.add(Be);
|
|
2485
|
-
b.add(
|
|
2485
|
+
b.add(ut);
|
|
2486
2486
|
b.add(De);
|
|
2487
2487
|
b.add(Ae);
|
|
2488
2488
|
b.add(ke);
|
|
@@ -2490,7 +2490,7 @@ b.add(Ke);
|
|
|
2490
2490
|
b.add(He);
|
|
2491
2491
|
b.add(We);
|
|
2492
2492
|
b.add(Xe);
|
|
2493
|
-
b.add(
|
|
2493
|
+
b.add(Le);
|
|
2494
2494
|
b.add(Ve);
|
|
2495
2495
|
b.add(Ee);
|
|
2496
2496
|
b.add(Se);
|