@eva/plugin-transition 2.0.0-beta.1 → 2.0.0-beta.2

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.
@@ -2,39 +2,6 @@ window.EVA = window.EVA || {};
2
2
  window.EVA.plugin = window.EVA.plugin || {};
3
3
  var _EVA_IIFE_transition = function (exports, eva_js) {
4
4
  'use strict';
5
- var extendStatics = function (d, b) {
6
- extendStatics = Object.setPrototypeOf || {
7
- __proto__: []
8
- } instanceof Array && function (d, b) {
9
- d.__proto__ = b;
10
- } || function (d, b) {
11
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
12
- };
13
- return extendStatics(d, b);
14
- };
15
- function __extends(d, b) {
16
- extendStatics(d, b);
17
- function __() {
18
- this.constructor = d;
19
- }
20
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21
- }
22
- function __values(o) {
23
- var s = typeof Symbol === "function" && Symbol.iterator,
24
- m = s && o[s],
25
- i = 0;
26
- if (m) return m.call(o);
27
- if (o && typeof o.length === "number") return {
28
- next: function () {
29
- if (o && i >= o.length) o = void 0;
30
- return {
31
- value: o && o[i++],
32
- done: !o
33
- };
34
- }
35
- };
36
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
- }
38
5
  var Easing = {
39
6
  Linear: {
40
7
  None: function (amount) {
@@ -703,7 +670,7 @@ var _EVA_IIFE_transition = function (exports, eva_js) {
703
670
  TWEEN.add.bind(TWEEN);
704
671
  TWEEN.remove.bind(TWEEN);
705
672
  TWEEN.update.bind(TWEEN);
706
- var easingMap = {
673
+ const easingMap = {
707
674
  linear: Easing.Linear.None,
708
675
  'ease-in': Easing.Quadratic.In,
709
676
  'ease-out': Easing.Quadratic.Out,
@@ -711,12 +678,10 @@ var _EVA_IIFE_transition = function (exports, eva_js) {
711
678
  'bounce-in': Easing.Bounce.In,
712
679
  'bounce-out': Easing.Bounce.Out,
713
680
  'bounce-in-out': Easing.Bounce.InOut,
714
- none: function (p) {
715
- return ~~p;
716
- }
681
+ none: p => ~~p
717
682
  };
718
- var Animation = function () {
719
- function Animation(timelines, tweenGroup) {
683
+ class Animation {
684
+ constructor(timelines, tweenGroup) {
720
685
  this.tweens = [];
721
686
  this.timelines = [];
722
687
  this.finishCount = 0;
@@ -726,20 +691,18 @@ var _EVA_IIFE_transition = function (exports, eva_js) {
726
691
  this.timelines = timelines;
727
692
  this.tweenGroup = tweenGroup;
728
693
  }
729
- Animation.prototype.on = function (eventName, callback) {
694
+ on(eventName, callback) {
730
695
  if (!this.callbacks[eventName]) {
731
696
  this.callbacks.set(eventName, []);
732
697
  }
733
698
  this.callbacks.get(eventName).push(callback);
734
- };
735
- Animation.prototype.emit = function (eventName) {
736
- var callbacks = this.callbacks.get(eventName);
699
+ }
700
+ emit(eventName) {
701
+ const callbacks = this.callbacks.get(eventName);
737
702
  if (!callbacks || !callbacks.length) return;
738
- callbacks.forEach(function (fn) {
739
- return fn();
740
- });
741
- };
742
- Animation.prototype.checkFinish = function () {
703
+ callbacks.forEach(fn => fn());
704
+ }
705
+ checkFinish() {
743
706
  if (++this.finishCount == this.tweens.length) {
744
707
  if (++this.currIteration == this.iteration) {
745
708
  this.emit('finish');
@@ -748,138 +711,120 @@ var _EVA_IIFE_transition = function (exports, eva_js) {
748
711
  this.start();
749
712
  }
750
713
  }
751
- };
752
- Animation.prototype.getObjectCache = function (component, name) {
753
- var key = "" + component.gameObject.id + component.name;
714
+ }
715
+ getObjectCache(component, name) {
716
+ const key = `${component.gameObject.id}${component.name}`;
754
717
  if (!this.objectCache[key]) {
755
718
  this.objectCache[key] = {};
756
719
  }
757
720
  if (this.objectCache[key][name]) {
758
721
  return this.objectCache[key][name];
759
722
  }
760
- var keys = name.split('.');
761
- var keyIndex = keys.length - 1;
762
- var property = component;
763
- for (var i = 0; i < keyIndex; i++) {
723
+ const keys = name.split('.');
724
+ const keyIndex = keys.length - 1;
725
+ let property = component;
726
+ for (let i = 0; i < keyIndex; i++) {
764
727
  property = property[keys[i]];
765
728
  }
766
729
  this.objectCache[key][name] = {
767
- property: property,
730
+ property,
768
731
  key: keys[keyIndex]
769
732
  };
770
733
  return this.objectCache[key][name];
771
- };
772
- Animation.prototype.doAnim = function (_a) {
773
- var component = _a.component,
774
- name = _a.name,
775
- value = _a.value;
776
- var _b = this.getObjectCache(component, name),
777
- property = _b.property,
778
- key = _b.key;
734
+ }
735
+ doAnim({
736
+ component,
737
+ name,
738
+ value
739
+ }) {
740
+ const {
741
+ property,
742
+ key
743
+ } = this.getObjectCache(component, name);
779
744
  property[key] = value;
780
- };
781
- Animation.prototype.init = function () {
782
- var _this = this;
745
+ }
746
+ init() {
783
747
  this.checkFinishFunc = this.checkFinish.bind(this);
784
- var lastTween;
785
- this.timelines.forEach(function (timeline, i) {
786
- for (var j = 0; j < timeline.values.length - 1; j++) {
787
- var frame = timeline.values[j];
788
- var nextFrame = timeline.values[j + 1];
789
- var tween = new Tween({
748
+ let lastTween;
749
+ this.timelines.forEach((timeline, i) => {
750
+ for (let j = 0; j < timeline.values.length - 1; j++) {
751
+ const frame = timeline.values[j];
752
+ const nextFrame = timeline.values[j + 1];
753
+ const tween = new Tween({
790
754
  value: frame.value
791
- }, _this.tweenGroup).to({
755
+ }, this.tweenGroup).to({
792
756
  value: nextFrame.value
793
- }).duration(nextFrame.time - frame.time).easing(easingMap[frame.tween]).onUpdate(function (props) {
794
- _this.doAnim({
757
+ }).duration(nextFrame.time - frame.time).easing(easingMap[frame.tween]).onUpdate(props => {
758
+ this.doAnim({
795
759
  component: timeline.component,
796
760
  name: timeline.name,
797
761
  value: props.value
798
762
  });
799
763
  });
800
764
  if (j === 0) {
801
- _this.tweens[i] = tween;
765
+ this.tweens[i] = tween;
802
766
  } else {
803
767
  lastTween.chain(tween);
804
768
  }
805
769
  lastTween = tween;
806
770
  }
807
- lastTween && lastTween.onComplete(function () {
808
- return _this.checkFinishFunc();
809
- });
771
+ lastTween && lastTween.onComplete(() => this.checkFinishFunc());
810
772
  });
811
- };
812
- Animation.prototype.play = function (iteration, currentTime) {
813
- if (iteration === void 0) {
814
- iteration = 1;
815
- }
773
+ }
774
+ play(iteration = 1, currentTime) {
816
775
  this.currentTime = currentTime;
817
776
  this.stoped = false;
818
777
  this.start();
819
778
  this.currIteration = 0;
820
779
  this.iteration = iteration;
821
- };
822
- Animation.prototype.start = function () {
823
- var _this = this;
780
+ }
781
+ start() {
824
782
  this.finishCount = 0;
825
783
  this.tweens.length = 0;
826
784
  this.init();
827
- this.tweens.forEach(function (tween) {
828
- return tween.start(_this.currentTime);
829
- });
830
- };
831
- Animation.prototype.pause = function () {
832
- var _this = this;
833
- this.tweens.forEach(function (tween) {
834
- return tween.pause(_this.currentTime);
835
- });
836
- };
837
- Animation.prototype.resume = function () {
838
- var _this = this;
839
- this.tweens.forEach(function (tween) {
840
- return tween.resume(_this.currentTime);
841
- });
842
- };
843
- Animation.prototype.stop = function () {
785
+ this.tweens.forEach(tween => tween.start(this.currentTime));
786
+ }
787
+ pause() {
788
+ this.tweens.forEach(tween => tween.pause(this.currentTime));
789
+ }
790
+ resume() {
791
+ this.tweens.forEach(tween => tween.resume(this.currentTime));
792
+ }
793
+ stop() {
844
794
  this.stoped = true;
845
- this.tweens.forEach(function (tween) {
846
- return tween.stop();
847
- });
848
- };
849
- Animation.prototype.destroy = function () {
795
+ this.tweens.forEach(tween => tween.stop());
796
+ }
797
+ destroy() {
850
798
  this.stop();
851
799
  this.tweens = null;
852
800
  this.timelines = null;
853
801
  this.objectCache = null;
854
802
  this.callbacks.clear();
855
803
  this.callbacks = null;
856
- };
857
- return Animation;
858
- }();
859
- var Animation$1 = Animation;
860
- var Transition = function (_super) {
861
- __extends(Transition, _super);
862
- function Transition() {
863
- var _this = _super !== null && _super.apply(this, arguments) || this;
864
- _this.animations = {};
865
- _this.group = {};
866
- _this.currentTime = 0;
867
- _this.needPlay = [];
868
- return _this;
869
804
  }
870
- Transition.prototype.init = function (_a) {
871
- var group = (_a === void 0 ? {
872
- group: {}
873
- } : _a).group;
805
+ }
806
+ class Transition extends eva_js.Component {
807
+ constructor() {
808
+ super(...arguments);
809
+ this.animations = {};
810
+ this.group = {};
811
+ this.currentTime = 0;
812
+ this.needPlay = [];
813
+ }
814
+ init({
815
+ group
816
+ } = {
817
+ group: {}
818
+ }) {
874
819
  this.group = group;
875
820
  this.tweenGroup = new Group();
876
- };
877
- Transition.prototype.awake = function () {
878
- for (var name_1 in this.group) {
879
- this.newAnimation(name_1);
821
+ }
822
+ awake() {
823
+ for (const name in this.group) {
824
+ this.newAnimation(name);
880
825
  }
881
- };
882
- Transition.prototype.play = function (name, iteration) {
826
+ }
827
+ play(name, iteration) {
883
828
  if (!name) {
884
829
  name = Object.keys(this.group)[0];
885
830
  }
@@ -888,36 +833,36 @@ var _EVA_IIFE_transition = function (exports, eva_js) {
888
833
  }
889
834
  if (name && this.animations[name]) {
890
835
  this.needPlay.push({
891
- name: name,
892
- iteration: iteration
836
+ name,
837
+ iteration
893
838
  });
894
839
  }
895
- };
896
- Transition.prototype.stop = function (name) {
840
+ }
841
+ stop(name) {
897
842
  var _a, _b;
898
843
  if (!name) {
899
- for (var key in this.animations) {
844
+ for (const key in this.animations) {
900
845
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.stop();
901
846
  }
902
847
  } else {
903
848
  (_b = this.animations[name]) === null || _b === void 0 ? void 0 : _b.stop();
904
849
  }
905
- };
906
- Transition.prototype.onPause = function () {
850
+ }
851
+ onPause() {
907
852
  var _a;
908
- for (var key in this.animations) {
853
+ for (const key in this.animations) {
909
854
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.pause();
910
855
  }
911
- };
912
- Transition.prototype.onResume = function () {
856
+ }
857
+ onResume() {
913
858
  var _a;
914
- for (var key in this.animations) {
859
+ for (const key in this.animations) {
915
860
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.resume();
916
861
  }
917
- };
918
- Transition.prototype.onDestroy = function () {
862
+ }
863
+ onDestroy() {
919
864
  var _a;
920
- for (var key in this.animations) {
865
+ for (const key in this.animations) {
921
866
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.destroy();
922
867
  }
923
868
  this.tweenGroup.removeAll();
@@ -925,58 +870,35 @@ var _EVA_IIFE_transition = function (exports, eva_js) {
925
870
  this.group = null;
926
871
  this.animations = null;
927
872
  this.removeAllListeners();
928
- };
929
- Transition.prototype.update = function (e) {
930
- var e_1, _a;
931
- var _b;
873
+ }
874
+ update(e) {
875
+ var _a;
932
876
  this.currentTime = e.time;
933
- for (var key in this.animations) {
877
+ for (const key in this.animations) {
934
878
  this.animations[key].currentTime = e.time;
935
879
  }
936
880
  this.tweenGroup.update(e.time);
937
- try {
938
- for (var _c = __values(this.needPlay), _d = _c.next(); !_d.done; _d = _c.next()) {
939
- var play = _d.value;
940
- (_b = this.animations[play.name]) === null || _b === void 0 ? void 0 : _b.play(play.iteration, this.currentTime);
941
- }
942
- } catch (e_1_1) {
943
- e_1 = {
944
- error: e_1_1
945
- };
946
- } finally {
947
- try {
948
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
949
- } finally {
950
- if (e_1) throw e_1.error;
951
- }
881
+ for (const play of this.needPlay) {
882
+ (_a = this.animations[play.name]) === null || _a === void 0 ? void 0 : _a.play(play.iteration, this.currentTime);
952
883
  }
953
884
  this.needPlay.length = 0;
954
- };
955
- Transition.prototype.newAnimation = function (name) {
956
- var _this = this;
957
- var animation = new Animation$1(this.group[name], this.tweenGroup);
958
- animation.on('finish', function () {
959
- return _this.emit('finish', name);
960
- });
885
+ }
886
+ newAnimation(name) {
887
+ const animation = new Animation(this.group[name], this.tweenGroup);
888
+ animation.on('finish', () => this.emit('finish', name));
961
889
  this.animations[name] = animation;
962
- };
963
- Transition.componentName = 'Transition';
964
- return Transition;
965
- }(eva_js.Component);
966
- var Transition$1 = Transition;
967
- var TransitionSystem = function (_super) {
968
- __extends(TransitionSystem, _super);
969
- function TransitionSystem() {
970
- var _this = _super !== null && _super.apply(this, arguments) || this;
971
- _this.name = 'transition';
972
- return _this;
973
890
  }
974
- TransitionSystem.systemName = 'transition';
975
- return TransitionSystem;
976
- }(eva_js.System);
977
- var TransitionSystem$1 = TransitionSystem;
978
- exports.Transition = Transition$1;
979
- exports.TransitionSystem = TransitionSystem$1;
891
+ }
892
+ Transition.componentName = 'Transition';
893
+ class TransitionSystem extends eva_js.System {
894
+ constructor() {
895
+ super(...arguments);
896
+ this.name = 'transition';
897
+ }
898
+ }
899
+ TransitionSystem.systemName = 'transition';
900
+ exports.Transition = Transition;
901
+ exports.TransitionSystem = TransitionSystem;
980
902
  Object.defineProperty(exports, '__esModule', {
981
903
  value: true
982
904
  });
@@ -1 +1 @@
1
- window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_transition=function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},n(t,e)};function i(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var r,o={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-o.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*o.Bounce.In(2*t):.5*o.Bounce.Out(2*t-1)+.5}}},s="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},a=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=s()),void 0===e&&(e=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],o=!e;r&&!1===r.update(t,o)&&!e&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}(),u={Linear:function(t,e){var n=t.length-1,i=n*e,r=Math.floor(i),o=u.Utils.Linear;return e<0?o(t[0],t[1],i):e>1?o(t[n],t[n-1],n-i):o(t[r],t[r+1>n?n:r+1],i-r)},Bezier:function(t,e){for(var n=0,i=t.length-1,r=Math.pow,o=u.Utils.Bernstein,s=0;s<=i;s++)n+=r(1-e,i-s)*r(e,s)*t[s]*o(i,s);return n},CatmullRom:function(t,e){var n=t.length-1,i=n*e,r=Math.floor(i),o=u.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(r=Math.floor(i=n*(1+e))),o(t[(r-1+n)%n],t[r],t[(r+1)%n],t[(r+2)%n],i-r)):e<0?t[0]-(o(t[0],t[0],t[1],t[1],-i)-t[0]):e>1?t[n]-(o(t[n],t[n],t[n-1],t[n-1],i-n)-t[n]):o(t[r?r-1:0],t[r],t[n<r+1?n:r+1],t[n<r+2?n:r+2],i-r)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=u.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:(r=[1],function(t){var e=1;if(r[t])return r[t];for(var n=t;n>1;n--)e*=n;return r[t]=e,e}),CatmullRom:function(t,e,n,i,r){var o=.5*(n-t),s=.5*(i-e),a=r*r;return(2*e-2*n+o+s)*(r*a)+(-3*e+3*n-2*o-s)*a+o*r+e}}},h=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),p=new a,c=function(){function t(t,e){void 0===e&&(e=p),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=o.Linear.None,this._interpolationFunction=u.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=h.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},t.prototype.duration=function(t){return this._duration=t,this},t.prototype.start=function(t){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==t?"string"==typeof t?s()+parseFloat(t):t:s(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},t.prototype._setupProperties=function(t,e,n,i){for(var r in n){var o=t[r],s=Array.isArray(o),a=s?"array":typeof o,u=!s&&Array.isArray(n[r]);if("undefined"!==a&&"function"!==a){if(u){var h=n[r];if(0===h.length)continue;h=h.map(this._handleRelativeValue.bind(this,o)),n[r]=[o].concat(h)}if("object"!==a&&!s||!o||u)void 0===e[r]&&(e[r]=o),s||(e[r]*=1),i[r]=u?n[r].slice().reverse():e[r]||0;else{for(var p in e[r]=s?[]:{},o)e[r][p]=o[p];i[r]=s?[]:{},this._setupProperties(o,e[r],n[r],i[r])}}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=s()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=s()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},t.prototype.group=function(t){return this._group=t,this},t.prototype.delay=function(t){return this._delayTime=t,this},t.prototype.repeat=function(t){return this._initialRepeat=t,this._repeat=t,this},t.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},t.prototype.yoyo=function(t){return this._yoyo=t,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return this._interpolationFunction=t,this},t.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},t.prototype.onStart=function(t){return this._onStartCallback=t,this},t.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},t.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},t.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},t.prototype.onStop=function(t){return this._onStopCallback=t,this},t.prototype.update=function(t,e){if(void 0===t&&(t=s()),void 0===e&&(e=!0),this._isPaused)return!0;var n,i,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>r)return!1;e&&this.start(t)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(t-this._startTime)/this._duration,i=0===this._duration||i>1?1:i;var o=this._easingFunction(i);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,o),this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var a=0,u=this._chainedTweens.length;a<u;a++)this._chainedTweens[a].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},t.prototype._updateProperties=function(t,e,n,i){for(var r in n)if(void 0!==e[r]){var o=e[r]||0,s=n[r],a=Array.isArray(t[r]),u=Array.isArray(s);!a&&u?t[r]=this._interpolationFunction(s,i):"object"==typeof s&&s?this._updateProperties(t[r],o,s,i):"number"==typeof(s=this._handleRelativeValue(o,s))&&(t[r]=o+(s-o)*i)}},t.prototype._handleRelativeValue=function(t,e){return"string"!=typeof e?e:"+"===e.charAt(0)||"-"===e.charAt(0)?t+parseFloat(e):parseFloat(e)},t.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],n=this._valuesEnd[t];this._valuesStartRepeat[t]="string"==typeof n?this._valuesStartRepeat[t]+parseFloat(n):this._valuesEnd[t],this._valuesEnd[t]=e},t}();h.nextId;var l=p;l.getAll.bind(l),l.removeAll.bind(l),l.add.bind(l),l.remove.bind(l),l.update.bind(l);var f={linear:o.Linear.None,"ease-in":o.Quadratic.In,"ease-out":o.Quadratic.Out,"ease-in-out":o.Quadratic.InOut,"bounce-in":o.Bounce.In,"bounce-out":o.Bounce.Out,"bounce-in-out":o.Bounce.InOut,none:function(t){return~~t}},_=function(){function t(t,e){this.tweens=[],this.timelines=[],this.finishCount=0,this.callbacks=new Map,this.objectCache={},this.currIteration=0,this.timelines=t,this.tweenGroup=e}return t.prototype.on=function(t,e){this.callbacks[t]||this.callbacks.set(t,[]),this.callbacks.get(t).push(e)},t.prototype.emit=function(t){var e=this.callbacks.get(t);e&&e.length&&e.forEach((function(t){return t()}))},t.prototype.checkFinish=function(){if(++this.finishCount==this.tweens.length)if(++this.currIteration==this.iteration)this.emit("finish");else{if(this.stoped)return;this.start()}},t.prototype.getObjectCache=function(t,e){var n=""+t.gameObject.id+t.name;if(this.objectCache[n]||(this.objectCache[n]={}),this.objectCache[n][e])return this.objectCache[n][e];for(var i=e.split("."),r=i.length-1,o=t,s=0;s<r;s++)o=o[i[s]];return this.objectCache[n][e]={property:o,key:i[r]},this.objectCache[n][e]},t.prototype.doAnim=function(t){var e=t.component,n=t.name,i=t.value,r=this.getObjectCache(e,n);r.property[r.key]=i},t.prototype.init=function(){var t,e=this;this.checkFinishFunc=this.checkFinish.bind(this),this.timelines.forEach((function(n,i){for(var r=0;r<n.values.length-1;r++){var o=n.values[r],s=n.values[r+1],a=new c({value:o.value},e.tweenGroup).to({value:s.value}).duration(s.time-o.time).easing(f[o.tween]).onUpdate((function(t){e.doAnim({component:n.component,name:n.name,value:t.value})}));0===r?e.tweens[i]=a:t.chain(a),t=a}t&&t.onComplete((function(){return e.checkFinishFunc()}))}))},t.prototype.play=function(t,e){void 0===t&&(t=1),this.currentTime=e,this.stoped=!1,this.start(),this.currIteration=0,this.iteration=t},t.prototype.start=function(){var t=this;this.finishCount=0,this.tweens.length=0,this.init(),this.tweens.forEach((function(e){return e.start(t.currentTime)}))},t.prototype.pause=function(){var t=this;this.tweens.forEach((function(e){return e.pause(t.currentTime)}))},t.prototype.resume=function(){var t=this;this.tweens.forEach((function(e){return e.resume(t.currentTime)}))},t.prototype.stop=function(){this.stoped=!0,this.tweens.forEach((function(t){return t.stop()}))},t.prototype.destroy=function(){this.stop(),this.tweens=null,this.timelines=null,this.objectCache=null,this.callbacks.clear(),this.callbacks=null},t}(),d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.animations={},e.group={},e.currentTime=0,e.needPlay=[],e}return i(e,t),e.prototype.init=function(t){var e=(void 0===t?{group:{}}:t).group;this.group=e,this.tweenGroup=new a},e.prototype.awake=function(){for(var t in this.group)this.newAnimation(t)},e.prototype.play=function(t,e){t||(t=Object.keys(this.group)[0]),t&&!this.animations[t]&&this.group[t]&&this.newAnimation(t),t&&this.animations[t]&&this.needPlay.push({name:t,iteration:e})},e.prototype.stop=function(t){var e,n;if(t)null===(n=this.animations[t])||void 0===n||n.stop();else for(var i in this.animations)null===(e=this.animations[i])||void 0===e||e.stop()},e.prototype.onPause=function(){var t;for(var e in this.animations)null===(t=this.animations[e])||void 0===t||t.pause()},e.prototype.onResume=function(){var t;for(var e in this.animations)null===(t=this.animations[e])||void 0===t||t.resume()},e.prototype.onDestroy=function(){var t;for(var e in this.animations)null===(t=this.animations[e])||void 0===t||t.destroy();this.tweenGroup.removeAll(),this.tweenGroup=null,this.group=null,this.animations=null,this.removeAllListeners()},e.prototype.update=function(t){var e,n,i;for(var r in this.currentTime=t.time,this.animations)this.animations[r].currentTime=t.time;this.tweenGroup.update(t.time);try{for(var o=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.needPlay),s=o.next();!s.done;s=o.next()){var a=s.value;null===(i=this.animations[a.name])||void 0===i||i.play(a.iteration,this.currentTime)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}this.needPlay.length=0},e.prototype.newAnimation=function(t){var e=this,n=new _(this.group[t],this.tweenGroup);n.on("finish",(function(){return e.emit("finish",t)})),this.animations[t]=n},e.componentName="Transition",e}(e.Component),y=d,v=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="transition",e}return i(e,t),e.systemName="transition",e}(e.System),m=v;return t.Transition=y,t.TransitionSystem=m,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA);window.EVA.plugin.transition=window.EVA.plugin.transition||_EVA_IIFE_transition;
1
+ window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_transition=function(t,e){"use strict";var i,n={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-n.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*n.Bounce.In(2*t):.5*n.Bounce.Out(2*t-1)+.5}}},s="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},r=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=s()),void 0===e&&(e=!1);var i=Object.keys(this._tweens);if(0===i.length)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n<i.length;n++){var r=this._tweens[i[n]],o=!e;r&&!1===r.update(t,o)&&!e&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}(),o={Linear:function(t,e){var i=t.length-1,n=i*e,s=Math.floor(n),r=o.Utils.Linear;return e<0?r(t[0],t[1],n):e>1?r(t[i],t[i-1],i-n):r(t[s],t[s+1>i?i:s+1],n-s)},Bezier:function(t,e){for(var i=0,n=t.length-1,s=Math.pow,r=o.Utils.Bernstein,a=0;a<=n;a++)i+=s(1-e,n-a)*s(e,a)*t[a]*r(n,a);return i},CatmullRom:function(t,e){var i=t.length-1,n=i*e,s=Math.floor(n),r=o.Utils.CatmullRom;return t[0]===t[i]?(e<0&&(s=Math.floor(n=i*(1+e))),r(t[(s-1+i)%i],t[s],t[(s+1)%i],t[(s+2)%i],n-s)):e<0?t[0]-(r(t[0],t[0],t[1],t[1],-n)-t[0]):e>1?t[i]-(r(t[i],t[i],t[i-1],t[i-1],n-i)-t[i]):r(t[s?s-1:0],t[s],t[i<s+1?i:s+1],t[i<s+2?i:s+2],n-s)},Utils:{Linear:function(t,e,i){return(e-t)*i+t},Bernstein:function(t,e){var i=o.Utils.Factorial;return i(t)/i(e)/i(t-e)},Factorial:(i=[1],function(t){var e=1;if(i[t])return i[t];for(var n=t;n>1;n--)e*=n;return i[t]=e,e}),CatmullRom:function(t,e,i,n,s){var r=.5*(i-t),o=.5*(n-e),a=s*s;return(2*e-2*i+r+o)*(s*a)+(-3*e+3*i-2*r-o)*a+r*s+e}}},a=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),h=new r,u=function(){function t(t,e){void 0===e&&(e=h),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=n.Linear.None,this._interpolationFunction=o.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=a.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},t.prototype.duration=function(t){return this._duration=t,this},t.prototype.start=function(t){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==t?"string"==typeof t?s()+parseFloat(t):t:s(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},t.prototype._setupProperties=function(t,e,i,n){for(var s in i){var r=t[s],o=Array.isArray(r),a=o?"array":typeof r,h=!o&&Array.isArray(i[s]);if("undefined"!==a&&"function"!==a){if(h){var u=i[s];if(0===u.length)continue;u=u.map(this._handleRelativeValue.bind(this,r)),i[s]=[r].concat(u)}if("object"!==a&&!o||!r||h)void 0===e[s]&&(e[s]=r),o||(e[s]*=1),n[s]=h?i[s].slice().reverse():e[s]||0;else{for(var c in e[s]=o?[]:{},r)e[s][c]=r[c];n[s]=o?[]:{},this._setupProperties(r,e[s],i[s],n[s])}}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=s()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=s()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},t.prototype.group=function(t){return this._group=t,this},t.prototype.delay=function(t){return this._delayTime=t,this},t.prototype.repeat=function(t){return this._initialRepeat=t,this._repeat=t,this},t.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},t.prototype.yoyo=function(t){return this._yoyo=t,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return this._interpolationFunction=t,this},t.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},t.prototype.onStart=function(t){return this._onStartCallback=t,this},t.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},t.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},t.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},t.prototype.onStop=function(t){return this._onStopCallback=t,this},t.prototype.update=function(t,e){if(void 0===t&&(t=s()),void 0===e&&(e=!0),this._isPaused)return!0;var i,n,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>r)return!1;e&&this.start(t)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),n=(t-this._startTime)/this._duration,n=0===this._duration||n>1?1:n;var o=this._easingFunction(n);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,o),this._onUpdateCallback&&this._onUpdateCallback(this._object,n),1===n){if(this._repeat>0){for(i in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[i]||(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var a=0,h=this._chainedTweens.length;a<h;a++)this._chainedTweens[a].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},t.prototype._updateProperties=function(t,e,i,n){for(var s in i)if(void 0!==e[s]){var r=e[s]||0,o=i[s],a=Array.isArray(t[s]),h=Array.isArray(o);!a&&h?t[s]=this._interpolationFunction(o,n):"object"==typeof o&&o?this._updateProperties(t[s],r,o,n):"number"==typeof(o=this._handleRelativeValue(r,o))&&(t[s]=r+(o-r)*n)}},t.prototype._handleRelativeValue=function(t,e){return"string"!=typeof e?e:"+"===e.charAt(0)||"-"===e.charAt(0)?t+parseFloat(e):parseFloat(e)},t.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];this._valuesStartRepeat[t]="string"==typeof i?this._valuesStartRepeat[t]+parseFloat(i):this._valuesEnd[t],this._valuesEnd[t]=e},t}();a.nextId;var c=h;c.getAll.bind(c),c.removeAll.bind(c),c.add.bind(c),c.remove.bind(c),c.update.bind(c);const p={linear:n.Linear.None,"ease-in":n.Quadratic.In,"ease-out":n.Quadratic.Out,"ease-in-out":n.Quadratic.InOut,"bounce-in":n.Bounce.In,"bounce-out":n.Bounce.Out,"bounce-in-out":n.Bounce.InOut,none:t=>~~t};class l{constructor(t,e){this.tweens=[],this.timelines=[],this.finishCount=0,this.callbacks=new Map,this.objectCache={},this.currIteration=0,this.timelines=t,this.tweenGroup=e}on(t,e){this.callbacks[t]||this.callbacks.set(t,[]),this.callbacks.get(t).push(e)}emit(t){const e=this.callbacks.get(t);e&&e.length&&e.forEach((t=>t()))}checkFinish(){if(++this.finishCount==this.tweens.length)if(++this.currIteration==this.iteration)this.emit("finish");else{if(this.stoped)return;this.start()}}getObjectCache(t,e){const i=`${t.gameObject.id}${t.name}`;if(this.objectCache[i]||(this.objectCache[i]={}),this.objectCache[i][e])return this.objectCache[i][e];const n=e.split("."),s=n.length-1;let r=t;for(let t=0;t<s;t++)r=r[n[t]];return this.objectCache[i][e]={property:r,key:n[s]},this.objectCache[i][e]}doAnim({component:t,name:e,value:i}){const{property:n,key:s}=this.getObjectCache(t,e);n[s]=i}init(){let t;this.checkFinishFunc=this.checkFinish.bind(this),this.timelines.forEach(((e,i)=>{for(let n=0;n<e.values.length-1;n++){const s=e.values[n],r=e.values[n+1],o=new u({value:s.value},this.tweenGroup).to({value:r.value}).duration(r.time-s.time).easing(p[s.tween]).onUpdate((t=>{this.doAnim({component:e.component,name:e.name,value:t.value})}));0===n?this.tweens[i]=o:t.chain(o),t=o}t&&t.onComplete((()=>this.checkFinishFunc()))}))}play(t=1,e){this.currentTime=e,this.stoped=!1,this.start(),this.currIteration=0,this.iteration=t}start(){this.finishCount=0,this.tweens.length=0,this.init(),this.tweens.forEach((t=>t.start(this.currentTime)))}pause(){this.tweens.forEach((t=>t.pause(this.currentTime)))}resume(){this.tweens.forEach((t=>t.resume(this.currentTime)))}stop(){this.stoped=!0,this.tweens.forEach((t=>t.stop()))}destroy(){this.stop(),this.tweens=null,this.timelines=null,this.objectCache=null,this.callbacks.clear(),this.callbacks=null}}class d extends e.Component{constructor(){super(...arguments),this.animations={},this.group={},this.currentTime=0,this.needPlay=[]}init({group:t}={group:{}}){this.group=t,this.tweenGroup=new r}awake(){for(const t in this.group)this.newAnimation(t)}play(t,e){t||(t=Object.keys(this.group)[0]),t&&!this.animations[t]&&this.group[t]&&this.newAnimation(t),t&&this.animations[t]&&this.needPlay.push({name:t,iteration:e})}stop(t){var e,i;if(t)null===(i=this.animations[t])||void 0===i||i.stop();else for(const t in this.animations)null===(e=this.animations[t])||void 0===e||e.stop()}onPause(){var t;for(const e in this.animations)null===(t=this.animations[e])||void 0===t||t.pause()}onResume(){var t;for(const e in this.animations)null===(t=this.animations[e])||void 0===t||t.resume()}onDestroy(){var t;for(const e in this.animations)null===(t=this.animations[e])||void 0===t||t.destroy();this.tweenGroup.removeAll(),this.tweenGroup=null,this.group=null,this.animations=null,this.removeAllListeners()}update(t){var e;this.currentTime=t.time;for(const e in this.animations)this.animations[e].currentTime=t.time;this.tweenGroup.update(t.time);for(const t of this.needPlay)null===(e=this.animations[t.name])||void 0===e||e.play(t.iteration,this.currentTime);this.needPlay.length=0}newAnimation(t){const e=new l(this.group[t],this.tweenGroup);e.on("finish",(()=>this.emit("finish",t))),this.animations[t]=e}}d.componentName="Transition";class _ extends e.System{constructor(){super(...arguments),this.name="transition"}}return _.systemName="transition",t.Transition=d,t.TransitionSystem=_,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA);window.EVA.plugin.transition=window.EVA.plugin.transition||_EVA_IIFE_transition;
@@ -5,47 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tween_js = require('@tweenjs/tween.js');
6
6
  var eva_js = require('@eva/eva.js');
7
7
 
8
- /*! *****************************************************************************
9
- Copyright (c) Microsoft Corporation. All rights reserved.
10
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
11
- this file except in compliance with the License. You may obtain a copy of the
12
- License at http://www.apache.org/licenses/LICENSE-2.0
13
-
14
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17
- MERCHANTABLITY OR NON-INFRINGEMENT.
18
-
19
- See the Apache Version 2.0 License for specific language governing permissions
20
- and limitations under the License.
21
- ***************************************************************************** */
22
- /* global Reflect, Promise */
23
-
24
- var extendStatics = function(d, b) {
25
- extendStatics = Object.setPrototypeOf ||
26
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
-
31
- function __extends(d, b) {
32
- extendStatics(d, b);
33
- function __() { this.constructor = d; }
34
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35
- }
36
-
37
- function __values(o) {
38
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
39
- if (m) return m.call(o);
40
- return {
41
- next: function () {
42
- if (o && i >= o.length) o = void 0;
43
- return { value: o && o[i++], done: !o };
44
- }
45
- };
46
- }
47
-
48
- var easingMap = {
8
+ const easingMap = {
49
9
  linear: tween_js.Easing.Linear.None,
50
10
  'ease-in': tween_js.Easing.Quadratic.In,
51
11
  'ease-out': tween_js.Easing.Quadratic.Out,
@@ -53,10 +13,10 @@ var easingMap = {
53
13
  'bounce-in': tween_js.Easing.Bounce.In,
54
14
  'bounce-out': tween_js.Easing.Bounce.Out,
55
15
  'bounce-in-out': tween_js.Easing.Bounce.InOut,
56
- none: function (p) { return ~~p; },
16
+ none: p => ~~p,
57
17
  };
58
- var Animation = (function () {
59
- function Animation(timelines, tweenGroup) {
18
+ class Animation {
19
+ constructor(timelines, tweenGroup) {
60
20
  this.tweens = [];
61
21
  this.timelines = [];
62
22
  this.finishCount = 0;
@@ -66,19 +26,19 @@ var Animation = (function () {
66
26
  this.timelines = timelines;
67
27
  this.tweenGroup = tweenGroup;
68
28
  }
69
- Animation.prototype.on = function (eventName, callback) {
29
+ on(eventName, callback) {
70
30
  if (!this.callbacks[eventName]) {
71
31
  this.callbacks.set(eventName, []);
72
32
  }
73
33
  this.callbacks.get(eventName).push(callback);
74
- };
75
- Animation.prototype.emit = function (eventName) {
76
- var callbacks = this.callbacks.get(eventName);
34
+ }
35
+ emit(eventName) {
36
+ const callbacks = this.callbacks.get(eventName);
77
37
  if (!callbacks || !callbacks.length)
78
38
  return;
79
- callbacks.forEach(function (fn) { return fn(); });
80
- };
81
- Animation.prototype.checkFinish = function () {
39
+ callbacks.forEach(fn => fn());
40
+ }
41
+ checkFinish() {
82
42
  if (++this.finishCount == this.tweens.length) {
83
43
  if (++this.currIteration == this.iteration) {
84
44
  this.emit('finish');
@@ -89,119 +49,108 @@ var Animation = (function () {
89
49
  this.start();
90
50
  }
91
51
  }
92
- };
93
- Animation.prototype.getObjectCache = function (component, name) {
94
- var key = "" + component.gameObject.id + component.name;
52
+ }
53
+ getObjectCache(component, name) {
54
+ const key = `${component.gameObject.id}${component.name}`;
95
55
  if (!this.objectCache[key]) {
96
56
  this.objectCache[key] = {};
97
57
  }
98
58
  if (this.objectCache[key][name]) {
99
59
  return this.objectCache[key][name];
100
60
  }
101
- var keys = name.split('.');
102
- var keyIndex = keys.length - 1;
103
- var property = component;
104
- for (var i = 0; i < keyIndex; i++) {
61
+ const keys = name.split('.');
62
+ const keyIndex = keys.length - 1;
63
+ let property = component;
64
+ for (let i = 0; i < keyIndex; i++) {
105
65
  property = property[keys[i]];
106
66
  }
107
- this.objectCache[key][name] = { property: property, key: keys[keyIndex] };
67
+ this.objectCache[key][name] = { property, key: keys[keyIndex] };
108
68
  return this.objectCache[key][name];
109
- };
110
- Animation.prototype.doAnim = function (_a) {
111
- var component = _a.component, name = _a.name, value = _a.value;
112
- var _b = this.getObjectCache(component, name), property = _b.property, key = _b.key;
69
+ }
70
+ doAnim({ component, name, value }) {
71
+ const { property, key } = this.getObjectCache(component, name);
113
72
  property[key] = value;
114
- };
115
- Animation.prototype.init = function () {
116
- var _this = this;
73
+ }
74
+ init() {
117
75
  this.checkFinishFunc = this.checkFinish.bind(this);
118
- var lastTween;
119
- this.timelines.forEach(function (timeline, i) {
120
- for (var j = 0; j < timeline.values.length - 1; j++) {
121
- var frame = timeline.values[j];
122
- var nextFrame = timeline.values[j + 1];
123
- var tween = new tween_js.Tween({ value: frame.value }, _this.tweenGroup)
76
+ let lastTween;
77
+ this.timelines.forEach((timeline, i) => {
78
+ for (let j = 0; j < timeline.values.length - 1; j++) {
79
+ const frame = timeline.values[j];
80
+ const nextFrame = timeline.values[j + 1];
81
+ const tween = new tween_js.Tween({ value: frame.value }, this.tweenGroup)
124
82
  .to({ value: nextFrame.value })
125
83
  .duration(nextFrame.time - frame.time)
126
84
  .easing(easingMap[frame.tween])
127
- .onUpdate(function (props) {
128
- _this.doAnim({
85
+ .onUpdate(props => {
86
+ this.doAnim({
129
87
  component: timeline.component,
130
88
  name: timeline.name,
131
89
  value: props.value,
132
90
  });
133
91
  });
134
92
  if (j === 0) {
135
- _this.tweens[i] = tween;
93
+ this.tweens[i] = tween;
136
94
  }
137
95
  else {
138
96
  lastTween.chain(tween);
139
97
  }
140
98
  lastTween = tween;
141
99
  }
142
- lastTween && lastTween.onComplete(function () { return _this.checkFinishFunc(); });
100
+ lastTween && lastTween.onComplete(() => this.checkFinishFunc());
143
101
  });
144
- };
145
- Animation.prototype.play = function (iteration, currentTime) {
146
- if (iteration === void 0) { iteration = 1; }
102
+ }
103
+ play(iteration = 1, currentTime) {
147
104
  this.currentTime = currentTime;
148
105
  this.stoped = false;
149
106
  this.start();
150
107
  this.currIteration = 0;
151
108
  this.iteration = iteration;
152
- };
153
- Animation.prototype.start = function () {
154
- var _this = this;
109
+ }
110
+ start() {
155
111
  this.finishCount = 0;
156
112
  this.tweens.length = 0;
157
113
  this.init();
158
- this.tweens.forEach(function (tween) { return tween.start(_this.currentTime); });
159
- };
160
- Animation.prototype.pause = function () {
161
- var _this = this;
162
- this.tweens.forEach(function (tween) { return tween.pause(_this.currentTime); });
163
- };
164
- Animation.prototype.resume = function () {
165
- var _this = this;
166
- this.tweens.forEach(function (tween) { return tween.resume(_this.currentTime); });
167
- };
168
- Animation.prototype.stop = function () {
114
+ this.tweens.forEach((tween) => tween.start(this.currentTime));
115
+ }
116
+ pause() {
117
+ this.tweens.forEach((tween) => tween.pause(this.currentTime));
118
+ }
119
+ resume() {
120
+ this.tweens.forEach((tween) => tween.resume(this.currentTime));
121
+ }
122
+ stop() {
169
123
  this.stoped = true;
170
- this.tweens.forEach(function (tween) { return tween.stop(); });
171
- };
172
- Animation.prototype.destroy = function () {
124
+ this.tweens.forEach((tween) => tween.stop());
125
+ }
126
+ destroy() {
173
127
  this.stop();
174
128
  this.tweens = null;
175
129
  this.timelines = null;
176
130
  this.objectCache = null;
177
131
  this.callbacks.clear();
178
132
  this.callbacks = null;
179
- };
180
- return Animation;
181
- }());
182
- var Animation$1 = Animation;
133
+ }
134
+ }
183
135
 
184
- var Transition = (function (_super) {
185
- __extends(Transition, _super);
186
- function Transition() {
187
- var _this = _super !== null && _super.apply(this, arguments) || this;
188
- _this.animations = {};
189
- _this.group = {};
190
- _this.currentTime = 0;
191
- _this.needPlay = [];
192
- return _this;
136
+ class Transition extends eva_js.Component {
137
+ constructor() {
138
+ super(...arguments);
139
+ this.animations = {};
140
+ this.group = {};
141
+ this.currentTime = 0;
142
+ this.needPlay = [];
193
143
  }
194
- Transition.prototype.init = function (_a) {
195
- var group = (_a === void 0 ? { group: {} } : _a).group;
144
+ init({ group } = { group: {} }) {
196
145
  this.group = group;
197
146
  this.tweenGroup = new tween_js.Group();
198
- };
199
- Transition.prototype.awake = function () {
200
- for (var name_1 in this.group) {
201
- this.newAnimation(name_1);
147
+ }
148
+ awake() {
149
+ for (const name in this.group) {
150
+ this.newAnimation(name);
202
151
  }
203
- };
204
- Transition.prototype.play = function (name, iteration) {
152
+ }
153
+ play(name, iteration) {
205
154
  if (!name) {
206
155
  name = Object.keys(this.group)[0];
207
156
  }
@@ -209,35 +158,35 @@ var Transition = (function (_super) {
209
158
  this.newAnimation(name);
210
159
  }
211
160
  if (name && this.animations[name]) {
212
- this.needPlay.push({ name: name, iteration: iteration });
161
+ this.needPlay.push({ name, iteration });
213
162
  }
214
- };
215
- Transition.prototype.stop = function (name) {
163
+ }
164
+ stop(name) {
216
165
  var _a, _b;
217
166
  if (!name) {
218
- for (var key in this.animations) {
167
+ for (const key in this.animations) {
219
168
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.stop();
220
169
  }
221
170
  }
222
171
  else {
223
172
  (_b = this.animations[name]) === null || _b === void 0 ? void 0 : _b.stop();
224
173
  }
225
- };
226
- Transition.prototype.onPause = function () {
174
+ }
175
+ onPause() {
227
176
  var _a;
228
- for (var key in this.animations) {
177
+ for (const key in this.animations) {
229
178
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.pause();
230
179
  }
231
- };
232
- Transition.prototype.onResume = function () {
180
+ }
181
+ onResume() {
233
182
  var _a;
234
- for (var key in this.animations) {
183
+ for (const key in this.animations) {
235
184
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.resume();
236
185
  }
237
- };
238
- Transition.prototype.onDestroy = function () {
186
+ }
187
+ onDestroy() {
239
188
  var _a;
240
- for (var key in this.animations) {
189
+ for (const key in this.animations) {
241
190
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.destroy();
242
191
  }
243
192
  this.tweenGroup.removeAll();
@@ -245,52 +194,34 @@ var Transition = (function (_super) {
245
194
  this.group = null;
246
195
  this.animations = null;
247
196
  this.removeAllListeners();
248
- };
249
- Transition.prototype.update = function (e) {
250
- var e_1, _a;
251
- var _b;
197
+ }
198
+ update(e) {
199
+ var _a;
252
200
  this.currentTime = e.time;
253
- for (var key in this.animations) {
201
+ for (const key in this.animations) {
254
202
  this.animations[key].currentTime = e.time;
255
203
  }
256
204
  this.tweenGroup.update(e.time);
257
- try {
258
- for (var _c = __values(this.needPlay), _d = _c.next(); !_d.done; _d = _c.next()) {
259
- var play = _d.value;
260
- (_b = this.animations[play.name]) === null || _b === void 0 ? void 0 : _b.play(play.iteration, this.currentTime);
261
- }
262
- }
263
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
264
- finally {
265
- try {
266
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
267
- }
268
- finally { if (e_1) throw e_1.error; }
205
+ for (const play of this.needPlay) {
206
+ (_a = this.animations[play.name]) === null || _a === void 0 ? void 0 : _a.play(play.iteration, this.currentTime);
269
207
  }
270
208
  this.needPlay.length = 0;
271
- };
272
- Transition.prototype.newAnimation = function (name) {
273
- var _this = this;
274
- var animation = new Animation$1(this.group[name], this.tweenGroup);
275
- animation.on('finish', function () { return _this.emit('finish', name); });
209
+ }
210
+ newAnimation(name) {
211
+ const animation = new Animation(this.group[name], this.tweenGroup);
212
+ animation.on('finish', () => this.emit('finish', name));
276
213
  this.animations[name] = animation;
277
- };
278
- Transition.componentName = 'Transition';
279
- return Transition;
280
- }(eva_js.Component));
281
- var Transition$1 = Transition;
214
+ }
215
+ }
216
+ Transition.componentName = 'Transition';
282
217
 
283
- var TransitionSystem = (function (_super) {
284
- __extends(TransitionSystem, _super);
285
- function TransitionSystem() {
286
- var _this = _super !== null && _super.apply(this, arguments) || this;
287
- _this.name = 'transition';
288
- return _this;
218
+ class TransitionSystem extends eva_js.System {
219
+ constructor() {
220
+ super(...arguments);
221
+ this.name = 'transition';
289
222
  }
290
- TransitionSystem.systemName = 'transition';
291
- return TransitionSystem;
292
- }(eva_js.System));
293
- var TransitionSystem$1 = TransitionSystem;
223
+ }
224
+ TransitionSystem.systemName = 'transition';
294
225
 
295
- exports.Transition = Transition$1;
296
- exports.TransitionSystem = TransitionSystem$1;
226
+ exports.Transition = Transition;
227
+ exports.TransitionSystem = TransitionSystem;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@tweenjs/tween.js"),n=require("@eva/eva.js"),i=function(t,n){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},i(t,n)};function e(t,n){function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var o={linear:t.Easing.Linear.None,"ease-in":t.Easing.Quadratic.In,"ease-out":t.Easing.Quadratic.Out,"ease-in-out":t.Easing.Quadratic.InOut,"bounce-in":t.Easing.Bounce.In,"bounce-out":t.Easing.Bounce.Out,"bounce-in-out":t.Easing.Bounce.InOut,none:function(t){return~~t}},r=function(){function n(t,n){this.tweens=[],this.timelines=[],this.finishCount=0,this.callbacks=new Map,this.objectCache={},this.currIteration=0,this.timelines=t,this.tweenGroup=n}return n.prototype.on=function(t,n){this.callbacks[t]||this.callbacks.set(t,[]),this.callbacks.get(t).push(n)},n.prototype.emit=function(t){var n=this.callbacks.get(t);n&&n.length&&n.forEach((function(t){return t()}))},n.prototype.checkFinish=function(){if(++this.finishCount==this.tweens.length)if(++this.currIteration==this.iteration)this.emit("finish");else{if(this.stoped)return;this.start()}},n.prototype.getObjectCache=function(t,n){var i=""+t.gameObject.id+t.name;if(this.objectCache[i]||(this.objectCache[i]={}),this.objectCache[i][n])return this.objectCache[i][n];for(var e=n.split("."),o=e.length-1,r=t,s=0;s<o;s++)r=r[e[s]];return this.objectCache[i][n]={property:r,key:e[o]},this.objectCache[i][n]},n.prototype.doAnim=function(t){var n=t.component,i=t.name,e=t.value,o=this.getObjectCache(n,i);o.property[o.key]=e},n.prototype.init=function(){var n,i=this;this.checkFinishFunc=this.checkFinish.bind(this),this.timelines.forEach((function(e,r){for(var s=0;s<e.values.length-1;s++){var a=e.values[s],u=e.values[s+1],h=new t.Tween({value:a.value},i.tweenGroup).to({value:u.value}).duration(u.time-a.time).easing(o[a.tween]).onUpdate((function(t){i.doAnim({component:e.component,name:e.name,value:t.value})}));0===s?i.tweens[r]=h:n.chain(h),n=h}n&&n.onComplete((function(){return i.checkFinishFunc()}))}))},n.prototype.play=function(t,n){void 0===t&&(t=1),this.currentTime=n,this.stoped=!1,this.start(),this.currIteration=0,this.iteration=t},n.prototype.start=function(){var t=this;this.finishCount=0,this.tweens.length=0,this.init(),this.tweens.forEach((function(n){return n.start(t.currentTime)}))},n.prototype.pause=function(){var t=this;this.tweens.forEach((function(n){return n.pause(t.currentTime)}))},n.prototype.resume=function(){var t=this;this.tweens.forEach((function(n){return n.resume(t.currentTime)}))},n.prototype.stop=function(){this.stoped=!0,this.tweens.forEach((function(t){return t.stop()}))},n.prototype.destroy=function(){this.stop(),this.tweens=null,this.timelines=null,this.objectCache=null,this.callbacks.clear(),this.callbacks=null},n}(),s=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.animations={},t.group={},t.currentTime=0,t.needPlay=[],t}return e(i,n),i.prototype.init=function(n){var i=(void 0===n?{group:{}}:n).group;this.group=i,this.tweenGroup=new t.Group},i.prototype.awake=function(){for(var t in this.group)this.newAnimation(t)},i.prototype.play=function(t,n){t||(t=Object.keys(this.group)[0]),t&&!this.animations[t]&&this.group[t]&&this.newAnimation(t),t&&this.animations[t]&&this.needPlay.push({name:t,iteration:n})},i.prototype.stop=function(t){var n,i;if(t)null===(i=this.animations[t])||void 0===i||i.stop();else for(var e in this.animations)null===(n=this.animations[e])||void 0===n||n.stop()},i.prototype.onPause=function(){var t;for(var n in this.animations)null===(t=this.animations[n])||void 0===t||t.pause()},i.prototype.onResume=function(){var t;for(var n in this.animations)null===(t=this.animations[n])||void 0===t||t.resume()},i.prototype.onDestroy=function(){var t;for(var n in this.animations)null===(t=this.animations[n])||void 0===t||t.destroy();this.tweenGroup.removeAll(),this.tweenGroup=null,this.group=null,this.animations=null,this.removeAllListeners()},i.prototype.update=function(t){var n,i,e;for(var o in this.currentTime=t.time,this.animations)this.animations[o].currentTime=t.time;this.tweenGroup.update(t.time);try{for(var r=function(t){var n="function"==typeof Symbol&&t[Symbol.iterator],i=0;return n?n.call(t):{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}}}(this.needPlay),s=r.next();!s.done;s=r.next()){var a=s.value;null===(e=this.animations[a.name])||void 0===e||e.play(a.iteration,this.currentTime)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}this.needPlay.length=0},i.prototype.newAnimation=function(t){var n=this,i=new r(this.group[t],this.tweenGroup);i.on("finish",(function(){return n.emit("finish",t)})),this.animations[t]=i},i.componentName="Transition",i}(n.Component),a=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.name="transition",n}return e(n,t),n.systemName="transition",n}(n.System);exports.Transition=s,exports.TransitionSystem=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@tweenjs/tween.js"),i=require("@eva/eva.js");const e={linear:t.Easing.Linear.None,"ease-in":t.Easing.Quadratic.In,"ease-out":t.Easing.Quadratic.Out,"ease-in-out":t.Easing.Quadratic.InOut,"bounce-in":t.Easing.Bounce.In,"bounce-out":t.Easing.Bounce.Out,"bounce-in-out":t.Easing.Bounce.InOut,none:t=>~~t};class s{constructor(t,i){this.tweens=[],this.timelines=[],this.finishCount=0,this.callbacks=new Map,this.objectCache={},this.currIteration=0,this.timelines=t,this.tweenGroup=i}on(t,i){this.callbacks[t]||this.callbacks.set(t,[]),this.callbacks.get(t).push(i)}emit(t){const i=this.callbacks.get(t);i&&i.length&&i.forEach((t=>t()))}checkFinish(){if(++this.finishCount==this.tweens.length)if(++this.currIteration==this.iteration)this.emit("finish");else{if(this.stoped)return;this.start()}}getObjectCache(t,i){const e=`${t.gameObject.id}${t.name}`;if(this.objectCache[e]||(this.objectCache[e]={}),this.objectCache[e][i])return this.objectCache[e][i];const s=i.split("."),n=s.length-1;let o=t;for(let t=0;t<n;t++)o=o[s[t]];return this.objectCache[e][i]={property:o,key:s[n]},this.objectCache[e][i]}doAnim({component:t,name:i,value:e}){const{property:s,key:n}=this.getObjectCache(t,i);s[n]=e}init(){let i;this.checkFinishFunc=this.checkFinish.bind(this),this.timelines.forEach(((s,n)=>{for(let o=0;o<s.values.length-1;o++){const a=s.values[o],h=s.values[o+1],r=new t.Tween({value:a.value},this.tweenGroup).to({value:h.value}).duration(h.time-a.time).easing(e[a.tween]).onUpdate((t=>{this.doAnim({component:s.component,name:s.name,value:t.value})}));0===o?this.tweens[n]=r:i.chain(r),i=r}i&&i.onComplete((()=>this.checkFinishFunc()))}))}play(t=1,i){this.currentTime=i,this.stoped=!1,this.start(),this.currIteration=0,this.iteration=t}start(){this.finishCount=0,this.tweens.length=0,this.init(),this.tweens.forEach((t=>t.start(this.currentTime)))}pause(){this.tweens.forEach((t=>t.pause(this.currentTime)))}resume(){this.tweens.forEach((t=>t.resume(this.currentTime)))}stop(){this.stoped=!0,this.tweens.forEach((t=>t.stop()))}destroy(){this.stop(),this.tweens=null,this.timelines=null,this.objectCache=null,this.callbacks.clear(),this.callbacks=null}}class n extends i.Component{constructor(){super(...arguments),this.animations={},this.group={},this.currentTime=0,this.needPlay=[]}init({group:i}={group:{}}){this.group=i,this.tweenGroup=new t.Group}awake(){for(const t in this.group)this.newAnimation(t)}play(t,i){t||(t=Object.keys(this.group)[0]),t&&!this.animations[t]&&this.group[t]&&this.newAnimation(t),t&&this.animations[t]&&this.needPlay.push({name:t,iteration:i})}stop(t){var i,e;if(t)null===(e=this.animations[t])||void 0===e||e.stop();else for(const t in this.animations)null===(i=this.animations[t])||void 0===i||i.stop()}onPause(){var t;for(const i in this.animations)null===(t=this.animations[i])||void 0===t||t.pause()}onResume(){var t;for(const i in this.animations)null===(t=this.animations[i])||void 0===t||t.resume()}onDestroy(){var t;for(const i in this.animations)null===(t=this.animations[i])||void 0===t||t.destroy();this.tweenGroup.removeAll(),this.tweenGroup=null,this.group=null,this.animations=null,this.removeAllListeners()}update(t){var i;this.currentTime=t.time;for(const i in this.animations)this.animations[i].currentTime=t.time;this.tweenGroup.update(t.time);for(const t of this.needPlay)null===(i=this.animations[t.name])||void 0===i||i.play(t.iteration,this.currentTime);this.needPlay.length=0}newAnimation(t){const i=new s(this.group[t],this.tweenGroup);i.on("finish",(()=>this.emit("finish",t))),this.animations[t]=i}}n.componentName="Transition";class o extends i.System{constructor(){super(...arguments),this.name="transition"}}o.systemName="transition",exports.Transition=n,exports.TransitionSystem=o;
@@ -1,47 +1,7 @@
1
- import { Easing, Tween, Group } from '@tweenjs/tween.js';
1
+ import { Tween, Easing, Group } from '@tweenjs/tween.js';
2
2
  import { Component, System } from '@eva/eva.js';
3
3
 
4
- /*! *****************************************************************************
5
- Copyright (c) Microsoft Corporation. All rights reserved.
6
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
7
- this file except in compliance with the License. You may obtain a copy of the
8
- License at http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
12
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
13
- MERCHANTABLITY OR NON-INFRINGEMENT.
14
-
15
- See the Apache Version 2.0 License for specific language governing permissions
16
- and limitations under the License.
17
- ***************************************************************************** */
18
- /* global Reflect, Promise */
19
-
20
- var extendStatics = function(d, b) {
21
- extendStatics = Object.setPrototypeOf ||
22
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24
- return extendStatics(d, b);
25
- };
26
-
27
- function __extends(d, b) {
28
- extendStatics(d, b);
29
- function __() { this.constructor = d; }
30
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31
- }
32
-
33
- function __values(o) {
34
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
35
- if (m) return m.call(o);
36
- return {
37
- next: function () {
38
- if (o && i >= o.length) o = void 0;
39
- return { value: o && o[i++], done: !o };
40
- }
41
- };
42
- }
43
-
44
- var easingMap = {
4
+ const easingMap = {
45
5
  linear: Easing.Linear.None,
46
6
  'ease-in': Easing.Quadratic.In,
47
7
  'ease-out': Easing.Quadratic.Out,
@@ -49,10 +9,10 @@ var easingMap = {
49
9
  'bounce-in': Easing.Bounce.In,
50
10
  'bounce-out': Easing.Bounce.Out,
51
11
  'bounce-in-out': Easing.Bounce.InOut,
52
- none: function (p) { return ~~p; },
12
+ none: p => ~~p,
53
13
  };
54
- var Animation = (function () {
55
- function Animation(timelines, tweenGroup) {
14
+ class Animation {
15
+ constructor(timelines, tweenGroup) {
56
16
  this.tweens = [];
57
17
  this.timelines = [];
58
18
  this.finishCount = 0;
@@ -62,19 +22,19 @@ var Animation = (function () {
62
22
  this.timelines = timelines;
63
23
  this.tweenGroup = tweenGroup;
64
24
  }
65
- Animation.prototype.on = function (eventName, callback) {
25
+ on(eventName, callback) {
66
26
  if (!this.callbacks[eventName]) {
67
27
  this.callbacks.set(eventName, []);
68
28
  }
69
29
  this.callbacks.get(eventName).push(callback);
70
- };
71
- Animation.prototype.emit = function (eventName) {
72
- var callbacks = this.callbacks.get(eventName);
30
+ }
31
+ emit(eventName) {
32
+ const callbacks = this.callbacks.get(eventName);
73
33
  if (!callbacks || !callbacks.length)
74
34
  return;
75
- callbacks.forEach(function (fn) { return fn(); });
76
- };
77
- Animation.prototype.checkFinish = function () {
35
+ callbacks.forEach(fn => fn());
36
+ }
37
+ checkFinish() {
78
38
  if (++this.finishCount == this.tweens.length) {
79
39
  if (++this.currIteration == this.iteration) {
80
40
  this.emit('finish');
@@ -85,119 +45,108 @@ var Animation = (function () {
85
45
  this.start();
86
46
  }
87
47
  }
88
- };
89
- Animation.prototype.getObjectCache = function (component, name) {
90
- var key = "" + component.gameObject.id + component.name;
48
+ }
49
+ getObjectCache(component, name) {
50
+ const key = `${component.gameObject.id}${component.name}`;
91
51
  if (!this.objectCache[key]) {
92
52
  this.objectCache[key] = {};
93
53
  }
94
54
  if (this.objectCache[key][name]) {
95
55
  return this.objectCache[key][name];
96
56
  }
97
- var keys = name.split('.');
98
- var keyIndex = keys.length - 1;
99
- var property = component;
100
- for (var i = 0; i < keyIndex; i++) {
57
+ const keys = name.split('.');
58
+ const keyIndex = keys.length - 1;
59
+ let property = component;
60
+ for (let i = 0; i < keyIndex; i++) {
101
61
  property = property[keys[i]];
102
62
  }
103
- this.objectCache[key][name] = { property: property, key: keys[keyIndex] };
63
+ this.objectCache[key][name] = { property, key: keys[keyIndex] };
104
64
  return this.objectCache[key][name];
105
- };
106
- Animation.prototype.doAnim = function (_a) {
107
- var component = _a.component, name = _a.name, value = _a.value;
108
- var _b = this.getObjectCache(component, name), property = _b.property, key = _b.key;
65
+ }
66
+ doAnim({ component, name, value }) {
67
+ const { property, key } = this.getObjectCache(component, name);
109
68
  property[key] = value;
110
- };
111
- Animation.prototype.init = function () {
112
- var _this = this;
69
+ }
70
+ init() {
113
71
  this.checkFinishFunc = this.checkFinish.bind(this);
114
- var lastTween;
115
- this.timelines.forEach(function (timeline, i) {
116
- for (var j = 0; j < timeline.values.length - 1; j++) {
117
- var frame = timeline.values[j];
118
- var nextFrame = timeline.values[j + 1];
119
- var tween = new Tween({ value: frame.value }, _this.tweenGroup)
72
+ let lastTween;
73
+ this.timelines.forEach((timeline, i) => {
74
+ for (let j = 0; j < timeline.values.length - 1; j++) {
75
+ const frame = timeline.values[j];
76
+ const nextFrame = timeline.values[j + 1];
77
+ const tween = new Tween({ value: frame.value }, this.tweenGroup)
120
78
  .to({ value: nextFrame.value })
121
79
  .duration(nextFrame.time - frame.time)
122
80
  .easing(easingMap[frame.tween])
123
- .onUpdate(function (props) {
124
- _this.doAnim({
81
+ .onUpdate(props => {
82
+ this.doAnim({
125
83
  component: timeline.component,
126
84
  name: timeline.name,
127
85
  value: props.value,
128
86
  });
129
87
  });
130
88
  if (j === 0) {
131
- _this.tweens[i] = tween;
89
+ this.tweens[i] = tween;
132
90
  }
133
91
  else {
134
92
  lastTween.chain(tween);
135
93
  }
136
94
  lastTween = tween;
137
95
  }
138
- lastTween && lastTween.onComplete(function () { return _this.checkFinishFunc(); });
96
+ lastTween && lastTween.onComplete(() => this.checkFinishFunc());
139
97
  });
140
- };
141
- Animation.prototype.play = function (iteration, currentTime) {
142
- if (iteration === void 0) { iteration = 1; }
98
+ }
99
+ play(iteration = 1, currentTime) {
143
100
  this.currentTime = currentTime;
144
101
  this.stoped = false;
145
102
  this.start();
146
103
  this.currIteration = 0;
147
104
  this.iteration = iteration;
148
- };
149
- Animation.prototype.start = function () {
150
- var _this = this;
105
+ }
106
+ start() {
151
107
  this.finishCount = 0;
152
108
  this.tweens.length = 0;
153
109
  this.init();
154
- this.tweens.forEach(function (tween) { return tween.start(_this.currentTime); });
155
- };
156
- Animation.prototype.pause = function () {
157
- var _this = this;
158
- this.tweens.forEach(function (tween) { return tween.pause(_this.currentTime); });
159
- };
160
- Animation.prototype.resume = function () {
161
- var _this = this;
162
- this.tweens.forEach(function (tween) { return tween.resume(_this.currentTime); });
163
- };
164
- Animation.prototype.stop = function () {
110
+ this.tweens.forEach((tween) => tween.start(this.currentTime));
111
+ }
112
+ pause() {
113
+ this.tweens.forEach((tween) => tween.pause(this.currentTime));
114
+ }
115
+ resume() {
116
+ this.tweens.forEach((tween) => tween.resume(this.currentTime));
117
+ }
118
+ stop() {
165
119
  this.stoped = true;
166
- this.tweens.forEach(function (tween) { return tween.stop(); });
167
- };
168
- Animation.prototype.destroy = function () {
120
+ this.tweens.forEach((tween) => tween.stop());
121
+ }
122
+ destroy() {
169
123
  this.stop();
170
124
  this.tweens = null;
171
125
  this.timelines = null;
172
126
  this.objectCache = null;
173
127
  this.callbacks.clear();
174
128
  this.callbacks = null;
175
- };
176
- return Animation;
177
- }());
178
- var Animation$1 = Animation;
129
+ }
130
+ }
179
131
 
180
- var Transition = (function (_super) {
181
- __extends(Transition, _super);
182
- function Transition() {
183
- var _this = _super !== null && _super.apply(this, arguments) || this;
184
- _this.animations = {};
185
- _this.group = {};
186
- _this.currentTime = 0;
187
- _this.needPlay = [];
188
- return _this;
132
+ class Transition extends Component {
133
+ constructor() {
134
+ super(...arguments);
135
+ this.animations = {};
136
+ this.group = {};
137
+ this.currentTime = 0;
138
+ this.needPlay = [];
189
139
  }
190
- Transition.prototype.init = function (_a) {
191
- var group = (_a === void 0 ? { group: {} } : _a).group;
140
+ init({ group } = { group: {} }) {
192
141
  this.group = group;
193
142
  this.tweenGroup = new Group();
194
- };
195
- Transition.prototype.awake = function () {
196
- for (var name_1 in this.group) {
197
- this.newAnimation(name_1);
143
+ }
144
+ awake() {
145
+ for (const name in this.group) {
146
+ this.newAnimation(name);
198
147
  }
199
- };
200
- Transition.prototype.play = function (name, iteration) {
148
+ }
149
+ play(name, iteration) {
201
150
  if (!name) {
202
151
  name = Object.keys(this.group)[0];
203
152
  }
@@ -205,35 +154,35 @@ var Transition = (function (_super) {
205
154
  this.newAnimation(name);
206
155
  }
207
156
  if (name && this.animations[name]) {
208
- this.needPlay.push({ name: name, iteration: iteration });
157
+ this.needPlay.push({ name, iteration });
209
158
  }
210
- };
211
- Transition.prototype.stop = function (name) {
159
+ }
160
+ stop(name) {
212
161
  var _a, _b;
213
162
  if (!name) {
214
- for (var key in this.animations) {
163
+ for (const key in this.animations) {
215
164
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.stop();
216
165
  }
217
166
  }
218
167
  else {
219
168
  (_b = this.animations[name]) === null || _b === void 0 ? void 0 : _b.stop();
220
169
  }
221
- };
222
- Transition.prototype.onPause = function () {
170
+ }
171
+ onPause() {
223
172
  var _a;
224
- for (var key in this.animations) {
173
+ for (const key in this.animations) {
225
174
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.pause();
226
175
  }
227
- };
228
- Transition.prototype.onResume = function () {
176
+ }
177
+ onResume() {
229
178
  var _a;
230
- for (var key in this.animations) {
179
+ for (const key in this.animations) {
231
180
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.resume();
232
181
  }
233
- };
234
- Transition.prototype.onDestroy = function () {
182
+ }
183
+ onDestroy() {
235
184
  var _a;
236
- for (var key in this.animations) {
185
+ for (const key in this.animations) {
237
186
  (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.destroy();
238
187
  }
239
188
  this.tweenGroup.removeAll();
@@ -241,51 +190,33 @@ var Transition = (function (_super) {
241
190
  this.group = null;
242
191
  this.animations = null;
243
192
  this.removeAllListeners();
244
- };
245
- Transition.prototype.update = function (e) {
246
- var e_1, _a;
247
- var _b;
193
+ }
194
+ update(e) {
195
+ var _a;
248
196
  this.currentTime = e.time;
249
- for (var key in this.animations) {
197
+ for (const key in this.animations) {
250
198
  this.animations[key].currentTime = e.time;
251
199
  }
252
200
  this.tweenGroup.update(e.time);
253
- try {
254
- for (var _c = __values(this.needPlay), _d = _c.next(); !_d.done; _d = _c.next()) {
255
- var play = _d.value;
256
- (_b = this.animations[play.name]) === null || _b === void 0 ? void 0 : _b.play(play.iteration, this.currentTime);
257
- }
258
- }
259
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
260
- finally {
261
- try {
262
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
263
- }
264
- finally { if (e_1) throw e_1.error; }
201
+ for (const play of this.needPlay) {
202
+ (_a = this.animations[play.name]) === null || _a === void 0 ? void 0 : _a.play(play.iteration, this.currentTime);
265
203
  }
266
204
  this.needPlay.length = 0;
267
- };
268
- Transition.prototype.newAnimation = function (name) {
269
- var _this = this;
270
- var animation = new Animation$1(this.group[name], this.tweenGroup);
271
- animation.on('finish', function () { return _this.emit('finish', name); });
205
+ }
206
+ newAnimation(name) {
207
+ const animation = new Animation(this.group[name], this.tweenGroup);
208
+ animation.on('finish', () => this.emit('finish', name));
272
209
  this.animations[name] = animation;
273
- };
274
- Transition.componentName = 'Transition';
275
- return Transition;
276
- }(Component));
277
- var Transition$1 = Transition;
210
+ }
211
+ }
212
+ Transition.componentName = 'Transition';
278
213
 
279
- var TransitionSystem = (function (_super) {
280
- __extends(TransitionSystem, _super);
281
- function TransitionSystem() {
282
- var _this = _super !== null && _super.apply(this, arguments) || this;
283
- _this.name = 'transition';
284
- return _this;
214
+ class TransitionSystem extends System {
215
+ constructor() {
216
+ super(...arguments);
217
+ this.name = 'transition';
285
218
  }
286
- TransitionSystem.systemName = 'transition';
287
- return TransitionSystem;
288
- }(System));
289
- var TransitionSystem$1 = TransitionSystem;
219
+ }
220
+ TransitionSystem.systemName = 'transition';
290
221
 
291
- export { Transition$1 as Transition, TransitionSystem$1 as TransitionSystem };
222
+ export { Transition, TransitionSystem };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-transition",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "@eva/plugin-transition",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-transition.esm.js",
@@ -18,7 +18,7 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/eva.js": "2.0.0-beta.1",
21
+ "@eva/eva.js": "2.0.0-beta.2",
22
22
  "@tweenjs/tween.js": "^18.6.4",
23
23
  "sprite-timeline": "^1.10.2"
24
24
  }