Files
esengine/extensions/demo/demo_egret/libs/ecs-tween/ecs-tween.min.js

1 line
23 KiB
JavaScript
Raw Normal View History

2021-01-01 18:29:10 +08:00
window.es={},window.__extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();var __generator=this&&this.__generator||function(e,t){var n,r,i,a,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}};!function(e){var t=function(){function t(){}return t.prototype.recycleSelf=function(){},t.prototype.isRunning=function(){return this._isCurrentlyManagedByTweenManager&&!this._isPaused},t.prototype.start=function(){this._isCurrentlyManagedByTweenManager?this._isPaused=!1:(e.TweenManager.addTween(this),this._isCurrentlyManagedByTweenManager=!0,this._isPaused=!1)},t.prototype.pause=function(){this._isPaused=!0},t.prototype.resume=function(){this._isPaused=!1},t.prototype.stop=function(t){void 0===t&&(t=!1),e.TweenManager.removeTween(this),this._isCurrentlyManagedByTweenManager=!1,this._isPaused=!0},t}();e.AbstractTweenable=t}(es||(es={})),function(e){var t=function(){function e(e,t){this._target=e,this._propertyName=t}return e.prototype.getTargetObject=function(){return this._target},e.prototype.setTweenedValue=function(e){this._target[this._propertyName]=e},e.prototype.getTweenedValue=function(){return this._target[this._propertyName]},e}(),n=function(){function n(){}return n.NumberPropertyTo=function(n,r,i,a){var s=new t(n,r),o=e.TweenManager.cacheNumberTweens?e.Pool.obtain(e.NumberTween):new e.NumberTween;return o.initialize(s,i,a),o},n.Vector2PropertyTo=function(n,r,i,a){var s=new t(n,r),o=e.TweenManager.cacheVector2Tweens?e.Pool.obtain(e.Vector2Tween):new e.Vector2Tween;return o.initialize(s,i,a),o},n}();e.PropertyTweens=n}(es||(es={})),function(e){var t=function(t){function n(e,n,r){var i=t.call(this)||this;return i.dampingRatio=.23,i.angularFrequency=25,i._transform=e,i._targetType=n,i.setTargetValue(r),i}return __extends(n,t),Object.defineProperty(n.prototype,"targetType",{get:function(){return this._targetType},enumerable:!0,configurable:!0}),n.prototype.setTargetValue=function(t){this._velocity=e.Vector2.zero,this._targetValue=t,this._isCurrentlyManagedByTweenManager||this.start()},n.prototype.updateDampingRatioWithHalfLife=function(e){this.dampingRatio=-e/this.angularFrequency*Math.log(.5)},n.prototype.tick=function(){return this._isPaused||this.setTweenedValue(e.Lerps.fastSpring(this.getCurrentValueOfTweenedTargetType(),this._targetValue,this._velocity,this.dampingRatio,this.angularFrequency)),!1},n.prototype.setTweenedValue=function(t){switch(this._targetType){case e.TransformTargetType.position:this._transform.position=t;break;case e.TransformTargetType.localPosition:this._transform.localPosition=t;break;case e.TransformTargetType.scale:this._transform.scale=t;break;case e.TransformTargetType.localScale:this._transform.localScale=t;break;case e.TransformTargetType.rotationDegrees:this._transform.rotationDegrees=t.x;case e.TransformTargetType.localRotationDegrees:this._transform.localRo