modern-canvas 0.23.11 → 0.23.13
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/index.js
CHANGED
|
@@ -3873,6 +3873,16 @@ var or = class extends z {}, sr = class extends le {
|
|
|
3873
3873
|
}
|
|
3874
3874
|
}), this.resetStatus();
|
|
3875
3875
|
}
|
|
3876
|
+
drawMesh(e, t, n) {
|
|
3877
|
+
this._draws.push({
|
|
3878
|
+
...this._parseDrawStyle(this.fillStyle),
|
|
3879
|
+
type: "mesh",
|
|
3880
|
+
vertices: e instanceof Float32Array ? e : new Float32Array(e),
|
|
3881
|
+
meshUvs: t instanceof Float32Array ? t : new Float32Array(t),
|
|
3882
|
+
indices: n instanceof Uint32Array ? n : new Uint32Array(n),
|
|
3883
|
+
transformVertex: this.transformVertex
|
|
3884
|
+
}), this.resetStatus();
|
|
3885
|
+
}
|
|
3876
3886
|
fillRect(e, t, n, r) {
|
|
3877
3887
|
this.rect(e, t, n, r).fill();
|
|
3878
3888
|
}
|
|
@@ -3912,28 +3922,38 @@ var or = class extends z {}, sr = class extends le {
|
|
|
3912
3922
|
toBatchables() {
|
|
3913
3923
|
let e = [];
|
|
3914
3924
|
for (let t = this._draws.length, n = 0; n < t; n++) {
|
|
3915
|
-
let
|
|
3916
|
-
if (
|
|
3917
|
-
let
|
|
3918
|
-
|
|
3919
|
-
|
|
3925
|
+
let t = this._draws[n];
|
|
3926
|
+
if (t.type === "mesh") {
|
|
3927
|
+
let { vertices: r, indices: i, ...a } = t;
|
|
3928
|
+
this._triCache[n] = void 0, e.push({
|
|
3929
|
+
...a,
|
|
3930
|
+
vertices: r,
|
|
3920
3931
|
indices: i
|
|
3921
|
-
})
|
|
3932
|
+
});
|
|
3933
|
+
continue;
|
|
3934
|
+
}
|
|
3935
|
+
let { path: r, ...i } = t, a = i.type === "stroke" ? i.lineStyle : void 0, o = `${i.type}|${r.toData()}|${a ? `${a.width},${a.cap},${a.join},${a.alignment},${a.miterLimit}` : ""}`, s = this._triCache[n];
|
|
3936
|
+
if (!s || s.sig !== o) {
|
|
3937
|
+
let e = [], t = [];
|
|
3938
|
+
i.type === "fill" ? r.fillTriangulate({
|
|
3922
3939
|
vertices: e,
|
|
3923
|
-
indices:
|
|
3924
|
-
|
|
3940
|
+
indices: t
|
|
3941
|
+
}) : r.strokeTriangulate({
|
|
3942
|
+
vertices: e,
|
|
3943
|
+
indices: t,
|
|
3944
|
+
lineStyle: i.lineStyle,
|
|
3925
3945
|
flipAlignment: !1,
|
|
3926
|
-
closed:
|
|
3927
|
-
}),
|
|
3928
|
-
sig:
|
|
3946
|
+
closed: r.getPoint(0).equals(r.getPoint(1))
|
|
3947
|
+
}), s = {
|
|
3948
|
+
sig: o,
|
|
3929
3949
|
vertices: new Float32Array(e),
|
|
3930
|
-
indices: new Uint32Array(
|
|
3931
|
-
}, this._triCache[n] =
|
|
3950
|
+
indices: new Uint32Array(t)
|
|
3951
|
+
}, this._triCache[n] = s;
|
|
3932
3952
|
}
|
|
3933
3953
|
e.push({
|
|
3934
|
-
...
|
|
3935
|
-
vertices:
|
|
3936
|
-
indices:
|
|
3954
|
+
...i,
|
|
3955
|
+
vertices: s.vertices,
|
|
3956
|
+
indices: s.indices
|
|
3937
3957
|
});
|
|
3938
3958
|
}
|
|
3939
3959
|
return this._triCache.length = this._draws.length, e;
|
|
@@ -4546,13 +4566,14 @@ var _r = class extends V {
|
|
|
4546
4566
|
this.emit("draw");
|
|
4547
4567
|
}
|
|
4548
4568
|
_transformUvs(e) {
|
|
4549
|
-
let { texture: t, vertices: n, transformUv: r } = e;
|
|
4569
|
+
let { texture: t, vertices: n, transformUv: r, meshUvs: i } = e;
|
|
4550
4570
|
if (!t) return;
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4571
|
+
if (i) return i;
|
|
4572
|
+
let { width: a, height: o } = t, s = r ?? ((e, t) => {
|
|
4573
|
+
e[t] = e[t] / a, e[t + 1] = e[t + 1] / o;
|
|
4574
|
+
}), c = n.slice();
|
|
4575
|
+
for (let e = c.length, t = 0; t < e; t += 2) s(c, t);
|
|
4576
|
+
return c;
|
|
4556
4577
|
}
|
|
4557
4578
|
_redraw() {
|
|
4558
4579
|
return this._draw(), this.context.toBatchables().map((e) => ({
|
|
@@ -7875,13 +7896,22 @@ ea = k([b("Element2D"), O("design:paramtypes", [typeof Partial > "u" ? Object :
|
|
|
7875
7896
|
//#region src/scene/2d/TextureRect2D.ts
|
|
7876
7897
|
var ta = class extends ea {
|
|
7877
7898
|
texture;
|
|
7899
|
+
region;
|
|
7878
7900
|
constructor(e, t = []) {
|
|
7879
7901
|
super(), this.setProperties(e).append(t);
|
|
7880
7902
|
}
|
|
7903
|
+
_uvTransform() {
|
|
7904
|
+
let e = this.region;
|
|
7905
|
+
if (e && this.texture) {
|
|
7906
|
+
let t = this.texture.width || 1, n = this.texture.height || 1;
|
|
7907
|
+
return new v(e.width / (this.size.x * t), 0, 0, e.height / (this.size.y * n), e.x / t, e.y / n);
|
|
7908
|
+
}
|
|
7909
|
+
return new v().scale(1 / this.size.x, 1 / this.size.y);
|
|
7910
|
+
}
|
|
7881
7911
|
_drawContent() {
|
|
7882
7912
|
if (this.texture?.isValid()) {
|
|
7883
7913
|
this.shape.draw(!0), this.context.fillStyle = this.texture;
|
|
7884
|
-
let { a: e, c: t, tx: n, b: r, d: i, ty: a } =
|
|
7914
|
+
let { a: e, c: t, tx: n, b: r, d: i, ty: a } = this._uvTransform(), o, s;
|
|
7885
7915
|
this.context.fill({ transformUv: (c, l) => {
|
|
7886
7916
|
o = c[l], s = c[l + 1], c[l] = e * o + t * s + n, c[l + 1] = r * o + i * s + a;
|
|
7887
7917
|
} });
|
|
@@ -7920,8 +7950,39 @@ var ta = class extends ea {
|
|
|
7920
7950
|
};
|
|
7921
7951
|
k([_({ fallback: "" }), O("design:type", String)], na.prototype, "src", void 0), na = k([b("Lottie2D"), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], na);
|
|
7922
7952
|
//#endregion
|
|
7923
|
-
//#region src/scene/2d/
|
|
7953
|
+
//#region src/scene/2d/Mesh2D.ts
|
|
7924
7954
|
var ra = class extends ea {
|
|
7955
|
+
texture;
|
|
7956
|
+
_vertices = new Float32Array();
|
|
7957
|
+
_uvs = new Float32Array();
|
|
7958
|
+
_indices = new Uint32Array();
|
|
7959
|
+
get vertices() {
|
|
7960
|
+
return this._vertices;
|
|
7961
|
+
}
|
|
7962
|
+
set vertices(e) {
|
|
7963
|
+
this._vertices = e instanceof Float32Array ? e : new Float32Array(e), this.requestDraw();
|
|
7964
|
+
}
|
|
7965
|
+
get uvs() {
|
|
7966
|
+
return this._uvs;
|
|
7967
|
+
}
|
|
7968
|
+
set uvs(e) {
|
|
7969
|
+
this._uvs = e instanceof Float32Array ? e : new Float32Array(e), this.requestDraw();
|
|
7970
|
+
}
|
|
7971
|
+
get indices() {
|
|
7972
|
+
return this._indices;
|
|
7973
|
+
}
|
|
7974
|
+
set indices(e) {
|
|
7975
|
+
this._indices = e instanceof Uint32Array ? e : new Uint32Array(e), this.requestDraw();
|
|
7976
|
+
}
|
|
7977
|
+
constructor(e, t = []) {
|
|
7978
|
+
super();
|
|
7979
|
+
let { vertices: n, uvs: r, indices: i, ...a } = e ?? {};
|
|
7980
|
+
this.setProperties(a), n && (this.vertices = n), r && (this.uvs = r), i && (this.indices = i), this.append(t);
|
|
7981
|
+
}
|
|
7982
|
+
_drawContent() {
|
|
7983
|
+
this.texture?.isValid() && this._indices.length && this._vertices.length && (this.context.fillStyle = this.texture, this.context.drawMesh(this._vertices, this._uvs, this._indices));
|
|
7984
|
+
}
|
|
7985
|
+
}, ia = class extends ea {
|
|
7925
7986
|
constructor(e, t = []) {
|
|
7926
7987
|
super(), this.setProperties(e).append(t);
|
|
7927
7988
|
}
|
|
@@ -7944,10 +8005,10 @@ var ra = class extends ea {
|
|
|
7944
8005
|
this.context.rect(0, 0, e, t), this.context.strokeStyle = "#00FF00", this.context.stroke(), this._drawCircle(0, 0), this._drawCircle(e, t), this._drawCircle(0, t), this._drawEllipse(0, t / 2), this._drawCircle(e, 0), this._drawEllipse(e, t / 2);
|
|
7945
8006
|
}
|
|
7946
8007
|
};
|
|
7947
|
-
k([_({ fallback: 6 }), O("design:type", Number)],
|
|
8008
|
+
k([_({ fallback: 6 }), O("design:type", Number)], ia.prototype, "handleSize", void 0);
|
|
7948
8009
|
//#endregion
|
|
7949
8010
|
//#region src/scene/2d/Video2D.ts
|
|
7950
|
-
var
|
|
8011
|
+
var aa = class extends ta {
|
|
7951
8012
|
get videoDuration() {
|
|
7952
8013
|
return (this.texture?.duration ?? 0) * 1e3;
|
|
7953
8014
|
}
|
|
@@ -7987,15 +8048,15 @@ var ia = class extends ta {
|
|
|
7987
8048
|
super._process(e), this._updateVideoCurrentTime();
|
|
7988
8049
|
}
|
|
7989
8050
|
};
|
|
7990
|
-
k([_({ fallback: "" }), O("design:type", String)],
|
|
8051
|
+
k([_({ fallback: "" }), O("design:type", String)], aa.prototype, "src", void 0), aa = k([b("Video2D"), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], aa);
|
|
7991
8052
|
//#endregion
|
|
7992
8053
|
//#region src/scene/animation/Animation.ts
|
|
7993
|
-
function
|
|
8054
|
+
function oa(e) {
|
|
7994
8055
|
if (e == null) return 0;
|
|
7995
8056
|
let t = String(e).trim(), n = Number.parseFloat(t);
|
|
7996
8057
|
return Number.isNaN(n) ? 0 : n / 100;
|
|
7997
8058
|
}
|
|
7998
|
-
function
|
|
8059
|
+
function sa(e, t) {
|
|
7999
8060
|
let n = t * 180 / Math.PI;
|
|
8000
8061
|
if (e == null || e === "auto") return n;
|
|
8001
8062
|
let r = String(e).trim();
|
|
@@ -8004,12 +8065,11 @@ function oa(e, t) {
|
|
|
8004
8065
|
let i = Number.parseFloat(r);
|
|
8005
8066
|
return Number.isNaN(i) ? n : i;
|
|
8006
8067
|
}
|
|
8007
|
-
function
|
|
8068
|
+
function ca(e) {
|
|
8008
8069
|
let t = e.trim(), n = /^path\((.*)\)$/s.exec(t);
|
|
8009
8070
|
return n && (t = n[1].trim()), t.length >= 2 && (t[0] === "\"" || t[0] === "'") && t[t.length - 1] === t[0] && (t = t.slice(1, -1)), t.trim();
|
|
8010
8071
|
}
|
|
8011
|
-
|
|
8012
|
-
function pa(e, t, n, r) {
|
|
8072
|
+
function la(e, t, n, r) {
|
|
8013
8073
|
let i = 1e-6, a = 3 * e - 3 * n + 1, o = 3 * n - 6 * e, s = 3 * e, c = 3 * t - 3 * r + 1, l = 3 * r - 6 * t, u = 3 * t, d = (e) => (3 * a * e + 2 * o) * e + s, f = (e) => ((a * e + o) * e + s) * e, p = (e) => ((c * e + l) * e + u) * e;
|
|
8014
8074
|
function m(e) {
|
|
8015
8075
|
let t = e, n, r;
|
|
@@ -8029,13 +8089,74 @@ function pa(e, t, n, r) {
|
|
|
8029
8089
|
}
|
|
8030
8090
|
return (e) => p(m(e));
|
|
8031
8091
|
}
|
|
8032
|
-
var
|
|
8033
|
-
linear:
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8092
|
+
var ua = {
|
|
8093
|
+
linear: [
|
|
8094
|
+
0,
|
|
8095
|
+
0,
|
|
8096
|
+
1,
|
|
8097
|
+
1
|
|
8098
|
+
],
|
|
8099
|
+
ease: [
|
|
8100
|
+
.25,
|
|
8101
|
+
.1,
|
|
8102
|
+
.25,
|
|
8103
|
+
1
|
|
8104
|
+
],
|
|
8105
|
+
"ease-in": [
|
|
8106
|
+
.42,
|
|
8107
|
+
0,
|
|
8108
|
+
1,
|
|
8109
|
+
1
|
|
8110
|
+
],
|
|
8111
|
+
"ease-out": [
|
|
8112
|
+
0,
|
|
8113
|
+
0,
|
|
8114
|
+
.58,
|
|
8115
|
+
1
|
|
8116
|
+
],
|
|
8117
|
+
"ease-in-out": [
|
|
8118
|
+
.42,
|
|
8119
|
+
0,
|
|
8120
|
+
.58,
|
|
8121
|
+
1
|
|
8122
|
+
],
|
|
8123
|
+
"ease-in-quad": [
|
|
8124
|
+
.55,
|
|
8125
|
+
.085,
|
|
8126
|
+
.68,
|
|
8127
|
+
.53
|
|
8128
|
+
],
|
|
8129
|
+
"ease-out-quad": [
|
|
8130
|
+
.25,
|
|
8131
|
+
.46,
|
|
8132
|
+
.45,
|
|
8133
|
+
.94
|
|
8134
|
+
],
|
|
8135
|
+
"ease-in-out-quad": [
|
|
8136
|
+
.455,
|
|
8137
|
+
.03,
|
|
8138
|
+
.515,
|
|
8139
|
+
.955
|
|
8140
|
+
],
|
|
8141
|
+
"ease-in-cubic": [
|
|
8142
|
+
.55,
|
|
8143
|
+
.055,
|
|
8144
|
+
.675,
|
|
8145
|
+
.19
|
|
8146
|
+
],
|
|
8147
|
+
"ease-out-cubic": [
|
|
8148
|
+
.215,
|
|
8149
|
+
.61,
|
|
8150
|
+
.355,
|
|
8151
|
+
1
|
|
8152
|
+
],
|
|
8153
|
+
"ease-in-out-cubic": [
|
|
8154
|
+
.645,
|
|
8155
|
+
.045,
|
|
8156
|
+
.355,
|
|
8157
|
+
1
|
|
8158
|
+
]
|
|
8159
|
+
}, da = Object.fromEntries(Object.entries(ua).map(([e, [t, n, r, i]]) => [e, la(t, n, r, i)])), fa = class extends V {
|
|
8039
8160
|
_keyframes = [];
|
|
8040
8161
|
_isFirstUpdatePosition = !1;
|
|
8041
8162
|
_cachedProps = new t();
|
|
@@ -8122,10 +8243,14 @@ var ma = {
|
|
|
8122
8243
|
});
|
|
8123
8244
|
}
|
|
8124
8245
|
_parseEasing(e) {
|
|
8125
|
-
if (!e) return
|
|
8126
|
-
if (e in
|
|
8127
|
-
let t =
|
|
8128
|
-
|
|
8246
|
+
if (!e) return da.linear;
|
|
8247
|
+
if (e in da) return da[e];
|
|
8248
|
+
let t = /cubic-bezier\((.+)\)/.exec(e);
|
|
8249
|
+
if (t) {
|
|
8250
|
+
let e = t[1].split(",").map((e) => Number(e));
|
|
8251
|
+
if (e.length === 4 && e.every((e) => !Number.isNaN(e))) return la(e[0], e[1], e[2], e[3]);
|
|
8252
|
+
}
|
|
8253
|
+
return da.linear;
|
|
8129
8254
|
}
|
|
8130
8255
|
_parseKeyframes(e, t) {
|
|
8131
8256
|
let n, r = this._keyframes;
|
|
@@ -8160,7 +8285,7 @@ var ma = {
|
|
|
8160
8285
|
});
|
|
8161
8286
|
}
|
|
8162
8287
|
_commitOffsetPath(e, t, n, r, i, a) {
|
|
8163
|
-
let o =
|
|
8288
|
+
let o = ca(t);
|
|
8164
8289
|
if (!o) return;
|
|
8165
8290
|
let s = this._pathMeasures.get(o);
|
|
8166
8291
|
if (!s) {
|
|
@@ -8171,7 +8296,7 @@ var ma = {
|
|
|
8171
8296
|
startY: t.y
|
|
8172
8297
|
}, this._pathMeasures.set(o, s);
|
|
8173
8298
|
}
|
|
8174
|
-
let c = E(D(
|
|
8299
|
+
let c = E(D(oa(r.offsetDistance ?? i.offsetDistance), oa(i.offsetDistance ?? r.offsetDistance), a), 0, 1), { position: l, angle: u } = s.measure.getPosTanAtProgress(c), d = l.x - s.startX, f = l.y - s.startY, p = sa(i.offsetRotate ?? r.offsetRotate, u), m = n.get("transform");
|
|
8175
8300
|
e.onUpdateStyleProperty("transform", `${m ? `${m} ` : ""}translate(${d}px, ${f}px) rotate(${p}deg)`, void 0);
|
|
8176
8301
|
}
|
|
8177
8302
|
_getDiffValue(e, t, n, r, i) {
|
|
@@ -8218,14 +8343,14 @@ var ma = {
|
|
|
8218
8343
|
});
|
|
8219
8344
|
}
|
|
8220
8345
|
};
|
|
8221
|
-
k([_({ fallback: "parent" }), O("design:type", Object)],
|
|
8346
|
+
k([_({ fallback: "parent" }), O("design:type", Object)], fa.prototype, "effectMode", void 0), k([_({ default: () => [] }), O("design:type", Array)], fa.prototype, "keyframes", void 0), k([_(), O("design:type", Object)], fa.prototype, "easing", void 0), fa = k([b("Animation", {
|
|
8222
8347
|
renderMode: "disabled",
|
|
8223
8348
|
processSortMode: "parent-before",
|
|
8224
8349
|
duration: 2e3
|
|
8225
|
-
}), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])],
|
|
8350
|
+
}), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], fa);
|
|
8226
8351
|
//#endregion
|
|
8227
8352
|
//#region src/scene/audio/html/HTMLAudioContext.ts
|
|
8228
|
-
var
|
|
8353
|
+
var pa = class t extends e {
|
|
8229
8354
|
static _instance;
|
|
8230
8355
|
static get instance() {
|
|
8231
8356
|
return this._instance ||= new t(), this._instance;
|
|
@@ -8255,7 +8380,7 @@ var ga = class t extends e {
|
|
|
8255
8380
|
togglePause() {
|
|
8256
8381
|
return this.paused = !this.paused, this.refreshPaused(), this.paused;
|
|
8257
8382
|
}
|
|
8258
|
-
},
|
|
8383
|
+
}, ma = class t extends e {
|
|
8259
8384
|
static PADDING = .1;
|
|
8260
8385
|
_source = null;
|
|
8261
8386
|
_audio = null;
|
|
@@ -8382,7 +8507,7 @@ var ga = class t extends e {
|
|
|
8382
8507
|
let e = this._source;
|
|
8383
8508
|
e && (e.onended = null, e.onplay = null, e.onpause = null, this._stop()), this._source = null, this._playbackRate = 1, this._volume = 1, this._loop = !1, this._end = 0, this._start = 0, this._duration = 0, this._playing = !1, this._pausedReal = !1, this._paused = !1, this._muted = !1, this._audio &&= (this._audio.context.off("refresh", this.refresh), this._audio.context.off("refreshPaused", this.refreshPaused), null);
|
|
8384
8509
|
}
|
|
8385
|
-
},
|
|
8510
|
+
}, ha = class {
|
|
8386
8511
|
parent;
|
|
8387
8512
|
source = new globalThis.Audio();
|
|
8388
8513
|
_src = "";
|
|
@@ -8399,7 +8524,7 @@ var ga = class t extends e {
|
|
|
8399
8524
|
return !!this.source && this.source.readyState === 4;
|
|
8400
8525
|
}
|
|
8401
8526
|
get context() {
|
|
8402
|
-
return
|
|
8527
|
+
return pa.instance;
|
|
8403
8528
|
}
|
|
8404
8529
|
constructor(e) {
|
|
8405
8530
|
this.parent = e;
|
|
@@ -8410,9 +8535,9 @@ var ga = class t extends e {
|
|
|
8410
8535
|
});
|
|
8411
8536
|
}
|
|
8412
8537
|
createSound() {
|
|
8413
|
-
return new
|
|
8538
|
+
return new ma();
|
|
8414
8539
|
}
|
|
8415
|
-
},
|
|
8540
|
+
}, ga = class extends e {
|
|
8416
8541
|
_input;
|
|
8417
8542
|
_output;
|
|
8418
8543
|
_processers = [];
|
|
@@ -8434,7 +8559,7 @@ var ga = class t extends e {
|
|
|
8434
8559
|
get destination() {
|
|
8435
8560
|
return this._input;
|
|
8436
8561
|
}
|
|
8437
|
-
},
|
|
8562
|
+
}, _a = class {
|
|
8438
8563
|
destination;
|
|
8439
8564
|
source;
|
|
8440
8565
|
constructor(e, t = null) {
|
|
@@ -8449,21 +8574,21 @@ var ga = class t extends e {
|
|
|
8449
8574
|
};
|
|
8450
8575
|
//#endregion
|
|
8451
8576
|
//#region src/scene/audio/web/WebAudioContext.ts
|
|
8452
|
-
function
|
|
8577
|
+
function va() {
|
|
8453
8578
|
if (He) return new AudioContext();
|
|
8454
8579
|
if (Ue) {
|
|
8455
8580
|
let e = globalThis.webkitAudioContext;
|
|
8456
8581
|
return new e();
|
|
8457
8582
|
} else throw Error("Failed to createAudioContext");
|
|
8458
8583
|
}
|
|
8459
|
-
function
|
|
8584
|
+
function ya(e, t, n) {
|
|
8460
8585
|
if (We) return new OfflineAudioContext(e, t, n);
|
|
8461
8586
|
if (Ge) {
|
|
8462
8587
|
let r = globalThis.webkitOfflineAudioContext;
|
|
8463
8588
|
return new r(e, t, n);
|
|
8464
8589
|
} else throw Error("Failed to createOfflineAudioContext");
|
|
8465
8590
|
}
|
|
8466
|
-
var
|
|
8591
|
+
var ba = class e extends ga {
|
|
8467
8592
|
static _instance;
|
|
8468
8593
|
static get instance() {
|
|
8469
8594
|
return this._instance ||= new e(), this._instance;
|
|
@@ -8504,7 +8629,7 @@ var Ca = class e extends ya {
|
|
|
8504
8629
|
_compressor;
|
|
8505
8630
|
_analyser;
|
|
8506
8631
|
constructor() {
|
|
8507
|
-
let e =
|
|
8632
|
+
let e = va(), t = ya(1, 2, We ? Math.max(8e3, Math.min(96e3, e.sampleRate)) : 44100), n = e.createDynamicsCompressor(), r = e.createAnalyser();
|
|
8508
8633
|
r.connect(n), n.connect(e.destination), super(r, n), this._context = e, this._offlineContext = t, this._compressor = n, this._analyser = r, this._locked = e.state === "suspended" && (ze || Be), qe && (this._locked && (this._unlock(), document.addEventListener("mousedown", this._unlock, !0), document.addEventListener("touchstart", this._unlock, !0), document.addEventListener("touchend", this._unlock, !0)), globalThis.addEventListener("focus", this._onFocus), globalThis.addEventListener("blur", this._onBlur));
|
|
8509
8634
|
}
|
|
8510
8635
|
_onFocus() {
|
|
@@ -8545,7 +8670,7 @@ var Ca = class e extends ya {
|
|
|
8545
8670
|
setParamValue(e, t) {
|
|
8546
8671
|
e.setValueAtTime ? e.setValueAtTime(t, this._context.currentTime) : e.value = t;
|
|
8547
8672
|
}
|
|
8548
|
-
},
|
|
8673
|
+
}, xa = class extends e {
|
|
8549
8674
|
_audio = null;
|
|
8550
8675
|
_sourceNode = null;
|
|
8551
8676
|
_gain = null;
|
|
@@ -8678,7 +8803,7 @@ var Ca = class e extends ya {
|
|
|
8678
8803
|
destroy() {
|
|
8679
8804
|
super.destroy(), this._stop(), this._gain?.disconnect(), this._gain = null, this._audio?.context.off("refresh", this.refresh), this._audio?.context.off("refreshPaused", this.refreshPaused), this._audio = null, this._processors.forEach((e) => e.disconnect()), this._processors.length = 0, this._end = 0, this._playbackRate = 1, this._volume = 1, this._loop = !1, this._elapsed = 0, this._duration = 0, this._paused = !1, this._muted = !1, this._pausedReal = !1;
|
|
8680
8805
|
}
|
|
8681
|
-
},
|
|
8806
|
+
}, Sa = class extends ga {
|
|
8682
8807
|
parent;
|
|
8683
8808
|
_sourceBuffer;
|
|
8684
8809
|
_sourceNode;
|
|
@@ -8686,7 +8811,7 @@ var Ca = class e extends ya {
|
|
|
8686
8811
|
gain;
|
|
8687
8812
|
analyser;
|
|
8688
8813
|
get context() {
|
|
8689
|
-
return
|
|
8814
|
+
return ba.instance;
|
|
8690
8815
|
}
|
|
8691
8816
|
get isPlayable() {
|
|
8692
8817
|
return !!this._sourceNode.buffer;
|
|
@@ -8701,8 +8826,8 @@ var Ca = class e extends ya {
|
|
|
8701
8826
|
this._sourceNode.buffer = e;
|
|
8702
8827
|
}
|
|
8703
8828
|
constructor(e) {
|
|
8704
|
-
let t =
|
|
8705
|
-
n.connect(i), i.connect(r), r.connect(
|
|
8829
|
+
let t = ba.audioContext, n = t.createBufferSource(), r = t.createGain(), i = t.createAnalyser();
|
|
8830
|
+
n.connect(i), i.connect(r), r.connect(ba.instance.destination), super(i, r), this.parent = e, this._sourceNode = n, this.gain = r, this.analyser = i;
|
|
8706
8831
|
}
|
|
8707
8832
|
async load() {
|
|
8708
8833
|
return this._sourceLoad ||= new Promise((e) => {
|
|
@@ -8715,7 +8840,7 @@ var Ca = class e extends ya {
|
|
|
8715
8840
|
});
|
|
8716
8841
|
}
|
|
8717
8842
|
_decode(e) {
|
|
8718
|
-
return Promise.resolve(e instanceof AudioBuffer ? e :
|
|
8843
|
+
return Promise.resolve(e instanceof AudioBuffer ? e : ba.decode(e)).then((e) => (this.parent.isLoaded = !0, this.buffer = e, e));
|
|
8719
8844
|
}
|
|
8720
8845
|
cloneSource() {
|
|
8721
8846
|
let e = this.context, t = this._sourceNode, n = e.audioContext.createBufferSource(), r = e.audioContext.createGain();
|
|
@@ -8725,15 +8850,15 @@ var Ca = class e extends ya {
|
|
|
8725
8850
|
};
|
|
8726
8851
|
}
|
|
8727
8852
|
createSound() {
|
|
8728
|
-
return new
|
|
8853
|
+
return new xa();
|
|
8729
8854
|
}
|
|
8730
|
-
},
|
|
8855
|
+
}, Ca, wa = class extends V {
|
|
8731
8856
|
static {
|
|
8732
|
-
|
|
8857
|
+
Ca = this;
|
|
8733
8858
|
}
|
|
8734
8859
|
static _soundPool = [];
|
|
8735
8860
|
_sounds = [];
|
|
8736
|
-
_platformAudio = Ke ? new
|
|
8861
|
+
_platformAudio = Ke ? new Sa(this) : new ha(this);
|
|
8737
8862
|
get platformAudio() {
|
|
8738
8863
|
return this._platformAudio;
|
|
8739
8864
|
}
|
|
@@ -8826,7 +8951,7 @@ var Ca = class e extends ya {
|
|
|
8826
8951
|
this._sounds.length = 0;
|
|
8827
8952
|
}
|
|
8828
8953
|
_createSound() {
|
|
8829
|
-
return
|
|
8954
|
+
return Ca._soundPool.length > 0 ? Ca._soundPool.pop().init(this._platformAudio) : this._platformAudio.createSound().init(this._platformAudio);
|
|
8830
8955
|
}
|
|
8831
8956
|
refresh() {
|
|
8832
8957
|
for (let e = this._sounds.length, t = 0; t < e; t++) this._sounds[t].refresh();
|
|
@@ -8842,7 +8967,7 @@ var Ca = class e extends ya {
|
|
|
8842
8967
|
this._recycleSound(e);
|
|
8843
8968
|
};
|
|
8844
8969
|
_recycleSound(e) {
|
|
8845
|
-
e.destroy(),
|
|
8970
|
+
e.destroy(), Ca._soundPool.includes(e) || Ca._soundPool.push(e);
|
|
8846
8971
|
}
|
|
8847
8972
|
_prevTime = 0;
|
|
8848
8973
|
_timer = 0;
|
|
@@ -8858,10 +8983,10 @@ var Ca = class e extends ya {
|
|
|
8858
8983
|
}, 100);
|
|
8859
8984
|
}
|
|
8860
8985
|
};
|
|
8861
|
-
|
|
8986
|
+
wa = Ca = k([b("Audio"), O("design:paramtypes", [Object])], wa);
|
|
8862
8987
|
//#endregion
|
|
8863
8988
|
//#region src/scene/audio/AudioSpectrum.ts
|
|
8864
|
-
var
|
|
8989
|
+
var Ta = class extends wr {}, Ea = class extends ea {
|
|
8865
8990
|
_audioBuffer;
|
|
8866
8991
|
_src = (() => {
|
|
8867
8992
|
let e = S();
|
|
@@ -8885,7 +9010,7 @@ var Oa = class extends wr {}, ka = class extends ea {
|
|
|
8885
9010
|
}
|
|
8886
9011
|
}
|
|
8887
9012
|
async _loadSrc(e) {
|
|
8888
|
-
await globalThis.fetch(e).then((e) => e.arrayBuffer()).then((e) =>
|
|
9013
|
+
await globalThis.fetch(e).then((e) => e.arrayBuffer()).then((e) => ba.decode(e)).then((e) => {
|
|
8889
9014
|
this._audioBuffer = e, this.syncTexture(!0);
|
|
8890
9015
|
});
|
|
8891
9016
|
}
|
|
@@ -8920,12 +9045,12 @@ var Oa = class extends wr {}, ka = class extends ea {
|
|
|
8920
9045
|
this.syncTexture(), super._process(e);
|
|
8921
9046
|
}
|
|
8922
9047
|
};
|
|
8923
|
-
k([_(), O("design:type", Object)],
|
|
9048
|
+
k([_(), O("design:type", Object)], Ea.prototype, "src", void 0), k([_({ fallback: 0 }), O("design:type", Number)], Ea.prototype, "gap", void 0), k([_({ fallback: "#000000" }), O("design:type", String)], Ea.prototype, "color", void 0), Ea = k([b("AudioWaveform"), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial])], Ea);
|
|
8924
9049
|
//#endregion
|
|
8925
9050
|
//#region src/scene/transitions/KawaseTransition.ts
|
|
8926
|
-
var
|
|
9051
|
+
var Da, Oa = class extends Cr {
|
|
8927
9052
|
static {
|
|
8928
|
-
|
|
9053
|
+
Da = this;
|
|
8929
9054
|
}
|
|
8930
9055
|
blur = 10;
|
|
8931
9056
|
quality = 10;
|
|
@@ -8944,7 +9069,7 @@ var Aa, ja = class extends Cr {
|
|
|
8944
9069
|
let d = 1 / s, f = 1 / c, p = [], m, h = o - 1;
|
|
8945
9070
|
for (let e = 0; e < h; e++) m = u[e] + .5, p[0] = m * d, p[1] = m * f, l.push({ offset: p });
|
|
8946
9071
|
m = u[h] + .5, p[0] = m * d, p[1] = m * f, l.push({ offset: p }), l.forEach((t) => {
|
|
8947
|
-
L.draw(e,
|
|
9072
|
+
L.draw(e, Da.material, {
|
|
8948
9073
|
sampler: r,
|
|
8949
9074
|
progress: i,
|
|
8950
9075
|
...t
|
|
@@ -8952,31 +9077,31 @@ var Aa, ja = class extends Cr {
|
|
|
8952
9077
|
});
|
|
8953
9078
|
}
|
|
8954
9079
|
};
|
|
8955
|
-
|
|
9080
|
+
Oa = Da = k([b("KawaseTransition")], Oa);
|
|
8956
9081
|
//#endregion
|
|
8957
9082
|
//#region src/scene/transitions/LeftEraseTransition.ts
|
|
8958
|
-
var
|
|
9083
|
+
var ka, Aa = class extends Cr {
|
|
8959
9084
|
static {
|
|
8960
|
-
|
|
9085
|
+
ka = this;
|
|
8961
9086
|
}
|
|
8962
9087
|
static material = new I({ gl: {
|
|
8963
9088
|
vertex: "attribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUv;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n vUv = uv;\n}",
|
|
8964
9089
|
fragment: "precision highp float;\nvarying vec2 vUv;\nuniform float progress;\nuniform sampler2D previous;\nuniform sampler2D next;\n\nfloat easeInOutQuint(float t) {\n return t < 0.5 ? 16.0*t*t*t*t*t : 1.0+16.0*(--t)*t*t*t*t;\n}\n\nvoid main() {\n vec4 src1Color = texture2D(previous, vUv);\n vec4 src2Color = texture2D(next, vUv);\n float mProgress = 1.0 - progress;\n float mixPercent = 0.0;\n if (vUv.x <= mProgress) {\n mixPercent = 1.0;\n }\n gl_FragColor = mix(src2Color, src1Color, mixPercent);\n}"
|
|
8965
9090
|
} });
|
|
8966
9091
|
apply(e) {
|
|
8967
|
-
L.draw(e,
|
|
9092
|
+
L.draw(e, ka.material, {
|
|
8968
9093
|
previous: 0,
|
|
8969
9094
|
next: 1,
|
|
8970
9095
|
progress: this.currentTimeProgress
|
|
8971
9096
|
});
|
|
8972
9097
|
}
|
|
8973
9098
|
};
|
|
8974
|
-
|
|
9099
|
+
Aa = ka = k([b("LeftEraseTransition")], Aa);
|
|
8975
9100
|
//#endregion
|
|
8976
9101
|
//#region src/scene/transitions/TiltShiftTransition.ts
|
|
8977
|
-
var
|
|
9102
|
+
var ja, Ma = class extends Cr {
|
|
8978
9103
|
static {
|
|
8979
|
-
|
|
9104
|
+
ja = this;
|
|
8980
9105
|
}
|
|
8981
9106
|
blur = 100;
|
|
8982
9107
|
gradientBlur = 600;
|
|
@@ -8988,7 +9113,7 @@ var Pa, Fa = class extends Cr {
|
|
|
8988
9113
|
let n = this.currentTimeProgress, r, i;
|
|
8989
9114
|
n < .5 ? (r = 0, i = (.5 - n) / .5) : (r = 1, i = (n - .5) / .5);
|
|
8990
9115
|
let a = t.width, o = t.height, s = [0, o / 2], c = [600, o / 2], l = [a, o], u = c[0] - s[0], d = c[1] - s[1], f = Math.sqrt(u * u + d * d);
|
|
8991
|
-
L.draw(e,
|
|
9116
|
+
L.draw(e, ja.material, {
|
|
8992
9117
|
sampler: r,
|
|
8993
9118
|
progress: i,
|
|
8994
9119
|
blur: this.blur,
|
|
@@ -8997,7 +9122,7 @@ var Pa, Fa = class extends Cr {
|
|
|
8997
9122
|
end: c,
|
|
8998
9123
|
delta: [u / f, d / f],
|
|
8999
9124
|
texSize: l
|
|
9000
|
-
}), L.draw(e,
|
|
9125
|
+
}), L.draw(e, ja.material, {
|
|
9001
9126
|
sampler: r,
|
|
9002
9127
|
progress: i,
|
|
9003
9128
|
blur: this.blur,
|
|
@@ -9009,12 +9134,12 @@ var Pa, Fa = class extends Cr {
|
|
|
9009
9134
|
});
|
|
9010
9135
|
}
|
|
9011
9136
|
};
|
|
9012
|
-
|
|
9137
|
+
Ma = ja = k([b("TiltShiftTransition")], Ma);
|
|
9013
9138
|
//#endregion
|
|
9014
9139
|
//#region src/scene/transitions/TwistTransition.ts
|
|
9015
|
-
var
|
|
9140
|
+
var Na, Pa = class extends Cr {
|
|
9016
9141
|
static {
|
|
9017
|
-
|
|
9142
|
+
Na = this;
|
|
9018
9143
|
}
|
|
9019
9144
|
radius;
|
|
9020
9145
|
angle = 4;
|
|
@@ -9028,7 +9153,7 @@ var Ia, La = class extends Cr {
|
|
|
9028
9153
|
let n = this.currentTimeProgress, r, i;
|
|
9029
9154
|
n < .5 ? (r = 0, i = (.5 - n) / .5) : (r = 1, i = (n - .5) / .5);
|
|
9030
9155
|
let a = t.width, o = t.height;
|
|
9031
|
-
L.draw(e,
|
|
9156
|
+
L.draw(e, Na.material, {
|
|
9032
9157
|
sampler: r,
|
|
9033
9158
|
progress: i,
|
|
9034
9159
|
filterArea: [
|
|
@@ -9044,10 +9169,10 @@ var Ia, La = class extends Cr {
|
|
|
9044
9169
|
});
|
|
9045
9170
|
}
|
|
9046
9171
|
};
|
|
9047
|
-
|
|
9172
|
+
Pa = Na = k([b("TwistTransition")], Pa);
|
|
9048
9173
|
//#endregion
|
|
9049
9174
|
//#region src/asset/loaders/GifLoader.ts
|
|
9050
|
-
var
|
|
9175
|
+
var Fa = class extends Vn {
|
|
9051
9176
|
install(e) {
|
|
9052
9177
|
let t = async (t) => {
|
|
9053
9178
|
let { decodeFrames: n } = await import("modern-gif");
|
|
@@ -9064,14 +9189,14 @@ var Ra = class extends Vn {
|
|
|
9064
9189
|
e.register(n, t);
|
|
9065
9190
|
}), e.gif = this, this;
|
|
9066
9191
|
}
|
|
9067
|
-
},
|
|
9192
|
+
}, Ia = class extends Vn {
|
|
9068
9193
|
install(e) {
|
|
9069
9194
|
let t = async (e) => JSON.parse(await e.text());
|
|
9070
9195
|
return this.load = (n) => typeof n == "string" ? e.loadBy(n).then(t) : t(n), ["application/json"].forEach((n) => {
|
|
9071
9196
|
e.register(n, t);
|
|
9072
9197
|
}), e.json = this, this;
|
|
9073
9198
|
}
|
|
9074
|
-
},
|
|
9199
|
+
}, La = class extends Vn {
|
|
9075
9200
|
install(e) {
|
|
9076
9201
|
return this.load = async (t, n) => (await import("lottie-web").then((e) => e.default)).loadAnimation({
|
|
9077
9202
|
container: null,
|
|
@@ -9082,12 +9207,12 @@ var Ra = class extends Vn {
|
|
|
9082
9207
|
animationData: await e.loadBy(t, () => e.fetch(t).then((e) => e.json()))
|
|
9083
9208
|
}), e.lottie = this, this;
|
|
9084
9209
|
}
|
|
9085
|
-
},
|
|
9210
|
+
}, Ra = class extends Vn {
|
|
9086
9211
|
install(e) {
|
|
9087
9212
|
let t = async (e) => e.text();
|
|
9088
9213
|
return this.load = (n) => typeof n == "string" ? e.loadBy(n).then(t) : t(n), e.text = this, this;
|
|
9089
9214
|
}
|
|
9090
|
-
},
|
|
9215
|
+
}, za = class extends Vn {
|
|
9091
9216
|
install(e) {
|
|
9092
9217
|
let t = (t) => e.fetchImageBitmap(t, { premultiplyAlpha: "premultiply" }).then((e) => new z({
|
|
9093
9218
|
source: e,
|
|
@@ -9111,11 +9236,11 @@ var Ra = class extends Vn {
|
|
|
9111
9236
|
e.register(n, t);
|
|
9112
9237
|
}), e.texture = this, this;
|
|
9113
9238
|
}
|
|
9114
|
-
},
|
|
9239
|
+
}, Ba = class extends Vn {
|
|
9115
9240
|
install(e) {
|
|
9116
9241
|
return this.load = (t) => e.awaitBy(() => new ar(t).load()), e.video = this, this;
|
|
9117
9242
|
}
|
|
9118
|
-
},
|
|
9243
|
+
}, Va = Object.entries({
|
|
9119
9244
|
"font/woff": ["woff"],
|
|
9120
9245
|
"font/ttf": ["ttf"],
|
|
9121
9246
|
"font/otf": ["otf"],
|
|
@@ -9131,31 +9256,31 @@ var Ra = class extends Vn {
|
|
|
9131
9256
|
"image/webp": ["webp"],
|
|
9132
9257
|
"application/json": ["json"]
|
|
9133
9258
|
});
|
|
9134
|
-
function
|
|
9135
|
-
for (let [t, n] of
|
|
9259
|
+
function Ha(e) {
|
|
9260
|
+
for (let [t, n] of Va) if (n.includes(e)) return t;
|
|
9136
9261
|
}
|
|
9137
|
-
function
|
|
9262
|
+
function Ua(e) {
|
|
9138
9263
|
let t;
|
|
9139
9264
|
if (e.startsWith("data:")) t = e.match(/^data:(.+?);/)?.[1];
|
|
9140
9265
|
else if (e.startsWith("http")) {
|
|
9141
9266
|
let n = e.split(/[#?]/)[0].split(".").pop()?.trim();
|
|
9142
|
-
n && (t =
|
|
9267
|
+
n && (t = Ha(n));
|
|
9143
9268
|
}
|
|
9144
9269
|
return t;
|
|
9145
9270
|
}
|
|
9146
9271
|
//#endregion
|
|
9147
9272
|
//#region src/asset/Assets.ts
|
|
9148
|
-
var
|
|
9273
|
+
var Wa = "WeakRef" in globalThis, Ga = class extends e {
|
|
9149
9274
|
defaultHandler = (e) => e;
|
|
9150
9275
|
_handlers = /* @__PURE__ */ new Map();
|
|
9151
9276
|
_handleing = /* @__PURE__ */ new Map();
|
|
9152
9277
|
_handled = /* @__PURE__ */ new Map();
|
|
9153
|
-
_gc =
|
|
9278
|
+
_gc = Wa ? new FinalizationRegistry((e) => {
|
|
9154
9279
|
let t = this.get(e);
|
|
9155
9280
|
t && "destroy" in t && t.destroy(), this._handled.delete(e);
|
|
9156
9281
|
}) : void 0;
|
|
9157
9282
|
constructor() {
|
|
9158
|
-
super(),
|
|
9283
|
+
super(), Wa || x.on(this.gc.bind(this), { sort: 2 });
|
|
9159
9284
|
}
|
|
9160
9285
|
use(e) {
|
|
9161
9286
|
return e.install(this), this;
|
|
@@ -9204,11 +9329,11 @@ var qa = "WeakRef" in globalThis, Ja = class extends e {
|
|
|
9204
9329
|
}
|
|
9205
9330
|
get(e) {
|
|
9206
9331
|
let t = this._handled.get(e);
|
|
9207
|
-
return
|
|
9332
|
+
return Wa && t instanceof WeakRef && (t = t.deref(), t || this._handleing.delete(e)), t;
|
|
9208
9333
|
}
|
|
9209
9334
|
set(e, t) {
|
|
9210
9335
|
let n = t;
|
|
9211
|
-
|
|
9336
|
+
Wa && typeof t == "object" && (this._gc.register(t, e), n = new WeakRef(t)), this._handled.set(e, n);
|
|
9212
9337
|
}
|
|
9213
9338
|
async awaitBy(e) {
|
|
9214
9339
|
let t = e(), n = c();
|
|
@@ -9223,7 +9348,7 @@ var qa = "WeakRef" in globalThis, Ja = class extends e {
|
|
|
9223
9348
|
return this._handleing.set(e, r), r;
|
|
9224
9349
|
}
|
|
9225
9350
|
async load(e, t) {
|
|
9226
|
-
let n = await this.loadBy(e), r =
|
|
9351
|
+
let n = await this.loadBy(e), r = Ua(e);
|
|
9227
9352
|
return r === void 0 && (r = n.type?.split(";")[0] ?? void 0), ((r ? this._handlers.get(r) : void 0) ?? this.defaultHandler)(n, t);
|
|
9228
9353
|
}
|
|
9229
9354
|
async waitUntilLoad() {
|
|
@@ -9237,14 +9362,14 @@ var qa = "WeakRef" in globalThis, Ja = class extends e {
|
|
|
9237
9362
|
n && "destroy" in n && n.destroy();
|
|
9238
9363
|
}), this._handled.clear();
|
|
9239
9364
|
}
|
|
9240
|
-
}, $ = new
|
|
9365
|
+
}, $ = new Ga().use(new Hn()).use(new Fa()).use(new Ia()).use(new La()).use(new Ra()).use(new za()).use(new Ba()), Ka = {
|
|
9241
9366
|
alpha: !0,
|
|
9242
9367
|
stencil: !0,
|
|
9243
9368
|
antialias: !1,
|
|
9244
9369
|
premultipliedAlpha: !0,
|
|
9245
9370
|
preserveDrawingBuffer: !1,
|
|
9246
9371
|
powerPreference: "default"
|
|
9247
|
-
},
|
|
9372
|
+
}, qa = class extends Sr {
|
|
9248
9373
|
renderer;
|
|
9249
9374
|
get view() {
|
|
9250
9375
|
return this.renderer.view;
|
|
@@ -9277,12 +9402,12 @@ var qa = "WeakRef" in globalThis, Ja = class extends e {
|
|
|
9277
9402
|
constructor(e = {}) {
|
|
9278
9403
|
let { view: t, width: n, height: r, pixelRatio: i = Ye, autoResize: a, data: o } = e;
|
|
9279
9404
|
super(), this.renderer = new Bn(t, {
|
|
9280
|
-
alpha:
|
|
9281
|
-
stencil:
|
|
9282
|
-
antialias:
|
|
9283
|
-
premultipliedAlpha:
|
|
9284
|
-
preserveDrawingBuffer:
|
|
9285
|
-
powerPreference:
|
|
9405
|
+
alpha: Ka.alpha ?? e.alpha,
|
|
9406
|
+
stencil: Ka.stencil ?? e.stencil,
|
|
9407
|
+
antialias: Ka.antialias ?? e.antialias,
|
|
9408
|
+
premultipliedAlpha: Ka.premultipliedAlpha ?? e.premultipliedAlpha,
|
|
9409
|
+
preserveDrawingBuffer: Ka.preserveDrawingBuffer ?? e.preserveDrawingBuffer,
|
|
9410
|
+
powerPreference: Ka.powerPreference ?? e.powerPreference
|
|
9286
9411
|
}), this._setupInput(), this.pixelRatio = i, a ? !t && this.renderer.view && (this.renderer.view.style.width = "100%", this.renderer.view.style.height = "100%") : this.resize(n || this.gl.drawingBufferWidth || this.view?.clientWidth || 200, r || this.gl.drawingBufferHeight || this.view?.clientHeight || 200, !t), this.setProperties(e), o && this.root.append(o);
|
|
9287
9412
|
}
|
|
9288
9413
|
_updateProperty(e, t, n) {
|
|
@@ -9365,22 +9490,22 @@ var qa = "WeakRef" in globalThis, Ja = class extends e {
|
|
|
9365
9490
|
super._destroy(), this._resizeObserver?.disconnect(), this.renderer.destroy();
|
|
9366
9491
|
}
|
|
9367
9492
|
};
|
|
9368
|
-
k([_({ fallback: !1 }), O("design:type", Boolean)],
|
|
9493
|
+
k([_({ fallback: !1 }), O("design:type", Boolean)], qa.prototype, "autoResize", void 0), k([_({ fallback: !1 }), O("design:type", Boolean)], qa.prototype, "autoStart", void 0);
|
|
9369
9494
|
//#endregion
|
|
9370
9495
|
//#region src/render.ts
|
|
9371
|
-
var
|
|
9372
|
-
function
|
|
9373
|
-
return
|
|
9496
|
+
var Ja, Ya = [], Xa = !1;
|
|
9497
|
+
function Za() {
|
|
9498
|
+
return Ja ??= new qa({
|
|
9374
9499
|
pixelRatio: 1,
|
|
9375
9500
|
width: 1,
|
|
9376
9501
|
height: 1,
|
|
9377
9502
|
preserveDrawingBuffer: !0
|
|
9378
9503
|
});
|
|
9379
9504
|
}
|
|
9380
|
-
async function
|
|
9381
|
-
if (
|
|
9382
|
-
for (
|
|
9383
|
-
let t =
|
|
9505
|
+
async function Qa(e = 100) {
|
|
9506
|
+
if (!Xa) {
|
|
9507
|
+
for (Xa = !0; Ya.length;) {
|
|
9508
|
+
let t = Ya.shift();
|
|
9384
9509
|
if (t) try {
|
|
9385
9510
|
await t();
|
|
9386
9511
|
} catch (e) {
|
|
@@ -9388,11 +9513,11 @@ async function to(e = 100) {
|
|
|
9388
9513
|
}
|
|
9389
9514
|
else await new Promise((t) => setTimeout(t, e));
|
|
9390
9515
|
}
|
|
9391
|
-
|
|
9516
|
+
Xa = !1;
|
|
9392
9517
|
}
|
|
9393
9518
|
}
|
|
9394
|
-
async function
|
|
9395
|
-
let { debug: t = !1, fonts: n, width: r, height: i, data: a, keyframes: o = [], onBefore: s, onKeyframe: c, ...l } = e, u = Math.floor(r), d = Math.floor(i), f =
|
|
9519
|
+
async function $a(e) {
|
|
9520
|
+
let { debug: t = !1, fonts: n, width: r, height: i, data: a, keyframes: o = [], onBefore: s, onKeyframe: c, ...l } = e, u = Math.floor(r), d = Math.floor(i), f = Za();
|
|
9396
9521
|
if (f.resetProperties(), f.setProperties(l), f.debug = t, f.fonts = n, f.timeline.currentTime = 0, f.resize(u, d, !0), f.root.removeChildren(!0), f.root.append(a), await s?.(f), await f.waitAndRender(), o.length) {
|
|
9397
9522
|
let e = o.length, t = o[e - 1];
|
|
9398
9523
|
for (let n = 0; n < e; n++) {
|
|
@@ -9410,15 +9535,15 @@ async function no(e) {
|
|
|
9410
9535
|
toCanvas2D: () => f.toCanvas2D(new ImageData(p, u, d))
|
|
9411
9536
|
};
|
|
9412
9537
|
}
|
|
9413
|
-
async function
|
|
9538
|
+
async function eo(e) {
|
|
9414
9539
|
return new Promise((t) => {
|
|
9415
|
-
|
|
9540
|
+
Ya.push(async () => t(await $a(e).then((e) => e.toCanvas2D()))), Qa();
|
|
9416
9541
|
});
|
|
9417
9542
|
}
|
|
9418
|
-
async function
|
|
9543
|
+
async function to(e) {
|
|
9419
9544
|
return new Promise((t) => {
|
|
9420
|
-
|
|
9545
|
+
Ya.push(async () => t(await $a(e).then((e) => e.pixels))), Qa();
|
|
9421
9546
|
});
|
|
9422
9547
|
}
|
|
9423
9548
|
//#endregion
|
|
9424
|
-
export { yt as Aabb2D, $n as AnimatedTexture,
|
|
9549
|
+
export { yt as Aabb2D, $n as AnimatedTexture, fa as Animation, Ga as Assets, wa as Audio, ga as AudioPipeline, _a as AudioProcessor, Ta as AudioSpectrum, Ea as AudioWaveform, A as BufferUsage, Tr as Camera2D, sr as CanvasContext, _r as CanvasItem, er as CanvasTexture, T as Color, W as ColorAdjustEffect, Rr as ColorFilterEffect, St as ColorMatrix, Vr as ColorOverlayEffect, Ur as ColorRemoveEffect, Kr as ColorReplaceEffect, tr as ColorTexture, C as CoreObject, bt as DEG_TO_RAD, Ye as DEVICE_PIXEL_RATIO, G as DrawboardEffect, $r as DropShadowEffect, U as Effect, Xn as EffectMaterial, ea as Element2D, _i as Element2DBackground, X as Element2DChart, xi as Element2DConnection, Y as Element2DFill, ki as Element2DForeground, ji as Element2DOutline, Mi as Element2DShadow, Ni as Element2DShape, Pi as Element2DStyle, Ri as Element2DTable, Z as Element2DText, ti as EmbossEffect, qa as Engine, Yi as Flexbox, Hn as FontLoader, Zr as GaussianBlurEffect, Wn as Geometry, Fa as GifLoader, ln as GlBatch2DSystem, an as GlBlendMode, Dt as GlBuffer, Pt as GlBufferSystem, Et as GlBufferTarget, pn as GlMaskSystem, Kt as GlProgram, _n as GlRenderTarget, vn as GlRenderTargetSystem, tn as GlShaderSystem, sn as GlState, cn as GlStateSystem, hn as GlStencilSystem, j as GlSystem, gn as GlViewportSystem, K as GlitchEffect, q as GodrayEffect, nr as GradientTexture, ha as HTMLAudio, pa as HTMLAudioContext, ma as HTMLSound, qe as IN_BROWSER, Je as IN_MAC_OS, Un as IndexBuffer, _t as Input, dt as InputEvent, Ia as JsonLoader, si as KawaseBlurEffect, Oa as KawaseTransition, ft as KeyboardInputEvent, Aa as LeftEraseTransition, Vn as Loader, na as Lottie2D, La as LottieLoader, Tt as MainLoop, li as MaskEffect, I as Material, ra as Mesh2D, lr as Meta, pt as MouseInputEvent, B as Node, wr as Node2D, Ct as Obb2D, J as OutlineEffect, Se as PI, Ce as PI_2, pi as PixelateEffect, rr as PixelsTexture, mt as PointerInputEvent, wt as Projection2D, Gn as QuadGeometry, L as QuadUvGeometry, xt as RAD_TO_DEG, vt as RefCounted, R as RenderTarget, Ot as Renderer, w as Resource, He as SUPPORTS_AUDIO_CONTEXT, Be as SUPPORTS_CLICK_EVENTS, Ve as SUPPORTS_CREATE_IMAGE_BITMAP, Pe as SUPPORTS_IMAGE_BITMAP, Re as SUPPORTS_MOUSE_EVENTS, We as SUPPORTS_OFFLINE_AUDIO_CONTEXT, Ie as SUPPORTS_POINTER_EVENTS, Fe as SUPPORTS_RESIZE_OBSERVER, ze as SUPPORTS_TOUCH_EVENTS, Ne as SUPPORTS_WEBGL2, Ue as SUPPORTS_WEBKIT_AUDIO_CONTEXT, Ge as SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, Ke as SUPPORTS_WEB_AUDIO, Le as SUPPORTS_WHEEL_EVENTS, Sr as SceneTree, Ra as TextLoader, z as Texture2D, za as TextureLoader, ta as TextureRect2D, x as Ticker, Ma as TiltShiftTransition, br as Timeline, V as TimelineNode, ia as TransformRect2D, Cr as Transition, Pa as TwistTransition, At as UniformGroup, Qn as UvGeometry, Zn as UvMaterial, F as VertexAttribute, P as VertexBuffer, aa as Video2D, Ba as VideoLoader, ar as VideoTexture, H as Viewport, or as ViewportTexture, Sa as WebAudio, ba as WebAudioContext, Bn as WebGLRenderer, xa as WebSound, ht as WheelInputEvent, xr as Window, hi as ZoomBlurEffect, Bi as alignMap, $ as assets, Er as axisDir, Ji as boxSizingMap, E as clamp, oi as clampFrag, S as createHTMLCanvas, Nt as createIdFromString, be as createNode, ct as crossOrigin, ua as cssEasingPresets, la as cubicBezier, b as customNode, ye as customNodes, Ka as defaultOptions, st as determineCrossOrigin, Hi as directionMap, Vi as displayMap, Q as edgeMap, Ui as flexDirectionMap, Wi as flexWrapMap, ai as frag, rt as getCanvasFactory, Oe as getDefaultCssPropertyValue, ot as getGlContextProvider, Za as getRenderEngine, zi as gutterMap, ut as instanceId, $e as isCanvasElement, Xe as isElementNode, Qe as isImageElement, we as isPow2, Ze as isVideoElement, et as isWebgl2, Gi as justifyMap, D as lerp, dn as log2, on as mapGlBlendModes, un as nextPow2, xe as nextTick, Ki as overflowMap, Pr as parseCssFilter, Ae as parseCssFunctions, ke as parseCssProperty, Fr as parseCssTransformOrigin, qi as positionTypeMap, eo as render, to as renderPixels, hr as resetBatchPool, Dr as routeConnection, nt as setCanvasFactory, at as setGlContextProvider, mn as stencilModeMap };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Node } from '../main';
|
|
2
|
+
import type { Texture2D } from '../resources';
|
|
3
|
+
import type { Element2DProperties } from './element';
|
|
4
|
+
import { Element2D } from './element';
|
|
5
|
+
export interface Mesh2DProperties extends Element2DProperties {
|
|
6
|
+
/** 顶点(局部像素坐标,[x,y,...]) */
|
|
7
|
+
vertices?: Float32Array | number[];
|
|
8
|
+
/** UV(归一化 0..1,[u,v,...]),与顶点一一对应 */
|
|
9
|
+
uvs?: Float32Array | number[];
|
|
10
|
+
/** 三角索引([i0,i1,i2,...]) */
|
|
11
|
+
indices?: Uint32Array | number[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 可变形三角网格节点:自定义顶点 + UV + 三角索引,用当前 texture 贴图绘制。
|
|
15
|
+
* 顶点在局部空间,随节点 globalTransform 变换到世界(同 fill 批次);UV 不由顶点派生。
|
|
16
|
+
* 适合精灵网格 / 骨骼网格(mesh)变形 —— 改 `vertices` 即变形,无需重建几何。
|
|
17
|
+
*/
|
|
18
|
+
export declare class Mesh2D<T extends Texture2D = Texture2D> extends Element2D {
|
|
19
|
+
texture?: T;
|
|
20
|
+
protected _vertices: Float32Array;
|
|
21
|
+
protected _uvs: Float32Array;
|
|
22
|
+
protected _indices: Uint32Array;
|
|
23
|
+
get vertices(): Float32Array;
|
|
24
|
+
set vertices(value: Float32Array | number[]);
|
|
25
|
+
get uvs(): Float32Array;
|
|
26
|
+
set uvs(value: Float32Array | number[]);
|
|
27
|
+
get indices(): Uint32Array;
|
|
28
|
+
set indices(value: Uint32Array | number[]);
|
|
29
|
+
constructor(properties?: Partial<Mesh2DProperties>, children?: Node[]);
|
|
30
|
+
protected _drawContent(): void;
|
|
31
|
+
}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import type { Node } from '../main';
|
|
2
2
|
import type { Texture2D } from '../resources';
|
|
3
3
|
import type { Element2DProperties } from './element';
|
|
4
|
+
import { Transform2D } from 'modern-path2d';
|
|
4
5
|
import { Element2D } from './element';
|
|
6
|
+
/** 纹理子区域(图集 sub-rect),单位为纹理像素。设置后只绘制该矩形区域,用于精灵图集 / 骨骼插槽。 */
|
|
7
|
+
export interface TextureRect2DRegion {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
5
13
|
export interface TextureRect2DProperties extends Element2DProperties {
|
|
14
|
+
/** 纹理子区域(像素)。省略则绘制整张纹理。 */
|
|
15
|
+
region?: TextureRect2DRegion;
|
|
6
16
|
}
|
|
7
17
|
export declare class TextureRect2D<T extends Texture2D = Texture2D> extends Element2D {
|
|
8
18
|
texture?: T;
|
|
19
|
+
/** 纹理子区域(像素)。省略则绘制整张纹理。 */
|
|
20
|
+
region?: TextureRect2DRegion;
|
|
9
21
|
constructor(properties?: Partial<TextureRect2DProperties>, children?: Node[]);
|
|
22
|
+
/** 把节点显示尺寸坐标(0..size)映射到纹理 UV(0..1)的变换;有 region 时映射到子矩形。 */
|
|
23
|
+
protected _uvTransform(): Transform2D;
|
|
10
24
|
protected _drawContent(): void;
|
|
11
25
|
}
|
package/dist/scene/2d/index.d.ts
CHANGED
|
@@ -3,21 +3,23 @@ import { RawWeakMap } from 'modern-idoc';
|
|
|
3
3
|
import { PathMeasure } from 'modern-path2d';
|
|
4
4
|
import { Element2D } from '../2d';
|
|
5
5
|
import { TimelineNode } from '../main';
|
|
6
|
-
export declare const linear: (amount: number) => number;
|
|
7
|
-
export declare const ease: (amount: number) => number;
|
|
8
|
-
export declare const easeIn: (amount: number) => number;
|
|
9
|
-
export declare const easeOut: (amount: number) => number;
|
|
10
|
-
export declare const easeInOut: (amount: number) => number;
|
|
11
6
|
export declare function cubicBezier(x1: number, y1: number, x2: number, y2: number): (amount: number) => number;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
/** CSS 缓动预设:name → cubic-bezier 控制点 [x1, y1, x2, y2] */
|
|
8
|
+
export declare const cssEasingPresets: {
|
|
9
|
+
readonly linear: readonly [0, 0, 1, 1];
|
|
10
|
+
readonly ease: readonly [0.25, 0.1, 0.25, 1];
|
|
11
|
+
readonly 'ease-in': readonly [0.42, 0, 1, 1];
|
|
12
|
+
readonly 'ease-out': readonly [0, 0, 0.58, 1];
|
|
13
|
+
readonly 'ease-in-out': readonly [0.42, 0, 0.58, 1];
|
|
14
|
+
readonly 'ease-in-quad': readonly [0.55, 0.085, 0.68, 0.53];
|
|
15
|
+
readonly 'ease-out-quad': readonly [0.25, 0.46, 0.45, 0.94];
|
|
16
|
+
readonly 'ease-in-out-quad': readonly [0.455, 0.03, 0.515, 0.955];
|
|
17
|
+
readonly 'ease-in-cubic': readonly [0.55, 0.055, 0.675, 0.19];
|
|
18
|
+
readonly 'ease-out-cubic': readonly [0.215, 0.61, 0.355, 1];
|
|
19
|
+
readonly 'ease-in-out-cubic': readonly [0.645, 0.045, 0.355, 1];
|
|
18
20
|
};
|
|
19
|
-
export type
|
|
20
|
-
export type Easing =
|
|
21
|
+
export type CssEasing = keyof typeof cssEasingPresets;
|
|
22
|
+
export type Easing = CssEasing | `cubic-bezier(${string})`;
|
|
21
23
|
export interface Keyframe {
|
|
22
24
|
easing?: Easing;
|
|
23
25
|
offset?: number;
|
|
@@ -5,7 +5,7 @@ import { Texture2D } from '../resources';
|
|
|
5
5
|
export type TransformUv = (uvs: Float32Array, index: number) => void;
|
|
6
6
|
export type TransformVertex = (vertices: Float32Array, index: number) => void;
|
|
7
7
|
export interface CanvasBatchable extends Batchable2D {
|
|
8
|
-
type: 'stroke' | 'fill';
|
|
8
|
+
type: 'stroke' | 'fill' | 'mesh';
|
|
9
9
|
texture?: Texture2D;
|
|
10
10
|
transformUv?: TransformUv;
|
|
11
11
|
transformVertex?: TransformVertex;
|
|
@@ -13,6 +13,8 @@ export interface CanvasBatchable extends Batchable2D {
|
|
|
13
13
|
width: number;
|
|
14
14
|
height: number;
|
|
15
15
|
};
|
|
16
|
+
/** mesh 显式 UV(0..1),绕过「由顶点位置派生 UV」。 */
|
|
17
|
+
meshUvs?: Float32Array;
|
|
16
18
|
}
|
|
17
19
|
export interface StrokeDraw extends Partial<CanvasBatchable> {
|
|
18
20
|
type: 'stroke';
|
|
@@ -23,6 +25,13 @@ export interface FillDraw extends Partial<CanvasBatchable> {
|
|
|
23
25
|
type: 'fill';
|
|
24
26
|
path: Path2D;
|
|
25
27
|
}
|
|
28
|
+
/** 自定义三角网格绘制:顶点(局部像素)+ 显式 UV(0..1) + 三角索引,不经路径三角化。 */
|
|
29
|
+
export interface MeshDraw extends Partial<CanvasBatchable> {
|
|
30
|
+
type: 'mesh';
|
|
31
|
+
vertices: Float32Array;
|
|
32
|
+
indices: Uint32Array;
|
|
33
|
+
meshUvs: Float32Array;
|
|
34
|
+
}
|
|
26
35
|
export declare class CanvasContext extends Path2D {
|
|
27
36
|
fillStyle?: ColorValue | Texture2D;
|
|
28
37
|
fillRule?: FillRule;
|
|
@@ -34,7 +43,7 @@ export declare class CanvasContext extends Path2D {
|
|
|
34
43
|
miterLimit?: number;
|
|
35
44
|
transformUv?: TransformUv;
|
|
36
45
|
transformVertex?: TransformVertex;
|
|
37
|
-
protected _draws: (StrokeDraw | FillDraw)[];
|
|
46
|
+
protected _draws: (StrokeDraw | FillDraw | MeshDraw)[];
|
|
38
47
|
protected _triCache: {
|
|
39
48
|
sig: string;
|
|
40
49
|
vertices: Float32Array;
|
|
@@ -44,6 +53,11 @@ export declare class CanvasContext extends Path2D {
|
|
|
44
53
|
texture?: Texture2D;
|
|
45
54
|
};
|
|
46
55
|
stroke(options?: Partial<StrokeDraw>): void;
|
|
56
|
+
/**
|
|
57
|
+
* 绘制自定义三角网格(用当前 fillStyle 纹理)。顶点为局部像素坐标 [x,y,...],
|
|
58
|
+
* UV 为归一化 [u,v,...](0..1),indices 为三角索引。用于精灵网格 / 骨骼网格变形。
|
|
59
|
+
*/
|
|
60
|
+
drawMesh(vertices: ArrayLike<number>, uvs: ArrayLike<number>, indices: ArrayLike<number>): void;
|
|
47
61
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
48
62
|
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
49
63
|
fill(options?: Partial<FillDraw>): void;
|