modern-canvas 0.4.5 → 0.4.6

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.mjs CHANGED
@@ -6133,6 +6133,7 @@ let TimelineNode = class extends Node {
6133
6133
  this.computedDuration = parent?.computedDuration ? Math.min(this._startTime + this.duration, parent.endTime) - this._startTime : this.duration;
6134
6134
  this._currentTime = this.timelineCurrentTime - this._startTime;
6135
6135
  this.emit("updateCurrentTime", this._currentTime);
6136
+ this.insideTimeRange = this.isInsideTimeRange();
6136
6137
  }
6137
6138
  }
6138
6139
  _process(delta) {
@@ -6149,6 +6150,9 @@ __decorateClass$H([
6149
6150
  __decorateClass$H([
6150
6151
  property({ default: false })
6151
6152
  ], TimelineNode.prototype, "paused", 2);
6153
+ __decorateClass$H([
6154
+ protectedProperty()
6155
+ ], TimelineNode.prototype, "insideTimeRange", 2);
6152
6156
  TimelineNode = __decorateClass$H([
6153
6157
  customNode("TimelineNode")
6154
6158
  ], TimelineNode);
@@ -8034,6 +8038,7 @@ let CanvasItem = class extends TimelineNode {
8034
8038
  this._updateGlobalOpacity();
8035
8039
  break;
8036
8040
  case "visible":
8041
+ case "insideTimeRange":
8037
8042
  this._updateGlobalVisible();
8038
8043
  break;
8039
8044
  }
@@ -8064,7 +8069,7 @@ let CanvasItem = class extends TimelineNode {
8064
8069
  }
8065
8070
  _updateGlobalVisible() {
8066
8071
  this._parentGlobalVisible = this.getParent()?.globalVisible;
8067
- this._globalVisible = this.visible && (this._parentGlobalVisible ?? true);
8072
+ this._globalVisible = (this._parentGlobalVisible ?? true) && this.visible && this.insideTimeRange;
8068
8073
  }
8069
8074
  _updateGlobalOpacity() {
8070
8075
  this._parentGlobalOpacity = this.getParent()?.opacity;
@@ -13136,25 +13141,25 @@ class Engine extends SceneTree {
13136
13141
  }
13137
13142
  toCanvas2D() {
13138
13143
  const imageData = this.toImageData();
13139
- const canvas0 = document.createElement("canvas");
13140
- canvas0.width = imageData.width;
13141
- canvas0.height = imageData.height;
13142
- canvas0.getContext("2d")?.putImageData(imageData, 0, 0);
13143
- const canvas = document.createElement("canvas");
13144
- canvas.width = this.width;
13145
- canvas.height = this.height;
13146
- canvas.getContext("2d")?.drawImage(
13147
- canvas0,
13144
+ const canvas1 = document.createElement("canvas");
13145
+ canvas1.width = imageData.width;
13146
+ canvas1.height = imageData.height;
13147
+ canvas1.getContext("2d")?.putImageData(imageData, 0, 0);
13148
+ const canvas2 = document.createElement("canvas");
13149
+ canvas2.width = this.width;
13150
+ canvas2.height = this.height;
13151
+ canvas2.getContext("2d")?.drawImage(
13152
+ canvas1,
13148
13153
  0,
13149
13154
  0,
13150
- canvas0.width,
13151
- canvas0.height,
13155
+ canvas1.width,
13156
+ canvas1.height,
13152
13157
  0,
13153
13158
  0,
13154
- canvas.width,
13155
- canvas.height
13159
+ canvas2.width,
13160
+ canvas2.height
13156
13161
  );
13157
- return canvas;
13162
+ return canvas2;
13158
13163
  }
13159
13164
  }
13160
13165
 
@@ -13189,6 +13194,7 @@ async function performRender(options) {
13189
13194
  }
13190
13195
  });
13191
13196
  await engine.waitUntilLoad();
13197
+ await options.onBeforeRender?.(engine);
13192
13198
  return engine.toCanvas2D();
13193
13199
  }
13194
13200
  async function render(options) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.4.5",
4
+ "version": "0.4.6",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",