@galacean/effects-core 2.0.0-alpha.32 → 2.0.0-alpha.33

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.
@@ -23,10 +23,6 @@ export declare class CompositionComponent extends ItemBehaviour {
23
23
  refId: string;
24
24
  items: VFXItem[];
25
25
  data: ContentOptions;
26
- /**
27
- * 合成是否冻结标志位
28
- */
29
- fezzed: boolean;
30
26
  private reusable;
31
27
  private sceneBindings;
32
28
  private timelineAsset;
@@ -287,16 +287,6 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
287
287
  protected reset(): void;
288
288
  prepareRender(): void;
289
289
  protected gatherRendererComponent(vfxItem: VFXItem, renderFrame: RenderFrame): void;
290
- /**
291
- * 是否合成需要重新播放
292
- * @returns 重新播放合成标志位
293
- */
294
- private shouldRestart;
295
- /**
296
- * 是否合成需要销毁
297
- * @returns 销毁合成标志位
298
- */
299
- private shouldDispose;
300
290
  /**
301
291
  * 合成更新,针对所有 item 的更新
302
292
  * @param deltaTime - 更新的时间步长
@@ -304,6 +294,7 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
304
294
  */
305
295
  update(deltaTime: number): void;
306
296
  private toLocalTime;
297
+ private shouldDispose;
307
298
  private getUpdateTime;
308
299
  private callStart;
309
300
  private callUpdate;
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.0-alpha.32
6
+ * Version: v2.0.0-alpha.33
7
7
  */
8
8
 
9
9
  'use strict';
@@ -16007,6 +16007,17 @@ var Link = /*#__PURE__*/ function() {
16007
16007
  }while (node = node.pre);
16008
16008
  }
16009
16009
  };
16010
+ _proto.getNodeByIndex = function getNodeByIndex(index) {
16011
+ var i = 0, res = this.first;
16012
+ if (!res || index >= this.length || index < 0) {
16013
+ return null;
16014
+ }
16015
+ while(i < index){
16016
+ res = res.next;
16017
+ i++;
16018
+ }
16019
+ return res;
16020
+ };
16010
16021
  return Link;
16011
16022
  }();
16012
16023
 
@@ -16843,10 +16854,8 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16843
16854
  content[3].delay -= duration;
16844
16855
  });
16845
16856
  this.renderer.minusTimeForLoop(duration);
16846
- this.onIterate(this);
16847
16857
  } else {
16848
16858
  this.ended = true;
16849
- this.onEnd(this);
16850
16859
  var endBehavior = this.item.endBehavior;
16851
16860
  if (endBehavior === EndBehavior.freeze) {
16852
16861
  this.frozen = true;
@@ -16994,7 +17003,21 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16994
17003
  time: startTime
16995
17004
  });
16996
17005
  };
16997
- _proto.getPointPosition = function getPointPosition(point) {
17006
+ /**
17007
+ * 通过索引获取指定index粒子当前时刻的位置
17008
+ * @params index - 粒子索引
17009
+ */ _proto.getPointPositionByIndex = function getPointPositionByIndex(index) {
17010
+ var point = this.particleLink.getNodeByIndex(index);
17011
+ if (!point) {
17012
+ console.error("Get point error.");
17013
+ return null;
17014
+ } else {
17015
+ return this.getPointPosition(point.content[3]);
17016
+ }
17017
+ };
17018
+ /**
17019
+ * 通过粒子参数获取当前时刻粒子的位置
17020
+ */ _proto.getPointPosition = function getPointPosition(point) {
16998
17021
  var transform = point.transform, vel = point.vel, lifetime = point.lifetime, delay = point.delay, _point_gravity = point.gravity, gravity = _point_gravity === void 0 ? [] : _point_gravity;
16999
17022
  var forceTarget = this.options.forceTarget;
17000
17023
  var time = this.lastUpdate - delay;
@@ -17016,8 +17039,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
17016
17039
  }
17017
17040
  return ret;
17018
17041
  };
