@galacean/effects-threejs 2.0.2 → 2.1.0-alpha.0

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
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.2
6
+ * Version: v2.1.0-alpha.0
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -4567,7 +4567,6 @@ function getDirectStore(target) {
4567
4567
 
4568
4568
  /**
4569
4569
  * @since 2.0.0
4570
- * @internal
4571
4570
  */ var EffectsObject = /*#__PURE__*/ function() {
4572
4571
  function EffectsObject(engine) {
4573
4572
  this.engine = engine;
@@ -4603,92 +4602,112 @@ function getDirectStore(target) {
4603
4602
 
4604
4603
  /**
4605
4604
  * @since 2.0.0
4606
- * @internal
4607
4605
  */ var Component = /*#__PURE__*/ function(EffectsObject) {
4608
4606
  _inherits(Component, EffectsObject);
4609
4607
  function Component() {
4610
- return EffectsObject.apply(this, arguments);
4611
- }
4612
- var _proto = Component.prototype;
4613
- _proto.onAttached = function onAttached() {};
4614
- _proto.onDestroy = function onDestroy() {};
4615
- _proto.fromData = function fromData(data) {
4616
- EffectsObject.prototype.fromData.call(this, data);
4617
- if (data.item) {
4618
- this.item = data.item;
4619
- }
4620
- };
4621
- _proto.dispose = function dispose() {
4622
- this.onDestroy();
4623
- if (this.item) {
4624
- removeItem(this.item.components, this);
4625
- }
4626
- };
4627
- _create_class(Component, [
4628
- {
4629
- key: "transform",
4630
- get: /**
4631
- * 附加到的 VFXItem 对象 Transform 组件
4632
- */ function get() {
4633
- return this.item.transform;
4634
- }
4635
- }
4636
- ]);
4637
- return Component;
4638
- }(EffectsObject);
4639
- /**
4640
- * @since 2.0.0
4641
- * @internal
4642
- */ var Behaviour = /*#__PURE__*/ function(Component) {
4643
- _inherits(Behaviour, Component);
4644
- function Behaviour() {
4645
4608
  var _this;
4646
- _this = Component.apply(this, arguments) || this;
4609
+ _this = EffectsObject.apply(this, arguments) || this;
4647
4610
  _this.isAwakeCalled = false;
4648
4611
  _this.isStartCalled = false;
4612
+ _this.isEnableCalled = false;
4649
4613
  _this._enabled = true;
4650
4614
  return _this;
4651
4615
  }
4652
- var _proto = Behaviour.prototype;
4616
+ var _proto = Component.prototype;
4653
4617
  /**
4654
4618
  * 生命周期函数,初始化后调用,生命周期内只调用一次
4655
- */ _proto.awake = function awake() {
4619
+ */ _proto.onAwake = function onAwake() {
4656
4620
  // OVERRIDE
4657
4621
  };
4658
4622
  /**
4659
- * 在每次设置 enabled true 时触发
4623
+ * enabled 变为 true 时触发
4660
4624
  */ _proto.onEnable = function onEnable() {
4661
4625
  // OVERRIDE
4662
4626
  };
4663
4627
  /**
4628
+ * 在 enabled 变为 false 时触发
4629
+ */ _proto.onDisable = function onDisable() {
4630
+ // OVERRIDE
4631
+ };
4632
+ /**
4664
4633
  * 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
4665
- */ _proto.start = function start() {
4634
+ */ _proto.onStart = function onStart() {
4666
4635
  // OVERRIDE
4667
4636
  };
4668
4637
  /**
4669
4638
  * 生命周期函数,每帧调用一次
4670
- */ _proto.update = function update(dt) {
4639
+ */ _proto.onUpdate = function onUpdate(dt) {
4671
4640
  // OVERRIDE
4672
4641
  };
4673
4642
  /**
4674
4643
  * 生命周期函数,每帧调用一次,在 update 之后调用
4675
- */ _proto.lateUpdate = function lateUpdate(dt) {
4644
+ */ _proto.onLateUpdate = function onLateUpdate(dt) {
4645
+ // OVERRIDE
4646
+ };
4647
+ /**
4648
+ * 生命周期函数,在组件销毁时调用
4649
+ */ _proto.onDestroy = function onDestroy() {
4676
4650
  // OVERRIDE
4677
4651
  };
4678
- _proto.onAttached = function onAttached() {
4679
- this.item.itemBehaviours.push(this);
4680
- if (!this.isAwakeCalled) {
4681
- this.awake();
4682
- this.isAwakeCalled = true;
4652
+ /**
4653
+ * @internal
4654
+ */ _proto.enable = function enable() {
4655
+ if (this.item.composition) {
4656
+ this.item.composition.sceneTicking.addComponent(this);
4657
+ this.isEnableCalled = true;
4658
+ }
4659
+ this.onEnable();
4660
+ };
4661
+ /**
4662
+ * @internal
4663
+ */ _proto.disable = function disable() {
4664
+ this.onDisable();
4665
+ if (this.item.composition) {
4666
+ this.isEnableCalled = false;
4667
+ this.item.composition.sceneTicking.removeComponent(this);
4668
+ }
4669
+ };
4670
+ _proto.setVFXItem = function setVFXItem(item) {
4671
+ this.item = item;
4672
+ if (item.isDuringPlay) {
4673
+ if (!this.isAwakeCalled) {
4674
+ this.onAwake();
4675
+ this.isAwakeCalled = true;
4676
+ }
4677
+ if (item.getVisible() && this.enabled) {
4678
+ this.start();
4679
+ this.enable();
4680
+ }
4681
+ }
4682
+ };
4683
+ _proto.fromData = function fromData(data) {
4684
+ EffectsObject.prototype.fromData.call(this, data);
4685
+ if (data.item) {
4686
+ this.item = data.item;
4683
4687
  }
4684
4688
  };
4685
4689
  _proto.dispose = function dispose() {
4690
+ this.onDestroy();
4686
4691
  if (this.item) {
4687
- removeItem(this.item.itemBehaviours, this);
4692
+ removeItem(this.item.components, this);
4688
4693
  }
4689
- Component.prototype.dispose.call(this);
4690
4694
  };
4691
- _create_class(Behaviour, [
4695
+ _proto.start = function start() {
4696
+ if (this.isStartCalled) {
4697
+ return;
4698
+ }
4699
+ this.isStartCalled = true;
4700
+ this.onStart();
4701
+ };
4702
+ _create_class(Component, [
4703
+ {
4704
+ key: "transform",
4705
+ get: /**
4706
+ * 附加到的 VFXItem 对象 Transform 组件
4707
+ */ function get() {
4708
+ return this.item.transform;
4709
+ }
4710
+ },
4692
4711
  {
4693
4712
  key: "isActiveAndEnabled",
4694
4713
  get: /**
@@ -4703,24 +4722,46 @@ function getDirectStore(target) {
4703
4722
  return this._enabled;
4704
4723
  },
4705
4724
  set: function set(value) {
4706
- this._enabled = value;
4707
- if (value) {
4708
- if (this.isActiveAndEnabled) {
4709
- this.onEnable();
4710
- }
4711
- if (!this.isStartCalled) {
4712
- this.start();
4713
- this.isStartCalled = true;
4725
+ if (this.enabled !== value) {
4726
+ this._enabled = value;
4727
+ if (value) {
4728
+ if (this.isActiveAndEnabled) {
4729
+ this.enable();
4730
+ if (!this.isStartCalled) {
4731
+ this.onStart();
4732
+ this.isStartCalled = true;
4733
+ }
4734
+ }
4735
+ } else {
4736
+ if (this.isEnableCalled) {
4737
+ this.disable();
4738
+ }
4714
4739
  }
4715
4740
  }
4716
4741
  }
4717
4742
  }
4718
4743
  ]);
4719
- return Behaviour;
4720
- }(Component);
4744
+ return Component;
4745
+ }(EffectsObject);
4721
4746
  __decorate([
4722
4747
  serialize()
4723
- ], Behaviour.prototype, "_enabled", void 0);
4748
+ ], Component.prototype, "_enabled", void 0);
4749
+ /**
4750
+ * @since 2.0.0
4751
+ */ var Behaviour = /*#__PURE__*/ function(Component) {
4752
+ _inherits(Behaviour, Component);
4753
+ function Behaviour() {
4754
+ return Component.apply(this, arguments);
4755
+ }
4756
+ var _proto = Behaviour.prototype;
4757
+ _proto.setVFXItem = function setVFXItem(item) {
4758
+ Component.prototype.setVFXItem.call(this, item);
4759
+ };
4760
+ _proto.dispose = function dispose() {
4761
+ Component.prototype.dispose.call(this);
4762
+ };
4763
+ return Behaviour;
4764
+ }(Component);
4724
4765
 
4725
4766
  /**
4726
4767
  * 所有渲染组件的基类
@@ -4730,19 +4771,14 @@ __decorate([
4730
4771
  function RendererComponent() {
4731
4772
  var _this;
4732
4773
  _this = Component.apply(this, arguments) || this;
4733
- _this.isStartCalled = false;
4734
4774
  _this.materials = [];
4735
4775
  _this._priority = 0;
4736
- _this._enabled = true;
4737
4776
  return _this;
4738
4777
  }
4739
4778
  var _proto = RendererComponent.prototype;
4740
- _proto.onEnable = function onEnable() {};
4741
- _proto.start = function start() {};
4742
- _proto.update = function update(dt) {};
4743
- _proto.lateUpdate = function lateUpdate(dt) {};
4744
4779
  _proto.render = function render(renderer) {};
4745
- _proto.onAttached = function onAttached() {
4780
+ _proto.setVFXItem = function setVFXItem(item) {
4781
+ Component.prototype.setVFXItem.call(this, item);
4746
4782
  this.item.rendererComponents.push(this);
4747
4783
  };
4748
4784
  _proto.fromData = function fromData(data) {
@@ -4767,26 +4803,6 @@ __decorate([
4767
4803
  this._priority = value;
4768
4804
  }
4769
4805
  },
4770
- {
4771
- key: "enabled",
4772
- get: function get() {
4773
- return this._enabled;
4774
- },
4775
- set: function set(value) {
4776
- this._enabled = value;
4777
- if (value) {
4778
- this.onEnable();
4779
- }
4780
- }
4781
- },
4782
- {
4783
- key: "isActiveAndEnabled",
4784
- get: /**
4785
- * 组件是否可以更新,true 更新,false 不更新
4786
- */ function get() {
4787
- return this.item.getVisible() && this.enabled;
4788
- }
4789
- },
4790
4806
  {
4791
4807
  key: "material",
4792
4808
  get: function get() {
@@ -4809,9 +4825,6 @@ __decorate([
4809
4825
  __decorate([
4810
4826
  serialize()
4811
4827
  ], RendererComponent.prototype, "_priority", void 0);
4812
- __decorate([
4813
- serialize()
4814
- ], RendererComponent.prototype, "_enabled", void 0);
4815
4828
 
4816
4829
  /**
4817
4830
  * 抽象插件类
@@ -4855,7 +4868,7 @@ var CameraController = /*#__PURE__*/ function(Behaviour) {
4855
4868
  return _this;
4856
4869
  }
4857
4870
  var _proto = CameraController.prototype;
4858
- _proto.update = function update() {
4871
+ _proto.onUpdate = function onUpdate() {
4859
4872
  if (this.item.composition && this.item.transform.getValid()) {
4860
4873
  var camera = this.item.composition.camera;
4861
4874
  camera.near = this.options.near;
@@ -8087,7 +8100,7 @@ function _loadVideo() {
8087
8100
  }, true);
8088
8101
  }
8089
8102
  video.addEventListener("error", function(e) {
8090
- reject(e);
8103
+ reject("Load video fail.");
8091
8104
  });
8092
8105
  })
8093
8106
  ];
@@ -13253,7 +13266,7 @@ var InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13253
13266
  return _this;
13254
13267
  }
13255
13268
  var _proto = InteractComponent.prototype;
13256
- _proto.start = function start() {
13269
+ _proto.onStart = function onStart() {
13257
13270
  var _this = this;
13258
13271
  var options = this.item.props.content.options;
13259
13272
  var env = this.item.engine.renderer.env;
@@ -13289,8 +13302,11 @@ var InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13289
13302
  }
13290
13303
  };
13291
13304
  };
13292
- _proto.update = function update(dt) {
13305
+ _proto.onUpdate = function onUpdate(dt) {
13293
13306
  var _this_previewContent;
13307
+ if (!this.isActiveAndEnabled) {
13308
+ return;
13309
+ }
13294
13310
  (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
13295
13311
  if (!this.hasBeenAddedToComposition && this.item.composition) {
13296
13312
  var options = this.item.props.content.options;
@@ -13561,7 +13577,6 @@ function _assert_this_initialized(self) {
13561
13577
  /**
13562
13578
  * 动画图,负责更新所有的动画节点
13563
13579
  * @since 2.0.0
13564
- * @internal
13565
13580
  */ var PlayableGraph = /*#__PURE__*/ function() {
13566
13581
  function PlayableGraph() {
13567
13582
  this.playableOutputs = [];
@@ -13621,7 +13636,6 @@ function _assert_this_initialized(self) {
13621
13636
  /**
13622
13637
  * 动画图可播放节点对象
13623
13638
  * @since 2.0.0
13624
- * @internal
13625
13639
  */ var Playable = /*#__PURE__*/ function() {
13626
13640
  function Playable(graph, inputCount) {
13627
13641
  if (inputCount === void 0) inputCount = 0;
@@ -13635,6 +13649,9 @@ function _assert_this_initialized(self) {
13635
13649
  this.outputs = [];
13636
13650
  this.playState = 0;
13637
13651
  this.traversalMode = 0;
13652
+ /**
13653
+ * 当前本地播放的时间
13654
+ */ this.time = 0;
13638
13655
  graph.addPlayable(this);
13639
13656
  this.inputs = new Array(inputCount);
13640
13657
  this.inputOuputPorts = new Array(inputCount);
@@ -13819,7 +13836,6 @@ function _assert_this_initialized(self) {
13819
13836
  /**
13820
13837
  * 动画图输出节点对象,将动画数据采样到绑定的元素属性上
13821
13838
  * @since 2.0.0
13822
- * @internal
13823
13839
  */ var PlayableOutput = /*#__PURE__*/ function() {
13824
13840
  function PlayableOutput() {
13825
13841
  this.sourceOutputPort = 0;
@@ -13902,13 +13918,17 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
13902
13918
  if (!_instanceof1(boundObject, VFXItem)) {
13903
13919
  return;
13904
13920
  }
13921
+ if (!this.spriteComponent) {
13922
+ this.spriteComponent = boundObject.getComponent(SpriteComponent);
13923
+ }
13905
13924
  if (!this.spriteMaterial) {
13906
- this.spriteMaterial = boundObject.getComponent(SpriteComponent).material;
13925
+ this.spriteMaterial = this.spriteComponent.material;
13907
13926
  var startColor = this.spriteMaterial.getVector4("_Color");
13908
13927
  if (startColor) {
13909
13928
  this.startColor = startColor.toArray();
13910
13929
  }
13911
13930
  }
13931
+ this.spriteComponent.setAnimationTime(this.time);
13912
13932
  var colorInc = vecFill(tempColor, 1);
13913
13933
  var colorChanged;
13914
13934
  var life = this.time / boundObject.duration;
@@ -13968,7 +13988,6 @@ var SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
13968
13988
  _this = RendererComponent.call(this, engine) || this;
13969
13989
  _this.cachePrefix = "-";
13970
13990
  _this.frameAnimationLoop = false;
13971
- _this.frameAnimationTime = 0;
13972
13991
  _this.color = [
13973
13992
  1,
13974
13993
  1,
@@ -13976,6 +13995,8 @@ var SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
13976
13995
  1
13977
13996
  ];
13978
13997
  _this.visible = true;
13998
+ _this.isManualTimeSet = false;
13999
+ _this.frameAnimationTime = 0;
13979
14000
  _this.getHitTestParams = function(force) {
13980
14001
  var ui = _this.interaction;
13981
14002
  if (force || ui) {
@@ -14058,6 +14079,12 @@ var SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
14058
14079
  this.renderer.texture = texture;
14059
14080
  this.material.setTexture("uSampler0", texture);
14060
14081
  };
14082
+ /**
14083
+ * @internal
14084
+ */ _proto.setAnimationTime = function setAnimationTime(time) {
14085
+ this.frameAnimationTime = time;
14086
+ this.isManualTimeSet = true;
14087
+ };
14061
14088
  _proto.render = function render(renderer) {
14062
14089
  if (!this.getVisible()) {
14063
14090
  return;
@@ -14070,14 +14097,14 @@ var SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
14070
14097
  this.material.setVector2("_Size", this.transform.size);
14071
14098
  renderer.drawGeometry(geo, material);
14072
14099
  };
14073
- _proto.start = function start() {
14100
+ _proto.onStart = function onStart() {
14074
14101
  this.item.getHitTestParams = this.getHitTestParams;
14075
- if (this.item.endBehavior === EndBehavior.restart) {
14076
- this.frameAnimationLoop = true;
14077
- }
14078
14102
  };
14079
- _proto.update = function update(dt) {
14080
- this.frameAnimationTime += dt / 1000;
14103
+ _proto.onUpdate = function onUpdate(dt) {
14104
+ if (!this.isManualTimeSet) {
14105
+ this.frameAnimationTime += dt / 1000;
14106
+ this.isManualTimeSet = false;
14107
+ }
14081
14108
  var time = this.frameAnimationTime;
14082
14109
  var duration = this.item.duration;
14083
14110
  if (time > duration && this.frameAnimationLoop) {
@@ -16472,7 +16499,6 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16472
16499
 
16473
16500
  /**
16474
16501
  * @since 2.0.0
16475
- * @internal
16476
16502
  */ var ParticleSystemRenderer = /*#__PURE__*/ function(RendererComponent) {
16477
16503
  _inherits(ParticleSystemRenderer, RendererComponent);
16478
16504
  function ParticleSystemRenderer(engine, particleMeshProps, trailMeshProps) {
@@ -16497,15 +16523,15 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16497
16523
  return _this;
16498
16524
  }
16499
16525
  var _proto = ParticleSystemRenderer.prototype;
16500
- _proto.start = function start() {
16526
+ _proto.onStart = function onStart() {
16501
16527
  this._priority = this.item.renderOrder;
16502
16528
  this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
16503
16529
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
16504
16530
  var mesh = _step.value;
16505
- mesh.start();
16531
+ mesh.onStart();
16506
16532
  }
16507
16533
  };
16508
- _proto.update = function update(dt) {
16534
+ _proto.onUpdate = function onUpdate(dt) {
16509
16535
  var time = this.particleMesh.time;
16510
16536
  this.particleMesh.mesh.material.setVector4("uParams", new Vector4(time, this.item.duration, 0, 0));
16511
16537
  };
@@ -16729,7 +16755,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
16729
16755
  _proto.getTextures = function getTextures() {
16730
16756
  return this.renderer.getTextures();
16731
16757
  };
16732
- _proto.start = function start() {
16758
+ _proto.startEmit = function startEmit() {
16733
16759
  if (!this.started || this.ended) {
16734
16760
  this.reset();
16735
16761
  this.started = true;
@@ -16755,7 +16781,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
16755
16781
  this.frozen = false;
16756
16782
  this.ended = false;
16757
16783
  };
16758
- _proto.onUpdate = function onUpdate(delta) {
16784
+ _proto.update = function update(delta) {
16759
16785
  var _this = this;
16760
16786
  if (this.started && !this.frozen) {
16761
16787
  var now = this.lastUpdate + delta / 1000;
@@ -17538,7 +17564,6 @@ function randomArrItem(arr, keepArr) {
17538
17564
 
17539
17565
  /**
17540
17566
  * @since 2.0.0
17541
- * @internal
17542
17567
  */ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
17543
17568
  _inherits(ParticleBehaviourPlayable, Playable);
17544
17569
  function ParticleBehaviourPlayable() {
@@ -17556,7 +17581,7 @@ function randomArrItem(arr, keepArr) {
17556
17581
  this.particleSystem = boundObject.getComponent(ParticleSystem);
17557
17582
  if (this.particleSystem) {
17558
17583
  this.particleSystem.name = boundObject.name;
17559
- this.particleSystem.start();
17584
+ this.particleSystem.startEmit();
17560
17585
  this.particleSystem.initEmitterTransform();
17561
17586
  }
17562
17587
  };
@@ -17576,7 +17601,7 @@ function randomArrItem(arr, keepArr) {
17576
17601
  if (Math.abs(this.time - this.lastTime) < 0.001) {
17577
17602
  deltaTime = 0;
17578
17603
  }
17579
- particleSystem.onUpdate(deltaTime);
17604
+ particleSystem.update(deltaTime);
17580
17605
  }
17581
17606
  this.lastTime = this.time;
17582
17607
  };
@@ -18598,7 +18623,6 @@ var tempSize = new Vector3(1, 1, 1);
18598
18623
  var tempPos = new Vector3();
18599
18624
  /**
18600
18625
  * @since 2.0.0
18601
- * @internal
18602
18626
  */ var TransformAnimationPlayable = /*#__PURE__*/ function(AnimationPlayable) {
18603
18627
  _inherits(TransformAnimationPlayable, AnimationPlayable);
18604
18628
  function TransformAnimationPlayable() {
@@ -18760,7 +18784,6 @@ TransformPlayableAsset = __decorate([
18760
18784
  ], TransformPlayableAsset);
18761
18785
  /**
18762
18786
  * @since 2.0.0
18763
- * @internal
18764
18787
  */ var ActivationPlayable = /*#__PURE__*/ function(Playable) {
18765
18788
  _inherits(ActivationPlayable, Playable);
18766
18789
  function ActivationPlayable() {
@@ -18911,7 +18934,6 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18911
18934
 
18912
18935
  /**
18913
18936
  * @since 2.0.0
18914
- * @internal
18915
18937
  */ var TimelineClip = /*#__PURE__*/ function() {
18916
18938
  function TimelineClip() {
18917
18939
  this.start = 0;
@@ -19309,25 +19331,15 @@ var TrackSortWrapper = function TrackSortWrapper(track, originalIndex) {
19309
19331
  this.track = track;
19310
19332
  this.originalIndex = originalIndex;
19311
19333
  };
19312
- function isAncestor(ancestorCandidate, descendantCandidate) {
19313
- var current = descendantCandidate.parent;
19314
- while(current){
19315
- if (current === ancestorCandidate) {
19316
- return true;
19317
- }
19318
- current = current.parent;
19319
- }
19320
- return false;
19321
- }
19322
19334
  function compareTracks(a, b) {
19323
19335
  var bindingA = a.track.binding;
19324
19336
  var bindingB = b.track.binding;
19325
19337
  if (!_instanceof1(bindingA, VFXItem) || !_instanceof1(bindingB, VFXItem)) {
19326
19338
  return a.originalIndex - b.originalIndex;
19327
19339
  }
19328
- if (isAncestor(bindingA, bindingB)) {
19340
+ if (VFXItem.isAncestor(bindingA, bindingB)) {
19329
19341
  return -1;
19330
- } else if (isAncestor(bindingB, bindingA)) {
19342
+ } else if (VFXItem.isAncestor(bindingB, bindingA)) {
19331
19343
  return 1;
19332
19344
  } else {
19333
19345
  return a.originalIndex - b.originalIndex; // 非父子关系的元素保持原始顺序
@@ -19336,7 +19348,6 @@ function compareTracks(a, b) {
19336
19348
 
19337
19349
  /**
19338
19350
  * @since 2.0.0
19339
- * @internal
19340
19351
  */ var CompositionComponent = /*#__PURE__*/ function(Behaviour) {
19341
19352
  _inherits(CompositionComponent, Behaviour);
19342
19353
  function CompositionComponent() {
@@ -19352,7 +19363,7 @@ function compareTracks(a, b) {
19352
19363
  return _this;
19353
19364
  }
19354
19365
  var _proto = CompositionComponent.prototype;
19355
- _proto.start = function start() {
19366
+ _proto.onStart = function onStart() {
19356
19367
  var _this_item_props = this.item.props, _this_item_props_startTime = _this_item_props.startTime, startTime = _this_item_props_startTime === void 0 ? 0 : _this_item_props_startTime;
19357
19368
  this.startTime = startTime;
19358
19369
  this.resolveBindings();
@@ -19380,7 +19391,7 @@ function compareTracks(a, b) {
19380
19391
  _proto.getReusable = function getReusable() {
19381
19392
  return this.reusable;
19382
19393
  };
19383
- _proto.update = function update(dt) {
19394
+ _proto.onUpdate = function onUpdate(dt) {
19384
19395
  var time = this.time;
19385
19396
  this.timelinePlayable.setTime(time);
19386
19397
  this.graph.evaluate(dt);
@@ -19416,7 +19427,9 @@ function compareTracks(a, b) {
19416
19427
  props.content = itemData.content;
19417
19428
  item = assetLoader.loadGUID(itemData.id);
19418
19429
  item.composition = this.item.composition;
19419
- var compositionComponent = item.addComponent(CompositionComponent);
19430
+ var compositionComponent = new CompositionComponent(this.engine);
19431
+ compositionComponent.item = item;
19432
+ item.components.push(compositionComponent);
19420
19433
  compositionComponent.data = props;
19421
19434
  compositionComponent.refId = refId;
19422
19435
  item.transform.parentTransform = this.transform;
@@ -19827,8 +19840,8 @@ var TextComponent = /*#__PURE__*/ function(SpriteComponent) {
19827
19840
  return _this;
19828
19841
  }
19829
19842
  var _proto = TextComponent.prototype;
19830
- _proto.update = function update(dt) {
19831
- SpriteComponent.prototype.update.call(this, dt);
19843
+ _proto.onUpdate = function onUpdate(dt) {
19844
+ SpriteComponent.prototype.onUpdate.call(this, dt);
19832
19845
  this.updateTexture();
19833
19846
  };
19834
19847
  _proto.fromData = function fromData(data) {
@@ -20243,7 +20256,7 @@ var EffectComponent = /*#__PURE__*/ function(RendererComponent) {
20243
20256
  return _this;
20244
20257
  }
20245
20258
  var _proto = EffectComponent.prototype;
20246
- _proto.start = function start() {
20259
+ _proto.onStart = function onStart() {
20247
20260
  this.item.getHitTestParams = this.getHitTestParams;
20248
20261
  };
20249
20262
  _proto.render = function render(renderer) {
@@ -20370,7 +20383,7 @@ var PostProcessVolume = /*#__PURE__*/ function(Behaviour) {
20370
20383
  return _this;
20371
20384
  }
20372
20385
  var _proto = PostProcessVolume.prototype;
20373
- _proto.start = function start() {
20386
+ _proto.onStart = function onStart() {
20374
20387
  var composition = this.item.composition;
20375
20388
  if (composition) {
20376
20389
  composition.globalVolume = this;
@@ -20512,8 +20525,8 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20512
20525
  */ _this.ended = false;
20513
20526
  _this.reusable = false;
20514
20527
  _this.type = ItemType.base;
20528
+ _this.isDuringPlay = false;
20515
20529
  _this.components = [];
20516
- _this.itemBehaviours = [];
20517
20530
  _this.rendererComponents = [];
20518
20531
  /**
20519
20532
  * 元素可见性,该值的改变会触发 `handleVisibleChanged` 回调
@@ -20523,6 +20536,7 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20523
20536
  * 元素动画的速度
20524
20537
  */ _this.speed = 1;
20525
20538
  _this.listIndex = 0;
20539
+ _this.isEnabled = false;
20526
20540
  _this.eventProcessor = new EventEmitter();
20527
20541
  _this.name = "VFXItem";
20528
20542
  _this.transform.name = _this.name;
@@ -20595,8 +20609,7 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20595
20609
  */ _proto.addComponent = function addComponent(classConstructor) {
20596
20610
  var newComponent = new classConstructor(this.engine);
20597
20611
  this.components.push(newComponent);
20598
- newComponent.item = this;
20599
- newComponent.onAttached();
20612
+ newComponent.setVFXItem(this);
20600
20613
  return newComponent;
20601
20614
  };
20602
20615
  /**
@@ -20629,21 +20642,22 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20629
20642
  return res;
20630
20643
  };
20631
20644
  _proto.setParent = function setParent(vfxItem) {
20632
- if (vfxItem === this) {
20645
+ if (vfxItem === this && !vfxItem) {
20633
20646
  return;
20634
20647
  }
20635
20648
  if (this.parent) {
20636
20649
  removeItem(this.parent.children, this);
20637
20650
  }
20638
20651
  this.parent = vfxItem;
20639
- if (vfxItem) {
20640
- if (!VFXItem.isCamera(this)) {
20641
- this.transform.parentTransform = vfxItem.transform;
20642
- }
20643
- vfxItem.children.push(this);
20644
- if (!this.composition) {
20645
- this.composition = vfxItem.composition;
20646
- }
20652
+ if (!VFXItem.isCamera(this)) {
20653
+ this.transform.parentTransform = vfxItem.transform;
20654
+ }
20655
+ vfxItem.children.push(this);
20656
+ if (!this.composition) {
20657
+ this.composition = vfxItem.composition;
20658
+ }
20659
+ if (!this.isDuringPlay && vfxItem.isDuringPlay) {
20660
+ this.beginPlay();
20647
20661
  }
20648
20662
  };
20649
20663
  /**
@@ -20674,6 +20688,7 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20674
20688
  */ _proto.setVisible = function setVisible(visible) {
20675
20689
  if (this.visible !== visible) {
20676
20690
  this.visible = !!visible;
20691
+ this.onActiveChanged();
20677
20692
  }
20678
20693
  };
20679
20694
  /**
@@ -20798,6 +20813,57 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20798
20813
  }
20799
20814
  return undefined;
20800
20815
  };
20816
+ /**
20817
+ * @internal
20818
+ */ _proto.beginPlay = function beginPlay() {
20819
+ this.isDuringPlay = true;
20820
+ if (this.composition && this.visible && !this.isEnabled) {
20821
+ this.onEnable();
20822
+ }
20823
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
20824
+ var child = _step.value;
20825
+ if (!child.isDuringPlay) {
20826
+ child.beginPlay();
20827
+ }
20828
+ }
20829
+ };
20830
+ /**
20831
+ * @internal
20832
+ */ _proto.onActiveChanged = function onActiveChanged() {
20833
+ if (!this.isEnabled) {
20834
+ this.onEnable();
20835
+ } else {
20836
+ this.onDisable();
20837
+ }
20838
+ };
20839
+ /**
20840
+ * @internal
20841
+ */ _proto.onEnable = function onEnable() {
20842
+ this.isEnabled = true;
20843
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
20844
+ var component = _step.value;
20845
+ if (component.enabled && !component.isStartCalled) {
20846
+ component.onStart();
20847
+ }
20848
+ }
20849
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.components), _step1; !(_step1 = _iterator1()).done;){
20850
+ var component1 = _step1.value;
20851
+ if (component1.enabled && !component1.isEnableCalled) {
20852
+ component1.enable();
20853
+ }
20854
+ }
20855
+ };
20856
+ /**
20857
+ * @internal
20858
+ */ _proto.onDisable = function onDisable() {
20859
+ this.isEnabled = false;
20860
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
20861
+ var component = _step.value;
20862
+ if (component.enabled && component.isEnableCalled) {
20863
+ component.disable();
20864
+ }
20865
+ }
20866
+ };
20801
20867
  _proto.fromData = function fromData(data) {
20802
20868
  EffectsObject.prototype.fromData.call(this, data);
20803
20869
  var id = data.id, name = data.name, delay = data.delay, parentId = data.parentId, endBehavior = data.endBehavior, transform = data.transform, _data_listIndex = data.listIndex, listIndex = _data_listIndex === void 0 ? 0 : _data_listIndex, _data_duration = data.duration, duration = _data_duration === void 0 ? 0 : _data_duration;
@@ -20847,14 +20913,10 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20847
20913
  if (duration <= 0) {
20848
20914
  throw new Error("Item duration can't be less than 0, see " + HELP_LINK["Item duration can't be less than 0"] + ".");
20849
20915
  }
20850
- this.itemBehaviours.length = 0;
20851
20916
  this.rendererComponents.length = 0;
20852
20917
  for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
20853
20918
  var component = _step.value;
20854
20919
  component.item = this;
20855
- if (_instanceof1(component, Behaviour)) {
20856
- this.itemBehaviours.push(component);
20857
- }
20858
20920
  if (_instanceof1(component, RendererComponent)) {
20859
20921
  this.rendererComponents.push(component);
20860
20922
  }
@@ -20959,6 +21021,16 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20959
21021
  VFXItem.isExtraCamera = function isExtraCamera(item) {
20960
21022
  return item.id === "extra-camera" && item.name === "extra-camera";
20961
21023
  };
21024
+ VFXItem.isAncestor = function isAncestor(ancestorCandidate, descendantCandidate) {
21025
+ var current = descendantCandidate.parent;
21026
+ while(current){
21027
+ if (current === ancestorCandidate) {
21028
+ return true;
21029
+ }
21030
+ current = current.parent;
21031
+ }
21032
+ return false;
21033
+ };
20962
21034
  _create_class(VFXItem, [
20963
21035
  {
20964
21036
  key: "content",
@@ -21625,7 +21697,6 @@ var SerializationHelper = /*#__PURE__*/ function() {
21625
21697
 
21626
21698
  /**
21627
21699
  * @since 2.0.0
21628
- * @internal
21629
21700
  */ var AssetLoader = /*#__PURE__*/ function() {
21630
21701
  function AssetLoader(engine) {
21631
21702
  this.engine = engine;
@@ -24097,7 +24168,7 @@ var seed$1 = 1;
24097
24168
  ];
24098
24169
  case 6:
24099
24170
  e = _state.sent();
24100
- throw new Error("Failed to load. Check the template or if the URL is " + (isVideo ? "video" : "image") + " type, URL: " + url + ", Error: " + e.message + ".");
24171
+ throw new Error("Failed to load. Check the template or if the URL is " + (isVideo ? "video" : "image") + " type, URL: " + url + ", Error: " + (e.message || e) + ".");
24101
24172
  case 7:
24102
24173
  return [
24103
24174
  3,
@@ -24832,6 +24903,109 @@ var listOrder = 0;
24832
24903
  return CompositionSourceManager;
24833
24904
  }();
24834
24905
 
24906
+ var SceneTicking = /*#__PURE__*/ function() {
24907
+ function SceneTicking() {
24908
+ this.update = new UpdateTickData();
24909
+ this.lateUpdate = new LateUpdateTickData();
24910
+ }
24911
+ var _proto = SceneTicking.prototype;
24912
+ _proto.addComponent = function addComponent(obj) {
24913
+ if (obj.onUpdate !== Component.prototype.onUpdate) {
24914
+ this.update.addComponent(obj);
24915
+ }
24916
+ if (obj.onLateUpdate !== Component.prototype.onLateUpdate) {
24917
+ this.lateUpdate.addComponent(obj);
24918
+ }
24919
+ };
24920
+ _proto.removeComponent = function removeComponent(obj) {
24921
+ if (obj.onUpdate !== Component.prototype.onUpdate) {
24922
+ this.update.removeComponent(obj);
24923
+ }
24924
+ if (obj.onLateUpdate !== Component.prototype.onLateUpdate) {
24925
+ this.lateUpdate.removeComponent(obj);
24926
+ }
24927
+ };
24928
+ _proto.clear = function clear() {
24929
+ this.update.clear();
24930
+ this.lateUpdate.clear();
24931
+ };
24932
+ return SceneTicking;
24933
+ }();
24934
+ var TickData = /*#__PURE__*/ function() {
24935
+ function TickData() {
24936
+ this.components = [];
24937
+ this.ticks = [];
24938
+ }
24939
+ var _proto = TickData.prototype;
24940
+ _proto.tick = function tick(dt) {
24941
+ this.tickComponents(this.components, dt);
24942
+ for(var i = 0; i < this.ticks.length; i++){
24943
+ this.ticks[i](dt);
24944
+ }
24945
+ };
24946
+ _proto.tickComponents = function tickComponents(components, dt) {
24947
+ // To be implemented in derived classes
24948
+ };
24949
+ _proto.addComponent = function addComponent(component) {
24950
+ if (!this.components.includes(component)) {
24951
+ this.components.push(component);
24952
+ }
24953
+ };
24954
+ _proto.removeComponent = function removeComponent(component) {
24955
+ var index = this.components.indexOf(component);
24956
+ if (index > -1) {
24957
+ this.components.splice(index, 1);
24958
+ }
24959
+ };
24960
+ _proto.addTick = function addTick(method, callee) {
24961
+ var tick = method.bind(callee);
24962
+ if (!this.ticks.includes(tick)) {
24963
+ this.ticks.push(tick);
24964
+ }
24965
+ };
24966
+ _proto.clear = function clear() {
24967
+ this.components = [];
24968
+ };
24969
+ return TickData;
24970
+ }();
24971
+ var UpdateTickData = /*#__PURE__*/ function(TickData) {
24972
+ _inherits(UpdateTickData, TickData);
24973
+ function UpdateTickData() {
24974
+ return TickData.apply(this, arguments);
24975
+ }
24976
+ var _proto = UpdateTickData.prototype;
24977
+ _proto.tickComponents = function tickComponents(components, dt) {
24978
+ for(var _iterator = _create_for_of_iterator_helper_loose(components), _step; !(_step = _iterator()).done;){
24979
+ var component = _step.value;
24980
+ component.onUpdate(dt);
24981
+ }
24982
+ };
24983
+ return UpdateTickData;
24984
+ }(TickData);
24985
+ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24986
+ _inherits(LateUpdateTickData, TickData);
24987
+ function LateUpdateTickData() {
24988
+ return TickData.apply(this, arguments);
24989
+ }
24990
+ var _proto = LateUpdateTickData.prototype;
24991
+ _proto.tickComponents = function tickComponents(components, dt) {
24992
+ for(var _iterator = _create_for_of_iterator_helper_loose(components), _step; !(_step = _iterator()).done;){
24993
+ var component = _step.value;
24994
+ component.onLateUpdate(dt);
24995
+ }
24996
+ };
24997
+ return LateUpdateTickData;
24998
+ } // function compareComponents (a: Component, b: Component): number {
24999
+ // const itemA = a.item;
25000
+ // const itemB = b.item;
25001
+ // if (VFXItem.isAncestor(itemA, itemB)) {
25002
+ // return -1;
25003
+ // } else {
25004
+ // return 1;
25005
+ // }
25006
+ // }
25007
+ (TickData);
25008
+
24835
25009
  /**
24836
25010
  * 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
24837
25011
  * 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
@@ -24841,6 +25015,7 @@ var listOrder = 0;
24841
25015
  function Composition(props, scene) {
24842
25016
  var _this;
24843
25017
  _this = EventEmitter.call(this) || this;
25018
+ _this.sceneTicking = new SceneTicking();
24844
25019
  /**
24845
25020
  * 动画播放速度
24846
25021
  */ _this.speed = 1;
@@ -24878,9 +25053,12 @@ var listOrder = 0;
24878
25053
  _this.rootItem = new VFXItem(_this.getEngine(), sourceContent);
24879
25054
  _this.rootItem.name = "rootItem";
24880
25055
  _this.rootItem.composition = _assert_this_initialized(_this);
24881
- _this.rootComposition = _this.rootItem.addComponent(CompositionComponent);
25056
+ // Spawn rootCompositionComponent
25057
+ _this.rootComposition = new CompositionComponent(_this.getEngine());
24882
25058
  _this.rootComposition.startTime = sourceContent.startTime;
24883
25059
  _this.rootComposition.data = sourceContent;
25060
+ _this.rootComposition.item = _this.rootItem;
25061
+ _this.rootItem.components.push(_this.rootComposition);
24884
25062
  var imageUsage = !reusable && imgUsage;
24885
25063
  _this.width = width;
24886
25064
  _this.height = height;
@@ -24914,7 +25092,6 @@ var listOrder = 0;
24914
25092
  _this.rendererOptions = null;
24915
25093
  _this.rootComposition.createContent();
24916
25094
  _this.buildItemTree(_this.rootItem);
24917
- _this.callAwake(_this.rootItem);
24918
25095
  _this.rootItem.onEnd = function() {
24919
25096
  window.setTimeout(function() {
24920
25097
  _this.emit("end", {
@@ -24926,6 +25103,16 @@ var listOrder = 0;
24926
25103
  return _this;
24927
25104
  }
24928
25105
  var _proto = Composition.prototype;
25106
+ _proto.initializeSceneTicking = function initializeSceneTicking(item) {
25107
+ for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
25108
+ var component = _step.value;
25109
+ this.sceneTicking.addComponent(component);
25110
+ }
25111
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(item.children), _step1; !(_step1 = _iterator1()).done;){
25112
+ var child = _step1.value;
25113
+ this.initializeSceneTicking(child);
25114
+ }
25115
+ };
24929
25116
  /**
24930
25117
  * 获取合成的时长
24931
25118
  */ _proto.getDuration = function getDuration() {
@@ -25028,7 +25215,7 @@ var listOrder = 0;
25028
25215
  this.resume();
25029
25216
  }
25030
25217
  if (!this.rootComposition.isStartCalled) {
25031
- this.rootComposition.start();
25218
+ this.rootComposition.onStart();
25032
25219
  this.rootComposition.isStartCalled = true;
25033
25220
  }
25034
25221
  this.forwardTime(time + this.startTime);
@@ -25105,9 +25292,12 @@ var listOrder = 0;
25105
25292
  // 更新 model-tree-plugin
25106
25293
  this.updatePluginLoaders(deltaTime);
25107
25294
  // scene VFXItem components lifetime function.
25108
- this.callStart(this.rootItem);
25109
- this.callUpdate(this.rootItem, time);
25110
- this.callLateUpdate(this.rootItem, time);
25295
+ if (!this.rootItem.isDuringPlay) {
25296
+ this.callAwake(this.rootItem);
25297
+ this.rootItem.beginPlay();
25298
+ }
25299
+ this.sceneTicking.update.tick(time);
25300
+ this.sceneTicking.lateUpdate.tick(time);
25111
25301
  this.updateCamera();
25112
25302
  this.prepareRender();
25113
25303
  if (this.shouldDispose()) {
@@ -25160,11 +25350,11 @@ var listOrder = 0;
25160
25350
  return t;
25161
25351
  };
25162
25352
  _proto.callAwake = function callAwake(item) {
25163
- for(var _iterator = _create_for_of_iterator_helper_loose(item.itemBehaviours), _step; !(_step = _iterator()).done;){
25164
- var itemBehaviour = _step.value;
25165
- if (!itemBehaviour.isAwakeCalled) {
25166
- itemBehaviour.awake();
25167
- itemBehaviour.isAwakeCalled = true;
25353
+ for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
25354
+ var component = _step.value;
25355
+ if (!component.isAwakeCalled) {
25356
+ component.onAwake();
25357
+ component.isAwakeCalled = true;
25168
25358
  }
25169
25359
  }
25170
25360
  for(var _iterator1 = _create_for_of_iterator_helper_loose(item.children), _step1; !(_step1 = _iterator1()).done;){
@@ -25172,72 +25362,6 @@ var listOrder = 0;
25172
25362
  this.callAwake(child);
25173
25363
  }
25174
25364
  };
25175
- _proto.callStart = function callStart(item) {
25176
- for(var _iterator = _create_for_of_iterator_helper_loose(item.itemBehaviours), _step; !(_step = _iterator()).done;){
25177
- var itemBehaviour = _step.value;
25178
- if (itemBehaviour.isActiveAndEnabled && !itemBehaviour.isStartCalled) {
25179
- itemBehaviour.start();
25180
- itemBehaviour.isStartCalled = true;
25181
- }
25182
- }
25183
- for(var _iterator1 = _create_for_of_iterator_helper_loose(item.rendererComponents), _step1; !(_step1 = _iterator1()).done;){
25184
- var rendererComponent = _step1.value;
25185
- if (rendererComponent.isActiveAndEnabled && !rendererComponent.isStartCalled) {
25186
- rendererComponent.start();
25187
- rendererComponent.isStartCalled = true;
25188
- }
25189
- }
25190
- for(var _iterator2 = _create_for_of_iterator_helper_loose(item.children), _step2; !(_step2 = _iterator2()).done;){
25191
- var child = _step2.value;
25192
- this.callStart(child);
25193
- }
25194
- };
25195
- _proto.callUpdate = function callUpdate(item, dt) {
25196
- for(var _iterator = _create_for_of_iterator_helper_loose(item.itemBehaviours), _step; !(_step = _iterator()).done;){
25197
- var itemBehaviour = _step.value;
25198
- if (itemBehaviour.isActiveAndEnabled && itemBehaviour.isStartCalled) {
25199
- itemBehaviour.update(dt);
25200
- }
25201
- }
25202
- for(var _iterator1 = _create_for_of_iterator_helper_loose(item.rendererComponents), _step1; !(_step1 = _iterator1()).done;){
25203
- var rendererComponent = _step1.value;
25204
- if (rendererComponent.isActiveAndEnabled && rendererComponent.isStartCalled) {
25205
- rendererComponent.update(dt);
25206
- }
25207
- }
25208
- for(var _iterator2 = _create_for_of_iterator_helper_loose(item.children), _step2; !(_step2 = _iterator2()).done;){
25209
- var child = _step2.value;
25210
- if (VFXItem.isComposition(child)) {
25211
- if (child.ended && child.endBehavior === EndBehavior.restart) {
25212
- child.ended = false;
25213
- // TODO K帧动画在元素重建后需要 tick ,否则会导致元素位置和 k 帧第一帧位置不一致
25214
- this.callUpdate(child, 0);
25215
- } else {
25216
- this.callUpdate(child, dt);
25217
- }
25218
- } else {
25219
- this.callUpdate(child, dt);
25220
- }
25221
- }
25222
- };
25223
- _proto.callLateUpdate = function callLateUpdate(item, dt) {
25224
- for(var _iterator = _create_for_of_iterator_helper_loose(item.itemBehaviours), _step; !(_step = _iterator()).done;){
25225
- var itemBehaviour = _step.value;
25226
- if (itemBehaviour.isActiveAndEnabled && itemBehaviour.isStartCalled) {
25227
- itemBehaviour.lateUpdate(dt);
25228
- }
25229
- }
25230
- for(var _iterator1 = _create_for_of_iterator_helper_loose(item.rendererComponents), _step1; !(_step1 = _iterator1()).done;){
25231
- var rendererComponent = _step1.value;
25232
- if (rendererComponent.isActiveAndEnabled && rendererComponent.isStartCalled) {
25233
- rendererComponent.lateUpdate(dt);
25234
- }
25235
- }
25236
- for(var _iterator2 = _create_for_of_iterator_helper_loose(item.children), _step2; !(_step2 = _iterator2()).done;){
25237
- var child = _step2.value;
25238
- this.callLateUpdate(child, dt);
25239
- }
25240
- };
25241
25365
  /**
25242
25366
  * 构建父子树,同时保存到 itemCacheMap 中便于查找
25243
25367
  */ _proto.buildItemTree = function buildItemTree(compVFXItem) {
@@ -27111,7 +27235,6 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
27111
27235
 
27112
27236
  /**
27113
27237
  * @since 2.0.0
27114
- * @internal
27115
27238
  */ var EffectsPackage = /*#__PURE__*/ function() {
27116
27239
  function EffectsPackage() {
27117
27240
  this.exportObjectDatas = [];
@@ -27520,11 +27643,12 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
27520
27643
  return Engine;
27521
27644
  }();
27522
27645
 
27646
+ var DEFAULT_FPS = 60;
27523
27647
  /**
27524
27648
  * 定时器类
27525
27649
  */ var Ticker = /*#__PURE__*/ function() {
27526
27650
  function Ticker(fps) {
27527
- if (fps === void 0) fps = 60;
27651
+ if (fps === void 0) fps = DEFAULT_FPS;
27528
27652
  this.paused = true;
27529
27653
  this.lastTime = 0;
27530
27654
  // deltaTime
@@ -27659,7 +27783,7 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
27659
27783
  registerPlugin("particle", ParticleLoader, VFXItem, true);
27660
27784
  registerPlugin("cal", CalculateLoader, VFXItem, true);
27661
27785
  registerPlugin("interact", InteractLoader, VFXItem, true);
27662
- var version$1 = "2.0.2";
27786
+ var version$1 = "2.1.0-alpha.0";
27663
27787
  logger.info("Core version: " + version$1 + ".");
27664
27788
 
27665
27789
  var _obj;
@@ -28592,8 +28716,8 @@ var seed = 1;
28592
28716
  this.material = mtl;
28593
28717
  this.mesh.material = mtl.material;
28594
28718
  };
28595
- _proto.start = function start() {
28596
- Mesh.prototype.start.call(this);
28719
+ _proto.onStart = function onStart() {
28720
+ Mesh.prototype.onStart.call(this);
28597
28721
  this.engine.threeGroup.add(this.mesh);
28598
28722
  };
28599
28723
  /**
@@ -29200,8 +29324,8 @@ var ThreeSpriteComponent = /*#__PURE__*/ function(SpriteComponent) {
29200
29324
  }
29201
29325
  }
29202
29326
  };
29203
- _proto.start = function start() {
29204
- SpriteComponent.prototype.start.call(this);
29327
+ _proto.onStart = function onStart() {
29328
+ SpriteComponent.prototype.onStart.call(this);
29205
29329
  this.engine.threeGroup.add(this.threeMesh);
29206
29330
  };
29207
29331
  _proto.render = function render(renderer) {
@@ -29272,8 +29396,8 @@ var ThreeTextComponent = /*#__PURE__*/ function(ThreeSpriteComponent) {
29272
29396
  return _this;
29273
29397
  }
29274
29398
  var _proto = ThreeTextComponent.prototype;
29275
- _proto.update = function update(dt) {
29276
- ThreeSpriteComponent.prototype.update.call(this, dt);
29399
+ _proto.onUpdate = function onUpdate(dt) {
29400
+ ThreeSpriteComponent.prototype.onUpdate.call(this, dt);
29277
29401
  this.updateTexture(false);
29278
29402
  };
29279
29403
  _proto.fromData = function fromData(data) {
@@ -29340,8 +29464,8 @@ setMaxSpriteMeshItemCount(8);
29340
29464
  */ Mesh.create = function(engine, props) {
29341
29465
  return new ThreeMesh(engine, props);
29342
29466
  };
29343
- var version = "2.0.2";
29467
+ var version = "2.1.0-alpha.0";
29344
29468
  logger.info("THREEJS plugin version: " + version + ".");
29345
29469
 
29346
- export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSceneJSON, isSceneURL, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
29470
+ export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSceneJSON, isSceneURL, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
29347
29471
  //# sourceMappingURL=index.mjs.map