modern-canvas 0.23.13 → 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
@@ -4412,6 +4412,11 @@ var V = class extends B {
4412
4412
  _currentTime = 0;
4413
4413
  _globalStartTime = 0;
4414
4414
  _globalDuration = 0;
4415
+ _standalone = !1;
4416
+ _localCurrentTime = 0;
4417
+ get standalone() {
4418
+ return this._standalone;
4419
+ }
4415
4420
  get parentGlobalStartTime() {
4416
4421
  return this._parent?.globalStartTime ?? 0;
4417
4422
  }
@@ -4456,12 +4461,18 @@ var V = class extends B {
4456
4461
  _updateInsideTimeRange() {
4457
4462
  this.insideTimeRange = this.isInsideTimeRange();
4458
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
+ }
4459
4470
  _updateCurrentTime(e = !1) {
4460
4471
  if (e || !this._paused) {
4461
4472
  let e = this._parent, t = this.parentGlobalStartTime + this._delay, n = e?.globalDuration ? Math.min(t + this._duration, e.globalEndTime) - t : this._duration;
4462
4473
  this._globalStartTime = t, this._globalDuration = n;
4463
- let r = this._globalCurrentTime - this.globalStartTime;
4464
- 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();
4465
4476
  }
4466
4477
  }
4467
4478
  _process(e) {
@@ -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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.23.13",
4
+ "version": "0.23.14",
5
5
  "packageManager": "pnpm@10.19.0",
6
6
  "description": "A JavaScript WebGL rendering engine. only the ESM.",
7
7
  "author": "wxm",