@galacean/effects-threejs 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.
package/dist/index.js 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.3
6
+ * Version: v2.0.5
7
7
  */
8
8
 
9
9
  'use strict';
@@ -8108,7 +8108,7 @@ function _loadVideo() {
8108
8108
  }, true);
8109
8109
  }
8110
8110
  video.addEventListener("error", function(e) {
8111
- reject(e);
8111
+ reject("Load video fail.");
8112
8112
  });
8113
8113
  })
8114
8114
  ];
@@ -13582,7 +13582,6 @@ function _assert_this_initialized(self) {
13582
13582
  /**
13583
13583
  * 动画图,负责更新所有的动画节点
13584
13584
  * @since 2.0.0
13585
- * @internal
13586
13585
  */ var PlayableGraph = /*#__PURE__*/ function() {
13587
13586
  function PlayableGraph() {
13588
13587
  this.playableOutputs = [];
@@ -13590,25 +13589,25 @@ function _assert_this_initialized(self) {
13590
13589
  }
13591
13590
  var _proto = PlayableGraph.prototype;
13592
13591
  _proto.evaluate = function evaluate(dt) {
13593
- // 初始化节点状态
13594
- for(var _iterator = _create_for_of_iterator_helper_loose(this.playables), _step; !(_step = _iterator()).done;){
13595
- var playable = _step.value;
13596
- this.updatePlayableTime(playable, dt);
13597
- }
13598
13592
  // 初始化输出节点状态
13599
- for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13600
- var playableOutput = _step1.value;
13593
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.playableOutputs), _step; !(_step = _iterator()).done;){
13594
+ var playableOutput = _step.value;
13601
13595
  playableOutput.context.deltaTime = dt;
13602
13596
  }
13603
13597
  // 执行生命周期函数
13604
- for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13605
- var playableOutput1 = _step2.value;
13598
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13599
+ var playableOutput1 = _step1.value;
13606
13600
  this.prepareFrameWithRoot(playableOutput1);
13607
13601
  }
13608
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step3; !(_step3 = _iterator3()).done;){
13609
- var playableOutput2 = _step3.value;
13602
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13603
+ var playableOutput2 = _step2.value;
13610
13604
  this.processFrameWithRoot(playableOutput2);
13611
13605
  }
13606
+ // 更新节点时间
13607
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
13608
+ var playable = _step3.value;
13609
+ this.updatePlayableTime(playable, dt);
13610
+ }
13612
13611
  };
13613
13612
  _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
13614
13613
  destination.connectInput(destinationInputPort, source, sourceOutputPort);
@@ -13631,24 +13630,18 @@ function _assert_this_initialized(self) {
13631
13630
  if (playable.getPlayState() !== 0) {
13632
13631
  return;
13633
13632
  }
13634
- if (playable.overrideTimeNextEvaluation) {
13635
- playable.overrideTimeNextEvaluation = false;
13636
- } else {
13637
- playable.setTime(playable.getTime() + deltaTime);
13638
- }
13633
+ playable.setTime(playable.getTime() + deltaTime);
13639
13634
  };
13640
13635
  return PlayableGraph;
13641
13636
  }();