17019
- _proto.onEnd = function onEnd(particle) {};
17020
- _proto.onIterate = function onIterate(particle) {};
17021
17042
  _proto.initPoint = function initPoint(data) {
17022
17043
  var options = this.options;
17023
17044
  var lifetime = this.lifetime;
@@ -17976,31 +17997,6 @@ var ParticleMesh = /*#__PURE__*/ function() {
17976
17997
  data[i + 3]
17977
17998
  ];
17978
17999
  };
17979
- /**
17980
- * 待废弃
17981
- * @deprecated - 使用 `particle-system.getPointPosition` 替代
17982
- */ _proto.getPointPosition = function getPointPosition(index) {
17983
- var geo = this.geometry;
17984
- var posIndex = index * 48;
17985
- var posData = geo.getAttributeData("aPos");
17986
- var offsetData = geo.getAttributeData("aOffset");
17987
- var time = this.time - offsetData[index * 16 + 2];
17988
- var pointDur = offsetData[index * 16 + 3];
17989
- var mtl = this.mesh.material;
17990
- var acc = mtl.getVector4("uAcceleration").toVector3();
17991
- var pos = Vector3.fromArray(posData, posIndex);
17992
- var vel = Vector3.fromArray(posData, posIndex + 3);
17993
- var ret = calculateTranslation(new Vector3(), this, acc, time, pointDur, pos, vel);
17994
- if (this.forceTarget) {
17995
- var target = mtl.getVector3("uFinalTarget");
17996
- var life = this.forceTarget.curve.getValue(time / pointDur);
17997
- var dl = 1 - life;
17998
- ret.x = ret.x * dl + target.x * life;
17999
- ret.y = ret.y * dl + target.y * life;
18000
- ret.z = ret.z * dl + target.z * life;
18001
- }
18002
- return ret;
18003
- };
18004
18000
  _proto.clearPoints = function clearPoints() {
18005
18001
  this.resetGeometryData(this.geometry);
18006
18002
  this.particleCount = 0;
@@ -19355,9 +19351,6 @@ function compareTracks(a, b) {
19355
19351
  _this.startTime = 0;
19356
19352
  _this.items = [] // 场景的所有元素
19357
19353
  ;
19358
- /**
19359
- * 合成是否冻结标志位
19360
- */ _this.fezzed = false;
19361
19354
  _this.reusable = false;
19362
19355
  _this.sceneBindings = [];
19363
19356
  _this.graph = new PlayableGraph();
@@ -25025,28 +25018,6 @@ var listOrder = 0;
25025
25018
  }
25026
25019
  };
