@galacean/effects-threejs 2.0.0-alpha.13 → 2.0.0-alpha.14

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.0-alpha.13
6
+ * Version: v2.0.0-alpha.14
7
7
  */
8
8
 
9
9
  'use strict';
@@ -18520,7 +18520,7 @@ exports.TransformPlayableAsset = __decorate([
18520
18520
  _proto.processFrame = function processFrame(context) {};
18521
18521
  return ActivationPlayable;
18522
18522
  }(Playable);
18523
- var ActivationPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
18523
+ exports.ActivationPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
18524
18524
  _inherits(ActivationPlayableAsset, PlayableAsset);
18525
18525
  function ActivationPlayableAsset() {
18526
18526
  return PlayableAsset.apply(this, arguments);
@@ -18531,6 +18531,9 @@ var ActivationPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
18531
18531
  };
18532
18532
  return ActivationPlayableAsset;
18533
18533
  }(PlayableAsset);
18534
+ exports.ActivationPlayableAsset = __decorate([
18535
+ effectsClass("ActivationPlayableAsset")
18536
+ ], exports.ActivationPlayableAsset);
18534
18537
  exports.AnimationClip = /*#__PURE__*/ function(EffectsObject) {
18535
18538
  _inherits(AnimationClip, EffectsObject);
18536
18539
  function AnimationClip() {
@@ -18712,6 +18715,9 @@ exports.TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
18712
18715
  _proto.getChildTracks = function getChildTracks() {
18713
18716
  return this.children;
18714
18717
  };
18718
+ _proto.addChild = function addChild(child) {
18719
+ this.children.push(child);
18720
+ };
18715
18721
  _proto.createClip = function createClip(classConstructor, name) {
18716
18722
  var newClip = new exports.TimelineClip();
18717
18723
  newClip.asset = new classConstructor(this.engine);
@@ -18789,9 +18795,10 @@ var RuntimeClip = /*#__PURE__*/ function() {
18789
18795
  var weight = 1.0;
18790
18796
  var ended = false;
18791
18797
  var started = false;
18798
+ var boundItem = this.track.binding;
18792
18799
  if (localTime > clip.start + clip.duration + 0.001 && clip.endBehaviour === ItemEndBehavior.destroy) {
18793
- var _this_track_binding_getComponent;
18794
- if (exports.VFXItem.isParticle(this.track.binding) && !((_this_track_binding_getComponent = this.track.binding.getComponent(exports.ParticleSystem)) == null ? void 0 : _this_track_binding_getComponent.destroyed)) {
18800
+ var _boundItem_getComponent;
18801
+ if (exports.VFXItem.isParticle(boundItem) && !((_boundItem_getComponent = boundItem.getComponent(exports.ParticleSystem)) == null ? void 0 : _boundItem_getComponent.destroyed)) {
18795
18802
  weight = 1.0;
18796
18803
  } else {
18797
18804
  weight = 0.0;
@@ -18807,7 +18814,6 @@ var RuntimeClip = /*#__PURE__*/ function() {
18807
18814
  this.playable.play();
18808
18815
  }
18809
18816
  this.parentMixer.setInputWeight(this.playable, weight);
18810
- var boundItem = this.track.binding;
18811
18817
  // 判断动画是否结束
18812
18818
  if (ended && !boundItem.ended) {
18813
18819
  boundItem.ended = true;
@@ -18844,6 +18850,64 @@ var RuntimeClip = /*#__PURE__*/ function() {
18844
18850
  return RuntimeClip;
18845
18851
  }();
18846
18852
 
18853
+ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
18854
+ _inherits(ObjectBindingTrack, TrackAsset1);
18855
+ function ObjectBindingTrack() {
18856
+ return TrackAsset1.apply(this, arguments);
18857
+ }
18858
+ var _proto = ObjectBindingTrack.prototype;
18859
+ _proto.create = function create(timelineAsset) {
18860
+ var boundItem = this.binding;
18861
+ this.options = {
18862
+ start: boundItem.start,
18863
+ duration: boundItem.duration,
18864
+ looping: boundItem.endBehavior === ItemEndBehavior.loop,
18865
+ endBehavior: boundItem.endBehavior || ItemEndBehavior.destroy
18866
+ };
18867
+ this.name = boundItem.name;
18868
+ // 添加粒子动画 clip
18869
+ if (boundItem.getComponent(exports.ParticleSystem)) {
18870
+ var particleTrack = timelineAsset.createTrack(exports.TrackAsset, this, "ParticleTrack");
18871
+ particleTrack.binding = this.binding;
18872
+ var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
18873
+ particleClip.start = boundItem.start;
18874
+ particleClip.duration = boundItem.duration;
18875
+ particleClip.endBehaviour = boundItem.endBehavior;
18876
+ }
18877
+ };
18878
+ _proto.toLocalTime = function toLocalTime(time) {
18879
+ var localTime = time - this.options.start;
18880
+ var duration = this.options.duration;
18881
+ if (localTime - duration > 0.001) {
18882
+ if (this.options.endBehavior === END_BEHAVIOR_RESTART) {
18883
+ localTime = localTime % duration;
18884
+ } else if (this.options.endBehavior === END_BEHAVIOR_FREEZE) {
18885
+ localTime = Math.min(duration, localTime);
18886
+ }
18887
+ }
18888
+ return localTime;
18889
+ };
18890
+ _proto.fromData = function fromData(data) {
18891
+ TrackAsset1.prototype.fromData.call(this, data);
18892
+ this.data = data;
18893
+ };
18894
+ return ObjectBindingTrack;
18895
+ }(exports.TrackAsset);
18896
+ exports.ObjectBindingTrack = __decorate([
18897
+ effectsClass("ObjectBindingTrack")
18898
+ ], exports.ObjectBindingTrack);
18899
+
18900
+ exports.TransformTrack = /*#__PURE__*/ function(TrackAsset) {
18901
+ _inherits(TransformTrack, TrackAsset);
18902
+ function TransformTrack() {
18903
+ return TrackAsset.apply(this, arguments);
18904
+ }
18905
+ return TransformTrack;
18906
+ }(exports.TrackAsset);
18907
+ exports.TransformTrack = __decorate([
18908
+ effectsClass("TransformTrack")
18909
+ ], exports.TransformTrack);
18910
+
18847
18911
  var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
18848
18912
  _inherits(ActivationMixerPlayable, Playable);
18849
18913
  function ActivationMixerPlayable() {
@@ -18898,6 +18962,9 @@ exports.ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
18898
18962
  return TrackAsset.apply(this, arguments);
18899
18963
  }
18900
18964
  var _proto = ActivationTrack.prototype;
18965
+ _proto.initializeBinding = function initializeBinding(parentBinding) {
18966
+ this.binding = parentBinding;
18967
+ };
18901
18968
  _proto.createTrackMixer = function createTrackMixer(graph) {
18902
18969
  return new ActivationMixerPlayable(graph);
18903
18970
  };
@@ -18907,85 +18974,6 @@ exports.ActivationTrack = __decorate([
18907
18974
  effectsClass("ActivationTrack")
18908
18975
  ], exports.ActivationTrack);
18909
18976
 
18910
- exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
18911
- _inherits(ObjectBindingTrack, TrackAsset1);
18912
- function ObjectBindingTrack() {
18913
- var _this;
18914
- _this = TrackAsset1.apply(this, arguments) || this;
18915
- _this.trackSeed = 0;
18916
- return _this;
18917
- }
18918
- var _proto = ObjectBindingTrack.prototype;
18919
- _proto.create = function create() {
18920
- this.options = {
18921
- start: this.binding.start,
18922
- duration: this.binding.duration,
18923
- looping: this.binding.endBehavior === ItemEndBehavior.loop,
18924
- endBehavior: this.binding.endBehavior || ItemEndBehavior.destroy
18925
- };
18926
- this.id = this.binding.id;
18927
- this.name = this.binding.name;
18928
- var activationTrack = this.createTrack(exports.ActivationTrack, "ActivationTrack");
18929
- activationTrack.binding = this.binding;
18930
- activationTrack.createClip(ActivationPlayableAsset, "ActivationTimelineClip");
18931
- // 添加粒子动画 clip
18932
- if (this.binding.getComponent(exports.ParticleSystem)) {
18933
- var particleTrack = this.createTrack(exports.TrackAsset, "ParticleTrack");
18934
- particleTrack.binding = this.binding;
18935
- particleTrack.createClip(ParticleBehaviourPlayableAsset);
18936
- }
18937
- // TODO TimelineClip 需要传入 start 和 duration 数据
18938
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
18939
- var track = _step.value;
18940
- for(var _iterator1 = _create_for_of_iterator_helper_loose(track.getClips()), _step1; !(_step1 = _iterator1()).done;){
18941
- var clip = _step1.value;
18942
- clip.start = this.binding.start;
18943
- clip.duration = this.binding.duration;
18944
- clip.endBehaviour = this.binding.endBehavior;
18945
- }
18946
- }
18947
- };
18948
- _proto.toLocalTime = function toLocalTime(time) {
18949
- var localTime = time - this.options.start;
18950
- var duration = this.options.duration;
18951
- if (localTime - duration > 0.001) {
18952
- if (this.options.endBehavior === END_BEHAVIOR_RESTART) {
18953
- localTime = localTime % duration;
18954
- } else if (this.options.endBehavior === END_BEHAVIOR_FREEZE) {
18955
- localTime = Math.min(duration, localTime);
18956
- }
18957
- }
18958
- return localTime;
18959
- };
18960
- _proto.createTrack = function createTrack(classConstructor, name) {
18961
- var newTrack = new classConstructor(this.engine);
18962
- newTrack.binding = this.binding;
18963
- newTrack.id = (this.trackSeed++).toString();
18964
- newTrack.name = name ? name : "Track" + newTrack.id;
18965
- this.children.push(newTrack);
18966
- return newTrack;
18967
- };
18968
- _proto.fromData = function fromData(data) {
18969
- TrackAsset1.prototype.fromData.call(this, data);
18970
- this.data = data;
18971
- };
18972
- return ObjectBindingTrack;
18973
- }(exports.TrackAsset);
18974
- exports.ObjectBindingTrack = __decorate([
18975
- effectsClass("ObjectBindingTrack")
18976
- ], exports.ObjectBindingTrack);
18977
-
18978
- exports.TransformTrack = /*#__PURE__*/ function(TrackAsset) {
18979
- _inherits(TransformTrack, TrackAsset);
18980
- function TransformTrack() {
18981
- return TrackAsset.apply(this, arguments);
18982
- }
18983
- return TransformTrack;
18984
- }(exports.TrackAsset);
18985
- exports.TransformTrack = __decorate([
18986
- effectsClass("TransformTrack")
18987
- ], exports.TransformTrack);
18988
-
18989
18977
  exports.SpriteColorTrack = /*#__PURE__*/ function(TrackAsset) {
18990
18978
  _inherits(SpriteColorTrack, TrackAsset);
18991
18979
  function SpriteColorTrack() {
@@ -19010,14 +18998,27 @@ exports.TimelineAsset = /*#__PURE__*/ function(PlayableAsset) {
19010
18998
  this.graph = graph;
19011
18999
  var timelinePlayable = new TimelinePlayable(graph);
19012
19000
  timelinePlayable.setTraversalMode(PlayableTraversalMode.Passthrough);
19001
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.tracks), _step; !(_step = _iterator()).done;){
19002
+ var track = _step.value;
19003
+ if (_instanceof1(track, exports.ObjectBindingTrack)) {
19004
+ track.create(this);
19005
+ }
19006
+ }
19013
19007
  timelinePlayable.compileTracks(graph, this.tracks);
19014
19008
  return timelinePlayable;
19015
19009
  };
19016
- _proto.fromData = function fromData(data) {
19017
- this.tracks = data.tracks;
19010
+ _proto.createTrack = function createTrack(classConstructor, parent, name) {
19011
+ var newTrack = new classConstructor(this.engine);
19012
+ newTrack.name = name ? name : classConstructor.name;
19013
+ parent.addChild(newTrack);
19014
+ return newTrack;
19018
19015
  };
19016
+ _proto.fromData = function fromData(data) {};
19019
19017
  return TimelineAsset;
19020
19018
  }(PlayableAsset);
19019
+ __decorate([
19020
+ serialize()
19021
+ ], exports.TimelineAsset.prototype, "tracks", void 0);
19021
19022
  exports.TimelineAsset = __decorate([
19022
19023
  effectsClass("TimelineAsset")
19023
19024
  ], exports.TimelineAsset);
@@ -19027,7 +19028,6 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
19027
19028
  var _this;
19028
19029
  _this = Playable.apply(this, arguments) || this;
19029
19030
  _this.clips = [];
19030
- _this.masterTracks = [];
19031
19031
  return _this;
19032
19032
  }
19033
19033
  var _proto = TimelinePlayable.prototype;
@@ -19044,25 +19044,18 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
19044
19044
  };
19045
19045
  _proto.compileTracks = function compileTracks(graph, tracks) {
19046
19046
  this.sortTracks(tracks);
19047
- for(var _iterator = _create_for_of_iterator_helper_loose(tracks), _step; !(_step = _iterator()).done;){
19048
- var track = _step.value;
19049
- if (_instanceof1(track, exports.ObjectBindingTrack)) {
19050
- track.create();
19051
- }
19052
- this.masterTracks.push(track);
19053
- }
19054
19047
  var outputTrack = [];
19055
- for(var _iterator1 = _create_for_of_iterator_helper_loose(tracks), _step1; !(_step1 = _iterator1()).done;){
19056
- var masterTrack = _step1.value;
19048
+ for(var _iterator = _create_for_of_iterator_helper_loose(tracks), _step; !(_step = _iterator()).done;){
19049
+ var masterTrack = _step.value;
19057
19050
  outputTrack.push(masterTrack);
19058
19051
  this.addSubTracksRecursive(masterTrack, outputTrack);
19059
19052
  }
19060
- for(var _iterator2 = _create_for_of_iterator_helper_loose(outputTrack), _step2; !(_step2 = _iterator2()).done;){
19061
- var track1 = _step2.value;
19062
- var trackMixPlayable = track1.createPlayableGraph(graph, this.clips);
19053
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(outputTrack), _step1; !(_step1 = _iterator1()).done;){
19054
+ var track = _step1.value;
19055
+ var trackMixPlayable = track.createPlayableGraph(graph, this.clips);
19063
19056
  this.addInput(trackMixPlayable, 0);
19064
- var trackOutput = track1.createOutput();
19065
- trackOutput.setUserData(track1.binding);
19057
+ var trackOutput = track.createOutput();
19058
+ trackOutput.setUserData(track.binding);
19066
19059
  graph.addOutput(trackOutput);
19067
19060
  trackOutput.setSourcePlayeble(this, this.getInputCount() - 1);
19068
19061
  }
@@ -19106,9 +19099,14 @@ function isAncestor(ancestorCandidate, descendantCandidate) {
19106
19099
  return false;
19107
19100
  }
19108
19101
  function compareTracks(a, b) {
19109
- if (isAncestor(a.track.binding, b.track.binding)) {
19102
+ var bindingA = a.track.binding;
19103
+ var bindingB = b.track.binding;
19104
+ if (!_instanceof1(bindingA, exports.VFXItem) || !_instanceof1(bindingB, exports.VFXItem)) {
19105
+ return a.originalIndex - b.originalIndex;
19106
+ }
19107
+ if (isAncestor(bindingA, bindingB)) {
19110
19108
  return -1;
19111
- } else if (isAncestor(b.track.binding, a.track.binding)) {
19109
+ } else if (isAncestor(bindingB, bindingA)) {
19112
19110
  return 1;
19113
19111
  } else {
19114
19112
  return a.originalIndex - b.originalIndex; // 非父子关系的元素保持原始顺序
@@ -22085,7 +22083,7 @@ function getStandardCameraContent(model) {
22085
22083
  content1.renderer.anchor = convertAnchor(renderer1.anchor, renderer1.particleOrigin);
22086
22084
  }
22087
22085
  // 修复相机K帧缺失 asMovement 参数
22088
- if (item.type === ItemType.camera) {
22086
+ if (item.type === ItemType.camera && item.content.positionOverLifetime && Object.keys(item.content.positionOverLifetime).length !== 0) {
22089
22087
  item.content.positionOverLifetime.asMovement = true;
22090
22088
  }
22091
22089
  // 动画数据转化 TODO: 动画数据移到 TimelineComponentData
@@ -22250,8 +22248,32 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22250
22248
  var itemDataPath = _step.value;
22251
22249
  var item = guidToItemMap[itemDataPath.id];
22252
22250
  var subTrackDatas = [];
22251
+ var newActivationPlayableAsset = {
22252
+ id: generateGUID(),
22253
+ dataType: "ActivationPlayableAsset"
22254
+ };
22255
+ playableAssetDatas.push(newActivationPlayableAsset);
22256
+ var newActivationTrackData = {
22257
+ id: generateGUID(),
22258
+ dataType: "ActivationTrack",
22259
+ children: [],
22260
+ clips: [
22261
+ {
22262
+ start: item.delay,
22263
+ duration: item.duration,
22264
+ endBehaviour: item.endBehavior,
22265
+ asset: {
22266
+ id: newActivationPlayableAsset.id
22267
+ }
22268
+ }
22269
+ ]
22270
+ };
22271
+ subTrackDatas.push({
22272
+ id: newActivationTrackData.id
22273
+ });
22274
+ trackDatas.push(newActivationTrackData);
22253
22275
  if (item.type !== ItemType.particle) {
22254
- var newPlayableAssetData = {
22276
+ var newTransformPlayableAssetData = {
22255
22277
  id: generateGUID(),
22256
22278
  dataType: "TransformPlayableAsset",
22257
22279
  //@ts-expect-error
@@ -22261,15 +22283,18 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22261
22283
  //@ts-expect-error
22262
22284
  positionOverLifetime: item.content.positionOverLifetime
22263
22285
  };
22264
- playableAssetDatas.push(newPlayableAssetData);
22286
+ playableAssetDatas.push(newTransformPlayableAssetData);
22265
22287
  var newTrackData = {
22266
22288
  id: generateGUID(),
22267
22289
  dataType: "TransformTrack",
22268
22290
  children: [],
22269
22291
  clips: [
22270
22292
  {
22293
+ start: item.delay,
22294
+ duration: item.duration,
22295
+ endBehaviour: item.endBehavior,
22271
22296
  asset: {
22272
- id: newPlayableAssetData.id
22297
+ id: newTransformPlayableAssetData.id
22273
22298
  }
22274
22299
  }
22275
22300
  ]
@@ -22280,21 +22305,24 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22280
22305
  trackDatas.push(newTrackData);
22281
22306
  }
22282
22307
  if (item.type === ItemType.sprite) {
22283
- var newPlayableAssetData1 = {
22308
+ var newSpriteColorPlayableAssetData = {
22284
22309
  id: generateGUID(),
22285
22310
  dataType: "SpriteColorPlayableAsset",
22286
22311
  colorOverLifetime: item.content.colorOverLifetime,
22287
22312
  startColor: item.content.options.startColor
22288
22313
  };
22289
- playableAssetDatas.push(newPlayableAssetData1);
22314
+ playableAssetDatas.push(newSpriteColorPlayableAssetData);
22290
22315
  var newTrackData1 = {
22291
22316
  id: generateGUID(),
22292
22317
  dataType: "SpriteColorTrack",
22293
22318
  children: [],
22294
22319
  clips: [
22295
22320
  {
22321
+ start: item.delay,
22322
+ duration: item.duration,
22323
+ endBehaviour: item.endBehavior,
22296
22324
  asset: {
22297
- id: newPlayableAssetData1.id
22325
+ id: newSpriteColorPlayableAssetData.id
22298
22326
  }
22299
22327
  }
22300
22328
  ]
@@ -23924,14 +23952,17 @@ var tmpScale = new Vector3(1, 1, 1);
23924
23952
  this.timelinePlayable.play();
23925
23953
  for(var _iterator1 = _create_for_of_iterator_helper_loose(this.timelineAsset.tracks), _step1; !(_step1 = _iterator1()).done;){
23926
23954
  var track = _step1.value;
23927
- // 重播不销毁元素
23928
- if (this.item.endBehavior !== ItemEndBehavior.destroy || this.reusable) {
23929
- if (_instanceof1(track, exports.ObjectBindingTrack)) {
23930
- track.binding.reusable = true;
23931
- }
23932
- var subCompositionComponent = track.binding.getComponent(CompositionComponent);
23933
- if (subCompositionComponent) {
23934
- subCompositionComponent.reusable = true;
23955
+ var binding = track.binding;
23956
+ if (_instanceof1(binding, exports.VFXItem)) {
23957
+ // 重播不销毁元素
23958
+ if (this.item.endBehavior !== ItemEndBehavior.destroy || this.reusable) {
23959
+ if (_instanceof1(track, exports.ObjectBindingTrack)) {
23960
+ binding.reusable = true;
23961
+ }
23962
+ var subCompositionComponent = binding.getComponent(CompositionComponent);
23963
+ if (subCompositionComponent) {
23964
+ subCompositionComponent.reusable = true;
23965
+ }
23935
23966
  }
23936
23967
  }
23937
23968
  this.masterTracks.push(track);
@@ -27139,12 +27170,11 @@ setMaxSpriteMeshItemCount(8);
27139
27170
  */ Mesh.create = function(engine, props) {
27140
27171
  return new ThreeMesh(engine, props);
27141
27172
  };
27142
- var version = "2.0.0-alpha.13";
27173
+ var version = "2.0.0-alpha.14";
27143
27174
  logger.info("THREEJS plugin version: " + version);
27144
27175
 
27145
27176
  exports.AbstractPlugin = AbstractPlugin;
27146
27177
  exports.ActivationPlayable = ActivationPlayable;
27147
- exports.ActivationPlayableAsset = ActivationPlayableAsset;
27148
27178
  exports.AnimationClipPlayable = AnimationClipPlayable;
27149
27179
  exports.AssetLoader = AssetLoader;
27150
27180
  exports.AssetManager = AssetManager;