UNPKG

@petkoneo/phaser3-rex-plugins

Version:
2 lines (1 loc) 6.23 kB
var t,s;t=void 0,s=function(){const t=Phaser.Curves.Curve,s=Phaser.Utils.Objects.GetValue,e=Phaser.Math.DegToRad,i=Phaser.Math.RadToDeg,a=Phaser.Math.Vector2,n=Phaser.Tweens.Builders.GetEaseFunction,r=Phaser.Math.Linear;class u extends t{constructor(t,i,r,u,h,d,o){var R,_,g,l,X,Y,p,y,c,A,v,x,f;if("object"==typeof t){var P=t;P.hasOwnProperty("x")?_=R=P.x:(R=s(P,"startX",0),_=s(P,"endX",R)),g=s(P,"easeX","Linear"),P.hasOwnProperty("y")?X=l=P.y:(l=s(P,"startY",0),X=s(P,"endY",l)),Y=s(P,"easeY","Linear"),P.hasOwnProperty("startRadius")?(A=p=P.startRadius,v=y=s(P,"endRadius",p)):(P.hasOwnProperty("xRadius")?y=p=P.xRadius:(p=s(P,"startXRadius",0),y=s(P,"endXRadius",p)),P.hasOwnProperty("yRadius")?v=A=P.yRadius:(A=s(P,"startYRadius",p),v=s(P,"endYRadius",y))),c=s(P,"easeXRadius","Linear"),x=s(P,"easeXRadius",c),h=s(P,"startAngle",0),d=s(P,"endAngle",360),f=s(P,"easeAngle","Linear"),o=s(P,"rotation",0)}else void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===u&&(u=0),void 0===h&&(h=0),void 0===d&&(d=360),void 0===o&&(o=0),R=t,_=t,g="Linear",l=i,X=i,Y="Linear",p=r,y=u,c="Linear",A=r,v=u,x="Linear",f="Linear";super("SpiralCurve"),this.p0=new a(R,l),this.p1=new a(_,X),this._easeX=g,this._easeXFunction=n(g),this._easeY=Y,this._easeYFunction=n(Y),this._startXRadius=p,this._endXRadius=y,this._easeXRadius=c,this._easeXRadiusFunction=n(c),this._startYRadius=A,this._endYRadius=v,this._easeYRadius=x,this._easeYRadiusFunction=n(x),this._startAngle=e(h),this._endAngle=e(d),this._easeAngle=f,this._easeAngleFunction=n(f),this._rotation=e(o)}getResolution(t){return 2*t}getStartPoint(t){return this.getPoint(0,t)}getPoint(t,s){void 0===s&&(s=new a);var e=r(this.p0.x,this.p1.x,this._easeXFunction(t)),i=r(this.p0.y,this.p1.y,this._easeYFunction(t)),n=r(this._startAngle,this._endAngle,this._easeAngleFunction(t)),u=r(this._startXRadius,this._endXRadius,this._easeXRadiusFunction(t)),h=r(this._startYRadius,this._endYRadius,this._easeYRadiusFunction(t)),d=e+u*Math.cos(n),o=i+h*Math.sin(n);if(0!==this._rotation){var R=Math.cos(this._rotation),_=Math.sin(this._rotation),g=d-e,l=o-i;d=g*R-l*_+e,o=g*_+l*R+i}return s.set(d,o)}get x(){return this.p0.x}set x(t){var s=t-this.p0.x;this.p0.x+=s,this.p1.x+=s}get y(){return this.p0.y}set y(t){var s=t-this.p0.y;this.p0.y+=s,this.p1.y+=s}setStartX(t){return this.startX=t,this}get startX(){return this.p0.x}set startX(t){this.p0.x=t}setEndX(t){return this.endX=t,this}get endX(){return this.p1.x}set endX(t){this.p1.x=t}setEaseX(t){return this.easeX=t,this}get easeX(){return this._easeX}set easeX(t){this._easeX=t,this._easeXFunction=n(t)}get y(){return this.p0.y}set y(t){var s=t-this.p0.y;this.p0.y+=s,this.p1.y+=s}setStartY(t){return this.startY=t,this}get startY(){return this.p0.y}set startY(t){this.p0.y=t}setEndY(t){return this.endY=t,this}get endY(){return this.p1.y}set endY(t){this.p1.y=t}setEaseY(t){return this.easeY=t,this}get easeY(){return this._easeY}set easeY(t){this._easeY=t,this._easeYFunction=n(t)}setXRadius(t){return this.xRadius=t,this}get xRadius(){return Math.max(this._startXRadius,this._endXRadius)}set xRadius(t){this._startXRadius=t,this._endXRadius=t}setStartXRadius(t){return this.startXRadius=t,this}get startXRadius(){return this._startXRadius}set startXRadius(t){this._startXRadius=t}setEndXRadius(t){return this.endXRadius=t,this}get endXRadius(){return this._endXRadius}set endXRadius(t){this._endXRadius=t}setEaseXRadius(t){return this.easeXRadius=t,this}get easeXRadius(){return this._easeXRadius}set easeXRadius(t){this._easeXRadius=t,this._easeXRadiusFunction=n(t)}setYRadius(t){return this.startYRadius=t,this.endYRadius=t,this}get yRadius(){return Math.max(this._startYRadius,this._endYRadius)}set yRadius(t){this._startYRadius=t,this._endYRadius=t}setStartYRadius(t){return this.startYRadius=t,this}get startYRadius(){return this._startYRadius}set startYRadius(t){this._startYRadius=t}setEndYRadius(t){return this.endYRadius=t,this}get endYRadius(){return this._endYRadius}set endYRadius(t){this._endYRadius=t}setEaseYRadius(t){return this.easeYRadius=t,this}get easeYRadius(){return this._easeYRadius}set easeYRadius(t){this._easeYRadius=t,this._easeYRadiusFunction=n(t)}setWidth(t){var s=this.xRadius/t;return this._startXRadius*=s,this._endXRadius*=s,this}setHeight(t){var s=this.yRadius/t;return this._startYRadius*=s,this._endYRadius*=s,this}setStartAngle(t){return this.startAngle=t,this}get startAngle(){return i(this._startAngle)}set startAngle(t){this._startAngle=e(t)}setEndAngle(t){return this.endAngle=t,this}get endAngle(){return i(this._endAngle)}set endAngle(t){this._endAngle=e(t)}setEaseAngle(t){return this.easeAngle=t,this}get easeAngle(){return this._easeAngle}set easeAngle(t){this._easeAngle=t,this._easeAngleFunction=n(t)}setRotation(t){return this.rotation=t,this}get angle(){return i(this._rotation)}set angle(t){this._rotation=e(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}toJSON(){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:i(this._startAngle),endAngle:i(this._endAngle),easeAngle:this._easeAngle,rotation:i(this._rotation)}}static fromJSON(t){return new u(t)}}var h=function(t){return null==t||""===t||0===t.length};class d extends Phaser.Plugins.BasePlugin{constructor(t){super(t)}start(){this.game.events.on("destroy",this.destroy,this)}add(t,s,e,i,a,n,r){return new u(t,s,e,i,a,n,r)}}return function(t,s,e,i){if(void 0===i&&(i="."),"object"==typeof t)if(h(s)){if(null==e)return;"object"==typeof e&&(t=e)}else{"string"==typeof s&&(s=s.split(i));var a=s.pop(),n=function(t,s,e){var i=t;if(h(s));else{var a;"string"==typeof s&&(s=s.split("."));for(var n=0,r=s.length;n<r;n++){var u;null!=i[a=s[n]]&&"object"==typeof i[a]||(u=n===r-1?void 0===e?{}:e:{},i[a]=u),i=i[a]}}return i}(t,s);n[a]=e}}(window,"RexPlugins.Curve.SpiralCurve",u),d},"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(t="undefined"!=typeof globalThis?globalThis:t||self).rexspiralcurveplugin=s();