@galacean/effects-threejs 2.0.3 → 2.0.4

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.4
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 = [];
@@ -13642,7 +13641,6 @@ function _assert_this_initialized(self) {
13642
13641
  /**
13643
13642
  * 动画图可播放节点对象
13644
13643
  * @since 2.0.0
13645
- * @internal
13646
13644
  */ var Playable = /*#__PURE__*/ function() {
13647
13645
  function Playable(graph, inputCount) {
13648
13646
  if (inputCount === void 0) inputCount = 0;
@@ -13840,7 +13838,6 @@ function _assert_this_initialized(self) {
13840
13838
  /**
13841
13839
  * 动画图输出节点对象,将动画数据采样到绑定的元素属性上
13842
13840
  * @since 2.0.0
13843
- * @internal
13844
13841
  */ var PlayableOutput = /*#__PURE__*/ function() {
13845
13842
  function PlayableOutput() {
13846
13843
  this.sourceOutputPort = 0;
@@ -16651,6 +16648,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16651
16648
  _proto.isFrozen = function isFrozen() {
16652
16649
  return this.frozen;
16653
16650
  };
16651
+ _proto.isEnded = function isEnded() {
16652
+ return this.ended;
16653
+ };
16654
16654
  _proto.initEmitterTransform = function initEmitterTransform() {
16655
16655
  var position = this.item.transform.position.clone();
16656
16656
  var rotation = this.item.transform.rotation.clone();
@@ -17569,7 +17569,6 @@ function randomArrItem(arr, keepArr) {
17569
17569
 
17570
17570
  /**
17571
17571
  * @since 2.0.0
17572
- * @internal
17573
17572
  */ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
17574
17573
  _inherits(ParticleBehaviourPlayable, Playable);
17575
17574
  function ParticleBehaviourPlayable() {
@@ -17597,11 +17596,8 @@ function randomArrItem(arr, keepArr) {
17597
17596
  }
17598
17597
  var particleSystem = this.particleSystem;
17599
17598
  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
17599
  var deltaTime = context.deltaTime;
17604
- if (this.time < particleSystem.item.duration && particleSystem.isFrozen()) {
17600
+ if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
17605
17601
  particleSystem.reset();
17606
17602
  }
17607
17603
  if (Math.abs(this.time - this.lastTime) < 0.001) {
@@ -18629,7 +18625,6 @@ var tempSize = new Vector3(1, 1, 1);
18629
18625
  var tempPos = new Vector3();
18630
18626
  /**
18631
18627
  * @since 2.0.0
18632
- * @internal
18633
18628
  */ var TransformAnimationPlayable = /*#__PURE__*/ function(AnimationPlayable) {
18634
18629
  _inherits(TransformAnimationPlayable, AnimationPlayable);
18635
18630
  function TransformAnimationPlayable() {
@@ -18791,7 +18786,6 @@ exports.TransformPlayableAsset = __decorate([
18791
18786
  ], exports.TransformPlayableAsset);
18792
18787
  /**
18793
18788
  * @since 2.0.0
18794
- * @internal
18795
18789
  */ var ActivationPlayable = /*#__PURE__*/ function(Playable) {
18796
18790
  _inherits(ActivationPlayable, Playable);
18797
18791
  function ActivationPlayable() {
@@ -18942,7 +18936,6 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18942
18936
 
18943
18937
  /**
18944
18938
  * @since 2.0.0
18945
- * @internal
18946
18939
  */ var TimelineClip = /*#__PURE__*/ function() {
18947
18940
  function TimelineClip() {
18948
18941
  this.start = 0;
@@ -19477,6 +19470,18 @@ function compareTracks(a, b) {
19477
19470
  }
19478
19471
  }
19479
19472
  };
19473
+ _proto.showItems = function showItems() {
19474
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
19475
+ var item = _step.value;
19476
+ item.setVisible(true);
19477
+ }
19478
+ };
19479
+ _proto.hideItems = function hideItems() {
19480
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
19481
+ var item = _step.value;
19482
+ item.setVisible(false);
19483
+ }
19484
+ };
19480
19485
  _proto.onDestroy = function onDestroy() {
19481
19486
  if (this.item.composition) {
19482
19487
  if (this.items) {
@@ -19587,6 +19592,34 @@ function compareTracks(a, b) {
19587
19592
  return CompositionComponent;
19588
19593
  }(Behaviour);
19589
19594
 
19595
+ var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
19596
+ _inherits(SubCompositionMixerPlayable, Playable);
19597
+ function SubCompositionMixerPlayable() {
19598
+ return Playable.apply(this, arguments);
19599
+ }
19600
+ var _proto = SubCompositionMixerPlayable.prototype;
19601
+ _proto.processFrame = function processFrame(context) {
19602
+ var boundObject = context.output.getUserData();
19603
+ if (!_instanceof1(boundObject, CompositionComponent)) {
19604
+ return;
19605
+ }
19606
+ var compositionComponent = boundObject;
19607
+ var hasInput = false;
19608
+ for(var i = 0; i < this.getInputCount(); i++){
19609
+ if (this.getInputWeight(i) > 0) {
19610
+ hasInput = true;
19611
+ break;
19612
+ }
19613
+ }
19614
+ if (hasInput) {
19615
+ compositionComponent.showItems();
19616
+ } else {
19617
+ compositionComponent.hideItems();
19618
+ }
19619
+ };
19620
+ return SubCompositionMixerPlayable;
19621
+ }(Playable);
19622
+
19590
19623
  exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
19591
19624
  _inherits(SubCompositionTrack, TrackAsset);
19592
19625
  function SubCompositionTrack() {
@@ -19599,6 +19632,9 @@ exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
19599
19632
  }
19600
19633
  return parentBinding.getComponent(CompositionComponent);
19601
19634
  };
19635
+ _proto.createTrackMixer = function createTrackMixer(graph) {
19636
+ return new SubCompositionMixerPlayable(graph);
19637
+ };
19602
19638
  return SubCompositionTrack;
19603
19639
  }(exports.TrackAsset);
19604
19640
  exports.SubCompositionTrack = __decorate([
@@ -23635,22 +23671,6 @@ var seed$1 = 1;
23635
23671
  this.timeout = timeout;
23636
23672
  };
23637
23673
  /**
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
23674
  * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
23655
23675
  * @param url - json 的 URL 链接或者 json 对象
23656
23676
  * @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
@@ -23777,7 +23797,6 @@ var seed$1 = 1;
23777
23797
  for(i1 = 0; i1 < scene.images.length; i1++){
23778
23798
  scene.textureOptions[i1].image = scene.images[i1];
23779
23799
  }
23780
- _this.updateSceneData(scene.jsonScene.items);
23781
23800
  _state.label = 5;
23782
23801
  case 5:
23783
23802
  return [
@@ -23834,7 +23853,6 @@ var seed$1 = 1;
23834
23853
  ];
23835
23854
  case 10:
23836
23855
  loadedTextures = _state.sent();
23837
- _this.updateSceneData(jsonScene.items);
23838
23856
  scene = {
23839
23857
  timeInfos: timeInfos,
23840
23858
  url: url,
@@ -24126,7 +24144,7 @@ var seed$1 = 1;
24126
24144
  ];
24127
24145
  case 6:
24128
24146
  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 + ".");
24147
+ 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
24148
  case 7:
24131
24149
  return [
24132
24150
  3,
@@ -25052,6 +25070,7 @@ var listOrder = 0;
25052
25070
  * 跳到指定时间点(不做任何播放行为)
25053
25071
  * @param time - 相对 startTime 的时间
25054
25072
  */ _proto.setTime = function setTime(time) {
25073
+ var speed = this.speed;
25055
25074
  var pause = this.paused;
25056
25075
  if (pause) {
25057
25076
  this.resume();
@@ -25060,7 +25079,9 @@ var listOrder = 0;
25060
25079
  this.rootComposition.start();
25061
25080
  this.rootComposition.isStartCalled = true;
25062
25081
  }
25082
+ this.setSpeed(1);
25063
25083
  this.forwardTime(time + this.startTime);
25084
+ this.setSpeed(speed);
25064
25085
  if (pause) {
25065
25086
  this.pause();
25066
25087
  }
@@ -25072,7 +25093,6 @@ var listOrder = 0;
25072
25093
  /**
25073
25094
  * 前进合成到指定时间
25074
25095
  * @param time - 相对0时刻的时间
25075
- * @param skipRender - 是否跳过渲染
25076
25096
  */ _proto.forwardTime = function forwardTime(time) {
25077
25097
  var deltaTime = time * 1000 - this.rootComposition.time * 1000;
25078
25098
  var reverse = deltaTime < 0;
@@ -25122,7 +25142,6 @@ var listOrder = 0;
25122
25142
  /**
25123
25143
  * 合成更新,针对所有 item 的更新
25124
25144
  * @param deltaTime - 更新的时间步长
25125
- * @param skipRender - 是否需要渲染
25126
25145
  */ _proto.update = function update(deltaTime) {
25127
25146
  if (!this.assigned || this.paused) {
25128
25147
  return;
@@ -27548,11 +27567,12 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
27548
27567
  return Engine;
27549
27568
  }();
27550
27569
 
27570
+ var DEFAULT_FPS = 60;
27551
27571
  /**
27552
27572
  * 定时器类
27553
27573
  */ var Ticker = /*#__PURE__*/ function() {
27554
27574
  function Ticker(fps) {
27555
- if (fps === void 0) fps = 60;
27575
+ if (fps === void 0) fps = DEFAULT_FPS;
27556
27576
  this.paused = true;
27557
27577
  this.lastTime = 0;
27558
27578
  // deltaTime
@@ -27687,7 +27707,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27687
27707
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27688
27708
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27689
27709
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27690
- var version$1 = "2.0.3";
27710
+ var version$1 = "2.0.4";
27691
27711
  logger.info("Core version: " + version$1 + ".");
27692
27712
 
27693
27713
  var _obj;
@@ -29368,7 +29388,7 @@ setMaxSpriteMeshItemCount(8);
29368
29388
  */ Mesh.create = function(engine, props) {
29369
29389
  return new ThreeMesh(engine, props);
29370
29390
  };
29371
- var version = "2.0.3";
29391
+ var version = "2.0.4";
29372
29392
  logger.info("THREEJS plugin version: " + version + ".");
29373
29393
 
29374
29394
  exports.AbstractPlugin = AbstractPlugin;
@@ -29396,6 +29416,7 @@ exports.Composition = Composition;
29396
29416
  exports.CompositionComponent = CompositionComponent;
29397
29417
  exports.CompositionSourceManager = CompositionSourceManager;
29398
29418
  exports.DEFAULT_FONTS = DEFAULT_FONTS;
29419
+ exports.DEFAULT_FPS = DEFAULT_FPS;
29399
29420
  exports.Database = Database;
29400
29421
  exports.Downloader = Downloader;
29401
29422
  exports.EFFECTS_COPY_MESH_NAME = EFFECTS_COPY_MESH_NAME;