@galacean/effects-core 2.0.3 → 2.0.5

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.
@@ -38,10 +38,6 @@ export declare class AssetManager implements Disposable {
38
38
  */
39
39
  constructor(options?: SceneLoadOptions, downloader?: Downloader);
40
40
  updateOptions(options?: SceneLoadOptions): void;
41
- /**
42
- * 根据用户传入的参数修改场景数据
43
- */
44
- private updateSceneData;
45
41
  /**
46
42
  * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
47
43
  * @param url - json 的 URL 链接或者 json 对象
@@ -32,6 +32,8 @@ export declare class CompositionComponent extends Behaviour {
32
32
  getReusable(): boolean;
33
33
  update(dt: number): void;
34
34
  createContent(): void;
35
+ showItems(): void;
36
+ hideItems(): void;
35
37
  onDestroy(): void;
36
38
  hitTest(ray: Ray, x: number, y: number, regions: Region[], force?: boolean, options?: CompositionHitTestOptions): Region[];
37
39
  fromData(data: unknown): void;
@@ -278,7 +278,6 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
278
278
  /**
279
279
  * 前进合成到指定时间
280
280
  * @param time - 相对0时刻的时间
281
- * @param skipRender - 是否跳过渲染
282
281
  */
283
282
  private forwardTime;
284
283
  /**
@@ -290,7 +289,6 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
290
289
  /**
291
290
  * 合成更新,针对所有 item 的更新
292
291
  * @param deltaTime - 更新的时间步长
293
- * @param skipRender - 是否需要渲染
294
292
  */
295
293
  update(deltaTime: number): void;
296
294
  private toLocalTime;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.3
6
+ * Version: v2.0.5
7
7
  */
8
8
 
9
9
  'use strict';
@@ -8086,7 +8086,7 @@ function _loadVideo() {
8086
8086
  }, true);
8087
8087
  }
8088
8088
  video.addEventListener("error", function(e) {
8089
- reject(e);
8089
+ reject("Load video fail.");
8090
8090
  });
8091
8091
  })
8092
8092
  ];
@@ -13560,7 +13560,6 @@ function _assert_this_initialized(self) {
13560
13560
  /**
13561
13561
  * 动画图,负责更新所有的动画节点
13562
13562
  * @since 2.0.0
13563
- * @internal
13564
13563
  */ var PlayableGraph = /*#__PURE__*/ function() {
13565
13564
  function PlayableGraph() {
13566
13565
  this.playableOutputs = [];
@@ -13568,25 +13567,25 @@ function _assert_this_initialized(self) {
13568
13567
  }
13569
13568
  var _proto = PlayableGraph.prototype;
13570
13569
  _proto.evaluate = function evaluate(dt) {
13571
- // 初始化节点状态
13572
- for(var _iterator = _create_for_of_iterator_helper_loose(this.playables), _step; !(_step = _iterator()).done;){
13573
- var playable = _step.value;
13574
- this.updatePlayableTime(playable, dt);
13575
- }
13576
13570
  // 初始化输出节点状态
13577
- for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13578
- var playableOutput = _step1.value;
13571
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.playableOutputs), _step; !(_step = _iterator()).done;){
13572
+ var playableOutput = _step.value;
13579
13573
  playableOutput.context.deltaTime = dt;
13580
13574
  }
13581
13575
  // 执行生命周期函数
13582
- for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13583
- var playableOutput1 = _step2.value;
13576
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13577
+ var playableOutput1 = _step1.value;
13584
13578
  this.prepareFrameWithRoot(playableOutput1);
13585
13579
  }
13586
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step3; !(_step3 = _iterator3()).done;){
13587
- var playableOutput2 = _step3.value;
13580
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13581
+ var playableOutput2 = _step2.value;
13588
13582
  this.processFrameWithRoot(playableOutput2);
13589
13583
  }
13584
+ // 更新节点时间
13585
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
13586
+ var playable = _step3.value;
13587
+ this.updatePlayableTime(playable, dt);
13588
+ }
13590
13589
  };
13591
13590
  _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
13592
13591
  destination.connectInput(destinationInputPort, source, sourceOutputPort);
@@ -13609,24 +13608,18 @@ function _assert_this_initialized(self) {
13609
13608
  if (playable.getPlayState() !== 0) {
13610
13609
  return;
13611
13610
  }
13612
- if (playable.overrideTimeNextEvaluation) {
13613
- playable.overrideTimeNextEvaluation = false;
13614
- } else {
13615
- playable.setTime(playable.getTime() + deltaTime);
13616
- }
13611
+ playable.setTime(playable.getTime() + deltaTime);
13617
13612
  };
