@galacean/effects-threejs 2.0.2 → 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/README.md CHANGED
@@ -92,4 +92,4 @@ displayObject.addEventListener('end', () => {
92
92
  });
93
93
  ```
94
94
 
95
- ## [API Documentation](https://galacean.antgroup.com/effects/#/api/modules_galacean_effects_threejs)
95
+ ## [API Documentation](https://galacean.antgroup.com/effects/api/effects-threejs)
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.2
6
+ * Version: v2.0.4
7
7
  */
8
8
 
9
9
  'use strict';
@@ -4591,7 +4591,6 @@ function getDirectStore(target) {
4591
4591
 
4592
4592
  /**
4593
4593
  * @since 2.0.0
4594
- * @internal
4595
4594
  */ var EffectsObject = /*#__PURE__*/ function() {
4596
4595
  function EffectsObject(engine) {
4597
4596
  this.engine = engine;
@@ -4627,7 +4626,6 @@ function getDirectStore(target) {
4627
4626
 
4628
4627
  /**
4629
4628
  * @since 2.0.0
4630
- * @internal
4631
4629
  */ var Component = /*#__PURE__*/ function(EffectsObject) {
4632
4630
  _inherits(Component, EffectsObject);
4633
4631
  function Component() {
@@ -4662,7 +4660,6 @@ function getDirectStore(target) {
4662
4660
  }(EffectsObject);
4663
4661
  /**
4664
4662
  * @since 2.0.0
4665
- * @internal
4666
4663
  */ var Behaviour = /*#__PURE__*/ function(Component) {
4667
4664
  _inherits(Behaviour, Component);
4668
4665
  function Behaviour() {
@@ -8111,7 +8108,7 @@ function _loadVideo() {
8111
8108
  }, true);
8112
8109
  }
8113
8110
  video.addEventListener("error", function(e) {
8114
- reject(e);
8111
+ reject("Load video fail.");
8115
8112
  });
8116
8113
  })
8117
8114
  ];
@@ -13585,7 +13582,6 @@ function _assert_this_initialized(self) {
13585
13582
  /**
13586
13583
  * 动画图,负责更新所有的动画节点
13587
13584
  * @since 2.0.0
13588
- * @internal
13589
13585
  */ var PlayableGraph = /*#__PURE__*/ function() {
13590
13586
  function PlayableGraph() {
13591
13587
  this.playableOutputs = [];
@@ -13645,7 +13641,6 @@ function _assert_this_initialized(self) {
13645
13641
  /**
13646
13642
  * 动画图可播放节点对象
13647
13643
  * @since 2.0.0
13648
- * @internal
13649
13644
  */ var Playable = /*#__PURE__*/ function() {
13650
13645
  function Playable(graph, inputCount) {
13651
13646
  if (inputCount === void 0) inputCount = 0;
@@ -13843,7 +13838,6 @@ function _assert_this_initialized(self) {
13843
13838
  /**
13844
13839
  * 动画图输出节点对象,将动画数据采样到绑定的元素属性上
13845
13840
  * @since 2.0.0
13846
- * @internal
13847
13841
  */ var PlayableOutput = /*#__PURE__*/ function() {
13848
13842
  function PlayableOutput() {
13849
13843
  this.sourceOutputPort = 0;
@@ -13926,13 +13920,17 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
13926
13920
  if (!_instanceof1(boundObject, exports.VFXItem)) {
13927
13921
  return;
13928
13922
  }
13923
+ if (!this.spriteComponent) {
13924
+ this.spriteComponent = boundObject.getComponent(exports.SpriteComponent);
13925
+ }
13929
13926
  if (!this.spriteMaterial) {
13930
- this.spriteMaterial = boundObject.getComponent(exports.SpriteComponent).material;
13927
+ this.spriteMaterial = this.spriteComponent.material;
13931
13928
  var startColor = this.spriteMaterial.getVector4("_Color");
13932
13929
  if (startColor) {
13933
13930
  this.startColor = startColor.toArray();
13934
13931
  }
13935
13932
  }
13933
+ this.spriteComponent.setAnimationTime(this.time);
13936
13934
  var colorInc = vecFill(tempColor, 1);
13937
13935
  var colorChanged;
13938
13936
  var life = this.time / boundObject.duration;
@@ -13992,7 +13990,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
13992
13990
  _this = RendererComponent.call(this, engine) || this;
13993
13991
  _this.cachePrefix = "-";
13994
13992
  _this.frameAnimationLoop = false;
13995
- _this.frameAnimationTime = 0;
13996
13993
  _this.color = [
13997
13994
  1,
13998
13995
  1,
@@ -14000,6 +13997,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
14000
13997
  1
14001
13998
  ];
14002
13999
  _this.visible = true;
14000
+ _this.isManualTimeSet = false;
14001
+ _this.frameAnimationTime = 0;
14003
14002
  _this.getHitTestParams = function(force) {
14004
14003
  var ui = _this.interaction;
14005
14004
  if (force || ui) {
@@ -14082,6 +14081,12 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
14082
14081
  this.renderer.texture = texture;
14083
14082
  this.material.setTexture("uSampler0", texture);
14084
14083
  };
14084
+ /**
14085
+ * @internal
14086
+ */ _proto.setAnimationTime = function setAnimationTime(time) {
14087
+ this.frameAnimationTime = time;
14088
+ this.isManualTimeSet = true;
14089
+ };
14085
14090
  _proto.render = function render(renderer) {
14086
14091
  if (!this.getVisible()) {
14087
14092
  return;
@@ -14096,12 +14101,12 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
14096
14101
  };
14097
14102
  _proto.start = function start() {
14098
14103
  this.item.getHitTestParams = this.getHitTestParams;
14099
- if (this.item.endBehavior === EndBehavior.restart) {
14100
- this.frameAnimationLoop = true;
14101
- }
14102
14104
  };
14103
14105
  _proto.update = function update(dt) {
14104
- this.frameAnimationTime += dt / 1000;
14106
+ if (!this.isManualTimeSet) {
14107
+ this.frameAnimationTime += dt / 1000;
14108
+ this.isManualTimeSet = false;
14109
+ }
14105
14110
  var time = this.frameAnimationTime;
14106
14111
  var duration = this.item.duration;
14107
14112
  if (time > duration && this.frameAnimationLoop) {
@@ -16496,7 +16501,6 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16496
16501
 
16497
16502
  /**
16498
16503
  * @since 2.0.0
16499
- * @internal
16500
16504
  */ var ParticleSystemRenderer = /*#__PURE__*/ function(RendererComponent) {
16501
16505
  _inherits(ParticleSystemRenderer, RendererComponent);
16502
16506
  function ParticleSystemRenderer(engine, particleMeshProps, trailMeshProps) {
@@ -16644,6 +16648,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16644
16648
  _proto.isFrozen = function isFrozen() {
16645
16649
  return this.frozen;
16646
16650
  };
16651
+ _proto.isEnded = function isEnded() {
16652
+ return this.ended;
16653
+ };
16647
16654
  _proto.initEmitterTransform = function initEmitterTransform() {
16648
16655
  var position = this.item.transform.position.clone();
16649
16656
  var rotation = this.item.transform.rotation.clone();
@@ -17562,7 +17569,6 @@ function randomArrItem(arr, keepArr) {
17562
17569
 
17563
17570
  /**
17564
17571
  * @since 2.0.0
17565
- * @internal
17566
17572
  */ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
17567
17573
  _inherits(ParticleBehaviourPlayable, Playable);
17568
17574
  function ParticleBehaviourPlayable() {
@@ -17590,11 +17596,8 @@ function randomArrItem(arr, keepArr) {
17590
17596
  }
17591
17597
  var particleSystem = this.particleSystem;
17592
17598
  if (particleSystem) {
17593
- // TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
17594
- // particleSystem.setParentTransform(parentItem.transform);
17595
- particleSystem.setVisible(true);
17596
17599
  var deltaTime = context.deltaTime;
17597
- if (this.time < particleSystem.item.duration && particleSystem.isFrozen()) {
17600
+ if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
17598
17601
  particleSystem.reset();
17599
17602
  }
17600
17603
  if (Math.abs(this.time - this.lastTime) < 0.001) {
@@ -18622,7 +18625,6 @@ var tempSize = new Vector3(1, 1, 1);
18622
18625
  var tempPos = new Vector3();
18623
18626
  /**
18624
18627
  * @since 2.0.0
18625
- * @internal
18626
18628
  */ var TransformAnimationPlayable = /*#__PURE__*/ function(AnimationPlayable) {
18627
18629
  _inherits(TransformAnimationPlayable, AnimationPlayable);
18628
18630
  function TransformAnimationPlayable() {
@@ -18784,7 +18786,6 @@ exports.TransformPlayableAsset = __decorate([
18784
18786
  ], exports.TransformPlayableAsset);
18785
18787
  /**
18786
18788
  * @since 2.0.0
18787
- * @internal
18788
18789
  */ var ActivationPlayable = /*#__PURE__*/ function(Playable) {
18789
18790
  _inherits(ActivationPlayable, Playable);
18790
18791
  function ActivationPlayable() {
@@ -18935,7 +18936,6 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18935
18936
 
18936
18937
  /**
18937
18938
  * @since 2.0.0
18938
- * @internal
18939
18939
  */ var TimelineClip = /*#__PURE__*/ function() {
18940
18940
  function TimelineClip() {
18941
18941
  this.start = 0;
@@ -19360,7 +19360,6 @@ function compareTracks(a, b) {
19360
19360
 
19361
19361
  /**
19362
19362
  * @since 2.0.0
19363
- * @internal
19364
19363
  */ var CompositionComponent = /*#__PURE__*/ function(Behaviour) {
19365
19364
  _inherits(CompositionComponent, Behaviour);
19366
19365
  function CompositionComponent() {
@@ -19471,6 +19470,18 @@ function compareTracks(a, b) {
19471
19470
  }
19472
19471
  }
19473
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
+ };
19474
19485
  _proto.onDestroy = function onDestroy() {
19475
19486
  if (this.item.composition) {
19476
19487
  if (this.items) {
@@ -19581,6 +19592,34 @@ function compareTracks(a, b) {
19581
19592
  return CompositionComponent;
19582
19593
  }(Behaviour);
19583
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
+
19584
19623
  exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
19585
19624
  _inherits(SubCompositionTrack, TrackAsset);
19586
19625
  function SubCompositionTrack() {
@@ -19593,6 +19632,9 @@ exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
19593
19632
  }
19594
19633
  return parentBinding.getComponent(CompositionComponent);
19595
19634
  };
19635
+ _proto.createTrackMixer = function createTrackMixer(graph) {
19636
+ return new SubCompositionMixerPlayable(graph);
19637
+ };
19596
19638
  return SubCompositionTrack;
19597
19639
  }(exports.TrackAsset);
19598
19640
  exports.SubCompositionTrack = __decorate([
@@ -21649,7 +21691,6 @@ var SerializationHelper = /*#__PURE__*/ function() {
21649
21691
 
21650
21692
  /**
21651
21693
  * @since 2.0.0
21652
- * @internal
21653
21694
  */ var AssetLoader = /*#__PURE__*/ function() {
21654
21695
  function AssetLoader(engine) {
21655
21696
  this.engine = engine;
@@ -23630,22 +23671,6 @@ var seed$1 = 1;
23630
23671
  this.timeout = timeout;
23631
23672
  };
23632
23673
  /**
23633
- * 根据用户传入的参数修改场景数据
23634
- */ _proto.updateSceneData = function updateSceneData(items) {
23635
- var variables = this.options.variables;
23636
- if (!variables || Object.keys(variables).length === 0) {
23637
- return;
23638
- }
23639
- items.forEach(function(item) {
23640
- if (item.type === ItemType.text) {
23641
- var textVariable = variables[item.name];
23642
- if (textVariable) {
23643
- item.content.options.text = textVariable;
23644
- }
23645
- }
23646
- });
23647
- };
23648
- /**
23649
23674
  * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
23650
23675
  * @param url - json 的 URL 链接或者 json 对象
23651
23676
  * @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
@@ -23772,7 +23797,6 @@ var seed$1 = 1;
23772
23797
  for(i1 = 0; i1 < scene.images.length; i1++){
23773
23798
  scene.textureOptions[i1].image = scene.images[i1];
23774
23799
  }
23775
- _this.updateSceneData(scene.jsonScene.items);
23776
23800
  _state.label = 5;
23777
23801
  case 5:
23778
23802
  return [
@@ -23829,7 +23853,6 @@ var seed$1 = 1;
23829
23853
  ];
23830
23854
  case 10:
23831
23855
  loadedTextures = _state.sent();
23832
- _this.updateSceneData(jsonScene.items);
23833
23856
  scene = {
23834
23857
  timeInfos: timeInfos,
23835
23858
  url: url,
@@ -24121,7 +24144,7 @@ var seed$1 = 1;
24121
24144
  ];
24122
24145
  case 6:
24123
24146
  e = _state.sent();
24124
- 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) + ".");
24125
24148
  case 7:
24126
24149
  return [
24127
24150
  3,
@@ -25047,6 +25070,7 @@ var listOrder = 0;
25047
25070
  * 跳到指定时间点(不做任何播放行为)
25048
25071
  * @param time - 相对 startTime 的时间
25049
25072
  */ _proto.setTime = function setTime(time) {
25073
+ var speed = this.speed;
25050
25074
  var pause = this.paused;
25051
25075
  if (pause) {
25052
25076
  this.resume();
@@ -25055,7 +25079,9 @@ var listOrder = 0;
25055
25079
  this.rootComposition.start();
25056
25080
  this.rootComposition.isStartCalled = true;
25057
25081
  }
25082
+ this.setSpeed(1);
25058
25083
  this.forwardTime(time + this.startTime);
25084
+ this.setSpeed(speed);
25059
25085
  if (pause) {
25060
25086
  this.pause();
25061
25087
  }
@@ -25067,7 +25093,6 @@ var listOrder = 0;
25067
25093
  /**
25068
25094
  * 前进合成到指定时间
25069
25095
  * @param time - 相对0时刻的时间
25070
- * @param skipRender - 是否跳过渲染
25071
25096
  */ _proto.forwardTime = function forwardTime(time) {
25072
25097
  var deltaTime = time * 1000 - this.rootComposition.time * 1000;
25073
25098
  var reverse = deltaTime < 0;
@@ -25117,7 +25142,6 @@ var listOrder = 0;
25117
25142
  /**
25118
25143
  * 合成更新,针对所有 item 的更新
25119
25144
  * @param deltaTime - 更新的时间步长
25120
- * @param skipRender - 是否需要渲染
25121
25145
  */ _proto.update = function update(deltaTime) {
25122
25146
  if (!this.assigned || this.paused) {
25123
25147
  return;
@@ -27135,7 +27159,6 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
27135
27159
 
27136
27160
  /**
27137
27161
  * @since 2.0.0
27138
- * @internal
27139
27162
  */ var EffectsPackage = /*#__PURE__*/ function() {
27140
27163
  function EffectsPackage() {
27141
27164
  this.exportObjectDatas = [];
@@ -27544,11 +27567,12 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
27544
27567
  return Engine;
27545
27568
  }();
27546
27569
 
27570
+ var DEFAULT_FPS = 60;
27547
27571
  /**
27548
27572
  * 定时器类
27549
27573
  */ var Ticker = /*#__PURE__*/ function() {
27550
27574
  function Ticker(fps) {
27551
- if (fps === void 0) fps = 60;
27575
+ if (fps === void 0) fps = DEFAULT_FPS;
27552
27576
  this.paused = true;
27553
27577
  this.lastTime = 0;
27554
27578
  // deltaTime
@@ -27683,7 +27707,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27683
27707
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27684
27708
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27685
27709
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27686
- var version$1 = "2.0.2";
27710
+ var version$1 = "2.0.4";
27687
27711
  logger.info("Core version: " + version$1 + ".");
27688
27712
 
27689
27713
  var _obj;
@@ -29364,7 +29388,7 @@ setMaxSpriteMeshItemCount(8);
29364
29388
  */ Mesh.create = function(engine, props) {
29365
29389
  return new ThreeMesh(engine, props);
29366
29390
  };
29367
- var version = "2.0.2";
29391
+ var version = "2.0.4";
29368
29392
  logger.info("THREEJS plugin version: " + version + ".");
29369
29393
 
29370
29394
  exports.AbstractPlugin = AbstractPlugin;
@@ -29392,6 +29416,7 @@ exports.Composition = Composition;
29392
29416
  exports.CompositionComponent = CompositionComponent;
29393
29417
  exports.CompositionSourceManager = CompositionSourceManager;
29394
29418
  exports.DEFAULT_FONTS = DEFAULT_FONTS;
29419
+ exports.DEFAULT_FPS = DEFAULT_FPS;
29395
29420
  exports.Database = Database;
29396
29421
  exports.Downloader = Downloader;
29397
29422
  exports.EFFECTS_COPY_MESH_NAME = EFFECTS_COPY_MESH_NAME;