modern-canvas 0.23.12 → 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 { path: t, ...r } = this._draws[n], i = r.type === "stroke" ? r.lineStyle : void 0, a = `${r.type}|${t.toData()}|${i ? `${i.width},${i.cap},${i.join},${i.alignment},${i.miterLimit}` : ""}`, o = this._triCache[n];
3916
- if (!o || o.sig !== a) {
3917
- let e = [], i = [];
3918
- r.type === "fill" ? t.fillTriangulate({
3919
- vertices: e,
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
- }) : t.strokeTriangulate({
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: i,
3924
- lineStyle: r.lineStyle,
3943
+ indices: t,
3944
+ lineStyle: i.lineStyle,
3925
3945
  flipAlignment: !1,
3926
- closed: t.getPoint(0).equals(t.getPoint(1))
3927
- }), o = {
3928
- sig: a,
3946
+ closed: r.getPoint(0).equals(r.getPoint(1))
3947
+ }), s = {
3948
+ sig: o,
3929
3949
  vertices: new Float32Array(e),
3930
- indices: new Uint32Array(i)
3931
- }, this._triCache[n] = o;
3950
+ indices: new Uint32Array(t)
3951
+ }, this._triCache[n] = s;
3932
3952
  }
3933
3953
  e.push({
3934
- ...r,
3935
- vertices: o.vertices,
3936
- indices: o.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
- let { width: i, height: a } = t, o = r ?? ((e, t) => {
4552
- e[t] = e[t] / i, e[t + 1] = e[t + 1] / a;
4553
- }), s = n.slice();
4554
- for (let e = s.length, t = 0; t < e; t += 2) o(s, t);
4555
- return s;
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 } = new v().scale(1 / this.size.x, 1 / this.size.y), o, s;
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/TransformRect2D.ts
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)], ra.prototype, "handleSize", void 0);
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 ia = class extends ta {
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)], ia.prototype, "src", void 0), ia = k([b("Video2D"), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], ia);
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 aa(e) {
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 oa(e, t) {
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,11 +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 sa(e) {
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
- function ca(e, t, n, r) {
8072
+ function la(e, t, n, r) {
8012
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;
8013
8074
  function m(e) {
8014
8075
  let t = e, n, r;
@@ -8028,7 +8089,7 @@ function ca(e, t, n, r) {
8028
8089
  }
8029
8090
  return (e) => p(m(e));
8030
8091
  }
8031
- var la = {
8092
+ var ua = {
8032
8093
  linear: [
8033
8094
  0,
8034
8095
  0,
@@ -8095,7 +8156,7 @@ var la = {
8095
8156
  .355,
8096
8157
  1
8097
8158
  ]
8098
- }, ua = Object.fromEntries(Object.entries(la).map(([e, [t, n, r, i]]) => [e, ca(t, n, r, i)])), da = class extends V {
8159
+ }, da = Object.fromEntries(Object.entries(ua).map(([e, [t, n, r, i]]) => [e, la(t, n, r, i)])), fa = class extends V {
8099
8160
  _keyframes = [];
8100
8161
  _isFirstUpdatePosition = !1;
8101
8162
  _cachedProps = new t();
@@ -8182,14 +8243,14 @@ var la = {
8182
8243
  });
8183
8244
  }
8184
8245
  _parseEasing(e) {
8185
- if (!e) return ua.linear;
8186
- if (e in ua) return ua[e];
8246
+ if (!e) return da.linear;
8247
+ if (e in da) return da[e];
8187
8248
  let t = /cubic-bezier\((.+)\)/.exec(e);
8188
8249
  if (t) {
8189
8250
  let e = t[1].split(",").map((e) => Number(e));
8190
- if (e.length === 4 && e.every((e) => !Number.isNaN(e))) return ca(e[0], e[1], e[2], e[3]);
8251
+ if (e.length === 4 && e.every((e) => !Number.isNaN(e))) return la(e[0], e[1], e[2], e[3]);
8191
8252
  }
8192
- return ua.linear;
8253
+ return da.linear;
8193
8254
  }
8194
8255
  _parseKeyframes(e, t) {
8195
8256
  let n, r = this._keyframes;
@@ -8224,7 +8285,7 @@ var la = {
8224
8285
  });
8225
8286
  }
8226
8287
  _commitOffsetPath(e, t, n, r, i, a) {
8227
- let o = sa(t);
8288
+ let o = ca(t);
8228
8289
  if (!o) return;
8229
8290
  let s = this._pathMeasures.get(o);
8230
8291
  if (!s) {
@@ -8235,7 +8296,7 @@ var la = {
8235
8296
  startY: t.y
8236
8297
  }, this._pathMeasures.set(o, s);
8237
8298
  }
8238
- let c = E(D(aa(r.offsetDistance ?? i.offsetDistance), aa(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 = oa(i.offsetRotate ?? r.offsetRotate, u), m = n.get("transform");
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");
8239
8300
  e.onUpdateStyleProperty("transform", `${m ? `${m} ` : ""}translate(${d}px, ${f}px) rotate(${p}deg)`, void 0);
8240
8301
  }
8241
8302
  _getDiffValue(e, t, n, r, i) {
@@ -8282,14 +8343,14 @@ var la = {
8282
8343
  });
8283
8344
  }
8284
8345
  };
8285
- k([_({ fallback: "parent" }), O("design:type", Object)], da.prototype, "effectMode", void 0), k([_({ default: () => [] }), O("design:type", Array)], da.prototype, "keyframes", void 0), k([_(), O("design:type", Object)], da.prototype, "easing", void 0), da = k([b("Animation", {
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", {
8286
8347
  renderMode: "disabled",
8287
8348
  processSortMode: "parent-before",
8288
8349
  duration: 2e3
8289
- }), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], da);
8350
+ }), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial, Array])], fa);
8290
8351
  //#endregion