13618
13613
  return PlayableGraph;
13619
13614
  }();
13620
13615
  /**
13621
13616
  * 动画图可播放节点对象
13622
13617
  * @since 2.0.0
13623
- * @internal
13624
13618
  */ var Playable = /*#__PURE__*/ function() {
13625
13619
  function Playable(graph, inputCount) {
13626
13620
  if (inputCount === void 0) inputCount = 0;
13627
13621
  this.onPlayablePlayFlag = true;
13628
13622
  this.onPlayablePauseFlag = false;
13629
- this.overrideTimeNextEvaluation = false;
13630
13623
  this.destroyed = false;
13631
13624
  this.inputs = [];
13632
13625
  this.inputOuputPorts = [];
@@ -13712,7 +13705,6 @@ function _assert_this_initialized(self) {
13712
13705
  };
13713
13706
  _proto.setTime = function setTime(time) {
13714
13707
  this.time = time;
13715
- this.overrideTimeNextEvaluation = true;
13716
13708
  };
13717
13709
  _proto.getTime = function getTime() {
13718
13710
  return this.time;
@@ -13818,7 +13810,6 @@ function _assert_this_initialized(self) {
13818
13810
  /**
13819
13811
  * 动画图输出节点对象,将动画数据采样到绑定的元素属性上
13820
13812
  * @since 2.0.0
13821
- * @internal
13822
13813
  */ var PlayableOutput = /*#__PURE__*/ function() {
13823
13814
  function PlayableOutput() {
13824
13815
  this.sourceOutputPort = 0;
@@ -16629,6 +16620,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16629
16620
  _proto.isFrozen = function isFrozen() {
16630
16621
  return this.frozen;
16631
16622
  };
16623
+ _proto.isEnded = function isEnded() {
16624
+ return this.ended;
16625
+ };
16632
16626
  _proto.initEmitterTransform = function initEmitterTransform() {
16633
16627
  var position = this.item.transform.position.clone();
16634
16628
  var rotation = this.item.transform.rotation.clone();
@@ -16821,7 +16815,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16821
16815
  break;
16822
16816
  }
16823
16817
  var burst = bursts[j];
16824
- var opts = burst.getGeneratorOptions(timePassed, lifetime);
16818
+ var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
16825
16819
  if (opts) {
16826
16820
  var originVec = [
16827
16821
  0,
@@ -16830,6 +16824,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16830
16824
  ];
16831
16825
  var offsets = emission.burstOffsets[j];
16832
16826
  var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
16827
+ if (burst.once) {
16828
+ this.removeBurst(j);
16829
+ }
16833
16830
  for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
16834
16831
  var _p_transform;
16835
16832
  if (shouldSkipGenerate()) {
@@ -17547,7 +17544,6 @@ function randomArrItem(arr, keepArr) {
17547
17544
 
17548
17545
  /**
17549
17546
  * @since 2.0.0
17550
- * @internal
17551
17547
  */ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
17552
17548
  _inherits(ParticleBehaviourPlayable, Playable);
17553
17549
  function ParticleBehaviourPlayable() {
@@ -17575,11 +17571,8 @@ function randomArrItem(arr, keepArr) {
17575
17571
  }
17576
17572
  var particleSystem = this.particleSystem;
17577
17573
  if (particleSystem) {
17578
- // TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
17579
- // particleSystem.setParentTransform(parentItem.transform);
17580
- particleSystem.setVisible(true);
17581
17574
  var deltaTime = context.deltaTime;
17582
- if (this.time < particleSystem.item.duration && particleSystem.isFrozen()) {
17575
+ if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
17583
17576
  particleSystem.reset();
17584
17577
  }
17585
17578
  if (Math.abs(this.time - this.lastTime) < 0.001) {
@@ -18607,7 +18600,6 @@ var tempSize = new Vector3(1, 1, 1);
18607
18600
  var tempPos = new Vector3();
18608
18601
  /**
18609
18602
  * @since 2.0.0
18610
- * @internal
18611
18603
  */ var TransformAnimationPlayable = /*#__PURE__*/ function(AnimationPlayable) {
18612
18604
  _inherits(TransformAnimationPlayable, AnimationPlayable);
18613
18605
  function TransformAnimationPlayable() {
@@ -18769,7 +18761,6 @@ exports.TransformPlayableAsset = __decorate([
18769
18761
  ], exports.TransformPlayableAsset);
18770
18762
  /**
18771
18763
  * @since 2.0.0
18772
- * @internal
18773
18764
  */ var ActivationPlayable = /*#__PURE__*/ function(Playable) {
18774
18765
  _inherits(ActivationPlayable, Playable);
18775
18766
  function ActivationPlayable() {
@@ -18920,7 +18911,6 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18920
18911
 
18921
18912
  /**
18922
18913
  * @since 2.0.0
18923
- * @internal
18924
18914
  */ var TimelineClip = /*#__PURE__*/ function() {
18925
18915
  function TimelineClip() {
18926
18916
  this.start = 0;
@@ -18930,7 +18920,7 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18930
18920
  _proto.toLocalTime = function toLocalTime(time) {
18931
18921
  var localTime = time - this.start;
18932
18922
  var duration = this.duration;
18933
- if (localTime - duration > 0.001) {
18923
+ if (localTime - duration > 0) {
18934
18924
  if (this.endBehavior === EndBehavior.restart) {
18935
18925
  localTime = localTime % duration;
18936
18926
  } else if (this.endBehavior === EndBehavior.freeze) {
@@ -19059,7 +19049,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
19059
19049
  var ended = false;
19060
19050
  var started = false;
19061
19051
  var boundObject = this.track.binding;
19062
- if (localTime > clip.start + clip.duration + 0.001 && clip.endBehavior === EndBehavior.destroy) {
19052
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
19063
19053
  if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
19064
19054
  weight = 1.0;
19065
19055
  } else {
@@ -19455,6 +19445,18 @@ function compareTracks(a, b) {
19455
19445
  }
19456
19446
  }
19457
19447
  };
19448
+ _proto.showItems = function showItems() {
19449
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
19450
+ var item = _step.value;
19451
+ item.setVisible(true);
19452
+ }
19453
+ };
19454
+ _proto.hideItems = function hideItems() {
19455
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
19456
+ var item = _step.value;
19457
+ item.setVisible(false);
19458
+ }
19459
+ };
19458
19460
  _proto.onDestroy = function onDestroy() {
19459
19461
  if (this.item.composition) {
19460
19462
  if (this.items) {
@@ -19565,6 +19567,34 @@ function compareTracks(a, b) {
19565
19567
  return CompositionComponent;
19566
19568
  }(Behaviour);
19567
19569
 
19570
+ var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
19571
+ _inherits(SubCompositionMixerPlayable, Playable);
19572
+ function SubCompositionMixerPlayable() {
19573
+ return Playable.apply(this, arguments);
19574
+ }
19575
+ var _proto = SubCompositionMixerPlayable.prototype;
19576
+ _proto.processFrame = function processFrame(context) {
19577
+ var boundObject = context.output.getUserData();
19578
+ if (!_instanceof1(boundObject, CompositionComponent)) {
19579
+ return;
19580
+ }
19581
+ var compositionComponent = boundObject;
19582
+ var hasInput = false;
19583
+ for(var i = 0; i < this.getInputCount(); i++){
19584
+ if (this.getInputWeight(i) > 0) {
19585
+ hasInput = true;
19586
+ break;
19587
+ }
19588
+ }
19589
+ if (hasInput) {
19590
+ compositionComponent.showItems();
19591
+ } else {
19592
+ compositionComponent.hideItems();
19593
+ }
19594
+ };
19595
+ return SubCompositionMixerPlayable;
19596
+ }(Playable);
19597
+
19568
19598
  exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
19569
19599
  _inherits(SubCompositionTrack, TrackAsset);
19570
19600
  function SubCompositionTrack() {
@@ -19577,6 +19607,9 @@ exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
19577
19607
  }
19578
19608
  return parentBinding.getComponent(CompositionComponent);
19579
19609
  };
19610
+ _proto.createTrackMixer = function createTrackMixer(graph) {
19611
+ return new SubCompositionMixerPlayable(graph);
19612
+ };
19580
19613
  return SubCompositionTrack;
19581
19614
  }(exports.TrackAsset);
19582
19615
  exports.SubCompositionTrack = __decorate([
@@ -23613,22 +23646,6 @@ var seed = 1;
23613
23646
  this.timeout = timeout;
23614
23647
  };
23615
23648
  /**
23616
- * 根据用户传入的参数修改场景数据
23617
- */ _proto.updateSceneData = function updateSceneData(items) {
23618
- var variables = this.options.variables;
23619
- if (!variables || Object.keys(variables).length === 0) {
23620
- return;
23621
- }
23622
- items.forEach(function(item) {
23623
- if (item.type === ItemType.text) {
23624
- var textVariable = variables[item.name];
23625
- if (textVariable) {
23626
- item.content.options.text = textVariable;
23627
- }
23628
- }
23629
- });
23630
- };
23631
- /**
23632
23649
  * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
23633
23650
  * @param url - json 的 URL 链接或者 json 对象
23634
23651
  * @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
@@ -23755,7 +23772,6 @@ var seed = 1;
23755
23772
  for(i1 = 0; i1 < scene.images.length; i1++){
23756
23773
  scene.textureOptions[i1].image = scene.images[i1];
23757
23774
  }
23758
- _this.updateSceneData(scene.jsonScene.items);
23759
23775
  _state.label = 5;
23760
23776
  case 5:
23761
23777
  return [
@@ -23812,7 +23828,6 @@ var seed = 1;
23812
23828
  ];
23813
23829
  case 10:
23814
23830
  loadedTextures = _state.sent();
23815
- _this.updateSceneData(jsonScene.items);
23816
23831
  scene = {
23817
23832
  timeInfos: timeInfos,
23818
23833
  url: url,
@@ -24104,7 +24119,7 @@ var seed = 1;
24104
24119
  ];
24105
24120
  case 6:
24106
24121
  e = _state.sent();
24107
- throw new Error("Failed to load. Check the template or if the URL is " + (isVideo ? "video" : "image") + " type, URL: " + url + ", Error: " + e.message + ".");
24122
+ throw new Error("Failed to load. Check the template or if the URL is " + (isVideo ? "video" : "image") + " type, URL: " + url + ", Error: " + (e.message || e) + ".");
24108
24123
  case 7:
24109
24124
  return [
24110
24125
  3,
@@ -25030,6 +25045,7 @@ var listOrder = 0;
25030
25045
  * 跳到指定时间点(不做任何播放行为)
25031
25046
  * @param time - 相对 startTime 的时间
25032
25047
  */ _proto.setTime = function setTime(time) {
25048
+ var speed = this.speed;
25033
25049
  var pause = this.paused;
25034
25050
  if (pause) {
25035
25051
  this.resume();
@@ -25038,7 +25054,9 @@ var listOrder = 0;
25038
25054
  this.rootComposition.start();
25039
25055
  this.rootComposition.isStartCalled = true;
25040
25056
  }
25057
+ this.setSpeed(1);
25041
25058
  this.forwardTime(time + this.startTime);
25059
+ this.setSpeed(speed);
25042
25060
  if (pause) {
25043
25061
  this.pause();
25044
25062
  }
@@ -25050,7 +25068,6 @@ var listOrder = 0;
25050
25068
  /**
25051
25069
  * 前进合成到指定时间
25052
25070
  * @param time - 相对0时刻的时间
25053
- * @param skipRender - 是否跳过渲染
25054
25071
  */ _proto.forwardTime = function forwardTime(time) {
25055
25072
  var deltaTime = time * 1000 - this.rootComposition.time * 1000;
25056
25073
  var reverse = deltaTime < 0;
@@ -25100,7 +25117,6 @@ var listOrder = 0;
25100
25117
  /**
25101
25118
  * 合成更新,针对所有 item 的更新
25102
25119
  * @param deltaTime - 更新的时间步长
25103
- * @param skipRender - 是否需要渲染
25104
25120
  */ _proto.update = function update(deltaTime) {
25105
25121
  if (!this.assigned || this.paused) {
25106
25122
  return;
@@ -27526,11 +27542,12 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
27526
27542
  return Engine;
27527
27543
  }();
27528
27544
 
27545
+ var DEFAULT_FPS = 60;
27529
27546
  /**
27530
27547
  * 定时器类
27531
27548
  */ var Ticker = /*#__PURE__*/ function() {
27532
27549
  function Ticker(fps) {
27533
- if (fps === void 0) fps = 60;
27550
+ if (fps === void 0) fps = DEFAULT_FPS;
27534
27551
  this.paused = true;
27535
27552
  this.lastTime = 0;
27536
27553
  // deltaTime
@@ -27665,7 +27682,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27665
27682
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27666
27683
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27667
27684
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27668
- var version = "2.0.3";
27685
+ var version = "2.0.5";
27669
27686
  logger.info("Core version: " + version + ".");
27670
27687
 
27671
27688
  exports.AbstractPlugin = AbstractPlugin;
@@ -27689,6 +27706,7 @@ exports.Composition = Composition;
27689
27706
  exports.CompositionComponent = CompositionComponent;
27690
27707
  exports.CompositionSourceManager = CompositionSourceManager;
27691
27708
  exports.DEFAULT_FONTS = DEFAULT_FONTS;
27709
+ exports.DEFAULT_FPS = DEFAULT_FPS;
27692
27710
  exports.Database = Database;
27693
27711
  exports.Downloader = Downloader;
27694
27712
  exports.EFFECTS_COPY_MESH_NAME = EFFECTS_COPY_MESH_NAME;