13642
13637
  /**
13643
13638
  * 动画图可播放节点对象
13644
13639
  * @since 2.0.0
13645
- * @internal
13646
13640
  */ var Playable = /*#__PURE__*/ function() {
13647
13641
  function Playable(graph, inputCount) {
13648
13642
  if (inputCount === void 0) inputCount = 0;
13649
13643
  this.onPlayablePlayFlag = true;
13650
13644
  this.onPlayablePauseFlag = false;
13651
- this.overrideTimeNextEvaluation = false;
13652
13645
  this.destroyed = false;
13653
13646
  this.inputs = [];
13654
13647
  this.inputOuputPorts = [];
@@ -13734,7 +13727,6 @@ function _assert_this_initialized(self) {
13734
13727
  };
13735
13728
  _proto.setTime = function setTime(time) {
13736
13729
  this.time = time;
13737
- this.overrideTimeNextEvaluation = true;
13738
13730
  };
13739
13731
  _proto.getTime = function getTime() {
13740
13732
  return this.time;
@@ -13840,7 +13832,6 @@ function _assert_this_initialized(self) {
13840
13832
  /**
13841
13833
  * 动画图输出节点对象,将动画数据采样到绑定的元素属性上
13842
13834
  * @since 2.0.0
13843
- * @internal
13844
13835
  */ var PlayableOutput = /*#__PURE__*/ function() {
13845
13836
  function PlayableOutput() {
13846
13837
  this.sourceOutputPort = 0;
@@ -16651,6 +16642,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16651
16642
  _proto.isFrozen = function isFrozen() {
16652
16643
  return this.frozen;
16653
16644
  };
16645
+ _proto.isEnded = function isEnded() {
16646
+ return this.ended;
16647
+ };
16654
16648
  _proto.initEmitterTransform = function initEmitterTransform() {
16655
16649
  var position = this.item.transform.position.clone();
16656
16650
  var rotation = this.item.transform.rotation.clone();
@@ -16843,7 +16837,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16843
16837
  break;
16844
16838
  }
16845
16839
  var burst = bursts[j];
16846
- var opts = burst.getGeneratorOptions(timePassed, lifetime);
16840
+ var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
16847
16841
  if (opts) {
16848
16842
  var originVec = [
16849
16843
  0,
@@ -16852,6 +16846,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16852
16846
  ];
16853
16847
  var offsets = emission.burstOffsets[j];
16854
16848
  var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
16849
+ if (burst.once) {
16850
+ this.removeBurst(j);
16851
+ }
16855
16852
  for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
16856
16853
  var _p_transform;
16857
16854
  if (shouldSkipGenerate()) {
@@ -17569,7 +17566,6 @@ function randomArrItem(arr, keepArr) {
17569
17566
 
17570
17567
  /**
17571
17568
  * @since 2.0.0
17572
- * @internal
17573
17569
  */ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
17574
17570
  _inherits(ParticleBehaviourPlayable, Playable);
17575
17571
  function ParticleBehaviourPlayable() {
@@ -17597,11 +17593,8 @@ function randomArrItem(arr, keepArr) {
17597
17593
  }
17598
17594
  var particleSystem = this.particleSystem;
17599
17595
  if (particleSystem) {
17600
- // TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
17601
- // particleSystem.setParentTransform(parentItem.transform);
17602
- particleSystem.setVisible(true);
17603
17596
  var deltaTime = context.deltaTime;
17604
- if (this.time < particleSystem.item.duration && particleSystem.isFrozen()) {
17597
+ if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
17605
17598
  particleSystem.reset();
17606
17599
  }
17607
17600
  if (Math.abs(this.time - this.lastTime) < 0.001) {
@@ -18629,7 +18622,6 @@ var tempSize = new Vector3(1, 1, 1);
18629
18622
  var tempPos = new Vector3();
18630
18623
  /**
18631
18624
  * @since 2.0.0
18632
- * @internal
18633
18625
  */ var TransformAnimationPlayable = /*#__PURE__*/ function(AnimationPlayable) {
18634
18626
  _inherits(TransformAnimationPlayable, AnimationPlayable);
18635
18627
  function TransformAnimationPlayable() {
@@ -18791,7 +18783,6 @@ exports.TransformPlayableAsset = __decorate([
18791
18783
  ], exports.TransformPlayableAsset);
18792
18784
  /**
18793
18785
  * @since 2.0.0
18794
- * @internal
18795
18786
  */ var ActivationPlayable = /*#__PURE__*/ function(Playable) {
18796
18787
  _inherits(ActivationPlayable, Playable);
18797
18788
  function ActivationPlayable() {
@@ -18942,7 +18933,6 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18942
18933
 
18943
18934
  /**
18944
18935
  * @since 2.0.0
18945
- * @internal
18946
18936
  */ var TimelineClip = /*#__PURE__*/ function() {
18947
18937
  function TimelineClip() {
18948
18938
  this.start = 0;
@@ -18952,7 +18942,7 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18952
18942
  _proto.toLocalTime = function toLocalTime(time) {
18953
18943
  var localTime = time - this.start;
18954
18944
  var duration = this.duration;
18955
- if (localTime - duration > 0.001) {
18945
+ if (localTime - duration > 0) {
18956
18946
  if (this.endBehavior === EndBehavior.restart) {
18957
18947
  localTime = localTime % duration;
18958
18948
  } else if (this.endBehavior === EndBehavior.freeze) {
@@ -19081,7 +19071,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
19081
19071
  var ended = false;
19082
19072
  var started = false;
19083
19073
  var boundObject = this.track.binding;
19084
- if (localTime > clip.start + clip.duration + 0.001 && clip.endBehavior === EndBehavior.destroy) {
19074
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
19085
19075
  if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
19086
19076
  weight = 1.0;
19087
19077
  } else {
@@ -19477,6 +19467,18 @@ function compareTracks(a, b) {
19477
19467
  }
19478
19468
  }
19479
19469
  };
19470
+ _proto.showItems = function showItems() {
19471
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
19472
+ var item = _step.value;
19473
+ item.setVisible(true);
19474
+ }
19475
+ };
19476
+ _proto.hideItems = function hideItems() {
19477
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
19478
+ var item = _step.value;
19479
+ item.setVisible(false);
19480
+ }
19481
+ };
19480
19482
  _proto.onDestroy = function onDestroy() {
19481
19483
  if (this.item.composition) {
19482
19484
  if (this.items) {
@@ -19587,6 +19589,34 @@ function compareTracks(a, b) {
19587
19589
  return CompositionComponent;
19588
19590
  }(Behaviour);
19589
19591
 
19592
+ var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
19593
+ _inherits(SubCompositionMixerPlayable, Playable);
19594
+ function SubCompositionMixerPlayable() {
19595
+ return Playable.apply(this, arguments);
19596
+ }
19597
+ var _proto = SubCompositionMixerPlayable.prototype;
19598
+ _proto.processFrame = function processFrame(context) {
19599
+ var boundObject = context.output.getUserData();
19600
+ if (!_instanceof1(boundObject, CompositionComponent)) {
19601
+ return;
19602
+ }
19603
+ var compositionComponent = boundObject;
19604
+ var hasInput = false;
19605
+ for(var i = 0; i < this.getInputCount(); i++){
19606
+ if (this.getInputWeight(i) > 0) {
19607
+ hasInput = true;
19608
+ break;
19609
+ }
19610
+ }
19611
+ if (hasInput) {
19612
+ compositionComponent.showItems();
19613
+ } else {
19614
+ compositionComponent.hideItems();
19615
+ }
19616
+ };
19617
+ return SubCompositionMixerPlayable;
19618
+ }(Playable);
19619
+
19590
19620
  exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
19591
19621
  _inherits(SubCompositionTrack, TrackAsset);
19592
19622
  function SubCompositionTrack() {
@@ -19599,6 +19629,9 @@ exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
19599
19629
  }
19600
19630
  return parentBinding.getComponent(CompositionComponent);
19601
19631
  };
19632
+ _proto.createTrackMixer = function createTrackMixer(graph) {
19633
+ return new SubCompositionMixerPlayable(graph);
19634
+ };
19602
19635
  return SubCompositionTrack;
19603
19636
  }(exports.TrackAsset);
19604
19637
  exports.SubCompositionTrack = __decorate([
@@ -23635,22 +23668,6 @@ var seed$1 = 1;
23635
23668
  this.timeout = timeout;
23636
23669
  };
23637
23670
  /**
23638
- * 根据用户传入的参数修改场景数据
23639
- */ _proto.updateSceneData = function updateSceneData(items) {
23640
- var variables = this.options.variables;
23641
- if (!variables || Object.keys(variables).length === 0) {
23642
- return;
23643
- }
23644
- items.forEach(function(item) {
23645
- if (item.type === ItemType.text) {
23646
- var textVariable = variables[item.name];
23647
- if (textVariable) {
23648
- item.content.options.text = textVariable;
23649
- }
23650
- }
23651
- });
23652
- };
23653
- /**
23654
23671
  * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
23655
23672
  * @param url - json 的 URL 链接或者 json 对象
23656
23673
  * @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
@@ -23777,7 +23794,6 @@ var seed$1 = 1;
23777
23794
  for(i1 = 0; i1 < scene.images.length; i1++){
23778
23795
  scene.textureOptions[i1].image = scene.images[i1];
23779
23796
  }
23780
- _this.updateSceneData(scene.jsonScene.items);
23781
23797
  _state.label = 5;
23782
23798
  case 5:
23783
23799
  return [
@@ -23834,7 +23850,6 @@ var seed$1 = 1;
23834
23850
  ];
23835
23851
  case 10:
23836
23852
  loadedTextures = _state.sent();
23837
- _this.updateSceneData(jsonScene.items);
23838
23853
  scene = {
23839
23854
  timeInfos: timeInfos,
23840
23855
  url: url,
@@ -24126,7 +24141,7 @@ var seed$1 = 1;
24126
24141
  ];
24127
24142
  case 6:
24128
24143
  e = _state.sent();
24129
- throw new Error("Failed to load. Check the template or if the URL is " + (isVideo ? "video" : "image") + " type, URL: " + url + ", Error: " + e.message + ".");
24144
+ throw new Error("Failed to load. Check the template or if the URL is " + (isVideo ? "video" : "image") + " type, URL: " + url + ", Error: " + (e.message || e) + ".");
24130
24145
  case 7:
24131
24146
  return [
24132
24147
  3,
@@ -25052,6 +25067,7 @@ var listOrder = 0;
25052
25067
  * 跳到指定时间点(不做任何播放行为)
25053
25068
  * @param time - 相对 startTime 的时间
25054
25069
  */ _proto.setTime = function setTime(time) {
25070
+ var speed = this.speed;
25055
25071
  var pause = this.paused;
25056
25072
  if (pause) {
25057
25073
  this.resume();
@@ -25060,7 +25076,9 @@ var listOrder = 0;
25060
25076
  this.rootComposition.start();
25061
25077
  this.rootComposition.isStartCalled = true;
25062
25078
  }
25079
+ this.setSpeed(1);
25063
25080
  this.forwardTime(time + this.startTime);
25081
+ this.setSpeed(speed);
25064
25082
  if (pause) {
25065
25083
  this.pause();
25066
25084
  }
@@ -25072,7 +25090,6 @@ var listOrder = 0;
25072
25090
  /**
25073
25091
  * 前进合成到指定时间
25074
25092
  * @param time - 相对0时刻的时间
25075
- * @param skipRender - 是否跳过渲染
25076
25093
  */ _proto.forwardTime = function forwardTime(time) {
25077
25094
  var deltaTime = time * 1000 - this.rootComposition.time * 1000;
25078
25095
  var reverse = deltaTime < 0;
@@ -25122,7 +25139,6 @@ var listOrder = 0;
25122
25139
  /**
25123
25140
  * 合成更新,针对所有 item 的更新
25124
25141
  * @param deltaTime - 更新的时间步长
25125
- * @param skipRender - 是否需要渲染
25126
25142
  */ _proto.update = function update(deltaTime) {
25127
25143
  if (!this.assigned || this.paused) {
25128
25144
  return;
@@ -27548,11 +27564,12 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
27548
27564
  return Engine;
27549
27565
  }();
27550
27566
 
27567
+ var DEFAULT_FPS = 60;
27551
27568
  /**
27552
27569
  * 定时器类
27553
27570
  */ var Ticker = /*#__PURE__*/ function() {
27554
27571
  function Ticker(fps) {
27555
- if (fps === void 0) fps = 60;
27572
+ if (fps === void 0) fps = DEFAULT_FPS;
27556
27573
  this.paused = true;
27557
27574
  this.lastTime = 0;
27558
27575
  // deltaTime
@@ -27687,7 +27704,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27687
27704
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27688
27705
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27689
27706
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27690
- var version$1 = "2.0.3";
27707
+ var version$1 = "2.0.5";
27691
27708
  logger.info("Core version: " + version$1 + ".");
27692
27709
 
27693
27710
  var _obj;
@@ -29368,7 +29385,7 @@ setMaxSpriteMeshItemCount(8);
29368
29385
  */ Mesh.create = function(engine, props) {
29369
29386
  return new ThreeMesh(engine, props);
29370
29387
  };
29371
- var version = "2.0.3";
29388
+ var version = "2.0.5";
29372
29389
  logger.info("THREEJS plugin version: " + version + ".");
29373
29390
 
29374
29391
  exports.AbstractPlugin = AbstractPlugin;
@@ -29396,6 +29413,7 @@ exports.Composition = Composition;
29396
29413
  exports.CompositionComponent = CompositionComponent;
29397
29414
  exports.CompositionSourceManager = CompositionSourceManager;
29398
29415
  exports.DEFAULT_FONTS = DEFAULT_FONTS;
29416
+ exports.DEFAULT_FPS = DEFAULT_FPS;
29399
29417
  exports.Database = Database;
29400
29418
  exports.Downloader = Downloader;
29401
29419
  exports.EFFECTS_COPY_MESH_NAME = EFFECTS_COPY_MESH_NAME;