8291
8352
  //#region src/scene/audio/html/HTMLAudioContext.ts
8292
- var fa = class t extends e {
8353
+ var pa = class t extends e {
8293
8354
  static _instance;
8294
8355
  static get instance() {
8295
8356
  return this._instance ||= new t(), this._instance;
@@ -8319,7 +8380,7 @@ var fa = class t extends e {
8319
8380
  togglePause() {
8320
8381
  return this.paused = !this.paused, this.refreshPaused(), this.paused;
8321
8382
  }
8322
- }, pa = class t extends e {
8383
+ }, ma = class t extends e {
8323
8384
  static PADDING = .1;
8324
8385
  _source = null;
8325
8386
  _audio = null;
@@ -8446,7 +8507,7 @@ var fa = class t extends e {
8446
8507
  let e = this._source;
8447
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);
8448
8509
  }
8449
- }, ma = class {
8510
+ }, ha = class {
8450
8511
  parent;
8451
8512
  source = new globalThis.Audio();
8452
8513
  _src = "";
@@ -8463,7 +8524,7 @@ var fa = class t extends e {
8463
8524
  return !!this.source && this.source.readyState === 4;
8464
8525
  }
8465
8526
  get context() {
8466
- return fa.instance;
8527
+ return pa.instance;
8467
8528
  }
8468
8529
  constructor(e) {
8469
8530
  this.parent = e;
@@ -8474,9 +8535,9 @@ var fa = class t extends e {
8474
8535
  });
8475
8536
  }
8476
8537
  createSound() {
8477
- return new pa();
8538
+ return new ma();
8478
8539
  }
8479
- }, ha = class extends e {
8540
+ }, ga = class extends e {
8480
8541
  _input;
8481
8542
  _output;
8482
8543
  _processers = [];
@@ -8498,7 +8559,7 @@ var fa = class t extends e {
8498
8559
  get destination() {
8499
8560
  return this._input;
8500
8561
  }
8501
- }, ga = class {
8562
+ }, _a = class {
8502
8563
  destination;
8503
8564
  source;
8504
8565
  constructor(e, t = null) {
@@ -8513,21 +8574,21 @@ var fa = class t extends e {
8513
8574
  };
8514
8575
  //#endregion
8515
8576
  //#region src/scene/audio/web/WebAudioContext.ts
8516
- function _a() {
8577
+ function va() {
8517
8578
  if (He) return new AudioContext();
8518
8579
  if (Ue) {
8519
8580
  let e = globalThis.webkitAudioContext;
8520
8581
  return new e();
8521
8582
  } else throw Error("Failed to createAudioContext");
8522
8583
  }
8523
- function va(e, t, n) {
8584
+ function ya(e, t, n) {
8524
8585
  if (We) return new OfflineAudioContext(e, t, n);
8525
8586
  if (Ge) {
8526
8587
  let r = globalThis.webkitOfflineAudioContext;
8527
8588
  return new r(e, t, n);
8528
8589
  } else throw Error("Failed to createOfflineAudioContext");
8529
8590
  }
8530
- var ya = class e extends ha {
8591
+ var ba = class e extends ga {
8531
8592
  static _instance;
8532
8593
  static get instance() {
8533
8594
  return this._instance ||= new e(), this._instance;
@@ -8568,7 +8629,7 @@ var ya = class e extends ha {
8568
8629
  _compressor;
8569
8630
  _analyser;
8570
8631
  constructor() {
8571
- let e = _a(), t = va(1, 2, We ? Math.max(8e3, Math.min(96e3, e.sampleRate)) : 44100), n = e.createDynamicsCompressor(), r = e.createAnalyser();
8632
+ let e = va(), t = ya(1, 2, We ? Math.max(8e3, Math.min(96e3, e.sampleRate)) : 44100), n = e.createDynamicsCompressor(), r = e.createAnalyser();
8572
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));
8573
8634
  }
8574
8635
  _onFocus() {
@@ -8609,7 +8670,7 @@ var ya = class e extends ha {
8609
8670
  setParamValue(e, t) {
8610
8671
  e.setValueAtTime ? e.setValueAtTime(t, this._context.currentTime) : e.value = t;
8611
8672
  }
8612
- }, ba = class extends e {
8673
+ }, xa = class extends e {
8613
8674
  _audio = null;
8614
8675
  _sourceNode = null;
8615
8676
  _gain = null;
@@ -8742,7 +8803,7 @@ var ya = class e extends ha {
8742
8803
  destroy() {
8743
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;
8744
8805
  }
8745
- }, xa = class extends ha {
8806
+ }, Sa = class extends ga {
8746
8807
  parent;
8747
8808
  _sourceBuffer;
8748
8809
  _sourceNode;
@@ -8750,7 +8811,7 @@ var ya = class e extends ha {
8750
8811
  gain;
8751
8812
  analyser;
8752
8813
  get context() {
8753
- return ya.instance;
8814
+ return ba.instance;
8754
8815
  }
8755
8816
  get isPlayable() {
8756
8817
  return !!this._sourceNode.buffer;
@@ -8765,8 +8826,8 @@ var ya = class e extends ha {
8765
8826
  this._sourceNode.buffer = e;
8766
8827
  }
8767
8828
  constructor(e) {
8768
- let t = ya.audioContext, n = t.createBufferSource(), r = t.createGain(), i = t.createAnalyser();
8769
- n.connect(i), i.connect(r), r.connect(ya.instance.destination), super(i, r), this.parent = e, this._sourceNode = n, this.gain = r, this.analyser = i;
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;
8770
8831
  }
8771
8832
  async load() {
8772
8833
  return this._sourceLoad ||= new Promise((e) => {
@@ -8779,7 +8840,7 @@ var ya = class e extends ha {
8779
8840
  });
8780
8841
  }
8781
8842
  _decode(e) {
8782
- return Promise.resolve(e instanceof AudioBuffer ? e : ya.decode(e)).then((e) => (this.parent.isLoaded = !0, this.buffer = e, e));
8843
+ return Promise.resolve(e instanceof AudioBuffer ? e : ba.decode(e)).then((e) => (this.parent.isLoaded = !0, this.buffer = e, e));
8783
8844
  }
8784
8845
  cloneSource() {
8785
8846
  let e = this.context, t = this._sourceNode, n = e.audioContext.createBufferSource(), r = e.audioContext.createGain();
@@ -8789,15 +8850,15 @@ var ya = class e extends ha {
8789
8850
  };
8790
8851
  }
8791
8852
  createSound() {
8792
- return new ba();
8853
+ return new xa();
8793
8854
  }
8794
- }, Sa, Ca = class extends V {
8855
+ }, Ca, wa = class extends V {
8795
8856
  static {
8796
- Sa = this;
8857
+ Ca = this;
8797
8858
  }
8798
8859
  static _soundPool = [];
8799
8860
  _sounds = [];
8800
- _platformAudio = Ke ? new xa(this) : new ma(this);
8861
+ _platformAudio = Ke ? new Sa(this) : new ha(this);
8801
8862
  get platformAudio() {
8802
8863
  return this._platformAudio;
8803
8864
  }
@@ -8890,7 +8951,7 @@ var ya = class e extends ha {
8890
8951
  this._sounds.length = 0;
8891
8952
  }
8892
8953
  _createSound() {
8893
- return Sa._soundPool.length > 0 ? Sa._soundPool.pop().init(this._platformAudio) : this._platformAudio.createSound().init(this._platformAudio);
8954
+ return Ca._soundPool.length > 0 ? Ca._soundPool.pop().init(this._platformAudio) : this._platformAudio.createSound().init(this._platformAudio);
8894
8955
  }
8895
8956
  refresh() {
8896
8957
  for (let e = this._sounds.length, t = 0; t < e; t++) this._sounds[t].refresh();
@@ -8906,7 +8967,7 @@ var ya = class e extends ha {
8906
8967
  this._recycleSound(e);
8907
8968
  };
8908
8969
  _recycleSound(e) {
8909
- e.destroy(), Sa._soundPool.includes(e) || Sa._soundPool.push(e);
8970
+ e.destroy(), Ca._soundPool.includes(e) || Ca._soundPool.push(e);
8910
8971
  }
8911
8972
  _prevTime = 0;
8912
8973
  _timer = 0;
@@ -8922,10 +8983,10 @@ var ya = class e extends ha {
8922
8983
  }, 100);
8923
8984
  }
8924
8985
  };
8925
- Ca = Sa = k([b("Audio"), O("design:paramtypes", [Object])], Ca);
8986
+ wa = Ca = k([b("Audio"), O("design:paramtypes", [Object])], wa);
8926
8987
  //#endregion
8927
8988
  //#region src/scene/audio/AudioSpectrum.ts
8928
- var wa = class extends wr {}, Ta = class extends ea {
8989
+ var Ta = class extends wr {}, Ea = class extends ea {
8929
8990
  _audioBuffer;
8930
8991
  _src = (() => {
8931
8992
  let e = S();
@@ -8949,7 +9010,7 @@ var wa = class extends wr {}, Ta = class extends ea {
8949
9010
  }
8950
9011
  }
8951
9012
  async _loadSrc(e) {
8952
- await globalThis.fetch(e).then((e) => e.arrayBuffer()).then((e) => ya.decode(e)).then((e) => {
9013
+ await globalThis.fetch(e).then((e) => e.arrayBuffer()).then((e) => ba.decode(e)).then((e) => {
8953
9014
  this._audioBuffer = e, this.syncTexture(!0);
8954
9015
  });
8955
9016
  }
@@ -8984,12 +9045,12 @@ var wa = class extends wr {}, Ta = class extends ea {
8984
9045
  this.syncTexture(), super._process(e);
8985
9046
  }
8986
9047
  };
8987
- k([_(), O("design:type", Object)], Ta.prototype, "src", void 0), k([_({ fallback: 0 }), O("design:type", Number)], Ta.prototype, "gap", void 0), k([_({ fallback: "#000000" }), O("design:type", String)], Ta.prototype, "color", void 0), Ta = k([b("AudioWaveform"), O("design:paramtypes", [typeof Partial > "u" ? Object : Partial])], Ta);
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);
8988
9049
  //#endregion
8989
9050
  //#region src/scene/transitions/KawaseTransition.ts
8990
- var Ea, Da = class extends Cr {
9051
+ var Da, Oa = class extends Cr {
8991
9052
  static {
8992
- Ea = this;
9053
+ Da = this;
8993
9054
  }
8994
9055
  blur = 10;
8995
9056
  quality = 10;
@@ -9008,7 +9069,7 @@ var Ea, Da = class extends Cr {
9008
9069
  let d = 1 / s, f = 1 / c, p = [], m, h = o - 1;
9009
9070
  for (let e = 0; e < h; e++) m = u[e] + .5, p[0] = m * d, p[1] = m * f, l.push({ offset: p });
9010
9071
  m = u[h] + .5, p[0] = m * d, p[1] = m * f, l.push({ offset: p }), l.forEach((t) => {
9011
- L.draw(e, Ea.material, {
9072
+ L.draw(e, Da.material, {
9012
9073
  sampler: r,
9013
9074
  progress: i,
9014
9075
  ...t
@@ -9016,31 +9077,31 @@ var Ea, Da = class extends Cr {
9016
9077
  });
9017
9078
  }
9018
9079
  };
9019
- Da = Ea = k([b("KawaseTransition")], Da);
9080
+ Oa = Da = k([b("KawaseTransition")], Oa);
9020
9081
  //#endregion
9021
9082
  //#region src/scene/transitions/LeftEraseTransition.ts
9022
- var Oa, ka = class extends Cr {
9083
+ var ka, Aa = class extends Cr {
9023
9084
  static {
9024
- Oa = this;
9085
+ ka = this;
9025
9086
  }
9026
9087
  static material = new I({ gl: {
9027
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}",
9028
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}"
9029
9090
  } });
9030
9091
  apply(e) {
9031
- L.draw(e, Oa.material, {
9092
+ L.draw(e, ka.material, {
9032
9093
  previous: 0,
9033
9094
  next: 1,
9034
9095
  progress: this.currentTimeProgress
9035
9096
  });
9036
9097
  }
9037
9098
  };
9038
- ka = Oa = k([b("LeftEraseTransition")], ka);
9099
+ Aa = ka = k([b("LeftEraseTransition")], Aa);
9039
9100
  //#endregion
9040
9101
  //#region src/scene/transitions/TiltShiftTransition.ts
9041
- var Aa, ja = class extends Cr {
9102
+ var ja, Ma = class extends Cr {
9042
9103
  static {
9043
- Aa = this;
9104
+ ja = this;
9044
9105
  }
9045
9106
  blur = 100;
9046
9107
  gradientBlur = 600;
@@ -9052,7 +9113,7 @@ var Aa, ja = class extends Cr {
9052
9113
  let n = this.currentTimeProgress, r, i;
9053
9114
  n < .5 ? (r = 0, i = (.5 - n) / .5) : (r = 1, i = (n - .5) / .5);
9054
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);
9055
- L.draw(e, Aa.material, {
9116
+ L.draw(e, ja.material, {
9056
9117
  sampler: r,
9057
9118
  progress: i,
9058
9119
  blur: this.blur,
@@ -9061,7 +9122,7 @@ var Aa, ja = class extends Cr {
9061
9122
  end: c,
9062
9123
  delta: [u / f, d / f],
9063
9124
  texSize: l
9064
- }), L.draw(e, Aa.material, {
9125
+ }), L.draw(e, ja.material, {
9065
9126
  sampler: r,
9066
9127
  progress: i,
9067
9128
  blur: this.blur,
@@ -9073,12 +9134,12 @@ var Aa, ja = class extends Cr {
9073
9134
  });
9074
9135
  }
9075
9136
  };
9076
- ja = Aa = k([b("TiltShiftTransition")], ja);
9137
+ Ma = ja = k([b("TiltShiftTransition")], Ma);
9077
9138
  //#endregion
9078
9139
  //#region src/scene/transitions/TwistTransition.ts
9079
- var Ma, Na = class extends Cr {
9140
+ var Na, Pa = class extends Cr {
9080
9141
  static {
9081
- Ma = this;
9142
+ Na = this;
9082
9143
  }
9083
9144
  radius;
9084
9145
  angle = 4;
@@ -9092,7 +9153,7 @@ var Ma, Na = class extends Cr {
9092
9153
  let n = this.currentTimeProgress, r, i;
9093
9154
  n < .5 ? (r = 0, i = (.5 - n) / .5) : (r = 1, i = (n - .5) / .5);
9094
9155
  let a = t.width, o = t.height;
9095
- L.draw(e, Ma.material, {
9156
+ L.draw(e, Na.material, {
9096
9157
  sampler: r,
9097
9158
  progress: i,
9098
9159
  filterArea: [
@@ -9108,10 +9169,10 @@ var Ma, Na = class extends Cr {
9108
9169
  });
9109
9170
  }
9110
9171
  };
9111
- Na = Ma = k([b("TwistTransition")], Na);
9172
+ Pa = Na = k([b("TwistTransition")], Pa);
9112
9173
  //#endregion
9113
9174
  //#region src/asset/loaders/GifLoader.ts
9114
- var Pa = class extends Vn {
9175
+ var Fa = class extends Vn {
9115
9176
  install(e) {
9116
9177
  let t = async (t) => {
9117
9178
  let { decodeFrames: n } = await import("modern-gif");
@@ -9128,14 +9189,14 @@ var Pa = class extends Vn {
9128
9189
  e.register(n, t);
9129
9190
  }), e.gif = this, this;
9130
9191
  }
9131
- }, Fa = class extends Vn {
9192
+ }, Ia = class extends Vn {
9132
9193
  install(e) {
9133
9194
  let t = async (e) => JSON.parse(await e.text());
9134
9195
  return this.load = (n) => typeof n == "string" ? e.loadBy(n).then(t) : t(n), ["application/json"].forEach((n) => {
9135
9196
  e.register(n, t);
9136
9197
  }), e.json = this, this;
9137
9198
  }
9138
- }, Ia = class extends Vn {
9199
+ }, La = class extends Vn {
9139
9200
  install(e) {
9140
9201
  return this.load = async (t, n) => (await import("lottie-web").then((e) => e.default)).loadAnimation({
9141
9202
  container: null,
@@ -9146,12 +9207,12 @@ var Pa = class extends Vn {
9146
9207
  animationData: await e.loadBy(t, () => e.fetch(t).then((e) => e.json()))
9147
9208
  }), e.lottie = this, this;
9148
9209
  }
9149
- }, La = class extends Vn {
9210
+ }, Ra = class extends Vn {
9150
9211
  install(e) {
9151
9212
  let t = async (e) => e.text();
9152
9213
  return this.load = (n) => typeof n == "string" ? e.loadBy(n).then(t) : t(n), e.text = this, this;
9153
9214
  }
9154
- }, Ra = class extends Vn {
9215
+ }, za = class extends Vn {
9155
9216
  install(e) {
9156
9217
  let t = (t) => e.fetchImageBitmap(t, { premultiplyAlpha: "premultiply" }).then((e) => new z({
9157
9218
  source: e,
@@ -9175,11 +9236,11 @@ var Pa = class extends Vn {
9175
9236
  e.register(n, t);
9176
9237
  }), e.texture = this, this;
9177
9238
  }
9178
- }, za = class extends Vn {
9239
+ }, Ba = class extends Vn {
9179
9240
  install(e) {
9180
9241
  return this.load = (t) => e.awaitBy(() => new ar(t).load()), e.video = this, this;
9181
9242
  }
9182
- }, Ba = Object.entries({
9243
+ }, Va = Object.entries({
9183
9244
  "font/woff": ["woff"],
9184
9245
  "font/ttf": ["ttf"],
9185
9246
  "font/otf": ["otf"],
@@ -9195,31 +9256,31 @@ var Pa = class extends Vn {
9195
9256
  "image/webp": ["webp"],
9196
9257
  "application/json": ["json"]
9197
9258
  });
9198
- function Va(e) {
9199
- for (let [t, n] of Ba) if (n.includes(e)) return t;
9200
- }
9201
9259
  function Ha(e) {
9260
+ for (let [t, n] of Va) if (n.includes(e)) return t;
9261
+ }
9262
+ function Ua(e) {
9202
9263
  let t;
9203
9264
  if (e.startsWith("data:")) t = e.match(/^data:(.+?);/)?.[1];
9204
9265
  else if (e.startsWith("http")) {
9205
9266
  let n = e.split(/[#?]/)[0].split(".").pop()?.trim();
9206
- n && (t = Va(n));
9267
+ n && (t = Ha(n));
9207
9268
  }
9208
9269
  return t;
9209
9270
  }
9210
9271
  //#endregion
9211
9272
  //#region src/asset/Assets.ts
9212
- var Ua = "WeakRef" in globalThis, Wa = class extends e {
9273
+ var Wa = "WeakRef" in globalThis, Ga = class extends e {
9213
9274
  defaultHandler = (e) => e;
9214
9275
  _handlers = /* @__PURE__ */ new Map();
9215
9276
  _handleing = /* @__PURE__ */ new Map();
9216
9277
  _handled = /* @__PURE__ */ new Map();
9217
- _gc = Ua ? new FinalizationRegistry((e) => {
9278
+ _gc = Wa ? new FinalizationRegistry((e) => {
9218
9279
  let t = this.get(e);
9219
9280
  t && "destroy" in t && t.destroy(), this._handled.delete(e);
9220
9281
  }) : void 0;
9221
9282
  constructor() {
9222
- super(), Ua || x.on(this.gc.bind(this), { sort: 2 });
9283
+ super(), Wa || x.on(this.gc.bind(this), { sort: 2 });
9223
9284
  }
9224
9285
  use(e) {
9225
9286
  return e.install(this), this;
@@ -9268,11 +9329,11 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
9268
9329
  }
9269
9330
  get(e) {
9270
9331
  let t = this._handled.get(e);
9271
- return Ua && t instanceof WeakRef && (t = t.deref(), t || this._handleing.delete(e)), t;
9332
+ return Wa && t instanceof WeakRef && (t = t.deref(), t || this._handleing.delete(e)), t;
9272
9333
  }
9273
9334
  set(e, t) {
9274
9335
  let n = t;
9275
- Ua && typeof t == "object" && (this._gc.register(t, e), n = new WeakRef(t)), this._handled.set(e, n);
9336
+ Wa && typeof t == "object" && (this._gc.register(t, e), n = new WeakRef(t)), this._handled.set(e, n);
9276
9337
  }
9277
9338
  async awaitBy(e) {
9278
9339
  let t = e(), n = c();
@@ -9287,7 +9348,7 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
9287
9348
  return this._handleing.set(e, r), r;
9288
9349
  }
9289
9350
  async load(e, t) {
9290
- let n = await this.loadBy(e), r = Ha(e);
9351
+ let n = await this.loadBy(e), r = Ua(e);
9291
9352
  return r === void 0 && (r = n.type?.split(";")[0] ?? void 0), ((r ? this._handlers.get(r) : void 0) ?? this.defaultHandler)(n, t);
9292
9353
  }
9293
9354
  async waitUntilLoad() {
@@ -9301,14 +9362,14 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
9301
9362
  n && "destroy" in n && n.destroy();
9302
9363
  }), this._handled.clear();
9303
9364
  }
9304
- }, $ = new Wa().use(new Hn()).use(new Pa()).use(new Fa()).use(new Ia()).use(new La()).use(new Ra()).use(new za()), Ga = {
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 = {
9305
9366
  alpha: !0,
9306
9367
  stencil: !0,
9307
9368
  antialias: !1,
9308
9369
  premultipliedAlpha: !0,
9309
9370
  preserveDrawingBuffer: !1,
9310
9371
  powerPreference: "default"
9311
- }, Ka = class extends Sr {
9372
+ }, qa = class extends Sr {
9312
9373
  renderer;
9313
9374
  get view() {
9314
9375
  return this.renderer.view;
@@ -9341,12 +9402,12 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
9341
9402
  constructor(e = {}) {
9342
9403
  let { view: t, width: n, height: r, pixelRatio: i = Ye, autoResize: a, data: o } = e;
9343
9404
  super(), this.renderer = new Bn(t, {
9344
- alpha: Ga.alpha ?? e.alpha,
9345
- stencil: Ga.stencil ?? e.stencil,
9346
- antialias: Ga.antialias ?? e.antialias,
9347
- premultipliedAlpha: Ga.premultipliedAlpha ?? e.premultipliedAlpha,
9348
- preserveDrawingBuffer: Ga.preserveDrawingBuffer ?? e.preserveDrawingBuffer,
9349
- powerPreference: Ga.powerPreference ?? e.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
9350
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);
9351
9412
  }
9352
9413
  _updateProperty(e, t, n) {
@@ -9429,22 +9490,22 @@ var Ua = "WeakRef" in globalThis, Wa = class extends e {
9429
9490
  super._destroy(), this._resizeObserver?.disconnect(), this.renderer.destroy();
9430
9491
  }
9431
9492
  };
9432
- k([_({ fallback: !1 }), O("design:type", Boolean)], Ka.prototype, "autoResize", void 0), k([_({ fallback: !1 }), O("design:type", Boolean)], Ka.prototype, "autoStart", void 0);
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);
9433
9494
  //#endregion
9434
9495
  //#region src/render.ts
9435
- var qa, Ja = [], Ya = !1;
9436
- function Xa() {
9437
- return qa ??= new Ka({
9496
+ var Ja, Ya = [], Xa = !1;
9497
+ function Za() {
9498
+ return Ja ??= new qa({
9438
9499
  pixelRatio: 1,
9439
9500
  width: 1,
9440
9501
  height: 1,
9441
9502
  preserveDrawingBuffer: !0
9442
9503
  });
9443
9504
  }
9444
- async function Za(e = 100) {
9445
- if (!Ya) {
9446
- for (Ya = !0; Ja.length;) {
9447
- let t = Ja.shift();
9505
+ async function Qa(e = 100) {
9506
+ if (!Xa) {
9507
+ for (Xa = !0; Ya.length;) {
9508
+ let t = Ya.shift();
9448
9509
  if (t) try {
9449
9510
  await t();
9450
9511
  } catch (e) {
@@ -9452,11 +9513,11 @@ async function Za(e = 100) {
9452
9513
  }
9453
9514
  else await new Promise((t) => setTimeout(t, e));
9454
9515
  }
9455
- Ya = !1;
9516
+ Xa = !1;
9456
9517
  }
9457
9518
  }
9458
- async function Qa(e) {
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 = Xa();
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();
9460
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) {
9461
9522
  let e = o.length, t = o[e - 1];
9462
9523
  for (let n = 0; n < e; n++) {
@@ -9474,15 +9535,15 @@ async function Qa(e) {
9474
9535
  toCanvas2D: () => f.toCanvas2D(new ImageData(p, u, d))
9475
9536
  };
9476
9537
  }
9477
- async function $a(e) {
9538
+ async function eo(e) {
9478
9539
  return new Promise((t) => {
9479
- Ja.push(async () => t(await Qa(e).then((e) => e.toCanvas2D()))), Za();
9540
+ Ya.push(async () => t(await $a(e).then((e) => e.toCanvas2D()))), Qa();
9480
9541
  });
9481
9542
  }
9482
- async function eo(e) {
9543
+ async function to(e) {
9483
9544
  return new Promise((t) => {
9484
- Ja.push(async () => t(await Qa(e).then((e) => e.pixels))), Za();
9545
+ Ya.push(async () => t(await $a(e).then((e) => e.pixels))), Qa();
9485
9546
  });
9486
9547
  }
9487
9548
  //#endregion
9488
- export { yt as Aabb2D, $n as AnimatedTexture, da as Animation, Wa as Assets, Ca as Audio, ha as AudioPipeline, ga as AudioProcessor, wa as AudioSpectrum, Ta 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, Ka as Engine, Yi as Flexbox, Hn as FontLoader, Zr as GaussianBlurEffect, Wn as Geometry, Pa 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, ma as HTMLAudio, fa as HTMLAudioContext, pa as HTMLSound, qe as IN_BROWSER, Je as IN_MAC_OS, Un as IndexBuffer, _t as Input, dt as InputEvent, Fa as JsonLoader, si as KawaseBlurEffect, Da as KawaseTransition, ft as KeyboardInputEvent, ka as LeftEraseTransition, Vn as Loader, na as Lottie2D, Ia as LottieLoader, Tt as MainLoop, li as MaskEffect, I as Material, 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, La as TextLoader, z as Texture2D, Ra as TextureLoader, ta as TextureRect2D, x as Ticker, ja as TiltShiftTransition, br as Timeline, V as TimelineNode, ra as TransformRect2D, Cr as Transition, Na as TwistTransition, At as UniformGroup, Qn as UvGeometry, Zn as UvMaterial, F as VertexAttribute, P as VertexBuffer, ia as Video2D, za as VideoLoader, ar as VideoTexture, H as Viewport, or as ViewportTexture, xa as WebAudio, ya as WebAudioContext, Bn as WebGLRenderer, ba 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, la as cssEasingPresets, ca as cubicBezier, b as customNode, ye as customNodes, Ga 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, Xa 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, $a as render, eo as renderPixels, hr as resetBatchPool, Dr as routeConnection, nt as setCanvasFactory, at as setGlContextProvider, mn as stencilModeMap };
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
  }
@@ -1,6 +1,7 @@
1
1
  export * from './Camera2D';
2
2
  export * from './element';
3
3
  export * from './Lottie2D';
4
+ export * from './Mesh2D';
4
5
  export * from './Node2D';
5
6
  export * from './TextureRect2D';
6
7
  export * from './TransformRect2D';
@@ -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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.23.12",
4
+ "version": "0.23.13",
5
5
  "packageManager": "pnpm@10.19.0",
6
6
  "description": "A JavaScript WebGL rendering engine. only the ESM.",
7
7
  "author": "wxm",