phaser3-rex-plugins
Version:
2 lines (1 loc) • 9.49 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexspiralcurveplugin=e();}(undefined,(function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(s=i.key,r=void 0,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(s,"string"))?r:String(r)),i);}var s,r;}function i(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e);}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function a(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function o(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}();return function(){var n,i=r(t);if(e){var s=r(this).constructor;n=Reflect.construct(i,arguments,s);}else n=i.apply(this,arguments);return a(this,n)}}var d=Phaser.Curves.Curve,h=Phaser.Utils.Objects.GetValue,c=Phaser.Math.DegToRad,f=Phaser.Math.RadToDeg,l=Phaser.Math.Vector2,y=Phaser.Tweens.Builders.GetEaseFunction,R=Phaser.Math.Linear,p=function(n){s(u,n);var r=o(u);function u(n,i,s,a,o,d,f){var R,p,_,g,v,X,Y,k,b,A,P,x,w,m;if(e(this,u),"object"===t(n)){var O=n;O.hasOwnProperty("x")?_=p=O.x:(p=h(O,"startX",0),_=h(O,"endX",p)),g=h(O,"easeX","Linear"),O.hasOwnProperty("y")?X=v=O.y:(v=h(O,"startY",0),X=h(O,"endY",v)),Y=h(O,"easeY","Linear"),O.hasOwnProperty("startRadius")?(P=k=O.startRadius,x=b=h(O,"endRadius",k)):(O.hasOwnProperty("xRadius")?b=k=O.xRadius:(k=h(O,"startXRadius",0),b=h(O,"endXRadius",k)),O.hasOwnProperty("yRadius")?x=P=O.yRadius:(P=h(O,"startYRadius",k),x=h(O,"endYRadius",b))),A=h(O,"easeXRadius","Linear"),w=h(O,"easeXRadius",A),o=h(O,"startAngle",0),d=h(O,"endAngle",360),m=h(O,"easeAngle","Linear"),f=h(O,"rotation",0);}else void 0===n&&(n=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===d&&(d=360),void 0===f&&(f=0),p=n,_=n,g="Linear",v=i,X=i,Y="Linear",k=s,b=a,A="Linear",P=s,x=a,w="Linear",m="Linear";return (R=r.call(this,"SpiralCurve")).p0=new l(p,v),R.p1=new l(_,X),R._easeX=g,R._easeXFunction=y(g),R._easeY=Y,R._easeYFunction=y(Y),R._startXRadius=k,R._endXRadius=b,R._easeXRadius=A,R._easeXRadiusFunction=y(A),R._startYRadius=P,R._endYRadius=x,R._easeYRadius=w,R._easeYRadiusFunction=y(w),R._startAngle=c(o),R._endAngle=c(d),R._easeAngle=m,R._easeAngleFunction=y(m),R._rotation=c(f),R}return i(u,[{key:"getResolution",value:function(t){return 2*t}},{key:"getStartPoint",value:function(t){return this.getPoint(0,t)}},{key:"getPoint",value:function(t,e){void 0===e&&(e=new l);var n=R(this.p0.x,this.p1.x,this._easeXFunction(t)),i=R(this.p0.y,this.p1.y,this._easeYFunction(t)),s=R(this._startAngle,this._endAngle,this._easeAngleFunction(t)),r=R(this._startXRadius,this._endXRadius,this._easeXRadiusFunction(t)),u=R(this._startYRadius,this._endYRadius,this._easeYRadiusFunction(t)),a=n+r*Math.cos(s),o=i+u*Math.sin(s);if(0!==this._rotation){var d=Math.cos(this._rotation),h=Math.sin(this._rotation),c=a-n,f=o-i;a=c*d-f*h+n,o=c*h+f*d+i;}return e.set(a,o)}},{key:"x",get:function(){return this.p0.x},set:function(t){var e=t-this.p0.x;this.p0.x+=e,this.p1.x+=e;}},{key:"y",get:function(){return this.p0.y},set:function(t){var e=t-this.p0.y;this.p0.y+=e,this.p1.y+=e;}},{key:"setStartX",value:function(t){return this.startX=t,this}},{key:"startX",get:function(){return this.p0.x},set:function(t){this.p0.x=t;}},{key:"setEndX",value:function(t){return this.endX=t,this}},{key:"endX",get:function(){return this.p1.x},set:function(t){this.p1.x=t;}},{key:"setEaseX",value:function(t){return this.easeX=t,this}},{key:"easeX",get:function(){return this._easeX},set:function(t){this._easeX=t,this._easeXFunction=y(t);}},{key:"setStartY",value:function(t){return this.startY=t,this}},{key:"startY",get:function(){return this.p0.y},set:function(t){this.p0.y=t;}},{key:"setEndY",value:function(t){return this.endY=t,this}},{key:"endY",get:function(){return this.p1.y},set:function(t){this.p1.y=t;}},{key:"setEaseY",value:function(t){return this.easeY=t,this}},{key:"easeY",get:function(){return this._easeY},set:function(t){this._easeY=t,this._easeYFunction=y(t);}},{key:"setXRadius",value:function(t){return this.xRadius=t,this}},{key:"xRadius",get:function(){return Math.max(this._startXRadius,this._endXRadius)},set:function(t){this._startXRadius=t,this._endXRadius=t;}},{key:"setStartXRadius",value:function(t){return this.startXRadius=t,this}},{key:"startXRadius",get:function(){return this._startXRadius},set:function(t){this._startXRadius=t;}},{key:"setEndXRadius",value:function(t){return this.endXRadius=t,this}},{key:"endXRadius",get:function(){return this._endXRadius},set:function(t){this._endXRadius=t;}},{key:"setEaseXRadius",value:function(t){return this.easeXRadius=t,this}},{key:"easeXRadius",get:function(){return this._easeXRadius},set:function(t){this._easeXRadius=t,this._easeXRadiusFunction=y(t);}},{key:"setYRadius",value:function(t){return this.startYRadius=t,this.endYRadius=t,this}},{key:"yRadius",get:function(){return Math.max(this._startYRadius,this._endYRadius)},set:function(t){this._startYRadius=t,this._endYRadius=t;}},{key:"setStartYRadius",value:function(t){return this.startYRadius=t,this}},{key:"startYRadius",get:function(){return this._startYRadius},set:function(t){this._startYRadius=t;}},{key:"setEndYRadius",value:function(t){return this.endYRadius=t,this}},{key:"endYRadius",get:function(){return this._endYRadius},set:function(t){this._endYRadius=t;}},{key:"setEaseYRadius",value:function(t){return this.easeYRadius=t,this}},{key:"easeYRadius",get:function(){return this._easeYRadius},set:function(t){this._easeYRadius=t,this._easeYRadiusFunction=y(t);}},{key:"setWidth",value:function(t){var e=this.xRadius/t;return this._startXRadius*=e,this._endXRadius*=e,this}},{key:"setHeight",value:function(t){var e=this.yRadius/t;return this._startYRadius*=e,this._endYRadius*=e,this}},{key:"setStartAngle",value:function(t){return this.startAngle=t,this}},{key:"startAngle",get:function(){return f(this._startAngle)},set:function(t){this._startAngle=c(t);}},{key:"setEndAngle",value:function(t){return this.endAngle=t,this}},{key:"endAngle",get:function(){return f(this._endAngle)},set:function(t){this._endAngle=c(t);}},{key:"setEaseAngle",value:function(t){return this.easeAngle=t,this}},{key:"easeAngle",get:function(){return this._easeAngle},set:function(t){this._easeAngle=t,this._easeAngleFunction=y(t);}},{key:"setRotation",value:function(t){return this.rotation=t,this}},{key:"angle",get:function(){return f(this._rotation)},set:function(t){this._rotation=c(t);}},{key:"rotation",get:function(){return this._rotation},set:function(t){this._rotation=t;}},{key:"toJSON",value:function(){return {type:this.type,startX:this.p0.x,startY:this.p0.y,endX:this.p1.x,endY:this.p1.y,startXRadius:this._startXRadius,endXRadius:this._endXRadius,easeXRadius:this._easeXRadius,startYRadius:this._startYRadius,endYRadius:this._endYRadius,easeYRadius:this._easeYRadius,startAngle:f(this._startAngle),endAngle:f(this._endAngle),easeAngle:this._easeAngle,rotation:f(this._rotation)}}}],[{key:"fromJSON",value:function(t){return new u(t)}}]),u}(d),_=function(t){return null==t||""===t||0===t.length},g=function(t){s(r,Phaser.Plugins.BasePlugin);var n=o(r);function r(t){return e(this,r),n.call(this,t)}return i(r,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}},{key:"add",value:function(t,e,n,i,s,r,u){return new p(t,e,n,i,s,r,u)}}]),r}();return function(e,n,i,s){if(void 0===s&&(s="."),"object"===t(e)){if(_(n)){if(null==i)return;"object"===t(i)&&(e=i);}else {"string"==typeof n&&(n=n.split(s));var r=n.pop(),u=function(e,n,i){var s=e;if(_(n));else {var r;"string"==typeof n&&(n=n.split("."));for(var u=0,a=n.length;u<a;u++){var o;null!=s[r=n[u]]&&"object"===t(s[r])||(o=u===a-1?void 0===i?{}:i:{},s[r]=o),s=s[r];}}return s}(e,n);u[r]=i;}}}(window,"RexPlugins.Curve.SpiralCurve",p),g}));