modern-canvas 0.23.12 → 0.23.14
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({
|
|
3939
|
+
vertices: e,
|
|
3940
|
+
indices: t
|
|
3941
|
+
}) : r.strokeTriangulate({
|
|
3922
3942
|
vertices: e,
|
|
3923
|
-
indices:
|
|
3924
|
-
lineStyle:
|
|
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;
|
|
@@ -4392,6 +4412,11 @@ var V = class extends B {
|
|
|
4392
4412
|
_currentTime = 0;
|
|
4393
4413
|
_globalStartTime = 0;
|
|
4394
4414
|
_globalDuration = 0;
|
|
4415
|
+
_standalone = !1;
|
|
4416
|
+
_localCurrentTime = 0;
|
|
4417
|
+
get standalone() {
|
|
4418
|
+
return this._standalone;
|
|
4419
|
+
}
|
|
4395
4420
|
get parentGlobalStartTime() {
|
|
4396
4421
|
return this._parent?.globalStartTime ?? 0;
|
|
4397
4422
|
}
|
|
@@ -4436,12 +4461,18 @@ var V = class extends B {
|
|
|
4436
4461
|
_updateInsideTimeRange() {
|
|
4437
4462
|
this.insideTimeRange = this.isInsideTimeRange();
|
|
4438
4463
|
}
|
|
4464
|
+
setStandalone(e) {
|
|
4465
|
+
return this._standalone !== e && (this._standalone = e, this._updateCurrentTime(!0)), this;
|
|
4466
|
+
}
|
|
4467
|
+
setLocalTime(e) {
|
|
4468
|
+
return this._localCurrentTime = e, this._updateCurrentTime(!0), this;
|
|
4469
|
+
}
|
|
4439
4470
|
_updateCurrentTime(e = !1) {
|
|
4440
4471
|
if (e || !this._paused) {
|
|
4441
4472
|
let e = this._parent, t = this.parentGlobalStartTime + this._delay, n = e?.globalDuration ? Math.min(t + this._duration, e.globalEndTime) - t : this._duration;
|
|
4442
4473
|
this._globalStartTime = t, this._globalDuration = n;
|
|
4443
|
-
let r = this._globalCurrentTime - this.globalStartTime;
|
|
4444
|
-
this._loop && (r %= this.globalDuration), this._currentTime = r, this.emit("updateCurrentTime", this._currentTime), this._updateInsideTimeRange();
|
|
4474
|
+
let r = this._standalone ? this._localCurrentTime : this._globalCurrentTime - this.globalStartTime;
|
|
4475
|
+
this._loop && this.globalDuration && (r %= this.globalDuration), this._currentTime = r, this.emit("updateCurrentTime", this._currentTime), this._updateInsideTimeRange();
|
|
4445
4476
|
}
|
|
4446
4477
|
}
|
|
4447
4478
|
_process(e) {
|
|
@@ -4546,13 +4577,14 @@ var _r = class extends V {
|
|
|
4546
4577
|
this.emit("draw");
|
|
4547
4578
|
}
|
|
4548
4579
|
_transformUvs(e) {
|
|
4549
|
-
let { texture: t, vertices: n, transformUv: r } = e;
|
|
4580
|
+
let { texture: t, vertices: n, transformUv: r, meshUvs: i } = e;
|
|
4550
4581
|
if (!t) return;
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4582
|
+
if (i) return i;
|
|
4583
|
+
let { width: a, height: o } = t, s = r ?? ((e, t) => {
|
|
4584
|
+
e[t] = e[t] / a, e[t + 1] = e[t + 1] / o;
|
|
4585
|
+
}), c = n.slice();
|
|
4586
|
+
for (let e = c.length, t = 0; t < e; t += 2) s(c, t);
|
|
4587
|
+
return c;
|
|
4556
4588
|
}
|
|
4557
4589
|
_redraw() {
|
|
4558
4590
|
return this._draw(), this.context.toBatchables().map((e) => ({
|
|
@@ -7875,13 +7907,22 @@ ea = k([b("Element2D"), O("design:paramtypes", [typeof Partial > "u" ? Object :
|
|
|
7875
7907
|
//#region src/scene/2d/TextureRect2D.ts
|
|
7876
7908
|
var ta = class extends ea {
|
|
7877
7909
|
texture;
|
|
7910
|
+
region;
|
|
7878
7911
|
constructor(e, t = []) {
|
|
7879
7912
|
super(), this.setProperties(e).append(t);
|
|
7880
7913
|
}
|
|
7914
|
+
_uvTransform() {
|
|
7915
|
+
let e = this.region;
|
|
7916
|
+
if (e && this.texture) {
|
|
7917
|
+
let t = this.texture.width || 1, n = this.texture.height || 1;
|
|
7918
|
+
return new v(e.width / (this.size.x * t), 0, 0, e.height / (this.size.y * n), e.x / t, e.y / n);
|
|
7919
|
+
}
|
|
7920
|
+
return new v().scale(1 / this.size.x, 1 / this.size.y);
|
|
7921
|
+
}
|
|
7881
7922
|
_drawContent() {
|
|
7882
7923
|
if (this.texture?.isValid()) {
|
|
7883
7924
|
this.shape.draw(!0), this.context.fillStyle = this.texture;
|
|
7884
|
-
let { a: e, c: t, tx: n, b: r, d: i, ty: a } =
|
|
7925
|
+
let { a: e, c: t, tx: n, b: r, d: i, ty: a } = this._uvTransform(), o, s;
|
|
7885
7926
|
this.context.fill({ transformUv: (c, l) => {
|
|
7886
7927
|
o = c[l], s = c[l + 1], c[l] = e * o + t * s + n, c[l + 1] = r * o + i * s + a;
|
|
7887
7928
|
} });
|
|
@@ -7920,8 +7961,39 @@ var ta = class extends ea {
|
|
|
7920
7961
|
};
|
|
7921
7962
|
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
7963
|
//#endregion
|
|
7923
|
-
//#region src/scene/2d/
|
|
7964
|
+
//#region src/scene/2d/Mesh2D.ts
|
|
7924
7965
|
var ra = class extends ea {
|
|
7966
|
+
texture;
|
|
7967
|
+
_vertices = new Float32Array();
|
|
7968
|
+
_uvs = new Float32Array();
|
|
7969
|
+
_indices = new Uint32Array();
|
|
7970
|
+
get vertices() {
|
|
7971
|
+
return this._vertices;
|
|
7972
|
+
}
|
|
7973
|
+
set vertices(e) {
|
|
7974
|
+
this._vertices = e instanceof Float32Array ? e : new Float32Array(e), this.requestDraw();
|
|
7975
|
+
}
|
|
7976
|
+
get uvs() {
|
|
7977
|
+
return this._uvs;
|
|
7978
|
+
}
|
|
7979
|
+
set uvs(e) {
|
|
7980
|
+
this._uvs = e instanceof Float32Array ? e : new Float32Array(e), this.requestDraw();
|
|
7981
|
+
}
|
|
7982
|
+
get indices() {
|
|
7983
|
+
return this._indices;
|
|
7984
|
+
}
|
|
7985
|
+
set indices(e) {
|
|
7986
|
+
this._indices = e instanceof Uint32Array ? e : new Uint32Array(e), this.requestDraw();
|
|
7987
|
+
}
|
|
7988
|
+
constructor(e, t = []) {
|
|
7989
|
+
super();
|
|
7990
|
+
let { vertices: n, uvs: r, indices: i, ...a } = e ?? {};
|
|
7991
|
+
this.setProperties(a), n && (this.vertices = n), r && (this.uvs = r), i && (this.indices = i), this.append(t);
|
|
7992
|
+
}
|
|
7993
|
+
_drawContent() {
|
|
7994
|
+
this.texture?.isValid() && this._indices.length && this._vertices.length && (this.context.fillStyle = this.texture, this.context.drawMesh(this._vertices, this._uvs, this._indices));
|
|
7995
|
+
}
|
|
7996
|
+
}, ia = class extends ea {
|
|
7925
7997
|
constructor(e, t = []) {
|
|
7926
7998
|
super(), this.setProperties(e).append(t);
|
|
7927
7999
|
}
|
|
@@ -7944,10 +8016,10 @@ var ra = class extends ea {
|
|
|
7944
8016
|
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
8017
|
}
|
|
7946
8018
|
};
|
|
7947
|
-
k([_({ fallback: 6 }), O("design:type", Number)],
|
|
8019
|
+
k([_({ fallback: 6 }), O("design:type", Number)], ia.prototype, "handleSize", void 0);
|
|
7948
8020
|
//#endregion
|
|
7949
8021
|
//#region src/scene/2d/Video2D.ts
|
|
7950
|
-
var
|
|
8022
|
+
var aa = class extends ta {
|
|
7951
8023
|
get videoDuration() {
|
|
7952
8024
|
return (this.texture?.duration ?? 0) * 1e3;
|
|
7953
8025
|
}
|
|
@@ -7987,15 +8059,15 @@ var ia = class extends ta {
|
|
|
7987
8059
|
super._process(e), this._updateVideoCurrentTime();
|
|
7988
8060
|
}
|
|
7989
8061
|
};
|
|
7990
|
-
k([_({ fallback: "" }), O("design:type", String)],
|
|
8062
|
+
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
8063
|
//#endregion
|
|
7992
8064
|
//#region src/scene/animation/Animation.ts
|
|
7993
|
-
function
|
|
8065
|
+
function oa(e) {
|
|
7994
8066
|
if (e == null) return 0;
|
|
7995
8067
|
let t = String(e).trim(), n = Number.parseFloat(t);
|
|
7996
8068
|
return Number.isNaN(n) ? 0 : n / 100;
|
|
7997
8069
|
}
|
|
7998
|
-
function
|
|
8070
|
+
function sa(e, t) {
|
|
7999
8071
|
let n = t * 180 / Math.PI;
|
|
8000
8072
|
if (e == null || e === "auto") return n;
|
|
8001
8073
|
let r = String(e).trim();
|
|
@@ -8004,11 +8076,11 @@ function oa(e, t) {
|
|
|
8004
8076
|
let i = Number.parseFloat(r);
|
|
8005
8077
|
return Number.isNaN(i) ? n : i;
|
|
8006
8078
|
}
|
|
8007
|
-
function
|
|
8079
|
+
function ca(e) {
|
|
8008
8080
|
let t = e.trim(), n = /^path\((.*)\)$/s.exec(t);
|
|
8009
8081
|
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
8082
|
}
|
|
8011
|
-
function
|
|
8083
|
+
function la(e, t, n, r) {
|
|
8012
8084
|
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;
|
|
8013
8085
|
function m(e) {
|
|
8014
8086
|
let t = e, n, r;
|
|
@@ -8028,7 +8100,7 @@ function ca(e, t, n, r) {
|
|
|
8028
8100
|
}
|
|
8029
8101
|
return (e) => p(m(e));
|
|
8030
8102
|
}
|
|
8031
|
-
var
|
|
8103
|
+
var ua = {
|
|
8032
8104
|
linear: [
|
|
8033
8105
|
0,
|
|
8034
8106
|
0,
|
|
@@ -8095,7 +8167,7 @@ var la = {
|
|
|
8095
8167
|
.355,
|
|
8096
8168
|
1
|
|
8097
8169
|
]
|
|
8098
|
-
},
|
|
8170
|
+
}, da = Object.fromEntries(Object.entries(ua).map(([e, [t, n, r, i]]) => [e, la(t, n, r, i)])), fa = class extends V {
|
|
8099
8171
|
_keyframes = [];
|
|
8100
8172
|
_isFirstUpdatePosition = !1;
|
|
8101
8173
|
_cachedProps = new t();
|
|
@@ -8182,14 +8254,14 @@ var la = {
|
|
|
8182
8254
|
});
|
|
8183
8255
|
}
|
|
8184
8256
|
_parseEasing(e) {
|
|
8185
|
-
if (!e) return
|
|
8186
|
-
if (e in
|
|
8257
|
+
if (!e) return da.linear;
|
|
8258
|
+
if (e in da) return da[e];
|
|
8187
8259
|
let t = /cubic-bezier\((.+)\)/.exec(e);
|
|
8188
8260
|
if (t) {
|
|
8189
8261
|
let e = t[1].split(",").map((e) => Number(e));
|
|
8190
|
-
if (e.length === 4 && e.every((e) => !Number.isNaN(e))) return
|
|
8262
|
+
if (e.length === 4 && e.every((e) => !Number.isNaN(e))) return la(e[0], e[1], e[2], e[3]);
|
|
8191
8263
|
}
|
|
8192
|
-
return
|
|
8264
|
+
return da.linear;
|
|
8193
8265
|
}
|
|
8194
8266
|
_parseKeyframes(e, t) {
|
|
8195
8267
|
let n, r = this._keyframes;
|
|
@@ -8224,7 +8296,7 @@ var la = {
|
|
|
8224
8296
|
});
|
|
8225
8297
|
}
|
|
8226
8298
|
_commitOffsetPath(e, t, n, r, i, a) {
|
|
8227
|
-
let o =
|
|
8299
|
+
let o = ca(t);
|
|
8228
8300
|
if (!o) return;
|
|
8229
8301
|
let s = this._pathMeasures.get(o);
|
|
8230
8302
|
if (!s) {
|
|
@@ -8235,7 +8307,7 @@ var la = {
|
|
|
8235
8307
|
startY: t.y
|
|
8236
8308
|
}, this._pathMeasures.set(o, s);
|
|
8237
8309
|
}
|
|
8238
|
-
let c = E(D(
|
|
8310
|
+
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");
|
|
8239
8311
|
e.onUpdateStyleProperty("transform", `${m ? `${m} ` : ""}translate(${d}px, ${f}px) rotate(${p}deg)`, void 0);
|
|
8240
8312
|
}
|
|
8241
8313
|
_getDiffValue(e, t, n, r, i) {
|
|
@@ -8282,14 +8354,14 @@ var la = {
|
|
|
8282
8354
|
});
|
|
8283
8355
|
}
|
|
8284
8356
|
};
|
|
8285
|
-
k([_({ fallback: "parent" }), O("design:type", Object)],
|
|
8357
|
+
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", {
|
|
8286
8358
|
renderMode: "disabled",
|
|
8287
8359
|
processSortMode: "parent-before",
|
|
8288
8360
|
duration: 2e3
|
|
8289
|
-
}), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])],
|
|
8361
|
+
}), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], fa);
|
|
8290
8362
|
//#endregion
|
|
8291
8363
|
//#region src/scene/audio/html/HTMLAudioContext.ts
|
|
8292
|
-
var
|
|
8364
|
+
var pa = class t extends e {
|
|
8293
8365
|
static _instance;
|
|
8294
8366
|
static get instance() {
|
|
8295
8367
|
return this._instance ||= new t(), this._instance;
|
|
@@ -8319,7 +8391,7 @@ var fa = class t extends e {
|
|
|
8319
8391
|
togglePause() {
|
|
8320
8392
|
return this.paused = !this.paused, this.refreshPaused(), this.paused;
|
|
8321
8393
|
}
|
|
8322
|
-
},
|
|
8394
|
+
}, ma = class t extends e {
|
|
8323
8395
|
static PADDING = .1;
|
|
8324
8396
|
_source = null;
|
|
8325
8397
|
_audio = null;
|
|
@@ -8446,7 +8518,7 @@ var fa = class t extends e {
|
|
|
8446
8518
|
let e = this._source;
|
|
8447
8519
|
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);
|
|
8448
8520
|
}
|
|
8449
|
-
},
|
|
8521
|
+
}, ha = class {
|
|
8450
8522
|
parent;
|
|
8451
8523
|
source = new globalThis.Audio();
|
|
8452
8524
|
_src = "";
|
|
@@ -8463,7 +8535,7 @@ var fa = class t extends e {
|
|
|
8463
8535
|
return !!this.source && this.source.readyState === 4;
|
|
8464
8536
|
}
|
|
8465
8537
|
get context() {
|
|
8466
|
-
return
|
|
8538
|
+
return pa.instance;
|
|
8467
8539
|
}
|
|
8468
8540
|
constructor(e) {
|
|
8469
8541
|
this.parent = e;
|
|
@@ -8474,9 +8546,9 @@ var fa = class t extends e {
|
|
|
8474
8546
|
});
|
|
8475
8547
|
}
|
|
8476
8548
|
createSound() {
|
|
8477
|
-
return new
|
|
8549
|
+
return new ma();
|
|
8478
8550
|
}
|
|
8479
|
-
},
|
|
8551
|
+
}, ga = class extends e {
|
|
8480
8552
|
_input;
|
|
8481
8553
|
_output;
|
|
8482
8554
|
_processers = [];
|
|
@@ -8498,7 +8570,7 @@ var fa = class t extends e {
|
|
|
8498
8570
|
get destination() {
|
|
8499
8571
|
return this._input;
|
|
8500
8572
|
}
|
|
8501
|
-
},
|
|
8573
|
+
}, _a = class {
|
|
8502
8574
|
destination;
|
|
8503
8575
|
source;
|
|
8504
8576
|
constructor(e, t = null) {
|
|
@@ -8513,21 +8585,21 @@ var fa = class t extends e {
|
|
|
8513
8585
|
};
|
|
8514
8586
|
//#endregion
|
|
8515
8587
|
//#region src/scene/audio/web/WebAudioContext.ts
|
|
8516
|
-
function
|
|
8588
|
+
function va() {
|
|
8517
8589
|
if (He) return new AudioContext();
|
|
8518
8590
|
if (Ue) {
|
|
8519
8591
|
let e = globalThis.webkitAudioContext;
|
|
8520
8592
|
return new e();
|
|
8521
8593
|
} else throw Error("Failed to createAudioContext");
|
|
8522
8594
|
}
|
|
8523
|
-
function
|
|
8595
|
+
function ya(e, t, n) {
|
|
8524
8596
|
if (We) return new OfflineAudioContext(e, t, n);
|
|
8525
8597
|
if (Ge) {
|
|
8526
8598
|
let r = globalThis.webkitOfflineAudioContext;
|
|
8527
8599
|
return new r(e, t, n);
|
|
8528
8600
|
} else throw Error("Failed to createOfflineAudioContext");
|
|
8529
8601
|
}
|
|
8530
|
-
var
|
|
8602
|
+
var ba = class e extends ga {
|
|
8531
8603
|
static _instance;
|
|
8532
8604
|
static get instance() {
|
|
8533
8605
|
return this._instance ||= new e(), this._instance;
|
|
@@ -8568,7 +8640,7 @@ var ya = class e extends ha {
|
|
|
8568
8640
|
_compressor;
|
|
8569
8641
|
_analyser;
|
|
8570
8642
|
constructor() {
|
|
8571
|
-
let e =
|
|
8643
|
+
let e = va(), t = ya(1, 2, We ? Math.max(8e3, Math.min(96e3, e.sampleRate)) : 44100), n = e.createDynamicsCompressor(), r = e.createAnalyser();
|
|
8572
8644
|
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));
|
|
8573
8645
|
}
|
|
8574
8646
|
_onFocus() {
|
|
@@ -8609,7 +8681,7 @@ var ya = class e extends ha {
|
|
|
8609
8681
|
setParamValue(e, t) {
|
|
8610
8682
|
e.setValueAtTime ? e.setValueAtTime(t, this._context.currentTime) : e.value = t;
|
|
8611
8683
|
}
|
|
8612
|
-
},
|
|
8684
|
+
}, xa = class extends e {
|
|
8613
8685
|
_audio = null;
|
|
8614
8686
|
_sourceNode = null;
|
|
8615
8687
|
_gain = null;
|
|
@@ -8742,7 +8814,7 @@ var ya = class e extends ha {
|
|
|
8742
8814
|
destroy() {
|
|
8743
8815
|
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;
|
|
8744
8816
|
}
|
|
8745
|
-
},
|
|
8817
|
+
}, Sa = class extends ga {
|
|
8746
8818
|
parent;
|
|
8747
8819
|
_sourceBuffer;
|
|
8748
8820
|
_sourceNode;
|
|
@@ -8750,7 +8822,7 @@ var ya = class e extends ha {
|
|
|
8750
8822
|
gain;
|
|
8751
8823
|
analyser;
|
|
8752
8824
|
get context() {
|
|
8753
|
-
return
|
|
8825
|
+
return ba.instance;
|
|
8754
8826
|
}
|
|
8755
8827
|
get isPlayable() {
|
|
8756
8828
|
return !!this._sourceNode.buffer;
|
|
@@ -8765,8 +8837,8 @@ var ya = class e extends ha {
|
|
|
8765
8837
|
this._sourceNode.buffer = e;
|
|
8766
8838
|
}
|
|
8767
8839
|
constructor(e) {
|
|
8768
|
-
let t =
|
|
8769
|
-
n.connect(i), i.connect(r), r.connect(
|
|
8840
|
+
let t = ba.audioContext, n = t.createBufferSource(), r = t.createGain(), i = t.createAnalyser();
|
|
8841
|
+
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;
|
|
8770
8842
|
}
|
|
8771
8843
|
async load() {
|
|
8772
8844
|
return this._sourceLoad ||= new Promise((e) => {
|
|
@@ -8779,7 +8851,7 @@ var ya = class e extends ha {
|
|
|
8779
8851
|
});
|
|
8780
8852
|
}
|
|
8781
8853
|
_decode(e) {
|
|
8782
|
-
return Promise.resolve(e instanceof AudioBuffer ? e :
|
|
8854
|
+
return Promise.resolve(e instanceof AudioBuffer ? e : ba.decode(e)).then((e) => (this.parent.isLoaded = !0, this.buffer = e, e));
|
|
8783
8855
|
}
|
|
8784
8856
|
cloneSource() {
|
|
8785
8857
|
let e = this.context, t = this._sourceNode, n = e.audioContext.createBufferSource(), r = e.audioContext.createGain();
|
|
@@ -8789,15 +8861,15 @@ var ya = class e extends ha {
|
|
|
8789
8861
|
};
|
|
8790
8862
|
}
|
|
8791
8863
|
createSound() {
|
|
8792
|
-
return new
|
|
8864
|
+
return new xa();
|
|
8793
8865
|
}
|
|
8794
|
-
},
|
|
8866
|
+
}, Ca, wa = class extends V {
|
|
8795
8867
|
static {
|
|
8796
|
-
|
|
8868
|
+
Ca = this;
|
|
8797
8869
|
}
|
|
8798
8870
|
static _soundPool = [];
|
|
8799
8871
|
_sounds = [];
|
|
8800
|
-
_platformAudio = Ke ? new
|
|
8872
|
+
_platformAudio = Ke ? new Sa(this) : new ha(this);
|
|
8801
8873
|
get platformAudio() {
|
|
8802
8874
|
return this._platformAudio;
|
|
8803
8875
|
}
|
|
@@ -8890,7 +8962,7 @@ var ya = class e extends ha {
|
|
|
8890
8962
|
this._sounds.length = 0;
|
|
8891
8963
|
}
|
|
8892
8964
|
_createSound() {
|
|
8893
|
-
return
|
|
8965
|
+
return Ca._soundPool.length > 0 ? Ca._soundPool.pop().init(this._platformAudio) : this._platformAudio.createSound().init(this._platformAudio);
|
|
8894
8966
|
}
|
|
8895
8967
|
refresh() {
|
|
8896
8968
|
for (let e = this._sounds.length, t = 0; t < e; t++) this._sounds[t].refresh();
|
|
@@ -8906,7 +8978,7 @@ var ya = class e extends ha {
|
|
|
8906
8978
|
this._recycleSound(e);
|
|
8907
8979
|
};
|
|
8908
8980
|
_recycleSound(e) {
|
|
8909
|
-
e.destroy(),
|
|
8981
|
+
e.destroy(), Ca._soundPool.includes(e) || Ca._soundPool.push(e);
|
|
8910
8982
|
}
|
|
8911
8983
|
_prevTime = 0;
|
|
8912
8984
|
_timer = 0;
|
|
@@ -8922,10 +8994,10 @@ var ya = class e extends ha {
|
|
|
8922
8994
|
}, 100);
|
|
8923
8995
|
}
|
|
8924
8996
|
};
|
|
8925
|
-
|
|
8997
|
+
wa = Ca = k([b("Audio"), O("design:paramtypes", [Object])], wa);
|
|
8926
8998
|
//#endregion
|
|
8927
8999
|
//#region src/scene/audio/AudioSpectrum.ts
|
|
8928
|
-
var
|
|
9000
|
+
var Ta = class extends wr {}, Ea = class extends ea {
|
|
8929
9001
|
_audioBuffer;
|
|
8930
9002
|
_src = (() => {
|
|
8931
9003
|
let e = S();
|
|
@@ -8949,7 +9021,7 @@ var wa = class extends wr {}, Ta = class extends ea {
|
|
|
8949
9021
|
}
|
|
8950
9022
|
}
|
|
8951
9023
|
async _loadSrc(e) {
|
|
8952
|
-
await globalThis.fetch(e).then((e) => e.arrayBuffer()).then((e) =>
|
|
9024
|
+
await globalThis.fetch(e).then((e) => e.arrayBuffer()).then((e) => ba.decode(e)).then((e) => {
|
|
8953
9025
|
this._audioBuffer = e, this.syncTexture(!0);
|
|
8954
9026
|
});
|
|
8955
9027
|
}
|
|
@@ -8984,12 +9056,12 @@ var wa = class extends wr {}, Ta = class extends ea {
|
|
|
8984
9056
|
this.syncTexture(), super._process(e);
|
|
8985
9057
|
}
|
|
8986
9058
|
};
|
|
8987
|
-
k([_(), O("design:type", Object)],
|
|
9059
|
+
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);
|
|
8988
9060
|
//#endregion
|
|
8989
9061
|
//#region src/scene/transitions/KawaseTransition.ts
|
|
8990
|
-
var
|
|
9062
|
+
var Da, Oa = class extends Cr {
|
|
8991
9063
|
static {
|
|
8992
|
-
|
|
9064
|
+
Da = this;
|
|
8993
9065
|
}
|
|
8994
9066
|
blur = 10;
|
|
8995
9067
|
quality = 10;
|
|
@@ -9008,7 +9080,7 @@ var Ea, Da = class extends Cr {
|
|
|
9008
9080
|
let d = 1 / s, f = 1 / c, p = [], m, h = o - 1;
|
|
9009
9081
|
for (let e = 0; e < h; e++) m = u[e] + .5, p[0] = m * d, p[1] = m * f, l.push({ offset: p });
|
|
9010
9082
|
m = u[h] + .5, p[0] = m * d, p[1] = m * f, l.push({ offset: p }), l.forEach((t) => {
|
|
9011
|
-
L.draw(e,
|
|
9083
|
+
L.draw(e, Da.material, {
|
|
9012
9084
|
sampler: r,
|
|
9013
9085
|
progress: i,
|
|
9014
9086
|
...t
|
|
@@ -9016,31 +9088,31 @@ var Ea, Da = class extends Cr {
|
|
|
9016
9088
|
});
|
|
9017
9089
|
}
|
|
9018
9090
|
};
|
|
9019
|
-
|
|
9091
|
+
Oa = Da = k([b("KawaseTransition")], Oa);
|
|
9020
9092
|
//#endregion
|
|
9021
9093
|
//#region src/scene/transitions/LeftEraseTransition.ts
|
|
9022
|
-
var
|
|
9094
|
+
var ka, Aa = class extends Cr {
|
|
9023
9095
|
static {
|
|
9024
|
-
|
|
9096
|
+
ka = this;
|
|
9025
9097
|
}
|
|
9026
9098
|
static material = new I({ gl: {
|
|
9027
9099
|
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}",
|
|
9028
9100
|
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}"
|
|
9029
9101
|
} });
|
|
9030
9102
|
apply(e) {
|
|
9031
|
-
L.draw(e,
|
|
9103
|
+
L.draw(e, ka.material, {
|
|
9032
9104
|
previous: 0,
|
|
9033
9105
|
next: 1,
|
|
9034
9106
|
progress: this.currentTimeProgress
|
|
9035
9107
|
});
|
|
9036
9108
|
}
|
|
9037
9109
|
};
|
|
9038
|
-
|
|
9110
|
+
Aa = ka = k([b("LeftEraseTransition")], Aa);
|
|
9039
9111
|
//#endregion
|
|
9040
9112
|
//#region src/scene/transitions/TiltShiftTransition.ts
|
|
9041
|
-
var
|
|
9113
|
+
var ja, Ma = class extends Cr {
|
|
9042
9114
|
static {
|
|
9043
|
-
|
|
9115
|
+
ja = this;
|
|
9044
9116
|
}
|
|
9045
9117
|
blur = 100;
|
|
9046
9118
|
gradientBlur = 600;
|
|
@@ -9052,7 +9124,7 @@ var Aa, ja = class extends Cr {
|
|
|
9052
9124
|
let n = this.currentTimeProgress, r, i;
|
|
9053
9125
|
n < .5 ? (r = 0, i = (.5 - n) / .5) : (r = 1, i = (n - .5) / .5);
|
|
9054
9126
|
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);
|
|
9055
|
-
L.draw(e,
|
|
9127
|
+
L.draw(e, ja.material, {
|
|
9056
9128
|
sampler: r,
|
|
9057
9129
|
progress: i,
|
|
9058
9130
|
blur: this.blur,
|
|
@@ -9061,7 +9133,7 @@ var Aa, ja = class extends Cr {
|
|
|
9061
9133
|
end: c,
|
|
9062
9134
|
delta: [u / f, d / f],
|
|
9063
9135
|
texSize: l
|
|
9064
|
-
}), L.draw(e,
|
|
9136
|
+
}), L.draw(e, ja.material, {
|
|
9065
9137
|
sampler: r,
|
|
9066
9138
|
progress: i,
|
|
9067
9139
|
blur: this.blur,
|
|
@@ -9073,12 +9145,12 @@ var Aa, ja = class extends Cr {
|
|
|
9073
9145
|
});
|
|
9074
9146
|
}
|
|
9075
9147
|
};
|
|
9076
|
-
|
|
9148
|
+
Ma = ja = k([b("TiltShiftTransition")], Ma);
|
|
9077
9149
|
//#endregion
|
|
9078
9150
|
//#region src/scene/transitions/TwistTransition.ts
|
|
9079
|
-
var
|
|
9151
|
+
var Na, Pa = class extends Cr {
|
|
9080
9152
|
static {
|
|
9081
|
-
|
|
9153
|
+
Na = this;
|
|
9082
9154
|
}
|
|
9083
9155
|
radius;
|
|
9084
9156
|
angle = 4;
|
|
@@ -9092,7 +9164,7 @@ var Ma, Na = class extends Cr {
|
|
|
9092
9164
|
let n = this.currentTimeProgress, r, i;
|
|
9093
9165
|
n < .5 ? (r = 0, i = (.5 - n) / .5) : (r = 1, i = (n - .5) / .5);
|
|
9094
9166
|
let a = t.width, o = t.height;
|
|
9095
|
-
L.draw(e,
|
|
9167
|
+
L.draw(e, Na.material, {
|
|
9096
9168
|
sampler: r,
|
|
9097
9169
|
progress: i,
|
|
9098
9170
|
filterArea: [
|
|
@@ -9108,10 +9180,10 @@ var Ma, Na = class extends Cr {
|
|
|
9108
9180
|
});
|
|
9109
9181
|
}
|
|
9110
9182
|
};
|
|
9111
|
-
|
|
9183
|
+
Pa = Na = k([b("TwistTransition")], Pa);
|
|
9112
9184
|
//#endregion
|
|
9113
9185
|
//#region src/asset/loaders/GifLoader.ts
|
|
9114
|
-
var
|
|
9186
|
+
var Fa = class extends Vn {
|
|
9115
9187
|
install(e) {
|
|
9116
9188
|
let t = async (t) => {
|
|
9117
9189
|
let { decodeFrames: n } = await import("modern-gif");
|
|
@@ -9128,14 +9200,14 @@ var Pa = class extends Vn {
|
|
|
9128
9200
|
e.register(n, t);
|
|
9129
9201
|
}), e.gif = this, this;
|
|
9130
9202
|
}
|
|
9131
|
-
},
|
|
9203
|
+
}, Ia = class extends Vn {
|
|
9132
9204
|
install(e) {
|
|
9133
9205
|
let t = async (e) => JSON.parse(await e.text());
|
|
9134
9206
|
return this.load = (n) => typeof n == "string" ? e.loadBy(n).then(t) : t(n), ["application/json"].forEach((n) => {
|
|
9135
9207
|
e.register(n, t);
|
|
9136
9208
|
}), e.json = this, this;
|
|
9137
9209
|
}
|
|
9138
|
-
},
|
|
9210
|
+
}, La = class extends Vn {
|
|
9139
9211
|
install(e) {
|
|
9140
9212
|
return this.load = async (t, n) => (await import("lottie-web").then((e) => e.default)).loadAnimation({
|
|
9141
9213
|
container: null,
|
|
@@ -9146,12 +9218,12 @@ var Pa = class extends Vn {
|
|
|
9146
9218
|
animationData: await e.loadBy(t, () => e.fetch(t).then((e) => e.json()))
|
|
9147
9219
|
}), e.lottie = this, this;
|
|
9148
9220
|
}
|
|
9149
|
-
},
|
|
9221
|
+
}, Ra = class extends Vn {
|
|
9150
9222
|
install(e) {
|
|
9151
9223
|
let t = async (e) => e.text();
|
|
9152
9224
|
return this.load = (n) => typeof n == "string" ? e.loadBy(n).then(t) : t(n), e.text = this, this;
|
|
9153
9225
|
}
|
|
9154
|
-
},
|
|
9226
|
+
}, za = class extends Vn {
|
|
9155
9227
|
install(e) {
|
|
9156
9228
|
let t = (t) => e.fetchImageBitmap(t, { premultiplyAlpha: "premultiply" }).then((e) => new z({
|
|
9157
9229
|
source: e,
|
|
@@ -9175,11 +9247,11 @@ var Pa = class extends Vn {
|
|
|
9175
9247
|
e.register(n, t);
|
|
9176
9248
|
}), e.texture = this, this;
|
|
9177
9249
|
}
|
|
9178
|
-
},
|
|
9250
|
+
}, Ba = class extends Vn {
|
|
9179
9251
|
install(e) {
|
|
9180
9252
|
return this.load = (t) => e.awaitBy(() => new ar(t).load()), e.video = this, this;
|
|
9181
9253
|
}
|
|
9182
|
-
},
|
|
9254
|
+
}, Va = Object.entries({
|
|
9183
9255
|
"font/woff": ["woff"],
|
|
9184
9256
|
"font/ttf": ["ttf"],
|
|
9185
9257
|
"font/otf": ["otf"],
|
|
@@ -9195,31 +9267,31 @@ var Pa = class extends Vn {
|
|
|
9195
9267
|
"image/webp": ["webp"],
|
|
9196
9268
|
"application/json": ["json"]
|
|
9197
9269
|
});
|
|
9198
|
-
function Va(e) {
|
|
9199
|
-
for (let [t, n] of Ba) if (n.includes(e)) return t;
|
|
9200
|
-
}
|
|
9201
9270
|
function Ha(e) {
|
|
9271
|
+
for (let [t, n] of Va) if (n.includes(e)) return t;
|
|
9272
|
+
}
|
|
9273
|
+
function Ua(e) {
|
|
9202
9274
|
let t;
|
|
9203
9275
|
if (e.startsWith("data:")) t = e.match(/^data:(.+?);/)?.[1];
|
|
9204
9276
|
else if (e.startsWith("http")) {
|
|
9205
9277
|
let n = e.split(/[#?]/)[0].split(".").pop()?.trim();
|
|
9206
|
-
n && (t =
|
|
9278
|
+
n && (t = Ha(n));
|
|
9207
9279
|
}
|
|
9208
9280
|
return t;
|
|
9209
9281
|
}
|
|
9210
9282
|
//#endregion
|
|
9211
9283
|
//#region src/asset/Assets.ts
|
|
9212
|
-
var
|
|
9284
|
+
var Wa = "WeakRef" in globalThis, Ga = class extends e {
|
|
9213
9285
|
defaultHandler = (e) => e;
|
|
9214
9286
|
_handlers = /* @__PURE__ */ new Map();
|
|
9215
9287
|
_handleing = /* @__PURE__ */ new Map();
|
|
9216
9288
|
_handled = /* @__PURE__ */ new Map();
|
|
9217
|
-
_gc =
|
|
9289
|
+
_gc = Wa ? new FinalizationRegistry((e) => {
|
|
9218
9290
|
let t = this.get(e);
|
|
9219
9291
|
t && "destroy" in t && t.destroy(), this._handled.delete(e);
|
|
9220
9292
|
}) : void 0;
|
|
9221
9293
|
constructor() {
|
|
9222
|
-
super(),
|
|
9294
|
+
super(), Wa || x.on(this.gc.bind(this), { sort: 2 });
|
|
9223
9295
|
}
|
|
9224
9296
|
use(e) {
|
|
9225
9297
|
return e.install(this), this;
|
|
@@ -9268,11 +9340,11 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
|
|
|
9268
9340
|
}
|
|
9269
9341
|
get(e) {
|
|
9270
9342
|
let t = this._handled.get(e);
|
|
9271
|
-
return
|
|
9343
|
+
return Wa && t instanceof WeakRef && (t = t.deref(), t || this._handleing.delete(e)), t;
|
|
9272
9344
|
}
|
|
9273
9345
|
set(e, t) {
|
|
9274
9346
|
let n = t;
|
|
9275
|
-
|
|
9347
|
+
Wa && typeof t == "object" && (this._gc.register(t, e), n = new WeakRef(t)), this._handled.set(e, n);
|
|
9276
9348
|
}
|
|
9277
9349
|
async awaitBy(e) {
|
|
9278
9350
|
let t = e(), n = c();
|
|
@@ -9287,7 +9359,7 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
|
|
|
9287
9359
|
return this._handleing.set(e, r), r;
|
|
9288
9360
|
}
|
|
9289
9361
|
async load(e, t) {
|
|
9290
|
-
let n = await this.loadBy(e), r =
|
|
9362
|
+
let n = await this.loadBy(e), r = Ua(e);
|
|
9291
9363
|
return r === void 0 && (r = n.type?.split(";")[0] ?? void 0), ((r ? this._handlers.get(r) : void 0) ?? this.defaultHandler)(n, t);
|
|
9292
9364
|
}
|
|
9293
9365
|
async waitUntilLoad() {
|
|
@@ -9301,14 +9373,14 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
|
|
|
9301
9373
|
n && "destroy" in n && n.destroy();
|
|
9302
9374
|
}), this._handled.clear();
|
|
9303
9375
|
}
|
|
9304
|
-
}, $ = new
|
|
9376
|
+
}, $ = new Ga().use(new Hn()).use(new Fa()).use(new Ia()).use(new La()).use(new Ra()).use(new za()).use(new Ba()), Ka = {
|
|
9305
9377
|
alpha: !0,
|
|
9306
9378
|
stencil: !0,
|
|
9307
9379
|
antialias: !1,
|
|
9308
9380
|
premultipliedAlpha: !0,
|
|
9309
9381
|
preserveDrawingBuffer: !1,
|
|
9310
9382
|
powerPreference: "default"
|
|
9311
|
-
},
|
|
9383
|
+
}, qa = class extends Sr {
|
|
9312
9384
|
renderer;
|
|
9313
9385
|
get view() {
|
|
9314
9386
|
return this.renderer.view;
|
|
@@ -9341,12 +9413,12 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
|
|
|
9341
9413
|
constructor(e = {}) {
|
|
9342
9414
|
let { view: t, width: n, height: r, pixelRatio: i = Ye, autoResize: a, data: o } = e;
|
|
9343
9415
|
super(), this.renderer = new Bn(t, {
|
|
9344
|
-
alpha:
|
|
9345
|
-
stencil:
|
|
9346
|
-
antialias:
|
|
9347
|
-
premultipliedAlpha:
|
|
9348
|
-
preserveDrawingBuffer:
|
|
9349
|
-
powerPreference:
|
|
9416
|
+
alpha: Ka.alpha ?? e.alpha,
|
|
9417
|
+
stencil: Ka.stencil ?? e.stencil,
|
|
9418
|
+
antialias: Ka.antialias ?? e.antialias,
|
|
9419
|
+
premultipliedAlpha: Ka.premultipliedAlpha ?? e.premultipliedAlpha,
|
|
9420
|
+
preserveDrawingBuffer: Ka.preserveDrawingBuffer ?? e.preserveDrawingBuffer,
|
|
9421
|
+
powerPreference: Ka.powerPreference ?? e.powerPreference
|
|
9350
9422
|
}), 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);
|
|
9351
9423
|
}
|
|
9352
9424
|
_updateProperty(e, t, n) {
|
|
@@ -9429,22 +9501,22 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
|
|
|
9429
9501
|
super._destroy(), this._resizeObserver?.disconnect(), this.renderer.destroy();
|
|
9430
9502
|
}
|
|
9431
9503
|
};
|
|
9432
|
-
k([_({ fallback: !1 }), O("design:type", Boolean)],
|
|
9504
|
+
k([_({ fallback: !1 }), O("design:type", Boolean)], qa.prototype, "autoResize", void 0), k([_({ fallback: !1 }), O("design:type", Boolean)], qa.prototype, "autoStart", void 0);
|
|
9433
9505
|
//#endregion
|
|
9434
9506
|
//#region src/render.ts
|
|
9435
|
-
var
|
|
9436
|
-
function
|
|
9437
|
-
return
|
|
9507
|
+
var Ja, Ya = [], Xa = !1;
|
|
9508
|
+
function Za() {
|
|
9509
|
+
return Ja ??= new qa({
|
|
9438
9510
|
pixelRatio: 1,
|
|
9439
9511
|
width: 1,
|
|
9440
9512
|
height: 1,
|
|
9441
9513
|
preserveDrawingBuffer: !0
|
|
9442
9514
|
});
|
|
9443
9515
|
}
|
|
9444
|
-
async function
|
|
9445
|
-
if (!
|
|
9446
|
-
for (
|
|
9447
|
-
let t =
|
|
9516
|
+
async function Qa(e = 100) {
|
|
9517
|
+
if (!Xa) {
|
|
9518
|
+
for (Xa = !0; Ya.length;) {
|
|
9519
|
+
let t = Ya.shift();
|
|
9448
9520
|
if (t) try {
|
|
9449
9521
|
await t();
|
|
9450
9522
|
} catch (e) {
|
|
@@ -9452,11 +9524,11 @@ async function Za(e = 100) {
|
|
|
9452
9524
|
}
|
|
9453
9525
|
else await new Promise((t) => setTimeout(t, e));
|
|
9454
9526
|
}
|
|
9455
|
-
|
|
9527
|
+
Xa = !1;
|
|
9456
9528
|
}
|
|
9457
9529
|
}
|
|
9458
|
-
async function
|
|
9459
|
-
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 =
|
|
9530
|
+
async function $a(e) {
|
|
9531
|
+
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();
|
|
9460
9532
|
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) {
|
|
9461
9533
|
let e = o.length, t = o[e - 1];
|
|
9462
9534
|
for (let n = 0; n < e; n++) {
|
|
@@ -9474,15 +9546,15 @@ async function Qa(e) {
|
|
|
9474
9546
|
toCanvas2D: () => f.toCanvas2D(new ImageData(p, u, d))
|
|
9475
9547
|
};
|
|
9476
9548
|
}
|
|
9477
|
-
async function
|
|
9549
|
+
async function eo(e) {
|
|
9478
9550
|
return new Promise((t) => {
|
|
9479
|
-
|
|
9551
|
+
Ya.push(async () => t(await $a(e).then((e) => e.toCanvas2D()))), Qa();
|
|
9480
9552
|
});
|
|
9481
9553
|
}
|
|
9482
|
-
async function
|
|
9554
|
+
async function to(e) {
|
|
9483
9555
|
return new Promise((t) => {
|
|
9484
|
-
|
|
9556
|
+
Ya.push(async () => t(await $a(e).then((e) => e.pixels))), Qa();
|
|
9485
9557
|
});
|
|
9486
9558
|
}
|
|
9487
9559
|
//#endregion
|
|
9488
|
-
export { yt as Aabb2D, $n as AnimatedTexture,
|
|
9560
|
+
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
|
@@ -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;
|
|
@@ -32,6 +32,9 @@ export declare class TimelineNode extends Node {
|
|
|
32
32
|
protected _currentTime: number;
|
|
33
33
|
protected _globalStartTime: number;
|
|
34
34
|
protected _globalDuration: number;
|
|
35
|
+
protected _standalone: boolean;
|
|
36
|
+
protected _localCurrentTime: number;
|
|
37
|
+
get standalone(): boolean;
|
|
35
38
|
get parentGlobalStartTime(): number;
|
|
36
39
|
get currentTime(): number;
|
|
37
40
|
get globalStartTime(): number;
|
|
@@ -42,6 +45,16 @@ export declare class TimelineNode extends Node {
|
|
|
42
45
|
constructor(properties?: Partial<TimelineNodeProperties>, nodes?: Node[]);
|
|
43
46
|
protected _updateProperty(key: string, newValue: any, oldValue: any): void;
|
|
44
47
|
protected _updateInsideTimeRange(): void;
|
|
48
|
+
/**
|
|
49
|
+
* 开启/关闭独立播放。开启后本节点的 currentTime 取自 {@link setLocalTime}
|
|
50
|
+
* 设置的本地时钟,完全脱离全局时间轴;关闭后恢复跟随全局时间轴。
|
|
51
|
+
*/
|
|
52
|
+
setStandalone(on: boolean): this;
|
|
53
|
+
/**
|
|
54
|
+
* 独立播放下设置本地时间(毫秒,相对本节点自身 0 起点)并立即刷新。
|
|
55
|
+
* 由外部循环(如交互运行器)逐帧驱动。
|
|
56
|
+
*/
|
|
57
|
+
setLocalTime(ms: number): this;
|
|
45
58
|
protected _updateCurrentTime(force?: boolean): void;
|
|
46
59
|
protected _process(delta: number): void;
|
|
47
60
|
}
|