modern-canvas 0.9.2 → 0.9.4
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.cjs +23 -11
- package/dist/index.d.cts +6 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +12 -12
- package/dist/index.mjs +23 -11
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -873,6 +873,9 @@ class CoreObject extends Reactivable {
|
|
|
873
873
|
get json() {
|
|
874
874
|
return this.toJSON();
|
|
875
875
|
}
|
|
876
|
+
set json(val) {
|
|
877
|
+
this.setProperties(val);
|
|
878
|
+
}
|
|
876
879
|
_nextTick() {
|
|
877
880
|
return nextTick();
|
|
878
881
|
}
|
|
@@ -4467,7 +4470,7 @@ class VertexAttribute extends Resource {
|
|
|
4467
4470
|
}
|
|
4468
4471
|
}
|
|
4469
4472
|
__decorateClass$W([
|
|
4470
|
-
property({
|
|
4473
|
+
property({ internal: true })
|
|
4471
4474
|
], VertexAttribute.prototype, "buffer");
|
|
4472
4475
|
__decorateClass$W([
|
|
4473
4476
|
property({ fallback: 0 })
|
|
@@ -4861,7 +4864,7 @@ class Texture2D extends Resource {
|
|
|
4861
4864
|
}
|
|
4862
4865
|
}
|
|
4863
4866
|
__decorateClass$V([
|
|
4864
|
-
property({
|
|
4867
|
+
property({ internal: true })
|
|
4865
4868
|
], Texture2D.prototype, "source");
|
|
4866
4869
|
__decorateClass$V([
|
|
4867
4870
|
property({ fallback: 0 })
|
|
@@ -6195,7 +6198,7 @@ __decorateClass$S([
|
|
|
6195
6198
|
property({ internal: true, fallback: "default" })
|
|
6196
6199
|
], Node.prototype, "internalMode", 2);
|
|
6197
6200
|
__decorateClass$S([
|
|
6198
|
-
property({
|
|
6201
|
+
property({ internal: true })
|
|
6199
6202
|
], Node.prototype, "mask", 2);
|
|
6200
6203
|
Node = __decorateClass$S([
|
|
6201
6204
|
customNode("Node")
|
|
@@ -6879,7 +6882,7 @@ let Effect = class extends TimelineNode {
|
|
|
6879
6882
|
}
|
|
6880
6883
|
};
|
|
6881
6884
|
__decorateClass$O([
|
|
6882
|
-
property({
|
|
6885
|
+
property({ internal: true })
|
|
6883
6886
|
], Effect.prototype, "material", 2);
|
|
6884
6887
|
__decorateClass$O([
|
|
6885
6888
|
property()
|
|
@@ -7013,6 +7016,7 @@ var __decorateClass$L = (decorators, target, key, kind) => {
|
|
|
7013
7016
|
return result;
|
|
7014
7017
|
};
|
|
7015
7018
|
class SceneTree extends MainLoop {
|
|
7019
|
+
fonts;
|
|
7016
7020
|
input = new Input();
|
|
7017
7021
|
renderStack = new RenderStack();
|
|
7018
7022
|
root = new Window(true).setTree(this);
|
|
@@ -8896,7 +8900,7 @@ void main(void) {
|
|
|
8896
8900
|
}`
|
|
8897
8901
|
}));
|
|
8898
8902
|
__decorateClass$w([
|
|
8899
|
-
property({
|
|
8903
|
+
property({ internal: true })
|
|
8900
8904
|
], MaskEffect.prototype, "texture", 2);
|
|
8901
8905
|
__decorateClass$w([
|
|
8902
8906
|
property({ fallback: "" })
|
|
@@ -9698,9 +9702,9 @@ class BaseElement2DText extends CoreObject {
|
|
|
9698
9702
|
constructor(parent) {
|
|
9699
9703
|
super();
|
|
9700
9704
|
this.parent = parent;
|
|
9701
|
-
this.base.setPropertyAccessor(this);
|
|
9705
|
+
this.base = new Text().setPropertyAccessor(this);
|
|
9702
9706
|
}
|
|
9703
|
-
base
|
|
9707
|
+
base;
|
|
9704
9708
|
measureResult;
|
|
9705
9709
|
_textureMap = /* @__PURE__ */ new Map();
|
|
9706
9710
|
setProperties(properties) {
|
|
@@ -9724,8 +9728,12 @@ class BaseElement2DText extends CoreObject {
|
|
|
9724
9728
|
break;
|
|
9725
9729
|
}
|
|
9726
9730
|
}
|
|
9727
|
-
|
|
9731
|
+
_updateBase() {
|
|
9732
|
+
this.base.fonts = this.base.fonts ?? this.parent.tree?.fonts;
|
|
9728
9733
|
this.base.update();
|
|
9734
|
+
}
|
|
9735
|
+
_updateTextureMap() {
|
|
9736
|
+
this._updateBase();
|
|
9729
9737
|
this._textureMap.clear();
|
|
9730
9738
|
const pGlyphBoxs = [];
|
|
9731
9739
|
this.base.paragraphs.forEach((p, pIndex) => {
|
|
@@ -9781,6 +9789,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9781
9789
|
this.content = normalizeTextContent(content);
|
|
9782
9790
|
}
|
|
9783
9791
|
measure() {
|
|
9792
|
+
this._updateBase();
|
|
9784
9793
|
return this.base.measure();
|
|
9785
9794
|
}
|
|
9786
9795
|
updateMeasure() {
|
|
@@ -9803,7 +9812,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9803
9812
|
}
|
|
9804
9813
|
draw() {
|
|
9805
9814
|
const ctx = this.parent.context;
|
|
9806
|
-
this.
|
|
9815
|
+
this._updateBase();
|
|
9807
9816
|
this.base.pathSets.forEach((pathSet) => {
|
|
9808
9817
|
pathSet.paths.forEach((path) => {
|
|
9809
9818
|
const meta = path.getMeta();
|
|
@@ -10926,7 +10935,7 @@ let Image2D = class extends Element2D {
|
|
|
10926
10935
|
}
|
|
10927
10936
|
};
|
|
10928
10937
|
__decorateClass$i([
|
|
10929
|
-
property({
|
|
10938
|
+
property({ internal: true })
|
|
10930
10939
|
], Image2D.prototype, "texture", 2);
|
|
10931
10940
|
__decorateClass$i([
|
|
10932
10941
|
property({ fallback: "" })
|
|
@@ -14165,6 +14174,7 @@ class Engine extends SceneTree {
|
|
|
14165
14174
|
height,
|
|
14166
14175
|
pixelRatio = DEVICE_PIXEL_RATIO,
|
|
14167
14176
|
backgroundColor = 0,
|
|
14177
|
+
fonts,
|
|
14168
14178
|
autoResize,
|
|
14169
14179
|
autoStart,
|
|
14170
14180
|
timeline,
|
|
@@ -14179,6 +14189,7 @@ class Engine extends SceneTree {
|
|
|
14179
14189
|
this._setupInput();
|
|
14180
14190
|
this.pixelRatio = pixelRatio;
|
|
14181
14191
|
this.backgroundColor = backgroundColor;
|
|
14192
|
+
this.fonts = fonts;
|
|
14182
14193
|
if (autoResize) {
|
|
14183
14194
|
if (!view && this.renderer.view) {
|
|
14184
14195
|
this.renderer.view.style.width = "100%";
|
|
@@ -14329,13 +14340,14 @@ async function start(sleep = 100) {
|
|
|
14329
14340
|
starting = false;
|
|
14330
14341
|
}
|
|
14331
14342
|
async function task(options) {
|
|
14332
|
-
const {
|
|
14343
|
+
const { debug = false, fonts, width, height, time = 0, data } = options;
|
|
14333
14344
|
engine ??= new Engine({
|
|
14334
14345
|
width: 1,
|
|
14335
14346
|
height: 1,
|
|
14336
14347
|
preserveDrawingBuffer: true
|
|
14337
14348
|
});
|
|
14338
14349
|
engine.debug = debug;
|
|
14350
|
+
engine.fonts = fonts;
|
|
14339
14351
|
engine.root.removeChildren();
|
|
14340
14352
|
engine.timeline.currentTime = time;
|
|
14341
14353
|
engine.resize(width, height, true);
|