25027
25020
  /**
25028
- * 是否合成需要重新播放
25029
- * @returns 重新播放合成标志位
25030
- */ _proto.shouldRestart = function shouldRestart() {
25031
- var _this_rootItem = this.rootItem, duration = _this_rootItem.duration, endBehavior = _this_rootItem.endBehavior;
25032
- var time = this.rootComposition.time;
25033
- return endBehavior === EndBehavior.restart && duration - time < 0.02;
25034
- };
25035
- /**
25036
- * 是否合成需要销毁
25037
- * @returns 销毁合成标志位
25038
- */ _proto.shouldDispose = function shouldDispose() {
25039
- if (this.reusable) {
25040
- return false;
25041
- }
25042
- var endBehavior = this.rootItem.endBehavior;
25043
- if (this.rootItem.isEnded(this.time)) {
25044
- this.rootItem.ended = true;
25045
- }
25046
- // TODO: 合成结束行为
25047
- return this.rootItem.ended && endBehavior === EndBehavior.destroy;
25048
- };
25049
- /**
25050
25021
  * 合成更新,针对所有 item 的更新
25051
25022
  * @param deltaTime - 更新的时间步长
25052
25023
  * @param skipRender - 是否需要渲染
@@ -25057,49 +25028,56 @@ var listOrder = 0;
25057
25028
  var time = this.getUpdateTime(deltaTime * this.speed);
25058
25029
  this.globalTime += time;
25059
25030
  this.updateRootComposition();
25060
- if (this.shouldRestart()) {
25061
- this.emit("end", {
25062
- composition: this
25063
- });
25064
- this.restart();
25065
- // restart then tick to avoid flicker
25066
- }
25067
25031
  this.updateVideo();
25068
25032
  // 更新 model-tree-plugin
25069
25033
  this.updatePluginLoaders(deltaTime);
25034
+ // scene VFXItem components lifetime function.
25070
25035
  this.callStart(this.rootItem);
25071
25036
  this.callUpdate(this.rootItem, time);
25072
25037
  this.callLateUpdate(this.rootItem, time);
25073
25038
  this.updateCamera();
25039
+ this.prepareRender();
25074
25040
  if (this.shouldDispose()) {
25075
- this.emit("end", {
25076
- composition: this
25077
- });
25078
25041
  this.dispose();
25079
- } else {
25080
- this.prepareRender();
25081
25042
  }
25082
25043
  };
25083
25044
  _proto.toLocalTime = function toLocalTime(time) {
25084
25045
  var localTime = time - this.rootItem.start;
25085
25046
  var duration = this.rootItem.duration;
25086
25047
  if (localTime - duration > 0.001) {
25087
- if (this.rootItem.endBehavior === EndBehavior.restart) {
25088
- localTime = localTime % duration;
25089
- } else if (this.rootItem.endBehavior === EndBehavior.freeze) {
25090
- localTime = Math.min(duration, localTime);
25091
- if (localTime === duration) {
25092
- if (!this.rootComposition.fezzed) {
25093
- this.rootComposition.fezzed = true;
25094
- this.emit("end", {
25095
- composition: this
25096
- });
25048
+ if (!this.rootItem.ended) {
25049
+ this.rootItem.ended = true;
25050
+ this.emit("end", {
25051
+ composition: this
25052
+ });
25053
+ }
25054
+ switch(this.rootItem.endBehavior){
25055
+ case EndBehavior.restart:
25056
+ {
25057
+ localTime = localTime % duration;
25058
+ this.restart();
25059
+ break;
25060
+ }
25061
+ case EndBehavior.freeze:
25062
+ {
25063
+ localTime = Math.min(duration, localTime);
25064
+ break;
25065
+ }
25066
+ case EndBehavior.forward:
25067
+ {
25068
+ break;
25069
+ }
25070
+ case EndBehavior.destroy:
25071
+ {
25072
+ break;
25097
25073
  }
25098
- }
25099
25074
  }
25100
25075
  }
25101
25076
  return localTime;
25102
25077
  };
25078
+ _proto.shouldDispose = function shouldDispose() {
25079
+ return this.rootItem.ended && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
25080
+ };
25103
25081
  _proto.getUpdateTime = function getUpdateTime(t) {
25104
25082
  var startTimeInMs = this.startTime * 1000;
25105
25083
  var now = this.rootComposition.time * 1000;
@@ -25430,7 +25408,9 @@ var listOrder = 0;
25430
25408
  (_this_rendererOptions = this.rendererOptions) == null ? void 0 : _this_rendererOptions.emptyTexture.dispose();
25431
25409
  (_this_pluginSystem = this.pluginSystem) == null ? void 0 : _this_pluginSystem.destroyComposition(this);
25432
25410
  this.update = function() {
25433
- logger.error("Update disposed composition: " + _this.name + ".");
25411
+ {
25412
+ logger.error("Update disposed composition: " + _this.name + ".");
25413
+ }
25434
25414
  };
25435
25415
  this.dispose = noop;
25436
25416
  if (textures && this.keepResource) {
@@ -27593,7 +27573,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27593
27573
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27594
27574
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27595
27575
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27596
- var version = "2.0.0-alpha.32";
27576
+ var version = "2.0.0-alpha.33";
27597
27577
  logger.info("Core version: " + version + ".");
27598
27578
 
27599
27579
  exports.AbstractPlugin = AbstractPlugin;