(function(t,e,i){function n(i,r){var s=e[i];if(!s){var o=t[i];if(!o)return;var a={};s=e[i]={exports:a},o[0]((function(t){return n(o[1][t]||t)}),s,a)}return s.exports}for(var r=0;r=0;i--)e.push(cc.v2(t[i].x,t[i].y));return e}function s(t){for(var e=[],i=0;i=this._duration},_cloneDecoration:function(t){t._repeatForever=this._repeatForever,t._speed=this._speed,t._timesForRepeat=this._timesForRepeat,t._easeList=this._easeList,t._speedMethod=this._speedMethod,t._repeatMethod=this._repeatMethod},_reverseEaseList:function(t){if(this._easeList){t._easeList=[];for(var e=0;e1.192092896e-7?this._duration:1.192092896e-7);e=1>e?e:1,this.update(e>0?e:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},startWithTarget:function(t){cc.Action.prototype.startWithTarget.call(this,t),this._elapsed=0,this._firstTick=!0},reverse:function(){return cc.logID(1010),null},setAmplitudeRate:function(t){cc.logID(1011)},getAmplitudeRate:function(){return cc.logID(1012),0},speed:function(t){return t<=0?(cc.logID(1013),this):(this._speedMethod=!0,this._speed*=t,this)},getSpeed:function(){return this._speed},setSpeed:function(t){return this._speed=t,this},repeat:function(t){return t=Math.round(t),isNaN(t)||t<1?(cc.logID(1014),this):(this._repeatMethod=!0,this._timesForRepeat*=t,this)},repeatForever:function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this}}),cc.actionInterval=function(t){return new cc.ActionInterval(t)},cc.Sequence=cc.Class({name:"cc.Sequence",extends:cc.ActionInterval,ctor:function(t){this._actions=[],this._split=null,this._last=0,this._reversed=!1;var e=t instanceof Array?t:arguments;if(1!==e.length){var i=e.length-1;if(i>=0&&null==e[i]&&cc.logID(1015),i>=0){for(var n,r=e[0],s=1;s1?e%1:e),this._last=n)},reverse:function(){var t=cc.Sequence._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t._reversed=!0,t}}),cc.sequence=function(t){var e=t instanceof Array?t:arguments;if(1===e.length)return cc.errorID(1019),null;var i=e.length-1;i>=0&&null==e[i]&&cc.logID(1015);var n=null;if(i>=0){n=e[0];for(var r=1;r<=i;r++)e[r]&&(n=cc.Sequence._actionOneTwo(n,e[r]))}return n},cc.Sequence._actionOneTwo=function(t,e){var i=new cc.Sequence;return i.initWithTwoActions(t,e),i},cc.Repeat=cc.Class({name:"cc.Repeat",extends:cc.ActionInterval,ctor:function(t,e){this._times=0,this._total=0,this._nextDt=0,this._actionInstant=!1,this._innerAction=null,void 0!==e&&this.initWithAction(t,e)},initWithAction:function(t,e){var i=t._duration*e;return!!this.initWithDuration(i)&&(this._times=e,this._innerAction=t,t instanceof cc.ActionInstant&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},clone:function(){var t=new cc.Repeat;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone(),this._times),t},startWithTarget:function(t){this._total=0,this._nextDt=this._innerAction._duration/this._duration,cc.ActionInterval.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},stop:function(){this._innerAction.stop(),cc.Action.prototype.stop.call(this)},update:function(t){t=this._computeEaseTime(t);var e=this._innerAction,i=this._duration,n=this._times,r=this._nextDt;if(t>=r){for(;t>r&&this._total1?1:r;t>=1&&this._total=0&&null==e[i]&&cc.logID(1015),i>=0){for(var n,r=e[0],s=1;sr?this._two=cc.Sequence._actionOneTwo(e,cc.delayTime(n-r)):n0&&null==e[e.length-1]&&cc.logID(1015);for(var i=e[0],n=1;n180&&(i-=360),i<-180&&(i+=360),this._startAngleX=e,this._diffAngleX=i,this._startAngleY=t.rotationY%360;var n=this._dstAngleY-this._startAngleY;n>180&&(n-=360),n<-180&&(n+=360),this._diffAngleY=n},reverse:function(){cc.logID(1016)},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.rotationX=this._startAngleX+this._diffAngleX*t,this.target.rotationY=this._startAngleY+this._diffAngleY*t)}}),cc.rotateTo=function(t,e,i){return new cc.RotateTo(t,e,i)},cc.RotateBy=cc.Class({name:"cc.RotateBy",extends:cc.ActionInterval,ctor:function(t,e,i){this._angleX=0,this._startAngleX=0,this._angleY=0,this._startAngleY=0,void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._angleX=e||0,this._angleY=void 0!==i?i:this._angleX,!0)},clone:function(){var t=new cc.RotateBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._angleX,this._angleY),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._startAngleX=t.rotationX,this._startAngleY=t.rotationY},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.rotationX=this._startAngleX+this._angleX*t,this.target.rotationY=this._startAngleY+this._angleY*t)},reverse:function(){var t=new cc.RotateBy(this._duration,-this._angleX,-this._angleY);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.rotateBy=function(t,e,i){return new cc.RotateBy(t,e,i)},cc.MoveBy=cc.Class({name:"cc.MoveBy",extends:cc.ActionInterval,ctor:function(t,e,i){this._positionDelta=cc.v2(0,0),this._startPosition=cc.v2(0,0),this._previousPosition=cc.v2(0,0),void 0!==e&&cc.MoveBy.prototype.initWithDuration.call(this,t,e,i)},initWithDuration:function(t,e,i){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(void 0!==e.x&&(i=e.y,e=e.x),this._positionDelta.x=e,this._positionDelta.y=i,!0)},clone:function(){var t=new cc.MoveBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._positionDelta),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.x,i=t.y;this._previousPosition.x=e,this._previousPosition.y=i,this._startPosition.x=e,this._startPosition.y=i},update:function(t){if(t=this._computeEaseTime(t),this.target){var e=this._positionDelta.x*t,i=this._positionDelta.y*t,n=this._startPosition;if(cc.macro.ENABLE_STACKABLE_ACTIONS){var r=this.target.x,s=this.target.y,o=this._previousPosition;n.x=n.x+r-o.x,n.y=n.y+s-o.y,e+=n.x,i+=n.y,o.x=e,o.y=i,this.target.setPosition(e,i)}else this.target.setPosition(n.x+e,n.y+i)}},reverse:function(){var t=new cc.MoveBy(this._duration,cc.v2(-this._positionDelta.x,-this._positionDelta.y));return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.moveBy=function(t,e,i){return new cc.MoveBy(t,e,i)},cc.MoveTo=cc.Class({name:"cc.MoveTo",extends:cc.MoveBy,ctor:function(t,e,i){this._endPosition=cc.v2(0,0),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.MoveBy.prototype.initWithDuration.call(this,t,e,i)&&(void 0!==e.x&&(i=e.y,e=e.x),this._endPosition.x=e,this._endPosition.y=i,!0)},clone:function(){var t=new cc.MoveTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endPosition),t},startWithTarget:function(t){cc.MoveBy.prototype.startWithTarget.call(this,t),this._positionDelta.x=this._endPosition.x-t.x,this._positionDelta.y=this._endPosition.y-t.y}}),cc.moveTo=function(t,e,i){return new cc.MoveTo(t,e,i)},cc.SkewTo=cc.Class({name:"cc.SkewTo",extends:cc.ActionInterval,ctor:function(t,e,i){this._skewX=0,this._skewY=0,this._startSkewX=0,this._startSkewY=0,this._endSkewX=0,this._endSkewY=0,this._deltaX=0,this._deltaY=0,void 0!==i&&cc.SkewTo.prototype.initWithDuration.call(this,t,e,i)},initWithDuration:function(t,e,i){var n=!1;return cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._endSkewX=e,this._endSkewY=i,n=!0),n},clone:function(){var t=new cc.SkewTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endSkewX,this._endSkewY),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._startSkewX=t.skewX%180,this._deltaX=this._endSkewX-this._startSkewX,this._deltaX>180&&(this._deltaX-=360),this._deltaX<-180&&(this._deltaX+=360),this._startSkewY=t.skewY%360,this._deltaY=this._endSkewY-this._startSkewY,this._deltaY>180&&(this._deltaY-=360),this._deltaY<-180&&(this._deltaY+=360)},update:function(t){t=this._computeEaseTime(t),this.target.skewX=this._startSkewX+this._deltaX*t,this.target.skewY=this._startSkewY+this._deltaY*t}}),cc.skewTo=function(t,e,i){return new cc.SkewTo(t,e,i)},cc.SkewBy=cc.Class({name:"cc.SkewBy",extends:cc.SkewTo,ctor:function(t,e,i){void 0!==i&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){var n=!1;return cc.SkewTo.prototype.initWithDuration.call(this,t,e,i)&&(this._skewX=e,this._skewY=i,n=!0),n},clone:function(){var t=new cc.SkewBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._skewX,this._skewY),t},startWithTarget:function(t){cc.SkewTo.prototype.startWithTarget.call(this,t),this._deltaX=this._skewX,this._deltaY=this._skewY,this._endSkewX=this._startSkewX+this._deltaX,this._endSkewY=this._startSkewY+this._deltaY},reverse:function(){var t=new cc.SkewBy(this._duration,-this._skewX,-this._skewY);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.skewBy=function(t,e,i){return new cc.SkewBy(t,e,i)},cc.JumpBy=cc.Class({name:"cc.JumpBy",extends:cc.ActionInterval,ctor:function(t,e,i,n,r){this._startPosition=cc.v2(0,0),this._previousPosition=cc.v2(0,0),this._delta=cc.v2(0,0),this._height=0,this._jumps=0,void 0!==n&&cc.JumpBy.prototype.initWithDuration.call(this,t,e,i,n,r)},initWithDuration:function(t,e,i,n,r){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(void 0===r&&(r=n,n=i,i=e.y,e=e.x),this._delta.x=e,this._delta.y=i,this._height=n,this._jumps=r,!0)},clone:function(){var t=new cc.JumpBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._delta,this._height,this._jumps),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.x,i=t.y;this._previousPosition.x=e,this._previousPosition.y=i,this._startPosition.x=e,this._startPosition.y=i},update:function(t){if(t=this._computeEaseTime(t),this.target){var e=t*this._jumps%1,i=4*this._height*e*(1-e);i+=this._delta.y*t;var n=this._delta.x*t,r=this._startPosition;if(cc.macro.ENABLE_STACKABLE_ACTIONS){var s=this.target.x,o=this.target.y,a=this._previousPosition;r.x=r.x+s-a.x,r.y=r.y+o-a.y,n+=r.x,i+=r.y,a.x=n,a.y=i,this.target.setPosition(n,i)}else this.target.setPosition(r.x+n,r.y+i)}},reverse:function(){var t=new cc.JumpBy(this._duration,cc.v2(-this._delta.x,-this._delta.y),this._height,this._jumps);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.jumpBy=function(t,e,i,n,r){return new cc.JumpBy(t,e,i,n,r)},cc.JumpTo=cc.Class({name:"cc.JumpTo",extends:cc.JumpBy,ctor:function(t,e,i,n,r){this._endPosition=cc.v2(0,0),void 0!==n&&this.initWithDuration(t,e,i,n,r)},initWithDuration:function(t,e,i,n,r){return!!cc.JumpBy.prototype.initWithDuration.call(this,t,e,i,n,r)&&(void 0===r&&(i=e.y,e=e.x),this._endPosition.x=e,this._endPosition.y=i,!0)},startWithTarget:function(t){cc.JumpBy.prototype.startWithTarget.call(this,t),this._delta.x=this._endPosition.x-this._startPosition.x,this._delta.y=this._endPosition.y-this._startPosition.y},clone:function(){var t=new cc.JumpTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endPosition,this._height,this._jumps),t}}),cc.jumpTo=function(t,e,i,n,r){return new cc.JumpTo(t,e,i,n,r)},cc.BezierBy=cc.Class({name:"cc.BezierBy",extends:cc.ActionInterval,ctor:function(t,e){this._config=[],this._startPosition=cc.v2(0,0),this._previousPosition=cc.v2(0,0),e&&cc.BezierBy.prototype.initWithDuration.call(this,t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._config=e,!0)},clone:function(){var t=new cc.BezierBy;this._cloneDecoration(t);for(var e=[],i=0;ie/2?255:0}},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._originalState=t.opacity},stop:function(){this.target.opacity=this._originalState,cc.ActionInterval.prototype.stop.call(this)},reverse:function(){var t=new cc.Blink(this._duration,this._times);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.blink=function(t,e){return new cc.Blink(t,e)},cc.FadeTo=cc.Class({name:"cc.FadeTo",extends:cc.ActionInterval,ctor:function(t,e){this._toOpacity=0,this._fromOpacity=0,void 0!==e&&cc.FadeTo.prototype.initWithDuration.call(this,t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._toOpacity=e,!0)},clone:function(){var t=new cc.FadeTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t},update:function(t){t=this._computeEaseTime(t);var e=void 0!==this._fromOpacity?this._fromOpacity:255;this.target.opacity=e+(this._toOpacity-e)*t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._fromOpacity=t.opacity}}),cc.fadeTo=function(t,e){return new cc.FadeTo(t,e)},cc.FadeIn=cc.Class({name:"cc.FadeIn",extends:cc.FadeTo,ctor:function(t){null==t&&(t=0),this._reverseAction=null,this.initWithDuration(t,255)},reverse:function(){var t=new cc.FadeOut;return t.initWithDuration(this._duration,0),this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.FadeIn;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t},startWithTarget:function(t){this._reverseAction&&(this._toOpacity=this._reverseAction._fromOpacity),cc.FadeTo.prototype.startWithTarget.call(this,t)}}),cc.fadeIn=function(t){return new cc.FadeIn(t)},cc.FadeOut=cc.Class({name:"cc.FadeOut",extends:cc.FadeTo,ctor:function(t){null==t&&(t=0),this._reverseAction=null,this.initWithDuration(t,0)},reverse:function(){var t=new cc.FadeIn;return t._reverseAction=this,t.initWithDuration(this._duration,255),this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.FadeOut;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t}}),cc.fadeOut=function(t){return new cc.FadeOut(t)},cc.TintTo=cc.Class({name:"cc.TintTo",extends:cc.ActionInterval,ctor:function(t,e,i,n){this._to=cc.color(0,0,0),this._from=cc.color(0,0,0),e instanceof cc.Color&&(n=e.b,i=e.g,e=e.r),void 0!==n&&this.initWithDuration(t,e,i,n)},initWithDuration:function(t,e,i,n){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._to=cc.color(e,i,n),!0)},clone:function(){var t=new cc.TintTo;this._cloneDecoration(t);var e=this._to;return t.initWithDuration(this._duration,e.r,e.g,e.b),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._from=this.target.color},update:function(t){t=this._computeEaseTime(t);var e=this._from,i=this._to;e&&(this.target.color=cc.color(e.r+(i.r-e.r)*t,e.g+(i.g-e.g)*t,e.b+(i.b-e.b)*t))}}),cc.tintTo=function(t,e,i,n){return new cc.TintTo(t,e,i,n)},cc.TintBy=cc.Class({name:"cc.TintBy",extends:cc.ActionInterval,ctor:function(t,e,i,n){this._deltaR=0,this._deltaG=0,this._deltaB=0,this._fromR=0,this._fromG=0,this._fromB=0,void 0!==n&&this.initWithDuration(t,e,i,n)},initWithDuration:function(t,e,i,n){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._deltaR=e,this._deltaG=i,this._deltaB=n,!0)},clone:function(){var t=new cc.TintBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._deltaR,this._deltaG,this._deltaB),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.color;this._fromR=e.r,this._fromG=e.g,this._fromB=e.b},update:function(t){t=this._computeEaseTime(t),this.target.color=cc.color(this._fromR+this._deltaR*t,this._fromG+this._deltaG*t,this._fromB+this._deltaB*t)},reverse:function(){var t=new cc.TintBy(this._duration,-this._deltaR,-this._deltaG,-this._deltaB);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.tintBy=function(t,e,i,n){return new cc.TintBy(t,e,i,n)},cc.DelayTime=cc.Class({name:"cc.DelayTime",extends:cc.ActionInterval,update:function(t){},reverse:function(){var t=new cc.DelayTime(this._duration);return this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.DelayTime;return this._cloneDecoration(t),t.initWithDuration(this._duration),t}}),cc.delayTime=function(t){return new cc.DelayTime(t)},cc.ReverseTime=cc.Class({name:"cc.ReverseTime",extends:cc.ActionInterval,ctor:function(t){this._other=null,t&&this.initWithAction(t)},initWithAction:function(t){return t?t===this._other?(cc.errorID(1029),!1):!!cc.ActionInterval.prototype.initWithDuration.call(this,t._duration)&&(this._other=t,!0):(cc.errorID(1028),!1)},clone:function(){var t=new cc.ReverseTime;return this._cloneDecoration(t),t.initWithAction(this._other.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._other.startWithTarget(t)},update:function(t){t=this._computeEaseTime(t),this._other&&this._other.update(1-t)},reverse:function(){return this._other.clone()},stop:function(){this._other.stop(),cc.Action.prototype.stop.call(this)}}),cc.reverseTime=function(t){return new cc.ReverseTime(t)},cc.TargetedAction=cc.Class({name:"cc.TargetedAction",extends:cc.ActionInterval,ctor:function(t,e){this._action=null,this._forcedTarget=null,e&&this.initWithTarget(t,e)},initWithTarget:function(t,e){return!!this.initWithDuration(e._duration)&&(this._forcedTarget=t,this._action=e,!0)},clone:function(){var t=new cc.TargetedAction;return this._cloneDecoration(t),t.initWithTarget(this._forcedTarget,this._action.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._action.startWithTarget(this._forcedTarget)},stop:function(){this._action.stop()},update:function(t){t=this._computeEaseTime(t),this._action.update(t)},getForcedTarget:function(){return this._forcedTarget},setForcedTarget:function(t){this._forcedTarget!==t&&(this._forcedTarget=t)}}),cc.targetedAction=function(t,e){return new cc.TargetedAction(t,e)}}),{}],6:[(function(t,e,i){t("../core/platform/CCClass");var n=t("../core/platform/js");cc.ActionManager=function(){this._hashTargets=n.createMap(!0),this._arrayTargets=[],this._currentTarget=null,cc.director._scheduler&&cc.director._scheduler.enableForTarget(this)},cc.ActionManager.prototype={constructor:cc.ActionManager,_elementPool:[],_searchElementByTarget:function(t,e){for(var i=0;i=n&&i.actionIndex--;break}}else cc.logID(1001)}},removeActionByTag:function(t,e){t===cc.Action.TAG_INVALID&&cc.logID(1002),cc.assertID(e,1003);var i=this._hashTargets[e._id];if(i)for(var n=i.actions.length,r=0;r=t&&e.actionIndex--,0===e.actions.length&&this._deleteHashElement(e)},_deleteHashElement:function(t){var e=!1;if(t&&!t.lock&&this._hashTargets[t.target._id]){delete this._hashTargets[t.target._id];for(var i=this._arrayTargets,n=0,r=i.length;n0?e:null})(n);for(var d=0,p=h.length;d1e-6){T=!1;break}return f._findFrameIndex=T?o:u,f}function f(t,e){var i=e.props,r=e.comps;if(i)for(var s in i){var o=_(t,s,i[s]);n.push(o)}if(r)for(var a in r){var h=t.getComponent(a);if(h){var l=r[a];for(var s in l){o=_(h,s,l[s]);n.push(o)}}}}n.length=0,e.duration=i.duration,e.speed=i.speed,e.wrapMode=i.wrapMode,e.frameRate=i.sample,(e.wrapMode&c.Loop)===c.Loop?e.repeatCount=1/0:e.repeatCount=1;var m=i.curveData,d=m.paths;for(var p in f(t,m),d){var y=cc.find(p,t);if(y)f(y,d[p])}var v=i.events;if(v)for(var g,x=0,A=v.length;x=0?b=g.events[T]:(b=new l,g.ratios.push(S),g.events.push(b)),b.add(C.func,C.params)}}f.playState=function(t,e){t.clip&&(t.curveLoaded||m(this.target,t),t.animator=this,t.play(),"number"==typeof e&&t.setTime(e),this.play())},f.stopStatesExcept=function(t){var e=this._anims,i=e.array;for(e.i=0;e.i=0?(this._anims.fastRemoveAt(e),0===this._anims.array.length&&this.stop()):cc.errorID(3908),t.animator=null},f.sample=function(){var t=this._anims,e=t.array;for(t.i=0;t.i=s)o=n[s-1];else{var l=n[h-1],c="number"==typeof l,u=l&&l.lerp;if(c||u){var _=r[h-1],f=r[h],m=this.types[h-1],d=(e-_)/(f-_);m&&(d=a(d,m));var p=n[h];c?o=l+(p-l)*d:u&&(o=l.lerp(p,d))}else o=l}else o=n[h];var y=this.subProps;if(y){for(var v=this.target[this.prop],g=v,x=0;x0?((c&s.PingPong)===s.PingPong?h*=-1:m=n,f++):1===h&&m===n-1&&lu)break}m+=h,cc.director.getAnimationManager().pushDelayEvent(this,"_fireEvent",[m])}while(m!==l&&m>-1&&m=this.events.length||this._ignoreIndex===t)){var e=this.events[t].events;if(this.target.isValid)for(var i=this.target._components,n=0;nr)return i;var s=(e=(e-n)/(r-n))/(1/i),o=0|s;return s-o<1e-6?o:~(o+1)}}}),{"../core/utils/binary-search":228,"./bezier":13,"./types":18}],11:[(function(t,e,i){var n=cc.js,r=cc.Class({ctor:function(){this._anims=new n.array.MutableForwardIterator([]),this._delayEvents=[],cc.director._scheduler&&cc.director._scheduler.enableForTarget(this)},update:function(t){var e=this._anims,i=e.array;for(e.i=0;e.i=0?this._anims.fastRemoveAt(e):cc.errorID(3907)},pushDelayEvent:function(t,e,i){this._delayEvents.push({target:t,func:e,args:i})}});cc.AnimationManager=e.exports=r}),{}],12:[(function(t,e,i){var n=cc.js,r=t("./playable"),s=t("./types"),o=s.WrappedInfo,a=s.WrapMode,h=s.WrapModeMask;function l(t,e){r.call(this),this._currentFramePlayed=!1,this._delay=0,this._delayTime=0,this._wrappedInfo=new o,this._lastWrappedInfo=null,this._process=u,this._clip=t,this._name=e||t&&t.name,this.animator=null,this.curves=[],this.delay=0,this.repeatCount=1,this.duration=1,this.speed=1,this.wrapMode=a.Normal,this.time=0,this._target=null,this._lastframeEventOn=!1,this.emit=function(){for(var t=new Array(arguments.length),e=0,i=t.length;e1&&(0|e.iterations)>(0|t.iterations)&&this.emit("lastframe",this),t.set(e));e.stopped&&(this.stop(),this.emit("finished",this))}function _(){var t=this.time,e=this.duration;t>e?0===(t%=e)&&(t=e):t<0&&0!==(t%=e)&&(t+=e);for(var i=t/e,n=this.curves,r=0,s=n.length;r0&&this._lastIterations>i||this.time<0&&this._lastIterations0&&(this._delayTime-=t,this._delayTime>0)||(this._currentFramePlayed?this.time+=t*this.speed:this._currentFramePlayed=!0,this._process())},c._needRevers=function(t){var e=this.wrapMode,i=!1;(e&h.PingPong)===h.PingPong&&(t-(0|t)==0&&t>0&&(t-=1),1&t&&(i=!i));return(e&h.Reverse)===h.Reverse&&(i=!i),i},c.getWrappedInfo=function(t,e){e=e||new o;var i=!1,n=this.duration,r=this.repeatCount,s=t>0?t/n:-t/n;if(s>=r){s=r,i=!0;var a=r-(0|r);0===a&&(a=1),t=a*n*(t>0?1:-1)}if(t>n){var l=t%n;t=0===l?n:l}else t<0&&0!==(t%=n)&&(t+=n);var c=!1,u=this._wrapMode&h.ShouldWrap;u&&(c=this._needRevers(s));var _=c?-1:1;return this.speed<0&&(_*=-1),u&&c&&(t=n-t),e.ratio=t/n,e.time=t,e.direction=_,e.stopped=i,e.iterations=s,e},c.sample=function(){for(var t=this.getWrappedInfo(this.time,this._wrappedInfo),e=this.curves,i=0,n=e.length;i0}),(function(){this.curves.length=0})),n.getset(c,"wrapMode",(function(){return this._wrapMode}),(function(t){this._wrapMode=t,this.time=0,t&h.Loop?this.repeatCount=1/0:this.repeatCount=1})),n.getset(c,"repeatCount",(function(){return this._repeatCount}),(function(t){this._repeatCount=t;var e=this._wrapMode&h.ShouldWrap,i=(this.wrapMode&h.Reverse)===h.Reverse;this._process=t!==1/0||e||i?u:_})),n.getset(c,"delay",(function(){return this._delay}),(function(t){this._delayTime=this._delay=t})),cc.AnimationState=e.exports=l}),{"./playable":17,"./types":18}],13:[(function(t,e,i){function n(t,e,i,n,r){var s=1-r;return t*s*s*s+3*e*s*s*r+3*i*s*r*r+n*r*r*r}var r=Math.cos,s=Math.acos,o=Math.max,a=2*Math.PI,h=Math.sqrt;function l(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}function c(t,e){var i=(function(t,e){var i,n,c,u,_=e-0,f=e-t[0],m=3*_,d=3*f,p=3*(e-t[2]),y=1/(-_+d-p+(e-1)),v=(m-6*f+p)*y,g=v*(1/3),x=(-m+d)*y,A=1/3*(3*x-v*v),b=A*(1/3),C=(2*v*v*v-9*v*x+_*y*27)/27,S=C/2,T=S*S+b*b*b;if(T<0){var w=1/3*-A,E=h(w*w*w),D=-C/(2*E),B=s(D<-1?-1:D>1?1:D),M=2*l(E);return n=M*r(B*(1/3))-g,c=M*r((B+a)*(1/3))-g,u=M*r((B+2*a)*(1/3))-g,0<=n&&n<=1?0<=c&&c<=1?0<=u&&u<=1?o(n,c,u):o(n,c):0<=u&&u<=1?o(n,u):n:0<=c&&c<=1?0<=u&&u<=1?o(c,u):c:u}if(0===T)return c=-(i=S<0?l(-S):-l(S))-g,0<=(n=2*i-g)&&n<=1?0<=c&&c<=1?o(n,c):n:c;var P=h(T);return n=(i=l(-S+P))-l(S+P)-g})(t,e),n=1-i;return 0*n*n*n+3*t[1]*i*n*n+3*t[3]*i*i*n+1*i*i*i}e.exports={bezier:n,bezierByTime:c}}),{}],14:[(function(t,e,i){var n={constant:function(){return 0},linear:function(t){return t},quadIn:function(t){return t*t},quadOut:function(t){return t*(2-t)},quadInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quartIn:function(t){return t*t*t*t},quartOut:function(t){return 1- --t*t*t*t},quartInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quintIn:function(t){return t*t*t*t*t},quintOut:function(t){return--t*t*t*t*t+1},quintInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sineIn:function(t){return 1-Math.cos(t*Math.PI/2)},sineOut:function(t){return Math.sin(t*Math.PI/2)},sineInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},expoIn:function(t){return 0===t?0:Math.pow(1024,t-1)},expoOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},expoInOut: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)))},circIn:function(t){return 1-Math.sqrt(1-t*t)},circOut:function(t){return Math.sqrt(1- --t*t)},circInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),-i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))},elasticOut:function(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)},elasticInOut:function(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut: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)},bounceOut: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},smooth:function(t){return t<=0?0:t>=1?1:t*t*(3-2*t)},fade:function(t){return t<=0?0:t>=1?1:t*t*t*(t*(6*t-15)+10)}};function r(t,e){return function(i){return i<.5?e(2*i)/2:t(2*i-1)/2+.5}}n.quadOutIn=r(n.quadIn,n.quadOut),n.cubicOutIn=r(n.cubicIn,n.cubicOut),n.quartOutIn=r(n.quartIn,n.quartOut),n.quintOutIn=r(n.quintIn,n.quintOut),n.sineOutIn=r(n.sineIn,n.sineOut),n.expoOutIn=r(n.expoIn,n.expoOut),n.circOutIn=r(n.circIn,n.circOut),n.backOutIn=r(n.backIn,n.backOut),n.backOutIn=r(n.backIn,n.backOut),n.bounceIn=function(t){return 1-n.bounceOut(1-t)},n.bounceInOut=function(t){return t<.5?.5*n.bounceIn(2*t):.5*n.bounceOut(2*t-1)+.5},n.bounceOutIn=r(n.bounceIn,n.bounceOut),cc.Easing=e.exports=n}),{}],15:[(function(t,e,i){t("./bezier"),t("./easing"),t("./types"),t("./motion-path-helper"),t("./animation-curves"),t("./animation-clip"),t("./animation-manager"),t("./animation-state"),t("./animation-animator")}),{"./animation-animator":8,"./animation-clip":9,"./animation-curves":10,"./animation-manager":11,"./animation-state":12,"./bezier":13,"./easing":14,"./motion-path-helper":16,"./types":18}],16:[(function(t,e,i){var n=t("./animation-curves").DynamicAnimCurve,r=t("./animation-curves").computeRatioByType,s=t("./bezier").bezier,o=t("../core/utils/binary-search").binarySearchEpsilon,a=cc.v2;function h(t){this.points=t||[],this.beziers=[],this.ratios=[],this.progresses=[],this.length=0,this.computeBeziers()}function l(){this.start=a(),this.end=a(),this.startCtrlPoint=a(),this.endCtrlPoint=a()}function c(t,e,i,s){function l(t){return t instanceof cc.Vec2?{in:t,pos:t,out:t}:Array.isArray(t)&&6===t.length?{in:a(t[2],t[3]),pos:a(t[0],t[1]),out:a(t[4],t[5])}:{in:cc.Vec2.ZERO,pos:cc.Vec2.ZERO,out:cc.Vec2.ZERO}}var c=e.values;if(0!==t.length&&0!==c.length)if(1!==(c=c.map((function(t){return a(t[0],t[1])}))).length){for(var u=e.types,_=e.ratios,f=e.values=[],m=e.types=[],d=e.ratios=[],p=0,y=n.Linear,v=0,g=t.length;v0){var M=[];M.push(l(S));for(var P=0,I=A.length;P1e-6;){var F,V,N,k;if((x=r(x=D,w))<0)k=(0-x)*(V=L.beziers[0]).getLength(),N=V.start.sub(V.endCtrlPoint).normalize(),F=V.start.add(N.mul(k));else if(x>1)k=(x-1)*(V=L.beziers[L.beziers.length-1]).getLength(),N=V.end.sub(V.startCtrlPoint).normalize(),F=V.end.add(N.mul(k));else{var G=o(O,x);G<0&&(G=~G),x-=G>0?O[G-1]:0,x/=L.ratios[G],F=L.beziers[G].getPointAt(x)}E.push(F),D+=B}}else for(;1-D>1e-6;)x=r(x=D,w),E.push(S.lerp(T,x)),D+=B;y="constant"===w?w:n.Linear;for(P=0,I=E.length;P1e-6?(D-1)*C:0}_[_.length-1]!==d[d.length-1]&&U(c[c.length-1],y,_[_.length-1])}else e.values=c;function U(t,e,i){f.push(t),m.push(e),d.push(i)}}h.prototype.computeBeziers=function(){var t;this.beziers.length=0,this.ratios.length=0,this.progresses.length=0,this.length=0;for(var e=1;e0)){h=r;break}h=r-1}if(n[r=h]===i)return r/(s-1);var l=n[r];return(r+(i-l)/(n[r+1]-l))/(s-1)},e.exports={sampleMotionPaths:c,Curve:h,Bezier:l}}),{"../core/utils/binary-search":228,"./animation-curves":10,"./bezier":13}],17:[(function(t,e,i){var n=cc.js,r=t("../core/CCDebug");function s(){this._isPlaying=!1,this._isPaused=!1,this._stepOnce=!1}var o=s.prototype;n.get(o,"isPlaying",(function(){return this._isPlaying}),!0),n.get(o,"isPaused",(function(){return this._isPaused}),!0);var a=function(){};o.onPlay=a,o.onPause=a,o.onResume=a,o.onStop=a,o.onError=a,o.play=function(){this._isPlaying?this._isPaused?(this._isPaused=!1,this.onResume()):this.onError(r.getError(3912)):(this._isPlaying=!0,this.onPlay())},o.stop=function(){this._isPlaying&&(this._isPlaying=!1,this.onStop(),this._isPaused=!1)},o.pause=function(){this._isPlaying&&!this._isPaused&&(this._isPaused=!0,this.onPause())},o.resume=function(){this._isPlaying&&this._isPaused&&(this._isPaused=!1,this.onResume())},o.step=function(){this.pause(),this._stepOnce=!0,this._isPlaying||this.play()},e.exports=s}),{"../core/CCDebug":25}],18:[(function(t,e,i){var n={Loop:2,ShouldWrap:4,PingPong:22,Reverse:36},r=cc.Enum({Default:0,Normal:1,Reverse:n.Reverse,Loop:n.Loop,LoopReverse:n.Loop|n.Reverse,PingPong:n.PingPong,PingPongReverse:n.PingPong|n.Reverse});function s(t){t?this.set(t):(this.ratio=0,this.time=0,this.direction=1,this.stopped=!0,this.iterations=0,this.frameIndex=void 0)}cc.WrapMode=r,s.prototype.set=function(t){this.ratio=t.ratio,this.time=t.time,this.direction=t.direction,this.stopped=t.stopped,this.iterations=t.iterations,this.frameIndex=t.frameIndex},e.exports={WrapModeMask:n,WrapMode:r,WrappedInfo:s}}),{}],19:[(function(t,e,i){var n=t("../core/event/event-target"),r=t("../core/platform/CCSys"),s=t("../core/assets/CCAudioClip").LoadMode,o=!1,a=[],h=function(t){n.call(this),this._src=t,this._element=null,this.id=0,this._volume=1,this._loop=!1,this._nextTime=0,this._state=h.State.INITIALZING,this._onended=function(){this.emit("ended")}.bind(this)};cc.js.extend(h,n),h.State={ERROR:-1,INITIALZING:0,PLAYING:1,PAUSED:2,STOPPED:3},(function(t){t._bindEnded=function(t){t=t||this._onended;var e=this._element;this._src&&e instanceof HTMLAudioElement?e.addEventListener("ended",t):e.onended=t},t._unbindEnded=function(){var t=this._element;t instanceof HTMLAudioElement?t.removeEventListener("ended",this._onended):t&&(t.onended=null)},t._onLoaded=function(){var t=this._src._nativeAsset;t instanceof HTMLAudioElement?(this._element||(this._element=document.createElement("audio")),this._element.src=t.src):this._element=new l(t,this),this.setVolume(this._volume),this.setLoop(this._loop),0!==this._nextTime&&this.setCurrentTime(this._nextTime),this._state===h.State.PLAYING?this.play():this._state=h.State.INITIALZING},t.play=function(){this._state=h.State.PLAYING,this._element&&(this._bindEnded(),this._element.play(),this._src&&this._src.loadMode===s.DOM_AUDIO&&this._element.paused&&a.push({instance:this,offset:0,audio:this._element}),o||(o=!0,cc.game.canvas.addEventListener("touchstart",(function(){for(var t=void 0;t=a.pop();)t.audio.play(t.offset)}))))},t.destroy=function(){this._element=null},t.pause=function(){this._element&&this._state===h.State.PLAYING&&(this._unbindEnded(),this._element.pause(),this._state=h.State.PAUSED)},t.resume=function(){this._element&&this._state===h.State.PAUSED&&(this._bindEnded(),this._element.play(),this._state=h.State.PLAYING)},t.stop=function(){if(this._element){this._element.pause();try{this._element.currentTime=0}catch(t){}for(var t=0;tthis._buffer.duration)})),t.__defineGetter__("loop",(function(){return this._loop})),t.__defineSetter__("loop",(function(t){return this._currentSource&&(this._currentSource.loop=t),this._loop=t})),t.__defineGetter__("volume",(function(){return this._volume})),t.__defineSetter__("volume",(function(t){return this._volume=t,this._gainObj.gain.setTargetAtTime?this._gainObj.gain.setTargetAtTime(this._volume,this._context.currentTime,.01):this._volume.gain.value=t,r.os===r.OS_IOS&&!this.paused&&this._currentSource&&(this._currentSource.onended=null,this.pause(),this.play()),t})),t.__defineGetter__("currentTime",(function(){return this.paused?this.playedLength:(this.playedLength=this._context.currentTime-this._startTime,this.playedLength%=this._buffer.duration,this.playedLength)})),t.__defineSetter__("currentTime",(function(t){return this.paused?this.playedLength=t:(this.pause(),this.playedLength=t,this.play()),t})),t.__defineGetter__("duration",(function(){return this._buffer.duration}))})(l.prototype),e.exports=cc.Audio=h}),{"../core/assets/CCAudioClip":33,"../core/event/event-target":99,"../core/platform/CCSys":165}],20:[(function(t,e,i){var n=t("./CCAudio"),r=t("../core/assets/CCAudioClip"),s=cc.js,o=0,a=s.createMap(!0),h={},l=[],c=function(t){var e=o++,i=h[t];if(i||(i=h[t]=[]),_._maxAudioInstance<=i.length){var r=i.shift();u(r).stop()}var s=l.pop()||new n,c=function(){if(u(this.id)){delete a[this.id];var t=i.indexOf(this.id);cc.js.array.fastRemoveAt(i,t)}(function(t){t._finishCallback=null,l.length<32?(t.off("ended"),t.off("stop"),t.src=null,l.push(t)):t.destroy()})(this)};return s.on("ended",(function(){this._finishCallback&&this._finishCallback(),c.call(this)}),s),s.on("stop",c,s),s.id=e,a[e]=s,i.push(e),s},u=function(t){return a[t]},_={AudioState:n.State,_maxWebAudioSize:2097152,_maxAudioInstance:24,_id2audio:a,play:function(t,e,i){var n,s=t;if("string"==typeof t)cc.warnID(8401,"cc.audioEngine","cc.AudioClip","AudioClip","cc.AudioClip","audio"),n=c(s=t),r._loadByUrl(s,(function(t,e){e&&(n.src=e)}));else{if(!t)return;s=t.nativeUrl,(n=c(s)).src=t}return n.setLoop(e||!1),"number"!=typeof i&&(i=1),n.setVolume(i),n.play(),n.id},setLoop:function(t,e){var i=u(t);i&&i.setLoop&&i.setLoop(e)},isLoop:function(t){var e=u(t);return!(!e||!e.getLoop)&&e.getLoop()},setVolume:function(t,e){var i=u(t);i&&i.setVolume(e)},getVolume:function(t){var e=u(t);return e?e.getVolume():1},setCurrentTime:function(t,e){var i=u(t);return!!i&&(i.setCurrentTime(e),!0)},getCurrentTime:function(t){var e=u(t);return e?e.getCurrentTime():0},getDuration:function(t){var e=u(t);return e?e.getDuration():0},getState:function(t){var e=u(t);return e?e.getState():this.AudioState.ERROR},setFinishCallback:function(t,e){var i=u(t);i&&(i._finishCallback=e)},pause:function(t){var e=u(t);return!!e&&(e.pause(),!0)},_pauseIDCache:[],pauseAll:function(){for(var t in a){var e=a[t];e.getState()===n.State.PLAYING&&(this._pauseIDCache.push(t),e.pause())}},resume:function(t){var e=u(t);e&&e.resume()},resumeAll:function(){for(var t=0;t0;){var n=i.pop(),r=a[n];r&&(r.stop(),delete a[n])}},uncacheAll:function(){this.stopAll();var t=void 0;for(var e in a)(t=a[e])&&t.destroy();for(;t=l.pop();)t.destroy();a=s.createMap(!0),h={}},getProfile:function(t){},preload:function(t,e){cc.loader.load(t,e&&function(t){t||e()})},setMaxWebAudioSize:function(t){this._maxWebAudioSize=1024*t},_breakCache:null,_break:function(){for(var t in this._breakCache=[],a){var e=a[t];e.getState()===n.State.PLAYING&&(this._breakCache.push(t),e.pause())}},_restore:function(){if(this._breakCache){for(;this._breakCache.length>0;){var t=this._breakCache.pop(),e=u(t);e&&e.resume&&e.resume()}this._breakCache=null}},_music:{id:-1,loop:!1,volume:1},_effect:{volume:1,pauseCache:[]},playMusic:function(t,e){var i=this._music;return this.stop(i.id),i.id=this.play(t,e,i.volume),i.loop=e,i.id},stopMusic:function(){this.stop(this._music.id)},pauseMusic:function(){return this.pause(this._music.id),this._music.id},resumeMusic:function(){return this.resume(this._music.id),this._music.id},getMusicVolume:function(){return this._music.volume},setMusicVolume:function(t){var e=this._music;return e.volume=t,this.setVolume(e.id,e.volume),e.volume},isMusicPlaying:function(){return this.getState(this._music.id)===this.AudioState.PLAYING},playEffect:function(t,e){return this.play(t,e||!1,this._effect.volume)},setEffectsVolume:function(t){var e=this._music.id;for(var i in this._effect.volume=t,a)i!==e&&_.setVolume(i,t)},getEffectsVolume:function(){return this._effect.volume},pauseEffect:function(t){return this.pause(t)},pauseAllEffects:function(){var t=this._music.id,e=this._effect;for(var i in e.pauseCache.length=0,a)if(i!==t){var n=a[i];n.getState()===this.AudioState.PLAYING&&(e.pauseCache.push(i),n.pause())}},resumeEffect:function(t){this.resume(t)},resumeAllEffects:function(){for(var t=this._effect.pauseCache,e=0;e=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},n.unzipAsArray=function(t,e){e=e||1;var i,n,r,s=this.unzip(t),o=[];for(i=0,r=s.length/e;i=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},cc.codec=e.exports=n}),{"./base64":22,"./gzip":23}],22:[(function(t,e,i){var n=t("../core/utils/misc").BASE64_VALUES,r={name:"Jacob__Codec__Base64",decode:function(t){var e,i,r,s,o,a,h=[],l=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");l>4,i=(15&s)<<4|(o=n[t.charCodeAt(l++)])>>2,r=(3&o)<<6|(a=n[t.charCodeAt(l++)]),h.push(String.fromCharCode(e)),64!==o&&h.push(String.fromCharCode(i)),64!==a&&h.push(String.fromCharCode(r));return h=h.join("")},decodeAsArray:function(t,e){var i,n,r,s=this.decode(t),o=[];for(i=0,r=s.length/e;i=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o}};e.exports=r}),{"../core/utils/misc":234}],23:[(function(t,e,i){var n=function(t){this.data=t,this.debug=!1,this.gpflags=void 0,this.files=0,this.unzipped=[],this.buf32k=new Array(32768),this.bIdx=0,this.modeZIP=!1,this.bytepos=0,this.bb=1,this.bits=0,this.nameBuf=[],this.fileout=void 0,this.literalTree=new Array(n.LITERALS),this.distanceTree=new Array(32),this.treepos=0,this.Places=null,this.len=0,this.fpos=new Array(17),this.fpos[0]=0,this.flens=void 0,this.fmax=void 0};n.gunzip=function(t){return t.constructor===Array||(t.constructor,String),new n(t).gunzip()[0][0]},n.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},n.LITERALS=288,n.NAMEMAX=256,n.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],n.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],n.cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],n.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],n.cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],n.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],n.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},n.prototype.readByte=function(){return this.bits+=8,this.bytepos>=1,0===this.bb&&(this.bb=this.readByte(),t=1&this.bb,this.bb=this.bb>>1|128),t},n.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=n.bitReverse[e]>>8-t),e},n.prototype.flushBuffer=function(){this.bIdx=0},n.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},n.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]===this.len)return this.fpos[this.len]++;this.fpos[this.len]++}},n.prototype.Rec=function(){var t,e=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,(t=this.IsPat())>=0)e.b0=t;else if(e.b0=32768,this.Rec())return-1;if((t=this.IsPat())>=0)e.b1=t,e.jump=null;else if(e.b1=32768,e.jump=this.Places[this.treepos],e.jumppos=this.treepos,this.Rec())return-1;return this.len--,0},n.prototype.CreateTree=function(t,e,i,n){var r;for(this.Places=t,this.treepos=0,this.flens=i,this.fmax=e,r=0;r<17;r++)this.fpos[r]=0;return this.len=0,this.Rec()?-1:0},n.prototype.DecodeValue=function(t){for(var e,i,n=0,r=t[n];;)if(this.readBit()){if(!(32768&r.b1))return r.b1;for(r=r.jump,e=t.length,i=0;i>1)>23?(a=a<<1|this.readBit())>199?a=(a-=128)<<1|this.readBit():(a-=48)>143&&(a+=136):a+=256,a<256)this.addBuffer(a);else{if(256===a)break;for(a-=257,d=this.readBits(n.cplext[a])+n.cplens[a],a=n.bitReverse[this.readBits(5)]>>3,n.cpdext[a]>8?(p=this.readBits(8),p|=this.readBits(n.cpdext[a]-8)<<8):p=this.readBits(n.cpdext[a]),p+=n.cpdist[a],a=0;ah)return this.flushBuffer(),1;for(f=i?_[i-1]:0;a--;)_[i++]=f}else{if(i+(a=17===a?3+this.readBits(3):11+this.readBits(7))>h)return this.flushBuffer(),1;for(;a--;)_[i++]=0}for(d=this.literalTree.length,i=0;i=256){var d,p;if(0===(a-=256))break;for(a--,d=this.readBits(n.cplext[a])+n.cplens[a],a=this.DecodeValue(this.distanceTree),n.cpdext[a]>8?(p=this.readBits(8),p|=this.readBits(n.cpdext[a]-8)<<8):p=this.readBits(n.cpdext[a]),p+=n.cpdist[a];d--;){o=this.buf32k[this.bIdx-p&32767];this.addBuffer(o)}}else this.addBuffer(a)}}while(!t);return this.flushBuffer(),this.byteAlign(),0},n.prototype.unzipFile=function(t){var e;for(this.gunzip(),e=0;e>>0;t=n}for(var r,s=1,o=0,a=t.length,h=0;0>>0}function a(e,i){this.index="number"==typeof i?i:0,this.i=0,this.buffer=e instanceof(s?Uint8Array:Array)?e:new(s?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}a.prototype.f=function(){var t,e=this.buffer,i=e.length,n=new(s?Uint8Array:Array)(i<<1);if(s)n.set(e);else for(t=0;t>>8&255]<<16|f[t>>>16&255]<<8|f[t>>>24&255])>>32-e:f[t]>>8-e),8>e+o)a=a<>e-n-1&1,8==++o&&(o=0,r[s++]=f[a],a=0,s===r.length&&(r=this.f()));r[s]=a,this.buffer=r,this.i=o,this.index=s},a.prototype.finish=function(){var t,e=this.buffer,i=this.index;return 0h;++h){for(var c=_=h,u=7,_=_>>>1;_;_>>>=1)c<<=1,c|=1&_,--u;l[h]=(c<>>0}var f=l;function m(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function d(t){var e,i,n,r,o,a,h,l,c,u=t.length,_=0,f=Number.POSITIVE_INFINITY;for(l=0;l_&&(_=t[l]),t[l]>=1;for(c=a;cs[n]);)r=s[i],s[i]=s[n],s[n]=r,r=s[i+1],s[i+1]=s[n+1],s[n+1]=r,i=n;return this.length},m.prototype.pop=function(){var t,e,i,n,r,s=this.buffer;for(e=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],r=0;!((n=2*r+2)>=this.length)&&(n+2s[n]&&(n+=2),s[n]>s[r]);)i=s[r],s[r]=s[n],s[n]=i,i=s[r+1],s[r+1]=s[n+1],s[n+1]=i,r=n;return{index:t,value:e,length:this.length}};var y,v=2,g={NONE:0,r:1,j:v,N:3},x=[];for(y=0;288>y;y++)switch(i){case 143>=y:x.push([y+48,8]);break;case 255>=y:x.push([y-144+400,9]);break;case 279>=y:x.push([y-256+0,7]);break;case 287>=y:x.push([y-280+192,8]);break;default:t("invalid literal: "+y)}function A(t,e){this.length=t,this.G=e}function b(){var e=C;switch(i){case 3===e:return[257,e-3,0];case 4===e:return[258,e-4,0];case 5===e:return[259,e-5,0];case 6===e:return[260,e-6,0];case 7===e:return[261,e-7,0];case 8===e:return[262,e-8,0];case 9===e:return[263,e-9,0];case 10===e:return[264,e-10,0];case 12>=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}p.prototype.n=function(){var n,r,o,h,l=this.input;switch(this.h){case 0:for(o=0,h=l.length;o>>8&255,y[g++]=255&_,y[g++]=_>>>8&255,s)y.set(f,g),g+=f.length,y=y.subarray(0,g);else{for(d=0,p=f.length;dJ)for(;0J?J:138)>J-3&&Q=Q?(it[K++]=17,it[K++]=Q-3,nt[17]++):(it[K++]=18,it[K++]=Q-11,nt[18]++),J-=Q;else if(it[K++]=et[Y],nt[et[Y]]++,3>--J)for(;0J?J:6)>J-3&&QU;U++)X[U]=N[H[U]];for(R=19;4=C;C++)S=b(),T[C]=S[2]<<24|S[1]<<16|S[0];var w=s?new Uint32Array(T):T;function E(n,r){function o(e,n){var r,s,o,a,h=e.G,l=[],c=0;switch(r=w[e.length],l[c++]=65535&r,l[c++]=r>>16&255,l[c++]=r>>24,i){case 1===h:s=[0,h-1,0];break;case 2===h:s=[1,h-2,0];break;case 3===h:s=[2,h-3,0];break;case 4===h:s=[3,h-4,0];break;case 6>=h:s=[4,h-5,1];break;case 8>=h:s=[5,h-7,1];break;case 12>=h:s=[6,h-9,2];break;case 16>=h:s=[7,h-13,2];break;case 24>=h:s=[8,h-17,3];break;case 32>=h:s=[9,h-25,3];break;case 48>=h:s=[10,h-33,4];break;case 64>=h:s=[11,h-49,4];break;case 96>=h:s=[12,h-65,5];break;case 128>=h:s=[13,h-97,5];break;case 192>=h:s=[14,h-129,6];break;case 256>=h:s=[15,h-193,6];break;case 384>=h:s=[16,h-257,7];break;case 512>=h:s=[17,h-385,7];break;case 768>=h:s=[18,h-513,8];break;case 1024>=h:s=[19,h-769,8];break;case 1536>=h:s=[20,h-1025,9];break;case 2048>=h:s=[21,h-1537,9];break;case 3072>=h:s=[22,h-2049,10];break;case 4096>=h:s=[23,h-3073,10];break;case 6144>=h:s=[24,h-4097,11];break;case 8192>=h:s=[25,h-6145,11];break;case 12288>=h:s=[26,h-8193,12];break;case 16384>=h:s=[27,h-12289,12];break;case 24576>=h:s=[28,h-16385,13];break;case 32768>=h:s=[29,h-24577,13];break;default:t("invalid distance")}for(r=s,l[c++]=r[0],l[c++]=r[1],l[c++]=r[2],o=0,a=l.length;o=l;)x[l++]=0;for(l=0;29>=l;)b[l++]=0}for(x[256]=1,a=0,h=r.length;a=h){for(m&&o(m,-1),l=0,c=h-a;lD&&a+DE&&(T=S,E=D),258===D)break}f=new A(E,a-T),m?m.length2*g[f-1]+x[f]&&(g[f]=2*g[f-1]+x[f]),b[f]=Array(g[f]),C[f]=Array(g[f]);for(_=0;_r[_]?(b[f][d]=p,C[f][d]=v,y+=2):(b[f][d]=r[_],C[f][d]=_,++_);S[f]=0,1===x[f]&&i(f)}for(o=A,a=0,h=n.length;a1<c&&t("undercommitted"),i=0,n=e.length;i>>=1;return a}function M(t,e){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=P.j;var i,n={};for(i in!e&&(e={})||"number"!=typeof e.compressionType||(this.h=e.compressionType),e)n[i]=e[i];n.outputBuffer=this.a,this.z=new p(this.input,n)}var P=g;function I(e,i){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=s?new Uint8Array(e):e,this.s=!1,this.m=L,this.B=!1,!i&&(i={})||(i.index&&(this.c=i.index),i.bufferSize&&(this.l=i.bufferSize),i.bufferType&&(this.m=i.bufferType),i.resize&&(this.B=i.resize)),this.m){case R:this.b=32768,this.a=new(s?Uint8Array:Array)(32768+this.l+258);break;case L:this.b=0,this.a=new(s?Uint8Array:Array)(this.l),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}M.prototype.n=function(){var e,i,n,r,a,h,l,c=0;switch(l=this.a,e=ct){case ct:i=Math.LOG2E*Math.log(32768)-8;break;default:t(Error("invalid compression method"))}switch(n=i<<4|e,l[c++]=n,e){case ct:switch(this.h){case P.NONE:a=0;break;case P.r:a=1;break;case P.j:a=2;break;default:t(Error("unsupported compression type"))}break;default:t(Error("invalid compression method"))}return r=a<<6|0,l[c++]=r|31-(256*n+r)%31,h=o(this.input),this.z.b=c,c=(l=this.z.n()).length,s&&((l=new Uint8Array(l.buffer)).length<=c+4&&(this.a=new Uint8Array(l.length+4),this.a.set(l),l=this.a),l=l.subarray(0,c+4)),l[c++]=h>>24&255,l[c++]=h>>16&255,l[c++]=h>>8&255,l[c++]=255&h,l},r("Zlib.Deflate",M),r("Zlib.Deflate.compress",(function(t,e){return new M(t,e).n()})),r("Zlib.Deflate.CompressionType",P),r("Zlib.Deflate.CompressionType.NONE",P.NONE),r("Zlib.Deflate.CompressionType.FIXED",P.r),r("Zlib.Deflate.CompressionType.DYNAMIC",P.j);var R=0,L=1,O={D:R,C:L};I.prototype.p=function(){for(;!this.s;){var n=tt(this,3);switch(1&n&&(this.s=i),n>>>=1){case 0:var r=this.input,o=this.c,a=this.a,h=this.b,l=e,c=e,u=e,_=a.length,f=e;switch(this.e=this.g=0,(l=r[o++])===e&&t(Error("invalid uncompressed block header: LEN (first byte)")),c=l,(l=r[o++])===e&&t(Error("invalid uncompressed block header: LEN (second byte)")),c|=l<<8,(l=r[o++])===e&&t(Error("invalid uncompressed block header: NLEN (first byte)")),u=l,(l=r[o++])===e&&t(Error("invalid uncompressed block header: NLEN (second byte)")),c===~(u|=l<<8)&&t(Error("invalid uncompressed block header: length verify")),o+c>r.length&&t(Error("input buffer is broken")),this.m){case R:for(;h+c>a.length;){if(c-=f=_-h,s)a.set(r.subarray(o,o+f),h),h+=f,o+=f;else for(;f--;)a[h++]=r[o++];this.b=h,a=this.f(),h=this.b}break;case L:for(;h+c>a.length;)a=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(s)a.set(r.subarray(o,o+c),h),h+=c,o+=c;else for(;c--;)a[h++]=r[o++];this.c=o,this.b=h,this.a=a;break;case 1:this.o(K,$);break;case 2:it(this);break;default:t(Error("unknown BTYPE: "+n))}}return this.t()};var F,V,N=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],k=s?new Uint16Array(N):N,G=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],z=s?new Uint16Array(G):G,U=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],W=s?new Uint8Array(U):U,j=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],H=s?new Uint16Array(j):j,X=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Y=s?new Uint8Array(X):X,q=new(s?Uint8Array:Array)(288);for(F=0,V=q.length;F=F?8:255>=F?9:279>=F?7:8;var J,Z,K=d(q),Q=new(s?Uint8Array:Array)(30);for(J=0,Z=Q.length;J>>n,i.e=o-n,i.c=h,r}function et(i,n){for(var r,s,o,a=i.g,h=i.e,l=i.input,c=i.c,u=n[0],_=n[1];h<_;)(r=l[c++])===e&&t(Error("input buffer is broken")),a|=r<>>16,i.g=a>>o,i.e=h-o,i.c=c,65535&s}function it(t){function e(t,e,i){var n,r,s,o;for(o=0;or)n>=h&&(this.b=n,i=this.f(),n=this.b),i[n++]=r;else for(a=z[s=r-257],0=h&&(this.b=n,i=this.f(),n=this.b);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},I.prototype.I=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,o,a,h=i.length;256!==(r=et(this,t));)if(256>r)n>=h&&(h=(i=this.f()).length),i[n++]=r;else for(a=z[s=r-257],0h&&(h=(i=this.f()).length);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},I.prototype.f=function(){var t,e,i=new(s?Uint8Array:Array)(this.b-32768),n=this.b-32768,r=this.a;if(s)i.set(r.subarray(32768,i.length));else for(t=0,e=i.length;tt;++t)r[t]=r[n+t];return this.b=32768,r},I.prototype.J=function(t){var e,i,n,r=this.input.length/this.c+1|0,o=this.input,a=this.a;return t&&("number"==typeof t.v&&(r=t.v),"number"==typeof t.F&&(r+=t.F)),2>r?i=(n=(o.length-this.c)/this.u[2]/2*258|0)e&&(this.a.length=e),t=this.a),this.buffer=t},nt.prototype.p=function(){var e,i=this.input;return e=this.A.p(),this.c=this.A.c,this.M&&((i[this.c++]<<24|i[this.c++]<<16|i[this.c++]<<8|i[this.c++])>>>0!==o(e)&&t(Error("invalid adler-32 checksum"))),e},r("Zlib.Inflate",nt),r("Zlib.Inflate.BufferType",O),O.ADAPTIVE=O.C,O.BLOCK=O.D,r("Zlib.Inflate.prototype.decompress",nt.prototype.p);s&&new Uint16Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);s&&new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258]);s&&new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0]);s&&new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]);s&&new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]);var rt,st,ot=new(s?Uint8Array:Array)(288);for(rt=0,st=ot.length;rt=rt?8:255>=rt?9:279>=rt?7:8;d(ot);var at,ht,lt=new(s?Uint8Array:Array)(30);for(at=0,ht=lt.length;atc.ERROR?(function(){function e(t){if(cc.game.canvas){if(!r){var e=document.createElement("Div");e.setAttribute("id","logInfoDiv"),e.setAttribute("width","200"),e.setAttribute("height",cc.game.canvas.height);var i=e.style;i.zIndex="99999",i.position="absolute",i.top=i.left="0",(r=document.createElement("textarea")).setAttribute("rows","20"),r.setAttribute("cols","30"),r.setAttribute("disabled","true");var n=r.style;n.backgroundColor="transparent",n.borderBottom="1px solid #cccccc",n.borderTopWidth=n.borderLeftWidth=n.borderRightWidth="0px",n.borderTopStyle=n.borderLeftStyle=n.borderRightStyle="none",n.padding="0px",n.margin=0,e.appendChild(r),cc.game.canvas.parentNode.appendChild(e)}r.value=r.value+t+"\r\n",r.scrollTop=r.scrollHeight}}cc.error=function(){e("ERROR : "+cc.js.formatStr.apply(null,arguments))},cc.assert=function(t,i){"use strict";!t&&i&&e("ASSERT: "+(i=cc.js.formatStr.apply(null,cc.js.shiftArguments.apply(null,arguments))))},t!==c.ERROR_FOR_WEB_PAGE&&(cc.warn=function(){e("WARN : "+cc.js.formatStr.apply(null,arguments))}),t===c.INFO_FOR_WEB_PAGE&&(cc.log=function(){e(cc.js.formatStr.apply(null,arguments))})})():console&&console.log.apply&&(console.error||(console.error=console.log),console.warn||(console.warn=console.log),console.error.bind?cc.error=console.error.bind(console):cc.error=function(){return console.error.apply(console,arguments)},cc.assert=function(t,e){if(!t)throw e&&(e=cc.js.formatStr.apply(null,cc.js.shiftArguments.apply(null,arguments))),new Error(e)}),t!==c.ERROR&&(console.warn.bind?cc.warn=console.warn.bind(console):cc.warn=function(){return console.warn.apply(console,arguments)}),t===c.INFO&&(console.log.bind?cc.log=console.log.bind(console):cc.log=function(){return console.log.apply(console,arguments)}))},getError:s("ERROR"),isDisplayStats:function(){return!!cc.profiler&&cc.profiler.isShowingStats()},setDisplayStats:function(t){cc.profiler&&(t?cc.profiler.showStats():cc.profiler.hideStats(),cc.game.config.showFPS=!!t)}}}),{"../../DebugInfos":void 0}],26:[(function(t,e,i){var n=t("./event/event-target"),r=t("./load-pipeline/auto-release-utils"),s=t("./component-scheduler"),o=t("./node-activator"),a=t("./platform/CCObject"),h=t("./CCGame"),l=t("./renderer"),c=t("./event-manager"),u=t("./CCScheduler");cc.Director=function(){n.call(this),this.invalid=!1,this._paused=!1,this._purgeDirectorInNextLoop=!1,this._winSizeInPoints=null,this._loadingScene="",this._scene=null,this._totalFrames=0,this._lastUpdate=0,this._deltaTime=0,this._scheduler=null,this._compScheduler=null,this._nodeActivator=null,this._actionManager=null;var t=this;h.on(h.EVENT_SHOW,(function(){t._lastUpdate=performance.now()})),h.once(h.EVENT_ENGINE_INITED,this.init,this)},cc.Director.prototype={constructor:cc.Director,init:function(){return this._totalFrames=0,this._lastUpdate=performance.now(),this._paused=!1,this._purgeDirectorInNextLoop=!1,this._winSizeInPoints=cc.size(0,0),this._scheduler=new u,cc.ActionManager?(this._actionManager=new cc.ActionManager,this._scheduler.scheduleUpdate(this._actionManager,u.PRIORITY_SYSTEM,!1)):this._actionManager=null,this.sharedInit(),!0},sharedInit:function(){this._compScheduler=new s,this._nodeActivator=new o,c&&c.setEnabled(!0),cc.AnimationManager?(this._animationManager=new cc.AnimationManager,this._scheduler.scheduleUpdate(this._animationManager,u.PRIORITY_SYSTEM,!1)):this._animationManager=null,cc.CollisionManager?(this._collisionManager=new cc.CollisionManager,this._scheduler.scheduleUpdate(this._collisionManager,u.PRIORITY_SYSTEM,!1)):this._collisionManager=null,cc.PhysicsManager?(this._physicsManager=new cc.PhysicsManager,this._scheduler.scheduleUpdate(this._physicsManager,u.PRIORITY_SYSTEM,!1)):this._physicsManager=null,cc._widgetManager&&cc._widgetManager.init(this),cc.loader.init(this)},calculateDeltaTime:function(){var t=performance.now();this._deltaTime=(t-this._lastUpdate)/1e3,this._lastUpdate=t},convertToGL:function(t){var e=h.container,i=cc.view,n=e.getBoundingClientRect(),r=n.left+window.pageXOffset-e.clientLeft,s=n.top+window.pageYOffset-e.clientTop,o=i._devicePixelRatio*(t.x-r),a=i._devicePixelRatio*(s+n.height-t.y);return i._isRotated?cc.v2(i._viewportRect.width-a,o):cc.v2(o,a)},convertToUI:function(t){var e=h.container,i=cc.view,n=e.getBoundingClientRect(),r=n.left+window.pageXOffset-e.clientLeft,s=n.top+window.pageYOffset-e.clientTop,o=cc.v2(0,0);return i._isRotated?(o.x=r+t.y/i._devicePixelRatio,o.y=s+n.height-(i._viewportRect.width-t.x)/i._devicePixelRatio):(o.x=r+t.x*i._devicePixelRatio,o.y=s+n.height-t.y*i._devicePixelRatio),o},end:function(){this._purgeDirectorInNextLoop=!0},getWinSize:function(){return cc.size(cc.winSize)},getWinSizeInPixels:function(){return cc.size(cc.winSize)},pause:function(){this._paused||(this._paused=!0)},purgeCachedData:function(){cc.loader.releaseAll()},purgeDirector:function(){this._scheduler.unscheduleAll(),this._compScheduler.unscheduleAll(),this._nodeActivator.reset(),c&&c.setEnabled(!1),cc.renderer.clear(),cc.isValid(this._scene)&&this._scene.destroy(),this._scene=null,this.stopAnimation(),cc.loader.releaseAll()},reset:function(){this.purgeDirector(),c&&c.setEnabled(!0),this._actionManager&&this._scheduler.scheduleUpdate(this._actionManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._animationManager&&this._scheduler.scheduleUpdate(this._animationManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._collisionManager&&this._scheduler.scheduleUpdate(this._collisionManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._physicsManager&&this._scheduler.scheduleUpdate(this._physicsManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this.startAnimation()},runSceneImmediate:function(t,e,i){cc.assertID(t instanceof cc.Scene,1216),t._load();for(var n=Object.keys(h._persistRootNodes).map((function(t){return h._persistRootNodes[t]})),s=0;s0){var i=this;cc.loader.load(e,(function(e){if(e)throw new Error(JSON.stringify(e));i._prepareFinished(t)}))}else this._prepareFinished(t)}},run:function(t,e){this._initConfig(t),this.onStart=e,this.prepare(h.onStart&&h.onStart.bind(h))},addPersistRootNode:function(t){if(cc.Node.isNode(t)&&t.uuid){var e=t.uuid;if(!this._persistRootNodes[e]){var i=cc.director._scene;if(cc.isValid(i))if(t.parent){if(!(t.parent instanceof cc.Scene))return void cc.warnID(3801);if(t.parent!==i)return void cc.warnID(3802)}else t.parent=i;this._persistRootNodes[e]=t,t._persistNode=!0}}else cc.warnID(3800)},removePersistRootNode:function(t){var e=t.uuid||"";t===this._persistRootNodes[e]&&(delete this._persistRootNodes[e],t._persistNode=!1)},isPersistRootNode:function(t){return t._persistNode},_setAnimFrame:function(){this._lastTime=new Date;var t=h.config.frameRate;this._frameTime=1e3/t,60!==t&&30!==t?(window.requestAnimFrame=this._stTime,window.cancelAnimFrame=this._ctTime):(window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||this._stTime,window.cancelAnimFrame=window.cancelAnimationFrame||window.cancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.oCancelAnimationFrame||this._ctTime)},_stTime:function(t){var e=(new Date).getTime(),i=Math.max(0,h._frameTime-(e-h._lastTime)),n=window.setTimeout((function(){t()}),i);return h._lastTime=e+i,n},_ctTime:function(t){window.clearTimeout(t)},_runMainLoop:function(){var t,e=this,i=e.config,n=cc.director,s=!0,o=i.frameRate;r.setDisplayStats(i.showFPS),t=function(){if(!e._paused){if(e._intervalId=window.requestAnimFrame(t),30===o&&(s=!s))return;n.mainLoop()}},e._intervalId=window.requestAnimFrame(t),e._paused=!1},_initConfig:function(t){"number"!=typeof t.debugMode&&(t.debugMode=0),t.exposeClassName=!!t.exposeClassName,"number"!=typeof t.frameRate&&(t.frameRate=60);var e=t.renderMode;("number"!=typeof e||e>2||e<0)&&(t.renderMode=0),"boolean"!=typeof t.registerSystemEvent&&(t.registerSystemEvent=!0),t.showFPS=!!t.showFPS,this._sceneInfos=t.scenes||[],this.collisionMatrix=t.collisionMatrix||[],this.groupList=t.groupList||[],r._resetDebugSetting(t.debugMode),this.config=t,this._configLoaded=!0},_determineRenderType:function(){var t=this.config,e=parseInt(t.renderMode)||0;this.renderType=this.RENDER_TYPE_CANVAS;var i=!1;if(0===e?cc.sys.capabilities.opengl?(this.renderType=this.RENDER_TYPE_WEBGL,i=!0):cc.sys.capabilities.canvas&&(this.renderType=this.RENDER_TYPE_CANVAS,i=!0):1===e&&cc.sys.capabilities.canvas?(this.renderType=this.RENDER_TYPE_CANVAS,i=!0):2===e&&cc.sys.capabilities.opengl&&(this.renderType=this.RENDER_TYPE_WEBGL,i=!0),!i)throw new Error(r.getError(3820,e))},_initRenderer:function(){if(!this._rendererInitialized){var t=this.config.id,e=void 0,i=void 0,n=void 0,r=void 0,o=cc.sys.platform===cc.sys.WECHAT_GAME,h=cc.sys.platform===cc.sys.QQ_PLAY;if(o)this.container=r=document.createElement("DIV"),this.frame=r.parentNode===document.body?document.documentElement:r.parentNode,n=cc.sys.browserType===cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB?window.sharedCanvas||wx.getSharedCanvas():canvas,this.canvas=n;else if(h)this.container=cc.container=document.createElement("DIV"),this.frame=document.documentElement,this.canvas=n=canvas;else{var l=t instanceof HTMLElement?t:document.querySelector(t)||document.querySelector("#"+t);"CANVAS"===l.tagName?(e=l.width,i=l.height,this.canvas=n=l,this.container=r=document.createElement("DIV"),n.parentNode&&n.parentNode.insertBefore(r,n)):("DIV"!==l.tagName&&cc.warnID(3819),e=l.clientWidth,i=l.clientHeight,this.canvas=n=document.createElement("CANVAS"),this.container=r=document.createElement("DIV"),l.appendChild(r)),r.setAttribute("id","Cocos2dGameContainer"),r.appendChild(n),this.frame=r.parentNode===document.body?document.documentElement:r.parentNode,(function(t,e){(" "+t.className+" ").indexOf(" "+e+" ")>-1||(t.className&&(t.className+=" "),t.className+=e)})(n,"gameCanvas"),n.setAttribute("width",e||480),n.setAttribute("height",i||320),n.setAttribute("tabindex",99)}if(this._determineRenderType(),this.renderType===this.RENDER_TYPE_WEBGL){var c={stencil:!0,antialias:cc.macro.ENABLE_WEBGL_ANTIALIAS,alpha:cc.macro.ENABLE_TRANSPARENT_CANVAS};(o||h)&&(c.preserveDrawingBuffer=!0),s.initWebGL(n,c),this._renderContext=s.device._gl,!cc.macro.CLEANUP_IMAGE_CACHE&&a&&(a.enabled=!0)}this._renderContext||(this.renderType=this.RENDER_TYPE_CANVAS,s.initCanvas(n),this._renderContext=s.device._ctx),this.canvas.oncontextmenu=function(){if(!cc._isContextMenuEnable)return!1},this._rendererInitialized=!0}},_initEvents:function(){var t,e=window;this.config.registerSystemEvent&&o.registerSystemEvent(this.canvas),void 0!==document.hidden?t="hidden":void 0!==document.mozHidden?t="mozHidden":void 0!==document.msHidden?t="msHidden":void 0!==document.webkitHidden&&(t="webkitHidden");var i=!1;function n(){i||(i=!0,h.emit(h.EVENT_HIDE))}function r(){i&&(i=!1,h.emit(h.EVENT_SHOW))}if(t)for(var s=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],a=0;a-1&&(e.onfocus=r),"onpageshow"in window&&"onpagehide"in window&&(e.addEventListener("pagehide",n),e.addEventListener("pageshow",r),document.addEventListener("pagehide",n),document.addEventListener("pageshow",r)),this.on(h.EVENT_HIDE,(function(){h.pause()})),this.on(h.EVENT_SHOW,(function(){h.resume()}))}};n.call(h),cc.js.addon(h,n.prototype),cc.game=e.exports=h}),{"../audio/CCAudioEngine":20,"../core/renderer/utils/dynamic-atlas/manager":201,"./CCDebug":25,"./event/event-target":99,"./platform/BKInputManager":154,"./platform/CCInputManager":160,"./renderer/index.js":197}],28:[(function(t,e,i){"use strict";var n=t("./utils/base-node"),r=t("./utils/prefab-helper"),s=t("./utils/math-pools"),o=t("./renderer/render-engine").math,a=t("./utils/affine-transform"),h=t("./event-manager"),l=t("./platform/CCMacro"),c=t("./utils/misc"),u=t("./platform/js"),_=(t("./event/event"),t("./event/event-target")),f=t("./renderer/render-flow"),m=cc.Object.Flags.Destroying,d=Math.PI/180,p=!!cc.ActionManager,y=function(){},v=cc.v2(),g=cc.v2(),x=o.mat4.create(),A=o.vec3.create(),b=o.quat.create(),C=1,S=new Array(16);S.length=0;var T=cc.Enum({DEBUG:31}),w=cc.Enum({POSITION:1,SCALE:2,ROTATION:4,SKEW:8,RT:7,ALL:65535}),E=cc.Enum({TOUCH_START:"touchstart",TOUCH_MOVE:"touchmove",TOUCH_END:"touchend",TOUCH_CANCEL:"touchcancel",MOUSE_DOWN:"mousedown",MOUSE_MOVE:"mousemove",MOUSE_ENTER:"mouseenter",MOUSE_LEAVE:"mouseleave",MOUSE_UP:"mouseup",MOUSE_WHEEL:"mousewheel",POSITION_CHANGED:"position-changed",ROTATION_CHANGED:"rotation-changed",SCALE_CHANGED:"scale-changed",SIZE_CHANGED:"size-changed",ANCHOR_CHANGED:"anchor-changed",CHILD_ADDED:"child-added",CHILD_REMOVED:"child-removed",CHILD_REORDER:"child-reorder",GROUP_CHANGED:"group-changed"}),D=[E.TOUCH_START,E.TOUCH_MOVE,E.TOUCH_END,E.TOUCH_CANCEL],B=[E.MOUSE_DOWN,E.MOUSE_ENTER,E.MOUSE_MOVE,E.MOUSE_LEAVE,E.MOUSE_UP,E.MOUSE_WHEEL],M=null,P=function(t,e){var i=t.getLocation(),n=this.owner;return!!n._hitTest(i,this)&&(e.type=E.TOUCH_START,e.touch=t,e.bubbles=!0,n.dispatchEvent(e),!0)},I=function(t,e){var i=this.owner;e.type=E.TOUCH_MOVE,e.touch=t,e.bubbles=!0,i.dispatchEvent(e)},R=function(t,e){var i=t.getLocation(),n=this.owner;n._hitTest(i,this)?e.type=E.TOUCH_END:e.type=E.TOUCH_CANCEL,e.touch=t,e.bubbles=!0,n.dispatchEvent(e)},L=function(t,e){t.getLocation();var i=this.owner;e.type=E.TOUCH_CANCEL,e.touch=t,e.bubbles=!0,i.dispatchEvent(e)},O=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=E.MOUSE_DOWN,t.bubbles=!0,i.dispatchEvent(t))},F=function(t){var e=t.getLocation(),i=this.owner;if(i._hitTest(e,this))this._previousIn||(M&&M._mouseListener&&(t.type=E.MOUSE_LEAVE,M.dispatchEvent(t),M._mouseListener._previousIn=!1),M=this.owner,t.type=E.MOUSE_ENTER,i.dispatchEvent(t),this._previousIn=!0),t.type=E.MOUSE_MOVE,t.bubbles=!0,i.dispatchEvent(t);else{if(!this._previousIn)return;t.type=E.MOUSE_LEAVE,i.dispatchEvent(t),this._previousIn=!1,M=null}t.stopPropagation()},V=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=E.MOUSE_UP,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())},N=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=E.MOUSE_WHEEL,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())};function k(t){var e=cc.Mask;if(e)for(var i=0,n=t;n&&cc.Node.isNode(n);n=n._parent,++i)if(n.getComponent(e))return{index:i,node:n};return null}function G(t,e){if(!(t._objFlags&m)){var i=0;if(t._bubblingListeners)for(;il.MAX_ZINDEX?(cc.warnID(1636),t=l.MAX_ZINDEX):t>16),0!==this._rotationX||0!==this._rotationY)this._rotationX===this._rotationY?o.quat.fromEuler(this._quat,0,0,-this._rotationX):o.quat.fromEuler(this._quat,this._rotationX,this._rotationY,0);else{var t=this._quat.getRoll(),e=this._quat.getPitch();0===t&&0===e?this._rotationX=this._rotationY=-this._quat.getYaw():(this._rotationX=t,this._rotationY=e)}this._color.a<255&&255===this._opacity&&(this._opacity=this._color.a,this._color.a=255)},_onBatchCreated:function(){this._upgrade_1x_to_2x(),this._updateOrderOfArrival();var t=this._prefab;t&&t.sync&&t.root===this&&r.syncWithPrefab(this),this._activeInHierarchy||(p&&cc.director.getActionManager().pauseTarget(this),h.pauseTarget(this));for(var e=this._children,i=0,n=e.length;i0&&(this._renderFlag|=f.FLAG_CHILDREN)},_onBatchRestored:function(){this._upgrade_1x_to_2x(),this._activeInHierarchy||(p&&cc.director.getActionManager().pauseTarget(this),h.pauseTarget(this));for(var t=this._children,e=0,i=t.length;e0&&(this._renderFlag|=f.FLAG_CHILDREN)},_checknSetupSysEvent:function(t){var e=!1,i=!1;return-1!==D.indexOf(t)?(this._touchListener||(this._touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,owner:this,mask:k(this),onTouchBegan:P,onTouchMoved:I,onTouchEnded:R,onTouchCancelled:L}),h.addListener(this._touchListener,this),e=!0),i=!0):-1!==B.indexOf(t)&&(this._mouseListener||(this._mouseListener=cc.EventListener.create({event:cc.EventListener.MOUSE,_previousIn:!1,owner:this,mask:k(this),onMouseDown:O,onMouseMove:F,onMouseUp:V,onMouseScroll:N}),h.addListener(this._mouseListener,this),e=!0),i=!0),e&&!this._activeInHierarchy&&cc.director.getScheduler().schedule((function(){this._activeInHierarchy||h.pauseTarget(this)}),this,0,0,0,!1),i},on:function(t,e,i,n){if(this._checknSetupSysEvent(t))return this._onDispatch(t,e,i,n);switch(t){case E.POSITION_CHANGED:this._eventMask|=1;break;case E.SCALE_CHANGED:this._eventMask|=2;break;case E.ROTATION_CHANGED:this._eventMask|=4;break;case E.SIZE_CHANGED:this._eventMask|=8;break;case E.ANCHOR_CHANGED:this._eventMask|=16}return this._bubblingListeners||(this._bubblingListeners=new _),this._bubblingListeners.on(t,e,i)},once:function(t,e,i,n){var r=this,s=this._checknSetupSysEvent(t),o="__ONCE_FLAG:"+t,a=null;(a=s&&n?this._capturingListeners=this._capturingListeners||new _:this._bubblingListeners=this._bubblingListeners||new _).hasEventListener(o,e,i)||(function(){var n=r,s=function(r,h,l,c,u){n.off(t,s,i),a.remove(o,e,i),e.call(this,r,h,l,c,u)};r.on(t,s,i),a.add(o,e,i)})()},_onDispatch:function(t,e,i,n){if("boolean"==typeof i?(n=i,i=void 0):n=!!n,e){var r=null;return(r=n?this._capturingListeners=this._capturingListeners||new _:this._bubblingListeners=this._bubblingListeners||new _).hasEventListener(t,e,i)||(r.add(t,e,i),i&&i.__eventTargets&&i.__eventTargets.push(this)),e}cc.errorID(6800)},off:function(t,e,i,n){var r=-1!==D.indexOf(t),s=!r&&-1!==B.indexOf(t);if(r||s)this._offDispatch(t,e,i,n),r?this._touchListener&&!G(this,D)&&(h.removeListener(this._touchListener),this._touchListener=null):s&&this._mouseListener&&!G(this,B)&&(h.removeListener(this._mouseListener),this._mouseListener=null);else if(this._bubblingListeners){if(this._bubblingListeners.off(t,e,i),!this._bubblingListeners.hasEventListener(t))switch(t){case E.POSITION_CHANGED:this._eventMask&=-2;break;case E.SCALE_CHANGED:this._eventMask&=-3;break;case E.ROTATION_CHANGED:this._eventMask&=-5;break;case E.SIZE_CHANGED:this._eventMask&=-9;break;case E.ANCHOR_CHANGED:this._eventMask&=-17}}},_offDispatch:function(t,e,i,n){if("boolean"==typeof i?(n=i,i=void 0):n=!!n,e){var r=n?this._capturingListeners:this._bubblingListeners;r&&(r.remove(t,e,i),i&&i.__eventTargets&&u.array.fastRemove(i.__eventTargets,this))}else this._capturingListeners&&this._capturingListeners.removeAll(t),this._bubblingListeners&&this._bubblingListeners.removeAll(t)},targetOff:function(t){var e=this._bubblingListeners;e&&(e.targetOff(t),1&this._eventMask&&!e.hasEventListener(E.POSITION_CHANGED)&&(this._eventMask&=-2),2&this._eventMask&&!e.hasEventListener(E.SCALE_CHANGED)&&(this._eventMask&=-3),4&this._eventMask&&!e.hasEventListener(E.ROTATION_CHANGED)&&(this._eventMask&=-5),8&this._eventMask&&!e.hasEventListener(E.SIZE_CHANGED)&&(this._eventMask&=-9),16&this._eventMask&&!e.hasEventListener(E.ANCHOR_CHANGED)&&(this._eventMask&=-17)),this._capturingListeners&&this._capturingListeners.targetOff(t),this._touchListener&&!G(this,D)&&(h.removeListener(this._touchListener),this._touchListener=null),this._mouseListener&&!G(this,B)&&(h.removeListener(this._mouseListener),this._mouseListener=null)},hasEventListener:function(t){var e=!1;return this._bubblingListeners&&(e=this._bubblingListeners.hasEventListener(t)),!e&&this._capturingListeners&&(e=this._capturingListeners.hasEventListener(t)),e},emit:function(t,e,i,n,r,s){this._bubblingListeners&&this._bubblingListeners.emit(t,e,i,n,r,s)},dispatchEvent:function(t){(function(t,e){var i,n;for(e.target=t,S.length=0,t._getCapturingTargets(e.type,S),e.eventPhase=1,n=S.length-1;n>=0;--n)if((i=S[n])._capturingListeners&&(e.currentTarget=i,i._capturingListeners.emit(e.type,e,S),e._propagationStopped))return void(S.length=0);if(S.length=0,e.eventPhase=2,e.currentTarget=t,t._capturingListeners&&t._capturingListeners.emit(e.type,e),!e._propagationImmediateStopped&&t._bubblingListeners&&t._bubblingListeners.emit(e.type,e),!e._propagationStopped&&e.bubbles)for(t._getBubblingTargets(e.type,S),e.eventPhase=3,n=0;n=0&&s.y>=0&&s.x<=i&&s.y<=n){if(e&&e.mask){for(var h=e.mask,l=this,c=0;l&&c1){var e,i,n,r=t.length;for(e=1;e=0&&n._localZOrder0,this._repeat=r,this._runForever=this._repeat===cc.macro.REPEAT_FOREVER,!0},_.getInterval=function(){return this._interval},_.setInterval=function(t){this._interval=t},_.update=function(t){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=t,this._runForever&&!this._useDelay?this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0):(this._useDelay?this._elapsed>=this._delay&&(this.trigger(),this._elapsed-=this._delay,this._timesExecuted+=1,this._useDelay=!1):this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0,this._timesExecuted+=1),this._callback&&!this._runForever&&this._timesExecuted>this._repeat&&this.cancel()))},_.getCallback=function(){return this._callback},_.trigger=function(){this._target&&this._callback&&(this._lock=!0,this._callback.call(this._target,this._elapsed),this._lock=!1)},_.cancel=function(){this._scheduler.unschedule(this._callback,this._target)};var f=[];u.get=function(){return f.pop()||new u},u.put=function(t){f.length<20&&!t._lock&&(t._scheduler=t._target=t._callback=null,f.push(t))},cc.Scheduler=function(){this._timeScale=1,this._updatesNegList=[],this._updates0List=[],this._updatesPosList=[],this._hashForUpdates=n.createMap(!0),this._hashForTimers=n.createMap(!0),this._currentTarget=null,this._currentTargetSalvaged=!1,this._updateHashLocked=!1,this._arrayForTimers=[]},cc.Scheduler.prototype={constructor:cc.Scheduler,_removeHashElement:function(t){delete this._hashForTimers[t.target._id];for(var e=this._arrayForTimers,i=0,n=e.length;i=s&&n.timerIndex--,void(0===r.length&&(this._currentTarget===n?this._currentTargetSalvaged=!0:this._removeHashElement(n)))}}},unscheduleUpdate:function(t){if(t){var e=t._id;e||(t.__instanceId?(cc.warnID(1513),e=t._id=t.__instanceId):cc.errorID(1510));var i=this._hashForUpdates[e];i&&(this._updateHashLocked?i.entry.markedForDeletion=!0:this._removeUpdateFromHash(i.entry))}},unscheduleAllForTarget:function(t){if(t){var e=t._id;e||(t.__instanceId?(cc.warnID(1513),e=t._id=t.__instanceId):cc.errorID(1510));var i=this._hashForTimers[e];if(i){var n=i.timers;n.indexOf(i.currentTimer)>-1&&!i.currentTimerSalvaged&&(i.currentTimerSalvaged=!0);for(var r=0,s=n.length;r=0;e--)i=r[e],this.unscheduleAllForTarget(i.target);var s=0;if(t<0)for(e=0;e=t&&this.unscheduleUpdate(n.target),s==this._updatesNegList.length&&e++;if(t<=0)for(e=0;e=t&&this.unscheduleUpdate(n.target),s==this._updatesPosList.length&&e++},isScheduled:function(t,e){cc.assertID(t,1508),cc.assertID(e,1509);var i=e._id;i||(e.__instanceId?(cc.warnID(1513),i=e._id=e.__instanceId):cc.errorID(1510));var n=this._hashForTimers[i];if(!n)return!1;if(null==n.timers)return!1;for(var r=n.timers,s=0;s=t&&(r.paused=!0,s.push(r.target));if(t<=0)for(i=0;i=t&&(r.paused=!0,s.push(r.target));return s},resumeTargets:function(t){if(t)for(var e=0;e=r.OptimizationPolicyThreshold)?(t=this._doInstantiate(),this.data._instantiate(t)):(this.data._prefab._synced=!0,t=this.data._instantiate()),++this._instantiatedTimes,t}});cc.Prefab=e.exports=r,cc.js.obsolete(cc,"cc._Prefab","Prefab")}),{"../platform/instantiate-jit":174}],39:[(function(t,e,i){var n=t("../platform/CCObject"),r=t("../platform/js");cc.RawAsset=cc.Class({name:"cc.RawAsset",extends:n,ctor:function(){Object.defineProperty(this,"_uuid",{value:"",writable:!0})}}),r.value(cc.RawAsset,"isRawAssetType",(function(t){return r.isChildClassOf(t,cc.RawAsset)&&!r.isChildClassOf(t,cc.Asset)})),r.value(cc.RawAsset,"wasRawAssetType",(function(t){return t===cc.Texture2D||t===cc.AudioClip||t===cc.ParticleAsset||t===cc.Asset})),e.exports=cc.RawAsset}),{"../platform/CCObject":162,"../platform/js":176}],40:[(function(t,e,i){var n=t("../renderer"),r=t("../renderer/render-engine"),s=r.gfx,o=t("./CCTexture2D"),a=cc.Class({name:"cc.RenderTexture",extends:o,ctor:function(){this._framebuffer=null},initWithSize:function(t,e,i){this.width=Math.floor(t||cc.visibleRect.width),this.height=Math.floor(e||cc.visibleRect.height);var o={};if(o.format=this._format,o.width=t,o.height=e,o.images=void 0,o.wrapS=this._wrapS,o.wrapT=this._wrapT,this._texture?this._texture.update(o):this._texture=new n.Texture2D(n.device,o),o={colors:[this._texture]},i){var a=new s.RenderBuffer(n.device,i,t,e);i===s.RB_FMT_D24S8?o.depth=o.stencil=a:i===s.RB_FMT_S8?o.stencil=a:i===gl.RB_FMT_D16&&(o.depth=a)}this._framebuffer&&this._framebuffer.destroy(),this._framebuffer=new r.gfx.FrameBuffer(n.device,t,e,o),this.loaded=!0,this.emit("load")},drawTextureAt:function(t,e,i){t._image&&this._texture.updateSubImage({x:e,y:i,image:t._image,width:t.width,height:t.height,level:0,flipY:!1})},readPixels:function(t,e,i,r,s){if(!this._framebuffer||!this._texture)return t;e=e||0,i=i||0;var o=r||this.width,a=s||this.height;t=t||new Uint8Array(o*a*4);var h=n._forward._device._gl,l=h.getParameter(h.FRAMEBUFFER_BINDING);return h.bindFramebuffer(h.FRAMEBUFFER,this._framebuffer._glID),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,this._texture._glID,0),h.readPixels(e,i,o,a,h.RGBA,h.UNSIGNED_BYTE,t),h.bindFramebuffer(h.FRAMEBUFFER,l),t},destroy:function(){this._super(),this._framebuffer&&this._framebuffer.destroy()}});cc.RenderTexture=e.exports=a}),{"../renderer":197,"../renderer/render-engine":198,"./CCTexture2D":47}],41:[(function(t,e,i){var n=cc.Class({name:"cc.SceneAsset",extends:cc.Asset,properties:{scene:null,asyncLoadAssets:void 0}});cc.SceneAsset=n,e.exports=n}),{}],42:[(function(t,e,i){var n=cc.Class({name:"cc.Script",extends:cc.Asset});cc._Script=n;var r=cc.Class({name:"cc.JavaScript",extends:n});cc._JavaScript=r;var s=cc.Class({name:"cc.CoffeeScript",extends:n});cc._CoffeeScript=s;var o=cc.Class({name:"cc.TypeScript",extends:n});cc._TypeScript=o}),{}],43:[(function(t,e,i){var n=cc.Class({name:"cc.SpriteAtlas",extends:cc.Asset,properties:{_spriteFrames:{default:{}}},getTexture:function(){var t=Object.keys(this._spriteFrames);if(t.length>0){var e=this._spriteFrames[t[0]];return e?e.getTexture():null}return null},getSpriteFrame:function(t){var e=this._spriteFrames[t];return e?(e.name||(e.name=t),e):null},getSpriteFrames:function(){var t=[],e=this._spriteFrames;for(var i in e)t.push(this.getSpriteFrame(i));return t}});cc.SpriteAtlas=n,e.exports=n}),{}],44:[(function(t,e,i){var n=t("../event/event-target"),r=t("../utils/texture-util"),s=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],o=cc.Class({name:"cc.SpriteFrame",extends:t("../assets/CCAsset"),mixins:[n],properties:{_textureSetter:{set:function(t){t&&(this._texture!==t&&this._refreshTexture(t),this._textureFilename=t.url)}},insetTop:{get:function(){return this._capInsets[1]},set:function(t){this._capInsets[1]=t,this._texture&&this._calculateSlicedUV()}},insetBottom:{get:function(){return this._capInsets[3]},set:function(t){this._capInsets[3]=t,this._texture&&this._calculateSlicedUV()}},insetLeft:{get:function(){return this._capInsets[0]},set:function(t){this._capInsets[0]=t,this._texture&&this._calculateSlicedUV()}},insetRight:{get:function(){return this._capInsets[2]},set:function(t){this._capInsets[2]=t,this._texture&&this._calculateSlicedUV()}}},ctor:function(){n.call(this);var t=arguments[0],e=arguments[1],i=arguments[2],r=arguments[3],s=arguments[4];this._rect=null,this._offset=null,this._originalSize=null,this._rotated=!1,this.vertices=null,this._capInsets=[0,0,0,0],this.uv=[],this.uvSliced=[],this._texture=null,this._textureFilename="",this._original=null,void 0!==t&&this.setTexture(t,e,i,r,s)},textureLoaded:function(){return this._texture&&this._texture.loaded},isRotated:function(){return this._rotated},setRotated:function(t){this._rotated=t},getRect:function(){return cc.rect(this._rect)},setRect:function(t){this._rect=t},getOriginalSize:function(){return cc.size(this._originalSize)},setOriginalSize:function(t){this._originalSize?(this._originalSize.width=t.width,this._originalSize.height=t.height):this._originalSize=cc.size(t)},getTexture:function(){return this._texture},_textureLoadedCallback:function(){var t=this._texture;if(t){var e=t.width,i=t.height;this._rotated&&cc.game.renderType===cc.game.RENDER_TYPE_CANVAS&&(this._rotated=!1,e=this._texture.width,i=this._texture.height,this.setRect(cc.rect(0,0,e,i))),this._rect?this._checkRect(this._texture):this.setRect(cc.rect(0,0,e,i)),this._originalSize||this.setOriginalSize(cc.size(e,i)),this._offset||this.setOffset(cc.v2(0,0)),this._calculateUV(),this.emit("load")}},_refreshTexture:function(t){this._texture=t,t.loaded?this._textureLoadedCallback():t.once("load",this._textureLoadedCallback,this)},getOffset:function(){return cc.v2(this._offset)},setOffset:function(t){this._offset=cc.v2(t)},clone:function(){return new o(this._texture||this._textureFilename,this._rect,this._rotated,this._offset,this._originalSize)},setTexture:function(t,e,i,n,r){e?this.setRect(e):this._rect=null,n?this.setOffset(n):this._offset=null,r?this.setOriginalSize(r):this._originalSize=null,this._rotated=i||!1;var s=t;return"string"==typeof s&&s&&(this._textureFilename=s,this._loadTexture()),s instanceof cc.Texture2D&&this._texture!==s&&this._refreshTexture(s),!0},_loadTexture:function(){if(this._textureFilename){var t=r.loadImage(this._textureFilename);this._refreshTexture(t)}},ensureLoadTexture:function(){this._texture?this._texture.loaded||(this._refreshTexture(this._texture),r.postLoadTexture(this._texture)):this._textureFilename&&this._loadTexture()},clearTexture:function(){this._texture=null},_checkRect:function(t){var e=this._rect,i=e.x,n=e.y;this._rotated?(i+=e.height,n+=e.width):(i+=e.width,n+=e.height),i>t.width&&cc.errorID(3300,t.url+"/"+this.name,i,t.width),n>t.height&&cc.errorID(3400,t.url+"/"+this.name,n,t.height)},_calculateSlicedUV:function(){var t=this._rect,e=this._texture.width,i=this._texture.height,n=this._capInsets[0],r=this._capInsets[2],o=t.width-n-r,a=this._capInsets[1],h=this._capInsets[3],l=t.height-a-h,c=this.uvSliced;if(c.length=0,this._rotated){s[0].u=t.x/e,s[1].u=(t.x+h)/e,s[2].u=(t.x+h+l)/e,s[3].u=(t.x+t.height)/e,s[3].v=t.y/i,s[2].v=(t.y+n)/i,s[1].v=(t.y+n+o)/i,s[0].v=(t.y+t.width)/i;for(var u=0;u<4;++u)for(var _=s[u],f=0;f<4;++f){var m=s[3-f];c.push({u:_.u,v:m.v})}}else{s[0].u=t.x/e,s[1].u=(t.x+n)/e,s[2].u=(t.x+n+o)/e,s[3].u=(t.x+t.width)/e,s[3].v=t.y/i,s[2].v=(t.y+a)/i,s[1].v=(t.y+a+l)/i,s[0].v=(t.y+t.height)/i;for(var d=0;d<4;++d)for(var p=s[d],y=0;y<4;++y){var v=s[y];c.push({u:v.u,v:p.v})}}},_calculateUV:function(){var t=this._rect,e=this._texture,i=this.uv,n=e.width,r=e.height;if(this._rotated){var s=0===n?0:t.x/n,o=0===n?0:(t.x+t.height)/n,a=0===r?0:(t.y+t.width)/r,h=0===r?0:t.y/r;i[0]=s,i[1]=h,i[2]=s,i[3]=a,i[4]=o,i[5]=h,i[6]=o,i[7]=a}else{var l=0===n?0:t.x/n,c=0===n?0:(t.x+t.width)/n,u=0===r?0:(t.y+t.height)/r,_=0===r?0:t.y/r;i[0]=l,i[1]=u,i[2]=c,i[3]=u,i[4]=l,i[5]=_,i[6]=c,i[7]=_}var f=this.vertices;if(f){f.nu.length=0,f.nv.length=0;for(var m=0;m0?this._image=t.images[0]:void 0!==t.image&&(this._image=t.image,t.images||(_.length=0,t.images=_),t.images.push(t.image)),t.images&&t.images.length>0&&this._texture.update(t)}},initWithElement:function(t){if(t)if(this._image=t,t.complete||t instanceof HTMLCanvasElement)this.handleLoadedTexture();else{var e=this;t.addEventListener("load",(function(){e.handleLoadedTexture()})),t.addEventListener("error",(function(t){cc.warnID(3119,t.message)}))}},initWithData:function(t,e,i,n){var r=m();return r.image=t,r.format=e,r.width=i,r.height=n,this.update(r),this.width=i,this.height=n,this.loaded=!0,this.emit("load"),!0},getHtmlElementObj:function(){return this._image},destroy:function(){this._image=null,this._texture&&this._texture.destroy(),this._super()},getPixelFormat:function(){return this._format},hasPremultipliedAlpha:function(){return this._premultiplyAlpha||!1},hasMipmap:function(){return this._hasMipmap||!1},handleLoadedTexture:function(){if(this._image&&this._image.width&&this._image.height){this.width=this._image.width,this.height=this._image.height;var t=m();t.image=this._image,t.images=[t.image],t.width=this.width,t.height=this.height,t.hasMipmap=this._hasMipmap,t.format=this._format,t.premultiplyAlpha=this._premultiplyAlpha,t.flipY=this._flipY,t.minFilter=u[this._minFilter],t.magFilter=u[this._magFilter],t.wrapS=this._wrapS,t.wrapT=this._wrapT,this._texture?this._texture.update(t):this._texture=new s.Texture2D(s.device,t),this.loaded=!0,this.emit("load"),cc.macro.CLEANUP_IMAGE_CACHE&&this._image instanceof HTMLImageElement&&(this._image.src="",cc.loader.removeItem(this._image.id))}},description:function(){return""},releaseTexture:function(){this._image=null,this._texture&&this._texture.destroy()},setWrapMode:function(t,e){if(this._wrapS!==t||this._wrapT!==e){var i=m();i.wrapS=t,i.wrapT=e,this.update(i)}},setFilters:function(t,e){if(this._minFilter!==t||this._magFilter!==e){var i=m();i.minFilter=t,i.magFilter=e,this.update(i)}},setFlipY:function(t){if(this._flipY!==t){var e=m();e.flipY=t,this.update(e)}},setPremultiplyAlpha:function(t){if(this._premultiplyAlpha!==t){var e=m();e.premultiplyAlpha=t,this.update(e)}},setMipmap:function(t){if(this._hasMipmap!==t){var e=m();e.hasMipmap=t,this.update(e)}},_serialize:!1,_deserialize:function(t,e){var i=t.split(","),n=i[0];if(n){var r=n.charCodeAt(0)-48,s=d.extnames[r];this._setRawAsset(s||n);var o=e.customEnv,a=o&&o.uuid;if(a){this._uuid=a;var h=this.nativeUrl;this.url=h}}6===i.length&&(this._minFilter=parseInt(i[1]),this._magFilter=parseInt(i[2]),this._wrapS=parseInt(i[3]),this._wrapT=parseInt(i[4]),this._premultiplyAlpha=49===i[5].charCodeAt(0))}});cc.Texture2D=e.exports=d}),{"../assets/CCAsset":32,"../event/event-target":99,"../platform/CCClass":156,"../platform/id-generater":172,"../renderer":197,"../renderer/render-engine":198}],48:[(function(t,e,i){t("./CCRawAsset"),t("./CCAsset"),t("./CCFont"),t("./CCPrefab"),t("./CCAudioClip"),t("./CCScripts"),t("./CCSceneAsset"),t("./CCSpriteFrame"),t("./CCTexture2D"),t("./CCRenderTexture"),t("./CCTTFFont"),t("./CCSpriteAtlas"),t("./CCBitmapFont"),t("./CCLabelAtlas"),t("./CCTextAsset"),t("./CCJsonAsset")}),{"./CCAsset":32,"./CCAudioClip":33,"./CCBitmapFont":34,"./CCFont":35,"./CCJsonAsset":36,"./CCLabelAtlas":37,"./CCPrefab":38,"./CCRawAsset":39,"./CCRenderTexture":40,"./CCSceneAsset":41,"./CCScripts":42,"./CCSpriteAtlas":43,"./CCSpriteFrame":44,"./CCTTFFont":45,"./CCTextAsset":46,"./CCTexture2D":47}],49:[(function(t,e,i){t("../CCNode").EventType;var n=56,r=7,s=cc.Enum({ONCE:0,ON_WINDOW_RESIZE:1,ALWAYS:2});function o(t){return t instanceof cc.Scene?cc.visibleRect:t._contentSize}function a(t,e,i,n){for(var r=t._parent._scale.x,s=t._parent._scale.y,o=0,a=0,h=t._parent;;){var l=h._position;if(o+=l.x,a+=l.y,!(h=h._parent))return i.x=i.y=0,void(n.x=n.y=1);if(h===e)break;var c=h._scale.x,u=h._scale.y;o*=c,a*=u,r*=c,s*=u}n.x=0!==r?1/r:1,n.y=0!==s?1/s:1,i.x=-o,i.y=-a}var h=cc.Vec2.ZERO,l=cc.Vec2.ONE;function c(t,e){var i,s,c,u=e._target;u?a(t,i=u,s=h,c=l):i=t._parent;var _=o(i),f=i._anchorPoint,m=i instanceof cc.Scene,d=t._position.x,p=t._position.y,y=t._anchorPoint;if(e._alignFlags&n){var v,g,x=_.width;m?(v=cc.visibleRect.left.x,g=cc.visibleRect.right.x):g=(v=-f.x*x)+x,v+=e._isAbsLeft?e._left:e._left*x,g-=e._isAbsRight?e._right:e._right*x,u&&(v+=s.x,v*=c.x,g+=s.x,g*=c.x);var A,b=y.x,C=t._scale.x;if(C<0&&(b=1-b,C=-C),e.isStretchWidth)A=g-v,0!==C&&(t.width=A/C),d=v+b*A;else if(A=t.width*C,e.isAlignHorizontalCenter){var S=e._isAbsHorizontalCenter?e._horizontalCenter:e._horizontalCenter*x,T=(.5-f.x)*_.width;u&&(S*=c.x,T+=s.x,T*=c.x),d=T+(b-.5)*A+S}else d=e.isAlignLeft?v+b*A:g+(b-1)*A}if(e._alignFlags&r){var w,E,D=_.height;m?(E=cc.visibleRect.bottom.y,w=cc.visibleRect.top.y):w=(E=-f.y*D)+D,E+=e._isAbsBottom?e._bottom:e._bottom*D,w-=e._isAbsTop?e._top:e._top*D,u&&(E+=s.y,E*=c.y,w+=s.y,w*=c.y);var B,M=y.y,P=t._scale.y;if(P<0&&(M=1-M,P=-P),e.isStretchHeight)B=w-E,0!==P&&(t.height=B/P),p=E+M*B;else if(B=t.height*P,e.isAlignVerticalCenter){var I=e._isAbsVerticalCenter?e._verticalCenter:e._verticalCenter*D,R=(.5-f.y)*_.height;u&&(I*=c.y,R+=s.y,R*=c.y),p=R+(M-.5)*B+I}else p=e.isAlignBottom?E+M*B:w+(M-1)*B}t.setPosition(d,p)}function u(){var t=cc.director.getScene();if(t){if(f.isAligning=!0,f._nodesOrderDirty)_.length=0,(function t(e){var i=e._widget;i&&(c(e,i),i.alignMode!==s.ALWAYS?i.enabled=!1:_.push(i));for(var n=e._children,r=0;rT&&(T=B),Bw&&(w=M),M=0){e.splice(i,1);for(var n=this._contacts,o=n.length-1;o>=0;o--){var a=n[o];a.collider1!==t&&a.collider2!==t||(a.touching&&this._doCollide(r.CollisionExit,a),n.splice(o,1))}t.node.off(s.GROUP_CHANGED,this.onNodeGroupChanged,this)}else cc.errorID(6600)},onNodeGroupChanged:function(t){for(var e=t.getComponents(cc.Collider),i=0,n=e.length;i0){t.moveTo(s[0].x,s[0].y);for(var o=1;or!=u>r&&n<(c-h)*(r-l)/(u-l)+h&&(i=!i)}return i}function a(t,e,i,n){var r,s=i.x-e.x,o=i.y-e.y,a=s*s+o*o,h=((t.x-e.x)*s+(t.y-e.y)*o)/a;return r=n?a?h<0?e:h>1?i:cc.v2(e.x+h*s,e.y+h*o):e:cc.v2(e.x+h*s,e.y+h*o),s=t.x-r.x,o=t.y-r.y,Math.sqrt(s*s+o*o)}n.lineLine=r,n.lineRect=function(t,e,i){var n=new cc.Vec2(i.x,i.y),s=new cc.Vec2(i.x,i.yMax),o=new cc.Vec2(i.xMax,i.yMax),a=new cc.Vec2(i.xMax,i.y);return!!(r(t,e,n,s)||r(t,e,s,o)||r(t,e,o,a)||r(t,e,a,n))},n.linePolygon=s,n.rectRect=function(t,e){var i=t.x,n=t.y,r=t.x+t.width,s=t.y+t.height,o=e.x,a=e.y,h=e.x+e.width,l=e.y+e.height;return i<=h&&r>=o&&n<=l&&s>=a},n.rectPolygon=function(t,e){var i,n,r=new cc.Vec2(t.x,t.y),a=new cc.Vec2(t.x,t.yMax),h=new cc.Vec2(t.xMax,t.yMax),l=new cc.Vec2(t.xMax,t.y);if(s(r,a,e))return!0;if(s(a,h,e))return!0;if(s(h,l,e))return!0;if(s(l,r,e))return!0;for(i=0,n=e.length;i>>1;r<=s;o=r+s>>>1){var a=t[o],h=a.constructor._executionOrder;if(h>i)s=o-1;else if(hn)s=o-1;else{if(!(l0&&(t.array.sort(f),this._invoke(t),t.array.length=0),this._invoke(this._zero),this._zero.array.length=0;var e=this._pos;e.array.length>0&&(e.array.sort(f),this._invoke(e),e.array.length=0)}}),d=cc.Class({extends:_,add:function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.array.push(t);else{var i=e<0?this._neg.array:this._pos.array,n=c(i,t);n<0&&i.splice(~n,0,t)}},remove:function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.fastRemove(t);else{var i=e<0?this._neg:this._pos,n=c(i.array,t);n>=0&&i.removeAt(n)}},invoke:function(t){this._neg.array.length>0&&this._invoke(this._neg,t),this._invoke(this._zero,t),this._pos.array.length>0&&this._invoke(this._pos,t)}});function p(t,e){if("function"==typeof t)return e?function(e,i){var n=e.array;for(e.i=0;e.i=0?r.fastRemoveAt(this.scheduleInNextFrame,e):(!t.start||t._objFlags&s||this.startInvoker.remove(t),t.update&&this.updateInvoker.remove(t),t.lateUpdate&&this.lateUpdateInvoker.remove(t))},enableComp:function(t,e){if(!(t._objFlags&o)){if(t.onEnable){if(e)return void e.add(t);if(t.onEnable(),!t.node._activeInHierarchy)return}this._onEnabled(t)}},disableComp:function(t){t._objFlags&o&&(t.onDisable&&t.onDisable(),this._onDisabled(t))},_scheduleImmediate:function(t){!t.start||t._objFlags&s||this.startInvoker.add(t),t.update&&this.updateInvoker.add(t),t.lateUpdate&&this.lateUpdateInvoker.add(t)},_deferredSchedule:function(){for(var t=this.scheduleInNextFrame,e=0,i=t.length;e0&&this._deferredSchedule(),this.startInvoker.invoke()},updatePhase:function(t){this.updateInvoker.invoke(t)},lateUpdatePhase:function(t){this.lateUpdateInvoker.invoke(t),this._updating=!1}});e.exports=v}),{"./platform/CCClass":156,"./platform/CCObject":162,"./platform/js":176,"./utils/misc":234}],60:[(function(t,e,i){var n=t("../../animation/animation-animator"),r=t("../../animation/animation-clip"),s=t("../event/event-target"),o=t("../platform/js");function a(t,e){return t===e||t&&e&&(t.name===e.name||t._uuid===e._uuid)}var h=cc.Enum({PLAY:"play",STOP:"stop",PAUSE:"pause",RESUME:"resume",LASTFRAME:"lastframe",FINISHED:"finished"}),l=cc.Class({name:"cc.Animation",extends:t("./CCComponent"),mixins:[s],editor:!1,statics:{EventType:h},ctor:function(){cc.EventTarget.call(this),this._animator=null,this._nameToState=o.createMap(!0),this._didInit=!1,this._currentClip=null},properties:{_defaultClip:{default:null,type:r},defaultClip:{type:r,get:function(){return this._defaultClip},set:function(t){},tooltip:!1},currentClip:{get:function(){return this._currentClip},set:function(t){this._currentClip=t},type:r,visible:!1},_clips:{default:[],type:[r],tooltip:!1,visible:!0},playOnLoad:{default:!1,tooltip:!1}},start:function(){if(this.playOnLoad&&this._defaultClip&&!(this._animator&&this._animator.isPlaying)){var t=this.getAnimationState(this._defaultClip.name);this._animator.playState(t)}},onEnable:function(){this._animator&&this._animator.resume()},onDisable:function(){this._animator&&this._animator.pause()},onDestroy:function(){this.stop()},getClips:function(){return this._clips},play:function(t,e){var i=this.playAdditive(t,e);return this._animator.stopStatesExcept(i),i},playAdditive:function(t,e){this._init();var i=this.getAnimationState(t||this._defaultClip&&this._defaultClip.name);if(i){this.enabled=!0;var n=this._animator;n.isPlaying&&i.isPlaying?i.isPaused?n.resumeState(i):(n.stopState(i),n.playState(i,e)):n.playState(i,e),this.enabledInHierarchy||n.pause(),this.currentClip=i.clip}return i},stop:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.stopState(e)}else this._animator.stop()},pause:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.pauseState(e)}else this.enabled=!1},resume:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.resumeState(e)}else this.enabled=!0},setCurrentTime:function(t,e){if(this._init(),e){var i=this._nameToState[e];i&&this._animator.setStateTime(i,t)}else this._animator.setStateTime(t)},getAnimationState:function(t){this._init();var e=this._nameToState[t];return e&&!e.curveLoaded&&this._animator._reloadClip(e),e||null},addClip:function(t,e){if(t){this._init(),cc.js.array.contains(this._clips,t)||this._clips.push(t),e=e||t.name;var i=this._nameToState[e];if(i){if(i.clip===t)return i;var n=this._clips.indexOf(i.clip);-1!==n&&this._clips.splice(n,1)}var r=new cc.AnimationState(t,e);return this._nameToState[e]=r,r}cc.warnID(3900)},removeClip:function(t,e){if(t){var i;for(var n in this._init(),this._nameToState){if((i=this._nameToState[n]).clip===t)break}if(t===this._defaultClip){if(!e)return void cc.warnID(3902);this._defaultClip=null}if(i&&i.isPlaying){if(!e)return void cc.warnID(3903);this.stop(i.name)}this._clips=this._clips.filter((function(e){return e!==t})),i&&delete this._nameToState[i.name]}else cc.warnID(3901)},sample:function(t){if(this._init(),t){var e=this._nameToState[t];e&&e.sample()}else this._animator.sample()},on:function(t,e,i,n){this._init();for(var r=this._EventTargetOn(t,e,i,n),s=this._animator._anims.array,o=0;o0&&(i=this.time/this.duration),i>=1&&(i=1,this._transitionFinished=!0),this.transition===s.COLOR?e.color=this._fromColor.lerp(this._toColor,i):this.transition===s.SCALE&&(e.scale=r.lerp(this._fromScale,this._toScale,i))}},_registerEvent:function(){this.node.on(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.on(cc.Node.EventType.TOUCH_MOVE,this._onTouchMove,this),this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.on(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(cc.Node.EventType.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(cc.Node.EventType.MOUSE_LEAVE,this._onMouseMoveOut,this)},_getTargetSprite:function(t){var e=null;return t&&(e=t.getComponent(cc.Sprite)),e},_applyTarget:function(){this._sprite=this._getTargetSprite(this.target),this.target&&(this._originalScale=this.target.scale)},_onTouchBegan:function(t){this.interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState(),t.stopPropagation())},_onTouchMove:function(t){if(this.interactable&&this.enabledInHierarchy&&this._pressed){var e=t.touch,i=this.node._hitTest(e.getLocation());if(this.transition===s.SCALE&&this.target)i?(this._fromScale=this._originalScale,this._toScale=this._originalScale*this.zoomScale,this._transitionFinished=!1):(this.time=0,this._transitionFinished=!0,this.target.scale=this._originalScale);else{var n=void 0;n=i?"pressed":"normal",this._applyTransition(n)}t.stopPropagation()}},_onTouchEnded:function(t){this.interactable&&this.enabledInHierarchy&&(this._pressed&&(cc.Component.EventHandler.emitEvents(this.clickEvents,t),this.node.emit("click",this)),this._pressed=!1,this._updateState(),t.stopPropagation())},_onTouchCancel:function(){this.interactable&&this.enabledInHierarchy&&(this._pressed=!1,this._updateState())},_onMouseMoveIn:function(){!this._pressed&&this.interactable&&this.enabledInHierarchy&&(this.transition!==s.SPRITE||this.hoverSprite)&&(this._hovered||(this._hovered=!0,this._updateState()))},_onMouseMoveOut:function(){this._hovered&&(this._hovered=!1,this._updateState())},_updateState:function(){var t=this._getButtonState();this._applyTransition(t),this._updateDisabledState()},_getButtonState:function(){return this.interactable?this._pressed?"pressed":this._hovered?"hover":"normal":"disabled"},_updateColorTransition:function(t){var e=this[t+"Color"],i=this.target;this._fromColor=i.color.clone(),this._toColor=e,this.time=0,this._transitionFinished=!1},_updateSpriteTransition:function(t){var e=this[t+"Sprite"];this._sprite&&e&&(this._sprite.spriteFrame=e)},_updateScaleTransition:function(t){"pressed"===t?this._zoomUp():this._zoomBack()},_zoomUp:function(){this._fromScale=this._originalScale,this._toScale=this._originalScale*this.zoomScale,this.time=0,this._transitionFinished=!1},_zoomBack:function(){this._fromScale=this.target.scale,this._toScale=this._originalScale,this.time=0,this._transitionFinished=!1},_applyTransition:function(t){var e=this.transition;e===s.COLOR?this._updateColorTransition(t):e===s.SPRITE?this._updateSpriteTransition(t):e===s.SCALE&&this._updateScaleTransition(t)},_resizeNodeToTargetNode:!1,_updateDisabledState:function(){this._sprite&&this._sprite.setState(cc.Sprite.State.NORMAL),this.enableAutoGrayEffect&&this.transition!==s.COLOR&&(this.transition===s.SPRITE&&this.disabledSprite||this._sprite&&!this.interactable&&this._sprite.setState(cc.Sprite.State.GRAY))}});cc.Button=e.exports=o}),{"../utils/misc":234,"./CCComponent":65}],64:[(function(t,e,i){var n=t("../camera/CCCamera"),r=t("./CCComponent"),s=cc.Class({name:"cc.Canvas",extends:r,editor:!1,resetInEditor:!1,statics:{instance:null},properties:{_designResolution:cc.size(960,640),designResolution:{get:function(){return cc.size(this._designResolution)},set:function(t){this._designResolution.width=t.width,this._designResolution.height=t.height,this.applySettings()},tooltip:!1},_fitWidth:!1,_fitHeight:!0,fitHeight:{get:function(){return this._fitHeight},set:function(t){this._fitHeight!==t&&(this._fitHeight=t,this.applySettings())},tooltip:!1},fitWidth:{get:function(){return this._fitWidth},set:function(t){this._fitWidth!==t&&(this._fitWidth=t,this.applySettings())},tooltip:!1}},ctor:function(){this._thisOnResized=this.onResized.bind(this)},__preload:function(){if(s.instance)return cc.errorID(6700,this.node.name,s.instance.node.name);s.instance=this,cc.director.on(cc.Director.EVENT_AFTER_UPDATE,this.alignWithScreen,this),cc.sys.isMobile?window.addEventListener("resize",this._thisOnResized):cc.view.on("canvas-resize",this._thisOnResized),this.applySettings(),this.onResized();var t=cc.find("Main Camera",this.node);t||((t=new cc.Node("Main Camera")).parent=this.node,t.setSiblingIndex(0));var e=t.getComponent(n);if(!e){e=t.addComponent(n);var i=n.ClearFlags;e.clearFlags=i.COLOR|i.DEPTH|i.STENCIL,e.depth=-1}n.main=e},onDestroy:function(){cc.director.off(cc.Director.EVENT_AFTER_UPDATE,this.alignWithScreen,this),cc.sys.isMobile?window.removeEventListener("resize",this._thisOnResized):cc.view.off("canvas-resize",this._thisOnResized),s.instance===this&&(s.instance=null)},alignWithScreen:function(){var t,e,i=e=cc.visibleRect;t=cc.view.getDesignResolutionSize();var n=0,r=0;!this.fitHeight&&!this.fitWidth&&(n=.5*(t.width-i.width),r=.5*(t.height-i.height)),this.node.setPosition(.5*i.width+n,.5*i.height+r),this.node.width=e.width,this.node.height=e.height},onResized:function(){this.alignWithScreen()},applySettings:function(){var t,e=cc.ResolutionPolicy;t=this.fitHeight&&this.fitWidth?e.SHOW_ALL:this.fitHeight||this.fitWidth?this.fitWidth?e.FIXED_WIDTH:e.FIXED_HEIGHT:e.NO_BORDER;var i=this._designResolution;cc.view.setDesignResolutionSize(i.width,i.height,t)}});cc.Canvas=e.exports=s}),{"../camera/CCCamera":50,"./CCComponent":65}],65:[(function(t,e,i){var n=t("../platform/CCObject"),r=t("../platform/js"),s=new(t("../platform/id-generater"))("Comp"),o=n.Flags.IsOnEnableCalled,a=n.Flags.IsOnLoadCalled,h=cc.Class({name:"cc.Component",extends:n,ctor:function(){this._id=s.getNewId(),this.__eventTargets=[]},properties:{node:{default:null,visible:!1},name:{get:function(){if(this._name)return this._name;var t=cc.js.getClassName(this),e=t.lastIndexOf(".");return e>=0&&(t=t.slice(e+1)),this.node.name+"<"+t+">"},set:function(t){this._name=t},visible:!1},uuid:{get:function(){return this._id},visible:!1},__scriptAsset:!1,_enabled:!0,enabled:{get:function(){return this._enabled},set:function(t){if(this._enabled!==t&&(this._enabled=t,this.node._activeInHierarchy)){var e=cc.director._compScheduler;t?e.enableComp(this):e.disableComp(this)}},visible:!1},enabledInHierarchy:{get:function(){return(this._objFlags&o)>0},visible:!1},_isOnLoadCalled:{get:function(){return this._objFlags&a}}},update:null,lateUpdate:null,__preload:null,onLoad:null,start:null,onEnable:null,onDisable:null,onDestroy:null,onFocusInEditor:null,onLostFocusInEditor:null,resetInEditor:null,addComponent:function(t){return this.node.addComponent(t)},getComponent:function(t){return this.node.getComponent(t)},getComponents:function(t){return this.node.getComponents(t)},getComponentInChildren:function(t){return this.node.getComponentInChildren(t)},getComponentsInChildren:function(t){return this.node.getComponentsInChildren(t)},_getLocalBounds:null,onRestore:null,destroy:function(){this._super()&&this._enabled&&this.node._activeInHierarchy&&cc.director._compScheduler.disableComp(this)},_onPreDestroy:function(){this.unscheduleAllCallbacks();for(var t=this.__eventTargets,e=0,i=t.length;e=0,1620),e=e||0,i=isNaN(i)?cc.macro.REPEAT_FOREVER:i,n=n||0;var r=cc.director.getScheduler(),s=r.isTargetPaused(this);r.schedule(t,this,e,i,n,s)},scheduleOnce:function(t,e){this.schedule(t,0,0,e)},unschedule:function(t){t&&cc.director.getScheduler().unschedule(t,this)},unscheduleAllCallbacks:function(){cc.director.getScheduler().unscheduleAllForTarget(this)}});h._requireComponent=null,h._executionOrder=0,r.value(h,"_registerEditorProps",(function(t,e){var i=e.requireComponent;i&&(t._requireComponent=i);var n=e.executionOrder;n&&"number"==typeof n&&(t._executionOrder=n)})),h.prototype.__scriptUuid="",cc.Component=e.exports=h}),{"../platform/CCObject":162,"../platform/id-generater":172,"../platform/js":176}],66:[(function(t,e,i){cc.Component.EventHandler=cc.Class({name:"cc.ClickEvent",properties:{target:{default:null,type:cc.Node},component:{default:""},handler:{default:""},customEventData:{default:""}},statics:{emitEvents:function(t){"use strict";var e=void 0;if(arguments.length>0)for(var i=0,n=(e=new Array(arguments.length-1)).length;id&&(d=p),D>=d&&(p=d,d=D,g=C.getAnchorPoint().y),this.horizontalDirection===h.RIGHT_TO_LEFT&&(w=1-C.anchorX),f=f+c*w*E+c*this.spacingX;var B=c*(1-w)*E;if(e){var M=f+B+c*(c>0?this.paddingRight:this.paddingLeft),P=this.horizontalDirection===h.LEFT_TO_RIGHT&&M>(1-o.x)*t,I=this.horizontalDirection===h.RIGHT_TO_LEFT&&M<-o.x*t;(P||I)&&(D>=d?(0===p&&(p=d),m+=p,p=d):(m+=d,p=D,d=0),f=_+c*(u+w*E),y++)}var R=i(C,m,y);t>=E+this.paddingLeft+this.paddingRight&&n&&C.setPosition(cc.v2(f,R));var L,O=1,F=0===d?D:d;this.verticalDirection===a.TOP_TO_BOTTOM?(v=v||this.node._contentSize.height,(L=R+(O=-1)*(F*g+this.paddingBottom))v&&(v=L)),f+=B}}return v},_getVerticalBaseHeight:function(t){var e=0,i=0;if(this.resizeMode===s.CONTAINER){for(var n=0;nd&&(d=p),E>=d&&(p=d,d=E,g=C.getAnchorPoint().x),this.verticalDirection===a.TOP_TO_BOTTOM&&(w=1-C.anchorY),f=f+c*w*D+c*this.spacingY;var B=c*(1-w)*D;if(e){var M=f+B+c*(c>0?this.paddingTop:this.paddingBottom),P=this.verticalDirection===a.BOTTOM_TO_TOP&&M>(1-o.y)*t,I=this.verticalDirection===a.TOP_TO_BOTTOM&&M<-o.y*t;(P||I)&&(E>=d?(0===p&&(p=d),m+=p,p=d):(m+=d,p=E,d=0),f=_+c*(u+w*D),y++)}var R=i(C,m,y);t>=D+(this.paddingTop+this.paddingBottom)&&n&&C.setPosition(cc.v2(R,f));var L,O=1,F=0===d?E:d;this.horizontalDirection===h.RIGHT_TO_LEFT?(O=-1,v=v||this.node._contentSize.width,(L=R+O*(F*g+this.paddingLeft))v&&(v=L)),f+=B}}return v},_doLayoutBasic:function(){for(var t=this.node.children,e=null,i=0;i0&&(this._doLayout(),this._layoutDirty=!1)}});Object.defineProperty(l.prototype,"padding",{get:function(){return cc.warnID(4100),this.paddingLeft},set:function(t){this._N$padding=t,this._migratePaddingData(),this._doLayoutDirty()}}),cc.Layout=e.exports=l}),{"../CCNode":28,"./CCComponent":65}],70:[(function(t,e,i){var n=t("../utils/misc"),r=t("../renderer/render-engine"),s=r.math,o=r.StencilMaterial,a=t("./CCRenderComponent"),h=t("../renderer/render-flow"),l=t("../graphics/graphics"),c=t("../CCNode"),u=cc.v2(),_=s.mat4.create(),f=cc.Enum({RECT:0,ELLIPSE:1,IMAGE_STENCIL:2}),m=cc.Class({name:"cc.Mask",extends:a,editor:!1,ctor:function(){this._graphics=null,this._clearGraphics=null},properties:{_spriteFrame:{default:null,type:cc.SpriteFrame},_type:f.RECT,type:{get:function(){return this._type},set:function(t){this._type=t,this._type!==f.IMAGE_STENCIL&&(this.spriteFrame=null,this.alphaThreshold=0,this._updateGraphics()),this._renderData&&(this.destroyRenderData(this._renderData),this._renderData=null),this._activateMaterial()},type:f,tooltip:!1},spriteFrame:{type:cc.SpriteFrame,tooltip:!1,get:function(){return this._spriteFrame},set:function(t){var e=this._spriteFrame;e!==t&&(this._spriteFrame=t,this._applySpriteFrame(e))}},alphaThreshold:{default:0,type:cc.Float,range:[0,1,.1],slide:!0,tooltip:!1,notify:function(){cc.game.renderType!==cc.game.RENDER_TYPE_CANVAS?this._material&&(this._material.alphaThreshold=this.alphaThreshold,this._material.updateHash()):cc.warnID(4201)}},inverted:{default:!1,type:cc.Boolean,tooltip:!1,notify:function(){cc.game.renderType!==cc.game.RENDER_TYPE_CANVAS||cc.warnID(4202)}},_segments:64,segements:{get:function(){return this._segments},set:function(t){this._segments=n.clampf(t,3,1e4)},tooltip:!1},_resizeToTarget:{animatable:!1,set:function(t){t&&this._resizeNodeToTargetNode()}}},statics:{Type:f},onLoad:function(){this._createGraphics()},onRestore:function(){this._createGraphics(),this._type!==f.IMAGE_STENCIL&&this._updateGraphics()},onEnable:function(){this._super(),this._type===f.IMAGE_STENCIL?this._spriteFrame&&this._spriteFrame.textureLoaded()||(this.markForRender(!1),this._spriteFrame&&(this._spriteFrame.once("load",this._onTextureLoaded,this),this._spriteFrame.ensureLoadTexture())):this._updateGraphics(),this.node.on(cc.Node.EventType.POSITION_CHANGED,this._updateGraphics,this),this.node.on(cc.Node.EventType.ROTATION_CHANGED,this._updateGraphics,this),this.node.on(cc.Node.EventType.SCALE_CHANGED,this._updateGraphics,this),this.node.on(cc.Node.EventType.SIZE_CHANGED,this._updateGraphics,this),this.node.on(cc.Node.EventType.ANCHOR_CHANGED,this._updateGraphics,this),this.node._renderFlag|=h.FLAG_POST_RENDER,this._activateMaterial()},onDisable:function(){this._super(),this.node.off(cc.Node.EventType.POSITION_CHANGED,this._updateGraphics,this),this.node.off(cc.Node.EventType.ROTATION_CHANGED,this._updateGraphics,this),this.node.off(cc.Node.EventType.SCALE_CHANGED,this._updateGraphics,this),this.node.off(cc.Node.EventType.SIZE_CHANGED,this._updateGraphics,this),this.node.off(cc.Node.EventType.ANCHOR_CHANGED,this._updateGraphics,this),this.node._renderFlag&=~h.FLAG_POST_RENDER},onDestroy:function(){this._super(),this._removeGraphics()},_resizeNodeToTargetNode:!1,_onTextureLoaded:function(){this._renderData&&(this._renderData.uvDirty=!0,this._renderData.vertDirty=!0,this.markForUpdateRenderData(!0)),this.enabledInHierarchy&&this._activateMaterial()},_applySpriteFrame:function(t){t&&t.off&&t.off("load",this._onTextureLoaded,this);var e=this._spriteFrame;e&&(e.textureLoaded()?this._onTextureLoaded(null):(e.once("load",this._onTextureLoaded,this),e.ensureLoadTexture()))},_activateMaterial:function(){if(this._type!==f.IMAGE_STENCIL||this.spriteFrame&&this.spriteFrame.textureLoaded()){if(cc.game.renderType!==cc.game.RENDER_TYPE_CANVAS)if(this._material||(this._material=new o),this._type===f.IMAGE_STENCIL){var t=this.spriteFrame.getTexture();this._material.useModel=!1,this._material.useTexture=!0,this._material.useColor=!0,this._material.texture=t,this._material.alphaThreshold=this.alphaThreshold}else this._material.useModel=!0,this._material.useTexture=!1,this._material.useColor=!1;this.markForRender(!0)}else this.markForRender(!1)},_createGraphics:function(){this._graphics||(this._graphics=new l,this._graphics.node=this.node,this._graphics.lineWidth=0,this._graphics.strokeColor=cc.color(0,0,0,0)),this._clearGraphics||(this._clearGraphics=new l,this._clearGraphics.node=new c,this._clearGraphics._activateMaterial(),this._clearGraphics.lineWidth=0,this._clearGraphics.rect(0,0,cc.visibleRect.width,cc.visibleRect.height),this._clearGraphics.fill())},_updateGraphics:function(){var t=this.node,e=this._graphics;e.clear(!1);var i=t._contentSize.width,n=t._contentSize.height,r=-i*t._anchorPoint.x,s=-n*t._anchorPoint.y;if(this._type===f.RECT)e.rect(r,s,i,n);else if(this._type===f.ELLIPSE){var o=r+i/2,a=s+n/2,h=i/2,l=n/2;e.ellipse(o,a,h,l)}cc.game.renderType===cc.game.RENDER_TYPE_CANVAS?e.stroke():e.fill()},_removeGraphics:function(){this._graphics&&this._graphics.destroy(),this._clearGraphics&&this._clearGraphics.destroy()},_hitTest:function(t){var e=this.node,i=e.getContentSize(),n=i.width,r=i.height,o=u;if(e._updateWorldMatrix(),s.mat4.invert(_,e._worldMatrix),s.vec2.transformMat4(o,t,_),o.x+=e._anchorPoint.x*n,o.y+=e._anchorPoint.y*r,this.type===f.RECT||this.type===f.IMAGE_STENCIL)return o.x>=0&&o.y>=0&&o.x<=n&&o.y<=r;if(this.type===f.ELLIPSE){var a=n/2,h=r/2,l=o.x-.5*n,c=o.y-.5*r;return l*l/(a*a)+c*c/(h*h)<1}},markForUpdateRenderData:function(t){t&&this.enabledInHierarchy?this.node._renderFlag|=h.FLAG_UPDATE_RENDER_DATA:t||(this.node._renderFlag&=~h.FLAG_UPDATE_RENDER_DATA)},markForRender:function(t){t&&this.enabledInHierarchy?this.node._renderFlag|=h.FLAG_RENDER|h.FLAG_UPDATE_RENDER_DATA|h.FLAG_POST_RENDER:t||(this.node._renderFlag&=~(h.FLAG_RENDER|h.FLAG_POST_RENDER))},disableRender:function(){this.node._renderFlag&=~(h.FLAG_RENDER|h.FLAG_UPDATE_RENDER_DATA|h.FLAG_POST_RENDER)}});cc.Mask=e.exports=m}),{"../CCNode":28,"../graphics/graphics":103,"../renderer/render-engine":198,"../renderer/render-flow":199,"../utils/misc":234,"./CCRenderComponent":75}],71:[(function(t,e,i){var n=t("../components/CCRenderComponent"),r=t("../renderer/render-engine").SpriteMaterial,s=t("../utils/texture-util"),o=cc.Class({name:"cc.MotionStreak",extends:n,editor:!1,ctor:function(){this._points=[]},properties:{preview:{default:!1,editorOnly:!0,notify:!1,animatable:!1},_fadeTime:1,fadeTime:{get:function(){return this._fadeTime},set:function(t){this._fadeTime=t,this.reset()},animatable:!1,tooltip:!1},_minSeg:1,minSeg:{get:function(){return this._minSeg},set:function(t){this._minSeg=t},animatable:!1,tooltip:!1},_stroke:64,stroke:{get:function(){return this._stroke},set:function(t){this._stroke=t},animatable:!1,tooltip:!1},_texture:{default:null,type:cc.Texture2D},texture:{get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t,t&&t.loaded?this._activateMaterial():(this.disableRender(),this._ensureLoadTexture()))},type:cc.Texture2D,animatable:!1,tooltip:!1},_color:cc.Color.WHITE,color:{get:function(){return this._color},set:function(t){this._color=t},type:cc.Color,tooltip:!1},_fastMode:!1,fastMode:{get:function(){return this._fastMode},set:function(t){this._fastMode=t},animatable:!1,tooltip:!1}},onEnable:function(){this._super(),this._texture&&this._texture.loaded?this._activateMaterial():(this.disableRender(),this._ensureLoadTexture()),this.reset()},_ensureLoadTexture:function(){var t=this;this._texture&&!this._texture.loaded&&(function(){var e=t;s.postLoadTexture(t._texture,(function(){e._activateMaterial()}))})()},_activateMaterial:function(){var t=this._material;t||((t=this._material=new r).useColor=!1),this._texture&&this._texture.loaded&&(t.texture=this._texture,this._updateMaterial(t),this.markForRender(!0),this.markForUpdateRenderData(!0))},onFocusInEditor:!1,onLostFocusInEditor:!1,reset:function(){this._points.length=0;var t=this._renderData;t&&(t.dataLength=0,t.vertexCount=0,t.indiceCount=0)}});cc.MotionStreak=e.exports=o}),{"../components/CCRenderComponent":75,"../renderer/render-engine":198,"../utils/texture-util":242}],72:[(function(t,e,i){var n=cc.Enum({Unified:0,Free:1}),r=cc.Enum({Horizontal:0,Vertical:1}),s=cc.Enum({PAGE_TURNING:0}),o=cc.Class({name:"cc.PageView",extends:cc.ScrollView,editor:!1,ctor:function(){this._curPageIdx=0,this._lastPageIdx=0,this._pages=[],this._scrollCenterOffsetX=[],this._scrollCenterOffsetY=[]},properties:{sizeMode:{default:n.Unified,type:n,tooltip:!1,notify:function(){this._syncSizeMode()}},direction:{default:r.Horizontal,type:r,tooltip:!1,notify:function(){this._syncScrollDirection()}},scrollThreshold:{default:.5,type:cc.Float,slide:!0,range:[0,1,.01],tooltip:!1},autoPageTurningThreshold:{default:100,type:cc.Float,tooltip:!1},pageTurningEventTiming:{default:.1,type:cc.Float,range:[0,1,.01],tooltip:!1},indicator:{default:null,type:cc.PageViewIndicator,tooltip:!1,notify:function(){this.indicator&&this.indicator.setPageView(this)}},pageTurningSpeed:{default:.3,type:cc.Float,tooltip:!1},pageEvents:{default:[],type:cc.Component.EventHandler,tooltip:!1}},statics:{SizeMode:n,Direction:r,EventType:s},__preload:function(){this.node.on(cc.Node.EventType.SIZE_CHANGED,this._updateAllPagesSize,this)},onEnable:function(){this._super(),this.node.on("scroll-ended-with-threshold",this._dispatchPageTurningEvent,this)},onDisable:function(){this._super(),this.node.off("scroll-ended-with-threshold",this._dispatchPageTurningEvent,this)},onLoad:function(){this._initPages(),this.indicator&&this.indicator.setPageView(this)},onDestroy:function(){this.node.off(cc.Node.EventType.SIZE_CHANGED,this._updateAllPagesSize,this)},getCurrentPageIndex:function(){return this._curPageIdx},setCurrentPageIndex:function(t){this.scrollToPage(t,!0)},getPages:function(){return this._pages},addPage:function(t){t&&-1===this._pages.indexOf(t)&&this.content&&(this.content.addChild(t),this._pages.push(t),this._updatePageView())},insertPage:function(t,e){e<0||!t||-1!==this._pages.indexOf(t)||!this.content||(e>=this._pages.length?this.addPage(t):(this._pages.splice(e,0,t),this.content.addChild(t),this._updatePageView()))},removePage:function(t){if(t&&this.content){var e=this._pages.indexOf(t);-1!==e?this.removePageAtIndex(e):cc.warnID(4300,t.name)}},removePageAtIndex:function(t){var e=this._pages;if(!(t<0||t>=e.length)){var i=e[t];i&&(this.content.removeChild(i),e.splice(t,1),this._updatePageView())}},removeAllPages:function(){if(this.content){for(var t=this._pages,e=0,i=t.length;e=this._pages.length||(e=void 0!==e?e:.3,this._curPageIdx=t,this.scrollToOffset(this._moveOffsetValue(t),e,!0),this.indicator&&this.indicator._changedState())},getScrollEndedEventTiming:function(){return this.pageTurningEventTiming},_syncScrollDirection:function(){this.horizontal=this.direction===r.Horizontal,this.vertical=this.direction===r.Vertical},_syncSizeMode:function(){if(this.content){var t=this.content.getComponent(cc.Layout);if(t){if(0===this._pages.length)t.padding=0;else{var e=this._pages[this._pages.length-1];this.sizeMode===n.Free&&(this.direction===r.Horizontal?(t.paddingLeft=(this.node.width-this._pages[0].width)/2,t.paddingRight=(this.node.width-e.width)/2):this.direction===r.Vertical&&(t.paddingTop=(this.node.height-this._pages[0].height)/2,t.paddingBottom=(this.node.height-e.height)/2))}t.updateLayout()}}},_updatePageView:function(){var t=this._pages.length;this._curPageIdx>=t&&(this._curPageIdx=0===t?0:t-1,this._lastPageIdx=this._curPageIdx);for(var e=0;e=0||this._pages.push(i)}this._syncScrollDirection(),this._syncSizeMode(),this._updatePageView()}},_dispatchPageTurningEvent:function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,cc.Component.EventHandler.emitEvents(this.pageEvents,this,s.PAGE_TURNING),this.node.emit("page-turning",this))},_isScrollable:function(t,e,i){if(this.sizeMode===n.Free){var s,o;if(this.direction===r.Horizontal)return s=this._scrollCenterOffsetX[e],o=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(s-o)*this.scrollThreshold;if(this.direction===r.Vertical)return s=this._scrollCenterOffsetY[e],o=this._scrollCenterOffsetY[i],Math.abs(t.y)>=Math.abs(s-o)*this.scrollThreshold}else{if(this.direction===r.Horizontal)return Math.abs(t.x)>=this.node.width*this.scrollThreshold;if(this.direction===r.Vertical)return Math.abs(t.y)>=this.node.height*this.scrollThreshold}},_isQuicklyScrollable:function(t){if(this.direction===r.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===r.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},_moveOffsetValue:function(t){var e=cc.v2(0,0);return this.sizeMode===n.Free?this.direction===r.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===r.Vertical&&(e.y=this._scrollCenterOffsetY[t]):this.direction===r.Horizontal?e.x=t*this.node.width:this.direction===r.Vertical&&(e.y=t*this.node.height),e},_getDragDirection:function(t){return this.direction===r.Horizontal?0===t.x?0:t.x>0?1:-1:this.direction===r.Vertical?0===t.y?0:t.y<0?1:-1:void 0},_handleReleaseLogic:function(t){var e=this._startBounceBackIfNeeded(),i=this._touchBeganPosition.sub(this._touchEndPosition);if(e){var n=this._getDragDirection(i);if(0===n)return;this._curPageIdx=n>0?this._pages.length-1:0,this.indicator&&this.indicator._changedState()}else{var r=this._curPageIdx,s=r+this._getDragDirection(i),o=this.pageTurningSpeed*Math.abs(r-s);if(s=t.length)){for(var i=0;it.length)for(i=0;i0;--i){var n=t[i-1];this.node.removeChild(n),t.splice(i-1,1)}this._layout&&this._layout.enabledInHierarchy&&this._layout.updateLayout(),this._changedState()}}}});cc.PageViewIndicator=e.exports=r}),{"./CCComponent":65}],74:[(function(t,e,i){var n=t("../utils/misc"),r=t("./CCComponent"),s=cc.Enum({HORIZONTAL:0,VERTICAL:1,FILLED:2}),o=cc.Class({name:"cc.ProgressBar",extends:r,editor:!1,_initBarSprite:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e=this.node.getContentSize(),i=this.node.getAnchorPoint(),n=t.getContentSize();t.parent===this.node&&this.node.setContentSize(n),this.barSprite.fillType===cc.Sprite.FillType.RADIAL&&(this.mode=s.FILLED);var r=t.getContentSize();if(this.mode===s.HORIZONTAL?this.totalLength=r.width:this.mode===s.VERTICAL?this.totalLength=r.height:this.totalLength=this.barSprite.fillRange,t.parent===this.node){var o=-e.width*i.x;t.setPosition(cc.v2(o,0))}}},_updateBarStatus:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e,i,r,o=t.getAnchorPoint(),a=t.getContentSize(),h=t.getPosition(),l=cc.v2(0,.5),c=n.clamp01(this.progress),u=this.totalLength*c;switch(this.mode){case s.HORIZONTAL:this.reverse&&(l=cc.v2(1,.5)),e=cc.size(u,a.height),i=this.totalLength,r=a.height;break;case s.VERTICAL:l=this.reverse?cc.v2(.5,1):cc.v2(.5,0),e=cc.size(a.width,u),i=a.width,r=this.totalLength}if(this.mode===s.FILLED)this.barSprite.type!==cc.Sprite.Type.FILLED?cc.warn("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"):(this.reverse&&(u*=-1),this.barSprite.fillRange=u);else if(this.barSprite.type!==cc.Sprite.Type.FILLED){var _=l.x-o.x,f=l.y-o.y,m=cc.v2(i*_,r*f);t.setPosition(h.x+m.x,h.y+m.y),t.setAnchorPoint(l),t.setContentSize(e)}else cc.warn("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!")}},properties:{barSprite:{default:null,type:cc.Sprite,tooltip:!1,notify:function(){this._initBarSprite()},animatable:!1},mode:{default:s.HORIZONTAL,type:s,tooltip:!1,notify:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e=t.getContentSize();this.mode===s.HORIZONTAL?this.totalLength=e.width:this.mode===s.VERTICAL?this.totalLength=e.height:this.mode===s.FILLED&&(this.totalLength=this.barSprite.fillRange)}},animatable:!1},_N$totalLength:1,totalLength:{range:[0,Number.MAX_VALUE],tooltip:!1,get:function(){return this._N$totalLength},set:function(t){this.mode===s.FILLED&&(t=n.clamp01(t)),this._N$totalLength=t,this._updateBarStatus()}},progress:{default:1,type:"Float",range:[0,1,.1],slide:!0,tooltip:!1,notify:function(){this._updateBarStatus()}},reverse:{default:!1,tooltip:!1,notify:function(){this.barSprite&&(this.barSprite.fillStart=1-this.barSprite.fillStart),this._updateBarStatus()},animatable:!1}},statics:{Mode:s}});cc.ProgressBar=e.exports=o}),{"../utils/misc":234,"./CCComponent":65}],75:[(function(t,e,i){var n=t("./CCComponent"),r=t("../renderer/render-engine"),s=t("../renderer/render-flow"),o=t("../platform/CCMacro").BlendFactor,a=r.RenderData,h=r.gfx,l=cc.Class({name:"RenderComponent",extends:n,editor:!1,properties:{_srcBlendFactor:o.SRC_ALPHA,_dstBlendFactor:o.ONE_MINUS_SRC_ALPHA,srcBlendFactor:{get:function(){return this._srcBlendFactor},set:function(t){this._srcBlendFactor!==t&&(this._srcBlendFactor=t,this._updateBlendFunc(!0))},animatable:!1,type:o,tooltip:!1},dstBlendFactor:{get:function(){return this._dstBlendFactor},set:function(t){this._dstBlendFactor!==t&&(this._dstBlendFactor=t,this._updateBlendFunc(!0))},animatable:!1,type:o,tooltip:!1}},ctor:function(){this._material=null,this._renderData=null,this.__allocedDatas=[],this._vertexFormat=null,this._toPostHandle=!1,this._assembler=this.constructor._assembler,this._postAssembler=this.constructor._postAssembler},onEnable:function(){this.node._renderComponent&&(this.node._renderComponent.enabled=!1),this.node._renderComponent=this,this.node._renderFlag|=s.FLAG_RENDER|s.FLAG_UPDATE_RENDER_DATA|s.FLAG_COLOR},onDisable:function(){this.node._renderComponent=null,this.disableRender()},onDestroy:function(){for(var t=0,e=this.__allocedDatas.length;tRichText",multiline:!0,tooltip:!1,notify:function(){this._updateRichTextStatus()}},horizontalAlign:{default:a.LEFT,type:a,tooltip:!1,animatable:!1,notify:function(t){this.horizontalAlign!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},fontSize:{default:40,tooltip:!1,notify:function(t){this.fontSize!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},font:{default:null,type:cc.TTFFont,tooltip:!1,notify:function(t){this.font!==t&&(this._layoutDirty=!0,this.font&&this._onTTFLoaded(),this._updateRichTextStatus())}},maxWidth:{default:0,tooltip:!1,notify:function(t){this.maxWidth!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},lineHeight:{default:40,tooltip:!1,notify:function(t){this.lineHeight!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},imageAtlas:{default:null,type:cc.SpriteAtlas,tooltip:!1,notify:function(t){this.imageAtlas!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},handleTouchEvent:{default:!0,tooltip:!1,notify:function(t){this.handleTouchEvent!==t&&this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners())}}},statics:{HorizontalAlign:a,VerticalAlign:h},onEnable:function(){this.handleTouchEvent&&this._addEventListeners(),this._updateRichText(),this._activateChildren(!0)},onDisable:function(){this.handleTouchEvent&&this._removeEventListeners(),this._activateChildren(!1)},start:function(){this._onTTFLoaded()},_addEventListeners:function(){this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this)},_removeEventListeners:function(){this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this)},_updateLabelSegmentTextAttributes:function(){this._labelSegments.forEach(function(t){this._applyTextAttribute(t)}.bind(this))},_createFontLabel:function(t){return l.get(t,this.font,this.fontSize)},_onTTFLoaded:function(){var t=this;this.font instanceof cc.TTFFont?this.font._nativeAsset?(this._layoutDirty=!0,this._updateRichText()):(function(){var e=t;cc.loader.load(t.font.nativeUrl,(function(t,i){e._layoutDirty=!0,e._updateRichText()}))})():(this._layoutDirty=!0,this._updateRichText())},_measureText:function(t,e){var i=this,n=function(e){var n=void 0;return 0===i._labelSegmentsCache.length?(n=i._createFontLabel(e),i._labelSegmentsCache.push(n)):(n=i._labelSegmentsCache[0]).getComponent(cc.Label).string=e,n._styleIndex=t,i._applyTextAttribute(n),n.getContentSize().width};return e?n(e):n},_onTouchEnded:function(t){for(var e=this,i=this.node.getComponents(cc.Component),n=function(n){var r=e._labelSegments[n],s=r._clickHandler;s&&e._containsTouchLocation(r,t.touch.getLocation())&&(i.forEach((function(e){e.enabledInHierarchy&&e[s]&&e[s](t)})),t.stopPropagation())},r=0;r=0;e--){var i=t[e];"RICHTEXT_CHILD"!==i.name&&"RICHTEXT_Image_CHILD"!==i.name||(i.parent===this.node?i.parent=null:t.splice(e,1),"RICHTEXT_CHILD"===i.name&&l.put(i))}this._labelSegments.length=0,this._labelSegmentsCache.length=0,this._linesWidth.length=0,this._lineOffsetX=0,this._lineCount=1,this._labelWidth=0,this._labelHeight=0,this._layoutDirty=!0},onRestore:!1,_activateChildren:function(t){for(var e=this.node.children.length-1;e>=0;e--){var i=this.node.children[e];"RICHTEXT_CHILD"!==i.name&&"RICHTEXT_Image_CHILD"!==i.name||(i.active=t)}},_addLabelSegment:function(t,e){var i=void 0;return 0===this._labelSegmentsCache.length?i=this._createFontLabel(t):(i=this._labelSegmentsCache.pop()).getComponent(cc.Label).string=t,i._styleIndex=e,i._lineCount=this._lineCount,i.setAnchorPoint(0,0),this._applyTextAttribute(i),this.node.addChild(i),this._labelSegments.push(i),i},_updateRichTextWithMaxWidth:function(t,e,i){var n=e;if(this._lineOffsetX>0&&n+this._lineOffsetX>this.maxWidth)for(var r=0;this._lineOffsetX<=this.maxWidth;){var o=this._getFirstWordLen(t,r,t.length),a=t.substr(r,o),h=this._measureText(i,a);if(!(this._lineOffsetX+h<=this.maxWidth)){if(r>0){var l=t.substr(0,r);this._addLabelSegment(l,i),t=t.substr(r,t.length),n=this._measureText(i,t)}this._updateLineInfo();break}this._lineOffsetX+=h,r+=o}if(n>this.maxWidth)for(var c=s.fragmentText(t,n,this.maxWidth,this._measureText(i)),u=0;u1&&u0&&c0&&(a=l),this.maxWidth>0?(this._lineOffsetX+a>this.maxWidth&&this._updateLineInfo(),this._lineOffsetX+=a):(this._lineOffsetX+=a,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),r.spriteFrame=i,n.setContentSize(a,h),n._lineCount=this._lineCount,t.style.event&&t.style.event.click&&(n._clickHandler=t.style.event.click)}else cc.warnID(4400)},_updateRichText:function(){if(this.enabled){var t=o.parse(this.string);if(!this._needsUpdateTextLayout(t))return this._textArray=t,void this._updateLabelSegmentTextAttributes();this._textArray=t,this._resetState();for(var e=!1,i=void 0,n=0;n0){var c=this._measureText(n,l);this._updateRichTextWithMaxWidth(l,c,n),a.length>1&&hthis._labelWidth&&(this._labelWidth=this._lineOffsetX),a.length>1&&h0&&(this._labelWidth=this.maxWidth),this._labelHeight=this._lineCount*this.lineHeight,this.node.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},_getFirstWordLen:function(t,e,i){var n=t.charAt(e);if(s.isUnicodeCJK(n)||s.isUnicodeSpace(n))return 1;for(var r=1,o=e+1;oe&&(t=0,e=s);var o=0;switch(this.horizontalAlign){case a.LEFT:o=-this._labelWidth/2;break;case a.CENTER:o=-this._linesWidth[s-1]/2;break;case a.RIGHT:o=this._labelWidth/2-this._linesWidth[s-1]}r.x=t+o;var h=r.getContentSize();r.y=this.lineHeight*(i-s)-this._labelHeight/2,s===e&&(t+=h.width)}},_convertLiteralColorValue:function(t){var e=t.toUpperCase();return cc.Color[e]?cc.Color[e]:cc.color().fromHEX(t)},_applyTextAttribute:function(t){var e=t.getComponent(cc.Label);if(e){var i=t._styleIndex;e.lineHeight=this.lineHeight,e.horizontalAlign=a.LEFT,e.verticalAlign=h.CENTER;var n=null;if(this._textArray[i]&&(n=this._textArray[i].style),n&&n.color?t.color=this._convertLiteralColorValue(n.color):t.color=this._convertLiteralColorValue("white"),e._enableBold(n&&n.bold),e._enableItalics(n&&n.italic),n&&n.italic&&(t.skewX=12),e._enableUnderline(n&&n.underline),n&&n.outline){var r=t.getComponent(cc.LabelOutline);r||(r=t.addComponent(cc.LabelOutline)),r.color=this._convertLiteralColorValue(n.outline.color),r.width=n.outline.width}n&&n.size?e.fontSize=n.size:e.fontSize=this.fontSize,e._updateRenderData(!0),n&&n.event&&n.event.click&&(t._clickHandler=n.event.click)}},onDestroy:function(){for(var t=0;t0?n:-n)),i*(e/r)},_calculatePosition:function(t,e,i,s,o,a){var h=t-e;o&&(h+=Math.abs(o));var l=0;h&&(l=s/h,l=n.clamp01(l));var c=(i-a)*l;return this.direction===r.VERTICAL?cc.v2(0,c):cc.v2(c,0)},_updateLength:function(t){if(this.handle){var e=this.handle.node,i=e.getContentSize();e.setAnchorPoint(cc.v2(0,0)),this.direction===r.HORIZONTAL?e.setContentSize(t,i.height):e.setContentSize(i.width,t)}},_processAutoHide:function(t){if(this.enableAutoHide&&!(this._autoHideRemainingTime<=0)&&!this._touching&&(this._autoHideRemainingTime-=t,this._autoHideRemainingTime<=this.autoHideTime)){this._autoHideRemainingTime=Math.max(0,this._autoHideRemainingTime);var e=this._opacity*(this._autoHideRemainingTime/this.autoHideTime);this._setOpacity(e)}},start:function(){this.enableAutoHide&&this._setOpacity(0)},hide:function(){this._autoHideRemainingTime=0,this._setOpacity(0)},show:function(){this._autoHideRemainingTime=this.autoHideTime,this._setOpacity(this._opacity)},update:function(t){this._processAutoHide(t)}});cc.Scrollbar=e.exports=s}),{"../utils/misc":234,"./CCComponent":65}],78:[(function(t,e,i){var n=t("../CCNode").EventType,r=function(){return(new Date).getMilliseconds()},s=cc.Enum({SCROLL_TO_TOP:0,SCROLL_TO_BOTTOM:1,SCROLL_TO_LEFT:2,SCROLL_TO_RIGHT:3,SCROLLING:4,BOUNCE_TOP:5,BOUNCE_BOTTOM:6,BOUNCE_LEFT:7,BOUNCE_RIGHT:8,SCROLL_ENDED:9,TOUCH_UP:10,AUTOSCROLL_ENDED_WITH_THRESHOLD:11,SCROLL_BEGAN:12}),o={"scroll-to-top":s.SCROLL_TO_TOP,"scroll-to-bottom":s.SCROLL_TO_BOTTOM,"scroll-to-left":s.SCROLL_TO_LEFT,"scroll-to-right":s.SCROLL_TO_RIGHT,scrolling:s.SCROLLING,"bounce-bottom":s.BOUNCE_BOTTOM,"bounce-left":s.BOUNCE_LEFT,"bounce-right":s.BOUNCE_RIGHT,"bounce-top":s.BOUNCE_TOP,"scroll-ended":s.SCROLL_ENDED,"touch-up":s.TOUCH_UP,"scroll-ended-with-threshold":s.AUTOSCROLL_ENDED_WITH_THRESHOLD,"scroll-began":s.SCROLL_BEGAN},a=cc.Class({name:"cc.ScrollView",extends:t("./CCViewGroup"),editor:!1,ctor:function(){this._topBoundary=0,this._bottomBoundary=0,this._leftBoundary=0,this._rightBoundary=0,this._touchMoveDisplacements=[],this._touchMoveTimeDeltas=[],this._touchMovePreviousTimestamp=0,this._touchMoved=!1,this._autoScrolling=!1,this._autoScrollAttenuate=!1,this._autoScrollStartPosition=cc.v2(0,0),this._autoScrollTargetDelta=cc.v2(0,0),this._autoScrollTotalTime=0,this._autoScrollAccumulatedTime=0,this._autoScrollCurrentlyOutOfBoundary=!1,this._autoScrollBraking=!1,this._autoScrollBrakingStartPosition=cc.v2(0,0),this._outOfBoundaryAmount=cc.v2(0,0),this._outOfBoundaryAmountDirty=!0,this._stopMouseWheel=!1,this._mouseWheelEventElapsedTime=0,this._isScrollEndedWithThresholdEventFired=!1,this._scrollEventEmitMask=0,this._isBouncing=!1,this._scrolling=!1},properties:{content:{default:void 0,type:cc.Node,tooltip:!1,formerlySerializedAs:"content",notify:function(t){this._calculateBoundary()}},horizontal:{default:!0,animatable:!1,tooltip:!1},vertical:{default:!0,animatable:!1,tooltip:!1},inertia:{default:!0,tooltip:!1},brake:{default:.5,type:"Float",range:[0,1,.1],tooltip:!1},elastic:{default:!0,animatable:!1,tooltip:!1},bounceDuration:{default:1,range:[0,10],tooltip:!1},horizontalScrollBar:{default:void 0,type:cc.Scrollbar,tooltip:!1,notify:function(){this.horizontalScrollBar&&(this.horizontalScrollBar.setTargetScrollView(this),this._updateScrollBar(0))},animatable:!1},verticalScrollBar:{default:void 0,type:cc.Scrollbar,tooltip:!1,notify:function(){this.verticalScrollBar&&(this.verticalScrollBar.setTargetScrollView(this),this._updateScrollBar(0))},animatable:!1},scrollEvents:{default:[],type:cc.Component.EventHandler,tooltip:!1},cancelInnerEvents:{default:!0,animatable:!1,tooltip:!1}},statics:{EventType:s},scrollToBottom:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.v2(0,0),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i,!0)},scrollToTop:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.v2(0,1),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.v2(0,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.v2(1,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToTopLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.v2(0,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToTopRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.v2(1,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToBottomLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.v2(0,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToBottomRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.v2(1,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToOffset:function(t,e,i){var n=this.getMaxScrollOffset(),r=cc.v2(0,0);0===n.x?r.x=0:r.x=t.x/n.x,0===n.y?r.y=1:r.y=(n.y-t.y)/n.y,this.scrollTo(r,e,i)},getScrollOffset:function(){var t=this._getContentTopBoundary()-this._topBoundary,e=this._getContentLeftBoundary()-this._leftBoundary;return cc.v2(e,t)},getMaxScrollOffset:function(){var t=this.node.getContentSize(),e=this.content.getContentSize(),i=e.width-t.width,n=e.height-t.height;return i=i>=0?i:0,n=n>=0?n:0,cc.v2(i,n)},scrollToPercentHorizontal:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:cc.v2(t,0),applyToHorizontal:!0,applyToVertical:!1});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},scrollTo:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:cc.v2(t),applyToHorizontal:!0,applyToVertical:!0});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},scrollToPercentVertical:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:cc.v2(0,t),applyToHorizontal:!1,applyToVertical:!0});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},stopAutoScroll:function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},setContentPosition:function(t){t.fuzzyEquals(this.getContentPosition(),1e-4)||(this.content.setPosition(t),this._outOfBoundaryAmountDirty=!0)},getContentPosition:function(){return this.content.getPosition()},isScrolling:function(){return this._scrolling},isAutoScrolling:function(){return this._autoScrolling},_registerEvent:function(){this.node.on(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this,!0),this.node.on(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this,!0),this.node.on(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.on(cc.Node.EventType.MOUSE_WHEEL,this._onMouseWheel,this,!0)},_unregisterEvent:function(){this.node.off(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this,!0),this.node.off(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this,!0),this.node.off(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.off(cc.Node.EventType.MOUSE_WHEEL,this._onMouseWheel,this,!0)},_onMouseWheel:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=cc.v2(0,0),n=-.1;0,this.vertical?i=cc.v2(0,t.getScrollY()*n):this.horizontal&&(i=cc.v2(t.getScrollY()*n,0)),this._mouseWheelEventElapsedTime=0,this._processDeltaMove(i),this._stopMouseWheel||(this._handlePressLogic(),this.schedule(this._checkMouseWheel,1/60),this._stopMouseWheel=!0),this._stopPropagationIfTargetIsMe(t)}},_checkMouseWheel:function(t){if(!this._getHowMuchOutOfBoundary().fuzzyEquals(cc.v2(0,0),1e-4))return this._processInertiaScroll(),this.unschedule(this._checkMouseWheel),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this.unschedule(this._checkMouseWheel),this._stopMouseWheel=!1)},_calculateMovePercentDelta:function(t){var e=t.anchor,i=t.applyToHorizontal,n=t.applyToVertical;this._calculateBoundary(),e=e.clampf(cc.v2(0,0),cc.v2(1,1));var r=this.content.parent.getContentSize(),s=this.content.getContentSize(),o=this._getContentBottomBoundary()-this._bottomBoundary;o=-o;var a=this._getContentLeftBoundary()-this._leftBoundary;a=-a;var h=cc.v2(0,0),l=0;return i&&(l=s.width-r.width,h.x=a-l*e.x),n&&(l=s.height-r.height,h.y=o-l*e.y),h},_moveContentToTopLeft:function(t){var e=this.content.getContentSize(),i=this._getContentBottomBoundary()-this._bottomBoundary;i=-i;var n=cc.v2(0,0),r=0,s=this._getContentLeftBoundary()-this._leftBoundary;s=-s,e.height7&&!this._touchMoved&&t.target!==this.node){var n=new cc.Event.EventTouch(t.getTouches(),t.bubbles);n.type=cc.Node.EventType.TOUCH_CANCEL,n.touch=t.touch,n.simulate=!0,t.target.dispatchEvent(n),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(t)}}},_onTouchEnded:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){this._dispatchEvent("touch-up");var i=t.touch;this.content&&this._handleReleaseLogic(i),this._touchMoved?t.stopPropagation():this._stopPropagationIfTargetIsMe(t)}},_onTouchCancelled:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){if(!t.simulate){var i=t.touch;this.content&&this._handleReleaseLogic(i)}this._stopPropagationIfTargetIsMe(t)}},_processDeltaMove:function(t){this._scrollChildren(t),this._gatherTouchMove(t)},_handleMoveLogic:function(t){var e=t.getDelta();this._processDeltaMove(e)},_scrollChildren:function(t){var e=t=this._clampDelta(t),i=void 0;this.elastic&&(i=this._getHowMuchOutOfBoundary(),e.x*=0===i.x?1:.5,e.y*=0===i.y?1:.5),this.elastic||(i=this._getHowMuchOutOfBoundary(e),e=e.add(i));var n=-1;if(e.y>0)this.content.y-this.content.anchorY*this.content.height+e.y>this._bottomBoundary&&(n="scroll-to-bottom");else if(e.y<0){this.content.y-this.content.anchorY*this.content.height+this.content.height+e.y<=this._topBoundary&&(n="scroll-to-top")}else if(e.x<0){this.content.x-this.content.anchorX*this.content.width+this.content.width+e.x<=this._rightBoundary&&(n="scroll-to-right")}else if(e.x>0){this.content.x-this.content.anchorX*this.content.width+e.x>=this._leftBoundary&&(n="scroll-to-left")}this._moveContent(e,!1),0===e.x&&0===e.y||(this._scrolling||(this._scrolling=!0,this._dispatchEvent("scroll-began")),this._dispatchEvent("scrolling")),-1!==n&&this._dispatchEvent(n)},_handlePressLogic:function(){this._autoScrolling&&this._dispatchEvent("scroll-ended"),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=r(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},_clampDelta:function(t){var e=this.content.getContentSize(),i=this.node.getContentSize();return e.width=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(t);var e=r();this._touchMoveTimeDeltas.push((e-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=e},_startBounceBackIfNeeded:function(){if(!this.elastic)return!1;var t=this._getHowMuchOutOfBoundary();if((t=this._clampDelta(t)).fuzzyEquals(cc.v2(0,0),1e-4))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent("bounce-top"),t.y<0&&this._dispatchEvent("bounce-bottom"),t.x>0&&this._dispatchEvent("bounce-right"),t.x<0&&this._dispatchEvent("bounce-left"),this._isBouncing=!0),!0},_processInertiaScroll:function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!t.fuzzyEquals(cc.v2(0,0),1e-4)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},_handleReleaseLogic:function(t){var e=t.getDelta();this._gatherTouchMove(e),this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent("scroll-ended"))},_isOutOfBoundary:function(){return!this._getHowMuchOutOfBoundary().fuzzyEquals(cc.v2(0,0),1e-4)},_isNecessaryAutoScrollBrake:function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,this._autoScrollBrakingStartPosition=this.getContentPosition(),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},getScrollEndedEventTiming:function(){return 1e-4},_processAutoScrolling:function(t){var e=this._isNecessaryAutoScrollBrake(),i=e?.05:1;this._autoScrollAccumulatedTime+=t*(1/i);var n=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(n=(function(t){return(t-=1)*t*t*t*t+1})(n));var r=this._autoScrollStartPosition.add(this._autoScrollTargetDelta.mul(n)),s=Math.abs(n-1)<=1e-4;if(Math.abs(n-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent("scroll-ended-with-threshold"),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var o=r.sub(this._autoScrollBrakingStartPosition);e&&(o=o.mul(i)),r=this._autoScrollBrakingStartPosition.add(o)}else{var a=r.sub(this.getContentPosition()),h=this._getHowMuchOutOfBoundary(a);h.fuzzyEquals(cc.v2(0,0),1e-4)||(r=r.add(h),s=!0)}s&&(this._autoScrolling=!1);var l=r.sub(this.getContentPosition());this._moveContent(this._clampDelta(l),s),this._dispatchEvent("scrolling"),this._autoScrolling||(this._isBouncing=!1,this._dispatchEvent("scroll-ended"))},_startInertiaScroll:function(t){var e=t.mul(.7);this._startAttenuatingAutoScroll(e,t)},_calculateAttenuatedFactor:function(t){return this.brake<=0?1-this.brake:(1-this.brake)*(1/(1+14e-6*t+t*t*8e-9))},_startAttenuatingAutoScroll:function(t,e){var i=this._calculateAutoScrollTimeByInitalSpeed(e.mag()),n=t.normalize(),r=this.content.getContentSize(),s=this.node.getContentSize(),o=r.width-s.width,a=r.height-s.height,h=this._calculateAttenuatedFactor(o),l=this._calculateAttenuatedFactor(a);n=cc.v2(n.x*o*(1-this.brake)*h,n.y*a*l*(1-this.brake));var c=t.mag(),u=n.mag()/c;n=n.add(t),this.brake>0&&u>7&&(u=Math.sqrt(u),n=t.mul(u).add(t)),this.brake>0&&u>3&&(i*=u=3),0===this.brake&&u>1&&(i*=u),this._startAutoScroll(n,i,!0)},_calculateAutoScrollTimeByInitalSpeed:function(t){return Math.sqrt(Math.sqrt(t/5))},_startAutoScroll:function(t,e,i){var n=this._flattenVectorByDirection(t);this._autoScrolling=!0,this._autoScrollTargetDelta=n,this._autoScrollAttenuate=i,this._autoScrollStartPosition=this.getContentPosition(),this._autoScrollTotalTime=e,this._autoScrollAccumulatedTime=0,this._autoScrollBraking=!1,this._isScrollEndedWithThresholdEventFired=!1,this._autoScrollBrakingStartPosition=cc.v2(0,0),this._getHowMuchOutOfBoundary().fuzzyEquals(cc.v2(0,0),1e-4)||(this._autoScrollCurrentlyOutOfBoundary=!0)},_calculateTouchMoveVelocity:function(){var t=0;if((t=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),t))<=0||t>=.5)return cc.v2(0,0);var e=cc.v2(0,0);return e=this._touchMoveDisplacements.reduce((function(t,e){return t.add(e)}),e),cc.v2(e.x*(1-this.brake)/t,e.y*(1-this.brake)/t)},_flattenVectorByDirection:function(t){var e=t;return e.x=this.horizontal?e.x:0,e.y=this.vertical?e.y:0,e},_moveContent:function(t,e){var i=this._flattenVectorByDirection(t),n=this.getContentPosition().add(i);this.setContentPosition(n);var r=this._getHowMuchOutOfBoundary();this._updateScrollBar(r),this.elastic&&e&&this._startBounceBackIfNeeded()},_getContentLeftBoundary:function(){return this.getContentPosition().x-this.content.getAnchorPoint().x*this.content.getContentSize().width},_getContentRightBoundary:function(){var t=this.content.getContentSize();return this._getContentLeftBoundary()+t.width},_getContentTopBoundary:function(){var t=this.content.getContentSize();return this._getContentBottomBoundary()+t.height},_getContentBottomBoundary:function(){return this.getContentPosition().y-this.content.getAnchorPoint().y*this.content.getContentSize().height},_getHowMuchOutOfBoundary:function(t){if((t=t||cc.v2(0,0)).fuzzyEquals(cc.v2(0,0),1e-4)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=cc.v2(0,0);return this._getContentLeftBoundary()+t.x>this._leftBoundary?e.x=this._leftBoundary-(this._getContentLeftBoundary()+t.x):this._getContentRightBoundary()+t.xthis._bottomBoundary&&(e.y=this._bottomBoundary-(this._getContentBottomBoundary()+t.y)),t.fuzzyEquals(cc.v2(0,0),1e-4)&&(this._outOfBoundaryAmount=e,this._outOfBoundaryAmountDirty=!1),e=this._clampDelta(e)},_updateScrollBar:function(t){this.horizontalScrollBar&&this.horizontalScrollBar._onScroll(t),this.verticalScrollBar&&this.verticalScrollBar._onScroll(t)},_onScrollBarTouchBegan:function(){this.horizontalScrollBar&&this.horizontalScrollBar._onTouchBegan(),this.verticalScrollBar&&this.verticalScrollBar._onTouchBegan()},_onScrollBarTouchEnded:function(){this.horizontalScrollBar&&this.horizontalScrollBar._onTouchEnded(),this.verticalScrollBar&&this.verticalScrollBar._onTouchEnded()},_dispatchEvent:function(t){if("scroll-ended"===t)this._scrollEventEmitMask=0;else if("scroll-to-top"===t||"scroll-to-bottom"===t||"scroll-to-left"===t||"scroll-to-right"===t){var e=1<0&&t[0].check()}},onEnable:function(){this.node.on("child-added",this._allowOnlyOneToggleChecked,this),this.node.on("child-removed",this._makeAtLeastOneToggleChecked,this)},onDisable:function(){this.node.off("child-added",this._allowOnlyOneToggleChecked,this),this.node.off("child-removed",this._makeAtLeastOneToggleChecked,this)},start:function(){this._makeAtLeastOneToggleChecked()}});t("../platform/js").get(n.prototype,"toggleItems",(function(){return this.node.getComponentsInChildren(cc.Toggle)})),cc.ToggleContainer=e.exports=n}),{"../platform/js":176}],84:[(function(t,e,i){var n=cc.Class({name:"cc.ToggleGroup",extends:cc.Component,ctor:function(){this._toggleItems=[]},editor:!1,properties:{allowSwitchOff:{tooltip:!1,default:!1},toggleItems:{get:function(){return this._toggleItems}}},updateToggles:function(t){this.enabledInHierarchy&&this._toggleItems.forEach((function(e){t.isChecked&&e!==t&&e.isChecked&&e.enabled&&(e.isChecked=!1)}))},addToggle:function(t){-1===this._toggleItems.indexOf(t)&&this._toggleItems.push(t),this._allowOnlyOneToggleChecked()},removeToggle:function(t){var e=this._toggleItems.indexOf(t);e>-1&&this._toggleItems.splice(e,1),this._makeAtLeastOneToggleChecked()},_allowOnlyOneToggleChecked:function(){var t=!1;return this._toggleItems.forEach((function(e){t&&e.enabled&&(e.isChecked=!1),e.isChecked&&e.enabled&&(t=!0)})),t},_makeAtLeastOneToggleChecked:function(){this._allowOnlyOneToggleChecked()||this.allowSwitchOff||this._toggleItems.length>0&&(this._toggleItems[0].isChecked=!0)},start:function(){this._makeAtLeastOneToggleChecked()}}),r=!1;t("../platform/js").get(cc,"ToggleGroup",(function(){return r||(cc.logID(1405,"cc.ToggleGroup","cc.ToggleContainer"),r=!0),n})),e.exports=n}),{"../platform/js":176}],85:[(function(t,e,i){var n=cc.Class({name:"cc.ViewGroup",extends:t("./CCComponent")});cc.ViewGroup=e.exports=n}),{"./CCComponent":65}],86:[(function(t,e,i){var n=t("../base-ui/CCWidgetManager"),r=n.AlignMode,s=n._AlignFlags,o=s.TOP,a=s.MID,h=s.BOT,l=s.LEFT,c=s.CENTER,u=s.RIGHT,_=o|h,f=l|u,m=cc.Class({name:"cc.Widget",extends:t("./CCComponent"),editor:!1,properties:{target:{get:function(){return this._target},set:function(t){this._target=t},type:cc.Node,tooltip:!1},isAlignTop:{get:function(){return(this._alignFlags&o)>0},set:function(t){this._setAlign(o,t)},animatable:!1,tooltip:!1},isAlignVerticalCenter:{get:function(){return(this._alignFlags&a)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=a):this._alignFlags&=~a},animatable:!1,tooltip:!1},isAlignBottom:{get:function(){return(this._alignFlags&h)>0},set:function(t){this._setAlign(h,t)},animatable:!1,tooltip:!1},isAlignLeft:{get:function(){return(this._alignFlags&l)>0},set:function(t){this._setAlign(l,t)},animatable:!1,tooltip:!1},isAlignHorizontalCenter:{get:function(){return(this._alignFlags&c)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=c):this._alignFlags&=~c},animatable:!1,tooltip:!1},isAlignRight:{get:function(){return(this._alignFlags&u)>0},set:function(t){this._setAlign(u,t)},animatable:!1,tooltip:!1},isStretchWidth:{get:function(){return(this._alignFlags&f)===f},visible:!1},isStretchHeight:{get:function(){return(this._alignFlags&_)===_},visible:!1},top:{get:function(){return this._top},set:function(t){this._top=t},tooltip:!1},bottom:{get:function(){return this._bottom},set:function(t){this._bottom=t},tooltip:!1},left:{get:function(){return this._left},set:function(t){this._left=t},tooltip:!1},right:{get:function(){return this._right},set:function(t){this._right=t},tooltip:!1},horizontalCenter:{get:function(){return this._horizontalCenter},set:function(t){this._horizontalCenter=t},tooltip:!1},verticalCenter:{get:function(){return this._verticalCenter},set:function(t){this._verticalCenter=t},tooltip:!1},isAbsoluteHorizontalCenter:{get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter=t},animatable:!1},isAbsoluteVerticalCenter:{get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter=t},animatable:!1},isAbsoluteTop:{get:function(){return this._isAbsTop},set:function(t){this._isAbsTop=t},animatable:!1},isAbsoluteBottom:{get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom=t},animatable:!1},isAbsoluteLeft:{get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft=t},animatable:!1},isAbsoluteRight:{get:function(){return this._isAbsRight},set:function(t){this._isAbsRight=t},animatable:!1},alignMode:{default:r.ON_WINDOW_RESIZE,type:r,tooltip:!1},_wasAlignOnce:{default:void 0,formerlySerializedAs:"isAlignOnce"},_target:null,_alignFlags:0,_left:0,_right:0,_top:0,_bottom:0,_verticalCenter:0,_horizontalCenter:0,_isAbsLeft:!0,_isAbsRight:!0,_isAbsTop:!0,_isAbsBottom:!0,_isAbsHorizontalCenter:!0,_isAbsVerticalCenter:!0,_originalWidth:0,_originalHeight:0},statics:{AlignMode:r},onLoad:function(){void 0!==this._wasAlignOnce&&(this.alignMode=this._wasAlignOnce?r.ONCE:r.ALWAYS,this._wasAlignOnce=void 0)},onEnable:function(){n.add(this)},onDisable:function(){n.remove(this)},_validateTargetInDEV:!1,_setAlign:function(t,e){if(e!==(this._alignFlags&t)>0){var i=(t&f)>0;e?(this._alignFlags|=t,i?(this.isAlignHorizontalCenter=!1,this.isStretchWidth&&(this._originalWidth=this.node.width)):(this.isAlignVerticalCenter=!1,this.isStretchHeight&&(this._originalHeight=this.node.height))):(i?this.isStretchWidth&&(this.node.width=this._originalWidth):this.isStretchHeight&&(this.node.height=this._originalHeight),this._alignFlags&=~t)}},updateAlignment:function(){n.updateAlignment(this.node)}});Object.defineProperty(m.prototype,"isAlignOnce",{get:function(){return this.alignMode===r.ONCE},set:function(t){this.alignMode=t?r.ONCE:r.ALWAYS}}),cc.Widget=e.exports=m}),{"../base-ui/CCWidgetManager":49,"./CCComponent":65}],87:[(function(t,e,i){var n=t("./CCComponent"),r=void 0;r=cc.Class({name:"cc.WXSubContextView",extends:n}),cc.WXSubContextView=e.exports=r}),{"./CCComponent":65}],88:[(function(t,e,i){var n=t("../../platform/CCMacro"),r=t("../editbox/CCEditBoxImpl"),s=t("../CCLabel"),o=t("./types"),a=o.InputMode,h=o.InputFlag,l=o.KeyboardReturnType;var c=cc.Class({name:"cc.EditBox",extends:cc.Component,editor:!1,properties:{_useOriginalSize:!0,_string:"",string:{tooltip:!1,get:function(){return this._string},set:function(t){this.maxLength>=0&&t.length>=this.maxLength&&(t=t.slice(0,this.maxLength)),this._string=t,this._impl&&this._updateString(t)}},backgroundImage:{tooltip:!1,default:null,type:cc.SpriteFrame,notify:function(){this._createBackgroundSprite()}},returnType:{default:l.DEFAULT,tooltip:!1,displayName:"KeyboardReturnType",type:l,notify:function(){this._impl&&(this._impl.returnType=this.returnType)}},inputFlag:{tooltip:!1,default:h.DEFAULT,type:h,notify:function(){this._impl&&(this._impl.setInputFlag(this.inputFlag),this._updateString(this._string))}},inputMode:{tooltip:!1,default:a.ANY,type:a,notify:function(){this._impl&&this._impl.setInputMode(this.inputMode)}},fontSize:{tooltip:!1,default:20,notify:function(){this._textLabel&&(this._textLabel.fontSize=this.fontSize),this._impl&&this._impl.setFontSize(this.fontSize)}},lineHeight:{tooltip:!1,default:40,notify:function(){this._textLabel&&(this._textLabel.lineHeight=this.lineHeight)}},fontColor:{tooltip:!1,default:cc.Color.WHITE,notify:function(){this._textLabel&&(this._textLabel.node.opacity=this.fontColor.a,this._textLabel.node.color=this.fontColor),this._impl&&this._impl.setFontColor(this.fontColor)}},placeholder:{tooltip:!1,default:"Enter text here...",notify:function(){this._placeholderLabel&&(this._placeholderLabel.string=this.placeholder),this._impl&&this._impl.setPlaceholderText(this.placeholder)}},placeholderFontSize:{tooltip:!1,default:20,notify:function(){this._placeholderLabel&&(this._placeholderLabel.fontSize=this.placeholderFontSize)}},placeholderFontColor:{tooltip:!1,default:cc.Color.GRAY,notify:function(){this._placeholderLabel&&(this._placeholderLabel.node.color=this.placeholderFontColor,this._placeholderLabel.node.opacity=this.placeholderFontColor.a)}},maxLength:{tooltip:!1,default:20,notify:function(){this._impl&&this._impl.setMaxLength(this.maxLength)}},stayOnTop:{tooltip:!1,default:!1,notify:function(){this._impl&&this._updateStayOnTop()}},_tabIndex:0,tabIndex:{tooltip:!1,get:function(){return this._tabIndex},set:function(t){this._tabIndex=t,this._impl&&this._impl.setTabIndex(t)}},editingDidBegan:{default:[],type:cc.Component.EventHandler},textChanged:{default:[],type:cc.Component.EventHandler},editingDidEnded:{default:[],type:cc.Component.EventHandler},editingReturn:{default:[],type:cc.Component.EventHandler}},statics:{_EditBoxImpl:r,KeyboardReturnType:l,InputFlag:h,InputMode:a},_init:function(){this._createBackgroundSprite(),this._createLabels(),this.node.on(cc.Node.EventType.SIZE_CHANGED,this._resizeChildNodes,this);var t=this._impl=new r;t.setDelegate(this),t.setNode(this.node),t.setInputMode(this.inputMode),t.setMaxLength(this.maxLength),t.setInputFlag(this.inputFlag),t.setReturnType(this.returnType),t.setTabIndex(this.tabIndex),t.setFontColor(this.fontColor),t.setFontSize(this.fontSize),t.setPlaceholderText(this.placeholder),this._updateStayOnTop(),this._updateString(this.string),this._syncSize()},_updateStayOnTop:function(){this.stayOnTop?this._hideLabels():this._showLabels(),this._impl.stayOnTop(this.stayOnTop)},_syncSize:function(){var t=this.node.getContentSize();this._background.node.setAnchorPoint(this.node.getAnchorPoint()),this._background.node.setContentSize(t),this._updateLabelPosition(t),this._impl.setSize(t.width,t.height)},_updateLabelPosition:function(t){var e=this.node,i=-e.anchorX*e.width,r=-e.anchorY*e.height,s=this._placeholderLabel,o=this._textLabel;o.node.setContentSize(t.width-2,t.height),s.node.setContentSize(t.width-2,t.height),s.lineHeight=t.height,s.node.setPosition(i+2,r+t.height),o.node.setPosition(i+2,r+t.height),this.inputMode===a.ANY?(s.verticalAlign=n.VerticalTextAlignment.TOP,s.enableWrapText=!0,o.verticalAlign=n.VerticalTextAlignment.TOP,o.enableWrapText=!0):(s.verticalAlign=n.VerticalTextAlignment.CENTER,s.enableWrapText=!1,o.verticalAlign=n.VerticalTextAlignment.CENTER,o.enableWrapText=!1)},_createBackgroundSprite:function(){var t=this._background;if(!t){var e=this.node.getChildByName("BACKGROUND_SPRITE");e||(e=new cc.Node("BACKGROUND_SPRITE")),(t=e.getComponent(cc.Sprite))||(t=e.addComponent(cc.Sprite)),t.type=cc.Sprite.Type.SLICED,e.parent=this.node,this._background=t}t.spriteFrame=this.backgroundImage},_createLabels:function(){if(!this._textLabel){var t=this.node.getChildByName("TEXT_LABEL");t||(t=new cc.Node("TEXT_LABEL")),t.color=this.fontColor,t.parent=this.node,t.setAnchorPoint(0,1);var e=t.getComponent(s);e||(e=t.addComponent(s)),e.overflow=s.Overflow.CLAMP,e.fontSize=this.fontSize,e.lineHeight=this.lineHeight,this._textLabel=e}if(!this._placeholderLabel){var i=this.node.getChildByName("PLACEHOLDER_LABEL");i||(i=new cc.Node("PLACEHOLDER_LABEL")),i.color=this.placeholderFontColor,i.parent=this.node,i.setAnchorPoint(0,1);var n=i.getComponent(s);n||(n=i.addComponent(s)),n.overflow=s.Overflow.CLAMP,n.fontSize=this.placeholderFontSize,n.string=this.placeholder,this._placeholderLabel=n}},_resizeChildNodes:function(){var t=this._textLabel.node,e=this._placeholderLabel.node,i=this._background.node;t.x=-this.node.width/2,t.y=this.node.height/2,t.width=this.node.width,t.height=this.node.height,e.x=-this.node.width/2,e.y=this.node.height/2,e.width=this.node.width,e.height=this.node.height,i.width=this.node.width,i.height=this.node.height},_showLabels:function(){var t=this._textLabel.string;this._textLabel.node.active=""!==t,this._placeholderLabel.node.active=""===t},_hideLabels:function(){this._textLabel.node.active=!1,this._placeholderLabel.node.active=!1},_updateString:function(t){var e=this._textLabel;if(e){var i=t;i&&(i=this._updateLabelStringStyle(i)),e.string=i,this._impl.setString(t),this._impl._editing||this.stayOnTop||this._showLabels()}},_updateLabelStringStyle:function(t,e){var i=this.inputFlag;if(e||i!==h.PASSWORD)i===h.INITIAL_CAPS_ALL_CHARACTERS?t=t.toUpperCase():i===h.INITIAL_CAPS_WORD?t=(function(t){return t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()}))})(t):i===h.INITIAL_CAPS_SENTENCE&&(t=(function(t){return t.charAt(0).toUpperCase()+t.slice(1)})(t));else{for(var n="",r=t.length,s=0;se&&(i=.7),setTimeout((function(){if(window.scrollY<40&&t320&&(n=320),window.scrollTo(0,n)}}),400)}}),p=d.prototype;function y(t,e){t.value.length>e._maxLength&&(t.value=t.value.slice(0,e._maxLength)),e._delegate&&e._delegate.editBoxTextChanged&&e._text!==t.value&&(e._text=t.value,e._delegate.editBoxTextChanged(e._text))}function v(t,e,i){var n=!1,s=e.__eventListeners;s.compositionstart=function(){n=!0},t.addEventListener("compositionstart",s.compositionstart),s.compositionend=function(){n=!1,y(this,e)},t.addEventListener("compositionend",s.compositionend),s.input=function(){n||y(this,e)},t.addEventListener("input",s.input),s.focus=function(){this.style.fontSize=e._edFontSize+"px",this.style.color=e._textColor.toCSS("rgba"),e._alwaysOnTop&&(e._editing=!0),cc.sys.isMobile&&e._beginEditingOnMobile(),e._delegate&&e._delegate.editBoxEditingDidBegan&&e._delegate.editBoxEditingDidBegan()},t.addEventListener("focus",s.focus),s.keypress=function(t){t.keyCode===r.KEY.enter&&(t.stopPropagation(),e._delegate&&e._delegate.editBoxEditingReturn&&e._delegate.editBoxEditingReturn(),i||(e._text=this.value,e._endEditing(),cc.game.canvas.focus()))},t.addEventListener("keypress",s.keypress),s.blur=function(){e._text=this.value,e._endEditing()},t.addEventListener("blur",s.blur),e._addDomToGameContainer()}p.createInput=function(){this._inputMode===o.ANY?this._createDomTextArea():this._createDomInput()},p._beginEditingOnMobile=function(){var t=this;this.__orientationChanged=function(){t._adjustEditBoxPosition()},window.addEventListener("orientationchange",this.__orientationChanged),cc.view.isAutoFullScreenEnabled()?(this.__fullscreen=!0,cc.view.enableAutoFullScreen(!1),cc.screen.exitFullScreen()):this.__fullscreen=!1,this.__autoResize=cc.view._resizeWithBrowserSize,cc.view.resizeWithBrowserSize(!1),f=this},p._endEditingOnMobile=function(){if(this.__rotateScreen){cc.game.container.style["-webkit-transform"]="rotate(90deg)",cc.game.container.style.transform="rotate(90deg)";var t=cc.view,e=t._originalDesignResolutionSize.width,i=t._originalDesignResolutionSize.height;e>0&&t.setDesignResolutionSize(e,i,t._resolutionPolicy),this.__rotateScreen=!1}window.removeEventListener("orientationchange",this.__orientationChanged),this.__fullscreen&&cc.view.enableAutoFullScreen(!0),this.__autoResize&&f===this&&cc.view.resizeWithBrowserSize(!0)},p._createDomInput=function(){this.removeDom();var t=this._edTxt=document.createElement("input");return t.type="text",t.style.fontSize=this._edFontSize+"px",t.style.color="#000000",t.style.border=0,t.style.background="transparent",t.style.width="100%",t.style.height="100%",t.style.active=0,t.style.outline="medium",t.style.padding="0",t.style.textTransform="uppercase",t.style.display="none",t.style.position="absolute",t.style.bottom="0px",t.style.left="2px",t.style["-moz-appearance"]="textfield",t.style.className="cocosEditBox",t.style.fontFamily="Arial",v(t,this),t},p._createDomTextArea=function(){this.removeDom();var t=this._edTxt=document.createElement("textarea");return t.type="text",t.style.fontSize=this._edFontSize+"px",t.style.color="#000000",t.style.border=0,t.style.background="transparent",t.style.width="100%",t.style.height="100%",t.style.active=0,t.style.outline="medium",t.style.padding="0",t.style.resize="none",t.style.textTransform="uppercase",t.style.overflow_y="scroll",t.style.display="none",t.style.position="absolute",t.style.bottom="0px",t.style.left="2px",t.style.className="cocosEditBox",t.style.fontFamily="Arial",v(t,this,!0),t},p._addDomToGameContainer=function(){cc.game.container.appendChild(this._edTxt)},p.removeDom=function(){var t=this._edTxt;if(t){var e=this.__eventListeners;t.removeEventListener("compositionstart",e.compositionstart),t.removeEventListener("compositionend",e.compositionend),t.removeEventListener("input",e.input),t.removeEventListener("focus",e.focus),t.removeEventListener("keypress",e.keypress),t.removeEventListener("blur",e.blur),e.compositionstart=null,e.compositionend=null,e.input=null,e.focus=null,e.keypress=null,e.blur=null,n.contains(cc.game.container,t)&&cc.game.container.removeChild(t)}this._edTxt=null},e.exports=d}),{"../../platform/CCMacro":161,"../../platform/utils":180,"./types":90}],90:[(function(t,e,i){var n=cc.Enum({DEFAULT:0,DONE:1,SEND:2,SEARCH:3,GO:4,NEXT:5}),r=cc.Enum({ANY:0,EMAIL_ADDR:1,NUMERIC:2,PHONE_NUMBER:3,URL:4,DECIMAL:5,SINGLE_LINE:6}),s=cc.Enum({PASSWORD:0,SENSITIVE:1,INITIAL_CAPS_WORD:2,INITIAL_CAPS_SENTENCE:3,INITIAL_CAPS_ALL_CHARACTERS:4,DEFAULT:5});e.exports={KeyboardReturnType:n,InputMode:r,InputFlag:s}}),{}],91:[(function(t,e,i){t("./CCComponent"),t("./CCComponentEventHandler"),t("./missing-script");var n=[t("./CCSprite"),t("./CCWidget"),t("./CCCanvas"),t("./CCAudioSource"),t("./CCAnimation"),t("./CCButton"),t("./CCLabel"),t("./CCProgressBar"),t("./CCMask"),t("./CCScrollBar"),t("./CCScrollView"),t("./CCPageViewIndicator"),t("./CCPageView"),t("./CCSlider"),t("./CCLayout"),t("./editbox/CCEditBox"),t("./CCLabelOutline"),t("./CCRichText"),t("./CCToggleContainer"),t("./CCToggleGroup"),t("./CCToggle"),t("./CCBlockInputEvents"),t("./CCMotionStreak"),t("./WXSubContextView")];e.exports=n}),{"./CCAnimation":60,"./CCAudioSource":61,"./CCBlockInputEvents":62,"./CCButton":63,"./CCCanvas":64,"./CCComponent":65,"./CCComponentEventHandler":66,"./CCLabel":67,"./CCLabelOutline":68,"./CCLayout":69,"./CCMask":70,"./CCMotionStreak":71,"./CCPageView":72,"./CCPageViewIndicator":73,"./CCProgressBar":74,"./CCRichText":76,"./CCScrollBar":77,"./CCScrollView":78,"./CCSlider":79,"./CCSprite":80,"./CCToggle":82,"./CCToggleContainer":83,"./CCToggleGroup":84,"./CCWidget":86,"./WXSubContextView":87,"./editbox/CCEditBox":88,"./missing-script":92}],92:[(function(t,e,i){var n=cc.js,r=t("../utils/misc").BUILTIN_CLASSID_RE,s=cc.Class({name:"cc.MissingClass",properties:{_$erialized:{default:null,visible:!1,editorOnly:!0}}}),o=cc.Class({name:"cc.MissingScript",extends:cc.Component,editor:{inspector:"packages://inspector/inspectors/comps/missing-script.js"},properties:{compiled:{default:!1,serializable:!1},_$erialized:{default:null,visible:!1,editorOnly:!0}},ctor:!1,statics:{safeFindClass:function(t,e){var i=n._getClassById(t);return i||(t?(cc.deserialize.reportMissingClass(t),o.getMissingWrapper(t,e)):null)},getMissingWrapper:function(t,e){return e.node&&(/^[0-9a-zA-Z+/]{23}$/.test(t)||r.test(t))?o:s}},onLoad:function(){cc.warnID(4600,this.node.name)}});cc._MissingScript=e.exports=o}),{"../utils/misc":234}],93:[(function(t,e,i){var n=cc.js;t("../event/event");var r=function(t,e){cc.Event.call(this,cc.Event.MOUSE,e),this._eventType=t,this._button=0,this._x=0,this._y=0,this._prevX=0,this._prevY=0,this._scrollX=0,this._scrollY=0};n.extend(r,cc.Event);var s=r.prototype;s.setScrollData=function(t,e){this._scrollX=t,this._scrollY=e},s.getScrollX=function(){return this._scrollX},s.getScrollY=function(){return this._scrollY},s.setLocation=function(t,e){this._x=t,this._y=e},s.getLocation=function(){return cc.v2(this._x,this._y)},s.getLocationInView=function(){return cc.v2(this._x,cc.view._designResolutionSize.height-this._y)},s._setPrevCursor=function(t,e){this._prevX=t,this._prevY=e},s.getPreviousLocation=function(){return cc.v2(this._prevX,this._prevY)},s.getDelta=function(){return cc.v2(this._x-this._prevX,this._y-this._prevY)},s.getDeltaX=function(){return this._x-this._prevX},s.getDeltaY=function(){return this._y-this._prevY},s.setButton=function(t){this._button=t},s.getButton=function(){return this._button},s.getLocationX=function(){return this._x},s.getLocationY=function(){return this._y},r.NONE=0,r.DOWN=1,r.UP=2,r.MOVE=3,r.SCROLL=4,r.BUTTON_LEFT=0,r.BUTTON_RIGHT=2,r.BUTTON_MIDDLE=1,r.BUTTON_4=3,r.BUTTON_5=4,r.BUTTON_6=5,r.BUTTON_7=6,r.BUTTON_8=7;var o=function(t,e){cc.Event.call(this,cc.Event.TOUCH,e),this._eventCode=0,this._touches=t||[],this.touch=null,this.currentTouch=null};n.extend(o,cc.Event),(s=o.prototype).getEventCode=function(){return this._eventCode},s.getTouches=function(){return this._touches},s._setEventCode=function(t){this._eventCode=t},s._setTouches=function(t){this._touches=t},s.setLocation=function(t,e){this.touch&&this.touch.setTouchInfo(this.touch.getID(),t,e)},s.getLocation=function(){return this.touch?this.touch.getLocation():cc.v2()},s.getLocationInView=function(){return this.touch?this.touch.getLocationInView():cc.v2()},s.getPreviousLocation=function(){return this.touch?this.touch.getPreviousLocation():cc.v2()},s.getStartLocation=function(){return this.touch?this.touch.getStartLocation():cc.v2()},s.getID=function(){return this.touch?this.touch.getID():null},s.getDelta=function(){return this.touch?this.touch.getDelta():cc.v2()},s.getDeltaX=function(){return this.touch?this.touch.getDelta().x:0},s.getDeltaY=function(){return this.touch?this.touch.getDelta().y:0},s.getLocationX=function(){return this.touch?this.touch.getLocationX():0},s.getLocationY=function(){return this.touch?this.touch.getLocationY():0},o.MAX_TOUCHES=5,o.BEGAN=0,o.MOVED=1,o.ENDED=2,o.CANCELED=3;var a=function(t,e){cc.Event.call(this,cc.Event.ACCELERATION,e),this.acc=t};n.extend(a,cc.Event);var h=function(t,e,i){cc.Event.call(this,cc.Event.KEYBOARD,i),this.keyCode=t,this.isPressed=e};n.extend(h,cc.Event),cc.Event.EventMouse=r,cc.Event.EventTouch=o,cc.Event.EventAcceleration=a,cc.Event.EventKeyboard=h,e.exports=cc.Event}),{"../event/event":100}],94:[(function(t,e,i){var n=t("../platform/js");cc.EventListener=function(t,e,i){this._onEvent=i,this._type=t||0,this._listenerID=e||"",this._registered=!1,this._fixedPriority=0,this._node=null,this._target=null,this._paused=!0,this._isEnabled=!0},cc.EventListener.prototype={constructor:cc.EventListener,_setPaused:function(t){this._paused=t},_isPaused:function(){return this._paused},_setRegistered:function(t){this._registered=t},_isRegistered:function(){return this._registered},_getType:function(){return this._type},_getListenerID:function(){return this._listenerID},_setFixedPriority:function(t){this._fixedPriority=t},_getFixedPriority:function(){return this._fixedPriority},_setSceneGraphPriority:function(t){this._target=t,this._node=t},_getSceneGraphPriority:function(){return this._node},checkAvailable:function(){return null!==this._onEvent},clone:function(){return null},setEnabled:function(t){this._isEnabled=t},isEnabled:function(){return this._isEnabled},retain:function(){},release:function(){}},cc.EventListener.UNKNOWN=0,cc.EventListener.TOUCH_ONE_BY_ONE=1,cc.EventListener.TOUCH_ALL_AT_ONCE=2,cc.EventListener.KEYBOARD=3,cc.EventListener.MOUSE=4,cc.EventListener.ACCELERATION=6,cc.EventListener.CUSTOM=8;var r=cc.EventListener.ListenerID={MOUSE:"__cc_mouse",TOUCH_ONE_BY_ONE:"__cc_touch_one_by_one",TOUCH_ALL_AT_ONCE:"__cc_touch_all_at_once",KEYBOARD:"__cc_keyboard",ACCELERATION:"__cc_acceleration"},s=function(t,e){this._onCustomEvent=e,cc.EventListener.call(this,cc.EventListener.CUSTOM,t,this._callback)};n.extend(s,cc.EventListener),n.mixin(s.prototype,{_onCustomEvent:null,_callback:function(t){null!==this._onCustomEvent&&this._onCustomEvent(t)},checkAvailable:function(){return cc.EventListener.prototype.checkAvailable.call(this)&&null!==this._onCustomEvent},clone:function(){return new s(this._listenerID,this._onCustomEvent)}});var o=function(){cc.EventListener.call(this,cc.EventListener.MOUSE,r.MOUSE,this._callback)};n.extend(o,cc.EventListener),n.mixin(o.prototype,{onMouseDown:null,onMouseUp:null,onMouseMove:null,onMouseScroll:null,_callback:function(t){var e=cc.Event.EventMouse;switch(t._eventType){case e.DOWN:this.onMouseDown&&this.onMouseDown(t);break;case e.UP:this.onMouseUp&&this.onMouseUp(t);break;case e.MOVE:this.onMouseMove&&this.onMouseMove(t);break;case e.SCROLL:this.onMouseScroll&&this.onMouseScroll(t)}},clone:function(){var t=new o;return t.onMouseDown=this.onMouseDown,t.onMouseUp=this.onMouseUp,t.onMouseMove=this.onMouseMove,t.onMouseScroll=this.onMouseScroll,t},checkAvailable:function(){return!0}});var a=function(){cc.EventListener.call(this,cc.EventListener.TOUCH_ONE_BY_ONE,r.TOUCH_ONE_BY_ONE,null),this._claimedTouches=[]};n.extend(a,cc.EventListener),n.mixin(a.prototype,{constructor:a,_claimedTouches:null,swallowTouches:!1,onTouchBegan:null,onTouchMoved:null,onTouchEnded:null,onTouchCancelled:null,setSwallowTouches:function(t){this.swallowTouches=t},isSwallowTouches:function(){return this.swallowTouches},clone:function(){var t=new a;return t.onTouchBegan=this.onTouchBegan,t.onTouchMoved=this.onTouchMoved,t.onTouchEnded=this.onTouchEnded,t.onTouchCancelled=this.onTouchCancelled,t.swallowTouches=this.swallowTouches,t},checkAvailable:function(){return!!this.onTouchBegan||(cc.logID(1801),!1)}});var h=function(){cc.EventListener.call(this,cc.EventListener.TOUCH_ALL_AT_ONCE,r.TOUCH_ALL_AT_ONCE,null)};n.extend(h,cc.EventListener),n.mixin(h.prototype,{constructor:h,onTouchesBegan:null,onTouchesMoved:null,onTouchesEnded:null,onTouchesCancelled:null,clone:function(){var t=new h;return t.onTouchesBegan=this.onTouchesBegan,t.onTouchesMoved=this.onTouchesMoved,t.onTouchesEnded=this.onTouchesEnded,t.onTouchesCancelled=this.onTouchesCancelled,t},checkAvailable:function(){return null!==this.onTouchesBegan||null!==this.onTouchesMoved||null!==this.onTouchesEnded||null!==this.onTouchesCancelled||(cc.logID(1802),!1)}});var l=function(t){this._onAccelerationEvent=t,cc.EventListener.call(this,cc.EventListener.ACCELERATION,r.ACCELERATION,this._callback)};n.extend(l,cc.EventListener),n.mixin(l.prototype,{constructor:l,_onAccelerationEvent:null,_callback:function(t){this._onAccelerationEvent(t.acc,t)},checkAvailable:function(){return cc.assertID(this._onAccelerationEvent,1803),!0},clone:function(){return new l(this._onAccelerationEvent)}});var c=function(){cc.EventListener.call(this,cc.EventListener.KEYBOARD,r.KEYBOARD,this._callback)};n.extend(c,cc.EventListener),n.mixin(c.prototype,{constructor:c,onKeyPressed:null,onKeyReleased:null,_callback:function(t){t.isPressed?this.onKeyPressed&&this.onKeyPressed(t.keyCode,t):this.onKeyReleased&&this.onKeyReleased(t.keyCode,t)},clone:function(){var t=new c;return t.onKeyPressed=this.onKeyPressed,t.onKeyReleased=this.onKeyReleased,t},checkAvailable:function(){return null!==this.onKeyPressed||null!==this.onKeyReleased||(cc.logID(1800),!1)}}),cc.EventListener.create=function(t){cc.assertID(t&&t.event,1900);var e=t.event;delete t.event;var i=null;for(var n in e===cc.EventListener.TOUCH_ONE_BY_ONE?i=new a:e===cc.EventListener.TOUCH_ALL_AT_ONCE?i=new h:e===cc.EventListener.MOUSE?i=new o:e===cc.EventListener.CUSTOM?(i=new s(t.eventName,t.callback),delete t.eventName,delete t.callback):e===cc.EventListener.KEYBOARD?i=new c:e===cc.EventListener.ACCELERATION&&(i=new l(t.callback),delete t.callback),t)i[n]=t[n];return i},e.exports=cc.EventListener}),{"../platform/js":176}],95:[(function(t,e,i){var n=t("../platform/js");t("./CCEventListener");var r=cc.EventListener.ListenerID,s=function(){this._fixedListeners=[],this._sceneGraphListeners=[],this.gt0Index=0};s.prototype={constructor:s,size:function(){return this._fixedListeners.length+this._sceneGraphListeners.length},empty:function(){return 0===this._fixedListeners.length&&0===this._sceneGraphListeners.length},push:function(t){0===t._getFixedPriority()?this._sceneGraphListeners.push(t):this._fixedListeners.push(t)},clearSceneGraphListeners:function(){this._sceneGraphListeners.length=0},clearFixedListeners:function(){this._fixedListeners.length=0},clear:function(){this._sceneGraphListeners.length=0,this._fixedListeners.length=0},getFixedPriorityListeners:function(){return this._fixedListeners},getSceneGraphPriorityListeners:function(){return this._sceneGraphListeners}};var o={DIRTY_NONE:0,DIRTY_FIXED_PRIORITY:1,DIRTY_SCENE_GRAPH_PRIORITY:2,DIRTY_ALL:3,_listenersMap:{},_priorityDirtyFlagMap:{},_nodeListenersMap:{},_nodePriorityMap:n.createMap(!0),_globalZOrderNodeMap:[],_toAddedListeners:[],_toRemovedListeners:[],_dirtyNodes:[],_inDispatch:0,_isEnabled:!1,_nodePriorityIndex:0,_internalCustomListenerIDs:[],_setDirtyForNode:function(t){if(void 0!==this._nodeListenersMap[t._id]&&this._dirtyNodes.push(t),t.getChildren)for(var e=t.getChildren(),i=0,n=e?e.length:0;i=0);)++n;e.gt0Index=n}}},_sortListenersOfFixedPriorityAsc:function(t,e){return t._getFixedPriority()-e._getFixedPriority()},_onUpdateListeners:function(t){var e,i,n,r=t.getFixedPriorityListeners(),s=t.getSceneGraphPriorityListeners(),o=this._toRemovedListeners;if(s)for(e=0;e0,3508),!(e>1)){var i;(i=this._listenersMap[r.TOUCH_ONE_BY_ONE])&&this._onUpdateListeners(i),(i=this._listenersMap[r.TOUCH_ALL_AT_ONCE])&&this._onUpdateListeners(i),cc.assertID(1===e,3509);var n=this._toAddedListeners;if(0!==n.length){for(var s=0,o=n.length;s0&&-1!==(r=t._claimedTouches.indexOf(n))&&(s=!0,a===h.MOVED&&t.onTouchMoved?t.onTouchMoved(n,i):a===h.ENDED?(t.onTouchEnded&&t.onTouchEnded(n,i),t._registered&&t._claimedTouches.splice(r,1)):a===h.CANCELLED&&(t.onTouchCancelled&&t.onTouchCancelled(n,i),t._registered&&t._claimedTouches.splice(r,1))),i.isStopped()?(o._updateTouchListeners(i),!0):!!(s&&t._registered&&t.swallowTouches)&&(e.needsMutableSet&&e.touches.splice(n,1),!0)},_dispatchTouchEvent:function(t){this._sortEventListeners(r.TOUCH_ONE_BY_ONE),this._sortEventListeners(r.TOUCH_ALL_AT_ONCE);var e=this._getListeners(r.TOUCH_ONE_BY_ONE),i=this._getListeners(r.TOUCH_ALL_AT_ONCE);if(null!==e||null!==i){var n=t.getTouches(),s=cc.js.array.copy(n),o={event:t,needsMutableSet:e&&i,touches:s,selTouch:null};if(e)for(var a=0;a0&&(this._dispatchEventToListeners(i,this._onTouchesEventCallback,{event:t,touches:s}),t.isStopped())||this._updateTouchListeners(t)}},_onTouchesEventCallback:function(t,e){if(!t._registered)return!1;var i=cc.Event.EventTouch,n=e.event,r=e.touches,s=n.getEventCode();return n.currentTarget=t._node,s===i.BEGAN&&t.onTouchesBegan?t.onTouchesBegan(r,n):s===i.MOVED&&t.onTouchesMoved?t.onTouchesMoved(r,n):s===i.ENDED&&t.onTouchesEnded?t.onTouchesEnded(r,n):s===i.CANCELLED&&t.onTouchesCancelled&&t.onTouchesCancelled(r,n),!!n.isStopped()&&(o._updateTouchListeners(n),!0)},_associateNodeAndEventListener:function(t,e){var i=this._nodeListenersMap[t._id];i||(i=[],this._nodeListenersMap[t._id]=i),i.push(e)},_dissociateNodeAndEventListener:function(t,e){var i=this._nodeListenersMap[t._id];i&&(cc.js.array.remove(i,e),0===i.length&&delete this._nodeListenersMap[t._id])},_dispatchEventToListeners:function(t,e,i){var n,r,s=!1,o=t.getFixedPriorityListeners(),a=t.getSceneGraphPriorityListeners(),h=0;if(o&&0!==o.length)for(;h0)for(void 0!==a[t._id]&&(o||(o=[]),o.push(t._id));r=2*r)y=2*r;else for(;y<0;)y+=2*r;else if(l(y)>=2*r)y=2*-r;else for(;y>0;)y-=2*r;for(d=0|o(1,s(l(y)/(.5*r)+.5,5)),v=l(4/3*(1-a(f=y/d/2))/h(f)),_||(v=-v),m=0;m<=d;m++)A=e+(g=a(p=c+y*(m/d)))*n,b=i+(x=h(p))*n,C=-x*n*v,S=g*n*v,0===m?t.moveTo(A,b):t.bezierCurveTo(T+E,w+D,A-C,b-S,A,b),T=A,w=b,E=C,D=S},ellipse:function(t,e,i,n,r){t.moveTo(e-n,i),t.bezierCurveTo(e-n,i+r*u,e-n*u,i+r,e,i+r),t.bezierCurveTo(e+n*u,i+r,e+n,i+r*u,e+n,i),t.bezierCurveTo(e+n,i-r*u,e+n*u,i-r,e,i-r),t.bezierCurveTo(e-n*u,i-r,e-n,i-r*u,e-n,i),t.close()},roundRect:function(t,e,i,n,r,o){if(o<.1)t.rect(e,i,n,r);else{var a=s(o,.5*l(n))*c(n),h=s(o,.5*l(r))*c(r);t.moveTo(e,i+h),t.lineTo(e,i+r-h),t.bezierCurveTo(e,i+r-h*(1-u),e+a*(1-u),i+r,e+a,i+r),t.lineTo(e+n-a,i+r),t.bezierCurveTo(e+n-a*(1-u),i+r,e+n,i+r-h*(1-u),e+n,i+r-h),t.lineTo(e+n,i+h),t.bezierCurveTo(e+n,i+h*(1-u),e+n-a*(1-u),i,e+n-a,i),t.lineTo(e+a,i),t.bezierCurveTo(e+a*(1-u),i,e,i+h*(1-u),e,i+h),t.close()}},tesselateBezier:function t(e,i,r,s,o,a,h,c,u,_,f){var m,d,p,y,v,g,x,A,b,C,S,T,w,E,D,B;_>10||(v=.5*(a+c),g=.5*(h+u),x=.5*((m=.5*(i+s))+(p=.5*(s+a))),A=.5*((d=.5*(r+o))+(y=.5*(o+h))),((D=l((s-c)*(E=u-r)-(o-u)*(w=c-i)))+(B=l((a-c)*E-(h-u)*w)))*(D+B)0){var r=this,s=t.map((function(t){return{type:"uuid",uuid:t}}));this.load(s,e,(function(t,e){if(i){for(var o=[],a=n&&[],h=0;he.length){var i=t.charCodeAt(e.length);return 46===i||47===i}return!0}var a=s.prototype;a.getUuid=function(t,e){t=cc.url.normalize(t);var i=this._pathToUuid[t];if(i)if(Array.isArray(i)){if(!e)return i[0].uuid;for(var n=0;n0&&n.src===s)return n;(function(){function i(){n.removeEventListener("load",i),n.removeEventListener("error",o),n.id=t.id,e(null,n)}function o(){n.removeEventListener("load",i),n.removeEventListener("error",o),"https:"!==window.location.protocol&&n.crossOrigin&&"anonymous"===n.crossOrigin.toLowerCase()?f(t,e,!1,n):e(new Error(r.getError(4930,s)))}n.addEventListener("load",i),n.addEventListener("error",o),n.src=s})()}var m={js:_,png:f,jpg:f,bmp:f,jpeg:f,gif:f,ico:f,tiff:f,webp:function(t,e,i,n){return cc.sys.capabilities.webp?f(t,e,i,n):new Error(r.getError(4929,t.url))},image:f,mp3:s=t("./audio-downloader"),ogg:s,wav:s,m4a:s,txt:l,xml:l,vsh:l,fsh:l,atlas:l,tmx:l,tsx:l,json:l,ExportJson:l,plist:l,fnt:l,font:u,eot:u,ttf:u,woff:u,svg:u,ttc:u,uuid:function(t,e){var i=a.load(t,e);return void 0===i?this.extMap.json(t,e):i||void 0},binary:h,default:l},d="Downloader",p=function(t){this.id=d,this.async=!0,this.pipeline=null,this._curConcurrent=0,this._loadQueue=[],this._subpackages={},this.extMap=n.mixin(t,m)};p.ID=d,p.PackDownloader=a,p.prototype.addHandlers=function(t){n.mixin(this.extMap,t)},p.prototype._handleLoadQueue=function(){for(;this._curConcurrent@",o={},a=-1,h=[],l=6e4;function c(){for(var t=!0,e=Date.now(),i=h.length-1;i>=0;i--){var o=h[i],c=o.fontFamilyName;if(e-o.startTime>l)cc.warnID(4933,c),o.callback(null,c),h.splice(i,1);else{var u=o.refWidth;r.font="40px "+c,u!==n.safeMeasureText(r,s)?(h.splice(i,1),o.callback(null,c)):t=!1}}t&&(clearInterval(a),a=-1)}var u={loadFont:function(t,e){var i=t.url,l=u._getFontFamily(i);if(o[l])return l;if(!r){var _=document.createElement("canvas");_.width=100,_.height=100,r=_.getContext("2d")}var f="40px "+l;r.font=f;var m=n.safeMeasureText(r,s),d=document.createElement("style");d.type="text/css";var p="";isNaN(l-0)?p+="@font-face { font-family:"+l+"; src:":p+="@font-face { font-family:'"+l+"'; src:",p+="url('"+i+"');",d.textContent=p+"}",document.body.appendChild(d);var y=document.createElement("div"),v=y.style;v.fontFamily=l,y.innerHTML=".",v.position="absolute",v.left="-100px",v.top="-100px",document.body.appendChild(y);var g={fontFamilyName:l,refWidth:m,callback:e,startTime:Date.now()};h.push(g),o[l]=d,-1===a&&(a=setInterval(c,100))},_getFontFamily:function(t){var e=t.lastIndexOf(".ttf");if(-1===e)return t;var i,n=t.lastIndexOf("/");return-1!==(i=-1===n?t.substring(0,e)+"_LABEL":t.substring(n+1,e)+"_LABEL").indexOf(" ")&&(i='"'+i+'"'),i}};e.exports=u}),{"../utils/text-utils":241}],116:[(function(t,e,i){t("./downloader"),t("./loader"),t("./loading-items"),t("./pipeline"),t("./CCLoader")}),{"./CCLoader":108,"./downloader":114,"./loader":117,"./loading-items":118,"./pipeline":121}],117:[(function(t,e,i){var n=t("../platform/js"),r=t("../platform/CCSAXParser").plistParser,s=t("./pipeline"),o=t("../assets/CCTexture2D"),a=t("./uuid-loader"),h=t("./font-loader");function l(t){if("string"!=typeof t.content)return new Error("JSON Loader: Input item doesn't contain string content");try{return JSON.parse(t.content)}catch(e){return new Error("JSON Loader: Parse json ["+t.id+"] failed : "+e)}}function c(t){if(t._owner instanceof cc.Asset)return null;var e=t.content;if(!(e instanceof Image))return new Error("Image Loader: Input item doesn't contain Image content");var i=t.rawUrl,n=t.texture||new o;return n._uuid=t.uuid,n.url=i,n._setRawAsset(i,!1),n._nativeAsset=e,n}function u(t,e){if(t._owner instanceof cc.Asset)return null;var i=new cc.AudioClip;return i._setRawAsset(t.rawUrl,!1),i._nativeAsset=t.content,i}var _={png:c,jpg:c,bmp:c,jpeg:c,gif:c,ico:c,tiff:c,webp:c,image:c,mp3:u,ogg:u,wav:u,m4a:u,json:l,ExportJson:l,plist:function(t){if("string"!=typeof t.content)return new Error("Plist Loader: Input item doesn't contain string content");var e=r.parse(t.content);return e||new Error("Plist Loader: Parse ["+t.id+"] failed")},uuid:a,prefab:a,fire:a,scene:a,binary:function(t){return t.load?t.load(t.content):null},font:h.loadFont,eot:h.loadFont,ttf:h.loadFont,woff:h.loadFont,svg:h.loadFont,ttc:h.loadFont,default:function(){return null}},f=function(t){this.id="Loader",this.async=!0,this.pipeline=null,this.extMap=n.mixin(t,_)};f.ID="Loader",f.prototype.addHandlers=function(t){this.extMap=n.mixin(this.extMap,t)},f.prototype.handle=function(t,e){return(this.extMap[t.type]||this.extMap.default).call(this,t,e)},s.Loader=e.exports=f}),{"../assets/CCTexture2D":47,"../platform/CCSAXParser":163,"../platform/js":176,"./font-loader":115,"./pipeline":121,"./uuid-loader":126}],118:[(function(t,e,i){var n=t("../platform/callbacks-invoker");t("../utils/CCPath");var r=t("../platform/js"),s=0|998*Math.random(),o=r.createMap(!0),a=[],h={WORKING:1,COMPLETE:2,ERROR:3},l=r.createMap(!0);function c(t){return"string"==typeof(t.url||t)}function u(t,e){var i="object"==typeof t?t.url:t,n={queueId:e,id:i,url:i,rawUrl:void 0,urlParam:(function(t){if(t){var e=t.split("?");if(e&&e[0]&&e[1]){var i={};return e[1].split("&").forEach((function(t){var e=t.split("=");i[e[0]]=e[1]})),i}}})(i),type:"",error:null,content:null,complete:!1,states:{},deps:null};if("object"==typeof t&&(r.mixin(n,t),t.skips))for(var s=0;s=0)&&(s.deps&&f(t,s,!0))){n=!0;break}}}return i||(_.length=0),n}var m=function(t,e,i,a){n.call(this),this._id=++s,o[this._id]=this,this._pipeline=t,this._errorUrls=[],this._appending=!1,this._ownerQueue=null,this.onProgress=i,this.onComplete=a,this.map=r.createMap(!0),this.completed={},this.totalCount=0,this.completedCount=0,this._pipeline?this.active=!0:this.active=!1,e&&(e.length>0?this.append(e):this.allComplete())};m.ItemState=new cc.Enum(h),m.create=function(t,e,i,n){void 0===i?"function"==typeof e&&(n=e,e=i=null):void 0===n&&("function"==typeof e?(n=i,i=e,e=null):(n=i,i=null));var r=a.pop();return r?(r._pipeline=t,r.onProgress=i,r.onComplete=n,o[r._id]=r,r._pipeline&&(r.active=!0),e&&r.append(e)):r=new m(t,e,i,n),r},m.getQueue=function(t){return t.queueId?o[t.queueId]:null},m.itemComplete=function(t){var e=o[t.queueId];e&&e.itemComplete(t.id)},m.initQueueDeps=function(t){var e=l[t._id];e?(e.completed.length=0,e.deps.length=0):e=l[t._id]={completed:[],deps:[]}},m.registerQueueDep=function(t,e){var i=t.queueId||t;if(!i)return!1;var n=l[i];if(n)-1===n.deps.indexOf(e)&&n.deps.push(e);else if(t.id)for(var r in l){var s=l[r];-1!==s.deps.indexOf(t.id)&&-1===s.deps.indexOf(e)&&s.deps.push(e)}},m.finishDep=function(t){for(var e in l){var i=l[e];-1!==i.deps.indexOf(t)&&-1===i.completed.indexOf(t)&&i.completed.push(t)}};var d=m.prototype;r.mixin(d,n.prototype),d.append=function(t,e){if(!this.active)return[];e&&!e.deps&&(e.deps=[]),this._appending=!0;var i,n,r,s=[];for(i=0;i=this.totalCount},d.isItemCompleted=function(t){return!!this.completed[t]},d.exists=function(t){return!!this.map[t]},d.getContent=function(t){var e=this.map[t],i=null;return e&&(e.content?i=e.content:e.alias&&(i=e.alias.content)),i},d.getError=function(t){var e=this.map[t],i=null;return e&&(e.error?i=e.error:e.alias&&(i=e.alias.error)),i},d.addListener=n.prototype.add,d.hasListener=n.prototype.has,d.removeListener=n.prototype.remove,d.removeAllListeners=n.prototype.removeAll,d.removeItem=function(t){var e=this.map[t];e&&this.completed[e.alias||t]&&(delete this.completed[t],delete this.map[t],e.alias&&(delete this.completed[e.alias.id],delete this.map[e.alias.id]),this.completedCount--,this.totalCount--)},d.itemComplete=function(t){var e=this.map[t];if(e){var i=this._errorUrls.indexOf(t);if(e.error&&-1===i?this._errorUrls.push(t):e.error||-1===i||this._errorUrls.splice(i,1),this.completed[t]=e,this.completedCount++,m.finishDep(e.id),this.onProgress){var n=l[this._id];this.onProgress(n?n.completed.length:this.completedCount,n?n.deps.length:this.totalCount,e)}this.invoke(t,e),this.removeAll(t),!this._appending&&this.completedCount>=this.totalCount&&this.allComplete()}},d.destroy=function(){this.active=!1,this._appending=!1,this._pipeline=null,this._ownerQueue=null,this._errorUrls.length=0,this.onProgress=null,this.onComplete=null,this.map=r.createMap(!0),this.completed={},this.totalCount=0,this.completedCount=0,n.call(this),l[this._id]&&(l[this._id].completed.length=0,l[this._id].deps.length=0),delete o[this._id],delete l[this._id],-1===a.indexOf(this)&&a.length<10&&a.push(this)},cc.LoadingItems=e.exports=m}),{"../platform/callbacks-invoker":169,"../platform/js":176,"../utils/CCPath":225}],119:[(function(t,e,i){var n=t("./pipeline"),r="MD5Pipe",s=/(\.[^.\n\\/]*)$/,o=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-]{8,})/;var a=function(t,e,i){this.id=r,this.async=!1,this.pipeline=null,this.md5AssetsMap=t,this.md5NativeAssetsMap=e,this.libraryBase=i};a.ID=r,a.prototype.handle=function(t){var e=!1;return"ttf"===t.type&&(e=!0),t.url=this.transformURL(t.url,e),t},a.prototype.transformURL=function(t,e){var i,n,r,a,h=this,l=(function(t){var e=t.match(o);return e?e[1]:""})(t);l&&(function(){i=!t.startsWith(h.libraryBase);var o=(i?h.md5NativeAssetsMap:h.md5AssetsMap)[l];o&&(e?(n=cc.path.dirname(t),r=cc.path.basename(t),t=n+"."+o+"/"+r):(a=!1,t=t.replace(s,(function(t,e){return a=!0,"."+o+e})),a||(t=t+"."+o)))})();return t},n.MD5Pipe=e.exports=a}),{"./pipeline":121}],120:[(function(t,e,i){var n=t("./unpackers"),r=t("../utils/misc").pushToMap,s={Invalid:0,Removed:1,Downloading:2,Loaded:3};function o(){this.unpacker=null,this.state=s.Invalid}var a={},h={},l={};function c(t,e){return new Error("Can not retrieve "+t+" from packer "+e)}e.exports={initPacks:function(t){for(var e in h=t,t)for(var i=t[e],n=0;ne&&(e=a,i=r)}}return e!==s.Invalid?i:t[0]},load:function(t,e){var i=t.uuid,n=a[i];if(n){Array.isArray(n)&&(n=this._selectLoadedPack(n));var r=l[n];if(r&&r.state===s.Loaded){var h=r.unpacker.retrieve(i);return h||c(i,n)}return r||(console.log("Create unpacker %s for %s",n,i),(r=l[n]=new o).state=s.Downloading),this._loadNewPack(i,n,e),null}}}}),{"../utils/misc":234,"./unpackers":124}],121:[(function(t,e,i){var n=t("../platform/js"),r=t("./loading-items"),s=r.ItemState;function o(t,e){var i=t.id,n=e.states[i],r=t.next,a=t.pipeline;if(!e.error&&n!==s.WORKING&&n!==s.ERROR)if(n===s.COMPLETE)r?o(r,e):a.flowOut(e);else{e.states[i]=s.WORKING;var h=t.handle(e,(function(t,n){t?(e.error=t,e.states[i]=s.ERROR,a.flowOut(e)):(n&&(e.content=n),e.states[i]=s.COMPLETE,r?o(r,e):a.flowOut(e))}));h instanceof Error?(e.error=h,e.states[i]=s.ERROR,a.flowOut(e)):void 0!==h&&(null!==h&&(e.content=h),e.states[i]=s.COMPLETE,r?o(r,e):a.flowOut(e))}}var a=function(t){this._pipes=t,this._cache=n.createMap(!0);for(var e=0;ethis._pipes.length)cc.warnID(4921);else if(this._pipes.indexOf(t)>0)cc.warnID(4922);else{t.pipeline=this;var i=null;e0&&(n=this._pipes[e-1]),n&&(n.next=t),t.next=i,this._pipes.splice(e,0,t)}},h.insertPipeAfter=function(t,e){var i=this._pipes.indexOf(t);i<0||this.insertPipe(e,i+1)},h.appendPipe=function(t){t.handle&&t.id&&(t.pipeline=this,t.next=null,this._pipes.length>0&&(this._pipes[this._pipes.length-1].next=t),this._pipes.push(t))},h.flowIn=function(t){var e,i,n=this._pipes[0];if(n){for(e=0;es&&(this._accumulator=s);this._accumulator>r;)e.Step(r,i,n),this._accumulator-=r}else{var o=1/cc.game.config.frameRate;e.Step(o,i,n)}this.debugDrawFlags&&(this._checkDebugDrawValid(),this._debugDrawer.clear(),e.DrawDebugData()),this._steping=!1;for(var a=this._delayEvents,h=0,l=a.length;h0){for(var s=n.getPoints(),a=n.getNormals(),l=n.getFractions(),c=[],u=0,_=r.length;u<_;u++){var d=r[u],p=d.collider;if(i===o.AllClosest){var y=c.find((function(t){return t.collider===p}));if(y){l[u]0}function l(t,e,i){return p(t,e,i)>=0}function c(t,e,i){return p(t,e,i)<=0}function u(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function _(t){f(t)||t.reverse()}function f(t){return t.length<3||(function(t){var e,i=0;for(e=0;e0}function m(t,e,i,n){var r=cc.v2(),s=e.y-t.y,o=t.x-e.x,a=s*t.x+o*t.y,h=n.y-i.y,l=i.x-n.x,c=h*i.x+l*i.y,u=s*l-h*o;return (function(t,e){return Math.abs(t-e)<=1e-6})(u,0)||(r.x=(l*a-o*c)/u,r.y=(s*c-h*a)/u),r}function d(t,e,i,n,r){if(t==i||t==n||e==i||e==n)return!1;var s=t.x,o=t.y,a=e.x,h=e.y,l=i.x,c=i.y,u=n.x,_=n.y;if(Math.max(s,a)E&&(D=T,E=B)}y=r(S,D,e),v=r(D,S,e)}return g=(g=g.concat(t(y))).concat(t(v))}g.push(e);for(S=g.length-1;S>=0;S--)0==g[S].length&&g.splice(S,0);return g},ForceCounterClockWise:_,IsCounterClockWise:f}}),{}],132:[(function(t,e,i){var n=t("../CCNode").EventType,r=t("./CCPhysicsTypes").PTM_RATIO,s=t("./CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,o=t("./CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE,a=t("./utils").getWorldRotation,h=t("./CCPhysicsTypes").BodyType,l=new b2.Vec2,c=new b2.Vec2,u=cc.Vec2.ZERO,_=cc.Class({name:"cc.RigidBody",extends:cc.Component,editor:!1,properties:{_type:h.Dynamic,_allowSleep:!0,_gravityScale:1,_linearDamping:0,_angularDamping:0,_linearVelocity:cc.v2(0,0),_angularVelocity:0,_fixedRotation:!1,enabled:{get:function(){return this._enabled},set:function(){cc.warnID(8200)},visible:!1,override:!0},enabledContactListener:{default:!1,tooltip:!1},bullet:{default:!1,tooltip:!1},type:{type:h,tooltip:!1,get:function(){return this._type},set:function(t){this._type=t,this._b2Body&&(t===h.Animated?this._b2Body.SetType(h.Kinematic):this._b2Body.SetType(t))}},allowSleep:{tooltip:!1,get:function(){return this._b2Body?this._b2Body.IsSleepingAllowed():this._allowSleep},set:function(t){this._allowSleep=t,this._b2Body&&this._b2Body.SetSleepingAllowed(t)}},gravityScale:{tooltip:!1,get:function(){return this._gravityScale},set:function(t){this._gravityScale=t,this._b2Body&&this._b2Body.SetGravityScale(t)}},linearDamping:{tooltip:!1,get:function(){return this._linearDamping},set:function(t){this._linearDamping=t,this._b2Body&&this._b2Body.SetLinearDamping(this._linearDamping)}},angularDamping:{tooltip:!1,get:function(){return this._angularDamping},set:function(t){this._angularDamping=t,this._b2Body&&this._b2Body.SetAngularDamping(t)}},linearVelocity:{tooltip:!1,type:cc.Vec2,get:function(){var t=this._linearVelocity;if(this._b2Body){var e=this._b2Body.GetLinearVelocity();t.x=e.x*r,t.y=e.y*r}return t},set:function(t){this._linearVelocity=t;var e=this._b2Body;if(e){var i=e.m_linearVelocity;i.Set(t.x/r,t.y/r),e.SetLinearVelocity(i)}}},angularVelocity:{tooltip:!1,get:function(){return this._b2Body?this._b2Body.GetAngularVelocity()*o:this._angularVelocity},set:function(t){this._angularVelocity=t,this._b2Body&&this._b2Body.SetAngularVelocity(t*s)}},fixedRotation:{tooltip:!1,get:function(){return this._fixedRotation},set:function(t){this._fixedRotation=t,this._b2Body&&this._b2Body.SetFixedRotation(t)}},awake:{tooltip:!1,get:function(){return!!this._b2Body&&this._b2Body.IsAwake()},set:function(t){this._b2Body&&this._b2Body.SetAwake(t)}},active:{visible:!1,get:function(){return!!this._b2Body&&this._b2Body.IsActive()},set:function(t){this._b2Body&&this._b2Body.SetActive(t)}}},getLocalPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){l.Set(t.x/r,t.y/r);var i=this._b2Body.GetLocalPoint(l,e);e.x=i.x*r,e.y=i.y*r}return e},getWorldPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){l.Set(t.x/r,t.y/r);var i=this._b2Body.GetWorldPoint(l,e);e.x=i.x*r,e.y=i.y*r}return e},getWorldVector:function(t,e){if(e=e||cc.v2(),this._b2Body){l.Set(t.x/r,t.y/r);var i=this._b2Body.GetWorldVector(l,e);e.x=i.x*r,e.y=i.y*r}return e},getLocalVector:function(t,e){if(e=e||cc.v2(),this._b2Body){l.Set(t.x/r,t.y/r);var i=this._b2Body.GetLocalVector(l,e);e.x=i.x*r,e.y=i.y*r}return e},getWorldPosition:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetPosition();t.x=e.x*r,t.y=e.y*r}return t},getWorldRotation:function(){return this._b2Body?this._b2Body.GetAngle()*o:0},getLocalCenter:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetLocalCenter();t.x=e.x*r,t.y=e.y*r}return t},getWorldCenter:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetWorldCenter();t.x=e.x*r,t.y=e.y*r}return t},getLinearVelocityFromWorldPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){l.Set(t.x/r,t.y/r);var i=this._b2Body.GetLinearVelocityFromWorldPoint(l,e);e.x=i.x*r,e.y=i.y*r}return e},getMass:function(){return this._b2Body?this._b2Body.GetMass():0},getInertia:function(){return this._b2Body?this._b2Body.GetInertia()*r*r:0},getJointList:function(){if(!this._b2Body)return[];var t=[],e=this._b2Body.GetJointList();if(!e)return[];t.push(e.joint._joint);for(var i=e.prev;i;)t.push(i.joint._joint),i=i.prev;for(var n=e.next;n;)t.push(n.joint._joint),n=n.next;return t},applyForce:function(t,e,i){this._b2Body&&(l.Set(t.x/r,t.y/r),c.Set(e.x/r,e.y/r),this._b2Body.ApplyForce(l,c,i))},applyForceToCenter:function(t,e){this._b2Body&&(l.Set(t.x/r,t.y/r),this._b2Body.ApplyForceToCenter(l,e))},applyTorque:function(t,e){this._b2Body&&this._b2Body.ApplyTorque(t/r,e)},applyLinearImpulse:function(t,e,i){this._b2Body&&(l.Set(t.x/r,t.y/r),c.Set(e.x/r,e.y/r),this._b2Body.ApplyLinearImpulse(l,c,i))},applyAngularImpulse:function(t,e){this._b2Body&&this._b2Body.ApplyAngularImpulse(t/r/r,e)},syncPosition:function(t){var e=this._b2Body;if(e){var i,n=this.node.convertToWorldSpaceAR(u);if((i=this.type===h.Animated?e.GetLinearVelocity():e.GetPosition()).x=n.x/r,i.y=n.y/r,this.type===h.Animated&&t){var s=e.GetPosition(),o=cc.game.config.frameRate;i.x=(i.x-s.x)*o,i.y=(i.y-s.y)*o,e.SetAwake(!0),e.SetLinearVelocity(i)}else e.SetTransformVec(i,e.GetAngle())}},syncRotation:function(t){var e=this._b2Body;if(e){var i=s*a(this.node);if(this.type===h.Animated&&t){var n=e.GetAngle(),r=cc.game.config.frameRate;e.SetAwake(!0),e.SetAngularVelocity((i-n)*r)}else e.SetTransformVec(e.GetPosition(),i)}},resetVelocity:function(){var t=this._b2Body;if(t){var e=t.m_linearVelocity;e.Set(0,0),t.SetLinearVelocity(e),t.SetAngularVelocity(0)}},onEnable:function(){this._init()},onDisable:function(){this._destroy()},_registerNodeEvents:function(){var t=this.node;t.on(n.POSITION_CHANGED,this._onNodePositionChanged,this),t.on(n.ROTATION_CHANGED,this._onNodeRotationChanged,this),t.on(n.SCALE_CHANGED,this._onNodeScaleChanged,this)},_unregisterNodeEvents:function(){var t=this.node;t.off(n.POSITION_CHANGED,this._onNodePositionChanged,this),t.off(n.ROTATION_CHANGED,this._onNodeRotationChanged,this),t.off(n.SCALE_CHANGED,this._onNodeScaleChanged,this)},_onNodePositionChanged:function(){this.syncPosition(!0)},_onNodeRotationChanged:function(t){this.syncRotation(!0)},_onNodeScaleChanged:function(t){if(this._b2Body)for(var e=this.getComponents(cc.PhysicsCollider),i=0;i=0;n--){var r=t[n];r.collider=null,i._unregisterContactFixture(r),e&&e.DestroyFixture(r)}this.body=null,this._fixtures.length=0,this._shapes.length=0,this._inited=!1}},_createShape:function(){},apply:function(){this._destroy(),this._init()},getAABB:function(){for(var t=1e7,e=1e7,i=-1e7,r=-1e7,s=this._fixtures,o=0;oi&&(i=c.upperBound.x),c.upperBound.y>r&&(r=c.upperBound.y)}t*=n,e*=n,i*=n,r*=n;var u=this._rect;return u.x=t,u.y=e,u.width=i-t,u.height=r-e,u}});cc.PhysicsCollider=e.exports=s}),{"../CCPhysicsTypes":130,"../utils":153}],138:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../CCPolygonSeparator"),s=cc.Class({name:"cc.PhysicsPolygonCollider",extends:cc.PhysicsCollider,mixins:[cc.Collider.Polygon],editor:{menu:!1,inspector:!1,requireComponent:cc.RigidBody},_createShape:function(t){var e=[],i=this.points;i.length>0&&i[0].equals(i[i.length-1])&&(i.length-=1);for(var s=r.ConvexPartition(i),o=this.offset,a=0;a=2?1:n)},n.prototype.getFixtures=function(){return this._fixtures},n.prototype.getPoints=function(){return this._points},n.prototype.getNormals=function(){return this._normals},n.prototype.getFractions=function(){return this._fractions},cc.PhysicsRayCastCallback=e.exports=n}),{}],153:[(function(t,e,i){e.exports={getWorldRotation:function(t){for(var e=t.rotationX,i=t.parent;i.parent;)e+=i.rotationX,i=i.parent;return e},getWorldScale:function(t){for(var e=t.scaleX,i=t.scaleY,n=t.parent;n.parent;)e*=n.scaleX,i*=n.scaleY,n=n.parent;return cc.v2(e,i)},convertToNodeRotation:function(t,e){e-=t.rotationX;for(var i=t.parent;i.parent;)e-=i.rotationX,i=i.parent;return e}}}),{}],154:[(function(t,e,i){}),{"../event-manager":97,"../platform/js":176,"./CCMacro":161,"./CCSys":165}],155:[(function(t,e,i){t("../assets/CCAsset");var n=t("./utils").callInNextTick,r=t("../load-pipeline/CCLoader"),s=t("../load-pipeline/pack-downloader"),o=t("../load-pipeline/auto-release-utils"),a=t("../utils/decode-uuid"),h=t("../load-pipeline/md5-pipe"),l=t("./js"),c="",u="",_=l.createMap(!0);function f(t){return t&&(t.constructor===cc.SceneAsset||t instanceof cc.Scene)}function m(t,e){this.url=t,this.type=e}var d={loadAsset:function(t,e,i){if("string"!=typeof t)return n(e,new Error("[AssetLibrary] uuid must be string"),null);var s={uuid:t,type:"uuid"};i&&i.existingAsset&&(s.existingAsset=i.existingAsset),r.load(s,(function(i,n){if(i||!n)i=new Error("[AssetLibrary] loading JSON or dependencies failed: "+(i?i.message:"Unknown error"));else{if(n.constructor===cc.SceneAsset){var s=cc.loader._getReferenceKey(t);n.scene.dependAssets=o.getDependsRecursively(s)}if(f(n)){var a=cc.loader._getReferenceKey(t);r.removeItem(a)}}e&&e(i,n)}))},getLibUrlNoExt:function(t,e){return t=a(t),(e?u+"assets/":c)+t.slice(0,2)+"/"+t},_queryAssetInfoInEditor:function(t,e){0},_getAssetInfoInRuntime:function(t,e){e=e||{url:null,raw:!1};var i=_[t];return i&&!l.isChildClassOf(i.type,cc.Asset)?(e.url=u+i.url,e.raw=!0):(e.url=this.getLibUrlNoExt(t)+".json",e.raw=!1),e},_uuidInSettings:function(t){return t in _},queryAssetInfo:function(t,e){var i=this._getAssetInfoInRuntime(t);e(null,i.url,i.raw)},parseUuidInEditor:function(t){},loadJson:function(t,e){var i=""+((new Date).getTime()+Math.random()),n={uuid:i,type:"uuid",content:t,skips:[r.assetLoader.id,r.downloader.id]};r.load(n,(function(t,n){if(t)t=new Error("[AssetLibrary] loading JSON or dependencies failed: "+t.message);else{if(n.constructor===cc.SceneAsset){var s=cc.loader._getReferenceKey(i);n.scene.dependAssets=o.getDependsRecursively(s)}if(f(n)){var a=cc.loader._getReferenceKey(i);r.removeItem(a)}}n._uuid="",e&&e(t,n)}))},getAssetByUuid:function(t){return d._uuidToAsset[t]||null},init:function(t){var e=t.libraryPath;e=e.replace(/\\/g,"/"),c=cc.path.stripSep(e)+"/",u=t.rawAssetsBase;var i=t.md5AssetsMap;if(i&&i.import){var n=0,o=0,f=l.createMap(!0),d=i.import;for(n=0;n0?s:null,!0);var _=a.prototype;if(e&&(c||(n.extend(a,e),_=a.prototype),a.$super=e),i){for(var f=i.length-1;f>=0;f--){var m=i[f];v(_,m.prototype),v(a,m,(function(t){return m.hasOwnProperty(t)&&!0})),D._isCCClass(m)&&v(o.getClassAttrs(a).constructor.prototype,o.getClassAttrs(m).constructor.prototype)}_.constructor=a}return c||(_.__initProps__=C),n.setClassName(t,a),a}function x(t){for(var e=n.getClassName(t),i=t.constructor,r="new "+e+"(",s=0;s0){0;var o="].apply(this,arguments);\n";if(1===s)r+="CCClass.__ctors__[0"+o;else{r+="var cs=CCClass.__ctors__;\n";for(var a=0;a=0)){var o=e[s];if("function"==typeof o){var a=n.getPropertyDescriptor(t.prototype,s);if(a){var h=a.value;if("function"==typeof h){T.test(o)&&(r=!0,e[s]=(function(t,e){return function(){var i=this._super;this._super=t;var n=e.apply(this,arguments);return this._super=i,n}})(h,o));continue}}0}}return r}function E(t,e,i,n,r,s){if(t.__props__=[],n&&n.__props__&&(t.__props__=n.__props__.slice()),r)for(var h=0;h=0)){var f=t[u];l.validateMethodWithProps(f,u,e,s,i)&&n.value(s.prototype,u,f,!0,!0)}var m=t.editor;return m&&n.isChildClassOf(i,cc.Component)&&cc.Component._registerEditorProps(s,m),s}D._isCCClass=function(t){return t&&t.hasOwnProperty("__ctors__")},D._fastDefine=function(t,e,i){n.setClassName(t,e);for(var r=e.__props__=e.__values__=Object.keys(i),s=o.getClassAttrsProto(e),h=0;h=2&&((l||u())[c+"min"]=y[0],l[c+"max"]=y[1],y.length>2&&(l[c+"step"]=y[2])),p("min","number"),p("max","number"),p("step","number"),_}cc.Class=D,e.exports={isArray:function(t){return t=y(t),Array.isArray(t)},fastDefine:D._fastDefine,getNewValueTypeCode:x,IDENTIFIER_RE:b,escapeForJS:A,getDefault:y}}),{"./CCEnum":158,"./attribute":168,"./js":176,"./preprocess-class":177,"./requiring-frame":178,"./utils":180}],157:[(function(t,e,i){t("./CCClass");var n=t("./preprocess-class"),r=t("./js"),s="__ccclassCache__";function o(t){return t}function a(t,e){return t[e]||(t[e]={})}function h(t){return function(e){return"function"==typeof e?t(e):function(i){return t(i,e)}}}function l(t,e,i){return function(t){return function(i){return e(i,t)}}}var c=l.bind(null,!1);function u(t){return l.bind(null,!1)}var _=u(),f=u();function m(t,e){return a(t,s)}var d=h((function(t,e){var i=r.getSuper(t);i===Object&&(i=null);var n={name:e,extends:i,ctor:t,__ES6__:!0},o=t[s];if(o){var a=o.proto;a&&r.mixin(n,a),t[s]=void 0}return cc.Class(n)}));function p(t,e,i){return t((function(t,n){var r=m(t);if(r){var s=void 0!==i?i:n;a(a(r,"proto"),"editor")[e]=s}}),e)}function y(t){return t(o)}var v=y(h),g=p(c,"requireComponent"),x=y(_),A=p(f,"executionOrder"),b=y(h),C=y(h),S=y(_),T=y(_),w=y(_);cc._decorator=e.exports={ccclass:d,property:function(t,e,i){var s=null;function o(t,e,i){var o=m(t.constructor);if(o){var h=a(a(o,"proto"),"properties");(function(t,e,i,s,o,a){var h;s&&(h=(h=n.getFullFormOfProperty(s))||s);var l=e[i],c=r.mixin(l||{},h||{});if(o&&(o.get||o.set))o.get&&(c.get=o.get),o.set&&(c.set=o.set);else{var u=void 0;if(o)o.initializer&&(u=(function(t){var e;try{e=t()}catch(e){return t}return"object"!=typeof e||null===e?e:t})(o.initializer));else{var _=a.default||(a.default=(function(t){var e;try{e=new t}catch(t){return{}}return e})(t));_.hasOwnProperty(i)&&(u=_[i])}c.default=u}e[i]=c})(t.constructor,h,e,s,i,o)}}if(void 0===e)return s=t,o;o(t,e,i)},executeInEditMode:v,requireComponent:g,menu:x,executionOrder:A,disallowMultiple:b,playOnFocus:C,inspector:S,icon:T,help:w,mixins:function(){for(var t=[],e=0;eo)return this._removeUsedIndexBit(i),delete this._touchesIntegerDict[n.getID()],i;t>>=1}return-1},_removeUsedIndexBit:function(t){if(!(t<0||t>=this._maxTouches)){var e=1<0){this._glView._convertTouchesWithScale(o);var _=new cc.Event.EventTouch(o);_._eventCode=cc.Event.EventTouch.BEGAN,s.dispatchEvent(_)}},handleTouchesMove:function(t){for(var e=void 0,i=void 0,n=void 0,o=[],a=this._touches,h=r.now(),l=0,c=t.length;l0){this._glView._convertTouchesWithScale(o);var u=new cc.Event.EventTouch(o);u._eventCode=cc.Event.EventTouch.MOVED,s.dispatchEvent(u)}},handleTouchesEnd:function(t){var e=this.getSetOfTouchesEndOrCancel(t);if(e.length>0){this._glView._convertTouchesWithScale(e);var i=new cc.Event.EventTouch(e);i._eventCode=cc.Event.EventTouch.ENDED,s.dispatchEvent(i)}this._preTouchPool.length=0},handleTouchesCancel:function(t){var e=this.getSetOfTouchesEndOrCancel(t);if(e.length>0){this._glView._convertTouchesWithScale(e);var i=new cc.Event.EventTouch(e);i._eventCode=cc.Event.EventTouch.CANCELLED,s.dispatchEvent(i)}this._preTouchPool.length=0},getSetOfTouchesEndOrCancel:function(t){for(var e=void 0,i=void 0,n=void 0,r=[],s=this._touches,o=this._touchesIntegerDict,a=0,h=t.length;a=0;r--)if(i[r].getID()===n){e=i[r];break}return e||(e=t),e},setPreTouch:function(t){for(var e=!1,i=this._preTouchPool,n=t.getID(),r=i.length-1;r>=0;r--)if(i[r].getID()===n){i[r]=t,e=!0;break}e||(i.length<=50?i.push(t):(i[this._preTouchPoolPointer]=t,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},getTouchByXY:function(t,e,i){var n=this._preTouchPoint,r=this._glView.convertToLocationInView(t,e,i),s=new cc.Touch(r.x,r.y,0);return s._setPrevPoint(n.x,n.y),n.x=r.x,n.y=r.y,s},getMouseEvent:function(t,e,i){var n=this._prevMousePoint,r=new cc.Event.EventMouse(i);return r._setPrevCursor(n.x,n.y),n.x=t.x,n.y=t.y,this._glView._convertMouseToLocationInView(n,e),r.setLocation(n.x,n.y),r},getPointByEvent:function(t,e){return null!=t.pageX?{x:t.pageX,y:t.pageY}:(r.platform===r.WECHAT_GAME?(e.left=0,e.top=0):(e.left-=document.body.scrollLeft,e.top-=document.body.scrollTop),{x:t.clientX,y:t.clientY})},getTouchesByEvent:function(t,e){for(var i=[],n=this._glView,s=void 0,o=void 0,h=void 0,l=this._preTouchPoint,c=t.changedTouches.length,u=0;uthis._accelInterval&&(this._accelCurTime-=this._accelInterval,s.dispatchEvent(new cc.Event.EventAcceleration(this._acceleration))),this._accelCurTime+=t}};e.exports=_cc.inputManager=h}),{"../event-manager":97,"./CCMacro":161,"./CCSys":165}],161:[(function(t,e,i){var n=t("./js");cc.macro={RAD:Math.PI/180,DEG:180/Math.PI,REPEAT_FOREVER:Number.MAX_VALUE-1,FLT_EPSILON:1.192092896e-7,MIN_ZINDEX:-Math.pow(2,15),MAX_ZINDEX:Math.pow(2,15)-1,ONE:1,ZERO:0,SRC_ALPHA:770,SRC_ALPHA_SATURATE:776,SRC_COLOR:768,DST_ALPHA:772,DST_COLOR:774,ONE_MINUS_SRC_ALPHA:771,ONE_MINUS_SRC_COLOR:769,ONE_MINUS_DST_ALPHA:773,ONE_MINUS_DST_COLOR:775,ONE_MINUS_CONSTANT_ALPHA:32772,ONE_MINUS_CONSTANT_COLOR:32770,ORIENTATION_PORTRAIT:1,ORIENTATION_LANDSCAPE:2,ORIENTATION_AUTO:3,DENSITYDPI_DEVICE:"device-dpi",DENSITYDPI_HIGH:"high-dpi",DENSITYDPI_MEDIUM:"medium-dpi",DENSITYDPI_LOW:"low-dpi",FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX:!0,DIRECTOR_STATS_POSITION:cc.v2(0,0),ENABLE_STACKABLE_ACTIONS:!0,TOUCH_TIMEOUT:5e3,BATCH_VERTEX_COUNT:2e4,ENABLE_TILEDMAP_CULLING:!0,DOWNLOAD_MAX_CONCURRENT:64,ENABLE_TRANSPARENT_CANVAS:!1,ENABLE_WEBGL_ANTIALIAS:!1,ENABLE_CULLING:!1,CLEANUP_IMAGE_CACHE:!1},n.getset(cc.macro,"ENABLE_3D",(function(){return cc._polyfill3D.enabled}),(function(t){t?cc._polyfill3D.enable():cc._polyfill3D.disable()})),cc.macro.KEY={none:0,back:6,menu:18,backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pause:19,capslock:20,escape:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,select:41,insert:45,Delete:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,num0:96,num1:97,num2:98,num3:99,num4:100,num5:101,num6:102,num7:103,num8:104,num9:105,"*":106,"+":107,"-":109,numdel:110,"/":111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,";":186,semicolon:186,equal:187,"=":187,",":188,comma:188,dash:189,".":190,period:190,forwardslash:191,grave:192,"[":219,openbracket:219,backslash:220,"]":221,closebracket:221,quote:222,dpadLeft:1e3,dpadRight:1001,dpadUp:1003,dpadDown:1004,dpadCenter:1005},cc.macro.ImageFormat=cc.Enum({JPG:0,PNG:1,TIFF:2,WEBP:3,PVR:4,ETC:5,S3TC:6,ATITC:7,TGA:8,RAWDATA:9,UNKNOWN:10}),cc.macro.BlendFactor=cc.Enum({ONE:1,ZERO:0,SRC_ALPHA:770,SRC_COLOR:768,DST_ALPHA:772,DST_COLOR:774,ONE_MINUS_SRC_ALPHA:771,ONE_MINUS_SRC_COLOR:769,ONE_MINUS_DST_ALPHA:773,ONE_MINUS_DST_COLOR:775}),cc.macro.TextAlignment=cc.Enum({LEFT:0,CENTER:1,RIGHT:2}),cc.macro.VerticalTextAlignment=cc.Enum({TOP:0,CENTER:1,BOTTOM:2}),e.exports=cc.macro}),{"./js":176}],162:[(function(t,e,i){var n=t("./js"),r=t("./CCClass"),s=1;function o(){this._name="",this._objFlags=0}r.fastDefine("cc.Object",o,{_name:"",_objFlags:0}),n.value(o,"Flags",{Destroyed:s,DontSave:8,EditorOnly:16,Dirty:32,DontDestroy:64,PersistentMask:-4192741,Destroying:128,Deactivating:256,LockedInEditor:512,IsPreloadStarted:8192,IsOnLoadStarted:32768,IsOnLoadCalled:16384,IsOnEnableCalled:2048,IsStartCalled:65536,IsEditorOnEnableCalled:4096,IsPositionLocked:1<<21,IsRotationLocked:1<<17,IsScaleLocked:1<<18,IsAnchorLocked:1<<19,IsSizeLocked:1<<20});var a=[];function h(){for(var t=a.length,e=0;e=6.2;break;case t.BROWSER_TYPE_ANDROID:t.osMainVersion&&t.osMainVersion>=5&&(b=!0);break;case t.BROWSER_TYPE_CHROME:b=C>=30;break;case t.BROWSER_TYPE_UC:b=C>11;break;case t.BROWSER_TYPE_360:b=!1}}var S,T=t.capabilities={canvas:A,opengl:b,webp:x};(void 0!==r.ontouchstart||void 0!==n.ontouchstart||i.msPointerEnabled)&&(T.touches=!0),void 0!==r.onmouseup&&(T.mouse=!0),void 0!==r.onkeyup&&(T.keyboard=!0),(e.DeviceMotionEvent||e.DeviceOrientationEvent)&&(T.accelerometer=!0),(function(){t.browserVersion;var e=t.browserType!==t.BROWSER_TYPE_WECHAT_GAME&&!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext);S={ONLY_ONE:!1,WEB_AUDIO:e,DELAY_CREATE_CTX:!1},t.os===t.OS_IOS&&(S.USE_LOADER_EVENT="loadedmetadata"),t.browserType===t.BROWSER_TYPE_FIREFOX&&(S.DELAY_CREATE_CTX=!0,S.USE_LOADER_EVENT="canplay"),t.os===t.OS_ANDROID&&t.browserType===t.BROWSER_TYPE_UC&&(S.ONE_SOURCE=!0)})();try{S.WEB_AUDIO&&(S.context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),S.DELAY_CREATE_CTX&&setTimeout((function(){S.context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}),0))}catch(t){S.WEB_AUDIO=!1,cc.logID(5201)}var w=[];return (function(){var t=document.createElement("audio");t.canPlayType&&(t.canPlayType('audio/ogg; codecs="vorbis"')&&w.push(".ogg"),t.canPlayType("audio/mpeg")&&w.push(".mp3"),t.canPlayType('audio/wav; codecs="1"')&&w.push(".wav"),t.canPlayType("audio/mp4")&&w.push(".mp4"),t.canPlayType("audio/x-m4a")&&w.push(".m4a"))})(),S.format=w,t.__audioSupport=S,t.NetworkType={NONE:0,LAN:1,WWAN:2},t.getNetworkType=function(){return t.NetworkType.LAN},t.getBatteryLevel=function(){return 1},t.garbageCollect=function(){},t.restartVM=function(){},t.isObjectValid=function(t){return!!t},t.dump=function(){var t="";t+="isMobile : "+this.isMobile+"\r\n",t+="language : "+this.language+"\r\n",t+="browserType : "+this.browserType+"\r\n",t+="browserVersion : "+this.browserVersion+"\r\n",t+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n",t+="os : "+this.os+"\r\n",t+="osVersion : "+this.osVersion+"\r\n",t+="platform : "+this.platform+"\r\n",t+="Using "+(cc.game.renderType===cc.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n",cc.log(t)},t.openURL=function(t){window.open(t)},t.now=function(){return Date.now?Date.now():+new Date},t})();e.exports=n}),{}],166:[(function(t,e,i){var n=t("../event/event-target"),r=t("../platform/js"),s=t("../renderer");t("../platform/CCClass");var o={init:function(){this.html=document.getElementsByTagName("html")[0]},availWidth:function(t){return t&&t!==this.html?t.clientWidth:window.innerWidth},availHeight:function(t){return t&&t!==this.html?t.clientHeight:window.innerHeight},meta:{width:"device-width"},adaptationType:cc.sys.browserType};switch(cc.sys.os===cc.sys.OS_IOS&&(o.adaptationType=cc.sys.BROWSER_TYPE_SAFARI),o.adaptationType){case cc.sys.BROWSER_TYPE_SAFARI:o.meta["minimal-ui"]="true";case cc.sys.BROWSER_TYPE_SOUGOU:case cc.sys.BROWSER_TYPE_UC:o.availWidth=function(t){return t.clientWidth},o.availHeight=function(t){return t.clientHeight};break;case cc.sys.BROWSER_TYPE_WECHAT_GAME:o.availWidth=function(){return window.innerWidth},o.availHeight=function(){return window.innerHeight};break;case cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB:var a=window.sharedCanvas||wx.getSharedCanvas();o.availWidth=function(){return a.width},o.availHeight=function(){return a.height}}var h=null,l=function(){n.call(this);var t=this,e=cc.ContainerStrategy,i=cc.ContentStrategy;o.init(this),t._frameSize=cc.size(0,0),t._designResolutionSize=cc.size(0,0),t._originalDesignResolutionSize=cc.size(0,0),t._scaleX=1,t._scaleY=1,t._viewportRect=cc.rect(0,0,0,0),t._visibleRect=cc.rect(0,0,0,0),t._autoFullScreen=!1,t._devicePixelRatio=1,t._retinaEnabled=!1,t._resizeCallback=null,t._resizing=!1,t._resizeWithBrowserSize=!1,t._orientationChanging=!0,t._isRotated=!1,t._orientation=cc.macro.ORIENTATION_AUTO,t._isAdjustViewport=!0,t._antiAliasEnabled=!1,t._resolutionPolicy=null,t._rpExactFit=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,i.EXACT_FIT),t._rpShowAll=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,i.SHOW_ALL),t._rpNoBorder=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,i.NO_BORDER),t._rpFixedHeight=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,i.FIXED_HEIGHT),t._rpFixedWidth=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,i.FIXED_WIDTH),cc.game.once(cc.game.EVENT_ENGINE_INITED,this.init,this)};cc.js.extend(l,n),cc.js.mixin(l.prototype,{init:function(){this._initFrameSize(),this.enableAntiAlias(!0);var t=cc.game.canvas.width,e=cc.game.canvas.height;this._designResolutionSize.width=t,this._designResolutionSize.height=e,this._originalDesignResolutionSize.width=t,this._originalDesignResolutionSize.height=e,this._viewportRect.width=t,this._viewportRect.height=e,this._visibleRect.width=t,this._visibleRect.height=e,cc.winSize.width=this._visibleRect.width,cc.winSize.height=this._visibleRect.height,cc.visibleRect&&cc.visibleRect.init(this._visibleRect)},_resizeEvent:function(){var t,e=(t=this.setDesignResolutionSize?this:cc.view)._frameSize.width,i=t._frameSize.height,n=t._isRotated;if(cc.sys.isMobile){var r=cc.game.container.style,s=r.margin;r.margin="0",r.display="none",t._initFrameSize(),r.margin=s,r.display="block"}else t._initFrameSize();if(t._isRotated!==n||t._frameSize.width!==e||t._frameSize.height!==i){var o=t._originalDesignResolutionSize.width,a=t._originalDesignResolutionSize.height;t._resizing=!0,o>0&&t.setDesignResolutionSize(o,a,t._resolutionPolicy),t._resizing=!1,t.emit("canvas-resize"),t._resizeCallback&&t._resizeCallback.call()}},_orientationChange:function(){cc.view._orientationChanging=!0,cc.view._resizeEvent()},resizeWithBrowserSize:function(t){t?this._resizeWithBrowserSize||(this._resizeWithBrowserSize=!0,window.addEventListener("resize",this._resizeEvent),window.addEventListener("orientationchange",this._orientationChange)):this._resizeWithBrowserSize&&(this._resizeWithBrowserSize=!1,window.removeEventListener("resize",this._resizeEvent),window.removeEventListener("orientationchange",this._orientationChange))},setResizeCallback:function(t){"function"!=typeof t&&null!=t||(this._resizeCallback=t)},setOrientation:function(t){if((t&=cc.macro.ORIENTATION_AUTO)&&this._orientation!==t){this._orientation=t;var e=this._originalDesignResolutionSize.width,i=this._originalDesignResolutionSize.height;this.setDesignResolutionSize(e,i,this._resolutionPolicy)}},_initFrameSize:function(){var t=this._frameSize,e=o.availWidth(cc.game.frame),i=o.availHeight(cc.game.frame),n=e>=i;!cc.sys.isMobile||n&&this._orientation&cc.macro.ORIENTATION_LANDSCAPE||!n&&this._orientation&cc.macro.ORIENTATION_PORTRAIT?(t.width=e,t.height=i,cc.game.container.style["-webkit-transform"]="rotate(0deg)",cc.game.container.style.transform="rotate(0deg)",this._isRotated=!1):(t.width=i,t.height=e,cc.game.container.style["-webkit-transform"]="rotate(90deg)",cc.game.container.style.transform="rotate(90deg)",cc.game.container.style["-webkit-transform-origin"]="0px 0px 0px",cc.game.container.style.transformOrigin="0px 0px 0px",this._isRotated=!0,cc.game.canvas.style["-webkit-transform"]="translateZ(0px)",cc.game.canvas.style.transform="translateZ(0px)"),this._orientationChanging&&setTimeout((function(){cc.view._orientationChanging=!1}),1e3)},_adjustSizeKeepCanvasSize:function(){var t=this._originalDesignResolutionSize.width,e=this._originalDesignResolutionSize.height;t>0&&this.setDesignResolutionSize(t,e,this._resolutionPolicy)},_setViewportMeta:function(t,e){var i=document.getElementById("cocosMetaElement");i&&e&&document.head.removeChild(i);var n,r,s,o=document.getElementsByName("viewport"),a=o?o[0]:null;for(r in n=a?a.content:"",(i=i||document.createElement("meta")).id="cocosMetaElement",i.name="viewport",i.content="",t)-1==n.indexOf(r)?n+=","+r+"="+t[r]:e&&(s=new RegExp(r+"s*=s*[^,]+"),n.replace(s,r+"="+t[r]));/^,/.test(n)&&(n=n.substr(1)),i.content=n,a&&(a.content=n),document.head.appendChild(i)},_adjustViewportMeta:function(){this._isAdjustViewport&&(this._setViewportMeta(o.meta,!1),this._isAdjustViewport=!1)},adjustViewportMeta:function(t){this._isAdjustViewport=t},enableRetina:function(t){this._retinaEnabled=!!t},isRetinaEnabled:function(){return this._retinaEnabled},enableAntiAlias:function(t){if(this._antiAliasEnabled!==t)if(this._antiAliasEnabled=t,cc.game.renderType===cc.game.RENDER_TYPE_WEBGL){var e=cc.loader._cache;for(var i in e){var n=e[i],r=n&&n.content instanceof cc.Texture2D?n.content:null;if(r){var s=cc.Texture2D.Filter;t?r.setFilters(s.LINEAR,s.LINEAR):r.setFilters(s.NEAREST,s.NEAREST)}}}else if(cc.game.renderType===cc.game.RENDER_TYPE_CANVAS){var o=cc.game.canvas.getContext("2d");o.imageSmoothingEnabled=t,o.mozImageSmoothingEnabled=t}},isAntiAliasEnabled:function(){return this._antiAliasEnabled},enableAutoFullScreen:function(t){t&&t!==this._autoFullScreen&&cc.sys.isMobile&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_WECHAT?(this._autoFullScreen=!0,cc.screen.autoFullScreen(cc.game.frame)):this._autoFullScreen=!1},isAutoFullScreenEnabled:function(){return this._autoFullScreen},setCanvasSize:function(t,e){var i=cc.game.canvas,n=cc.game.container;i.width=t*this._devicePixelRatio,i.height=e*this._devicePixelRatio,i.style.width=t+"px",i.style.height=e+"px",n.style.width=t+"px",n.style.height=e+"px",this._resizeEvent()},getCanvasSize:function(){return cc.size(cc.game.canvas.width,cc.game.canvas.height)},getFrameSize:function(){return cc.size(this._frameSize.width,this._frameSize.height)},setFrameSize:function(t,e){this._frameSize.width=t,this._frameSize.height=e,cc.game.frame.style.width=t+"px",cc.game.frame.style.height=e+"px",this._resizeEvent()},getVisibleSize:function(){return cc.size(this._visibleRect.width,this._visibleRect.height)},getVisibleSizeInPixel:function(){return cc.size(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},getVisibleOrigin:function(){return cc.v2(this._visibleRect.x,this._visibleRect.y)},getVisibleOriginInPixel:function(){return cc.v2(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},getResolutionPolicy:function(){return this._resolutionPolicy},setResolutionPolicy:function(t){var e=this;if(t instanceof cc.ResolutionPolicy)e._resolutionPolicy=t;else{var i=cc.ResolutionPolicy;t===i.EXACT_FIT&&(e._resolutionPolicy=e._rpExactFit),t===i.SHOW_ALL&&(e._resolutionPolicy=e._rpShowAll),t===i.NO_BORDER&&(e._resolutionPolicy=e._rpNoBorder),t===i.FIXED_HEIGHT&&(e._resolutionPolicy=e._rpFixedHeight),t===i.FIXED_WIDTH&&(e._resolutionPolicy=e._rpFixedWidth)}},setDesignResolutionSize:function(t,e,i){if(t>0||e>0){this.setResolutionPolicy(i);var n=this._resolutionPolicy;if(n&&n.preApply(this),cc.sys.isMobile&&this._adjustViewportMeta(),this._orientationChanging=!0,this._resizing||this._initFrameSize(),n){this._originalDesignResolutionSize.width=this._designResolutionSize.width=t,this._originalDesignResolutionSize.height=this._designResolutionSize.height=e;var r=n.apply(this,this._designResolutionSize);if(r.scale&&2===r.scale.length&&(this._scaleX=r.scale[0],this._scaleY=r.scale[1]),r.viewport){var o=this._viewportRect,a=this._visibleRect,h=r.viewport;o.x=h.x,o.y=h.y,o.width=h.width,o.height=h.height,a.x=0,a.y=0,a.width=h.width/this._scaleX,a.height=h.height/this._scaleY}n.postApply(this),cc.winSize.width=this._visibleRect.width,cc.winSize.height=this._visibleRect.height,cc.visibleRect&&cc.visibleRect.init(this._visibleRect),s.updateCameraViewport(),this.emit("design-resolution-changed")}else cc.logID(2201)}else cc.logID(2200)},getDesignResolutionSize:function(){return cc.size(this._designResolutionSize.width,this._designResolutionSize.height)},setRealPixelResolution:function(t,e,i){this._setViewportMeta({width:t},!0),document.documentElement.style.width=t+"px",document.body.style.width=t+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(t,e,i)},setViewportInPoints:function(t,e,i,n){var r=this._scaleX,s=this._scaleY;cc.game._renderContext.viewport(t*r+this._viewportRect.x,e*s+this._viewportRect.y,i*r,n*s)},setScissorInPoints:function(t,e,i,n){var r=this._scaleX,s=this._scaleY,o=Math.ceil(t*r+this._viewportRect.x),a=Math.ceil(e*s+this._viewportRect.y),l=Math.ceil(i*r),c=Math.ceil(n*s),u=cc.game._renderContext;if(!h){var _=u.getParameter(u.SCISSOR_BOX);h=cc.rect(_[0],_[1],_[2],_[3])}h.x===o&&h.y===a&&h.width===l&&h.height===c||(h.x=o,h.y=a,h.width=l,h.height=c,u.scissor(o,a,l,c))},isScissorEnabled:function(){return cc.game._renderContext.isEnabled(gl.SCISSOR_TEST)},getScissorRect:function(){if(!h){var t=gl.getParameter(gl.SCISSOR_BOX);h=cc.rect(t[0],t[1],t[2],t[3])}var e=1/this._scaleX,i=1/this._scaleY;return cc.rect((h.x-this._viewportRect.x)*e,(h.y-this._viewportRect.y)*i,h.width*e,h.height*i)},getViewportRect:function(){return this._viewportRect},getScaleX:function(){return this._scaleX},getScaleY:function(){return this._scaleY},getDevicePixelRatio:function(){return this._devicePixelRatio},convertToLocationInView:function(t,e,i,n){var r=n||cc.v2(),s=this._devicePixelRatio*(t-i.left),o=this._devicePixelRatio*(i.top+i.height-e);return this._isRotated?(r.x=cc.game.canvas.width-o,r.y=s):(r.x=s,r.y=o),r},_convertMouseToLocationInView:function(t,e){var i=this._viewportRect;t.x=(this._devicePixelRatio*(t.x-e.left)-i.x)/this._scaleX,t.y=(this._devicePixelRatio*(e.top+e.height-t.y)-i.y)/this._scaleY},_convertPointWithScale:function(t){var e=this._viewportRect;t.x=(t.x-e.x)/this._scaleX,t.y=(t.y-e.y)/this._scaleY},_convertTouchesWithScale:function(t){for(var e,i,n,r=this._viewportRect,s=this._scaleX,o=this._scaleY,a=0;a=0;n--){var r=i[n];r.hasOwnProperty("__attrs__")&&r.__attrs__||s(r,0,(e=i[n+1])&&e.__attrs__)}return s(t,0,(e=i[0])&&e.__attrs__),t.__attrs__})(t)}function h(t){return a(t).constructor.prototype}function l(t,e){0}cc.Integer="Integer",cc.Float="Float",cc.Boolean="Boolean",cc.String="String",e.exports={attr:o,getClassAttrs:a,getClassAttrsProto:h,setClassAttr:function(t,e,i,n){h(t)[e+r+i]=n},DELIMETER:r,getTypeChecker:l,ObjectType:function(t){return{type:"Object",ctor:t,_onAfterProp:!1}},ScriptUuid:{}}}),{"./CCClass":156,"./js":176,"./utils":180}],169:[(function(t,e,i){var n=t("./js"),r=n.array.fastRemoveAt;function s(){this.callbacks=[],this.targets=[],this.isInvoking=!1,this.containCanceled=!1}var o=s.prototype;o.removeBy=function(t,e){for(var i=this.callbacks,n=this.targets,s=0;s0}i=i||null;for(var o=n.targets,a=0;a0?this.deserializedList[0]:[]}else this.deserializedList.length=1,this.deserializedData=t?this._deserializeObject(t,!1):null,this.deserializedList[0]=this.deserializedData;return (function(t){var e,i,n,r=t.deserializedList,s=t._idPropList,o=t._idList,a=t._idObjList;for(t._classFinder&&t._classFinder.onDereferenced,e=0;e0&&(i=f+this.globalVariables.join(",")+";");var n=l.flattenCodeArray(["return (function(R){",i||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",n)(this.objs,this.funcs);for(var r=0,s=this.objsToClear_iN$t.length;r1)t.push(d+"="+this._targetExp+";"),e=d;else{if(1!==this._exps.length)return;e=this._targetExp}for(var i=0;i=0&&(f(t,i),!0)}o.formatStr=function(){var t=arguments.length;if(0===t)return"";var e=arguments[0];if(1===t)return""+e;if("string"==typeof e&&u.test(e))for(var i=1;i=0&&(t[i]=t[t.length-1],--t.length)},removeAt:f,fastRemoveAt:function(t,e){var i=t.length;e<0||e>=i||(t[e]=t[i-1],t.length=i-1)},contains:function(t,e){return t.indexOf(e)>=0},verifyType:function(t,e){if(t&&t.length>0)for(var i=0;i0){--this.count;var t=this._pool[this.count];return this._pool[this.count]=null,t}return null},p.prototype.put=function(t){var e=this._pool;if(this.count=0&&(this._pool.length=t,this.count>t&&(this.count=t))},o.Pool=p,cc.js=o,e.exports=o}),{"../utils/mutable-forward-iterator":235,"./id-generater":172}],177:[(function(t,e,i){var n=t("./js"),r={url:{canUsedInGet:!0},default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function s(t,e,i,n){if(!t.get&&!t.set)if(t.hasOwnProperty("default")){var s="_N$"+e;t.get=function(){return this[s]},t.set=function(t){var e=this[s];this[s]=t,i.call(this,e)};var o={};for(var a in n[s]=o,r){var h=r[a];t.hasOwnProperty(a)&&(o[a]=t[a],h.canUsedInGet||delete t[a])}}else 0}function o(t,e,i,n){Array.isArray(n)&&n.length>0&&(n=n[0]),t.type=n}function a(t,e,i,n){if(Array.isArray(e)){if(!(e.length>0))return cc.errorID(5508,i,n);if(cc.RawAsset.isRawAssetType(e[0]))return t.url=e[0],void delete t.type;t.type=e=e[0]}}i.getFullFormOfProperty=function(t,e,i){if(!(t&&t.constructor===Object)){if(Array.isArray(t)&&t.length>0){var r=t[0];return{default:[],type:t,_short:!0}}if("function"==typeof t){r=t;return cc.RawAsset.isRawAssetType(r)||cc.RawAsset.wasRawAssetType(r)?{default:"",url:r,_short:!0}:{default:n.isChildClassOf(r,cc.ValueType)?new r:null,type:r,_short:!0}}return{default:t,_short:!0}}return null},i.preprocessAttrs=function(t,e,n,r){for(var h in t){var l=t[h],c=i.getFullFormOfProperty(l,h,e);if(c&&(l=t[h]=c),l){var u=l.notify;u&&s(l,h,u,t),"type"in l&&a(l,l.type,e,h),"url"in l&&o(l,0,0,l.url),"type"in l&&l.type}}},i.validateMethodWithProps=function(t,e,i,n,r){return"function"==typeof t||null===t}}),{"./CCClass":156,"./js":176}],178:[(function(t,e,i){var n=[];cc._RF={push:function(t,e,i){void 0===i&&(i=e,e=""),n.push({uuid:e,script:i,module:t,exports:t.exports,beh:null})},pop:function(){var t=n.pop(),e=t.module,i=e.exports;if(i===t.exports){for(var r in i)return;e.exports=i=t.cls}},peek:function(){return n[n.length-1]}}}),{}],179:[(function(t,e,i){cc.url={_rawAssets:"",normalize:function(t){return t&&(46===t.charCodeAt(0)&&47===t.charCodeAt(1)?t=t.slice(2):47===t.charCodeAt(0)&&(t=t.slice(1))),t},raw:function(t){if((t=this.normalize(t)).startsWith("resources/")){var e=cc.loader._getResUuid(t.slice(10),cc.Asset,!0);if(e)return cc.AssetLibrary.getLibUrlNoExt(e,!0)+cc.path.extname(t)}else cc.errorID(7002,t);return this._rawAssets+t},_init:function(t){this._rawAssets=cc.path.stripSep(t)+"/"}},e.exports=cc.url}),{}],180:[(function(t,e,i){e.exports={contains:function(t,e){if("function"==typeof t.contains)return t.contains(e);if("function"==typeof t.compareDocumentPosition)return!!(16&t.compareDocumentPosition(e));var i=e.parentNode;if(i)do{if(i===t)return!0;i=i.parentNode}while(null!==i);return!1},isDomNode:"object"==typeof window&&("function"==typeof Node?function(t){return t instanceof Node}:function(t){return t&&"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName}),callInNextTick:function(t,e,i){t&&setTimeout((function(){t(e,i)}),0)}}}),{}],181:[(function(t,e,i){t("./platform/js"),t("./value-types"),t("./utils"),t("./platform/CCInputManager"),t("./platform/CCInputExtension"),t("./event"),t("./platform/CCSys"),t("./platform/CCMacro"),t("./load-pipeline"),t("./CCDirector"),t("./renderer"),t("./platform/CCView"),t("./platform/CCScreen"),t("./CCScheduler"),t("./event-manager")}),{"./CCDirector":26,"./CCScheduler":31,"./event":101,"./event-manager":97,"./load-pipeline":116,"./platform/CCInputExtension":159,"./platform/CCInputManager":160,"./platform/CCMacro":161,"./platform/CCScreen":164,"./platform/CCSys":165,"./platform/CCView":166,"./platform/js":176,"./renderer":197,"./utils":232,"./value-types":244}],182:[(function(t,e,i){t("../../platform/js");var n=t("../render-flow");t("./renderers");var r=function(t,e){this._device=t,this._camera=e,this.parentOpacity=1,this.parentOpacityDirty=0,this.worldMatDirty=0,n.init(this)};r.prototype={constructor:r,reset:function(){},_commitComp:function(t,e){var i=this._device._ctx,n=this._camera;i.setTransform(n.a,n.b,n.c,n.d,n.tx,n.ty),i.scale(1,-1),e.draw(i,t)},visit:function(t){var e=this._device._ctx,i=this._device._canvas,r=cc.Camera.main.backgroundColor,s="rgba("+r.r+", "+r.g+", "+r.b+", "+r.a/255+")";e.fillStyle=s,e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),e.fillRect(0,0,i.width,i.height),this._device._stats.drawcalls=0,n.render(t)}},e.exports=r}),{"../../platform/js":176,"../render-flow":199,"./renderers":187}],183:[(function(t,e,i){var n=function(){};n.prototype={constructor:n,_reset:function(){},render:function(){}},e.exports=n}),{}],184:[(function(t,e,i){e.exports={ForwardRenderer:t("./forward-renderer"),RenderComponentWalker:t("./canvas-render-walker"),_renderers:t("./renderers")}}),{"./canvas-render-walker":182,"./forward-renderer":183,"./renderers":187}],185:[(function(t,e,i){var n=t("../../../../graphics/helper"),r=t("../../../../graphics/types"),s=t("../../../../platform/js"),o=(r.PointFlags,r.LineJoin),a=r.LineCap;function h(){this.cmds=[],this.style={strokeStyle:"black",fillStyle:"white",lineCap:"butt",lineJoin:"miter",miterLimit:10}}var l=h.prototype;s.mixin(l,{moveTo:function(t,e){this.cmds.push(["moveTo",[t,e]])},lineTo:function(t,e){this.cmds.push(["lineTo",[t,e]])},bezierCurveTo:function(t,e,i,n,r,s){this.cmds.push(["bezierCurveTo",[t,e,i,n,r,s]])},quadraticCurveTo:function(t,e,i,n){this.cmds.push(["quadraticCurveTo",[t,e,i,n]])},arc:function(t,e,i,r,s,o){n.arc(this,t,e,i,r,s,o)},ellipse:function(t,e,i,r){n.ellipse(this,t,e,i,r)},circle:function(t,e,i){n.ellipse(this,t,e,i,i)},rect:function(t,e,i,n){this.moveTo(t,e),this.lineTo(t,e+n),this.lineTo(t+i,e+n),this.lineTo(t+i,e),this.close()},roundRect:function(t,e,i,r,s){n.roundRect(this,t,e,i,r,s)},clear:function(t,e){this.cmds.length=0},close:function(){this.cmds.push(["closePath",[]])},stroke:function(){this.cmds.push(["stroke",[]])},fill:function(){this.cmds.push(["fill",[]])}}),s.set(l,"strokeColor",(function(t){var e="rgba("+(0|t.r)+","+(0|t.g)+","+(0|t.b)+","+t.a/255+")";this.cmds.push(["strokeStyle",e]),this.style.strokeStyle=e})),s.set(l,"fillColor",(function(t){var e="rgba("+(0|t.r)+","+(0|t.g)+","+(0|t.b)+","+t.a/255+")";this.cmds.push(["fillStyle",e]),this.style.fillStyle=e})),s.set(l,"lineWidth",(function(t){this.cmds.push(["lineWidth",t]),this.style.lineWidth=t})),s.set(l,"lineCap",(function(t){var e="butt";t===a.BUTT?e="butt":t===a.ROUND?e="round":t===a.SQUARE&&(e="square"),this.cmds.push(["lineCap",e]),this.style.lineCap=e})),s.set(l,"lineJoin",(function(t){var e="bevel";t===o.BEVEL?e="bevel":t===o.ROUND?e="round":t===o.MITER&&(e="miter"),this.cmds.push(["lineJoin",e]),this.style.lineJoin=e})),s.set(l,"miterLimit",(function(t){this.cmds.push(["miterLimit",t]),this.style.miterLimit=t})),e.exports=h}),{"../../../../graphics/helper":104,"../../../../graphics/types":106,"../../../../platform/js":176}],186:[(function(t,e,i){var n=t("./impl");e.exports={createImpl:function(){return new n},draw:function(t,e){var i=e.node,n=i._worldMatrix,r=n.m00,s=n.m01,o=n.m04,a=n.m05,h=n.m12,l=n.m13;t.transform(r,s,o,a,h,l),t.save(),t.globalAlpha=i.opacity/255;var c=e._impl.style;t.strokeStyle=c.strokeStyle,t.fillStyle=c.fillStyle,t.lineWidth=c.lineWidth,t.lineJoin=c.lineJoin,t.miterLimit=c.miterLimit;for(var u=!0,_=e._impl.cmds,f=0,m=_.length;f1?1:d,p=isNaN(p)||p>1?1:p,f=f<0?0:f,m=m<0?0:m,i[0].x=-o,i[0].y=-a,i[1].x=l*d-o,i[1].y=_*p-a,i[2].x=i[1].x+f,i[2].y=i[1].y+m,i[3].x=r-o,i[3].y=s-a,e.vertDirty=!1},draw:function(t,e){var i=e.node,r=i._worldMatrix,s=r.m00,o=r.m01,a=r.m04,h=r.m05,l=r.m12,c=r.m13;t.transform(s,o,a,h,l,c),t.scale(1,-1),t.globalAlpha=i.opacity/255;for(var u=e._spriteFrame._texture,_=e._renderData._data,f=n.getColorizedImage(u,i._color),m=0,d=void 0,p=void 0,y=void 0,v=void 0,g=void 0,x=void 0,A=void 0,b=void 0,C=void 0,S=void 0,T=void 0,w=void 0,E=0;E<3;++E){v=_[E],y=_[E+1];for(var D=0;D<3;++D)d=_[D],p=_[D+1],g=d.x,x=v.y,A=p.x-g,x=-x-(b=y.y-x),C=d.u,S=y.v,T=p.u-C,w=v.v-S,T>0&&w>0&&A>0&&b>0&&(t.drawImage(f,C,S,T,w,g,x,A,b),m++)}return m}};e.exports=r}),{"../utils":196,"./simple":193}],195:[(function(t,e,i){var n=t("../utils"),r=(t("./simple"),{createData:function(t){return t.requestRenderData()},updateRenderData:function(t){t._material||t._activateMaterial()},draw:function(t,e){var i=e.node,r=i._worldMatrix,s=r.m00,o=r.m01,a=r.m04,h=r.m05,l=r.m12,c=r.m13;t.transform(s,o,a,h,l,c),t.scale(1,-1),t.globalAlpha=i.opacity/255;var u=e.spriteFrame,_=u._rect,f=u._texture,m=_.x,d=_.y,p=u._rotated?_.height:_.width,y=u._rotated?_.width:_.height,v=n.getFrameCache(f,i._color,m,d,p,y),g=i.width,x=i.height,A=-i.anchorX*g,b=-i.anchorY*x;return b=-b-x,t.translate(A,b),t.fillStyle=t.createPattern(v,"repeat"),t.fillRect(0,0,g,x),1}});e.exports=r}),{"../utils":196,"./simple":193}],196:[(function(t,e,i){function n(t,e,i,n,r,s,o){if(cc.sys.browserType===cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB)return t;var a=e._image,h=t.getContext("2d");return t.width=s,t.height=o,h.globalCompositeOperation="source-over",h.fillStyle="rgb("+i.r+","+i.g+","+i.b+")",h.fillRect(0,0,s,o),h.globalCompositeOperation="multiply",h.drawImage(a,n,r,s,o,0,0,s,o),h.globalCompositeOperation="destination-atop",h.drawImage(a,n,r,s,o,0,0,s,o),t}var r={canvasMap:{},canvasUsed:{},canvasPool:[],checking:!1,check:function(){var t=!1;for(var e in this.canvasUsed)if(t=!0,this.canvasUsed[e])this.canvasUsed[e]=!1;else{var i=this.canvasMap[e];i.width=0,i.height=0,this.canvasPool.length<32&&this.canvasPool.push(i),delete this.canvasMap[e],delete this.canvasUsed[e]}t||(cc.director.off(cc.Director.EVENT_AFTER_DRAW,this.check,this),this.checking=!1)},startCheck:function(){cc.director.on(cc.Director.EVENT_AFTER_DRAW,this.check,this),this.checking=!0},getCanvas:function(t){return this.canvasUsed[t]=!0,this.canvasMap[t]},cacheCanvas:function(t,e){this.canvasMap[e]=t,this.canvasUsed[e]=!0,this.checking||this.startCheck()},dropImage:function(t){this.canvasMap[t]&&delete this.canvasMap[t]}};e.exports={getColorizedImage:function(t,e){if(!t)return null;if(0===t.width||0===t.height)return t._image;var i=16777215&e._val;if(16777215===i)return t._image;var s=t.url+i,o=r.getCanvas(s);return o||(n(o=r.canvasPool.pop()||document.createElement("canvas"),t,e,0,0,t.width,t.height),r.cacheCanvas(o,s)),o},getFrameCache:function(t,e,i,s,o,a){if(!t||!t.url||i<0||s<0||o<=0||a<=0)return null;var h=t.url,l=!1,c=16777215&e._val;if(16777215!==c&&(h+=c,l=!0),(0!==i||0!==s&&o!==t.width&&a!==t.height)&&(h+="_"+i+"_"+s+"_"+o+"_"+a,l=!0),!l)return t._image;var u=r.getCanvas(h);return u||(n(u=r.canvasPool.pop()||document.createElement("canvas"),t,e,i,s,o,a),r.cacheCanvas(u,h)),u},dropColorizedImage:function(t,e){var i=t.url+(16777215&e._val);r.dropImage(i)}}}),{}],197:[(function(t,e,i){var n=t("./render-engine");n.math.vec3.create();cc.renderer=e.exports={renderEngine:n,Texture2D:null,canvas:null,device:null,scene:null,drawCalls:0,_walker:null,_cameraNode:null,_camera:null,_forward:null,initWebGL:function(e,i){t("./webgl/assemblers");var r=t("./webgl/render-component-walker");this.Texture2D=n.Texture2D,this.canvas=e,this.device=new n.Device(e,i),this.scene=new n.Scene,this._walker=new r(this.device,this.scene);var s=(function(t){return{defaultTexture:new n.Texture2D(t,{images:[],width:128,height:128,wrapS:n.gfx.WRAP_REPEAT,wrapT:n.gfx.WRAP_REPEAT,format:n.gfx.TEXTURE_FMT_RGB8,mipmap:!1}),programTemplates:n.shaders.templates,programChunks:n.shaders.chunks}})(this.device);this._forward=new n.ForwardRenderer(this.device,s)},initCanvas:function(e){var i=t("./canvas");this.Texture2D=n.Texture2D,this.canvas=e,this.device=new n.Device(e),this._camera={a:1,b:0,c:0,d:1,tx:0,ty:0},this._walker=new i.RenderComponentWalker(this.device,this._camera),this._forward=new i.ForwardRenderer},updateCameraViewport:function(){if(cc.director){var t=cc.director.getScene();t.scaleX=t.scaleY=1}if(cc.game.renderType===cc.game.RENDER_TYPE_CANVAS){var e=cc.view.getViewportRect();this.device.setViewport(e.x,e.y,e.width,e.height),this._camera.a=cc.view.getScaleX(),this._camera.d=cc.view.getScaleY(),this._camera.tx=e.x,this._camera.ty=e.y+e.height}else{}},render:function(t){this.device._stats.drawcalls=0,t&&(this._walker.visit(t),this._forward.render(this.scene),this.drawCalls=this.device._stats.drawcalls)},clear:function(){this._walker.reset(),this._forward._reset()}}}),{"./canvas":184,"./render-engine":198,"./webgl/assemblers":207,"./webgl/render-component-walker":222}],198:[(function(t,e,i){"use strict";var n=Math.PI/180,r=180/Math.PI,s=1e-6;function o(t){return t*n}var a=Math.random;function h(t,e){return Math.random()*(e-t)+t}var l=32,c=-1<>>=1;i;i>>>=1)n<<=1,n|=1&i,--r;t[e]=n<0)-(t<0)},abs:function(t){var e=t>>l-1;return(t^e)-e},min:function(t,e){return e^(t^e)&-(t65535)<<4,e|=i=((t>>>=e)>255)<<3,e|=i=((t>>>=i)>15)<<2,(e|=i=((t>>>=i)>3)<<1)|(t>>>=i)>>1},log10:function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},popCount:function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},countTrailingZeros:u,nextPow2:function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,1+(t|=t>>>16)},prevPow2:function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},parity:function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1},reverse:function(t){return _[255&t]<<24|_[t>>>8&255]<<16|_[t>>>16&255]<<8|_[t>>>24&255]},interleave2:function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},deinterleave2:function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},interleave3:function(t,e,i){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(i=1227133513&((i=3272356035&((i=251719695&((i=4278190335&((i&=1023)|i<<16))|i<<8))|i<<4))|i<<2))<<2},deinterleave3:function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},nextCombination:function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>u(t)+1}}),m=new Array(2),d=function(t,e){this.x=t,this.y=e};d.prototype.toJSON=function(){return m[0]=this.x,m[1]=this.y,m};var p={create:function(){return new d(0,0)},new:function(t,e){return new d(t,e)},clone:function(t){return new d(t.x,t.y)},copy:function(t,e){return t.x=e.x,t.y=e.y,t},set:function(t,e,i){return t.x=e,t.y=i,t},add:function(t,e,i){return t.x=e.x+i.x,t.y=e.y+i.y,t},subtract:function(t,e,i){return t.x=e.x-i.x,t.y=e.y-i.y,t}};p.sub=p.subtract,p.multiply=function(t,e,i){return t.x=e.x*i.x,t.y=e.y*i.y,t},p.mul=p.multiply,p.divide=function(t,e,i){return t.x=e.x/i.x,t.y=e.y/i.y,t},p.div=p.divide,p.ceil=function(t,e){return t.x=Math.ceil(e.x),t.y=Math.ceil(e.y),t},p.floor=function(t,e){return t.x=Math.floor(e.x),t.y=Math.floor(e.y),t},p.min=function(t,e,i){return t.x=Math.min(e.x,i.x),t.y=Math.min(e.y,i.y),t},p.max=function(t,e,i){return t.x=Math.max(e.x,i.x),t.y=Math.max(e.y,i.y),t},p.round=function(t,e){return t.x=Math.round(e.x),t.y=Math.round(e.y),t},p.scale=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t},p.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t},p.distance=function(t,e){var i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)},p.dist=p.distance,p.squaredDistance=function(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},p.sqrDist=p.squaredDistance,p.length=function(t){var e=t.x,i=t.y;return Math.sqrt(e*e+i*i)},p.len=p.length,p.squaredLength=function(t){var e=t.x,i=t.y;return e*e+i*i},p.sqrLen=p.squaredLength,p.negate=function(t,e){return t.x=-e.x,t.y=-e.y,t},p.inverse=function(t,e){return t.x=1/e.x,t.y=1/e.y,t},p.inverseSafe=function(t,e){var i=e.x,n=e.y;return Math.abs(i)0&&(r=1/Math.sqrt(r),t.x=e.x*r,t.y=e.y*r),t},p.dot=function(t,e){return t.x*e.x+t.y*e.y},p.cross=function(t,e,i){var n=e.x*i.y-e.y*i.x;return t.x=t.y=0,t.z=n,t},p.lerp=function(t,e,i,n){var r=e.x,s=e.y;return t.x=r+n*(i.x-r),t.y=s+n*(i.y-s),t},p.random=function(t,e){e=e||1;var i=2*a()*Math.PI;return t.x=Math.cos(i)*e,t.y=Math.sin(i)*e,t},p.transformMat2=function(t,e,i){var n=e.x,r=e.y;return t.x=i.m00*n+i.m02*r,t.y=i.m01*n+i.m03*r,t},p.transformMat23=function(t,e,i){var n=e.x,r=e.y;return t.x=i.m00*n+i.m02*r+i.m04,t.y=i.m01*n+i.m03*r+i.m05,t},p.transformMat3=function(t,e,i){var n=e.x,r=e.y;return t.x=i.m00*n+i.m03*r+i.m06,t.y=i.m01*n+i.m04*r+i.m07,t},p.transformMat4=function(t,e,i){var n=e.x,r=e.y;return t.x=i.m00*n+i.m04*r+i.m12,t.y=i.m01*n+i.m05*r+i.m13,t},p.forEach=(function(){var t=p.create();return function(e,i,n,r,s,o){var a,h;for(i||(i=2),n||(n=0),h=r?Math.min(r*i+n,e.length):e.length,a=n;a0&&(s=1/Math.sqrt(s),t.x=i*s,t.y=n*s,t.z=r*s),t},g.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},g.cross=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.x,a=i.y,h=i.z;return t.x=r*h-s*a,t.y=s*o-n*h,t.z=n*a-r*o,t},g.lerp=function(t,e,i,n){var r=e.x,s=e.y,o=e.z;return t.x=r+n*(i.x-r),t.y=s+n*(i.y-s),t.z=o+n*(i.z-o),t},g.hermite=function(t,e,i,n,r,s){var o=s*s,a=o*(2*s-3)+1,h=o*(s-2)+s,l=o*(s-1),c=o*(3-2*s);return t.x=e.x*a+i.x*h+n.x*l+r.x*c,t.y=e.y*a+i.y*h+n.y*l+r.y*c,t.z=e.z*a+i.z*h+n.z*l+r.z*c,t},g.bezier=function(t,e,i,n,r,s){var o=1-s,a=o*o,h=s*s,l=a*o,c=3*s*a,u=3*h*o,_=h*s;return t.x=e.x*l+i.x*c+n.x*u+r.x*_,t.y=e.y*l+i.y*c+n.y*u+r.y*_,t.z=e.z*l+i.z*c+n.z*u+r.z*_,t},g.random=function(t,e){e=e||1;var i=2*a()*Math.PI,n=2*a()-1,r=Math.sqrt(1-n*n)*e;return t.x=Math.cos(i)*r,t.y=Math.sin(i)*r,t.z=n*e,t},g.transformMat4=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.m03*n+i.m07*r+i.m11*s+i.m15;return o=o||1,t.x=(i.m00*n+i.m04*r+i.m08*s+i.m12)/o,t.y=(i.m01*n+i.m05*r+i.m09*s+i.m13)/o,t.z=(i.m02*n+i.m06*r+i.m10*s+i.m14)/o,t},g.transformMat3=function(t,e,i){var n=e.x,r=e.y,s=e.z;return t.x=n*i.m00+r*i.m03+s*i.m06,t.y=n*i.m01+r*i.m04+s*i.m07,t.z=n*i.m02+r*i.m05+s*i.m08,t},g.transformQuat=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.x,a=i.y,h=i.z,l=i.w,c=l*n+a*s-h*r,u=l*r+h*n-o*s,_=l*s+o*r-a*n,f=-o*n-a*r-h*s;return t.x=c*l+f*-o+u*-h-_*-a,t.y=u*l+f*-a+_*-o-c*-h,t.z=_*l+f*-h+c*-a-u*-o,t},g.rotateX=function(t,e,i,n){var r=[],s=[];return r.x=e.x-i.x,r.y=e.y-i.y,r.z=e.z-i.z,s.x=r.x,s.y=r.y*Math.cos(n)-r.z*Math.sin(n),s.z=r.y*Math.sin(n)+r.z*Math.cos(n),t.x=s.x+i.x,t.y=s.y+i.y,t.z=s.z+i.z,t},g.rotateY=function(t,e,i,n){var r=[],s=[];return r.x=e.x-i.x,r.y=e.y-i.y,r.z=e.z-i.z,s.x=r.z*Math.sin(n)+r.x*Math.cos(n),s.y=r.y,s.z=r.z*Math.cos(n)-r.x*Math.sin(n),t.x=s.x+i.x,t.y=s.y+i.y,t.z=s.z+i.z,t},g.rotateZ=function(t,e,i,n){var r=[],s=[];return r.x=e.x-i.x,r.y=e.y-i.y,r.z=e.z-i.z,s.x=r.x*Math.cos(n)-r.y*Math.sin(n),s.y=r.x*Math.sin(n)+r.y*Math.cos(n),s.z=r.z,t.x=s.x+i.x,t.y=s.y+i.y,t.z=s.z+i.z,t},g.forEach=(function(){var t=g.create();return function(e,i,n,r,s,o){var a,h;for(i||(i=3),n||(n=0),h=r?Math.min(r*i+n,e.length):e.length,a=n;a1?0:r<-1?Math.PI:Math.acos(r)}})(),g.str=function(t){return"vec3("+t.x+", "+t.y+", "+t.z+")"},g.array=function(t,e){return t[0]=e.x,t[1]=e.y,t[2]=e.z,t},g.exactEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z},g.equals=function(t,e){var i=t.x,n=t.y,r=t.z,o=e.x,a=e.y,h=e.z;return Math.abs(i-o)<=s*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-a)<=s*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-h)<=s*Math.max(1,Math.abs(r),Math.abs(h))};var x=new Array(4),A=function(t,e,i,n){this.x=t,this.y=e,this.z=i,this.w=n};A.prototype.toJSON=function(){return x[0]=this.x,x[1]=this.y,x[2]=this.z,x[3]=this.w,x};var b={create:function(){return new A(0,0,0,0)},new:function(t,e,i,n){return new A(t,e,i,n)},clone:function(t){return new A(t.x,t.y,t.z,t.w)},copy:function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t},set:function(t,e,i,n,r){return t.x=e,t.y=i,t.z=n,t.w=r,t},add:function(t,e,i){return t.x=e.x+i.x,t.y=e.y+i.y,t.z=e.z+i.z,t.w=e.w+i.w,t},subtract:function(t,e,i){return t.x=e.x-i.x,t.y=e.y-i.y,t.z=e.z-i.z,t.w=e.w-i.w,t}};b.sub=b.subtract,b.multiply=function(t,e,i){return t.x=e.x*i.x,t.y=e.y*i.y,t.z=e.z*i.z,t.w=e.w*i.w,t},b.mul=b.multiply,b.divide=function(t,e,i){return t.x=e.x/i.x,t.y=e.y/i.y,t.z=e.z/i.z,t.w=e.w/i.w,t},b.div=b.divide,b.ceil=function(t,e){return t.x=Math.ceil(e.x),t.y=Math.ceil(e.y),t.z=Math.ceil(e.z),t.w=Math.ceil(e.w),t},b.floor=function(t,e){return t.x=Math.floor(e.x),t.y=Math.floor(e.y),t.z=Math.floor(e.z),t.w=Math.floor(e.w),t},b.min=function(t,e,i){return t.x=Math.min(e.x,i.x),t.y=Math.min(e.y,i.y),t.z=Math.min(e.z,i.z),t.w=Math.min(e.w,i.w),t},b.max=function(t,e,i){return t.x=Math.max(e.x,i.x),t.y=Math.max(e.y,i.y),t.z=Math.max(e.z,i.z),t.w=Math.max(e.w,i.w),t},b.round=function(t,e){return t.x=Math.round(e.x),t.y=Math.round(e.y),t.z=Math.round(e.z),t.w=Math.round(e.w),t},b.scale=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i,t},b.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t.z=e.z+i.z*n,t.w=e.w+i.w*n,t},b.distance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z,s=e.w-t.w;return Math.sqrt(i*i+n*n+r*r+s*s)},b.dist=b.distance,b.squaredDistance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z,s=e.w-t.w;return i*i+n*n+r*r+s*s},b.sqrDist=b.squaredDistance,b.length=function(t){var e=t.x,i=t.y,n=t.z,r=t.w;return Math.sqrt(e*e+i*i+n*n+r*r)},b.len=b.length,b.squaredLength=function(t){var e=t.x,i=t.y,n=t.z,r=t.w;return e*e+i*i+n*n+r*r},b.sqrLen=b.squaredLength,b.negate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=-e.w,t},b.inverse=function(t,e){return t.x=1/e.x,t.y=1/e.y,t.z=1/e.z,t.w=1/e.w,t},b.inverseSafe=function(t,e){var i=e.x,n=e.y,r=e.z,o=e.w;return Math.abs(i)0&&(o=1/Math.sqrt(o),t.x=i*o,t.y=n*o,t.z=r*o,t.w=s*o),t},b.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},b.lerp=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=e.w;return t.x=r+n*(i.x-r),t.y=s+n*(i.y-s),t.z=o+n*(i.z-o),t.w=a+n*(i.w-a),t},b.random=function(t,e){return e=e||1,t.x=a(),t.y=a(),t.z=a(),t.w=a(),b.normalize(t,t),b.scale(t,t,e),t},b.transformMat4=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=e.w;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12*o,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13*o,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14*o,t.w=i.m03*n+i.m07*r+i.m11*s+i.m15*o,t},b.transformQuat=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.x,a=i.y,h=i.z,l=i.w,c=l*n+a*s-h*r,u=l*r+h*n-o*s,_=l*s+o*r-a*n,f=-o*n-a*r-h*s;return t.x=c*l+f*-o+u*-h-_*-a,t.y=u*l+f*-a+_*-o-c*-h,t.z=_*l+f*-h+c*-a-u*-o,t.w=e.w,t},b.forEach=(function(){var t=b.create();return function(e,i,n,r,s,o){var a,h;for(i||(i=4),n||(n=0),h=r?Math.min(r*i+n,e.length):e.length,a=n;a.999999?(n.x=0,n.y=0,n.z=0,n.w=1,n):(g.cross(t,r,s),n.x=t.x,n.y=t.y,n.z=t.z,n.w=1+o,D.normalize(n,n))}})(),D.getAxisAngle=function(t,e){var i=2*Math.acos(e.w),n=Math.sin(i/2);return 0!=n?(t.x=e.x/n,t.y=e.y/n,t.z=e.z/n):(t.x=1,t.y=0,t.z=0),i},D.multiply=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=e.w,a=i.x,h=i.y,l=i.z,c=i.w;return t.x=n*c+o*a+r*l-s*h,t.y=r*c+o*h+s*a-n*l,t.z=s*c+o*l+n*h-r*a,t.w=o*c-n*a-r*h-s*l,t},D.mul=D.multiply,D.scale=b.scale,D.rotateX=function(t,e,i){i*=.5;var n=e.x,r=e.y,s=e.z,o=e.w,a=Math.sin(i),h=Math.cos(i);return t.x=n*h+o*a,t.y=r*h+s*a,t.z=s*h-r*a,t.w=o*h-n*a,t},D.rotateY=function(t,e,i){i*=.5;var n=e.x,r=e.y,s=e.z,o=e.w,a=Math.sin(i),h=Math.cos(i);return t.x=n*h-s*a,t.y=r*h+o*a,t.z=s*h+n*a,t.w=o*h-r*a,t},D.rotateZ=function(t,e,i){i*=.5;var n=e.x,r=e.y,s=e.z,o=e.w,a=Math.sin(i),h=Math.cos(i);return t.x=n*h+r*a,t.y=r*h-n*a,t.z=s*h+o*a,t.w=o*h-s*a,t},D.rotateAround=(function(){var t=g.create(),e=D.create();return function(i,n,r,s){return D.invert(e,n),g.transformQuat(t,r,e),D.fromAxisAngle(e,t,s),D.mul(i,n,e),i}})(),D.rotateAroundLocal=(function(){var t=D.create();return function(e,i,n,r){return D.fromAxisAngle(t,n,r),D.mul(e,i,t),e}})(),D.calculateW=function(t,e){var i=e.x,n=e.y,r=e.z;return t.x=i,t.y=n,t.z=r,t.w=Math.sqrt(Math.abs(1-i*i-n*n-r*r)),t},D.dot=b.dot,D.lerp=b.lerp,D.slerp=function(t,e,i,n){var r,s,o,a,h,l=e.x,c=e.y,u=e.z,_=e.w,f=i.x,m=i.y,d=i.z,p=i.w;return(s=l*f+c*m+u*d+_*p)<0&&(s=-s,f=-f,m=-m,d=-d,p=-p),1-s>1e-6?(r=Math.acos(s),o=Math.sin(r),a=Math.sin((1-n)*r)/o,h=Math.sin(n*r)/o):(a=1-n,h=n),t.x=a*l+h*f,t.y=a*c+h*m,t.z=a*u+h*d,t.w=a*_+h*p,t},D.sqlerp=(function(){var t=D.create(),e=D.create();return function(i,n,r,s,o,a){return D.slerp(t,n,o,a),D.slerp(e,r,s,a),D.slerp(i,t,e,2*a*(1-a)),i}})(),D.invert=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w,o=i*i+n*n+r*r+s*s,a=o?1/o:0;return t.x=-i*a,t.y=-n*a,t.z=-r*a,t.w=s*a,t},D.conjugate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w,t},D.length=b.length,D.len=D.length,D.squaredLength=b.squaredLength,D.sqrLen=D.squaredLength,D.normalize=b.normalize,D.fromAxes=(function(){var t=T.create();return function(e,i,n,r){return T.set(t,i.x,i.y,i.z,n.x,n.y,n.z,r.x,r.y,r.z),D.normalize(e,D.fromMat3(e,t))}})(),D.fromViewUp=(function(){var t=T.create();return function(e,i,n){return T.fromViewUp(t,i,n),t?D.normalize(e,D.fromMat3(e,t)):null}})(),D.fromAxisAngle=function(t,e,i){i*=.5;var n=Math.sin(i);return t.x=n*e.x,t.y=n*e.y,t.z=n*e.z,t.w=Math.cos(i),t},D.fromMat3=function(t,e){var i=e.m00,n=e.m03,r=e.m06,s=e.m01,o=e.m04,a=e.m07,h=e.m02,l=e.m05,c=e.m08,u=i+o+c;if(u>0){var _=.5/Math.sqrt(u+1);t.w=.25/_,t.x=(l-a)*_,t.y=(r-h)*_,t.z=(s-n)*_}else if(i>o&&i>c){var f=2*Math.sqrt(1+i-o-c);t.w=(l-a)/f,t.x=.25*f,t.y=(n+s)/f,t.z=(r+h)/f}else if(o>c){var m=2*Math.sqrt(1+o-i-c);t.w=(r-h)/m,t.x=(n+s)/m,t.y=.25*m,t.z=(a+l)/m}else{var d=2*Math.sqrt(1+c-i-o);t.w=(s-n)/d,t.x=(r+h)/d,t.y=(a+l)/d,t.z=.25*d}return t},D.fromEuler=function(t,e,i,n){var r=.5*Math.PI/180;e*=r,i*=r,n*=r;var s=Math.sin(e),o=Math.cos(e),a=Math.sin(i),h=Math.cos(i),l=Math.sin(n),c=Math.cos(n);return t.x=s*h*c-o*a*l,t.y=o*a*c+s*h*l,t.z=o*h*l-s*a*c,t.w=o*h*c+s*a*l,t},D.str=function(t){return"quat("+t.x+", "+t.y+", "+t.z+", "+t.w+")"},D.array=function(t,e){return t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w,t},D.exactEquals=b.exactEquals,D.equals=b.equals;var B=new Array(4),M=function(t,e,i,n){this.m00=t,this.m01=e,this.m02=i,this.m03=n};M.prototype.toJSON=function(){return B[0]=this.m00,B[1]=this.m01,B[2]=this.m02,B[3]=this.m03,B};var P={create:function(){return new M(1,0,0,1)},new:function(t,e,i,n){return new M(t,e,i,n)},clone:function(t){return new M(t.m00,t.m01,t.m02,t.m03)},copy:function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t},identity:function(t){return t.m00=1,t.m01=0,t.m02=0,t.m03=1,t},set:function(t,e,i,n,r){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t},transpose:function(t,e){if(t===e){var i=e.m01;t.m01=e.m02,t.m02=i}else t.m00=e.m00,t.m01=e.m02,t.m02=e.m01,t.m03=e.m03;return t},invert:function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=i*s-r*n;return o?(o=1/o,t.m00=s*o,t.m01=-n*o,t.m02=-r*o,t.m03=i*o,t):null},adjoint:function(t,e){var i=e.m00;return t.m00=e.m03,t.m01=-e.m01,t.m02=-e.m02,t.m03=i,t},determinant:function(t){return t.m00*t.m03-t.m02*t.m01},multiply:function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=i.m00,h=i.m01,l=i.m02,c=i.m03;return t.m00=n*a+s*h,t.m01=r*a+o*h,t.m02=n*l+s*c,t.m03=r*l+o*c,t}};P.mul=P.multiply,P.rotate=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=Math.sin(i),h=Math.cos(i);return t.m00=n*h+s*a,t.m01=r*h+o*a,t.m02=n*-a+s*h,t.m03=r*-a+o*h,t},P.scale=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=i.x,h=i.y;return t.m00=n*a,t.m01=r*a,t.m02=s*h,t.m03=o*h,t},P.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t.m00=n,t.m01=i,t.m02=-i,t.m03=n,t},P.fromScaling=function(t,e){return t.m00=e.x,t.m01=0,t.m02=0,t.m03=e.y,t},P.str=function(t){return"mat2("+t.m00+", "+t.m01+", "+t.m02+", "+t.m03+")"},P.array=function(t,e){return t[0]=e.m00,t[1]=e.m01,t[2]=e.m02,t[3]=e.m03,t},P.frob=function(t){return Math.sqrt(Math.pow(t.m00,2)+Math.pow(t.m01,2)+Math.pow(t.m02,2)+Math.pow(t.m03,2))},P.LDU=function(t,e,i,n){t.m02=n.m02/n.m00,i.m00=n.m00,i.m01=n.m01,i.m03=n.m03-t.m02*i.m01},P.add=function(t,e,i){return t.m00=e.m00+i.m00,t.m01=e.m01+i.m01,t.m02=e.m02+i.m02,t.m03=e.m03+i.m03,t},P.subtract=function(t,e,i){return t.m00=e.m00-i.m00,t.m01=e.m01-i.m01,t.m02=e.m02-i.m02,t.m03=e.m03-i.m03,t},P.sub=P.subtract,P.exactEquals=function(t,e){return t.m00===e.m00&&t.m01===e.m01&&t.m02===e.m02&&t.m03===e.m03},P.equals=function(t,e){var i=t.m00,n=t.m01,r=t.m02,o=t.m03,a=e.m00,h=e.m01,l=e.m02,c=e.m03;return Math.abs(i-a)<=s*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-h)<=s*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(r-l)<=s*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(o-c)<=s*Math.max(1,Math.abs(o),Math.abs(c))},P.multiplyScalar=function(t,e,i){return t.m00=e.m00*i,t.m01=e.m01*i,t.m02=e.m02*i,t.m03=e.m03*i,t},P.multiplyScalarAndAdd=function(t,e,i,n){return t.m00=e.m00+i.m00*n,t.m01=e.m01+i.m01*n,t.m02=e.m02+i.m02*n,t.m03=e.m03+i.m03*n,t};var I=new Array(6),R=function(t,e,i,n,r,s){this.m00=t,this.m01=e,this.m02=i,this.m03=n,this.m04=r,this.m05=s};R.prototype.toJSON=function(){return I[0]=this.m00,I[1]=this.m01,I[2]=this.m02,I[3]=this.m03,I[4]=this.m04,I[5]=this.m05,I};var L={create:function(){return new R(1,0,0,1,0,0)},new:function(t,e,i,n,r,s){return new R(t,e,i,n,r,s)},clone:function(t){return new R(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05)},copy:function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m04=e.m04,t.m05=e.m05,t},identity:function(t){return t.m00=1,t.m01=0,t.m02=0,t.m03=1,t.m04=0,t.m05=0,t},set:function(t,e,i,n,r,s,o){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t.m04=s,t.m05=o,t},invert:function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=i*s-n*r;return h?(h=1/h,t.m00=s*h,t.m01=-n*h,t.m02=-r*h,t.m03=i*h,t.m04=(r*a-s*o)*h,t.m05=(n*o-i*a)*h,t):null},determinant:function(t){return t.m00*t.m03-t.m01*t.m02},multiply:function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,l=i.m00,c=i.m01,u=i.m02,_=i.m03,f=i.m04,m=i.m05;return t.m00=n*l+s*c,t.m01=r*l+o*c,t.m02=n*u+s*_,t.m03=r*u+o*_,t.m04=n*f+s*m+a,t.m05=r*f+o*m+h,t}};L.mul=L.multiply,L.rotate=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,l=Math.sin(i),c=Math.cos(i);return t.m00=n*c+s*l,t.m01=r*c+o*l,t.m02=n*-l+s*c,t.m03=r*-l+o*c,t.m04=a,t.m05=h,t},L.scale=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,l=i.x,c=i.y;return t.m00=n*l,t.m01=r*l,t.m02=s*c,t.m03=o*c,t.m04=a,t.m05=h,t},L.translate=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,l=i.x,c=i.y;return t.m00=n,t.m01=r,t.m02=s,t.m03=o,t.m04=n*l+s*c+a,t.m05=r*l+o*c+h,t},L.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t.m00=n,t.m01=i,t.m02=-i,t.m03=n,t.m04=0,t.m05=0,t},L.fromScaling=function(t,e){return t.m00=e.m00,t.m01=0,t.m02=0,t.m03=e.m01,t.m04=0,t.m05=0,t},L.fromTranslation=function(t,e){return t.m00=1,t.m01=0,t.m02=0,t.m03=1,t.m04=e.x,t.m05=e.y,t},L.str=function(t){return"mat23("+t.m00+", "+t.m01+", "+t.m02+", "+t.m03+", "+t.m04+", "+t.m05+")"},L.array=function(t,e){return t[0]=e.m00,t[1]=e.m01,t[2]=e.m02,t[3]=e.m03,t[4]=e.m04,t[5]=e.m05,t},L.array4x4=function(t,e){return t[0]=e.m00,t[1]=e.m01,t[2]=0,t[3]=0,t[4]=e.m02,t[5]=e.m03,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e.m04,t[13]=e.m05,t[14]=0,t[15]=1,t},L.frob=function(t){return Math.sqrt(Math.pow(t.m00,2)+Math.pow(t.m01,2)+Math.pow(t.m02,2)+Math.pow(t.m03,2)+Math.pow(t.m04,2)+Math.pow(t.m05,2)+1)},L.add=function(t,e,i){return t.m00=e.m00+i.m00,t.m01=e.m01+i.m01,t.m02=e.m02+i.m02,t.m03=e.m03+i.m03,t.m04=e.m04+i.m04,t.m05=e.m05+i.m05,t},L.subtract=function(t,e,i){return t.m00=e.m00-i.m00,t.m01=e.m01-i.m01,t.m02=e.m02-i.m02,t.m03=e.m03-i.m03,t.m04=e.m04-i.m04,t.m05=e.m05-i.m05,t},L.sub=L.subtract,L.multiplyScalar=function(t,e,i){return t.m00=e.m00*i,t.m01=e.m01*i,t.m02=e.m02*i,t.m03=e.m03*i,t.m04=e.m04*i,t.m05=e.m05*i,t},L.multiplyScalarAndAdd=function(t,e,i,n){return t.m00=e.m00+i.m00*n,t.m01=e.m01+i.m01*n,t.m02=e.m02+i.m02*n,t.m03=e.m03+i.m03*n,t.m04=e.m04+i.m04*n,t.m05=e.m05+i.m05*n,t},L.exactEquals=function(t,e){return t.m00===e.m00&&t.m01===e.m01&&t.m02===e.m02&&t.m03===e.m03&&t.m04===e.m04&&t.m05===e.m05},L.equals=function(t,e){var i=t.m00,n=t.m01,r=t.m02,o=t.m03,a=t.m04,h=t.m05,l=e.m00,c=e.m01,u=e.m02,_=e.m03,f=e.m04,m=e.m05;return Math.abs(i-l)<=s*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(n-c)<=s*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(r-u)<=s*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(o-_)<=s*Math.max(1,Math.abs(o),Math.abs(_))&&Math.abs(a-f)<=s*Math.max(1,Math.abs(a),Math.abs(f))&&Math.abs(h-m)<=s*Math.max(1,Math.abs(h),Math.abs(m))};var O=new Array(16),F=function(t,e,i,n,r,s,o,a,h,l,c,u,_,f,m,d){this.m00=t,this.m01=e,this.m02=i,this.m03=n,this.m04=r,this.m05=s,this.m06=o,this.m07=a,this.m08=h,this.m09=l,this.m10=c,this.m11=u,this.m12=_,this.m13=f,this.m14=m,this.m15=d};F.prototype.toJSON=function(){return O[0]=this.m00,O[1]=this.m01,O[2]=this.m02,O[3]=this.m03,O[4]=this.m04,O[5]=this.m05,O[6]=this.m06,O[7]=this.m07,O[8]=this.m08,O[9]=this.m09,O[10]=this.m10,O[11]=this.m11,O[12]=this.m12,O[13]=this.m13,O[14]=this.m14,O[15]=this.m15,O};var V={create:function(){return new F(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},new:function(t,e,i,n,r,s,o,a,h,l,c,u,_,f,m,d){return new F(t,e,i,n,r,s,o,a,h,l,c,u,_,f,m,d)},clone:function(t){return new F(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05,t.m06,t.m07,t.m08,t.m09,t.m10,t.m11,t.m12,t.m13,t.m14,t.m15)},copy:function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m04=e.m04,t.m05=e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t.m09=e.m09,t.m10=e.m10,t.m11=e.m11,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15,t},set:function(t,e,i,n,r,s,o,a,h,l,c,u,_,f,m,d,p){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t.m04=s,t.m05=o,t.m06=a,t.m07=h,t.m08=l,t.m09=c,t.m10=u,t.m11=_,t.m12=f,t.m13=m,t.m14=d,t.m15=p,t},identity:function(t){return t.m00=1,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=1,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=1,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},transpose:function(t,e){if(t===e){var i=e.m01,n=e.m02,r=e.m03,s=e.m06,o=e.m07,a=e.m11;t.m01=e.m04,t.m02=e.m08,t.m03=e.m12,t.m04=i,t.m06=e.m09,t.m07=e.m13,t.m08=n,t.m09=s,t.m11=e.m14,t.m12=r,t.m13=o,t.m14=a}else t.m00=e.m00,t.m01=e.m04,t.m02=e.m08,t.m03=e.m12,t.m04=e.m01,t.m05=e.m05,t.m06=e.m09,t.m07=e.m13,t.m08=e.m02,t.m09=e.m06,t.m10=e.m10,t.m11=e.m14,t.m12=e.m03,t.m13=e.m07,t.m14=e.m11,t.m15=e.m15;return t},invert:function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=e.m06,l=e.m07,c=e.m08,u=e.m09,_=e.m10,f=e.m11,m=e.m12,d=e.m13,p=e.m14,y=e.m15,v=i*a-n*o,g=i*h-r*o,x=i*l-s*o,A=n*h-r*a,b=n*l-s*a,C=r*l-s*h,S=c*d-u*m,T=c*p-_*m,w=c*y-f*m,E=u*p-_*d,D=u*y-f*d,B=_*y-f*p,M=v*B-g*D+x*E+A*w-b*T+C*S;return M?(M=1/M,t.m00=(a*B-h*D+l*E)*M,t.m01=(r*D-n*B-s*E)*M,t.m02=(d*C-p*b+y*A)*M,t.m03=(_*b-u*C-f*A)*M,t.m04=(h*w-o*B-l*T)*M,t.m05=(i*B-r*w+s*T)*M,t.m06=(p*x-m*C-y*g)*M,t.m07=(c*C-_*x+f*g)*M,t.m08=(o*D-a*w+l*S)*M,t.m09=(n*w-i*D-s*S)*M,t.m10=(m*b-d*x+y*v)*M,t.m11=(u*x-c*b-f*v)*M,t.m12=(a*T-o*E-h*S)*M,t.m13=(i*E-n*T+r*S)*M,t.m14=(d*g-m*A-p*v)*M,t.m15=(c*A-u*g+_*v)*M,t):null},adjoint:function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=e.m06,l=e.m07,c=e.m08,u=e.m09,_=e.m10,f=e.m11,m=e.m12,d=e.m13,p=e.m14,y=e.m15;return t.m00=a*(_*y-f*p)-u*(h*y-l*p)+d*(h*f-l*_),t.m01=-(n*(_*y-f*p)-u*(r*y-s*p)+d*(r*f-s*_)),t.m02=n*(h*y-l*p)-a*(r*y-s*p)+d*(r*l-s*h),t.m03=-(n*(h*f-l*_)-a*(r*f-s*_)+u*(r*l-s*h)),t.m04=-(o*(_*y-f*p)-c*(h*y-l*p)+m*(h*f-l*_)),t.m05=i*(_*y-f*p)-c*(r*y-s*p)+m*(r*f-s*_),t.m06=-(i*(h*y-l*p)-o*(r*y-s*p)+m*(r*l-s*h)),t.m07=i*(h*f-l*_)-o*(r*f-s*_)+c*(r*l-s*h),t.m08=o*(u*y-f*d)-c*(a*y-l*d)+m*(a*f-l*u),t.m09=-(i*(u*y-f*d)-c*(n*y-s*d)+m*(n*f-s*u)),t.m10=i*(a*y-l*d)-o*(n*y-s*d)+m*(n*l-s*a),t.m11=-(i*(a*f-l*u)-o*(n*f-s*u)+c*(n*l-s*a)),t.m12=-(o*(u*p-_*d)-c*(a*p-h*d)+m*(a*_-h*u)),t.m13=i*(u*p-_*d)-c*(n*p-r*d)+m*(n*_-r*u),t.m14=-(i*(a*p-h*d)-o*(n*p-r*d)+m*(n*h-r*a)),t.m15=i*(a*_-h*u)-o*(n*_-r*u)+c*(n*h-r*a),t},determinant:function(t){var e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,o=t.m05,a=t.m06,h=t.m07,l=t.m08,c=t.m09,u=t.m10,_=t.m11,f=t.m12,m=t.m13,d=t.m14,p=t.m15;return(e*o-i*s)*(u*p-_*d)-(e*a-n*s)*(c*p-_*m)+(e*h-r*s)*(c*d-u*m)+(i*a-n*o)*(l*p-_*f)-(i*h-r*o)*(l*d-u*f)+(n*h-r*a)*(l*m-c*f)},multiply:function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,l=e.m06,c=e.m07,u=e.m08,_=e.m09,f=e.m10,m=e.m11,d=e.m12,p=e.m13,y=e.m14,v=e.m15,g=i.m00,x=i.m01,A=i.m02,b=i.m03;return t.m00=g*n+x*a+A*u+b*d,t.m01=g*r+x*h+A*_+b*p,t.m02=g*s+x*l+A*f+b*y,t.m03=g*o+x*c+A*m+b*v,g=i.m04,x=i.m05,A=i.m06,b=i.m07,t.m04=g*n+x*a+A*u+b*d,t.m05=g*r+x*h+A*_+b*p,t.m06=g*s+x*l+A*f+b*y,t.m07=g*o+x*c+A*m+b*v,g=i.m08,x=i.m09,A=i.m10,b=i.m11,t.m08=g*n+x*a+A*u+b*d,t.m09=g*r+x*h+A*_+b*p,t.m10=g*s+x*l+A*f+b*y,t.m11=g*o+x*c+A*m+b*v,g=i.m12,x=i.m13,A=i.m14,b=i.m15,t.m12=g*n+x*a+A*u+b*d,t.m13=g*r+x*h+A*_+b*p,t.m14=g*s+x*l+A*f+b*y,t.m15=g*o+x*c+A*m+b*v,t}};V.mul=V.multiply,V.translate=function(t,e,i){var n,r,s,o,a,h,l,c,u,_,f,m,d=i.x,p=i.y,y=i.z;return e===t?(t.m12=e.m00*d+e.m04*p+e.m08*y+e.m12,t.m13=e.m01*d+e.m05*p+e.m09*y+e.m13,t.m14=e.m02*d+e.m06*p+e.m10*y+e.m14,t.m15=e.m03*d+e.m07*p+e.m11*y+e.m15):(n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,l=e.m06,c=e.m07,u=e.m08,_=e.m09,f=e.m10,m=e.m11,t.m00=n,t.m01=r,t.m02=s,t.m03=o,t.m04=a,t.m05=h,t.m06=l,t.m07=c,t.m08=u,t.m09=_,t.m10=f,t.m11=m,t.m12=n*d+a*p+u*y+e.m12,t.m13=r*d+h*p+_*y+e.m13,t.m14=s*d+l*p+f*y+e.m14,t.m15=o*d+c*p+m*y+e.m15),t},V.scale=function(t,e,i){var n=i.x,r=i.y,s=i.z;return t.m00=e.m00*n,t.m01=e.m01*n,t.m02=e.m02*n,t.m03=e.m03*n,t.m04=e.m04*r,t.m05=e.m05*r,t.m06=e.m06*r,t.m07=e.m07*r,t.m08=e.m08*s,t.m09=e.m09*s,t.m10=e.m10*s,t.m11=e.m11*s,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15,t},V.rotate=function(t,e,i,n){var r,o,a,h,l,c,u,_,f,m,d,p,y,v,g,x,A,b,C,S,T,w,E,D,B=n.x,M=n.y,P=n.z,I=Math.sqrt(B*B+M*M+P*P);return Math.abs(I)0?(n=2*Math.sqrt(i+1),t.w=.25*n,t.x=(e.m06-e.m09)/n,t.y=(e.m08-e.m02)/n,t.z=(e.m01-e.m04)/n):e.m00>e.m05&e.m00>e.m10?(n=2*Math.sqrt(1+e.m00-e.m05-e.m10),t.w=(e.m06-e.m09)/n,t.x=.25*n,t.y=(e.m01+e.m04)/n,t.z=(e.m08+e.m02)/n):e.m05>e.m10?(n=2*Math.sqrt(1+e.m05-e.m00-e.m10),t.w=(e.m08-e.m02)/n,t.x=(e.m01+e.m04)/n,t.y=.25*n,t.z=(e.m06+e.m09)/n):(n=2*Math.sqrt(1+e.m10-e.m00-e.m05),t.w=(e.m01-e.m04)/n,t.x=(e.m08+e.m02)/n,t.y=(e.m06+e.m09)/n,t.z=.25*n),t},V.fromRTS=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=e.w,h=r+r,l=s+s,c=o+o,u=r*h,_=r*l,f=r*c,m=s*l,d=s*c,p=o*c,y=a*h,v=a*l,g=a*c,x=n.x,A=n.y,b=n.z;return t.m00=(1-(m+p))*x,t.m01=(_+g)*x,t.m02=(f-v)*x,t.m03=0,t.m04=(_-g)*A,t.m05=(1-(u+p))*A,t.m06=(d+y)*A,t.m07=0,t.m08=(f+v)*b,t.m09=(d-y)*b,t.m10=(1-(u+m))*b,t.m11=0,t.m12=i.x,t.m13=i.y,t.m14=i.z,t.m15=1,t},V.fromRTSOrigin=function(t,e,i,n,r){var s=e.x,o=e.y,a=e.z,h=e.w,l=s+s,c=o+o,u=a+a,_=s*l,f=s*c,m=s*u,d=o*c,p=o*u,y=a*u,v=h*l,g=h*c,x=h*u,A=n.x,b=n.y,C=n.z,S=r.x,T=r.y,w=r.z;return t.m00=(1-(d+y))*A,t.m01=(f+x)*A,t.m02=(m-g)*A,t.m03=0,t.m04=(f-x)*b,t.m05=(1-(_+y))*b,t.m06=(p+v)*b,t.m07=0,t.m08=(m+g)*C,t.m09=(p-v)*C,t.m10=(1-(_+d))*C,t.m11=0,t.m12=i.x+S-(t.m00*S+t.m04*T+t.m08*w),t.m13=i.y+T-(t.m01*S+t.m05*T+t.m09*w),t.m14=i.z+w-(t.m02*S+t.m06*T+t.m10*w),t.m15=1,t},V.fromQuat=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w,o=i+i,a=n+n,h=r+r,l=i*o,c=n*o,u=n*a,_=r*o,f=r*a,m=r*h,d=s*o,p=s*a,y=s*h;return t.m00=1-u-m,t.m01=c+y,t.m02=_-p,t.m03=0,t.m04=c-y,t.m05=1-l-m,t.m06=f+d,t.m07=0,t.m08=_+p,t.m09=f-d,t.m10=1-l-u,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},V.frustum=function(t,e,i,n,r,s,o){var a=1/(i-e),h=1/(r-n),l=1/(s-o);return t.m00=2*s*a,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=2*s*h,t.m06=0,t.m07=0,t.m08=(i+e)*a,t.m09=(r+n)*h,t.m10=(o+s)*l,t.m11=-1,t.m12=0,t.m13=0,t.m14=o*s*2*l,t.m15=0,t},V.perspective=function(t,e,i,n,r){var s=1/Math.tan(e/2),o=1/(n-r);return t.m00=s/i,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=s,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=(r+n)*o,t.m11=-1,t.m12=0,t.m13=0,t.m14=2*r*n*o,t.m15=0,t},V.perspectiveFromFieldOfView=function(t,e,i,n){var r=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),h=2/(o+a),l=2/(r+s);return t.m00=h,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=l,t.m06=0,t.m07=0,t.m08=-(o-a)*h*.5,t.m09=(r-s)*l*.5,t.m10=n/(i-n),t.m11=-1,t.m12=0,t.m13=0,t.m14=n*i/(i-n),t.m15=0,t},V.ortho=function(t,e,i,n,r,s,o){var a=1/(e-i),h=1/(n-r),l=1/(s-o);return t.m00=-2*a,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=-2*h,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=2*l,t.m11=0,t.m12=(e+i)*a,t.m13=(r+n)*h,t.m14=(o+s)*l,t.m15=1,t},V.lookAt=function(t,e,i,n){var r,o,a,h,l,c,u,_,f,m,d=e.x,p=e.y,y=e.z,v=n.x,g=n.y,x=n.z,A=i.x,b=i.y,C=i.z;return Math.abs(d-A)>16)/255,n=(e>>8&255)/255,r=(255&e)/255;return t.r=i,t.g=n,t.b=r,t},add:function(t,e,i){return t.r=e.r+i.r,t.g=e.g+i.g,t.b=e.b+i.b,t},subtract:function(t,e,i){return t.r=e.r-i.r,t.g=e.g-i.g,t.b=e.b-i.b,t}};G.sub=G.subtract,G.multiply=function(t,e,i){return t.r=e.r*i.r,t.g=e.g*i.g,t.b=e.b*i.b,t},G.mul=G.multiply,G.divide=function(t,e,i){return t.r=e.r/i.r,t.g=e.g/i.g,t.b=e.b/i.b,t},G.div=G.divide,G.scale=function(t,e,i){return t.r=e.r*i,t.g=e.g*i,t.b=e.b*i,t},G.lerp=function(t,e,i,n){var r=e.r,s=e.g,o=e.b;return t.r=r+n*(i.r-r),t.g=s+n*(i.g-s),t.b=o+n*(i.b-o),t},G.str=function(t){return"color3("+t.r+", "+t.g+", "+t.b+")"},G.array=function(t,e){return t[0]=e.r,t[1]=e.g,t[2]=e.b,t},G.exactEquals=function(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b},G.equals=function(t,e){var i=t.r,n=t.g,r=t.b,o=e.r,a=e.g,h=e.b;return Math.abs(i-o)<=s*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-a)<=s*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-h)<=s*Math.max(1,Math.abs(r),Math.abs(h))},G.hex=function(t){return 255*t.r<<16|255*t.g<<8|255*t.b};var z=new Array(4),U=function(t,e,i,n){this.r=t,this.g=e,this.b=i,this.a=n};U.prototype.toJSON=function(){return z[0]=this.r,z[1]=this.g,z[2]=this.b,z[3]=this.a,z};var W={create:function(){return new U(1,1,1,1)},new:function(t,e,i,n){return new U(t,e,i,n)},clone:function(t){return new U(t.r,t.g,t.b,t.a)},copy:function(t,e){return t.r=e.r,t.g=e.g,t.b=e.b,t.a=e.a,t},set:function(t,e,i,n,r){return t.r=e,t.g=i,t.b=n,t.a=r,t},fromHex:function(t,e){var i=(e>>24)/255,n=(e>>16&255)/255,r=(e>>8&255)/255,s=(255&e)/255;return t.r=i,t.g=n,t.b=r,t.a=s,t},add:function(t,e,i){return t.r=e.r+i.r,t.g=e.g+i.g,t.b=e.b+i.b,t.a=e.a+i.a,t},subtract:function(t,e,i){return t.r=e.r-i.r,t.g=e.g-i.g,t.b=e.b-i.b,t.a=e.a-i.a,t}};W.sub=W.subtract,W.multiply=function(t,e,i){return t.r=e.r*i.r,t.g=e.g*i.g,t.b=e.b*i.b,t.a=e.a*i.a,t},W.mul=W.multiply,W.divide=function(t,e,i){return t.r=e.r/i.r,t.g=e.g/i.g,t.b=e.b/i.b,t.a=e.a/i.a,t},W.div=W.divide,W.scale=function(t,e,i){return t.r=e.r*i,t.g=e.g*i,t.b=e.b*i,t.a=e.a*i,t},W.lerp=function(t,e,i,n){var r=e.r,s=e.g,o=e.b,a=e.a;return t.r=r+n*(i.r-r),t.g=s+n*(i.g-s),t.b=o+n*(i.b-o),t.a=a+n*(i.a-a),t},W.str=function(t){return"color4("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},W.array=function(t,e){return t[0]=e.r,t[1]=e.g,t[2]=e.b,t[3]=e.a,t},W.exactEquals=function(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a},W.equals=function(t,e){var i=t.r,n=t.g,r=t.b,o=t.a,a=e.r,h=e.g,l=e.b,c=e.a;return Math.abs(i-a)<=s*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-h)<=s*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(r-l)<=s*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(o-c)<=s*Math.max(1,Math.abs(o),Math.abs(c))},W.hex=function(t){return(255*t.r<<24|255*t.g<<16|255*t.b<<8|255*t.a)>>>0};var j=f,H=Object.freeze({bits:j,vec2:p,vec3:g,vec4:b,quat:D,mat2:P,mat23:L,mat3:T,mat4:V,color3:G,color4:W,EPSILON:s,equals:function(t,e){return Math.abs(t-e)<=s*Math.max(1,Math.abs(t),Math.abs(e))},approx:function(t,e,i){return i=i||s,Math.abs(t-e)<=i},clamp:function(t,e,i){return ti?i:t},clamp01:function(t){return t<0?0:t>1?1:t},lerp:function(t,e,i){return t+(e-t)*i},toRadian:o,toDegree:function(t){return t*r},random:a,randomRange:h,randomRangeInt:function(t,e){return Math.floor(h(t,e))},nextPow2:function(t){return--t,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}}),X={PROJ_PERSPECTIVE:0,PROJ_ORTHO:1,LIGHT_DIRECTIONAL:0,LIGHT_POINT:1,LIGHT_SPOT:2,SHADOW_NONE:0,SHADOW_HARD:1,SHADOW_SOFT:2,PARAM_INT:0,PARAM_INT2:1,PARAM_INT3:2,PARAM_INT4:3,PARAM_FLOAT:4,PARAM_FLOAT2:5,PARAM_FLOAT3:6,PARAM_FLOAT4:7,PARAM_COLOR3:8,PARAM_COLOR4:9,PARAM_MAT2:10,PARAM_MAT3:11,PARAM_MAT4:12,PARAM_TEXTURE_2D:13,PARAM_TEXTURE_CUBE:14,CLEAR_COLOR:1,CLEAR_DEPTH:2,CLEAR_STENCIL:4},Y=[[9728,9984,9986],[9729,9985,9987]],q=[{format:6407,internalFormat:33776,pixelType:null},{format:6408,internalFormat:33777,pixelType:null},{format:6408,internalFormat:33778,pixelType:null},{format:6408,internalFormat:33779,pixelType:null},{format:6407,internalFormat:36196,pixelType:null},{format:6407,internalFormat:35841,pixelType:null},{format:6408,internalFormat:35843,pixelType:null},{format:6407,internalFormat:35840,pixelType:null},{format:6408,internalFormat:35842,pixelType:null},{format:6406,internalFormat:6406,pixelType:5121},{format:6409,internalFormat:6409,pixelType:5121},{format:6410,internalFormat:6410,pixelType:5121},{format:6407,internalFormat:6407,pixelType:33635},{format:6408,internalFormat:6408,pixelType:32820},{format:6408,internalFormat:6408,pixelType:32819},{format:6407,internalFormat:6407,pixelType:5121},{format:6408,internalFormat:6408,pixelType:5121},{format:6407,internalFormat:6407,pixelType:36193},{format:6408,internalFormat:6408,pixelType:36193},{format:6407,internalFormat:6407,pixelType:5126},{format:6408,internalFormat:6408,pixelType:5126},{format:null,internalFormat:null,pixelType:null},{format:null,internalFormat:null,pixelType:null},{format:null,internalFormat:null,pixelType:null},{format:null,internalFormat:null,pixelType:null},{format:6402,internalFormat:6402,pixelType:5123},{format:6402,internalFormat:6402,pixelType:5125},{format:null,internalFormat:null,pixelType:null}],J={USAGE_STATIC:35044,USAGE_DYNAMIC:35048,USAGE_STREAM:35040,INDEX_FMT_UINT8:5121,INDEX_FMT_UINT16:5123,INDEX_FMT_UINT32:5125,ATTR_POSITION:"a_position",ATTR_NORMAL:"a_normal",ATTR_TANGENT:"a_tangent",ATTR_BITANGENT:"a_bitangent",ATTR_WEIGHTS:"a_weights",ATTR_JOINTS:"a_joints",ATTR_COLOR:"a_color",ATTR_COLOR0:"a_color0",ATTR_COLOR1:"a_color1",ATTR_UV:"a_uv",ATTR_UV0:"a_uv0",ATTR_UV1:"a_uv1",ATTR_UV2:"a_uv2",ATTR_UV3:"a_uv3",ATTR_UV4:"a_uv4",ATTR_UV5:"a_uv5",ATTR_UV6:"a_uv6",ATTR_UV7:"a_uv7",ATTR_TYPE_INT8:5120,ATTR_TYPE_UINT8:5121,ATTR_TYPE_INT16:5122,ATTR_TYPE_UINT16:5123,ATTR_TYPE_INT32:5124,ATTR_TYPE_UINT32:5125,ATTR_TYPE_FLOAT32:5126,FILTER_NEAREST:0,FILTER_LINEAR:1,WRAP_REPEAT:10497,WRAP_CLAMP:33071,WRAP_MIRROR:33648,TEXTURE_FMT_RGB_DXT1:0,TEXTURE_FMT_RGBA_DXT1:1,TEXTURE_FMT_RGBA_DXT3:2,TEXTURE_FMT_RGBA_DXT5:3,TEXTURE_FMT_RGB_ETC1:4,TEXTURE_FMT_RGB_PVRTC_2BPPV1:5,TEXTURE_FMT_RGBA_PVRTC_2BPPV1:6,TEXTURE_FMT_RGB_PVRTC_4BPPV1:7,TEXTURE_FMT_RGBA_PVRTC_4BPPV1:8,TEXTURE_FMT_A8:9,TEXTURE_FMT_L8:10,TEXTURE_FMT_L8_A8:11,TEXTURE_FMT_R5_G6_B5:12,TEXTURE_FMT_R5_G5_B5_A1:13,TEXTURE_FMT_R4_G4_B4_A4:14,TEXTURE_FMT_RGB8:15,TEXTURE_FMT_RGBA8:16,TEXTURE_FMT_RGB16F:17,TEXTURE_FMT_RGBA16F:18,TEXTURE_FMT_RGB32F:19,TEXTURE_FMT_RGBA32F:20,TEXTURE_FMT_R32F:21,TEXTURE_FMT_111110F:22,TEXTURE_FMT_SRGB:23,TEXTURE_FMT_SRGBA:24,TEXTURE_FMT_D16:25,TEXTURE_FMT_D32:26,TEXTURE_FMT_D24S8:27,DS_FUNC_NEVER:512,DS_FUNC_LESS:513,DS_FUNC_EQUAL:514,DS_FUNC_LEQUAL:515,DS_FUNC_GREATER:516,DS_FUNC_NOTEQUAL:517,DS_FUNC_GEQUAL:518,DS_FUNC_ALWAYS:519,RB_FMT_RGBA4:32854,RB_FMT_RGB5_A1:32855,RB_FMT_RGB565:36194,RB_FMT_D16:33189,RB_FMT_S8:36168,RB_FMT_D24S8:34041,BLEND_FUNC_ADD:32774,BLEND_FUNC_SUBTRACT:32778,BLEND_FUNC_REVERSE_SUBTRACT:32779,BLEND_ZERO:0,BLEND_ONE:1,BLEND_SRC_COLOR:768,BLEND_ONE_MINUS_SRC_COLOR:769,BLEND_DST_COLOR:774,BLEND_ONE_MINUS_DST_COLOR:775,BLEND_SRC_ALPHA:770,BLEND_ONE_MINUS_SRC_ALPHA:771,BLEND_DST_ALPHA:772,BLEND_ONE_MINUS_DST_ALPHA:773,BLEND_CONSTANT_COLOR:32769,BLEND_ONE_MINUS_CONSTANT_COLOR:32770,BLEND_CONSTANT_ALPHA:32771,BLEND_ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_SRC_ALPHA_SATURATE:776,STENCIL_OP_KEEP:7680,STENCIL_OP_ZERO:0,STENCIL_OP_REPLACE:7681,STENCIL_OP_INCR:7682,STENCIL_OP_INCR_WRAP:34055,STENCIL_OP_DECR:7683,STENCIL_OP_DECR_WRAP:34056,STENCIL_OP_INVERT:5386,CULL_NONE:0,CULL_FRONT:1028,CULL_BACK:1029,CULL_FRONT_AND_BACK:1032,PT_POINTS:0,PT_LINES:1,PT_LINE_LOOP:2,PT_LINE_STRIP:3,PT_TRIANGLES:4,PT_TRIANGLE_STRIP:5,PT_TRIANGLE_FAN:6};function Z(t){return t===J.ATTR_TYPE_INT8?1:t===J.ATTR_TYPE_UINT8?1:t===J.ATTR_TYPE_INT16?2:t===J.ATTR_TYPE_UINT16?2:t===J.ATTR_TYPE_INT32?4:t===J.ATTR_TYPE_UINT32?4:t===J.ATTR_TYPE_FLOAT32?4:(console.warn("Unknown ATTR_TYPE: "+t),0)}function K(t,e,i){void 0===i&&(i=-1);var n=Y[e][i+1];return void 0===n?(console.warn("Unknown FILTER: "+e),-1===i?t.LINEAR:t.LINEAR_MIPMAP_LINEAR):n}function Q(t){var e=q[t];return void 0===e?(console.warn("Unknown TEXTURE_FMT: "+t),q[J.TEXTURE_FMT_RGBA8]):e}var $=function(t){this._attr2el={},this._elements=[],this._bytes=0;for(var e=0,i=0,n=t.length;ithis._bytes)console.error("Failed to update data, bytes exceed.");else{var i=this._device._gl,n=this._usage;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._glID),e?t?i.bufferSubData(i.ELEMENT_ARRAY_BUFFER,t,e):i.bufferData(i.ELEMENT_ARRAY_BUFFER,e,n):this._bytes?i.bufferData(i.ELEMENT_ARRAY_BUFFER,this._bytes,n):console.warn("bufferData should not submit 0 bytes data"),this._device._restoreIndexBuffer()}else console.error("The buffer is destroyed")},et.count.get=function(){return this._numIndices},Object.defineProperties(tt.prototype,et);var it=function(t,e,i,n,r){this._device=t,this._format=e,this._usage=i,this._numVertices=r,this._bytes=this._format._bytes*r,this._glID=t._gl.createBuffer(),this.update(0,n),t._stats.vb+=this._bytes},nt={count:{configurable:!0}};it.prototype.destroy=function(){-1!==this._glID?(this._device._gl.deleteBuffer(this._glID),this._device._stats.vb-=this.bytes,this._glID=-1):console.error("The buffer already destroyed")},it.prototype.update=function(t,e){if(-1!==this._glID)if(e&&e.byteLength+t>this._bytes)console.error("Failed to update data, bytes exceed.");else{var i=this._device._gl,n=this._usage;i.bindBuffer(i.ARRAY_BUFFER,this._glID),e?t?i.bufferSubData(i.ARRAY_BUFFER,t,e):i.bufferData(i.ARRAY_BUFFER,e,n):this._bytes?i.bufferData(i.ARRAY_BUFFER,this._bytes,n):console.warn("bufferData should not submit 0 bytes data"),i.bindBuffer(i.ARRAY_BUFFER,null)}else console.error("The buffer is destroyed")},nt.count.get=function(){return this._numVertices},Object.defineProperties(it.prototype,nt);var rt=0;function st(t,e,i){i.split("\n").forEach((function(i){if(!(i.length<5)){var n=/^ERROR\:\s+(\d+)\:(\d+)\:\s*(.*)$/.exec(i);n?t.push({type:e,fileID:0|n[1],line:0|n[2],message:n[3].trim()}):i.length>0&&t.push({type:e,fileID:-1,line:0,message:i})}}))}var ot=function(t,e){this._device=t,this._attributes=[],this._uniforms=[],this._samplers=[],this._errors=[],this._linked=!1,this._vertSource=e.vert,this._fragSource=e.frag,this._glID=null,this._id=rt++},at={id:{configurable:!0}};function ht(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}at.id.get=function(){return this._id},ot.prototype.link=function(){if(!this._linked){var t=this._device._gl,e=ht(t,t.VERTEX_SHADER,this._vertSource),i=ht(t,t.FRAGMENT_SHADER,this._fragSource),n=t.createProgram();t.attachShader(n,e),t.attachShader(n,i),t.linkProgram(n);var r=!1,s=this._errors;if(t.getShaderParameter(e,t.COMPILE_STATUS)||(st(s,"vs",t.getShaderInfoLog(e)),r=!0),t.getShaderParameter(i,t.COMPILE_STATUS)||(st(s,"fs",t.getShaderInfoLog(i)),r=!0),t.deleteShader(e),t.deleteShader(i),r)s.forEach((function(t){console.error("Failed to compile "+t.type+" "+t.fileID+" (ln "+t.line+"): "+t.message)}));else if(t.getProgramParameter(n,t.LINK_STATUS)||(console.error("Failed to link shader program: "+t.getProgramInfoLog(n)),r=!0),!r){this._glID=n;for(var o=t.getProgramParameter(n,t.ACTIVE_ATTRIBUTES),a=0;a=J.TEXTURE_FMT_RGB_DXT1&&this._format<=J.TEXTURE_FMT_RGBA_PVRTC_4BPPV1),void 0!==t.mipmap&&(this._hasMipmap=t.mipmap,i=t.mipmap),void 0!==t.images&&t.images.length>1&&(i=!1,(t.width>t.height?t.width:t.height)>>t.images.length-1!=1&&console.error("texture-2d mipmap is invalid, should have a 1x1 mipmap.")));ct(this._width)&&ct(this._height)||(i=!1),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this._glID),void 0!==t.images&&t.images.length>0&&this._setMipmap(t.images,t.flipY,t.premultiplyAlpha),this._setTexInfo(),i&&(e.hint(e.GENERATE_MIPMAP_HINT,e.NICEST),e.generateMipmap(e.TEXTURE_2D)),this._device._restoreTexture(0)},e.prototype.updateSubImage=function(t){var e=this._device._gl,i=Q(this._format);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this._glID),this._setSubImage(i,t),this._device._restoreTexture(0)},e.prototype.updateImage=function(t){var e=this._device._gl,i=Q(this._format);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this._glID),this._setImage(i,t),this._device._restoreTexture(0)},e.prototype._setSubImage=function(t,e){var i=this._device._gl,n=e.flipY,r=e.premultiplyAlpha,s=e.image;s instanceof HTMLCanvasElement||s instanceof HTMLImageElement||s instanceof HTMLVideoElement?(void 0===n?i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0):i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,n),void 0===r?i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1):i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),i.texSubImage2D(i.TEXTURE_2D,e.level,e.x,e.y,t.format,t.pixelType,s)):(void 0===n?i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1):i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,n),void 0===r?i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1):i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),this._compressed?i.compressedTexSubImage2D(i.TEXTURE_2D,e.level,e.x,e.y,e.width,e.height,t.format,s):i.texSubImage2D(i.TEXTURE_2D,e.level,e.x,e.y,e.width,e.height,t.format,t.pixelType,s))},e.prototype._setImage=function(t,e){var i=this._device._gl,n=e.flipY,r=e.premultiplyAlpha,s=e.image;s instanceof HTMLCanvasElement||s instanceof HTMLImageElement||s instanceof HTMLVideoElement?(void 0===n?i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0):i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,n),void 0===r?i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1):i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),i.texImage2D(i.TEXTURE_2D,e.level,t.internalFormat,t.format,t.pixelType,s)):(void 0===n?i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1):i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,n),void 0===r?i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1):i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),this._compressed?i.compressedTexImage2D(i.TEXTURE_2D,e.level,t.internalFormat,e.width,e.height,0,s):i.texImage2D(i.TEXTURE_2D,e.level,t.internalFormat,e.width,e.height,0,t.format,t.pixelType,s))},e.prototype._setMipmap=function(t,e,i){for(var n=Q(this._format),r={width:this._width,height:this._height,flipY:e,premultiplyAlpha:i,level:0,image:null},s=0;s>s,r.height=this._height>>s,r.image=t[s],this._setImage(n,r)},e.prototype._setTexInfo=function(){var t=this._device._gl,e=ct(this._width)&&ct(this._height);e||this._wrapS===J.WRAP_CLAMP&&this._wrapT===J.WRAP_CLAMP||(console.warn("WebGL1 doesn't support all wrap modes with NPOT textures"),this._wrapS=J.WRAP_CLAMP,this._wrapT=J.WRAP_CLAMP);var i=this._hasMipmap?this._mipFilter:-1;e||-1===i||(console.warn("NPOT textures do not support mipmap filter"),i=-1),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,K(t,this._minFilter,i)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,K(t,this._magFilter,-1)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,this._wrapS),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,this._wrapT);var n=this._device.ext("EXT_texture_filter_anisotropic");n&&n.TEXTURE_MAX_ANISOTROPY_EXT&&t.texParameteri(t.TEXTURE_2D,n.TEXTURE_MAX_ANISOTROPY_EXT,this._anisotropy)},e})(lt),_t=(function(t){function e(e,i){t.call(this,e);var n=this._device._gl;this._target=n.TEXTURE_CUBE_MAP,this._glID=n.createTexture(),this.update(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(t){var e=this._device._gl,i=this._hasMipmap;t&&(void 0!==t.width&&(this._width=t.width),void 0!==t.height&&(this._height=t.height),void 0!==t.anisotropy&&(this._anisotropy=t.anisotropy),void 0!==t.minFilter&&(this._minFilter=t.minFilter),void 0!==t.magFilter&&(this._magFilter=t.magFilter),void 0!==t.mipFilter&&(this._mipFilter=t.mipFilter),void 0!==t.wrapS&&(this._wrapS=t.wrapS),void 0!==t.wrapT&&(this._wrapT=t.wrapT),void 0!==t.format&&(this._format=t.format,this._compressed=this._format>=J.TEXTURE_FMT_RGB_DXT1&&this._format<=J.TEXTURE_FMT_RGBA_PVRTC_4BPPV1),void 0!==t.mipmap&&(this._hasMipmap=t.mipmap,i=t.mipmap),void 0!==t.images&&t.images.length>1&&(i=!1,t.width!==t.height&&console.warn("texture-cube width and height should be identical."),t.width>>t.images.length-1!=1&&console.error("texture-cube mipmap is invalid. please set mipmap as 1x1, 2x2, 4x4 ... nxn"))),ct(this._width)&&ct(this._height)||(i=!1),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,this._glID),void 0!==t.images&&t.images.length>0&&this._setMipmap(t.images,t.flipY,t.premultiplyAlpha),this._setTexInfo(),i&&(e.hint(e.GENERATE_MIPMAP_HINT,e.NICEST),e.generateMipmap(e.TEXTURE_CUBE_MAP)),this._device._restoreTexture(0)},e.prototype.updateSubImage=function(t){var e=this._device._gl,i=Q(this._format);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,this._glID),this._setSubImage(i,t),this._device._restoreTexture(0)},e.prototype.updateImage=function(t){var e=this._device._gl,i=Q(this._format);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,this._glID),this._setImage(i,t),this._device._restoreTexture(0)},e.prototype._setSubImage=function(t,e){var i=this._device._gl,n=e.flipY,r=e.premultiplyAlpha,s=e.faceIndex,o=e.image;void 0===n?i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1):i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,n),void 0===r?i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1):i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),o instanceof HTMLCanvasElement||o instanceof HTMLImageElement||o instanceof HTMLVideoElement?i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.level,e.x,e.y,t.format,t.pixelType,o):this._compressed?i.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.level,e.x,e.y,e.width,e.height,t.format,o):i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.level,e.x,e.y,e.width,e.height,t.format,t.pixelType,o)},e.prototype._setImage=function(t,e){var i=this._device._gl,n=e.flipY,r=e.premultiplyAlpha,s=e.faceIndex,o=e.image;void 0===n?i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1):i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,n),void 0===r?i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1):i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),o instanceof HTMLCanvasElement||o instanceof HTMLImageElement||o instanceof HTMLVideoElement?i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.level,t.internalFormat,t.format,t.pixelType,o):this._compressed?i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.level,t.internalFormat,e.width,e.height,0,o):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.level,t.internalFormat,e.width,e.height,0,t.format,t.pixelType,o)},e.prototype._setMipmap=function(t,e,i){for(var n=Q(this._format),r={width:this._width,height:this._height,faceIndex:0,flipY:e,premultiplyAlpha:i,level:0,image:null},s=0;s>s,r.height=this._height>>s;for(var a=0;a<6;++a)r.faceIndex=a,r.image=o[a],this._setImage(n,r)}},e.prototype._setTexInfo=function(){var t=this._device._gl,e=ct(this._width)&&ct(this._height);e||this._wrapS===J.WRAP_CLAMP&&this._wrapT===J.WRAP_CLAMP||(console.warn("WebGL1 doesn't support all wrap modes with NPOT textures"),this._wrapS=J.WRAP_CLAMP,this._wrapT=J.WRAP_CLAMP);var i=this._hasMipmap?this._mipFilter:-1;e||-1===i||(console.warn("NPOT textures do not support mipmap filter"),i=-1),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,K(t,this._minFilter,i)),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,K(t,this._magFilter,-1)),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this._wrapS),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this._wrapT);var n=this._device.ext("EXT_texture_filter_anisotropic");n&&n.TEXTURE_MAX_ANISOTROPY_EXT&&t.texParameteri(t.TEXTURE_CUBE_MAP,n.TEXTURE_MAX_ANISOTROPY_EXT,this._anisotropy)},e})(lt),ft=function(t,e,i,n){this._device=t,this._format=e,this._width=i,this._height=n;var r=t._gl;this._glID=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,this._glID),r.renderbufferStorage(r.RENDERBUFFER,e,i,n),r.bindRenderbuffer(r.RENDERBUFFER,null)};ft.prototype.destroy=function(){if(null!==this._glID){var t=this._device._gl;t.bindRenderbuffer(t.RENDERBUFFER,null),t.deleteRenderbuffer(this._glID),this._glID=null}else console.error("The render-buffer already destroyed")};var mt=function(t,e,i,n){this._device=t,this._width=e,this._height=i,this._colors=n.colors||[],this._depth=n.depth||null,this._stencil=n.stencil||null,this._depthStencil=n.depthStencil||null,this._glID=t._gl.createFramebuffer()};mt.prototype.destroy=function(){null!==this._glID?(this._device._gl.deleteFramebuffer(this._glID),this._glID=null):console.error("The frame-buffer already destroyed")};var dt={blend:!1,blendSep:!1,blendColor:4294967295,blendEq:J.BLEND_FUNC_ADD,blendAlphaEq:J.BLEND_FUNC_ADD,blendSrc:J.BLEND_ONE,blendDst:J.BLEND_ZERO,blendSrcAlpha:J.BLEND_ONE,blendDstAlpha:J.BLEND_ZERO,depthTest:!1,depthWrite:!1,depthFunc:J.DS_FUNC_LESS,stencilTest:!1,stencilSep:!1,stencilFuncFront:J.DS_FUNC_ALWAYS,stencilRefFront:0,stencilMaskFront:255,stencilFailOpFront:J.STENCIL_OP_KEEP,stencilZFailOpFront:J.STENCIL_OP_KEEP,stencilZPassOpFront:J.STENCIL_OP_KEEP,stencilWriteMaskFront:255,stencilFuncBack:J.DS_FUNC_ALWAYS,stencilRefBack:0,stencilMaskBack:255,stencilFailOpBack:J.STENCIL_OP_KEEP,stencilZFailOpBack:J.STENCIL_OP_KEEP,stencilZPassOpBack:J.STENCIL_OP_KEEP,stencilWriteMaskBack:255,cullMode:J.CULL_BACK,primitiveType:J.PT_TRIANGLES,maxStream:-1,vertexBuffers:[],vertexBufferOffsets:[],indexBuffer:null,maxTextureSlot:-1,textureUnits:[],program:null},pt=function(t){this.vertexBuffers=new Array(t._caps.maxVertexStreams),this.vertexBufferOffsets=new Array(t._caps.maxVertexStreams),this.textureUnits=new Array(t._caps.maxTextureUnits),this.set(dt)};pt.initDefault=function(t){dt.vertexBuffers=new Array(t._caps.maxVertexStreams),dt.vertexBufferOffsets=new Array(t._caps.maxVertexStreams),dt.textureUnits=new Array(t._caps.maxTextureUnits)},pt.prototype.reset=function(){this.set(dt)},pt.prototype.set=function(t){this.blend=t.blend,this.blendSep=t.blendSep,this.blendColor=t.blendColor,this.blendEq=t.blendEq,this.blendAlphaEq=t.blendAlphaEq,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.depthFunc=t.depthFunc,this.stencilTest=t.stencilTest,this.stencilSep=t.stencilSep,this.stencilFuncFront=t.stencilFuncFront,this.stencilRefFront=t.stencilRefFront,this.stencilMaskFront=t.stencilMaskFront,this.stencilFailOpFront=t.stencilFailOpFront,this.stencilZFailOpFront=t.stencilZFailOpFront,this.stencilZPassOpFront=t.stencilZPassOpFront,this.stencilWriteMaskFront=t.stencilWriteMaskFront,this.stencilFuncBack=t.stencilFuncBack,this.stencilRefBack=t.stencilRefBack,this.stencilMaskBack=t.stencilMaskBack,this.stencilFailOpBack=t.stencilFailOpBack,this.stencilZFailOpBack=t.stencilZFailOpBack,this.stencilZPassOpBack=t.stencilZPassOpBack,this.stencilWriteMaskBack=t.stencilWriteMaskBack,this.cullMode=t.cullMode,this.primitiveType=t.primitiveType,this.maxStream=t.maxStream;for(var e=0;e>>0},xt.prototype.setBlendFunc=function(t,e){this._next.blendSep=!1,this._next.blendSrc=t,this._next.blendDst=e},xt.prototype.setBlendFuncSep=function(t,e,i,n){this._next.blendSep=!0,this._next.blendSrc=t,this._next.blendDst=e,this._next.blendSrcAlpha=i,this._next.blendDstAlpha=n},xt.prototype.setBlendEq=function(t){this._next.blendSep=!1,this._next.blendEq=t},xt.prototype.setBlendEqSep=function(t,e){this._next.blendSep=!0,this._next.blendEq=t,this._next.blendAlphaEq=e},xt.prototype.setCullMode=function(t){this._next.cullMode=t},xt.prototype.setVertexBuffer=function(t,e,i){void 0===i&&(i=0),this._next.vertexBuffers[t]=e,this._next.vertexBufferOffsets[t]=i,this._next.maxStream=this._caps.maxTextureUnits?console.warn("Can not set texture "+t+" at stage "+i+", max texture exceed: "+this._caps.maxTextureUnits):(this._next.textureUnits[i]=e,this.setUniform(t,i),this._next.maxTextureSlot=this._caps.maxTextureUnits)console.warn("Can not set "+n+" textures for "+t+", max texture exceed: "+this._caps.maxTextureUnits);else{for(var r=0;r>24)/255,(i.blendColor>>16&255)/255,(i.blendColor>>8&255)/255,(255&i.blendColor)/255),void(i.blendSep?(t.blendFuncSeparate(i.blendSrc,i.blendDst,i.blendSrcAlpha,i.blendDstAlpha),t.blendEquationSeparate(i.blendEq,i.blendAlphaEq)):(t.blendFunc(i.blendSrc,i.blendDst),t.blendEquation(i.blendEq)))):void t.disable(t.BLEND);!1!==i.blend&&(e.blendColor!==i.blendColor&&t.blendColor((i.blendColor>>24)/255,(i.blendColor>>16&255)/255,(i.blendColor>>8&255)/255,(255&i.blendColor)/255),e.blendSep===i.blendSep?i.blendSep?(e.blendSrc===i.blendSrc&&e.blendDst===i.blendDst&&e.blendSrcAlpha===i.blendSrcAlpha&&e.blendDstAlpha===i.blendDstAlpha||t.blendFuncSeparate(i.blendSrc,i.blendDst,i.blendSrcAlpha,i.blendDstAlpha),e.blendEq===i.blendEq&&e.blendAlphaEq===i.blendAlphaEq||t.blendEquationSeparate(i.blendEq,i.blendAlphaEq)):(e.blendSrc===i.blendSrc&&e.blendDst===i.blendDst||t.blendFunc(i.blendSrc,i.blendDst),e.blendEq!==i.blendEq&&t.blendEquation(i.blendEq)):i.blendSep?(t.blendFuncSeparate(i.blendSrc,i.blendDst,i.blendSrcAlpha,i.blendDstAlpha),t.blendEquationSeparate(i.blendEq,i.blendAlphaEq)):(t.blendFunc(i.blendSrc,i.blendDst),t.blendEquation(i.blendEq)))})(i,n,r),(function(t,e,i){if(e.depthTest!==i.depthTest)return i.depthTest?(t.enable(t.DEPTH_TEST),t.depthFunc(i.depthFunc),void t.depthMask(i.depthWrite)):void t.disable(t.DEPTH_TEST);e.depthWrite!==i.depthWrite&&t.depthMask(i.depthWrite),!1!==i.depthTest?e.depthFunc!==i.depthFunc&&t.depthFunc(i.depthFunc):i.depthWrite&&(i.depthTest=!0,i.depthFunc=J.DS_FUNC_ALWAYS,t.enable(t.DEPTH_TEST),t.depthFunc(i.depthFunc))})(i,n,r),(function(t,e,i){if(i.stencilTest!==e.stencilTest)return i.stencilTest?(t.enable(t.STENCIL_TEST),void(i.stencilSep?(t.stencilFuncSeparate(t.FRONT,i.stencilFuncFront,i.stencilRefFront,i.stencilMaskFront),t.stencilMaskSeparate(t.FRONT,i.stencilWriteMaskFront),t.stencilOpSeparate(t.FRONT,i.stencilFailOpFront,i.stencilZFailOpFront,i.stencilZPassOpFront),t.stencilFuncSeparate(t.BACK,i.stencilFuncBack,i.stencilRefBack,i.stencilMaskBack),t.stencilMaskSeparate(t.BACK,i.stencilWriteMaskBack),t.stencilOpSeparate(t.BACK,i.stencilFailOpBack,i.stencilZFailOpBack,i.stencilZPassOpBack)):(t.stencilFunc(i.stencilFuncFront,i.stencilRefFront,i.stencilMaskFront),t.stencilMask(i.stencilWriteMaskFront),t.stencilOp(i.stencilFailOpFront,i.stencilZFailOpFront,i.stencilZPassOpFront)))):void t.disable(t.STENCIL_TEST);i.stencilTest&&(e.stencilSep===i.stencilSep?i.stencilSep?(e.stencilFuncFront===i.stencilFuncFront&&e.stencilRefFront===i.stencilRefFront&&e.stencilMaskFront===i.stencilMaskFront||t.stencilFuncSeparate(t.FRONT,i.stencilFuncFront,i.stencilRefFront,i.stencilMaskFront),e.stencilWriteMaskFront!==i.stencilWriteMaskFront&&t.stencilMaskSeparate(t.FRONT,i.stencilWriteMaskFront),e.stencilFailOpFront===i.stencilFailOpFront&&e.stencilZFailOpFront===i.stencilZFailOpFront&&e.stencilZPassOpFront===i.stencilZPassOpFront||t.stencilOpSeparate(t.FRONT,i.stencilFailOpFront,i.stencilZFailOpFront,i.stencilZPassOpFront),e.stencilFuncBack===i.stencilFuncBack&&e.stencilRefBack===i.stencilRefBack&&e.stencilMaskBack===i.stencilMaskBack||t.stencilFuncSeparate(t.BACK,i.stencilFuncBack,i.stencilRefBack,i.stencilMaskBack),e.stencilWriteMaskBack!==i.stencilWriteMaskBack&&t.stencilMaskSeparate(t.BACK,i.stencilWriteMaskBack),e.stencilFailOpBack===i.stencilFailOpBack&&e.stencilZFailOpBack===i.stencilZFailOpBack&&e.stencilZPassOpBack===i.stencilZPassOpBack||t.stencilOpSeparate(t.BACK,i.stencilFailOpBack,i.stencilZFailOpBack,i.stencilZPassOpBack)):(e.stencilFuncFront===i.stencilFuncFront&&e.stencilRefFront===i.stencilRefFront&&e.stencilMaskFront===i.stencilMaskFront||t.stencilFunc(i.stencilFuncFront,i.stencilRefFront,i.stencilMaskFront),e.stencilWriteMaskFront!==i.stencilWriteMaskFront&&t.stencilMask(i.stencilWriteMaskFront),e.stencilFailOpFront===i.stencilFailOpFront&&e.stencilZFailOpFront===i.stencilZFailOpFront&&e.stencilZPassOpFront===i.stencilZPassOpFront||t.stencilOp(i.stencilFailOpFront,i.stencilZFailOpFront,i.stencilZPassOpFront)):i.stencilSep?(t.stencilFuncSeparate(t.FRONT,i.stencilFuncFront,i.stencilRefFront,i.stencilMaskFront),t.stencilMaskSeparate(t.FRONT,i.stencilWriteMaskFront),t.stencilOpSeparate(t.FRONT,i.stencilFailOpFront,i.stencilZFailOpFront,i.stencilZPassOpFront),t.stencilFuncSeparate(t.BACK,i.stencilFuncBack,i.stencilRefBack,i.stencilMaskBack),t.stencilMaskSeparate(t.BACK,i.stencilWriteMaskBack),t.stencilOpSeparate(t.BACK,i.stencilFailOpBack,i.stencilZFailOpBack,i.stencilZPassOpBack)):(t.stencilFunc(i.stencilFuncFront,i.stencilRefFront,i.stencilMaskFront),t.stencilMask(i.stencilWriteMaskFront),t.stencilOp(i.stencilFailOpFront,i.stencilZFailOpFront,i.stencilZPassOpFront)))})(i,n,r),(function(t,e,i){e.cullMode!==i.cullMode&&(i.cullMode!==J.CULL_NONE?(t.enable(t.CULL_FACE),t.cullFace(i.cullMode)):t.disable(t.CULL_FACE))})(i,n,r),(function(t,e,i,n){var r=!1;if(-1!==n.maxStream){if(i.maxStream!==n.maxStream)r=!0;else if(i.program!==n.program)r=!0;else for(var s=0;s=this._inputAssemblers.length?(t.model=null,t.node=null,t.ia=null,t.effect=null,void(t.defines=null)):(t.model=this,t.node=this._node,t.ia=this._inputAssemblers[e],e=0)return-1;if(t>=0)return 1;t=-t,e=-e}var i=Kt(t),n=Kt(e),r=0;return in&&(e*=Zt[i-n-1],t/=10,r=1),t===e?r:t=0;)r++;return r-e}function te(t,e,i,n,r){for(n===e&&n++;n>>1;r(s,t[h])<0?a=h:o=h+1}var l=n-o;switch(l){case 3:t[o+3]=t[o+2];case 2:t[o+2]=t[o+1];case 1:t[o+1]=t[o];break;default:for(;l>0;)t[o+l]=t[o+l-1],l--}t[o]=s}}function ee(t,e,i,n,r,s){var o=0,a=0,h=1;if(s(t,e[i+r])>0){for(a=n-r;h0;)o=h,(h=1+(h<<1))<=0&&(h=a);h>a&&(h=a),o+=r,h+=r}else{for(a=r+1;ha&&(h=a);var l=o;o=r-h,h=r-l}for(o++;o>>1);s(t,e[i+c])>0?o=c+1:h=c}return h}function ie(t,e,i,n,r,s){var o=0,a=0,h=1;if(s(t,e[i+r])<0){for(a=r+1;ha&&(h=a);var l=o;o=r-h,h=r-l}else{for(a=n-r;h=0;)o=h,(h=1+(h<<1))<=0&&(h=a);h>a&&(h=a),o+=r,h+=r}for(o++;o>>1);s(t,e[i+c])<0?h=c:o=c+1}return h}var ne=function(t,e){this.array=t,this.compare=e,this.minGallop=7,this.length=t.length,this.tmpStorageLength=256,this.length<512&&(this.tmpStorageLength=this.length>>>1),this.tmp=new Array(this.tmpStorageLength),this.stackLength=this.length<120?5:this.length<1542?10:this.length<119151?19:40,this.runStart=new Array(this.stackLength),this.runLength=new Array(this.stackLength),this.stackSize=0};function re(t,e,i,n){if(!Array.isArray(t))throw new TypeError("Can only sort arrays");void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===n&&(n=Qt);var r=i-e;if(!(r<2)){var s=0;if(r=Jt;)e|=1&t,t>>=1;return t+e})(r);do{if((s=$t(t,e,i,n))a&&(h=a),te(t,e,e+h,e+s,n),s=h}o.pushRun(e,s),o.mergeRuns(),r-=s,e+=s}while(0!==r);o.forceMergeRuns()}}}ne.prototype.pushRun=function(t,e){this.runStart[this.stackSize]=t,this.runLength[this.stackSize]=e,this.stackSize+=1},ne.prototype.mergeRuns=function(){for(;this.stackSize>1;){var t=this.stackSize-2;if(t>=1&&this.runLength[t-1]<=this.runLength[t]+this.runLength[t+1]||t>=2&&this.runLength[t-2]<=this.runLength[t]+this.runLength[t-1])this.runLength[t-1]this.runLength[t+1])break;this.mergeAt(t)}},ne.prototype.forceMergeRuns=function(){for(;this.stackSize>1;){var t=this.stackSize-2;t>0&&this.runLength[t-1]=7||f>=7);if(m)break;u<0&&(u=0),u+=2}if(this.minGallop=u,u<1&&(this.minGallop=1),1===e){for(a=0;a=0;a--)s[_+a]=s[u+a];if(0===e){p=!0;break}}if(s[c--]=o[l--],1==--n){p=!0;break}if(0!==(d=n-ee(s[h],o,0,n,n-1,r))){for(n-=d,_=(c-=d)+1,u=(l-=d)+1,a=0;a=7||d>=7);if(p)break;f<0&&(f=0),f+=2}if(this.minGallop=f,f<1&&(this.minGallop=1),1===n){for(_=(c-=e)+1,u=(h-=e)+1,a=e-1;a>=0;a--)s[_+a]=s[u+a];s[c]=o[l]}else{if(0===n)throw new Error("mergeHigh preconditions were not respected");for(u=c-(n-1),a=0;a=0;a--)s[_+a]=s[u+a];s[c]=o[l]}else for(u=c-(n-1),a=0;athis._data.length)for(var e=this._data.length;e=this._data.length&&this._resize(2*this._data.length),this._data[this._count]=t,++this._count},se.prototype.pop=function(){--this._count,this._count<0&&(this._count=0);var t=this._data[this._count];return this._data[this._count]=void 0,t},se.prototype.fastRemove=function(t){if(!(t>=this._count)){var e=this._count-1;this._data[t]=this._data[e],this._data[e]=void 0,this._count-=1}},se.prototype.indexOf=function(t){var e=this._data.indexOf(t);return e>=this._count?-1:e},se.prototype.sort=function(t){return re(this._data,0,this._count,t)},Object.defineProperties(se.prototype,oe);var ae=function(t,e){this._fn=t,this._idx=e-1,this._frees=new Array(e);for(var i=0;ithis._data.length)for(var e=this._data.length;e=this._data.length&&this.resize(2*this._data.length),this._data[this._count++]},ce.prototype.remove=function(t){if(!(t>=this._count)){var e=this._count-1,i=this._data[t];this._data[t]=this._data[e],this._data[e]=i,this._count-=1}},ce.prototype.sort=function(t){return re(this._data,0,this._count,t)},Object.defineProperties(ce.prototype,ue);for(var _e=Array(8),fe=0;fe<8;++fe)_e[fe]=[];var me=function(){this._lights=new se(16),this._models=new se(16),this._cameras=new se(16),this._debugCamera=null,this._views=[]};me.prototype._add=function(t,e){-1===e._poolID&&(t.push(e),e._poolID=t.length-1)},me.prototype._remove=function(t,e){-1!==e._poolID&&(t.data[t.length-1]._poolID=e._poolID,t.fastRemove(e._poolID),e._poolID=-1)},me.prototype.reset=function(){for(var t=0;t=t._caps.maxTextureUnits&&console.warn("Trying to use "+e+" texture units while this GPU supports only "+t._caps.maxTextureUnits),this._usedTextureUnits+=1,e},Le.prototype._registerStage=function(t,e){this._stage2fn[t]=e},Le.prototype._reset=function(){this._viewPools.reset(),this._stageItemsPools.reset()},Le.prototype._requestView=function(){return this._viewPools.add()},Le.prototype._render=function(t,e){var i=this._device;i.setFrameBuffer(t._framebuffer),i.setViewport(t._rect.x,t._rect.y,t._rect.w,t._rect.h);var n={};t._clearFlags&X.CLEAR_COLOR&&(n.color=[t._color.r,t._color.g,t._color.b,t._color.a]),t._clearFlags&X.CLEAR_DEPTH&&(n.depth=t._depth),t._clearFlags&X.CLEAR_STENCIL&&(n.stencil=t._stencil),i.clear(n),this._drawItemsPools.reset();for(var r=0;r64){console.error("Uniform array is too long!");continue}m=d.func(u)}else{m=(0,Ie[c.type])(u)}e.setUniform(c.name,m)}else console.warn("Failed to set technique property "+c.name+", value not found.")}for(var p=0;pe._depth?1:t._depth0;i--)We.free(t._data[i]);t._data.length=0,t._indices.length=0,t.material=null,t.uvDirty=!0,t.vertDirty=!0,t.vertexCount=0,t.indiceCount=0,Fe.free(t)}},Object.defineProperties(e.prototype,i),e})(Ue);je.type="RenderData",Fe=new ae(function(){return new je},32);var He=(function(t){function e(){t.call(this),this.ia=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return e.type},Object.defineProperties(e.prototype,i),e})(Ue);He.type="IARenderData";var Xe=function(t){void 0===t&&(t=!0),this._loaded=!1,this._persist=t};Xe.prototype.unload=function(){this._loaded=!1},Xe.prototype.reload=function(){};var Ye=(function(t){function e(e){void 0===e&&(e=!0),t.call(this,e),this._texture=null}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getImpl=function(){return this._texture},e.prototype.getId=function(){},e.prototype.destroy=function(){this._texture&&this._texture.destroy()},e})(Xe);function qe(t){var e=t._programName+t._cullMode;return t._blend&&(e+=t._blendEq+t._blendAlphaEq+t._blendSrc+t._blendDst+t._blendSrcAlpha+t._blendDstAlpha+t._blendColor),t._depthTest&&(e+=t._depthWrite+t._depthFunc),t._stencilTest&&(e+=t._stencilFuncFront+t._stencilRefFront+t._stencilMaskFront+t._stencilFailOpFront+t._stencilZFailOpFront+t._stencilZPassOpFront+t._stencilWriteMaskFront+t._stencilFuncBack+t._stencilRefBack+t._stencilMaskBack+t._stencilFailOpBack+t._stencilZFailOpBack+t._stencilZPassOpBack+t._stencilWriteMaskBack),e}var Je=(function(t){function e(e){void 0===e&&(e=!1),t.call(this,e),this._effect=null,this._texIds={},this._hash=""}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={hash:{configurable:!0}};return i.hash.get=function(){return this._hash},e.prototype.updateHash=function(t){this._hash=t||(function(t){var e,i,n,r,s,o,a=t._effect,h="";if(a)for(h+=(function(t){for(var e="",i=0;i=4;)i=1540483477*(65535&(i=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(i>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:r^=(255&t.charCodeAt(s+2))<<16;case 2:r^=(255&t.charCodeAt(s+1))<<8;case 1:r=1540483477*(65535&(r^=255&t.charCodeAt(s)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0})(h,666):h})(this)},Object.defineProperties(e.prototype,i),e})(Xe),Ze=(function(t){function e(){t.call(this,!1);var e=new Oe.Pass("sprite");e.setDepth(!1,!1),e.setCullMode(At.CULL_NONE),e.setBlend(At.BLEND_FUNC_ADD,At.BLEND_SRC_ALPHA,At.BLEND_ONE_MINUS_SRC_ALPHA,At.BLEND_FUNC_ADD,At.BLEND_SRC_ALPHA,At.BLEND_ONE_MINUS_SRC_ALPHA);var i=new Oe.Technique(["transparent"],[{name:"texture",type:Oe.PARAM_TEXTURE_2D},{name:"color",type:Oe.PARAM_COLOR4}],[e]);this._color={r:1,g:1,b:1,a:1},this._effect=new Oe.Effect([i],{color:this._color},[{name:"useTexture",value:!0},{name:"useModel",value:!1},{name:"alphaTest",value:!1},{name:"use2DPos",value:!0},{name:"useColor",value:!0}]),this._mainTech=i,this._texture=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={effect:{configurable:!0},useTexture:{configurable:!0},useModel:{configurable:!0},use2DPos:{configurable:!0},useColor:{configurable:!0},texture:{configurable:!0},color:{configurable:!0}};return i.effect.get=function(){return this._effect},i.useTexture.get=function(){return this._effect.getDefine("useTexture")},i.useTexture.set=function(t){this._effect.define("useTexture",t)},i.useModel.get=function(){return this._effect.getDefine("useModel")},i.useModel.set=function(t){this._effect.define("useModel",t)},i.use2DPos.get=function(){return this._effect.getDefine("use2DPos")},i.use2DPos.set=function(t){this._effect.define("use2DPos",t)},i.useColor.get=function(){return this._effect.getDefine("useColor")},i.useColor.set=function(t){this._effect.define("useColor",t)},i.texture.get=function(){return this._texture},i.texture.set=function(t){this._texture!==t&&(this._texture=t,this._effect.setProperty("texture",t.getImpl()),this._texIds.texture=t.getId())},i.color.get=function(){return this._color},i.color.set=function(t){var e=this._color;e.r=t.r/255,e.g=t.g/255,e.b=t.b/255,e.a=t.a/255,this._effect.setProperty("color",e)},e.prototype.clone=function(){var t=new e;return t.texture=this.texture,t.useTexture=this.useTexture,t.useModel=this.useModel,t.use2DPos=this.use2DPos,t.useColor=this.useColor,t.updateHash(),t},Object.defineProperties(e.prototype,i),e})(Je),Ke=(function(t){function e(){t.call(this,!1);var e=new Oe.Pass("gray_sprite");e.setDepth(!1,!1),e.setCullMode(At.CULL_NONE),e.setBlend(At.BLEND_FUNC_ADD,At.BLEND_SRC_ALPHA,At.BLEND_ONE_MINUS_SRC_ALPHA,At.BLEND_FUNC_ADD,At.BLEND_SRC_ALPHA,At.BLEND_ONE_MINUS_SRC_ALPHA);var i=new Oe.Technique(["transparent"],[{name:"texture",type:Oe.PARAM_TEXTURE_2D},{name:"color",type:Oe.PARAM_COLOR4}],[e]);this._color={r:1,g:1,b:1,a:1},this._effect=new Oe.Effect([i],{color:this._color},[]),this._mainTech=i,this._texture=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={effect:{configurable:!0},texture:{configurable:!0},color:{configurable:!0}};return i.effect.get=function(){return this._effect},i.texture.get=function(){return this._texture},i.texture.set=function(t){this._texture!==t&&(this._texture=t,this._effect.setProperty("texture",t.getImpl()),this._texIds.texture=t.getId())},i.color.get=function(){return this._color},i.color.set=function(t){var e=this._color;e.r=t.r/255,e.g=t.g/255,e.b=t.b/255,e.a=t.a/255,this._effect.setProperty("color",e)},e.prototype.clone=function(){var t=new e;return t.texture=this.texture,t.color=this.color,t.updateHash(),t},Object.defineProperties(e.prototype,i),e})(Je),Qe=(function(t){function e(){t.call(this,!1),this._pass=new Oe.Pass("sprite"),this._pass.setDepth(!1,!1),this._pass.setCullMode(At.CULL_NONE),this._pass.setBlend(At.BLEND_FUNC_ADD,At.BLEND_SRC_ALPHA,At.BLEND_ONE_MINUS_SRC_ALPHA,At.BLEND_FUNC_ADD,At.BLEND_SRC_ALPHA,At.BLEND_ONE_MINUS_SRC_ALPHA);var e=new Oe.Technique(["transparent"],[{name:"texture",type:Oe.PARAM_TEXTURE_2D},{name:"alphaThreshold",type:Oe.PARAM_FLOAT},{name:"color",type:Oe.PARAM_COLOR4}],[this._pass]);this._effect=new Oe.Effect([e],{color:{r:1,g:1,b:1,a:1}},[{name:"useTexture",value:!0},{name:"useModel",value:!1},{name:"alphaTest",value:!0},{name:"use2DPos",value:!0},{name:"useColor",value:!0}]),this._mainTech=e,this._texture=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={effect:{configurable:!0},useTexture:{configurable:!0},useModel:{configurable:!0},useColor:{configurable:!0},texture:{configurable:!0},alphaThreshold:{configurable:!0}};return i.effect.get=function(){return this._effect},i.useTexture.get=function(){this._effect.getDefine("useTexture")},i.useTexture.set=function(t){this._effect.define("useTexture",t)},i.useModel.get=function(){this._effect.getDefine("useModel")},i.useModel.set=function(t){this._effect.define("useModel",t)},i.useColor.get=function(){this._effect.getDefine("useColor")},i.useColor.set=function(t){this._effect.define("useColor",t)},i.texture.get=function(){return this._texture},i.texture.set=function(t){this._texture!==t&&(this._texture=t,this._effect.setProperty("texture",t.getImpl()),this._texIds.texture=t.getId())},i.alphaThreshold.get=function(){return this._effect.getProperty("alphaThreshold")},i.alphaThreshold.set=function(t){this._effect.setProperty("alphaThreshold",t)},e.prototype.clone=function(){var t=new e;return t.useTexture=this.useTexture,t.useModel=this.useModel,t.useColor=this.useColor,t.texture=this.texture,t.alphaThreshold=this.alphaThreshold,t.updateHash(),t},Object.defineProperties(e.prototype,i),e})(Je),$e=function(t){var e;try{e=t.getContext("2d")}catch(t){return void console.error(t)}this._canvas=t,this._ctx=e,this._caps={},this._stats={drawcalls:0},this._vx=this._vy=this._vw=this._vh=0,this._sx=this._sy=this._sw=this._sh=0};$e.prototype._restoreTexture=function(t){},$e.prototype.setViewport=function(t,e,i,n){this._vx===t&&this._vy===e&&this._vw===i&&this._vh===n||(this._vx=t,this._vy=e,this._vw=i,this._vh=n)},$e.prototype.setScissor=function(t,e,i,n){this._sx===t&&this._sy===e&&this._sw===i&&this._sh===n||(this._sx=t,this._sy=e,this._sw=i,this._sh=n)},$e.prototype.clear=function(t){var e=this._ctx;e.clearRect(this._vx,this._vy,this._vw,this._vh),!t||0===t[0]&&0===t[1]&&0===t[2]||(e.fillStyle="rgb("+t[0]+","+t[1]+","+t[2]+")",e.globalAlpha=t[3],e.fillRect(this._vx,this._vy,this._vw,this._vh))};var ti=function(t,e){this._device=t,this._width=4,this._height=4,this._image=null,e&&(void 0!==e.width&&(this._width=e.width),void 0!==e.height&&(this._height=e.height),this.updateImage(e))};ti.prototype.update=function(t){this.updateImage(t)},ti.prototype.updateImage=function(t){if(t.images&&t.images[0]){var e=t.images[0];e&&e!==this._image&&(this._image=e)}},ti.prototype.destroy=function(){this._image=null};var ei={Device:$e,Texture2D:ti},ii=Oe.Scene,ni=Oe.Camera,ri=Oe.View,si=At.Texture2D,oi=At.Device,ai=Oe.Model,hi=Oe.InputAssembler;Oe.addStage("transparent");var li={Device:oi,ForwardRenderer:Ge,Texture2D:si,canvas:ei,Scene:ii,Camera:ni,View:ri,Model:ai,RenderData:je,IARenderData:He,InputAssembler:hi,Asset:Xe,TextureAsset:Ye,Material:Je,SpriteMaterial:Ze,GraySpriteMaterial:Ke,StencilMaterial:Qe,shaders:ze,RecyclePool:ce,Pool:ae,math:H,renderer:Oe,gfx:At};e.exports=li}),{}],199:[(function(t,e,i){var n=0,r=1,s=2,o=r|s,a=4,h=8,l=16,c=32,u=64,_=128,f=256,m=512,d=1024,p=null,y=0;function v(){this._func=C,this._next=null}var g=v.prototype;g._doNothing=function(){},g._localTransform=function(t){t._updateLocalMatrix(),t._renderFlag&=~r,this._next._func(t)},g._worldTransform=function(t){p.worldMatDirty++;var e=t._matrix,i=t._position;e.m12=i.x,e.m13=i.y,(function(t,e,i){var n=e.m00,r=e.m01,s=e.m04,o=e.m05,a=e.m12,h=e.m13,l=i.m00,c=i.m01,u=i.m04,_=i.m05,f=i.m12,m=i.m13;0!==c||0!==u?(t.m00=n*l+r*u,t.m01=n*c+r*_,t.m04=s*l+o*u,t.m05=s*c+o*_,t.m12=l*a+u*h+f,t.m13=c*a+_*h+m):(t.m00=n*l,t.m01=r*_,t.m04=s*l,t.m05=o*_,t.m12=l*a+f,t.m13=_*h+m)})(t._worldMatrix,e,t._parent._worldMatrix),t._renderFlag&=~s,this._next._func(t),p.worldMatDirty--},g._color=function(t){var e=t._renderComponent;e?e._updateColor():t._renderFlag&=~l,this._next._func(t)},g._opacity=function(t){p.parentOpacityDirty++,t._renderFlag&=~h,this._next._func(t),p.parentOpacityDirty--},g._updateRenderData=function(t){var e=t._renderComponent;e._assembler.updateRenderData(e),t._renderFlag&=~a,this._next._func(t)},g._render=function(t){var e=t._renderComponent;p._commitComp(e,e._assembler,t._cullingMask),this._next._func(t)},g._customIARender=function(t){var e=t._renderComponent;p._commitIA(e,e._assembler,t._cullingMask),this._next._func(t)},g._children=function(t){var e=y,i=p.parentOpacity;p.parentOpacity*=t._opacity/255;for(var n=p.worldMatDirty?s:0,r=p.parentOpacityDirty?l:0,o=t._children,a=0,h=o.length;a0;)i&t&&(e=b(i,e)),i>>=1;return e})(e))._func(t)}v.flows=A,v.createFlow=b,v.render=function(t){y=1<this._width&&(this._x=n,this._y=this._nexty),this._y+h>this._nexty&&(this._nexty=this._y+h+n),this._nexty>this._height)return!1;this._texture.drawTextureAt(i,this._x-1,this._y),this._texture.drawTextureAt(i,this._x+1,this._y),this._texture.drawTextureAt(i,this._x,this._y-1),this._texture.drawTextureAt(i,this._x,this._y+1),this._texture.drawTextureAt(i,this._x,this._y),this._innerTextureInfos[i._id]={x:this._x,y:this._y,texture:i},e.x+=this._x,e.y+=this._y,this._x+=a+n,this._dirty=!0}return t._original={x:s,y:o,texture:t._texture},t._texture=this._texture,t._calculateUV(),this._innerSpriteFrames.push(t),!0},update:function(){this._dirty&&(this._texture.update(),this._dirty=!1)},reset:function(){this._x=n,this._y=n,this._nexty=n;for(var t=this._innerSpriteFrames,e=0,i=t.length;eh||n>h||i<=8||n<=8||(a&c)!==_)){var f=r[s];f||(f=l()),f.insertSpriteFrame(t)||s===o||(f=l()).insertSpriteFrame(t)}}}},reset:function(){for(var t=0,e=r.length;t0&&n>0&&G+u._width*b>F&&!s.isUnicodeSpace(C)){_.push(a),a=0,i++,n=0,r-=P*b+0,V=!0;break}f.x=G,f.y=r-u._offsetY*b,this._recordLetterInfo(m,f,C,k,i),k+1f.y-u._height*b&&(D=f.y-u._height*b)}else this._recordPlaceholderInfo(k,C),console.log("Can't find letter definition in texture atlas "+p.atlasName+" for letter:"+C);else this._recordPlaceholderInfo(k,C)}V||(n=I,a=B,hD&&(l=D),o1&&(v+=0*(y-1)),E.width=L,E.height=O,L<=0&&(E.width=parseFloat(o.toFixed(2))),O<=0&&(E.height=parseFloat(v.toFixed(2))),x=E.height,A=0,h>0&&(x=E.height+h),l<-v&&(A=v+l),!0},_getFirstCharLen:function(){return 1},_getFirstWordLen:function(t,e,i){var n=t.charAt(e);if(s.isUnicodeCJK(n)||"\n"===n||s.isUnicodeSpace(n))return 1;var r=1,o=d.getLetterDefinitionForChar(n);if(!o)return r;for(var a=o._xAdvance*b+M,h=e+1;hF&&!s.isUnicodeSpace(n)&&F>0)return r;if(a+=o._xAdvance*b+M,"\n"===n||s.isUnicodeSpace(n)||s.isUnicodeCJK(n))break;r++}return r},_multilineTextWrapByWord:function(){return this._multilineTextWrap(this._getFirstWordLen)},_multilineTextWrapByChar:function(){return this._multilineTextWrap(this._getFirstCharLen)},_recordPlaceholderInfo:function(t,e){if(t>=u.length){var i=new a;u.push(i)}u[t]._char=e,u[t]._valid=!1},_recordLetterInfo:function(t,e,i,n,r){if(n>=u.length){var s=new a;u.push(s)}i=i.charCodeAt(0),u[n]._lineIndex=r,u[n]._char=i,u[n]._valid=t[i]._validDefinition,u[n]._positionX=e.x,u[n]._positionY=e.y},_alignText:function(){v=0,_.length=0,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),I===r.SHRINK&&T>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp),this._updateQuads()||I===r.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp)},_scaleFontSizeDown:function(t){var e=!0;t||(t=.1,e=!1),T=t,e&&this._updateContent()},_shrinkLabelToContentSize:function(t){for(var e=T,i=P,n=d,r=0,s=n.cloneLetterDefinition(),o=!0;t();){var a=e-++r;if(o=!1,a<=0)break;var h=a/e;n.assignLetterDefinitions(s),n.scaleFontLetterDefinition(h),P=i*h,this._multilineTextWrapByWord(),this._computeAlignmentOffset()}P=i,n.assignLetterDefinitions(s),o||e-r>=0&&this._scaleFontSizeDown(e-r)},_isVerticalClamp:function(){return v>E.height},_isHorizontalClamp:function(){for(var t=d._letterDefinitions,e=!1,i=0,n=S.length;i0)if(R){if(_[a]>E.width&&(o>E.width||o<0)){e=!0;break}}else if(o>E.width){e=!0;break}}}return e},_isHorizontalClamped:function(t,e){var i=_[e],n=t>E.width||t<0;return R?i>E.width&&n:n},_updateQuads:function(){var t=d._letterDefinitions,e=C._texture,i=l.node,n=l._renderData;n.dataLength=n.vertexCount=n.indiceCount=0;for(var s=E,o=i._anchorPoint.x*s.width,a=i._anchorPoint.y*s.height,c=!0,_=0,m=S.length;_0){if(v>x){var T=v-x;h.y+=T,h.height-=T,v-=T}v-y._height*b0&&this._isHorizontalClamped(D,w))if(I===r.CLAMP)h.width=0;else if(I===r.SHRINK){if(E.width>y._width){c=!1;break}h.width=0}if(h.height>0&&h.width>0){var B=C.isRotated(),M=C._originalSize,P=C._rect,R=C._offset,F=R.x+(M.width-P.width)/2,V=R.y-(M.height-P.height)/2;if(B){var N=h.x;h.x=P.x+P.height-h.y-h.height-V,h.y=N+P.y-F,h.y<0&&(h.height=h.height+V)}else h.x+=P.x-F,h.y+=P.y+V;var k=p._positionX+f[p._lineIndex];this.appendQuad(n,e,h,B,k-o,v-a,b)}}}return c},appendQuad:function(t,e,i,n,r,s,o){},_computeAlignmentOffset:function(){switch(f.length=0,D){case n.TextAlignment.LEFT:for(var t=0;t=32||this.pool.push(t)}};e.exports={_getAssemblerData:function(){if(cc.game.renderType===cc.game.RENDER_TYPE_CANVAS)L=O.get();else if(!L){var t=document.createElement("canvas");L={canvas:t,context:t.getContext("2d")}}return L.canvas.width=L.canvas.height=1,L},_resetAssemblerData:function(t){cc.game.renderType===cc.game.RENDER_TYPE_CANVAS&&t&&O.put(t)},updateRenderData:function(t){t._renderData.vertDirty&&(this._updateFontFamly(t),this._updateProperties(t),this._calculateLabelFont(),this._calculateSplitedStrings(),this._updateLabelDimensions(),this._calculateTextBaseline(),this._updateTexture(t),t._actualFontSize=p,t.node.setContentSize(g),this._updateVerts(t),t._renderData.vertDirty=t._renderData.uvDirty=!1,u=null,_=null,f=null)},_updateVerts:function(){},_updateFontFamly:function(t){t.useSystemFont?S=t.fontFamily:t.font?t.font._nativeAsset?S=t.font._nativeAsset:cc.loader.load(t.font.nativeUrl,(function(e,i){S=i||"Arial",t._updateRenderData(!0)})):S="Arial"},_updateProperties:function(t){var e=t._assemblerData;u=e.context,_=e.canvas,f=t._texture,d=t.string.toString(),p=t._fontSize,y=p,T=t.overflow,g.width=t.node.width,g.height=t.node.height,x=t._lineHeight,A=t.horizontalAlign,b=t.verticalAlign,C=t.node.color,P=t._isBold,I=t._isItalic,R=t._isUnderline,w=T!==h.NONE&&(T===h.RESIZE_HEIGHT||t.enableWrapText);var i=c&&t.getComponent(a);i&&i.enabled?(E=!0,M=B=i.width,(D=cc.color(i.color)).a=D.a*t.node.color.a/255):(E=!1,M=0)},_calculateFillTextStartPosition:function(){var t=this._getLineHeight(),e=v.length,i=void 0,r=void 0;return i=A===n.TextAlignment.RIGHT?g.width-M:A===n.TextAlignment.CENTER?g.width/2:0+M,r=b===n.VerticalTextAlignment.TOP?0:b===n.VerticalTextAlignment.CENTER?g.height/2-t*(e-1)/2:g.height-t*(e-1),cc.v2(i,r)},_updateTexture:function(){u.clearRect(0,0,_.width,_.height),u.font=m;var t=this._calculateFillTextStartPosition(),e=this._getLineHeight();u.lineJoin="round",u.fillStyle="rgba("+C.r+", "+C.g+", "+C.b+", "+C.a/255+")";for(var i=void 0,n=0;ns?e:s}i=v.length*this._getLineHeight(),g.width=parseFloat(e.toFixed(2))+2*M,g.height=parseFloat(i.toFixed(2)),I&&(g.width+=y*Math.tan(.20943951))}_.width=g.width,_.height=g.height},_calculateTextBaseline:function(){this._node;var t=void 0,e=void 0;t=A===n.TextAlignment.RIGHT?"right":A===n.TextAlignment.CENTER?"center":"left",u.textAlign=t,e=b===n.VerticalTextAlignment.TOP?"top":b===n.VerticalTextAlignment.CENTER?"middle":"bottom",u.textBaseline=e},_calculateSplitedStrings:function(){var t=d.split("\n");if(w){v=[];for(var e=g.width-2*M,i=0;ia||s>o;){if(_?l=f/2|0:f=l=f-1,l<=0){cc.logID(4003);break}for(p=l,m=this._getFontDesc(),u.font=m,v=[],n=0,i=0;ia?f=0|l:(_=!1,n=a+1))}}else{for(n=t.length*this._getLineHeight(),i=0;i80*i){n=h=t[0],a=l=t[1];for(var x=i;xh&&(h=c),f>l&&(l=f);d=Math.max(h-n,l-a)}return o(v,g,i,n,a,d),g}function r(t,e,i,n,r){var s,o;if(r===T(t,e,i,n)>0)for(s=e;s=e;s-=n)o=b(s,t[s],t[s+1],o);return o&&v(o,o.next)&&(C(o),o=o.next),o}function s(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!v(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(C(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,r,u,_){if(t){!_&&u&&(function(t,e,i,n){var r=t;do{null===r.z&&(r.z=f(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,(function(t){var e,i,n,r,s,o,a,h,l=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0===a?(r=n,n=n.nextZ,h--):0!==h&&n?i.z<=n.z?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,h--):(r=i,i=i.nextZ,a--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,l*=2}while(o>1)})(r)})(t,n,r,u);for(var m,d,p=t;t.prev!==t.next;)if(m=t.prev,d=t.next,u?h(t,n,r,u):a(t))e.push(m.i/i),e.push(t.i/i),e.push(d.i/i),C(t),t=d.next,p=d.next;else if((t=d)===p){_?1===_?o(t=l(t,e,i),e,i,n,r,u,2):2===_&&c(t,e,i,n,r,u):o(s(t),e,i,n,r,u,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(y(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(d(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&y(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function h(t,e,i,n){var r=t.prev,s=t,o=t.next;if(y(r,s,o)>=0)return!1;for(var a=r.xs.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,c=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,u=f(a,h,e,i,n),_=f(l,c,e,i,n),m=t.nextZ;m&&m.z<=_;){if(m!==t.prev&&m!==t.next&&d(r.x,r.y,s.x,s.y,o.x,o.y,m.x,m.y)&&y(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(m=t.prevZ;m&&m.z>=u;){if(m!==t.prev&&m!==t.next&&d(r.x,r.y,s.x,s.y,o.x,o.y,m.x,m.y)&&y(m.prev,m,m.next)>=0)return!1;m=m.prevZ}return!0}function l(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!v(r,s)&&g(r,n,n.next,s)&&x(r,s)&&x(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),C(n),C(n.next),n=t=s),n=n.next}while(n!==t);return n}function c(t,e,i,n,r,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&p(h,l)){var c=A(h,l);return h=s(h,h.next),c=s(c,c.next),o(h,e,i,n,r,a),void o(c,e,i,n,r,a)}l=l.next}h=h.next}while(h!==t)}function u(t,e){return t.x-e.x}function _(t,e){if(e=(function(t,e){var i,n=e,r=t.x,s=t.y,o=-1/0;do{if(s<=n.y&&s>=n.next.y){var a=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>o){if(o=a,a===r){if(s===n.y)return n;if(s===n.next.y)return n.next}i=n.x=n.x&&n.x>=c&&d(si.x)&&x(n,t)&&(i=n,_=h),n=n.next;return i})(t,e)){var i=A(e,t);s(i,i.next)}}function f(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function m(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!(function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&g(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1})(t,e)&&x(t,e)&&x(e,t)&&(function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n})(t,e)}function y(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function v(t,e){return t.x===e.x&&t.y===e.y}function g(t,e,i,n){return!!(v(t,e)&&v(i,n)||v(t,n)&&v(i,e))||y(t,e,i)>0!=y(t,e,n)>0&&y(i,n,t)>0!=y(i,n,e)>0}function x(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function A(t,e){var i=new S(t.i,t.x,t.y),n=new S(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function b(t,e,i,n){var r=new S(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function C(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(t,e,i,n){for(var r=0,s=e,o=i-n;s0&&(n+=t[r-1].length,i.holes.push(n))}return i}}),{}],205:[(function(t,e,i){var n=t("../../../../graphics/helper"),r=t("../../../../graphics/types").PointFlags,s=t("../../mesh-buffer"),o=t("../../vertex-format").vfmtPosColor,a=t("../../../index"),h=a.renderEngine,l=h.IARenderData,c=h.InputAssembler,u=cc.Class({name:"cc.GraphicsPoint",extends:cc.Vec2,ctor:function(t,e){this.reset()},reset:function(){this.dx=0,this.dy=0,this.dmx=0,this.dmy=0,this.flags=0,this.len=0}});function _(){this.reset()}function f(t){this._tessTol=.25,this._distTol=.01,this._updatePathOffset=!1,this._paths=null,this._pathLength=0,this._pathOffset=0,this._points=null,this._pointsOffset=0,this._commandx=0,this._commandy=0,this._paths=[],this._points=[],this._renderDatas=[],this._dataOffset=0}cc.js.mixin(_.prototype,{reset:function(){this.closed=!1,this.nbevel=0,this.complex=!0,this.points?this.points.length=0:this.points=[]}}),cc.js.mixin(f.prototype,{moveTo:function(t,e){this._updatePathOffset&&(this._pathOffset=this._pathLength,this._updatePathOffset=!1),this._addPath(),this._addPoint(t,e,r.PT_CORNER),this._commandx=t,this._commandy=e},lineTo:function(t,e){this._addPoint(t,e,r.PT_CORNER),this._commandx=t,this._commandy=e},bezierCurveTo:function(t,e,i,s,o,a){var h=this._curPath,l=h.points[h.points.length-1];l.x!==t||l.y!==e||i!==o||s!==a?(n.tesselateBezier(this,l.x,l.y,t,e,i,s,o,a,0,r.PT_CORNER),this._commandx=o,this._commandy=a):this.lineTo(o,a)},quadraticCurveTo:function(t,e,i,n){var r=this._commandx,s=this._commandy;this.bezierCurveTo(r+2/3*(t-r),s+2/3*(e-s),i+2/3*(t-i),n+2/3*(e-n),i,n)},arc:function(t,e,i,r,s,o){n.arc(this,t,e,i,r,s,o)},ellipse:function(t,e,i,r){n.ellipse(this,t,e,i,r),this._curPath.complex=!1},circle:function(t,e,i){n.ellipse(this,t,e,i,i),this._curPath.complex=!1},rect:function(t,e,i,n){this.moveTo(t,e),this.lineTo(t,e+n),this.lineTo(t+i,e+n),this.lineTo(t+i,e),this.close(),this._curPath.complex=!1},roundRect:function(t,e,i,r,s){n.roundRect(this,t,e,i,r,s),this._curPath.complex=!1},clear:function(t,e){this._pathLength=0,this._pathOffset=0,this._pointsOffset=0,this._dataOffset=0,this._curPath=null;var i=this._renderDatas;if(e){this._paths.length=0,this._points.length=0;for(var n=0,r=i.length;ni?i:t}var A={useModel:!0,createImpl:function(t){return new h(t)},updateRenderData:function(t){for(var e=t._impl.getRenderDatas(),i=0,n=e.length;i65535||3*s>131070)&&(++v._dataOffset,s=e,v._dataOffsetr.vertexOffset&&r.requestStatic(e,3*e),n},stroke:function(t){g=t._strokeColor._val,this._flattenPaths(t._impl),this._expandStroke(t),t._impl._updatePathOffset=!0},fill:function(t){g=t._fillColor._val,this._expandFill(t),t._impl._updatePathOffset=!0},_expandStroke:function(t){var e=.5*t.lineWidth,i=t.lineCap,n=t.lineJoin,a=t.miterLimit;v=t._impl;var h=(function(t,e,i){var n=2*f(t/(t+i));return u(2,_(e/n))})(e,l,v._tessTol);this._calculateJoins(v,e,n,a);for(var c=v._paths,m=0,d=v._pathOffset,p=v._pathLength;d0&&(o=1/e);for(var a=t._paths,h=t._pathOffset,l=t._pathLength;h1e-6){var S=1/v;S>600&&(S=600),p.dmx*=S,p.dmy*=S}p.dx*d.dy-d.dx*p.dy>0&&(0,p.flags|=r.PT_LEFT),v*(g=u(11,c(d.len,p.len)*o))*g<1&&(p.flags|=r.PT_INNERBEVEL),p.flags&r.PT_CORNER&&(v*n*n<1||i===s.BEVEL||i===s.ROUND)&&(p.flags|=r.PT_BEVEL),0!=(p.flags&(r.PT_BEVEL|r.PT_INNERBEVEL))&&_.nbevel++,d=p,p=f[y+1]}}},_flattenPaths:function(t){for(var e=t._paths,i=t._pathOffset,n=t._pathLength;iC&&(S-=2*l),this._vset(v,g),this._vset(u-o*n,e.y-a*n);for(var T=x(_((C-S)/l)*s,2,s),w=0;w>2,m=n.vertexCount;_.request(m,n.indiceCount);for(var d=_._vData,p=0;p>2;c.request(4,6);for(var _=c._vData,f=0;f<4;f++){var m=i[f];_[u++]=m.x*r+m.y*o+h,_[u++]=m.x*s+m.y*a+l,_[u++]=m.u,_[u++]=m.v}},_updateVerts:function(t){var e=t._renderData,i=t.node,n=i.width,r=i.height,s=i.anchorX*n,o=i.anchorY*r,a=e._data;a[0].x=-s,a[0].y=-o,a[1].x=n-s,a[1].y=-o,a[2].x=-s,a[2].y=r-o,a[3].x=n-s,a[3].y=r-o}},r)}),{"../../../../platform/js":176,"../../../utils/label/ttf":203}],211:[(function(t,e,i){var n=t("../stencil-manager"),r=t("../../../components/CCMask"),s=(t("../../../graphics/graphics"),t("../../render-flow")),o=t("./sprite/simple"),a=t("./graphics"),h=n.sharedManager,l={updateRenderData:function(t){t._renderData||(t._type===r.Type.IMAGE_STENCIL?t._renderData=o.createData(t):(t._renderData=t.requestRenderData(),a.updateRenderData(t._clearGraphics)));var e=t._renderData;if(t._type===r.Type.IMAGE_STENCIL)if(t.spriteFrame){var i=t.node._contentSize,n=t.node._anchorPoint;e.updateSizeNPivot(i.width,i.height,n.x,n.y),e.dataLength=4,o.updateRenderData(t),e.material=t._material}else t._material=null;else t._graphics._material=t._material,a.updateRenderData(t._graphics)},fillBuffers:function(t,e){(t._type!==r.Type.IMAGE_STENCIL||t.spriteFrame)&&(h.pushMask(t),h.clear(),a.fillBuffers(t._clearGraphics,e),h.enterLevel(),e.node=t.node,e.material=t._material,t._type===r.Type.IMAGE_STENCIL?(o.fillBuffers(t,e),e._flush()):a.fillBuffers(t._graphics,e)),t.node._renderFlag|=s.FLAG_UPDATE_RENDER_DATA}},c={fillBuffers:function(t,e){(t._type!==r.Type.IMAGE_STENCIL||t.spriteFrame)&&h.exitMask(),t.node._renderFlag|=s.FLAG_UPDATE_RENDER_DATA}};r._assembler=l,r._postAssembler=c,e.exports={front:l,end:c}}),{"../../../components/CCMask":70,"../../../graphics/graphics":103,"../../render-flow":199,"../stencil-manager":223,"./graphics":206,"./sprite/simple":217}],212:[(function(t,e,i){var n=t("../../../components/CCMotionStreak"),r=t("../../render-flow"),s=t("../vertex-format").vfmtPosUvColor;function o(t,e){this.point=t||cc.v2(),this.dir=e||cc.v2(),this.distance=0,this.time=0}o.prototype.setPoint=function(t,e){this.point.x=t,this.point.y=e},o.prototype.setDir=function(t,e){this.dir.x=t,this.dir.y=e};cc.v2(),cc.v2();var a=cc.v2(),h=cc.v2();function l(t,e){return t.x=-e.y,t.y=e.x,t}var c={updateRenderData:function(t){var e=cc.director.getDeltaTime();this.update(t,e);var i=t._renderData,n=t.node._contentSize,r=t.node._anchorPoint;i.updateSizeNPivot(n.width,n.height,r.x,r.y),i.material=t.getMaterial()},update:function(t,e){var i=t._renderData;i||(i=t._renderData=t.requestRenderData());var n=t._stroke/2,r=t.node._worldMatrix,s=(r.m00,r.m01,r.m04,r.m05,r.m12),c=r.m13,u=t._points,_=void 0;if(u.length>1){var f=u[0].point.x-s,m=u[0].point.y-c;f*f+m*m=0;S--){var T=u[S],w=T.point,E=T.dir;if(T.time-=e,T.time<0)u.splice(S,1);else{var D=T.time/b,B=u[S-1];if(!C){if(!B){u.splice(S,1);continue}w.x=B.point.x-E.x*D,w.y=B.point.y-E.y*D}C=!0,l(a,E),i.dataLength+=2;var M=(D*x<<24>>>0)+(g<<16)+(v<<8)+y,P=d.length-1;d[P].x=w.x-a.x*n,d[P].y=w.y-a.y*n,d[P].u=0,d[P].v=D,d[P].color=M,d[--P].x=w.x+a.x*n,d[P].y=w.y+a.y*n,d[P].u=1,d[P].v=D,d[P].color=M}}i.vertexCount=i.dataLength,i.indiceCount=3*(i.vertexCount-2)}},fillBuffers:function(t,e){t.node;var i=t._renderData,n=i._data,o=e.getBuffer("mesh",s),a=o.byteOffset>>2,h=i.vertexCount,l=o.indiceOffset,c=o.vertexOffset;o.request(h,i.indiceCount);for(var u=o._vData,_=o._iData,f=o._uintVData,m=void 0,d=0,p=i.vertexCount;d1?1:o)<0?0:o,a=(a=a>1?1:a)<0?0:a;var h=o+(a=(a-=o)<0?0:a);h=h>1?1:h,n&&this.updateUVs(t,o,h),s&&(this.updateVerts(t,o,h),this.updateWorldVerts(t))}},updateUVs:function(t,e,i){var r=t._spriteFrame,s=t._renderData,o=s._data,a=r._texture.width,h=r._texture.height,l=r._rect,c=void 0,u=void 0,_=void 0,f=void 0,m=void 0,d=void 0,p=void 0,y=void 0,v=void 0,g=void 0;switch(r._rotated?(c=l.x/a,u=(l.y+l.width)/h,_=m=c,p=v=(l.x+l.height)/a,d=g=u,f=y=l.y/h):(c=l.x/a,u=(l.y+l.height)/h,_=p=c,m=v=(l.x+l.width)/a,f=d=u,y=g=l.y/h),t._fillType){case n.HORIZONTAL:o[0].u=_+(m-_)*e,o[0].v=f,o[1].u=_+(m-_)*i,o[1].v=d,o[2].u=p+(v-p)*e,o[2].v=y,o[3].u=p+(v-p)*i,o[3].v=g;break;case n.VERTICAL:o[0].u=_,o[0].v=f+(y-f)*e,o[1].u=m,o[1].v=d+(g-d)*e,o[2].u=p,o[2].v=f+(y-f)*i,o[3].u=v,o[3].v=d+(g-d)*i;break;default:cc.errorID(2626)}s.uvDirty=!1},updateVerts:function(t,e,i){var r=t._renderData,s=r._data,o=t.node,a=o.width,h=o.height,l=o.anchorX*a,c=o.anchorY*h,u=-l,_=-c,f=a-l,m=h-c,d=void 0;switch(t._fillType){case n.HORIZONTAL:d=u+(f-u)*i,u=u+(f-u)*e,f=d;break;case n.VERTICAL:d=_+(m-_)*i,_=_+(m-_)*e,m=d;break;default:cc.errorID(2626)}s[4].x=u,s[4].y=_,s[5].x=f,s[5].y=_,s[6].x=u,s[6].y=m,s[7].x=f,s[7].y=m,r.vertDirty=!1},createData:function(t){var e=t.requestRenderData();return e.dataLength=8,e.vertexCount=4,e.indiceCount=6,e},updateWorldVerts:function(t){for(var e=t.node,i=t._renderData._data,n=e._worldMatrix,r=n.m00,s=n.m01,o=n.m04,a=n.m05,h=n.m12,l=n.m13,c=0;c<4;c++){var u=i[c+4],_=i[c];_.x=u.x*r+u.y*o+h,_.y=u.x*s+u.y*a+l}},fillBuffers:function(t,e){e.worldMatDirty&&this.updateWorldVerts(t);var i=t._renderData._data,n=t.node._worldMatrix,r=(n.m00,n.m01,n.m04,n.m05,n.m12,n.m13,e._quadBuffer),s=r.byteOffset>>2;r.request(4,6);for(var o=r._vData,a=0;a<4;a++){var h=i[a];o[s++]=h.x,o[s++]=h.y,o[s++]=h.u,o[s++]=h.v}}}}),{"../../../../components/CCSprite":80,"../../../utils/dynamic-atlas/manager":201}],214:[(function(t,e,i){var n=t("../../../../components/CCSprite"),r=n.Type,s=n.FillType,o=t("./simple"),a=t("./sliced"),h=t("./tiled"),l=t("./radial-filled"),c=t("./bar-filled"),u=t("./mesh"),_={getAssembler:function(t){var e=o;switch(t.type){case r.SLICED:e=a;break;case r.TILED:e=h;break;case r.FILLED:e=t._fillType===s.RADIAL?l:c;break;case r.MESH:e=u}return e},updateRenderData:function(t){return t.__allocedDatas}};n._assembler=_,e.exports=_}),{"../../../../components/CCSprite":80,"./bar-filled":213,"./mesh":215,"./radial-filled":216,"./simple":217,"./sliced":218,"./tiled":219}],215:[(function(t,e,i){var n=t("../../../utils/dynamic-atlas/manager");e.exports={useModel:!1,createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.spriteFrame;e&&(!e._original&&n&&n.insertSpriteFrame(e),t._material._texture!==e._texture&&t._activateMaterial());var i=t._renderData;if(i&&e){var r=e.vertices;if(r)i.vertexCount!==r.x.length&&(i.vertexCount=r.x.length,i.indiceCount=r.triangles.length,i.dataLength=2*i.vertexCount,i.uvDirty=i.vertDirty=!0),i.uvDirty&&this.updateUVs(t),i.vertDirty&&(this.updateVerts(t),this.updateWorldVerts(t))}},updateUVs:function(t){for(var e=t.getMaterial().effect.getProperty("texture"),i=(e._width,e._height,t.spriteFrame.vertices),n=i.nu,r=i.nv,s=t._renderData,o=s._data,a=0,h=n.length;a>2,a=s.indiceOffset,h=s.vertexOffset;s.request(i.vertexCount,i.indiceCount);for(var l=s._vData,c=s._iData,u=0,_=i.vertexCount;u<_;u++){var f=n[u];l[o++]=f.x,l[o++]=f.y,l[o++]=f.u,l[o++]=f.v}for(var m=r.triangles,d=0,p=m.length;d=1;)o-=1;for(;o<0;)o+=1;var h=(o*=r)+(a*=r);this._calculateVertices(t),this._calculateUVs(e);var l=this._center,c=this._vertPos,u=this._vertices,_=this._triangles;this._calcInsectedPoints(u[0],u[2],u[1],u[3],l,o,this._intersectPoint_1),this._calcInsectedPoints(u[0],u[2],u[1],u[3],l,o+a,this._intersectPoint_2);for(var f=0,m=0;m<4;++m){var d=_[m];if(d)if(a>=r)i.dataLength=f+3,this._generateTriangle(s,f,l,c[d[0]],c[d[1]]),f+=3;else{var p=this._getVertAngle(l,c[d[0]]),y=this._getVertAngle(l,c[d[1]]);y=h||(p>=o?(i.dataLength=f+3,y>=h?this._generateTriangle(s,f,l,c[d[0]],this._intersectPoint_2[m]):this._generateTriangle(s,f,l,c[d[0]],c[d[1]]),f+=3):y<=o||(y<=h?(i.dataLength=f+3,this._generateTriangle(s,f,l,this._intersectPoint_1[m],c[d[1]]),f+=3):(i.dataLength=f+3,this._generateTriangle(s,f,l,this._intersectPoint_1[m],this._intersectPoint_2[m]),f+=3))),p+=r,y+=r}}i.indiceCount=i.vertexCount=f,i.vertDirty=i.uvDirty=!1}},_getVertAngle:function(t,e){var i,n;if(i=e.x-t.x,n=e.y-t.y,0!==i||0!==n){if(0===i)return n>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(n/i);return i<0&&(r+=Math.PI),r}},_generateTriangle:function(t,e,i,n,r){var s=this._vertices,o=s[0],a=s[1],h=s[2],l=s[3];t[e].x=i.x,t[e].y=i.y,t[e+1].x=n.x,t[e+1].y=n.y,t[e+2].x=r.x,t[e+2].y=r.y;var c=void 0,u=void 0;c=(i.x-o)/(h-o),u=(i.y-a)/(l-a),this._generateUV(c,u,t,e),c=(n.x-o)/(h-o),u=(n.y-a)/(l-a),this._generateUV(c,u,t,e+1),c=(r.x-o)/(h-o),u=(r.y-a)/(l-a),this._generateUV(c,u,t,e+2)},_generateUV:function(t,e,i,n){var r=this._uvs,s=r[0]+(r[2]-r[0])*t,o=r[4]+(r[6]-r[4])*t,a=r[1]+(r[3]-r[1])*t,h=r[5]+(r[7]-r[5])*t,l=i[n];l.u=s+(o-s)*e,l.v=a+(h-a)*e},_calcInsectedPoints:function(t,e,i,n,r,s,o){var a=Math.sin(s),h=Math.cos(s),l=void 0,c=void 0;if(0!==Math.cos(s)){if(l=a/h,(t-r.x)*h>0){var u=r.y+l*(t-r.x);o[0].x=t,o[0].y=u}if((e-r.x)*h>0){var _=r.y+l*(e-r.x);o[2].x=e,o[2].y=_}}if(0!==Math.sin(s)){if(c=h/a,(n-r.y)*a>0){var f=r.x+c*(n-r.y);o[3].x=f,o[3].y=n}if((i-r.y)*a>0){var m=r.x+c*(i-r.y);o[1].x=m,o[1].y=i}}},_calculateVertices:function(t){var e=t.node,i=e.width,n=e.height,r=e.anchorX*i,s=e.anchorY*n,o=-r,a=-s,h=i-r,l=n-s,c=this._vertices;c[0]=o,c[1]=a,c[2]=h,c[3]=l;var u=this._center,_=t._fillCenter,f=u.x=Math.min(Math.max(0,_.x),1)*(h-o)+o,m=u.y=Math.min(Math.max(0,_.y),1)*(l-a)+a,d=this._vertPos;d[0].x=d[3].x=o,d[1].x=d[2].x=h,d[0].y=d[1].y=a,d[2].y=d[3].y=l;var p=this._triangles;p.length=0,f!==c[0]&&(p[0]=[3,0]),f!==c[2]&&(p[2]=[1,2]),m!==c[1]&&(p[1]=[0,1]),m!==c[3]&&(p[3]=[2,3])},_calculateUVs:function(t){var e=t._texture.width,i=t._texture.height,n=t._rect,r=void 0,s=void 0,o=void 0,a=void 0,h=this._uvs;t._rotated?(r=n.x/e,s=(n.x+n.height)/e,o=n.y/i,a=(n.y+n.width)/i,h[0]=h[2]=r,h[4]=h[6]=s,h[3]=h[7]=a,h[1]=h[5]=o):(r=n.x/e,s=(n.x+n.width)/e,o=n.y/i,a=(n.y+n.height)/i,h[0]=h[4]=r,h[2]=h[6]=s,h[1]=h[3]=a,h[5]=h[7]=o)},fillBuffers:function(t,e){var i=t._renderData,n=i._data,r=t.node._worldMatrix,s=r.m00,o=r.m01,a=r.m04,h=r.m05,l=r.m12,c=r.m13,u=e._meshBuffer,_=u.byteOffset>>2,f=u._vData,m=u._iData,d=u.indiceOffset,p=u.vertexOffset;u.request(i.vertexCount,i.indiceCount);for(var y=n.length,v=0;v>2;c.request(4,6);var _=c._vData,f=t._spriteFrame.uv;_[u+2]=f[0],_[u+3]=f[1],_[u+6]=f[2],_[u+7]=f[3],_[u+10]=f[4],_[u+11]=f[5],_[u+14]=f[6],_[u+15]=f[7];var m=i[0],d=i[3],p=m.x,y=d.x,v=m.y,g=d.y,x=r*p,A=r*y,b=s*p,C=s*y,S=o*v,T=o*g,w=a*v,E=a*g;_[u]=x+S+h,_[u+1]=b+w+l,_[u+4]=A+S+h,_[u+5]=C+w+l,_[u+8]=x+T+h,_[u+9]=b+E+l,_[u+12]=A+T+h,_[u+13]=C+E+l},createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.vertexCount=4,e.indiceCount=6,e},updateVerts:function(t){var e=t._renderData,i=t.node,n=e._data,r=i.width,s=i.height,o=i.anchorX*r,a=i.anchorY*s,h=void 0,l=void 0,c=void 0,u=void 0;if(t.trim)h=-o,l=-a,c=r-o,u=s-a;else{var _=t.spriteFrame,f=_._originalSize.width,m=_._originalSize.height,d=_._rect.width,p=_._rect.height,y=_._offset,v=r/f,g=s/m,x=y.x+(f-d)/2,A=y.x-(f-d)/2;h=x*v-o,l=(y.y+(m-p)/2)*g-a,c=r+A*v-o,u=s+(y.y-(m-p)/2)*g-a}n[0].x=h,n[0].y=l,n[3].x=c,n[3].y=u,e.vertDirty=!1}}}),{"../../../utils/dynamic-atlas/manager":201}],218:[(function(t,e,i){var n=t("../../../utils/dynamic-atlas/manager");e.exports={useModel:!1,createData:function(t){var e=t.requestRenderData();return e.dataLength=20,e.vertexCount=16,e.indiceCount=54,e},updateRenderData:function(t,e){var i=t.spriteFrame;i&&(!i._original&&n&&n.insertSpriteFrame(i),t._material._texture!==i._texture&&t._activateMaterial());var r=t._renderData;r&&i&&(r.vertDirty&&(this.updateVerts(t),this.updateWorldVerts(t)))},updateVerts:function(t){var e=t._renderData,i=e._data,n=t.node,r=n.width,s=n.height,o=n.anchorX*r,a=n.anchorY*s,h=t.spriteFrame,l=h.insetLeft,c=h.insetRight,u=h.insetTop,_=h.insetBottom,f=r-l-c,m=s-u-_,d=r/(l+c),p=s/(u+_);d=isNaN(d)||d>1?1:d,p=isNaN(p)||p>1?1:p,f=f<0?0:f,m=m<0?0:m,i[0].x=-o,i[0].y=-a,i[1].x=l*d-o,i[1].y=_*p-a,i[2].x=i[1].x+f,i[2].y=i[1].y+m,i[3].x=r-o,i[3].y=s-a,e.vertDirty=!1},fillBuffers:function(t,e){e.worldMatDirty&&this.updateWorldVerts(t);var i=t._renderData,n=i._data,r=e._meshBuffer,s=r.byteOffset>>2,o=i.vertexCount,a=r.indiceOffset,h=r.vertexOffset,l=t.spriteFrame.uvSliced;r.request(o,i.indiceCount);for(var c=r._vData,u=r._iData,_=4;_<20;++_){var f=n[_],m=l[_-4];c[s++]=f.x,c[s++]=f.y,c[s++]=m.u,c[s++]=m.v}for(var d=0;d<3;++d)for(var p=0;p<3;++p){var y=h+4*d+p;u[a++]=y,u[a++]=y+1,u[a++]=y+4,u[a++]=y+1,u[a++]=y+5,u[a++]=y+4}},updateWorldVerts:function(t){for(var e=t.node,i=t._renderData._data,n=e._worldMatrix,r=n.m00,s=n.m01,o=n.m04,a=n.m05,h=n.m12,l=n.m13,c=0;c<4;++c)for(var u=i[c],_=0;_<4;++_){var f=i[_],m=i[4+4*c+_];m.x=f.x*r+u.y*o+h,m.y=f.x*s+u.y*a+l}}}}),{"../../../utils/dynamic-atlas/manager":201}],219:[(function(t,e,i){var n=t("../../../utils/dynamic-atlas/manager");e.exports={useModel:!1,createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.spriteFrame;e&&(!e._original&&n&&n.insertSpriteFrame(e),t._material._texture!==e._texture&&t._activateMaterial());var i=t._renderData;if(e&&i&&(i.uvDirty||i.vertDirty)){var r=e._texture,s=(r.width,r.height,e._rect),o=t.node,a=Math.abs(o.width),h=Math.abs(o.height),l=o.anchorX*a,c=o.anchorY*h,u=s.width,_=s.height,f=a/u,m=h/_,d=Math.ceil(m),p=Math.ceil(f),y=i._data;i.dataLength=Math.max(8,d+1,p+1);for(var v=0;v<=p;++v)y[v].x=Math.min(u*v,a)-l;for(var g=0;g<=d;++g)y[g].y=Math.min(_*g,h)-c;i.vertexCount=d*p*4,i.indiceCount=d*p*6,i.uvDirty=!1,i.vertDirty=!1}},fillBuffers:function(t,e){var i=t.node,n=t._renderData,r=n._data,s=e._meshBuffer,o=s.byteOffset>>2,a=s.indiceOffset,h=s.vertexOffset;s.request(n.vertexCount,n.indiceCount);for(var l=s._vData,c=s._iData,u=t.spriteFrame._rotated,_=t.spriteFrame.uv,f=t.spriteFrame._rect,m=Math.abs(i.width),d=Math.abs(i.height),p=m/f.width,y=d/f.height,v=Math.ceil(y),g=Math.ceil(p),x=i._worldMatrix,A=x.m00,b=x.m01,C=x.m04,S=x.m05,T=x.m12,w=x.m13,E=void 0,D=void 0,B=void 0,M=void 0,P=void 0,I=void 0,R=0,L=v;R>2),e=new Uint16Array(this._iData.buffer,0,this.indiceOffset);this._vb.update(0,t),this._ib.update(0,e),this._dirty=!1}},requestStatic:function(t,e){var i=this.byteOffset+t*this._vertexBytes,n=this.indiceOffset+e,r=this._vData.byteLength,s=this._iData.length;if(i>r||n>s){for(;r>2);this._vb.update(0,t),this._dirty=!1}},_reallocBuffer:function(){this._reallocVData(!0),this._reallocIData(),this._fillQuadBuffer()}});cc.QuadBuffer=e.exports=r}),{"./mesh-buffer":220}],222:[(function(t,e,i){var n=t("../../platform/CCMacro"),r=t("../render-engine"),s=t("./vertex-format").vfmtPosUv,o=t("./stencil-manager"),a=t("../utils/dynamic-atlas/manager"),h=t("../render-flow"),l=t("./quad-buffer"),c=t("./mesh-buffer"),u=new(t("../../platform/id-generater"))("VertextFormat"),_=(r.gfx,r.RecyclePool),f=r.InputAssembler,m=(s._bytes,n.BATCH_VERTEX_COUNT),d=(s._bytes,{}),p=new r.Material;p.updateHash();var y=function(t,e){this._renderScene=e,this._device=t,this._stencilMgr=o.sharedManager,this.walking=!1,this.material=p,this.cullingMask=1,this._iaPool=new _(function(){return new f},16),this._modelPool=new _(function(){return new r.Model},16),this._quadBuffer=this.getBuffer("quad",s),this._meshBuffer=this.getBuffer("mesh",s),this._buffer=this._quadBuffer,this._batchedModels=[],this._dummyNode=new cc.Node,this._sortKey=0,this.node=this._dummyNode,this.parentOpacity=1,this.parentOpacityDirty=0,this.worldMatDirty=0,h.init(this)};y.prototype={constructor:y,reset:function(){this._iaPool.reset();for(var t=this._renderScene,e=this._batchedModels,i=0;ithis._maxLevel&&cc.errorID(9e3,this._maxLevel),this._maskStack.push(t)},clear:function(){this.stage=r.CLEAR},enterLevel:function(){this.stage=r.ENTER_LEVEL},exitMask:function(){0===this._maskStack.length&&cc.errorID(9001),this._maskStack.pop(),0===this._maskStack.length?this.stage=r.DISABLED:this.stage=r.ENABLED},getWriteMask:function(){return 1<0&&(t=t.substring(0,i));var n=/(\/|\\)([^\/\\]+)$/g.exec(t.replace(/(\/|\\)$/,""));if(!n)return null;var r=n[2];return e&&t.substring(t.length-e.length).toLowerCase()===e.toLowerCase()?r.substring(0,r.length-e.length):r},dirname:function(t){var e=r.exec(t);return e?e[2]:""},changeExtname:function(t,e){e=e||"";var i=t.indexOf("?"),n="";return i>0&&(n=t.substring(i),t=t.substring(0,i)),(i=t.lastIndexOf("."))<0?t+e+n:t.substring(0,i)+e+n},changeBasename:function(t,e,i){if(0===e.indexOf("."))return this.changeExtname(t,e);var n=t.indexOf("?"),r="",s=i?this.extname(t):"";return n>0&&(r=t.substring(n),t=t.substring(0,n)),n=(n=t.lastIndexOf("/"))<=0?0:n+1,t.substring(0,n)+e+s+r},_normalize:function(t){var e=t=String(t);do{e=t,t=t.replace(s,"")}while(e.length!==t.length);return t},sep:cc.sys.os===cc.sys.OS_WINDOWS?"\\":"/",stripSep:function(t){return t.replace(/[\/\\]$/,"")}},e.exports=cc.path}),{"../platform/CCSys":165}],226:[(function(t,e,i){var n=function(t,e,i,n,r,s){this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s};n.create=function(t,e,i,n,r,s){return{a:t,b:e,c:i,d:n,tx:r,ty:s}},n.identity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}},n.clone=function(t){return{a:t.a,b:t.b,c:t.c,d:t.d,tx:t.tx,ty:t.ty}},n.concat=function(t,e,i){var n=e.a,r=e.b,s=e.c,o=e.d,a=e.tx,h=e.ty;return t.a=n*i.a+r*i.c,t.b=n*i.b+r*i.d,t.c=s*i.a+o*i.c,t.d=s*i.b+o*i.d,t.tx=a*i.a+h*i.c+i.tx,t.ty=a*i.b+h*i.d+i.ty,t},n.invert=function(t,e){var i=e.a,n=e.b,r=e.c,s=e.d,o=1/(i*s-n*r),a=e.tx,h=e.ty;return t.a=o*s,t.b=-o*n,t.c=-o*r,t.d=o*i,t.tx=o*(r*h-s*a),t.ty=o*(n*a-i*h),t},n.fromMat4=function(t,e){return t.a=e.m00,t.b=e.m01,t.c=e.m04,t.d=e.m05,t.tx=e.m12,t.ty=e.m13,t},n.transformVec2=function(t,e,i,n){var r,s;return void 0===n?(n=i,r=e.x,s=e.y):(r=e,s=i),t.x=n.a*r+n.c*s+n.tx,t.y=n.b*r+n.d*s+n.ty,t},n.transformSize=function(t,e,i){return t.width=i.a*e.width+i.c*e.height,t.height=i.b*e.width+i.d*e.height,t},n.transformRect=function(t,e,i){var n=e.x,r=e.y,s=n+e.width,o=r+e.height,a=i.a*n+i.c*r+i.tx,h=i.b*n+i.d*r+i.ty,l=i.a*s+i.c*r+i.tx,c=i.b*s+i.d*r+i.ty,u=i.a*n+i.c*o+i.tx,_=i.b*n+i.d*o+i.ty,f=i.a*s+i.c*o+i.tx,m=i.b*s+i.d*o+i.ty,d=Math.min(a,l,u,f),p=Math.max(a,l,u,f),y=Math.min(h,c,_,m),v=Math.max(h,c,_,m);return t.x=d,t.y=y,t.width=p-d,t.height=v-y,t},n.transformObb=function(t,e,i,n,r,s){var o=r.x,a=r.y,h=r.width,l=r.height,c=s.a*o+s.c*a+s.tx,u=s.b*o+s.d*a+s.ty,_=s.a*h,f=s.b*h,m=s.c*l,d=s.d*l;e.x=c,e.y=u,i.x=_+c,i.y=f+u,t.x=m+c,t.y=d+u,n.x=_+m+c,n.y=f+d+u},cc.AffineTransform=e.exports=n}),{}],227:[(function(t,e,i){var n=t("../platform/CCObject").Flags,r=t("./misc"),s=t("../platform/js"),o=t("../platform/id-generater"),a=t("../event-manager"),h=t("../renderer/render-flow"),l=n.Destroying,c=n.DontDestroy,u=n.Deactivating,_=new o("Node");function f(t){return t?"string"==typeof t?s.getClassByName(t):t:(cc.errorID(3804),null)}function m(t,e){if(e._sealed)for(var i=0;i0},set:function(t){t?this._objFlags|=c:this._objFlags&=~c}},name:{get:function(){return this._name},set:function(t){this._name=t}},uuid:{get:function(){return this._id}},children:{get:function(){return this._children}},childrenCount:{get:function(){return this._children.length}},active:{get:function(){return this._active},set:function(t){if(t=!!t,this._active!==t){this._active=t;var e=this._parent;if(e)e._activeInHierarchy&&cc.director._nodeActivator.activateNode(this,t)}}},activeInHierarchy:{get:function(){return this._activeInHierarchy}}},ctor:function(t){this._name=void 0!==t?t:"New Node",this._activeInHierarchy=!1,this._id=_.getNewId(),cc.director._scheduler&&cc.director._scheduler.enableForTarget(this),this.__eventTargets=[],this._renderFlag=h.FLAG_TRANSFORM},getParent:function(){return this._parent},setParent:function(t){if(this._parent!==t){0;var e=this._parent;if(this._parent=t||null,this._onSetParent(t),t&&(this._level=t._level+1,a._setDirtyForNode(this),t._children.push(this),t.emit&&t.emit("child-added",this),t._renderFlag|=h.FLAG_CHILDREN),e){if(!(e._objFlags&l)){var i=e._children.indexOf(this);0,e._children.splice(i,1),e.emit&&e.emit("child-removed",this),this._onHierarchyChanged(e),0===e._children.length&&(e._renderFlag&=~h.FLAG_CHILDREN)}}else t&&this._onHierarchyChanged(null)}},attr:function(t){s.mixin(this,t)},getChildByUuid:function(t){if(!t)return cc.log("Invalid uuid"),null;for(var e=this._children,i=0,n=e.length;i0?(l=n,i=n._children,r=0,h[a]=i[r],a++):(h[a]=n,a++,s=!0);h.length=0,o._stackId--},cleanup:function(){},removeFromParent:function(t){this._parent&&(void 0===t&&(t=!0),this._parent.removeChild(this,t))},removeChild:function(t,e){this._children.indexOf(t)>-1&&((e||void 0===e)&&t.cleanup(),t.parent=null)},removeAllChildren:function(t){var e=this._children;void 0===t&&(t=!0);for(var i=e.length-1;i>=0;i--){var n=e[i];n&&(t&&n.cleanup(),n.parent=null)}this._children.length=0},isChildOf:function(t){var e=this;do{if(e===t)return!0;e=e._parent}while(e);return!1},getComponent:function(t){var e=f(t);return e?m(this,e):null},getComponents:function(t){var e=f(t),i=[];return e&&d(this,e,i),i},getComponentInChildren:function(t){var e=f(t);return e?(function t(e,i){for(var n=0;n0&&(s=t(r._children,i)))return s}return null})(this._children,e):null},getComponentsInChildren:function(t){var e=f(t),i=[];return e&&(d(this,e,i),(function t(e,i,n){for(var r=0;r0&&t(s._children,i,n)}})(this._children,e,i)),i},_checkMultipleComp:!1,addComponent:function(t){var e;if("string"==typeof t){if(!(e=s.getClassByName(t)))return cc.errorID(3807,t),cc._RFpeek()&&cc.errorID(3808,t),null}else{if(!t)return cc.errorID(3804),null;e=t}if("function"!=typeof e)return cc.errorID(3809),null;if(!s.isChildClassOf(e,cc.Component))return cc.errorID(3810),null;var i=e._requireComponent;if(i&&!this.getComponent(i)&&!this.addComponent(i))return null;var n=new e;return n.node=this,this._components.push(n),this._activeInHierarchy&&cc.director._nodeActivator.activateComp(n),n},_addComponentAt:!1,removeComponent:function(t){t?(t instanceof cc.Component||(t=this.getComponent(t)),t&&t.destroy()):cc.errorID(3813)},_getDependComponent:!1,_removeComponent:function(t){if(t){if(!(this._objFlags&l)){var e=this._components.indexOf(t);-1!==e?this._components.splice(e,1):t.node!==this&&cc.errorID(3815)}}else cc.errorID(3814)},_disableChildComps:function(){var t,e=this._components.length;for(t=0;t>>1;i<=r;s=i+r>>>1){var o=t[s];if(o>e+n)r=s-1;else{if(!(o>2],o[a[i++]]=r[(3&s)<<2|h>>4],o[a[i++]]=r[15&h]}return o.join("")}}),{"./misc":234}],230:[(function(t,e,i){cc.find=e.exports=function(t,e){if(null==t)return cc.errorID(5600),null;if(e)0;else{var i=cc.director.getScene();if(!i)return null;e=i}for(var n=e,r="/"!==t[0]?0:1,s=t.split("/"),o=r;o"]),this._specialSymbolArray.push([/&/g,"&"]),this._specialSymbolArray.push([/"/g,'"']),this._specialSymbolArray.push([/'/g,"'"])};s.prototype={constructor:s,parse:function(t){this._resultObjectArray=[],this._stack=[];for(var e=0,i=t.length;e",e);-1===r?r=n:"/"===t.charAt(n+1)?this._stack.pop():this._addToStack(t.substring(n+1,r)),e=r+1}}return this._resultObjectArray},_attributeToObject:function(t){var e,i,n,s,o={},a=(t=t.trim()).match(/^(color|size)(\s)*=/);if(a){if(e=a[0],""===(t=t.substring(e.length).trim()))return o;switch(i=t.indexOf(" "),e[0]){case"c":o.color=i>-1?t.substring(0,i).trim():t;break;case"s":o.size=parseInt(t)}return i>-1&&(s=t.substring(i+1).trim(),n=this._processEventHandler(s),o.event=n),o}if((a=t.match(/^(br(\s)*\/)/))&&a[0].length>0&&(e=a[0].trim()).startsWith("br")&&"/"===e[e.length-1])return o.isNewLine=!0,this._resultObjectArray.push({text:"",style:{newline:!0}}),o;if((a=t.match(/^(img(\s)*src(\s)*=[^>]+\/)/))&&a[0].length>0&&(e=a[0].trim()).startsWith("img")&&"/"===e[e.length-1]){var h;a=t.match(r);for(var l=!1;a;)e=(t=t.substring(t.indexOf(a[0]))).substr(0,a[0].length),u=(i=(h=t.substring(e.length).trim()).indexOf(" "))>-1?h.substr(0,i):h,e=(e=e.replace(/[^a-zA-Z]/g,"").trim()).toLocaleLowerCase(),t=h.substring(i).trim(),"src"===e?(o.isImage=!0,u.endsWith("/")&&(u=u.substring(0,u.length-1)),0===u.indexOf("'")?(l=!0,u=u.substring(1,u.length-1)):0===u.indexOf('"')&&(l=!0,u=u.substring(1,u.length-1)),o.src=u):"height"===e?o.imageHeight=parseInt(u):"width"===e?o.imageWidth=parseInt(u):"click"===e&&(o.event=this._processEventHandler(e+"="+u)),a=t.match(r);return l&&o.isImage&&this._resultObjectArray.push({text:"",style:o}),{}}if(a=t.match(/^(outline(\s)*[^>]*)/)){var c={color:"#ffffff",width:1};if(t=a[0].substring("outline".length).trim()){var u,_=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=/;for(a=t.match(_);a;)e=(t=t.substring(t.indexOf(a[0]))).substr(0,a[0].length),u=(i=(h=t.substring(e.length).trim()).indexOf(" "))>-1?h.substr(0,i):h,e=(e=e.replace(/[^a-zA-Z]/g,"").trim()).toLocaleLowerCase(),t=h.substring(i).trim(),"click"===e?o.event=this._processEventHandler(e+"="+u):"color"===e?c.color=u:"width"===e&&(c.width=parseInt(u)),a=t.match(_)}o.outline=c}if((a=t.match(/^(on|u|b|i)(\s)*/))&&a[0].length>0){switch(e=a[0],t=t.substring(e.length).trim(),e[0]){case"u":o.underline=!0;break;case"i":o.italic=!0;break;case"b":o.bold=!0}if(""===t)return o;n=this._processEventHandler(t),o.event=n}return o},_processEventHandler:function(t){for(var e=0,i={},r=t.match(n),s=!1;r;){var o=r[0],a="";if(s=!1,'"'===(t=t.substring(o.length).trim()).charAt(0))(e=t.indexOf('"',1))>-1&&(a=t.substring(1,e).trim(),s=!0),e++;else if("'"===t.charAt(0))(e=t.indexOf("'",1))>-1&&(a=t.substring(1,e).trim(),s=!0),e++;else{var h=t.match(/(\S)+/);e=(a=h?h[0]:"").length}s&&(i[o=o.substring(0,o.length-1).trim()]=a),r=(t=t.substring(e).trim()).match(n)}return i},_addToStack:function(t){var e=this._attributeToObject(t);if(0===this._stack.length)this._stack.push(e);else{if(e.isNewLine||e.isImage)return;var i=this._stack[this._stack.length-1];for(var n in i)e[n]||(e[n]=i[n]);this._stack.push(e)}},_processResult:function(t){""!==t&&(t=this._escapeSpecialSymbol(t),this._stack.length>0?this._resultObjectArray.push({text:t,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:t}))},_escapeSpecialSymbol:function(t){for(var e=0;e>1,t|=t>>2,t|=t>>4,t|=t>>8,(t|=t>>16)+1},BUILTIN_CLASSID_RE:/^(?:cc|dragonBones|sp|ccsg)\..+/},s=new Array(123),o=0;o<123;++o)s[o]=64;for(var a=0;a<64;++a)s["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(a)]=a;r.BASE64_VALUES=s,r.pushToMap=function(t,e,i,n){var r=t[e];r?Array.isArray(r)?n?(r.push(r[0]),r[0]=i):r.push(i):t[e]=n?[i,r]:[r,i]:t[e]=i},r.clampf=function(t,e,i){if(e>i){var n=e;e=i,i=n}return t=0&&this.removeAt(e)},r.removeAt=function(t){this.array.splice(t,1),t<=this.i&&--this.i},r.fastRemove=function(t){var e=this.array.indexOf(t);e>=0&&this.fastRemoveAt(e)},r.fastRemoveAt=function(t){var e=this.array;e[t]=e[e.length-1],--e.length,t<=this.i&&--this.i},r.push=function(t){this.array.push(t)},e.exports=n}),{}],236:[(function(t,e,i){var n=t("../CCNode"),r=n.EventType,s=n._LocalDirtyFlag,o=t("../renderer/render-engine").math,a=t("../renderer/render-flow"),h=Math.PI/180,l=1,c=2,u=4,_=null,f=null;function m(){if(this._localMatDirty){var t=this._matrix;if(o.mat4.fromRTS(t,this._quat,this._position,this._scale),this._skewX||this._skewY){var e=t.m00,i=t.m01,n=t.m04,r=t.m05,s=Math.tan(this._skewX*h),a=Math.tan(this._skewY*h);s===1/0&&(s=99999999),a===1/0&&(a=99999999),t.m00=e+n*a,t.m01=i+r*a,t.m04=n+e*s,t.m05=r+i*s}this._localMatDirty=0,this._worldMatDirty=!0}}function d(){if(this._localMatDirty&&this._updateLocalMatrix(),this._parent){var t=this._parent._worldMatrix;o.mat4.mul(this._worldMatrix,t,this._matrix)}else o.mat4.copy(this._worldMatrix,this._matrix);this._worldMatDirty=!1}function p(){return new cc.Vec3(this._position)}function y(t,e,i){var n=void 0;void 0===e?(n=t.x,e=t.y,i=t.z||0):(n=t,i=i||0);var o=this._position;o.x===n&&o.y===e&&o.z===i||(o.x=n,o.y=e,o.z=i,this.setLocalDirty(s.POSITION),this._renderFlag|=a.FLAG_WORLD_TRANSFORM,this._eventMask&l&&this.emit(r.POSITION_CHANGED))}function v(){return o.quat.clone(this._quat)}function g(t,e,i,n){var o=void 0;void 0===e&&(o=t.x,e=t.y,i=t.z,n=t.w);var h=this._quat;h.x===o&&h.y===e&&h.z===i&&h.w===n||(h.x=o,h.y=e,h.z=i,h.w=n,this.setLocalDirty(s.ROTATION),this._renderFlag|=a.FLAG_TRANSFORM,this._eventMask&u&&this.emit(r.ROTATION_CHANGED))}function x(){return cc.v3(this._scale)}function A(t,e,i){t&&"number"!=typeof t?(e=t.y,i=t.z||1,t=t.x):void 0!==t&&void 0===e?(e=t,i=t):void 0===i&&(i=1),this._scale.x===t&&this._scale.y===e&&this._scale.z===i||(this._scale.x=t,this._scale.y=e,this._scale.z=i,this.setLocalDirty(s.SCALE),this._renderFlag|=a.FLAG_TRANSFORM,this._eventMask&c&&this.emit(r.SCALE_CHANGED))}cc._polyfill3D=e.exports={enabled:!1,enable:function(){var t=cc.Node.prototype;_||(_=t._updateLocalMatrix,f=t._calculWorldMatrix),this.enabled||(t._updateLocalMatrix=m,t._calculWorldMatrix=d,t.getPosition=p,t.setPosition=y,t.getScale=x,t.setScale=A,t.getQuat=v,t.setQuat=g,this.enabled=!0)},disable:function(){this.enabled&&(cc.Node.prototype._updateLocalMatrix=_,cc.Node.prototype._calculWorldMatrix=f,this.enabled=!1)}}}),{"../CCNode":28,"../renderer/render-engine":198,"../renderer/render-flow":199}],237:[(function(t,e,i){var n=t("../renderer").renderEngine.math;cc._PrefabInfo=cc.Class({name:"cc.PrefabInfo",properties:{root:null,asset:null,fileId:"",sync:!1,_synced:{default:!1,serializable:!1}}}),e.exports={syncWithPrefab:function(t){var e=t._prefab;if(e._synced=!0,!e.asset)return cc.errorID(3701,t.name),void(t._prefab=null);var i=t._objFlags,r=t._parent,s=t._id,o=t._name,a=t._active,h=t._position.x,l=t._position.y,c=t._quat,u=t._localZOrder,_=t._globalZOrder;cc.game._isCloning=!0,e.asset._doInstantiate(t),cc.game._isCloning=!1,t._objFlags=i,t._parent=r,t._id=s,t._prefab=e,t._name=o,t._active=a,t._position.x=h,t._position.y=l,n.quat.copy(t._quat,c),t._localZOrder=u,t._globalZOrder=_}}}),{"../renderer":197}],238:[(function(t,e,i){var n=t("../../platform/CCMacro"),r=t("./perf-counter"),s=!1,o=15,a=null,h=null,l=null,c=null;function u(){(function(){if(!l||!l.isValid){(l=new cc.Node("PROFILER-NODE")).x=l.y=10,l.groupIndex=cc.Node.BuiltinGroupIndex.DEBUG,cc.Camera._setupDebugCamera(),l.zIndex=n.MAX_ZINDEX,cc.game.addPersistRootNode(l);var t=new cc.Node("LEFT-PANEL");t.anchorX=t.anchorY=0,t.parent=l;var e=t.addComponent(cc.Label);e.font=a,e.fontSize=o,e.lineHeight=o;var i=new cc.Node("RIGHT-PANEL");i.anchorX=1,i.anchorY=0,i.x=200,i.parent=l;var r=i.addComponent(cc.Label);r.horizontalAlign=cc.Label.HorizontalAlign.RIGHT,r.font=a,r.fontSize=o,r.lineHeight=o,c={left:e,right:r}}})();var t=cc.director._lastUpdate;h.frame._counter.start(t),h.logic._counter.start(t)}function _(){var t=performance.now();cc.director.isPaused()?h.frame._counter.start(t):h.logic._counter.end(t),h.render._counter.start(t)}function f(){var t=performance.now();h.render._counter.end(t),h.draws._counter.value=cc.renderer.drawCalls,h.frame._counter.end(t),h.fps._counter.frame(t);var e="",i="";for(var n in h){var r=h[n];r._counter.sample(t),e+=r.desc+"\n",i+=r._counter.human()+"\n"}c.left.string=e,c.right.string=i}cc.profiler=e.exports={isShowingStats:function(){return s},hideStats:function(){s&&(l&&(l.active=!1),cc.director.off(cc.Director.EVENT_BEFORE_UPDATE,u),cc.director.off(cc.Director.EVENT_AFTER_UPDATE,_),cc.director.off(cc.Director.EVENT_AFTER_DRAW,f),s=!1)},showStats:function(){s||(function(){if(!a){var t=document.createElement("canvas");t.style.width=t.width=256,t.style.height=t.height=256;var e=t.getContext("2d");e.font=o+"px Arial",e.textBaseline="top",e.textAlign="left",e.fillStyle="#fff";var i=2,n=2,r=o;(a=new cc.LabelAtlas)._fntConfig={atlasName:"profiler-arial",commonHeight:r,fontSize:o,kerningDict:{},fontDefDictionary:{}},a._name="profiler-arial",a.fontSize=o;for(var s=a._fntConfig.fontDefDictionary,h=32;h<=126;h++){var l=String.fromCharCode(h),c=e.measureText(l).width;i+c>=256&&(i=2,n+=r+2),e.fillText(l,i,n),s[h]={xAdvance:c,xOffset:0,yOffset:0,rect:{x:i,y:n,width:c,height:r}},i+=c+2}var u=new cc.Texture2D;u.initWithElement(t);var _=new cc.SpriteFrame;_.setTexture(u),a.spriteFrame=_}}(),(function(){if(!h){h={frame:{desc:"Frame time (ms)",min:0,max:50,average:500},fps:{desc:"Framerate (FPS)",below:30,average:500},draws:{desc:"Draw call"},logic:{desc:"Game Logic (ms)",min:0,max:50,average:500,color:"#080"},render:{desc:"Renderer (ms)",min:0,max:50,average:500,color:"#f90"},mode:{desc:cc.game.renderType===cc.game.RENDER_TYPE_WEBGL?"WebGL":"Canvas",min:1}};var t=performance.now();for(var e in h)h[e]._counter=new r(e,h[e],t)}})(),l&&(l.active=!0),cc.director.on(cc.Director.EVENT_BEFORE_UPDATE,u),cc.director.on(cc.Director.EVENT_AFTER_UPDATE,_),cc.director.on(cc.Director.EVENT_AFTER_DRAW,f),s=!0)}}}),{"../../platform/CCMacro":161,"./perf-counter":240}],239:[(function(t,e,i){var n=cc.Class({name:"cc.Counter",ctor:function(t,e,i){this._id=t,this._opts=e||{},this._value=0,this._total=0,this._averageValue=0,this._accumValue=0,this._accumSamples=0,this._accumStart=i},properties:{value:{get:function(){return this._value},set:function(t){this._value=t}}},_average:function(t,e){if(this._opts.average){this._accumValue+=t,++this._accumSamples;var i=e;i-this._accumStart>=this._opts.average&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=i,this._accumSamples=0)}},sample:function(t){this._average(this._value,t)},human:function(){var t=this._opts.average?this._averageValue:this._value;return Math.round(100*t)/100},alarm:function(){return this._opts.below&&this._valuethis._opts.over}});e.exports=n}),{}],240:[(function(t,e,i){var n=t("./counter"),r=cc.Class({name:"cc.PerfCounter",extends:n,ctor:function(t,e,i){this._time=i},start:function(t){this._time=t},end:function(t){this._value=t-this._time,this._average(this._value)},tick:function(){this.end(),this.start()},frame:function(t){var e=t,i=e-this._time;this._total++,i>(this._opts.average||1e3)&&(this._value=1e3*this._total/i,this._total=0,this._time=e,this._average(this._value))}});e.exports=r}),{"./counter":239}],241:[(function(t,e,i){e.exports={label_wordRex:/([a-zA-Z0-9\xc4\xd6\xdc\xe4\xf6\xfc\xdf\xe9\xe8\xe7\xe0\xf9\xea\xe2\xee\xf4\xfb\u0430-\u044f\u0410-\u042f\u0401\u0451]+|\S)/,label_symbolRex:/^[!,.:;'}\]%\?>\u3001\u2018\u201c\u300b\uff1f\u3002\uff0c\uff01]/,label_lastWordRex:/([a-zA-Z0-9\xc4\xd6\xdc\xe4\xf6\xfc\xdf\xe9\xe8\xe7\xe0\xf9\xea\xe2\xee\xf4\xfb\u0430\xed\xec\xcd\xcc\xef\xc1\xc0\xe1\xe0\xc9\xc8\xd2\xd3\xf2\xf3\u0150\u0151\xd9\xda\u0170\xfa\u0171\xf1\xd1\xe6\xc6\u0153\u0152\xc3\xc2\xe3\xd4\xf5\u011b\u0161\u010d\u0159\u017e\xfd\xe1\xed\xe9\xf3\xfa\u016f\u0165\u010f\u0148\u011a\u0160\u010c\u0158\u017d\xc1\xcd\xc9\xd3\xda\u0164\u017c\u017a\u015b\xf3\u0144\u0142\u0119\u0107\u0105\u017b\u0179\u015a\xd3\u0143\u0141\u0118\u0106\u0104-\u044f\u0410-\u042f\u0401\u0451]+|\S)$/,label_lastEnglish:/[a-zA-Z0-9\xc4\xd6\xdc\xe4\xf6\xfc\xdf\xe9\xe8\xe7\xe0\xf9\xea\xe2\xee\xf4\xfb\u0430\xed\xec\xcd\xcc\xef\xc1\xc0\xe1\xe0\xc9\xc8\xd2\xd3\xf2\xf3\u0150\u0151\xd9\xda\u0170\xfa\u0171\xf1\xd1\xe6\xc6\u0153\u0152\xc3\xc2\xe3\xd4\xf5\u011b\u0161\u010d\u0159\u017e\xfd\xe1\xed\xe9\xf3\xfa\u016f\u0165\u010f\u0148\u011a\u0160\u010c\u0158\u017d\xc1\xcd\xc9\xd3\xda\u0164\u017c\u017a\u015b\xf3\u0144\u0142\u0119\u0107\u0105\u017b\u0179\u015a\xd3\u0143\u0141\u0118\u0106\u0104-\u044f\u0410-\u042f\u0401\u0451]+$/,label_firstEnglish:/^[a-zA-Z0-9\xc4\xd6\xdc\xe4\xf6\xfc\xdf\xe9\xe8\xe7\xe0\xf9\xea\xe2\xee\xf4\xfb\u0430\xed\xec\xcd\xcc\xef\xc1\xc0\xe1\xe0\xc9\xc8\xd2\xd3\xf2\xf3\u0150\u0151\xd9\xda\u0170\xfa\u0171\xf1\xd1\xe6\xc6\u0153\u0152\xc3\xc2\xe3\xd4\xf5\u011b\u0161\u010d\u0159\u017e\xfd\xe1\xed\xe9\xf3\xfa\u016f\u0165\u010f\u0148\u011a\u0160\u010c\u0158\u017d\xc1\xcd\xc9\xd3\xda\u0164\u017c\u017a\u015b\xf3\u0144\u0142\u0119\u0107\u0105\u017b\u0179\u015a\xd3\u0143\u0141\u0118\u0106\u0104-\u044f\u0410-\u042f\u0401\u0451]/,label_wrapinspection:!0,isUnicodeCJK:function(t){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(t)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(t)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(t)},isUnicodeSpace:function(t){return(t=t.charCodeAt(0))>=9&&t<=13||32===t||133===t||160===t||5760===t||t>=8192&&t<=8202||8232===t||8233===t||8239===t||8287===t||12288===t},safeMeasureText:function(t,e){var i=t.measureText(e);return i&&i.width||0},fragmentText:function(t,e,i,n){var r=[];if(0===t.length||i<0)return r.push(""),r;for(var s=t;e>i&&s.length>1;){for(var o=s.length*(i/e)|0,a=s.substr(o),h=e-n(a),l=a,c=0,u=0;h>i&&u++<10;)o*=i/h,o|=0,h=e-n(a=s.substr(o));for(u=0;h<=i&&u++<10;){if(a){var _=this.label_wordRex.exec(a);c=_?_[0].length:1,l=a}o+=c,h=e-n(a=s.substr(o))}0==(o-=c)&&(o=1,l=l.substr(1));var f,m=s.substr(0,o);this.label_wrapinspection&&this.label_symbolRex.test(l||a)&&(0==(o-=(f=this.label_lastWordRex.exec(m))?f[0].length:0)&&(o=1),l=s.substr(o),m=s.substr(0,o)),this.label_firstEnglish.test(l)&&(f=this.label_lastEnglish.exec(m))&&m!==f[0]&&(o-=f[0].length,l=s.substr(o),m=s.substr(0,o)),0===r.length?r.push(m):(m=m.trim()).length>0&&r.push(m),e=n(s=l||a)}return 0===r.length?r.push(s):(s=s.trim()).length>0&&r.push(s),r}}}),{}],242:[(function(t,e,i){var n=t("../assets/CCTexture2D"),r={loadImage:function(t,e,i){cc.assertID(t,3103);var r=cc.loader.getRes(t);return r?r.loaded?(e&&e.call(i,r),r):(r.once("load",(function(){e&&e.call(i,r)}),i),r):((r=new n).url=t,cc.loader.load({url:t,texture:r},(function(t,n){if(t)return e&&e.call(i,t||new Error("Unknown error"));n.handleLoadedTexture(),e&&e.call(i,null,n)})),r)},cacheImage:function(t,e){if(t&&e){var i=new n;i.initWithElement(e);var r={id:t,url:t,error:null,content:i,complete:!1};return cc.loader.flowOut(r),i}},postLoadTexture:function(t,e){t.loaded?e&&e():t.url?cc.loader.load({url:t.url,skips:["Loader"]},(function(i,n){n&&(t.loaded||(t._nativeAsset=n)),e&&e(i)})):e&&e()}};cc.textureUtil=e.exports=r}),{"../assets/CCTexture2D":47}],243:[(function(t,e,i){var n=t("./value-type"),r=t("../platform/js"),s=(function(){function e(t,e,i,n){"object"==typeof t&&(e=t.g,i=t.b,n=t.a,t=t.r),t=t||0,e=e||0,i=i||0,n="number"==typeof n?n:255,this._val=(n<<24>>>0)+(i<<16)+(e<<8)+t}r.extend(e,n),t("../platform/CCClass").fastDefine("cc.Color",e,{r:0,g:0,b:0,a:255});var i={WHITE:[255,255,255,255],BLACK:[0,0,0,255],TRANSPARENT:[0,0,0,0],GRAY:[127.5,127.5,127.5],RED:[255,0,0],GREEN:[0,255,0],BLUE:[0,0,255],YELLOW:[255,235,4],ORANGE:[255,127,0],CYAN:[0,255,255],MAGENTA:[255,0,255]};for(var s in i)r.get(e,s,(function(t){return function(){return new e(t[0],t[1],t[2],t[3])}})(i[s]));var o=e.prototype;return o.clone=function(){var t=new e;return t._val=this._val,t},o.equals=function(t){return t&&this._val===t._val},o.lerp=function(t,i,n){n=n||new e;var r=this.r,s=this.g,o=this.b,a=this.a;return n.r=r+(t.r-r)*i,n.g=s+(t.g-s)*i,n.b=o+(t.b-o)*i,n.a=a+(t.a-a)*i,n},o.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},o.getR=function(){return 255&this._val},o.setR=function(t){return t=~~cc.misc.clampf(t,0,255),this._val=(4294967040&this._val|t)>>>0,this},o.getG=function(){return(65280&this._val)>>8},o.setG=function(t){return t=~~cc.misc.clampf(t,0,255),this._val=(4294902015&this._val|t<<8)>>>0,this},o.getB=function(){return(16711680&this._val)>>16},o.setB=function(t){return t=~~cc.misc.clampf(t,0,255),this._val=(4278255615&this._val|t<<16)>>>0,this},o.getA=function(){return(4278190080&this._val)>>>24},o.setA=function(t){return t=~~cc.misc.clampf(t,0,255),this._val=(16777215&this._val|t<<24>>>0)>>>0,this},r.getset(o,"r",o.getR,o.setR,!0),r.getset(o,"g",o.getG,o.setG,!0),r.getset(o,"b",o.getB,o.setB,!0),r.getset(o,"a",o.getA,o.setA,!0),o.toCSS=function(t){return"rgba"===t?"rgba("+(0|this.r)+","+(0|this.g)+","+(0|this.b)+","+(this.a/255).toFixed(2)+")":"rgb"===t?"rgb("+(0|this.r)+","+(0|this.g)+","+(0|this.b)+")":"#"+this.toHEX(t)},o.fromHEX=function(t){t=0===t.indexOf("#")?t.substring(1):t;var e=parseInt(t.substr(0,2),16)||0,i=parseInt(t.substr(2,2),16)||0,n=parseInt(t.substr(4,2),16)||0,r=parseInt(t.substr(6,2),16)||255;return this._val=(r<<24>>>0)+(n<<16)+(i<<8)+e,this},o.toHEX=function(t){var e=[(0|this.r).toString(16),(0|this.g).toString(16),(0|this.b).toString(16)],i=-1;if("#rgb"===t)for(i=0;i1&&(e[i]=e[i][0]);else if("#rrggbb"===t)for(i=0;i>>0)+(s<<16)+(r<<8)+n,this},o.toHSV=function(){var t=this.r/255,e=this.g/255,i=this.b/255,n={h:0,s:0,v:0},r=Math.max(t,e,i),s=Math.min(t,e,i),o=0;return n.v=r,n.s=r?(r-s)/r:0,n.s?(o=r-s,n.h=t===r?(e-i)/o:e===r?2+(i-t)/o:4+(t-e)/o,n.h/=6,n.h<0&&(n.h+=1)):n.h=0,n},o.set=function(t){t._val?this._val=t._val:(this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a)},e})();cc.Color=s,cc.color=function(t,e,i,n){return"string"==typeof t?(new cc.Color).fromHEX(t):"object"==typeof t?new cc.Color(t.r,t.g,t.b,t.a):new cc.Color(t,e,i,n)},e.exports=cc.Color}),{"../platform/CCClass":156,"../platform/js":176,"./value-type":249}],244:[(function(t,e,i){t("./value-type"),t("./vec2"),t("./vec3"),t("./quat"),t("./mat4"),t("./size"),t("./rect"),t("./color"),cc.vmath=t("../renderer/render-engine").math}),{"../renderer/render-engine":198,"./color":243,"./mat4":245,"./quat":246,"./rect":247,"./size":248,"./value-type":249,"./vec2":250,"./vec3":251}],245:[(function(t,e,i){var n=t("./value-type"),r=t("../platform/js"),s=t("../platform/CCClass"),o=t("../renderer/render-engine").math.mat4;function a(t,e,i,n,r,s,o,a,h,l,c,u,_,f,m,d){var p=this;p.m00=t,p.m01=e,p.m02=i,p.m03=n,p.m04=r,p.m05=s,p.m06=o,p.m07=a,p.m08=h,p.m09=l,p.m10=c,p.m11=u,p.m12=_,p.m13=f,p.m14=m,p.m15=d}r.extend(a,n),s.fastDefine("cc.Mat4",a,{m00:1,m01:0,m02:0,m03:0,m04:0,m05:1,m06:0,m07:0,m08:0,m09:0,m10:1,m11:0,m12:0,m13:0,m14:0,m15:1}),r.mixin(a.prototype,{clone:function(){var t=this;return new a(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05,t.m06,t.m07,t.m08,t.m09,t.m10,t.m11,t.m12,t.m13,t.m14,t.m15)},set:function(t){var e=this;return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e.m09=t.m09,e.m10=t.m10,e.m11=t.m11,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15,this},equals:function(t){return o.exactEquals(this,t)},fuzzyEquals:function(t){return o.equals(this,t)},toString:function(){var t=this;return"[\n"+t.m00+", "+t.m01+", "+t.m02+", "+t.m03+",\n"+t.m04+", "+t.m05+", "+t.m06+", "+t.m07+",\n"+t.m08+", "+t.m09+", "+t.m10+", "+t.m11+",\n"+t.m12+", "+t.m13+", "+t.m14+", "+t.m15+"\n]"},identity:function(){return o.identity(this)},transpose:function(t){return t=t||new cc.Mat4,o.transpose(t,this)},invert:function(t){return t=t||new cc.Mat4,o.invert(t,this)},adjoint:function(t){return t=t||new cc.Mat4,o.adjoint(t,this)},determinant:function(){return o.determinant(this)},add:function(t,e){return e=e||new cc.Mat4,o.add(e,this,t)},sub:function(t,e){return e=e||new cc.Mat4,o.subtract(e,this,t)},mul:function(t,e){return e=e||new cc.Mat4,o.multiply(e,this,t)},mulScalar:function(t,e){return e=e||new cc.Mat4,o.mulScalar(e,this,t)},translate:function(t,e){return e=e||new cc.Mat4,o.translate(e,this,t)},scale:function(t,e){return e=e||new cc.Mat4,o.scale(e,this,t)},rotate:function(t,e,i){return i=i||new cc.Mat4,o.rotate(i,this,t,e)},getTranslation:function(t){return t=t||new cc.Vec3,o.getTranslation(t,this)},getScale:function(t){return t=t||new cc.Vec3,o.getScaling(t,this)},getRotation:function(t){return t=t||new cc.Quat,o.getRotation(t,this)},fromRTS:function(t,e,i){return o.fromRTS(this,t,e,i)},fromQuat:function(t){return o.fromQuat(this,t)}}),cc.mat4=function(t,e,i,n,r,s,o,h,l,c,u,_,f,m,d,p){return new a(t,e,i,n,r,s,o,h,l,c,u,_,f,m,d,p)}}),{"../platform/CCClass":156,"../platform/js":176,"../renderer/render-engine":198,"./value-type":249}],246:[(function(t,e,i){var n=t("./value-type"),r=t("../platform/js"),s=t("../platform/CCClass");function o(t,e,i,n){t&&"object"==typeof t&&(i=t.z,e=t.y,n=(t=t.x).w),this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||1}r.extend(o,n),s.fastDefine("cc.Quat",o,{x:0,y:0,z:0,w:1});var a=o.prototype;a.clone=function(){return new o(this.x,this.y,this.z,this.w)},a.set=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},a.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},a.getRoll=function(){var t=2*(this.w*this.x+this.y*this.z),e=1-2*(this.x*this.x+this.y*this.y);return 180*Math.atan2(t,e)/Math.PI},a.getPitch=function(){var t=2*(this.w*this.y-this.z*this.x),e=t>1?1:t;return e=t<-1?-1:t,e=180*Math.asin(e)/Math.PI},a.getYaw=function(){var t=2*(this.w*this.z+this.x*this.y),e=1-2*(this.y*this.y+this.z*this.z);return 180*Math.atan2(t,e)/Math.PI},cc.quat=function(t,e,i,n){return new o(t,e,i,n)},e.exports=cc.Quat=o}),{"../platform/CCClass":156,"../platform/js":176,"./value-type":249}],247:[(function(t,e,i){var n=t("./value-type"),r=t("../platform/js");function s(t,e,i,n){t&&"object"==typeof t&&(e=t.y,i=t.width,n=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=i||0,this.height=n||0}r.extend(s,n),t("../platform/CCClass").fastDefine("cc.Rect",s,{x:0,y:0,width:0,height:0}),s.fromMinMax=function(t,e){var i=Math.min(t.x,e.x),n=Math.min(t.y,e.y);return new s(i,n,Math.max(t.x,e.x)-i,Math.max(t.y,e.y)-n)};var o=s.prototype;o.clone=function(){return new s(this.x,this.y,this.width,this.height)},o.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},o.lerp=function(t,e,i){i=i||new s;var n=this.x,r=this.y,o=this.width,a=this.height;return i.x=n+(t.x-n)*e,i.y=r+(t.y-r)*e,i.width=o+(t.width-o)*e,i.height=a+(t.height-a)*e,i},o.set=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},o.intersects=function(t){var e=this.x+this.width,i=this.y+this.height,n=t.x+t.width,r=t.y+t.height;return!(e=t.x&&this.y<=t.y&&this.y+this.height>=t.y},o.containsRect=function(t){return this.x<=t.x&&this.x+this.width>=t.x+t.width&&this.y<=t.y&&this.y+this.height>=t.y+t.height},o.union=function(t,e){var i=this.x,n=this.y,r=this.width,s=this.height,o=e.x,a=e.y,h=e.width,l=e.height;return t.x=Math.min(i,o),t.y=Math.min(n,a),t.width=Math.max(i+r,o+h)-t.x,t.height=Math.max(n+s,a+l)-t.y,t},o.transformMat4=function(t,e){var i=this.x,n=this.y,r=i+this.width,s=n+this.height,o=e.m00*i+e.m04*n+e.m12,a=e.m01*i+e.m05*n+e.m13,h=e.m00*r+e.m04*n+e.m12,l=e.m01*r+e.m05*n+e.m13,c=e.m00*i+e.m04*s+e.m12,u=e.m01*i+e.m05*s+e.m13,_=e.m00*r+e.m04*s+e.m12,f=e.m01*r+e.m05*s+e.m13,m=Math.min(o,h,c,_),d=Math.max(o,h,c,_),p=Math.min(a,l,u,f),y=Math.max(a,l,u,f);return t.x=m,t.y=p,t.width=d-m,t.height=y-p,t},o.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},r.getset(o,"xMin",(function(){return this.x}),(function(t){this.width+=this.x-t,this.x=t})),r.getset(o,"yMin",(function(){return this.y}),(function(t){this.height+=this.y-t,this.y=t})),r.getset(o,"xMax",(function(){return this.x+this.width}),(function(t){this.width=t-this.x})),r.getset(o,"yMax",(function(){return this.y+this.height}),(function(t){this.height=t-this.y})),r.getset(o,"center",(function(){return new cc.Vec2(this.x+.5*this.width,this.y+.5*this.height)}),(function(t){this.x=t.x-.5*this.width,this.y=t.y-.5*this.height})),r.getset(o,"origin",(function(){return new cc.Vec2(this.x,this.y)}),(function(t){this.x=t.x,this.y=t.y})),r.getset(o,"size",(function(){return new cc.Size(this.width,this.height)}),(function(t){this.width=t.width,this.height=t.height})),cc.Rect=s,cc.rect=function(t,e,i,n){return new s(t,e,i,n)},e.exports=cc.Rect}),{"../platform/CCClass":156,"../platform/js":176,"./value-type":249}],248:[(function(t,e,i){var n=t("./value-type"),r=t("../platform/js");function s(t,e){t&&"object"==typeof t&&(e=t.height,t=t.width),this.width=t||0,this.height=e||0}r.extend(s,n),t("../platform/CCClass").fastDefine("cc.Size",s,{width:0,height:0}),r.get(s,"ZERO",(function(){return new s(0,0)}));var o=s.prototype;o.clone=function(){return new s(this.width,this.height)},o.equals=function(t){return t&&this.width===t.width&&this.height===t.height},o.lerp=function(t,e,i){i=i||new s;var n=this.width,r=this.height;return i.width=n+(t.width-n)*e,i.height=r+(t.height-r)*e,i},o.set=function(t){this.width=t.width,this.height=t.height},o.toString=function(){return"("+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},cc.size=function(t,e){return new s(t,e)},cc.Size=e.exports=s}),{"../platform/CCClass":156,"../platform/js":176,"./value-type":249}],249:[(function(t,e,i){var n=t("../platform/js");function r(){}n.setClassName("cc.ValueType",r);var s=r.prototype;s.toString=function(){return""+{}},cc.ValueType=e.exports=r}),{"../platform/js":176}],250:[(function(t,e,i){var n=t("./value-type"),r=t("../platform/js"),s=t("../platform/CCClass"),o=t("../renderer/render-engine").math,a=t("../utils/misc");function h(t,e){t&&"object"==typeof t&&(e=t.y,t=t.x),this.x=t||0,this.y=e||0}r.extend(h,n),s.fastDefine("cc.Vec2",h,{x:0,y:0});var l=h.prototype;l.clone=function(){return new h(this.x,this.y)},l.set=function(t){return this.x=t.x,this.y=t.y,this},l.equals=function(t){return t&&this.x===t.x&&this.y===t.y},l.fuzzyEquals=function(t,e){return this.x-e<=t.x&&t.x<=this.x+e&&this.y-e<=t.y&&t.y<=this.y+e},l.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+")"},l.lerp=function(t,e,i){i=i||new h;var n=this.x,r=this.y;return i.x=n+(t.x-n)*e,i.y=r+(t.y-r)*e,i},l.clampf=function(t,e){return this.x=a.clampf(this.x,t.x,e.x),this.y=a.clampf(this.y,t.y,e.y),this},l.addSelf=function(t){return this.x+=t.x,this.y+=t.y,this},l.add=function(t,e){return(e=e||new h).x=this.x+t.x,e.y=this.y+t.y,e},l.subSelf=function(t){return this.x-=t.x,this.y-=t.y,this},l.sub=function(t,e){return(e=e||new h).x=this.x-t.x,e.y=this.y-t.y,e},l.mulSelf=function(t){return this.x*=t,this.y*=t,this},l.mul=function(t,e){return(e=e||new h).x=this.x*t,e.y=this.y*t,e},l.scaleSelf=function(t){return this.x*=t.x,this.y*=t.y,this},l.scale=function(t,e){return(e=e||new h).x=this.x*t.x,e.y=this.y*t.y,e},l.divSelf=function(t){return this.x/=t,this.y/=t,this},l.div=function(t,e){return(e=e||new h).x=this.x/t,e.y=this.y/t,e},l.negSelf=function(){return this.x=-this.x,this.y=-this.y,this},l.neg=function(t){return(t=t||new h).x=-this.x,t.y=-this.y,t},l.dot=function(t){return this.x*t.x+this.y*t.y},l.cross=function(t){return this.x*t.y-this.y*t.x},l.mag=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},l.magSqr=function(){return this.x*this.x+this.y*this.y},l.normalizeSelf=function(){var t=this.x*this.x+this.y*this.y;if(1===t)return this;if(0===t)return this;var e=1/Math.sqrt(t);return this.x*=e,this.y*=e,this},l.normalize=function(t){return(t=t||new h).x=this.x,t.y=this.y,t.normalizeSelf(),t},l.angle=function(t){var e=this.magSqr(),i=t.magSqr();if(0===e||0===i)return console.warn("Can't get angle between zero vector"),0;var n=this.dot(t)/Math.sqrt(e*i);return n=a.clampf(n,-1,1),Math.acos(n)},l.signAngle=function(t){var e=this.angle(t);return this.cross(t)<0?-e:e},l.rotate=function(t,e){return(e=e||new h).x=this.x,e.y=this.y,e.rotateSelf(t)},l.rotateSelf=function(t){var e=Math.sin(t),i=Math.cos(t),n=this.x;return this.x=i*n-e*this.y,this.y=e*n+i*this.y,this},l.project=function(t){return t.mul(this.dot(t)/t.dot(t))},l.transformMat4=function(t,e){e=e||new h,o.vec2.transformMat4(e,this,t)},r.get(h,"ONE",(function(){return new h(1,1)})),r.get(h,"ZERO",(function(){return new h(0,0)})),r.get(h,"UP",(function(){return new h(0,1)})),r.get(h,"RIGHT",(function(){return new h(1,0)})),cc.Vec2=h,cc.v2=function(t,e){return new h(t,e)},cc.p=cc.v2,e.exports=cc.Vec2}),{"../platform/CCClass":156,"../platform/js":176,"../renderer/render-engine":198,"../utils/misc":234,"./value-type":249}],251:[(function(t,e,i){var n=t("./value-type"),r=t("../platform/js"),s=t("../platform/CCClass"),o=t("../renderer/render-engine").math,a=t("../utils/misc");function h(t,e,i){t&&"object"==typeof t&&(i=t.z,e=t.y,t=t.x),this.x=t||0,this.y=e||0,this.z=i||0}r.extend(h,n),s.fastDefine("cc.Vec3",h,{x:0,y:0,z:0});var l=h.prototype;l.clone=function(){return new h(this.x,this.y,this.z)},l.set=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},l.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z},l.fuzzyEquals=function(t,e){return this.x-e<=t.x&&t.x<=this.x+e&&this.y-e<=t.y&&t.y<=this.y+e&&this.z-e<=t.z&&t.z<=this.z+e},l.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+")"},l.lerp=function(t,e,i){return i=i||new h,o.vec3.lerp(i,this,t,e),i},l.clampf=function(t,e){return this.x=a.clampf(this.x,t.x,e.x),this.y=a.clampf(this.y,t.y,e.y),this.z=a.clampf(this.z,t.z,e.z),this},l.addSelf=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},l.add=function(t,e){return(e=e||new h).x=this.x+t.x,e.y=this.y+t.y,e.z=this.z+t.z,e},l.subSelf=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},l.sub=function(t,e){return(e=e||new h).x=this.x-t.x,e.y=this.y-t.y,e.z=this.z-t.z,e},l.mulSelf=function(t){return this.x*=t,this.y*=t,this.z*=t,this},l.mul=function(t,e){return(e=e||new h).x=this.x*t,e.y=this.y*t,e.z=this.z*t,e},l.scaleSelf=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},l.scale=function(t,e){return(e=e||new h).x=this.x*t.x,e.y=this.y*t.y,e.z=this.z*t.z,e},l.divSelf=function(t){return this.x/=t,this.y/=t,this.z/=t,this},l.div=function(t,e){return(e=e||new h).x=this.x/t,e.y=this.y/t,e.z=this.z/t,e},l.negSelf=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},l.neg=function(t){return(t=t||new h).x=-this.x,t.y=-this.y,t.z=-this.z,t},l.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},l.cross=function(t,e){return e=e||new h,o.vec3.cross(e,this,t),e},l.mag=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},l.magSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z},l.normalizeSelf=function(){return o.vec3.normalize(this,this),this},l.normalize=function(t){return t=t||new h,o.vec3.normalize(t,this),t},l.transformMat4=function(t,e){e=e||new h,o.vec3.transformMat4(e,this,t)},cc.v3=function(t,e,i){return new h(t,e,i)},e.exports=cc.Vec3=h}),{"../platform/CCClass":156,"../platform/js":176,"../renderer/render-engine":198,"../utils/misc":234,"./value-type":249}],252:[(function(t,e,i){cc.js}),{}],253:[(function(t,e,i){t("./core/CCGame"),t("./actions")}),{"./actions":7,"./core/CCGame":27}],254:[(function(t,e,i){var n=t("../compression/zlib.min"),r=t("../core/CCDebug"),s=function(t){var e,i,n,s,o,a,h,l,c,u,_,f,m;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},o=null;;){switch(e=this.readUInt32(),l=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join("")){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":o&&this.animation.frames.push(o),this.pos+=4,o={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),n=this.readUInt16()||100,o.delay=1e3*s/n,o.disposeOp=this.data[this.pos++],o.blendOp=this.data[this.pos++],o.data=[];break;case"IDAT":case"fdAT":for("fdAT"===l&&(this.pos+=4,e-=4),t=(null!=o?o.data:void 0)||this.imgData,_=0;0<=e?_e;0<=e?++_:--_)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(f=0;0<=c?fc;0<=c?++f:--f)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":a=(u=this.read(e)).indexOf(0),h=String.fromCharCode.apply(String,u.slice(0,a)),this.text[h]=String.fromCharCode.apply(String,u.slice(a+1));break;case"IEND":return o&&this.animation.frames.push(o),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(m=this.colorType)||6===m,i=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*i,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(Uint8Array!=Array&&(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error(r.getError(6017))}};s.prototype={constructor:s,read:function(t){var e,i;for(i=[],e=0;0<=t?et;0<=t?++e:--e)i.push(this.data[this.pos++]);return i},readUInt32:function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},readUInt16:function(){return this.data[this.pos++]<<8|this.data[this.pos++]},decodePixels:function(t){var e,i,s,o,a,h,l,c,u,_,f,m,d,p,y,v,g,x,A,b,C,S,T;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=new n.Inflate(t,{index:0,verify:!1}).decompress(),v=(m=this.pixelBitlength/8)*this.width,d=new Uint8Array(v*this.height),h=t.length,y=0,p=0,i=0;p=this.totalParticles},setTextureWithRect:function(t,e){t instanceof cc.Texture2D&&(this.spriteFrame=new cc.SpriteFrame(t,e))},_applyFile:function(){var t=this._file;if(t){var e=this;cc.loader.load(t.nativeUrl,(function(i,n){!i&&n?e.isValid&&(e._plistFile=t.nativeUrl,e._custom||e._initWithDictionary(n),e.spriteFrame||(t.texture?e.spriteFrame=new cc.SpriteFrame(t.texture):e._custom&&e._initTextureWithDictionary(n))):cc.errorID(6029)}))}},_initTextureWithDictionary:function(t){var e=cc.path.changeBasename(this._plistFile,t.textureFileName||"");if(t.textureFileName)l.loadImage(e,(function(e,i){e?(t.textureFileName=void 0,this._initTextureWithDictionary(t)):this.spriteFrame=new cc.SpriteFrame(i)}),this);else if(t.textureImageData){var i=t.textureImageData;if(!(i&&i.length>0))return!1;var r=o.unzipBase64AsArray(i,1);if(!r)return cc.logID(6030),!1;var s=(function(t){return t.length>8&&137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]&&13===t[4]&&10===t[5]&&26===t[6]&&10===t[7]?n.ImageFormat.PNG:t.length>2&&(73===t[0]&&73===t[1]||77===t[0]&&77===t[1]||255===t[0]&&216===t[1])?n.ImageFormat.TIFF:n.ImageFormat.UNKNOWN})(r);if(s!==n.ImageFormat.TIFF&&s!==n.ImageFormat.PNG)return cc.logID(6031),!1;var c=document.createElement("canvas");s===n.ImageFormat.PNG?new a(r).render(c):h.parseTIFF(r,c);var u=l.cacheImage(e,c);u||cc.logID(6032),this.spriteFrame=new cc.SpriteFrame(u)}return!0},_initWithDictionary:function(t){this.totalParticles=parseInt(t.maxParticles||0),this.life=parseFloat(t.particleLifespan||0),this.lifeVar=parseFloat(t.particleLifespanVariance||0),this.emissionRate=this.totalParticles/this.life,this.duration=parseFloat(t.duration||0),this.srcBlendFactor=parseInt(t.blendFuncSource||n.SRC_ALPHA),this.dstBlendFactor=parseInt(t.blendFuncDestination||n.ONE_MINUS_SRC_ALPHA);var e=this._startColor;e.r=255*parseFloat(t.startColorRed||0),e.g=255*parseFloat(t.startColorGreen||0),e.b=255*parseFloat(t.startColorBlue||0),e.a=255*parseFloat(t.startColorAlpha||0);var i=this._startColorVar;i.r=255*parseFloat(t.startColorVarianceRed||0),i.g=255*parseFloat(t.startColorVarianceGreen||0),i.b=255*parseFloat(t.startColorVarianceBlue||0),i.a=255*parseFloat(t.startColorVarianceAlpha||0);var r=this._endColor;r.r=255*parseFloat(t.finishColorRed||0),r.g=255*parseFloat(t.finishColorGreen||0),r.b=255*parseFloat(t.finishColorBlue||0),r.a=255*parseFloat(t.finishColorAlpha||0);var s=this._endColorVar;if(s.r=255*parseFloat(t.finishColorVarianceRed||0),s.g=255*parseFloat(t.finishColorVarianceGreen||0),s.b=255*parseFloat(t.finishColorVarianceBlue||0),s.a=255*parseFloat(t.finishColorVarianceAlpha||0),this.startSize=parseFloat(t.startParticleSize||0),this.startSizeVar=parseFloat(t.startParticleSizeVariance||0),this.endSize=parseFloat(t.finishParticleSize||0),this.endSizeVar=parseFloat(t.finishParticleSizeVariance||0),this.sourcePos.x=0,this.sourcePos.y=0,this.posVar.x=parseFloat(t.sourcePositionVariancex||0),this.posVar.y=parseFloat(t.sourcePositionVariancey||0),this.angle=parseFloat(t.angle||0),this.angleVar=parseFloat(t.angleVariance||0),this.startSpin=parseFloat(t.rotationStart||0),this.startSpinVar=parseFloat(t.rotationStartVariance||0),this.endSpin=parseFloat(t.rotationEnd||0),this.endSpinVar=parseFloat(t.rotationEndVariance||0),this.emitterMode=parseInt(t.emitterType||f.GRAVITY),this.emitterMode===f.GRAVITY){this.gravity.x=parseFloat(t.gravityx||0),this.gravity.y=parseFloat(t.gravityy||0),this.speed=parseFloat(t.speed||0),this.speedVar=parseFloat(t.speedVariance||0),this.radialAccel=parseFloat(t.radialAcceleration||0),this.radialAccelVar=parseFloat(t.radialAccelVariance||0),this.tangentialAccel=parseFloat(t.tangentialAcceleration||0),this.tangentialAccelVar=parseFloat(t.tangentialAccelVariance||0);var o=t.rotationIsDir||"";null!==o?(o=o.toString().toLowerCase(),this.rotationIsDir="true"===o||"1"===o):this.rotationIsDir=!1}else{if(this.emitterMode!==f.RADIUS)return cc.warnID(6009),!1;this.startRadius=parseFloat(t.maxRadius||0),this.startRadiusVar=parseFloat(t.maxRadiusVariance||0),this.endRadius=parseFloat(t.minRadius||0),this.endRadiusVar=parseFloat(t.minRadiusVariance||0),this.rotatePerS=parseFloat(t.rotatePerSecond||0),this.rotatePerSVar=parseFloat(t.rotatePerSecondVariance||0)}return this._initTextureWithDictionary(t),!0},_onTextureLoaded:function(){this._texture=this._spriteFrame.getTexture(),this._simulator.updateUVs(!0),this._activateMaterial()},_applySpriteFrame:function(t){t&&t.off&&t.off("load",this._onTextureLoaded,this);var e=this._spriteFrame;e&&(e.textureLoaded()?this._onTextureLoaded(null):(e.once("load",this._onTextureLoaded,this),e.ensureLoadTexture()))},_activateMaterial:function(){this._material||(this._material=new c.SpriteMaterial,this._material.useTexture=!0,this._material.useModel=!0,this._material.useColor=!1),this._texture&&this._texture.loaded?(this.markForUpdateRenderData(!0),this.markForCustomIARender(!0),this._material.texture=this._texture,this._updateMaterial(this._material)):(this.markForCustomIARender(!1),this._spriteFrame&&this._applySpriteFrame())},_finishedSimulation:function(){this.disableRender(),this.autoRemoveOnFinish&&this._stopped&&this.node.destroy()}});cc.ParticleSystem=e.exports=p}),{"../compression/ZipUtils":21,"../core/components/CCRenderComponent":75,"../core/platform/CCMacro":161,"../core/renderer/render-engine":198,"../core/renderer/render-flow":199,"../core/utils/texture-util":242,"./CCPNGReader":254,"./CCParticleAsset":255,"./CCTIFFReader":257,"./particle-simulator":259}],257:[(function(t,e,i){var n=t("../core/CCDebug"),r={_littleEndian:!1,_tiffData:null,_fileDirectories:[],getUint8:function(t){return this._tiffData[t]},getUint16:function(t){return this._littleEndian?this._tiffData[t+1]<<8|this._tiffData[t]:this._tiffData[t]<<8|this._tiffData[t+1]},getUint32:function(t){var e=this._tiffData;return this._littleEndian?e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]:e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]},checkLittleEndian:function(){var t=this.getUint16(0);if(18761===t)this.littleEndian=!0;else{if(19789!==t)throw console.log(t),TypeError(n.getError(6019));this.littleEndian=!1}return this.littleEndian},hasTowel:function(){if(42!==this.getUint16(2))throw RangeError(n.getError(6020));return!0},getFieldTypeName:function(t){var e=this.fieldTypeNames;return t in e?e[t]:null},getFieldTagName:function(t){var e=this.fieldTagNames;return t in e?e[t]:(cc.logID(6021,t),"Tag"+t)},getFieldTypeLength:function(t){return-1!==["BYTE","ASCII","SBYTE","UNDEFINED"].indexOf(t)?1:-1!==["SHORT","SSHORT"].indexOf(t)?2:-1!==["LONG","SLONG","FLOAT"].indexOf(t)?4:-1!==["RATIONAL","SRATIONAL","DOUBLE"].indexOf(t)?8:null},getFieldValues:function(t,e,i,n){var r=[],s=this.getFieldTypeLength(e);if(s*i<=4)!1===this.littleEndian?r.push(n>>>8*(4-s)):r.push(n);else for(var o=0;o=8?-1!==["RATIONAL","SRATIONAL"].indexOf(e)?(r.push(this.getUint32(n+a)),r.push(this.getUint32(n+a+4))):cc.logID(8e3):r.push(this.getBytes(s,n+a))}return"ASCII"===e&&r.forEach((function(t,e,i){i[e]=String.fromCharCode(t)})),r},getBytes:function(t,e){if(t<=0)cc.logID(8001);else{if(t<=1)return this.getUint8(e);if(t<=2)return this.getUint16(e);if(t<=3)return this.getUint32(e)>>>8;if(t<=4)return this.getUint32(e);cc.logID(8002)}},getBits:function(t,e,i){i=i||0;var n,r,s=e+Math.floor(i/8),o=i+t,a=32-t;return o<=0?cc.logID(6023):o<=8?(n=24+i,r=this.getUint8(s)):o<=16?(n=16+i,r=this.getUint16(s)):o<=32?(n=i,r=this.getUint32(s)):cc.logID(6022),{bits:r<>>a,byteOffset:s+Math.floor(o/8),bitOffset:o%8}},parseFileDirectory:function(t){for(var e=this.getUint16(t),i=[],n=t+2,r=0;r=0&&R<=127?P=R+1:R>=-127&&R<=-1?I=1-R:C=!0}else{var L=this.getUint8(v+x);for(D=0;D0)for(var nt=0;ntm;)this.emitParticle(h),this.emitCounter-=m;this.elapsed+=t,-1!==e.duration&&e.durationthis._uvFilled&&this.updateUVs();for(var y=0;y0){if(e.emitterMode===cc.ParticleSystem.EmitterMode.GRAVITY){var g=u,x=l,A=c;(v.pos.x||v.pos.y)&&(x.set(v.pos),x.normalizeSelf()),A.set(x),x.mulSelf(v.radialAccel);var b=A.x;A.x=-A.y,A.y=b,A.mulSelf(v.tangentialAccel),g.set(x),g.addSelf(A),g.addSelf(e.gravity),g.mulSelf(t),v.dir.addSelf(g),g.set(v.dir),g.mulSelf(t),v.pos.addSelf(g)}else v.angle+=v.degreesPerSecond*t,v.radius+=v.deltaRadius*t,v.pos.x=-Math.cos(v.angle)*v.radius,v.pos.y=-Math.sin(v.angle)*v.radius;v.color.r+=v.deltaColor.r*t,v.color.g+=v.deltaColor.g*t,v.color.b+=v.deltaColor.b*t,v.color.a+=v.deltaColor.a*t,v.size+=v.deltaSize*t,v.size<0&&(v.size=0),v.rotation+=v.deltaRotation*t;var C=l;if(e.positionType===cc.ParticleSystem.PositionType.FREE||e.positionType===cc.ParticleSystem.PositionType.RELATIVE){var S=c,T=u;n.transformVec2(S,h,f),n.transformVec2(T,v.startPos,f),S.subSelf(T),C.set(v.pos),C.subSelf(S)}else C.set(v.pos);var w=s*y;this.updateParticleBuffer(v,C,d,w),++y}else{var E=r[y];y!==r.length-1&&(r[y]=r[r.length-1]),_.put(E),r.length--}}r.length>0?(d.uploadData(),e._ia._count=6*r.length):this.active||(this.finished=!0,e._finishedSimulation())},e.exports=f}),{"../core/platform/js":176,"../core/utils/affine-transform":226,"../core/utils/misc":234}],260:[(function(t,e,i){var n=t("./CCParticleSystem"),r=t("../core/renderer/"),s=t("../core/renderer/render-engine"),o=t("../core/renderer/webgl/vertex-format").vfmtPosUvColor,a=t("../core/renderer/webgl/quad-buffer"),h={useModel:!0,createIA:function(t){r.device;t._vertexFormat=o,t._buffer=new a(r._walker,o),t._ia=new s.InputAssembler,t._ia._vertexBuffer=t._buffer._vb,t._ia._indexBuffer=t._buffer._ib,t._ia._start=0,t._ia._count=0},updateRenderData:function(t){t._renderData||(t._renderData=new s.IARenderData,t._renderData.ia=t._ia),t._renderData.material=t._material},renderIA:function(t,e){e._flushIA(t._renderData)}};n._assembler=h,e.exports=h}),{"../core/renderer/":197,"../core/renderer/render-engine":198,"../core/renderer/webgl/quad-buffer":221,"../core/renderer/webgl/vertex-format":224,"./CCParticleSystem":256}],261:[(function(t,e,i){"use strict";var n=t("../compression/ZipUtils"),r=t("../compression/zlib.min"),s=t("../core/platform/js");function o(t,e){for(var i=[],n=t.getElementsByTagName("properties"),r=0;r0&&(c.type=cc.TiledMap.TMXObjectType.ELLIPSE);var m=l.getElementsByTagName("polygon");if(m&&m.length>0){c.type=cc.TiledMap.TMXObjectType.POLYGON;var d=m[0].getAttribute("points");d&&(c.points=this._parsePointsString(d))}var p=l.getElementsByTagName("polyline");if(p&&p.length>0){c.type=cc.TiledMap.TMXObjectType.POLYLINE;var y=p[0].getAttribute("points");y&&(c.polylinePoints=this._parsePointsString(y))}c.type||(c.type=cc.TiledMap.TMXObjectType.RECT),e._objects.push(c)}return e},_parsePointsString:function(t){if(!t)return null;for(var e=[],i=t.split(" "),n=0;n=this._layerSize.width||e>=this._layerSize.height||t<0||e<0},_positionForIsoAt:function(t,e){return cc.v2(this._mapTileSize.width/2*(this._layerSize.width+t-e-1),this._mapTileSize.height/2*(2*this._layerSize.height-t-e-2))},_positionForOrthoAt:function(t,e){return cc.v2(t*this._mapTileSize.width,(this._layerSize.height-e-1)*this._mapTileSize.height)},_positionForHexAt:function(t,e){var i=this._mapTileSize.width,n=this._mapTileSize.height,r=this._layerSize.height,s=this._tileset.tileOffset,o=this.node.width/2,a=this.node.height/2,h=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD?1:-1,l=0,c=0;switch(this._staggerAxis){case cc.TiledMap.StaggerAxis.STAGGERAXIS_Y:var u=0,_=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD?0:i/2;e%2==1&&(u=i/2*h),l=t*i+u+_+s.x-o,c=(r-e-1)*(n-(n-this._hexSideLength)/2)-s.y-a;break;case cc.TiledMap.StaggerAxis.STAGGERAXIS_X:var f=0,m=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD?n/2:0;t%2==1&&(f=n/2*-h),l=t*(i-(i-this._hexSideLength)/2)+s.x-o,c=(r-e-1)*n+f+m-s.y-a}return cc.v2(l,c)},setTileGIDAt:function(t,e,i,n){if(void 0===e)throw new Error("cc.TiledLayer.setTileGIDAt(): pos should be non-null");var r=void 0;if(void 0===n&&e instanceof cc.Vec2?(r=e,n=i):r=cc.v2(e,i),r.x=Math.floor(r.x),r.y=Math.floor(r.y),this._isInvalidPosition(r))throw new Error("cc.TiledLayer.setTileGIDAt(): invalid position");if(this._tiles)if(0!==t&&t>>0;this._updateTileForGID(o,r)}}else cc.logID(7238)},_updateTileForGID:function(t,e){if(0===t||this._texGrids[t]){var i=0|e.x+e.y*this._layerSize.width;i>>0},getTileFlagsAt:function(t,e){if(!t)throw new Error("TiledLayer.getTileFlagsAt: pos should be non-null");if(void 0!==e&&(t=cc.v2(t,e)),this._isInvalidPosition(t))throw new Error("TiledLayer.getTileFlagsAt: invalid position");if(!this._tiles)return cc.logID(7240),null;var i=Math.floor(t.x)+Math.floor(t.y)*this._layerSize.width;return(this._tiles[i]&cc.TiledMap.TileFlag.FLIPPED_ALL)>>>0},getTiledTileAt:function(t,e,i){if(this._isInvalidPosition(t,e))throw new Error("TiledLayer.getTiledTileAt: invalid position");if(!this._tiles)return cc.logID(7236),null;var n=Math.floor(t)+Math.floor(e)*this._layerSize.width,r=this._tiledTiles[n];if(!r&&i){var s=new cc.Node;return(r=s.addComponent(cc.TiledTile))._x=t,r._y=e,r._layer=this,r._updateInfo(),s.parent=this.node,r}return r},setTiledTileAt:function(t,e,i){if(this._isInvalidPosition(t,e))throw new Error("TiledLayer.setTiledTileAt: invalid position");if(!this._tiles)return cc.logID(7236),null;var n=Math.floor(t)+Math.floor(e)*this._layerSize.width;return this._tiledTiles[n]=i},getTexture:function(){return this._texture},setTexture:function(t){this._texture=t,this._activateMaterial()},getLayerSize:function(){return this._layerSize},getMapTileSize:function(){return this._mapTileSize},getTileSet:function(){return this._tileset},setTileSet:function(t){this._tileset=t},getLayerOrientation:function(){return this._layerOrientation},getProperties:function(){return this._properties},_init:function(t,e,i){var n=e._layerSize;this._layerName=e.name,this._tiles=e._tiles,this._properties=e.properties,this._layerSize=n,this._minGID=e._minGID,this._maxGID=e._maxGID,this._opacity=e._opacity,this._staggerAxis=i.getStaggerAxis(),this._staggerIndex=i.getStaggerIndex(),this._hexSideLength=i.getHexSideLength(),this._tileset=t,this._layerOrientation=i.orientation,this._mapTileSize=i.getTileSize();var r=i._tilesets;if(r){this._textures.length=r.length,this._texGrids.length=0;for(var s=0,o=r.length;s0&&(a[s[h]]=o[h].text);var l=new cc.TMXMapInfo(t.tmxXmlStr,a,n),c=l.getTilesets();c&&0!==c.length||cc.logID(7241),this._buildWithMapInfo(l)}else this._relseasMapInfo()},_relseasMapInfo:function(){for(var t=this._layers,e=0,i=t.length;e0)for(var s=0,o=r.length;s=0;r--){var s=n[r];if(s)for(var o=0;o>>0>=s.firstGid)return s}}return cc.logID(7215,t.name),null}});cc.TiledMap=e.exports=l,cc.js.obsolete(cc.TiledMap.prototype,"cc.TiledMap.tmxFile","tmxAsset",!0),cc.js.get(cc.TiledMap.prototype,"mapLoaded",(function(){return cc.errorID(7203),[]}),!1)}),{"./CCTMXXMLParser":261,"./CCTiledLayer":262,"./CCTiledMapAsset":264,"./CCTiledObjectGroup":265,"./CCTiledTile":266}],264:[(function(t,e,i){var n=cc.Class({name:"cc.TiledMapAsset",extends:cc.Asset,properties:{tmxXmlStr:"",textures:{default:[],type:[cc.Texture2D]},textureNames:[cc.String],tsxFiles:[cc.TextAsset],tsxFileNames:[cc.String]},statics:{preventDeferredLoadDependents:!0},createNode:!1});cc.TiledMapAsset=n,e.exports=n}),{}],265:[(function(t,e,i){var n=cc.Class({name:"cc.TiledObjectGroup",extends:cc.Component,getPositionOffset:function(){return this._positionOffset},getProperties:function(){this._properties},getGroupName:function(){return this._groupName},getProperty:function(t){return this._properties[t.toString()]},getObject:function(t){for(var e=0,i=this._objects.length;e>2,h=i.vertexCount,l=r.indiceOffset,c=r.vertexOffset;r.request(h,i.indiceCount);for(var u=r._vData,_=r._iData,f=r._uintVData,m=0,d=i.vertexCount;mL&&(z=L),U>R&&(U=R)}}var pt=G*L,yt=void 0,vt=void 0,gt=void 0,xt=void 0,At=void 0,bt=void 0,Ct=void 0,St=void 0,Tt=void 0,wt=void 0,Et=void 0,Dt=void 0,Bt=void 0;if(o===h.HEX){var Mt=t._hexSideLength;Tt=t._staggerAxis,wt=t._tileset.tileOffset,Bt=t._staggerIndex===_.STAGGERINDEX_ODD?1:-1,Et=Tt===u.STAGGERAXIS_X?(T-Mt)/2:0,Dt=Tt===u.STAGGERAXIS_Y?(w-Mt)/2:0}for(var Pt=0,It=void 0,Rt=void 0,Lt=void 0,Ot=void 0,Ft=void 0,Vt=void 0,Nt=void 0,kt=G;kt>>0]){switch(o){case h.ORTHO:xt=Gt*T,At=(R-kt-1)*w;break;case h.ISO:xt=T/2*(L+Gt-kt-1),At=w/2*(2*R-Gt-kt-2);break;case h.HEX:xt=Gt*(T-Et)+(Tt===u.STAGGERAXIS_Y&&kt%2==1?T/2*Bt:0)+wt.x,At=(R-kt-1)*(w-Dt)+(Tt===u.STAGGERAXIS_X&&Gt%2==1?w/2*-Bt:0)-wt.y}if(jt){var Ht=jt.node;Nt=r;var Xt=Ht.opacity*s/255;r=Ht.color.setA(Xt)._val,It=g,Rt=x,Lt=A,Ot=b,Ft=C,Vt=S,Ht._updateLocalMatrix(),m.copy(p,Ht._matrix),d.set(v,-xt,-At,0),m.translate(p,p,v),m.multiply(p,e._worldMatrix,p),g=p.m00,x=p.m01,A=p.m04,b=p.m05,C=p.m12,S=p.m13}if(bt=xt+E,gt=At+D,J&&o===h.ISO){if((Ct=X+At*j)>I+q){Gt+=Math.floor(2*(Ct-I)/q)-1;continue}if((St=H+bt*W)<-Y){Gt+=Math.floor(2*-St/Y)-1;continue}if(H+xt*W>P||X+gt*j<0){Gt=z;continue}}yt>l.DIAGONAL&&(Ut=(yt&l.HORIZONTAL)>>>0,Wt=(yt&l.VERTICAL)>>>0),i.vertexCount+=4,i.indiceCount+=6,i.dataLength=i.vertexCount,n[Pt].x=xt*g+gt*A+C,n[Pt].y=xt*x+gt*b+S,n[Pt].u=Ut?vt.r:vt.l,n[Pt].v=Wt?vt.b:vt.t,n[Pt].color=r,n[++Pt].x=xt*g+At*A+C,n[Pt].y=xt*x+At*b+S,n[Pt].u=Ut?vt.r:vt.l,n[Pt].v=Wt?vt.t:vt.b,n[Pt].color=r,n[++Pt].x=bt*g+gt*A+C,n[Pt].y=bt*x+gt*b+S,n[Pt].u=Ut?vt.l:vt.r,n[Pt].v=Wt?vt.b:vt.t,n[Pt].color=r,n[++Pt].x=bt*g+At*A+C,n[Pt].y=bt*x+At*b+S,n[Pt].u=Ut?vt.l:vt.r,n[Pt].v=Wt?vt.t:vt.b,n[Pt].color=r,Pt++,jt&&(r=Nt,g=It,x=Rt,A=Lt,b=Ot,C=Ft,S=Vt)}}pt+=L}}}};e.exports=n._assembler=g}),{"../../cocos2d/core/renderer/webgl/vertex-format":224,"../core/renderer/render-engine":198,"../core/renderer/render-flow":199,"./CCTiledLayer":262,"./CCTiledMap":263}],269:[(function(t,e,i){var n=t("./video-player-impl"),r=n.EventType,s=cc.Enum({REMOTE:0,LOCAL:1}),o=cc.Class({name:"cc.VideoPlayer",extends:cc.Component,editor:!1,properties:{_resourceType:s.REMOTE,resourceType:{tooltip:!1,type:s,set:function(t){this._resourceType=t,this._updateVideoSource()},get:function(){return this._resourceType}},_remoteURL:"",remoteURL:{tooltip:!1,type:cc.String,set:function(t){this._remoteURL=t,this._updateVideoSource()},get:function(){return this._remoteURL}},_clip:{default:null,type:cc.Asset},clip:{tooltip:!1,get:function(){return this._clip},set:function(t){this._clip=t,this._updateVideoSource()},type:cc.Asset},currentTime:{tooltip:!1,type:cc.Float,set:function(t){this._impl&&this._impl.seekTo(t)},get:function(){return this._impl?this._impl.currentTime():-1}},_volume:1,volume:{get:function(){return this._volume},set:function(t){this._volume=t,this.isPlaying()&&!this._mute&&this._syncVolume()},range:[0,1],type:cc.Float,tooltip:!1},_mute:!1,mute:{get:function(){return this._mute},set:function(t){this._mute=t,this._syncVolume()},tooltip:!1},keepAspectRatio:{tooltip:!1,default:!0,type:cc.Boolean,notify:function(){this._impl.setKeepAspectRatioEnabled(this.keepAspectRatio)}},isFullscreen:{tooltip:!1,default:!1,type:cc.Boolean,notify:function(){this._impl.setFullScreenEnabled(this.isFullscreen)}},videoPlayerEvent:{default:[],type:cc.Component.EventHandler}},statics:{EventType:r,ResourceType:s},ctor:function(){this._impl=new n},_syncVolume:function(){var t=this._impl;if(t){var e=this._mute?0:this._volume;t.setVolume(e)}},_updateVideoSource:function(){var t="";this.resourceType===s.REMOTE?t=this.remoteURL:this._clip&&(t=this._clip.nativeUrl||""),t&&cc.loader.md5Pipe&&(t=cc.loader.md5Pipe.transformURL(t)),this._impl.setURL(t)},onLoad:function(){var t=this._impl;t&&(t.createDomElementIfNeeded(),this._updateVideoSource(),t.seekTo(this.currentTime),t.setKeepAspectRatioEnabled(this.keepAspectRatio),t.setFullScreenEnabled(this.isFullscreen),this.pause(),t.setEventListener(r.PLAYING,this.onPlaying.bind(this)),t.setEventListener(r.PAUSED,this.onPasued.bind(this)),t.setEventListener(r.STOPPED,this.onStopped.bind(this)),t.setEventListener(r.COMPLETED,this.onCompleted.bind(this)),t.setEventListener(r.META_LOADED,this.onMetaLoaded.bind(this)),t.setEventListener(r.CLICKED,this.onClicked.bind(this)),t.setEventListener(r.READY_TO_PLAY,this.onReadyToPlay.bind(this)))},onRestore:function(){this._impl||(this._impl=new n)},onEnable:function(){this._impl&&this._impl.enable()},onDisable:function(){this._impl&&this._impl.disable()},onDestroy:function(){this._impl&&(this._impl.destroy(),this._impl=null)},update:function(t){this._impl&&this._impl.updateMatrix(this.node)},onReadyToPlay:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,r.READY_TO_PLAY),this.node.emit("ready-to-play",this)},onMetaLoaded:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,r.META_LOADED),this.node.emit("meta-loaded",this)},onClicked:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,r.CLICKED),this.node.emit("clicked",this)},onPlaying:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,r.PLAYING),this.node.emit("playing",this)},onPasued:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,r.PAUSED),this.node.emit("paused",this)},onStopped:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,r.STOPPED),this.node.emit("stopped",this)},onCompleted:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,r.COMPLETED),this.node.emit("completed",this)},play:function(){this._impl&&(this._syncVolume(),this._impl.play())},resume:function(){this._impl&&(this._syncVolume(),this._impl.resume())},pause:function(){this._impl&&this._impl.pause()},stop:function(){this._impl&&this._impl.stop()},getDuration:function(){return this._impl?this._impl.duration():-1},isPlaying:function(){return!!this._impl&&this._impl.isPlaying()}});cc.VideoPlayer=e.exports=o}),{"./video-player-impl":270}],270:[(function(t,e,i){var n=t("../core/platform/utils"),r=t("../core/platform/CCSys"),s=t("../core/renderer/render-engine").math.mat4.create();function o(t,e){t&&(e?t.webkitEnterFullscreen&&t.webkitEnterFullscreen():t.webkitExitFullscreen&&t.webkitExitFullscreen())}var a=cc.Class({name:"VideoPlayerImpl",ctor:function(){this._EventList={},this._video=null,this._url="",this._fullScreenEnabled=!1,this._loadedmeta=!1,this._loaded=!1,this._visible=!1,this._played=!1,this._playing=!1,this._ignorePause=!1,this._forceUpdate=!0,this._m00=0,this._m01=0,this._m04=0,this._m05=0,this._m12=0,this._m13=0,this._w=0,this._h=0,this.__eventListeners={}},_bindEvent:function(){var t=this._video,e=this,i=this.__eventListeners;i.loadedmetadata=function(){e._loadedmeta=!0,r.os===r.OS_IOS&&r.isBrowser&&o(t,e._fullScreenEnabled),e._dispatchEvent(a.EventType.META_LOADED)},i.ended=function(){e._video===t&&(e._playing=!1,e._dispatchEvent(a.EventType.COMPLETED))},i.play=function(){e._video===t&&(e._playing=!0,e._dispatchEvent(a.EventType.PLAYING))},i.pause=function(){e._ignorePause||e._video!==t||(e._playing=!1,e._dispatchEvent(a.EventType.PAUSED))},i.click=function(){e._dispatchEvent(a.EventType.CLICKED)},t.addEventListener("loadedmetadata",i.loadedmetadata),t.addEventListener("ended",i.ended),t.addEventListener("play",i.play),t.addEventListener("pause",i.pause),t.addEventListener("click",i.click),i.onCanPlay=function(){if(!this._loaded){var t=this._video;4===t.readyState&&(this._loaded=!0,t.currentTime=0,this._dispatchEvent(a.EventType.READY_TO_PLAY),this._updateVisibility())}}.bind(this),t.addEventListener("canplay",i.onCanPlay),t.addEventListener("canplaythrough",i.onCanPlay),t.addEventListener("suspend",i.onCanPlay)},_updateVisibility:function(){if(this._video){var t=this._video;this._visible?t.style.visibility="visible":(t.style.visibility="hidden",t.pause(),this._playing=!1),this._forceUpdate=!0}},_updateSize:function(t,e){var i=this._video;i&&(i.style.width=t+"px",i.style.height=e+"px")},_createDom:function(){var t=document.createElement("video");t.style.position="absolute",t.style.bottom="0px",t.style.left="0px",t.className="cocosVideo",t.setAttribute("preload","auto"),t.setAttribute("webkit-playsinline",""),t.setAttribute("playsinline","");var e=cc.winSize.width>cc.winSize.height?"landscape":"portrait";t.setAttribute("x5-playsinline",""),t.setAttribute("x5-video-player-type","h5"),t.setAttribute("x5-video-orientation",e),this._video=t,cc.game.container.appendChild(t)},createDomElementIfNeeded:function(){this._video||this._createDom()},removeDom:function(){var t=this._video;if(t){n.contains(cc.game.container,t)&&cc.game.container.removeChild(t);var e=this.__eventListeners;t.removeEventListener("loadedmetadata",e.loadedmetadata),t.removeEventListener("ended",e.ended),t.removeEventListener("play",e.play),t.removeEventListener("pause",e.pause),t.removeEventListener("click",e.click),t.removeEventListener("canplay",e.onCanPlay),t.removeEventListener("canplaythrough",e.onCanPlay),t.removeEventListener("suspend",e.onCanPlay),e.loadedmetadata=null,e.ended=null,e.play=null,e.pause=null,e.click=null,e.onCanPlay=null}this._video=null,this._url=""},setURL:function(t){var e,i=void 0;if(this._url!==t){this._url=t,this.removeDom(),this.createDomElementIfNeeded(),this._bindEvent();var n=this._video;n.style.visibility="hidden",this._loaded=!1,this._played=!1,this._playing=!1,this._loadedmeta=!1,(i=document.createElement("source")).src=t,n.appendChild(i),e=cc.path.extname(t);for(var r=a._polyfill,s=0;s":0});var l=cc.Class({name:"dragonBones.ArmatureDisplay",extends:n,mixins:[s],editor:!1,properties:{_factory:{default:null,type:dragonBones.CCFactory,serializable:!1},dragonAsset:{default:null,type:dragonBones.DragonBonesAsset,notify:function(){this._parseDragonAsset(),this._refresh()},tooltip:!1},dragonAtlasAsset:{default:null,type:dragonBones.DragonBonesAtlasAsset,notify:function(){this._parseDragonAtlasAsset(),this._buildArmature(),this._activateMaterial()},tooltip:!1},_armatureName:"",armatureName:{get:function(){return this._armatureName},set:function(t){this._armatureName=t;var e=this.getAnimationNames(this._armatureName);(!this.animationName||e.indexOf(this.animationName)<0)&&(this.animationName=""),this._armature&&this._factory._dragonBones.clock.remove(this._armature),this._refresh(),this._armature&&this._factory._dragonBones.clock.add(this._armature)},visible:!1},_animationName:"",animationName:{get:function(){return this._animationName},set:function(t){this._animationName=t},visible:!1},_defaultArmatureIndex:{default:0,notify:function(){var t="";if(this.dragonAsset){var e=void 0;if(this.dragonAsset&&(e=this.dragonAsset.getArmatureEnum()),!e)return cc.errorID(7400,this.name);t=e[this._defaultArmatureIndex]}void 0!==t?this.armatureName=t:cc.errorID(7401,this.name)},type:a,visible:!0,editorOnly:!0,displayName:"Armature",tooltip:!1},_animationIndex:{default:0,notify:function(){if(0!==this._animationIndex){var t=void 0;if(this.dragonAsset&&(t=this.dragonAsset.getAnimsEnum(this.armatureName)),t){var e=t[this._animationIndex];void 0!==e?this.animationName=e:cc.errorID(7402,this.name)}}else this.animationName=""},type:h,visible:!0,editorOnly:!0,displayName:"Animation",tooltip:!1},timeScale:{default:1,notify:function(){this._armature.animation.timeScale=this.timeScale},tooltip:!1},playTimes:{default:-1,tooltip:!1},debugBones:{default:!1,notify:function(){this._initDebugDraw()},tooltip:!1}},ctor:function(){this._inited=!1,this._factory=dragonBones.CCFactory.getInstance()},__preload:function(){this._init()},_init:function(){this._inited||(this._inited=!0,this._parseDragonAsset(),this._parseDragonAtlasAsset(),this._refresh(),this._activateMaterial())},onEnable:function(){this._super(),this._armature&&this._factory._dragonBones.clock.add(this._armature)},onDisable:function(){this._super(),this._armature&&this._factory._dragonBones.clock.remove(this._armature)},onDestroy:function(){this._super(),this._inited=!1,this._armature&&(this._armature.dispose(),this._armature=null)},_initDebugDraw:function(){if(this.debugBones){if(!this._debugDraw){var t=new cc.PrivateNode;t.name="DEBUG_DRAW_NODE";var e=t.addComponent(o);e.lineWidth=1,e.strokeColor=cc.color(255,0,0,255),this._debugDraw=e}this._debugDraw.node.parent=this.node}else this._debugDraw&&(this._debugDraw.node.parent=null)},_activateMaterial:function(){var t=this.dragonAtlasAsset&&this.dragonAtlasAsset.texture,e=this._material||new r;e.useColor=!1,t?(e.texture=t,this.markForUpdateRenderData(!0),this.markForRender(!0)):this.disableRender(),this._updateMaterial(e)},_buildArmature:function(){if(this.dragonAsset&&this.dragonAtlasAsset&&this.armatureName){var t=dragonBones.CCFactory.getInstance();this._armature=t.buildArmatureDisplay(this.armatureName,this.dragonAsset._dragonBonesData.name,this),this._armature.animation.timeScale=this.timeScale,this.animationName&&this.playAnimation(this.animationName,this.playTimes)}},_parseDragonAsset:function(){this.dragonAsset&&this.dragonAsset.init(this._factory)},_parseDragonAtlasAsset:function(){this.dragonAtlasAsset&&this.dragonAtlasAsset.init(this._factory)},_refresh:function(){this._buildArmature()},_updateAnimEnum:!1,_updateArmatureEnum:!1,playAnimation:function(t,e){return this._armature?(this.playTimes=void 0===e?-1:e,this.animationName=t,this._armature.animation.play(t,this.playTimes)):null},getArmatureNames:function(){var t=this.dragonAsset&&this.dragonAsset._dragonBonesData;return t&&t.armatureNames||[]},getAnimationNames:function(t){var e=[];if(this.dragonAsset&&this.dragonAsset._dragonBonesData){var i=this.dragonAsset._dragonBonesData.getArmature(t);if(i)for(var n in i.animations)i.animations.hasOwnProperty(n)&&e.push(n)}return e},addEventListener:function(t,e,i){this.addDBEventListener(t,e,i)},removeEventListener:function(t,e,i){this.removeDBEventListener(t,e,i)},buildArmature:function(t,e){return dragonBones.CCFactory.getInstance().createArmatureNode(this,t,e)},armature:function(){return this._armature},dbInit:function(t){this._armature=t},dbClear:function(){this._armature=null},dbUpdate:function(){},advanceTimeBySelf:function(t){this.shouldAdvanced=!!t},hasDBEventListener:function(t){return this.hasEventListener(t)},addDBEventListener:function(t,e,i){this.on(t,e,i)},removeDBEventListener:function(t,e,i){this.off(t,e,i)},dispatchDBEvent:function(t,e){this.emit(t,e)}});e.exports=dragonBones.ArmatureDisplay=l}),{"../../cocos2d/core/CCNode":28,"../../cocos2d/core/components/CCRenderComponent":75,"../../cocos2d/core/event/event-target":99,"../../cocos2d/core/graphics/graphics":103,"../../cocos2d/core/renderer/render-engine":198}],276:[(function(t,e,i){var n=dragonBones.BaseObject,r=dragonBones.CCFactory=cc.Class({name:"dragonBones.CCFactory",extends:dragonBones.BaseFactory,statics:{_factory:null,getInstance:function(){return r._factory||(r._factory=new r),r._factory}},ctor:function(){this._dragonBones=new dragonBones.DragonBones,cc.director._scheduler&&(cc.director._scheduler.enableForTarget(this),cc.director._scheduler.scheduleUpdate(this,cc.Scheduler.PRIORITY_SYSTEM,!1))},update:function(t){this._dragonBones.advanceTime(t)},buildArmatureDisplay:function(t,e,i){this._display=i;var n=this.buildArmature(t,e,i);return this._display=null,n},parseTextureAtlasData:function(t,e){var i=JSON.parse(t);return this._super(i,e)},createArmatureNode:function(t,e,i){var n=(i=i||new cc.Node).getComponent(dragonBones.ArmatureDisplay);return n||(n=i.addComponent(dragonBones.ArmatureDisplay)),i.name=e,n._armatureName=e,n._N$dragonAsset=t.dragonAsset,n._N$dragonAtlasAsset=t.dragonAtlasAsset,n._init(),n},_buildChildArmature:function(t,e,i){var n=this._display,r="CHILD_ARMATURE-"+i.path,s=this._display.node.getChildByName(r);s||(s=new cc.Node);var o=this.createArmatureNode(n,i.path,s);return s.name=r,this._display=n,o._armature},_buildTextureAtlasData:function(t,e){return t?t.renderTexture=e:t=n.borrowObject(dragonBones.CCTextureAtlasData),t},_sortSlots:function(){for(var t=this._slots,e=[],i=0,n=t.length;i=0;a--)if(s>=e[a]._zOrder){e.splice(a+1,0,r),o=!0;break}o||e.splice(0,0,r)}this._slots=e},_buildArmature:function(t){var e=n.borrowObject(dragonBones.Armature);return e._skinData=t.skin,e._animation=n.borrowObject(dragonBones.Animation),e._animation._armature=e,e._animation.animations=t.armature.animations,e._isChildArmature=!1,e.init(t.armature,this._display,this._display,this._dragonBones),e},_buildSlot:function(t,e,i){var r=n.borrowObject(dragonBones.CCSlot);r.name=e.name,r.reset();var s=r;return r.init(e,i,s,s),r}})}),{}],277:[(function(t,e,i){var n=t("../../cocos2d/core/renderer/render-engine").math,r=(t("../../cocos2d/core/platform/CCMacro"),dragonBones.BinaryOffset),s=dragonBones.BoneType;dragonBones.CCSlot=cc.Class({name:"dragonBones.CCSlot",extends:dragonBones.Slot,ctor:function(){this._vertices=[],this._localVertices=[],this._indices=[],this._matrix=n.mat4.create(),this._visible=!1,this._color=cc.color()},reset:function(){this._vertices.length=0,this._localVertices.length=0,this._indices.length=0,n.mat4.identity(this._matrix),this._visible=!1},statics:{toString:function(){return"[class dragonBones.CCSlot]"}},_onUpdateDisplay:function(){this._childArmature&&(this._childArmature.display._isChildArmature=!0)},_initDisplay:function(t){},_addDisplay:function(){this._visible=!0,this._rawDisplay.parent=this._armature.display.node},_replaceDisplay:function(t){t instanceof dragonBones.ArmatureDisplay&&(t.node.parent=null),this._display instanceof dragonBones.ArmatureDisplay&&(this._display.node.parent=this._armature.display.node)},_removeDisplay:function(){this._visible=!1,this._rawDisplay.parent=null},_disposeDisplay:function(t){},_updateVisible:function(){},_updateZOrder:function(){},_updateBlendMode:function(){},_updateColor:function(){var t=this._color;t.r=255*this._colorTransform.redMultiplier,t.g=255*this._colorTransform.greenMultiplier,t.b=255*this._colorTransform.blueMultiplier,t.a=255*this._colorTransform.alphaMultiplier},_updateFrame:function(){this._vertices.length=0,this._indices.length=0;var t=this._vertices,e=this._indices,i=this._localVertices;t.length=0,e.length=0,i.length=0;var n=this._textureData;if(this._display&&!(this._displayIndex<0)&&n){var s=this._displayIndex0&&e.inheritDeform,n=e.weight,o=this._localVertices;if(null!==n){var a=e.parent.parent.parent,h=a.intArray,l=a.floatArray,c=h[e.offset+r.MeshVertexCount],u=h[n.offset+r.WeigthFloatOffset];u<0&&(u+=65536);for(var _=0,f=n.offset+r.WeigthBoneIndices+n.bones.length,m=u,d=0;_0){for(var i=0,n=this._objects;i0){for(var r=0;ri&&(r.length=i),t._maxCountMap[n]=i;else for(var n in t._defaultMaxCount=i,t._poolsMap){var r;(r=t._poolsMap[n]).length>i&&(r.length=i),n in t._maxCountMap&&(t._maxCountMap[n]=i)}},t.clearPool=function(e){if(void 0===e&&(e=null),null!==e){var i=String(e);null!==(r=i in t._poolsMap?t._poolsMap[i]:null)&&r.length>0&&(r.length=0)}else for(var n in t._poolsMap){var r;(r=t._poolsMap[n]).length=0}},t.borrowObject=function(e){var i=String(e),n=i in t._poolsMap?t._poolsMap[i]:null;if(null!==n&&n.length>0){var r=n.pop();return r._isInPool=!1,r}var s=new e;return s._onClear(),s},t.prototype.returnToPool=function(){this._onClear(),t._returnObject(this)},t._hashCode=0,t._defaultMaxCount=3e3,t._maxCountMap={},t._poolsMap={},t})();t.BaseObject=e})(n||(n={})),(function(t){var e=(function(){function t(t,e,i,n,r,s){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s}return t.prototype.toString=function(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty},t.prototype.copyFrom=function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},t.prototype.copyFromArray=function(t,e){return void 0===e&&(e=0),this.a=t[e],this.b=t[e+1],this.c=t[e+2],this.d=t[e+3],this.tx=t[e+4],this.ty=t[e+5],this},t.prototype.identity=function(){return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this},t.prototype.concat=function(t){var e=this.a*t.a,i=0,n=0,r=this.d*t.d,s=this.tx*t.a+t.tx,o=this.ty*t.d+t.ty;return 0===this.b&&0===this.c||(e+=this.b*t.c,i+=this.b*t.d,n+=this.c*t.a,r+=this.c*t.b),0===t.b&&0===t.c||(i+=this.a*t.b,n+=this.d*t.c,s+=this.ty*t.c,o+=this.tx*t.b),this.a=e,this.b=i,this.c=n,this.d=r,this.tx=s,this.ty=o,this},t.prototype.invert=function(){var t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,s=this.ty;if(0===e&&0===i)return this.b=this.c=0,0===t||0===n?this.a=this.b=this.tx=this.ty=0:(t=this.a=1/t,n=this.d=1/n,this.tx=-t*r,this.ty=-n*s),this;var o=t*n-e*i;if(0===o)return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this;o=1/o;var a=this.a=n*o;return e=this.b=-e*o,i=this.c=-i*o,n=this.d=t*o,this.tx=-(a*r+i*s),this.ty=-(e*r+n*s),this},t.prototype.transformPoint=function(t,e,i,n){void 0===n&&(n=!1),i.x=this.a*t+this.c*e,i.y=this.b*t+this.d*e,n||(i.x+=this.tx,i.y+=this.ty)},t.prototype.transformRectangle=function(t,e){void 0===e&&(e=!1);var i=this.a,n=this.b,r=this.c,s=this.d,o=e?0:this.tx,a=e?0:this.ty,h=t.x,l=t.y,c=h+t.width,u=l+t.height,_=i*h+r*l+o,f=n*h+s*l+a,m=i*c+r*l+o,d=n*c+s*l+a,p=i*c+r*u+o,y=n*c+s*u+a,v=i*h+r*u+o,g=n*h+s*u+a,x=0;_>m&&(x=_,_=m,m=x),p>v&&(x=p,p=v,v=x),t.x=Math.floor(_v?m:v)-t.x),f>d&&(x=f,f=d,d=x),y>g&&(x=y,y=g,g=x),t.y=Math.floor(fg?d:g)-t.y)},t})();t.Matrix=e})(n||(n={})),(function(t){var e=(function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=1),this.x=t,this.y=e,this.skew=i,this.rotation=n,this.scaleX=r,this.scaleY=s}return t.normalizeRadian=function(t){return t=(t+Math.PI)%(2*Math.PI),t+=t>0?-Math.PI:Math.PI},t.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+180*this.skew/Math.PI+" skewY:"+180*this.rotation/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.skew=t.skew,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this},t.prototype.identity=function(){return this.x=this.y=0,this.skew=this.rotation=0,this.scaleX=this.scaleY=1,this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.skew+=t.skew,this.rotation+=t.rotation,this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this},t.prototype.minus=function(t){return this.x-=t.x,this.y-=t.y,this.skew-=t.skew,this.rotation-=t.rotation,this.scaleX/=t.scaleX,this.scaleY/=t.scaleY,this},t.prototype.fromMatrix=function(e){var i=this.scaleX,n=this.scaleY,r=t.PI_Q;this.x=e.tx,this.y=e.ty,this.rotation=Math.atan(e.b/e.a);var s=Math.atan(-e.c/e.d);return this.scaleX=this.rotation>-r&&this.rotation-r&&s=0&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.rotation=this.rotation-Math.PI),n>=0&&this.scaleY<0&&(this.scaleY=-this.scaleY,s-=Math.PI),this.skew=s-this.rotation,this},t.prototype.toMatrix=function(t){return 0===this.rotation?(t.a=1,t.b=0):(t.a=Math.cos(this.rotation),t.b=Math.sin(this.rotation)),0===this.skew?(t.c=-t.b,t.d=t.a):(t.c=-Math.sin(this.skew+this.rotation),t.d=Math.cos(this.skew+this.rotation)),1!==this.scaleX&&(t.a*=this.scaleX,t.b*=this.scaleX),1!==this.scaleY&&(t.c*=this.scaleY,t.d*=this.scaleY),t.tx=this.x,t.ty=this.y,this},t.PI=Math.PI,t.PI_D=2*Math.PI,t.PI_H=Math.PI/2,t.PI_Q=Math.PI/4,t.RAD_DEG=180/Math.PI,t.DEG_RAD=Math.PI/180,t})();t.Transform=e})(n||(n={})),(function(t){var e=(function(){function t(t,e,i,n,r,s,o,a){void 0===t&&(t=1),void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=0),this.alphaMultiplier=t,this.redMultiplier=e,this.greenMultiplier=i,this.blueMultiplier=n,this.alphaOffset=r,this.redOffset=s,this.greenOffset=o,this.blueOffset=a}return t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier,this.redMultiplier=t.redMultiplier,this.greenMultiplier=t.greenMultiplier,this.blueMultiplier=t.blueMultiplier,this.alphaOffset=t.alphaOffset,this.redOffset=t.redOffset,this.greenOffset=t.greenOffset,this.blueOffset=t.blueOffset},t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1,this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0},t})();t.ColorTransform=e})(n||(n={})),(function(t){var e=(function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t.prototype.clear=function(){this.x=this.y=0},t})();t.Point=e})(n||(n={})),(function(t){var e=(function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},t.prototype.clear=function(){this.x=this.y=0,this.width=this.height=0},t})();t.Rectangle=e})(n||(n={})),(function(t){var e=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ints=[],e.floats=[],e.strings=[],e}return r(e,t),e.toString=function(){return"[class dragonBones.UserData]"},e.prototype._onClear=function(){this.ints.length=0,this.floats.length=0,this.strings.length=0},e.prototype.addInt=function(t){this.ints.push(t)},e.prototype.addFloat=function(t){this.floats.push(t)},e.prototype.addString=function(t){this.strings.push(t)},e.prototype.getInt=function(t){return void 0===t&&(t=0),t>=0&&t=0&&t=0&&t=t&&(i=0),!(this.sortedBones.indexOf(r)>=0)){var s=!1;for(var o in this.constraints){var a=this.constraints[o];if(a.root===r&&this.sortedBones.indexOf(a.target)<0){s=!0;break}}s||null!==r.parent&&this.sortedBones.indexOf(r.parent)<0||(this.sortedBones.push(r),n++)}}}},i.prototype.cacheFrames=function(t){if(!(this.cacheFrameRate>0))for(var e in this.cacheFrameRate=t,this.animations)this.animations[e].cacheFrames(this.cacheFrameRate)},i.prototype.setCacheFrame=function(t,e){var i=this.parent.cachedFrames,n=i.length;return i.length+=10,i[n]=t.a,i[n+1]=t.b,i[n+2]=t.c,i[n+3]=t.d,i[n+4]=t.tx,i[n+5]=t.ty,i[n+6]=e.rotation,i[n+7]=e.skew,i[n+8]=e.scaleX,i[n+9]=e.scaleY,n},i.prototype.getCacheFrame=function(t,e,i){var n=this.parent.cachedFrames;t.a=n[i],t.b=n[i+1],t.c=n[i+2],t.d=n[i+3],t.tx=n[i+4],t.ty=n[i+5],e.rotation=n[i+6],e.skew=n[i+7],e.scaleX=n[i+8],e.scaleY=n[i+9],e.x=t.tx,e.y=t.ty},i.prototype.addBone=function(t){t.name in this.bones?console.warn("Same bone: "+t.name):(this.bones[t.name]=t,this.sortedBones.push(t))},i.prototype.addSlot=function(t){t.name in this.slots?console.warn("Same slot: "+t.name):(this.slots[t.name]=t,this.sortedSlots.push(t))},i.prototype.addConstraint=function(t){t.name in this.constraints?console.warn("Same constraint: "+t.name):this.constraints[t.name]=t},i.prototype.addSkin=function(t){t.name in this.skins?console.warn("Same skin: "+t.name):(t.parent=this,this.skins[t.name]=t,null===this.defaultSkin&&(this.defaultSkin=t),"default"===t.name&&(this.defaultSkin=t))},i.prototype.addAnimation=function(t){t.name in this.animations?console.warn("Same animation: "+t.name):(t.parent=this,this.animations[t.name]=t,this.animationNames.push(t.name),null===this.defaultAnimation&&(this.defaultAnimation=t))},i.prototype.addAction=function(t,e){e?this.defaultActions.push(t):this.actions.push(t)},i.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null},i.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null},i.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null},i.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null},i.prototype.getMesh=function(t,e,i){var n=this.getSkin(t);return null===n?null:n.getDisplay(e,i)},i.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null},i})(t.BaseObject);t.ArmatureData=e;var i=(function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.transform=new t.Transform,i.userData=null,i}return r(i,e),i.toString=function(){return"[class dragonBones.BoneData]"},i.prototype._onClear=function(){null!==this.userData&&this.userData.returnToPool(),this.inheritTranslation=!1,this.inheritRotation=!1,this.inheritScale=!1,this.inheritReflection=!1,this.type=0,this.length=0,this.name="",this.transform.identity(),this.userData=null,this.parent=null},i})(t.BaseObject);t.BoneData=i;var n=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.vertices=[],e}return r(e,t),e.toString=function(){return"[class dragonBones.SurfaceData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=1,this.segmentX=0,this.segmentY=0,this.vertices.length=0},e})(i);t.SurfaceData=n;var s=(function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.color=null,t.userData=null,t}return r(i,e),i.createColor=function(){return new t.ColorTransform},i.toString=function(){return"[class dragonBones.SlotData]"},i.prototype._onClear=function(){null!==this.userData&&this.userData.returnToPool(),this.blendMode=0,this.displayIndex=0,this.zOrder=0,this.name="",this.color=null,this.userData=null,this.parent=null},i.DEFAULT_COLOR=new t.ColorTransform,i})(t.BaseObject);t.SlotData=s})(n||(n={})),(function(t){var e=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._onClear=function(){this.order=0,this.name="",this.target=null,this.root=null,this.bone=null},e})(t.BaseObject);t.ConstraintData=e;var i=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.toString=function(){return"[class dragonBones.IKConstraintData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.scaleEnabled=!1,this.bendPositive=!1,this.weight=1},e})(e);t.IKConstraintData=i})(n||(n={})),(function(t){var e=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.toString=function(){return"[class dragonBones.CanvasData]"},e.prototype._onClear=function(){this.hasBackground=!1,this.color=0,this.x=0,this.y=0,this.width=0,this.height=0},e})(t.BaseObject);t.CanvasData=e})(n||(n={})),(function(t){var e=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.displays={},e}return r(e,t),e.toString=function(){return"[class dragonBones.SkinData]"},e.prototype._onClear=function(){for(var t in this.displays){for(var e=0,i=this.displays[t];er&&(o|=2),es&&(o|=8),o},e.rectangleIntersectsSegment=function(t,i,n,r,s,o,a,h,l,c,u){void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=null);var _=t>s&&to&&is&&no&&r=-i&&t<=i){var n=.5*this.height;if(e>=-n&&e<=n)return!0}return!1},e.prototype.intersectsSegment=function(t,i,n,r,s,o,a){void 0===s&&(s=null),void 0===o&&(o=null),void 0===a&&(a=null);var h=.5*this.width,l=.5*this.height;return e.rectangleIntersectsSegment(t,i,n,r,-h,-l,h,l,s,o,a)},e})(e);t.RectangleBoundingBoxData=i;var n=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.toString=function(){return"[class dragonBones.EllipseData]"},e.ellipseIntersectsSegment=function(t,e,i,n,r,s,o,a,h,l,c){void 0===h&&(h=null),void 0===l&&(l=null),void 0===c&&(c=null);var u=o/a,_=u*u,f=i-t,m=(n*=u)-(e*=u),d=Math.sqrt(f*f+m*m),p=f/d,y=m/d,v=(r-t)*p+(s-e)*y,g=o*o,x=g-(t*t+e*e)+v*v,A=0;if(x>=0){var b=Math.sqrt(x),C=v-b,S=v+b,T=C<0?-1:C<=d?0:1,w=S<0?-1:S<=d?0:1,E=T*w;if(E<0)return-1;0===E&&(-1===T?(A=2,i=t+S*p,n=(e+S*y)/u,null!==h&&(h.x=i,h.y=n),null!==l&&(l.x=i,l.y=n),null!==c&&(c.x=Math.atan2(n/g*_,i/g),c.y=c.x+Math.PI)):1===w?(A=1,t+=C*p,e=(e+C*y)/u,null!==h&&(h.x=t,h.y=e),null!==l&&(l.x=t,l.y=e),null!==c&&(c.x=Math.atan2(e/g*_,t/g),c.y=c.x+Math.PI)):(A=3,null!==h&&(h.x=t+C*p,h.y=(e+C*y)/u,null!==c&&(c.x=Math.atan2(h.y/g*_,h.x/g))),null!==l&&(l.x=t+S*p,l.y=(e+S*y)/u,null!==c&&(c.y=Math.atan2(l.y/g*_,l.x/g)))))}return A},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=1},e.prototype.containsPoint=function(t,e){var i=.5*this.width;if(t>=-i&&t<=i){var n=.5*this.height;if(e>=-n&&e<=n)return e*=i/n,Math.sqrt(t*t+e*e)<=i}return!1},e.prototype.intersectsSegment=function(t,i,n,r,s,o,a){return void 0===s&&(s=null),void 0===o&&(o=null),void 0===a&&(a=null),e.ellipseIntersectsSegment(t,i,n,r,0,0,.5*this.width,.5*this.height,s,o,a)},e})(e);t.EllipseBoundingBoxData=n;var s=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.vertices=[],e.weight=null,e}return r(e,t),e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"},e.polygonIntersectsSegment=function(t,e,i,n,r,s,o,a){void 0===s&&(s=null),void 0===o&&(o=null),void 0===a&&(a=null),t===i&&(t=i+1e-6),e===n&&(e=n+1e-6);for(var h=r.length,l=t-i,c=e-n,u=t*n-e*i,_=0,f=r[h-2],m=r[h-1],d=0,p=0,y=0,v=0,g=0,x=0,A=0;A=f&&D<=b||D>=b&&D<=f)&&(0===l||D>=t&&D<=i||D>=i&&D<=t)){var B=(u*T-c*w)/E;if((B>=m&&B<=C||B>=C&&B<=m)&&(0===c||B>=e&&B<=n||B>=n&&B<=e)){if(null===o){y=D,v=B,g=D,x=B,_++,null!==a&&(a.x=Math.atan2(C-m,b-f)-.5*Math.PI,a.y=a.x);break}var M=D-t;M<0&&(M=-M),0===_?(d=M,p=M,y=D,v=B,g=D,x=B,null!==a&&(a.x=Math.atan2(C-m,b-f)-.5*Math.PI,a.y=a.x)):(Mp&&(p=M,g=D,x=B,null!==a&&(a.y=Math.atan2(C-m,b-f)-.5*Math.PI))),_++}}f=b,m=C}return 1===_?(null!==s&&(s.x=y,s.y=v),null!==o&&(o.x=y,o.y=v),null!==a&&(a.y=a.x+Math.PI)):_>1&&(_++,null!==s&&(s.x=y,s.y=v),null!==o&&(o.x=g,o.y=x)),_},e.prototype._onClear=function(){t.prototype._onClear.call(this),null!==this.weight&&this.weight.returnToPool(),this.type=2,this.x=0,this.y=0,this.vertices.length=0,this.weight=null},e.prototype.containsPoint=function(t,e){var i=!1;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height)for(var n=0,r=this.vertices.length,s=r-2;n=e||o=e){var h=this.vertices[s],l=this.vertices[n];(e-a)*(h-l)/(o-a)+l0)){this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var i=0,n=this.cacheFrames.length;i=0},e.prototype.addBoneMask=function(t,e,i){void 0===i&&(i=!0);var n=t.getBone(e);if(null!==n&&(this.boneMask.indexOf(e)<0&&this.boneMask.push(e),i))for(var r=0,s=t.getBones();r=0&&this.boneMask.splice(n,1),i){var r=t.getBone(e);if(null!==r)if(this.boneMask.length>0)for(var s=0,o=t.getBones();s=0&&r.contains(a)&&this.boneMask.splice(h,1)}else for(var l=0,c=t.getBones();le._zOrder?1:-1},i.prototype._onClear=function(){null!==this._clock&&this._clock.remove(this);for(var t=0,e=this._bones;t=t&&(i=0),!(this._bones.indexOf(r)>=0)){if(r._hasConstraint){for(var s=!1,o=0,a=this._constraints;o=s)){var a=i[o],h=this.getSlot(a.name);null!==h&&h._setZorder(r)}}this._slotsDirty=!0,this._zOrderDirty=!n}},i.prototype._addBoneToBoneList=function(t){this._bones.indexOf(t)<0&&(this._bonesDirty=!0,this._bones.push(t))},i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);e>=0&&this._bones.splice(e,1)},i.prototype._addSlotToSlotList=function(t){this._slots.indexOf(t)<0&&(this._slotsDirty=!0,this._slots.push(t))},i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);e>=0&&this._slots.splice(e,1)},i.prototype._bufferAction=function(t,e){this._actions.indexOf(t)<0&&(e?this._actions.push(t):this._actions.unshift(t))},i.prototype.dispose=function(){null!==this._armatureData&&(this._lockUpdate=!0,this._dragonBones.bufferObject(this))},i.prototype.init=function(e,i,n,r){null===this._armatureData&&(this._armatureData=e,this._animation=t.BaseObject.borrowObject(t.Animation),this._proxy=i,this._display=n,this._dragonBones=r,this._proxy.dbInit(this),this._animation.init(this),this._animation.animations=this._armatureData.animations)},i.prototype.advanceTime=function(t){if(!this._lockUpdate)if(null!==this._armatureData)if(null!==this._armatureData.parent){var e=this._cacheFrameIndex;if(this._animation.advanceTime(t),this._bonesDirty&&(this._bonesDirty=!1,this._sortBones()),this._slotsDirty&&(this._slotsDirty=!1,this._sortSlots()),this._cacheFrameIndex<0||this._cacheFrameIndex!==e){var i=0,n=0;for(i=0,n=this._bones.length;i0){this._lockUpdate=!0;for(var r=0,s=this._actions;r0){if(null!==(o=this.getBone(t))&&(o.invalidUpdate(),e))for(var i=0,n=this._slots;i0){if(null===r&&null===s){p=x;break}var A;null!==r&&((A=a?r.y-e:r.x-t)<0&&(A=-A),(null===p||Al)&&(l=A,_=s.x,f=s.y,y=x,null!==o&&(d=o.y)))}}return null!==p&&null!==r&&(r.x=c,r.y=u,null!==o&&(o.x=m)),null!==y&&null!==s&&(s.x=_,s.y=f,null!==o&&(o.y=d)),p},i.prototype.getBone=function(t){for(var e=0,i=this._bones;e0?this.getBone(e):null)},i.prototype.addSlot=function(t,e){var i=this.getBone(e);console.assert(null!==t&&null!==i),t._setArmature(this),t._setParent(i)},i.prototype.addConstraint=function(t){this._constraints.indexOf(t)<0&&this._constraints.push(t)},i.prototype.removeBone=function(t){console.assert(null!==t&&t.armature===this),t._setParent(null),t._setArmature(null)},i.prototype.removeSlot=function(t){console.assert(null!==t&&t.armature===this),t._setParent(null),t._setArmature(null)},i.prototype.getBones=function(){return this._bones},i.prototype.getSlots=function(){return this._slots},Object.defineProperty(i.prototype,"flipX",{get:function(){return this._flipX},set:function(t){this._flipX!==t&&(this._flipX=t,this.invalidUpdate())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"flipY",{get:function(){return this._flipY},set:function(t){this._flipY!==t&&(this._flipY=t,this.invalidUpdate())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cacheFrameRate",{get:function(){return this._armatureData.cacheFrameRate},set:function(t){if(this._armatureData.cacheFrameRate!==t){this._armatureData.cacheFrames(t);for(var e=0,i=this._slots;e=0&&null!==this._cachedFrameIndices){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e)this._transformDirty=!1;else if(e>=0)this._transformDirty=!0,this._cachedFrameIndex=e;else{if(this._hasConstraint)for(var i=0,n=this._armature._constraints;i=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}}else{if(this._hasConstraint)for(var r=0,s=this._armature._constraints;r=0;this._localDirty&&this._updateGlobalTransformMatrix(a),a&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0},i.prototype.updateByConstraint=function(){this._localDirty&&(this._localDirty=!1,(this._transformDirty||null!==this._parent&&this._parent._childrenTransformDirty)&&this._updateGlobalTransformMatrix(!0),this._transformDirty=!0)},i.prototype.invalidUpdate=function(){this._transformDirty=!0},i.prototype.contains=function(t){if(t===this)return!1;for(var e=t;e!==this&&null!==e;)e=e.parent;return e===this},Object.defineProperty(i.prototype,"boneData",{get:function(){return this._boneData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible!==t){this._visible=t;for(var e=0,i=this._armature.getSlots();es)return this.globalTransformMatrix;if(m=7*(2*(a*(h+1)+2*a+h+f)+((r=i>this._kX*(t+s)+p)?1:0)),this._matrixCahce[m]>0)v.copyFromArray(y,m+1);else{var g=f*(l+2),x=this._hullCache[4],A=this._hullCache[5],b=this._hullCache[2]-(h-f)*x,C=this._hullCache[3]-(h-f)*A,S=this._vertices;r?this._getAffineTransform(-s,p+u,800,u,S[g+l+2],S[g+l+3],b+x,C+A,S[g],S[g+1],e._helpTransform,v,!0):this._getAffineTransform(-n,p,800,u,b,C,S[g],S[g+1],b+x,C+A,e._helpTransform,v,!1),y[m]=1,y[m+1]=v.a,y[m+2]=v.b,y[m+3]=v.c,y[m+4]=v.d,y[m+5]=v.tx,y[m+6]=v.ty}}else if(t>s){if(i<-s||i>s)return this.globalTransformMatrix;if(m=7*(2*(a*(h+1)+a+f)+((r=i>this._kX*(t-n)+p)?1:0)),this._matrixCahce[m]>0)v.copyFromArray(y,m+1);else{g=(f+1)*(l+2)-2,x=this._hullCache[4],A=this._hullCache[5],b=this._hullCache[0]+f*x,C=this._hullCache[1]+f*A,S=this._vertices;r?this._getAffineTransform(n,p+u,800,u,b+x,C+A,S[g+l+2],S[g+l+3],b,C,e._helpTransform,v,!0):this._getAffineTransform(s,p,800,u,S[g],S[g+1],b,C,S[g+l+2],S[g+l+3],e._helpTransform,v,!1),y[m]=1,y[m+1]=v.a,y[m+2]=v.b,y[m+3]=v.c,y[m+4]=v.d,y[m+5]=v.tx,y[m+6]=v.ty}}else if(i<-s){if(t<-s||t>s)return this.globalTransformMatrix;if(m=7*(a*(h+1)+2*_+((r=i>this._kY*(t-d-c)-n)?1:0)),this._matrixCahce[m]>0)v.copyFromArray(y,m+1);else{g=2*_,x=this._hullCache[10],A=this._hullCache[11],b=this._hullCache[8]+_*x,C=this._hullCache[9]+_*A,S=this._vertices;r?this._getAffineTransform(d+c,-s,c,800,S[g+2],S[g+3],S[g],S[g+1],b+x,C+A,e._helpTransform,v,!0):this._getAffineTransform(d,-n,c,800,b,C,b+x,C+A,S[g],S[g+1],e._helpTransform,v,!1),y[m]=1,y[m+1]=v.a,y[m+2]=v.b,y[m+3]=v.c,y[m+4]=v.d,y[m+5]=v.tx,y[m+6]=v.ty}}else if(i>s){if(t<-s||t>s)return this.globalTransformMatrix;if(m=7*(2*(a*(h+1)+a+h+f)+((r=i>this._kY*(t-d-c)+s)?1:0)),this._matrixCahce[m]>0)v.copyFromArray(y,m+1);else{g=h*(l+2)+2*_,x=this._hullCache[10],A=this._hullCache[11],b=this._hullCache[6]-(a-_)*x,C=this._hullCache[7]-(a-_)*A,S=this._vertices;r?this._getAffineTransform(d+c,n,c,800,b+x,C+A,b,C,S[g+2],S[g+3],e._helpTransform,v,!0):this._getAffineTransform(d,s,c,800,S[g],S[g+1],S[g+2],S[g+3],b,C,e._helpTransform,v,!1),y[m]=1,y[m+1]=v.a,y[m+2]=v.b,y[m+3]=v.c,y[m+4]=v.d,y[m+5]=v.tx,y[m+6]=v.ty}}else if(m=7*(2*(a*f+_)+((r=i>this._k*(t-d-c)+p)?1:0)),this._matrixCahce[m]>0)v.copyFromArray(y,m+1);else{g=2*_+f*(l+2),S=this._vertices;r?this._getAffineTransform(d+c,p+u,c,u,S[g+l+4],S[g+l+5],S[g+l+2],S[g+l+3],S[g+2],S[g+3],e._helpTransform,v,!0):this._getAffineTransform(d,p,c,u,S[g],S[g+1],S[g+2],S[g+3],S[g+l+2],S[g+l+3],e._helpTransform,v,!1),y[m]=1,y[m+1]=v.a,y[m+2]=v.b,y[m+3]=v.c,y[m+4]=v.d,y[m+5]=v.tx,y[m+6]=v.ty}return v},e.prototype.init=function(e){if(null===this._boneData){t.prototype.init.call(this,e);var i=e.segmentX,n=e.segmentY,r=e.vertices.length;this._dX=400/i,this._dY=400/n,this._k=-this._dY/this._dX,this._kX=-this._dY/800,this._kY=-800/this._dX,this._vertices.length=r,this._deformVertices.length=r,this._matrixCahce.length=2*(i*n+2*i+2*n)*7,this._hullCache.length=10;for(var s=0;s=0&&null!==this._cachedFrameIndices){var i=this._cachedFrameIndices[t];if(i>=0&&this._cachedFrameIndex===i)this._transformDirty=!1;else if(i>=0)this._transformDirty=!0,this._cachedFrameIndex=i;else{if(this._hasConstraint)for(var n=0,r=this._armature._constraints;n=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}}else{if(this._hasConstraint)for(var s=0,o=this._armature._constraints;s=0;this._localDirty&&this._updateGlobalTransformMatrix(c),c&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);var u=2*this.global.x,_=2*this.global.y,f=e._helpPoint;this.globalTransformMatrix.transformPoint(1e3,-200,f),this._hullCache[0]=f.x,this._hullCache[1]=f.y,this._hullCache[2]=u-f.x,this._hullCache[3]=_-f.y,this.globalTransformMatrix.transformPoint(0,this._dY,f,!0),this._hullCache[4]=f.x,this._hullCache[5]=f.y,this.globalTransformMatrix.transformPoint(200,1e3,f),this._hullCache[6]=f.x,this._hullCache[7]=f.y,this._hullCache[8]=u-f.x,this._hullCache[9]=_-f.y,this.globalTransformMatrix.transformPoint(this._dX,0,f,!0),this._hullCache[10]=f.x,this._hullCache[11]=f.y}else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0},e})(t.Bone);t.Surface=e})(n||(n={})),(function(t){var e=(function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._localMatrix=new t.Matrix,i._colorTransform=new t.ColorTransform,i._deformVertices=[],i._displayDatas=[],i._displayList=[],i._meshBones=[],i._meshSlots=[],i._rawDisplay=null,i._meshDisplay=null,i}return r(i,e),i.prototype._onClear=function(){e.prototype._onClear.call(this);for(var i=[],n=0,r=this._displayList;n=0?(null!==this._rawDisplayDatas&&null===(r=this._displayIndex=0&&m.slice(C,1)}for(u=0,_=this._deformVertices.length;u<_;++u)this._deformVertices[u]=0;this._meshDirty=!0}else this._deformVertices.length=0,this._meshBones.length=0,this._meshSlots.length=0;else null!==this._meshData&&this._textureData!==e&&(this._meshDirty=!0);this._displayDirty=!0,this._transformDirty=!0}},i.prototype._updateDisplay=function(){var e=null!==this._display?this._display:this._rawDisplay,i=this._childArmature;this._displayIndex>=0&&this._displayIndex=0&&null!==this._rawDisplayDatas){var o=this._displayIndex0)for(var a=0,h=s;a0){this._displayList.length!==e.length&&(this._displayList.length=e.length);for(var i=0,n=e.length;i0&&(this._displayList.length=0);return this._displayIndex>=0&&this._displayIndex=0&&null!==this._cachedFrameIndices){var e=this._cachedFrameIndices[t];e>=0&&this._cachedFrameIndex===e?this._transformDirty=!1:e>=0?(this._transformDirty=!0,this._cachedFrameIndex=e):this._transformDirty||this._parent._childrenTransformDirty?(this._transformDirty=!0,this._cachedFrameIndex=-1):this._cachedFrameIndex>=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}else(this._transformDirty||this._parent._childrenTransformDirty)&&(t=-1,this._transformDirty=!0,this._cachedFrameIndex=-1);if(null!==this._display){if(this._visibleDirty&&(this._visibleDirty=!1,this._updateVisible()),this._blendModeDirty&&(this._blendModeDirty=!1,this._updateBlendMode()),this._colorDirty&&(this._colorDirty=!1,this._updateColor()),null!==this._meshData&&this._display===this._meshDisplay){var i=null!==this._meshData.weight,n=0!==this._parent._boneData.type,r=null!==this._meshData.glue;if((this._meshDirty||i&&this._isMeshBonesUpdate()||n&&this._parent._childrenTransformDirty||r&&this._parent._childrenTransformDirty)&&(this._meshDirty=!1,this._updateMesh()),i||n||r)return}if(this._transformDirty){if(this._transformDirty=!1,this._cachedFrameIndex<0){var s=t>=0;this._updateGlobalTransformMatrix(s),s&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);this._updateTransform()}}},i.prototype.updateTransformAndMatrix=function(){this._transformDirty&&(this._transformDirty=!1,this._updateGlobalTransformMatrix(!1))},i.prototype.replaceDisplayData=function(t,e){if(void 0===e&&(e=-1),e<0&&(e=this._displayIndex<0?0:this._displayIndex),this._displayDatas.length<=e){this._displayDatas.length=e+1;for(var i=0,n=this._displayDatas.length;i0&&(1===h||2===h?null!==s?(this.globalTransformMatrix.transformPoint(s.x,s.y,s),null!==o&&(o.x=s.x,o.y=s.y)):null!==o&&this.globalTransformMatrix.transformPoint(o.x,o.y,o):(null!==s&&this.globalTransformMatrix.transformPoint(s.x,s.y,s),null!==o&&this.globalTransformMatrix.transformPoint(o.x,o.y,o)),null!==a&&(this.globalTransformMatrix.transformPoint(Math.cos(a.x),Math.sin(a.x),i._helpPoint,!0),a.x=Math.atan2(i._helpPoint.y,i._helpPoint.x),this.globalTransformMatrix.transformPoint(Math.cos(a.y),Math.sin(a.y),i._helpPoint,!0),a.y=Math.atan2(i._helpPoint.y,i._helpPoint.x))),h},i.prototype.invalidUpdate=function(){this._displayDirty=!0,this._transformDirty=!0},Object.defineProperty(i.prototype,"visible",{get:function(){return this._visible},set:function(t){this._visible!==t&&(this._visible=t,this._updateVisible())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){this._setDisplayIndex(t)&&this.update(-1)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._slotData.name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat(),n=new Array;this._setDisplayList(e)&&this.update(-1);for(var r=0,s=i;r0&&(this._animatebles[e-i]=r,this._animatebles[e]=null),r.advanceTime(t)):i++}if(i>0){for(n=this._animatebles.length;e=0&&(this._animatebles[e]=null,t.clock=null)},t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&_._subFadeState>0)this._armature._dragonBones.bufferObject(_),this._animationStates.length=0,this._lastAnimationState=null;else{var i=_._animationData,n=i.cacheFrameRate;if(this._animationDirty&&n>0){this._animationDirty=!1;for(var r=0,s=this._armature.getBones();r1){for(var c=0,u=0;c0&&_._subFadeState>0?(u++,this._armature._dragonBones.bufferObject(_),this._animationDirty=!0,this._lastAnimationState===_&&(this._lastAnimationState=null)):(u>0&&(this._animationStates[c-u]=_),_.advanceTime(t,0)),c===e-1&&u>0&&(this._animationStates.length-=u,null===this._lastAnimationState&&this._animationStates.length>0&&(this._lastAnimationState=this._animationStates[this._animationStates.length-1]))}this._armature._cacheFrameIndex=-1}else this._armature._cacheFrameIndex=-1},i.prototype.reset=function(){for(var t=0,e=this._animationStates;t1?(e.position<0?(e.position%=n.duration,e.position=n.duration-e.position):e.position===n.duration?e.position-=1e-6:e.position>n.duration&&(e.position%=n.duration),e.duration>0&&e.position+e.duration>n.duration&&(e.duration=n.duration-e.position),e.playTimes<0&&(e.playTimes=n.playTimes)):(e.playTimes=1,e.position=0,e.duration>0&&(e.duration=0)),0===e.duration&&(e.duration=-1),this._fadeOut(e);var a=t.BaseObject.borrowObject(t.AnimationState);if(a.init(this._armature,n,e),this._animationDirty=!0,this._armature._cacheFrameIndex=-1,this._animationStates.length>0){for(var h=!1,l=0,c=this._animationStates.length;lthis._animationStates[l].layer){h=!0,this._animationStates.splice(l,0,a);break}if(l!==c-1&&a.layer>this._animationStates[l+1].layer){h=!0,this._animationStates.splice(l+1,0,a);break}}h||this._animationStates.push(a)}else this._animationStates.push(a);for(var u=0,_=this._armature.getSlots();u<_.length;u++){var f=_[u].childArmature;null!==f&&f.inheritAnimation&&f.animation.hasAnimation(i)&&null===f.animation.getState(i)&&f.animation.fadeIn(i)}var m=!1;for(var d in n.animationTimelines){this._lockUpdate||(m=!0,this._lockUpdate=!0);var p=this.fadeIn(d,e.fadeInTime,1,a.layer,null,0);null!==p&&(p.resetToPose=!1,p._parent=a,p.stop())}return m&&(this._lockUpdate=!1),this._lockUpdate||(e.fadeInTime<=0&&this._armature.advanceTime(0),this._lastAnimationState=a),a},i.prototype.play=function(t,e){if(void 0===t&&(t=null),void 0===e&&(e=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=e,this._animationConfig.fadeInTime=0,this._animationConfig.animation=null!==t?t:"",null!==t&&t.length>0)this.playConfig(this._animationConfig);else if(null===this._lastAnimationState){var i=this._armature.armatureData.defaultAnimation;null!==i&&(this._animationConfig.animation=i.name,this.playConfig(this._animationConfig))}else this._lastAnimationState.isPlaying||this._lastAnimationState.isCompleted?(this._animationConfig.animation=this._lastAnimationState.name,this.playConfig(this._animationConfig)):this._lastAnimationState.play();return this._lastAnimationState},i.prototype.fadeIn=function(t,e,i,n,r,s){return void 0===e&&(e=-1),void 0===i&&(i=-1),void 0===n&&(n=0),void 0===r&&(r=null),void 0===s&&(s=3),this._animationConfig.clear(),this._animationConfig.fadeOutMode=s,this._animationConfig.playTimes=i,this._animationConfig.layer=n,this._animationConfig.fadeInTime=e,this._animationConfig.animation=t,this._animationConfig.group=null!==r?r:"",this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByTime=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.position=e,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t,this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByFrame=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t;var n=t in this._animations?this._animations[t]:null;return null!==n&&(this._animationConfig.position=n.duration*e/n.frameCount),this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByProgress=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t;var n=t in this._animations?this._animations[t]:null;return null!==n&&(this._animationConfig.position=n.duration*(e>0?e:0)),this.playConfig(this._animationConfig)},i.prototype.gotoAndStopByTime=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByTime(t,e,1);return null!==i&&i.stop(),i},i.prototype.gotoAndStopByFrame=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByFrame(t,e,1);return null!==i&&i.stop(),i},i.prototype.gotoAndStopByProgress=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByProgress(t,e,1);return null!==i&&i.stop(),i},i.prototype.getState=function(t){for(var e=this._animationStates.length;e--;){var i=this._animationStates[e];if(i.name===t)return i}return null},i.prototype.hasAnimation=function(t){return t in this._animations},i.prototype.getStates=function(){return this._animationStates},Object.defineProperty(i.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return null!==this._lastAnimationState?this._lastAnimationState.name:""},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations!==t){for(var e in this._animationNames.length=0,this._animations)delete this._animations[e];for(var e in t)this._animationNames.push(e),this._animations[e]=t[e]}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationConfig",{get:function(){return this._animationConfig.clear(),this._animationConfig},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:!0,configurable:!0}),i.prototype.gotoAndPlay=function(t,e,i,n,r,s,o,a,h){void 0===e&&(e=-1),void 0===i&&(i=-1),void 0===n&&(n=-1),void 0===r&&(r=0),void 0===s&&(s=null),void 0===o&&(o=3),void 0===a&&(a=!0),void 0===h&&(h=!0),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.fadeOutMode=o,this._animationConfig.playTimes=n,this._animationConfig.layer=r,this._animationConfig.fadeInTime=e,this._animationConfig.animation=t,this._animationConfig.group=null!==s?s:"";var l=this._animations[t];return l&&i>0&&(this._animationConfig.timeScale=l.duration/i),this.playConfig(this._animationConfig)},i.prototype.gotoAndStop=function(t,e){return void 0===e&&(e=0),this.gotoAndStopByTime(t,e)},Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationDataList",{get:function(){for(var t=[],e=0,i=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var n=i?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasDBEventListener(n))(r=t.BaseObject.borrowObject(t.EventObject)).type=n,r.armature=this._armature,r.animationState=this,this._armature._dragonBones.bufferEvent(r)}if(e<0&&(e=-e),this._fadeTime+=e,this._fadeTime>=this.fadeTotalTime?(this._subFadeState=1,this._fadeProgress=i?0:1):this._fadeTime>0?this._fadeProgress=i?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime:this._fadeProgress=i?1:0,this._subFadeState>0){i||(this._playheadState|=1,this._fadeState=0);var r;n=i?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasDBEventListener(n))(r=t.BaseObject.borrowObject(t.EventObject)).type=n,r.armature=this._armature,r.animationState=this,this._armature._dragonBones.bufferEvent(r)}},s.prototype.init=function(e,i,n){if(null===this._armature){if(this._armature=e,this._animationData=i,this.resetToPose=n.resetToPose,this.additiveBlending=n.additiveBlending,this.displayControl=n.displayControl,this.actionEnabled=n.actionEnabled,this.layer=n.layer,this.playTimes=n.playTimes,this.timeScale=n.timeScale,this.fadeTotalTime=n.fadeInTime,this.autoFadeOutTime=n.autoFadeOutTime,this.weight=n.weight,this.name=n.name.length>0?n.name:n.animation,this.group=n.group,n.pauseFadeIn?this._playheadState=2:this._playheadState=3,n.duration<0?(this._position=0,this._duration=this._animationData.duration,0!==n.position?this.timeScale>=0?this._time=n.position:this._time=n.position-this._duration:this._time=0):(this._position=n.position,this._duration=n.duration,this._time=0),this.timeScale<0&&0===this._time&&(this._time=-1e-6),this.fadeTotalTime<=0&&(this._fadeProgress=.999999),n.boneMask.length>0){this._boneMask.length=n.boneMask.length;for(var r=0,s=this._boneMask.length;r0,r=!0,s=!0,o=this._time;if(this._weightResult=this.weight*this._fadeProgress,null!==this._parent&&(this._weightResult*=this._parent._weightResult/this._parent._fadeProgress),this._actionTimeline.playState<=0&&this._actionTimeline.update(o),n){var a=2*i;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*a)/a}if(null!==this._zOrderTimeline&&this._zOrderTimeline.playState<=0&&this._zOrderTimeline.update(o),n){var h=Math.floor(this._actionTimeline.currentTime*i);this._armature._cacheFrameIndex===h?(r=!1,s=!1):(this._armature._cacheFrameIndex=h,this._animationData.cachedFrames[h]?s=!1:this._animationData.cachedFrames[h]=!0)}if(r){if(s)for(var l=0,c=this._boneTimelines.length;l0&&(this._subFadeState=0,this._poseTimelines.length>0)){for(var f=0,m=this._poseTimelines;f0&&this.autoFadeOutTime>=0&&this.fadeOut(this.autoFadeOutTime)}}},s.prototype.play=function(){this._playheadState=3},s.prototype.stop=function(){this._playheadState&=1},s.prototype.fadeOut=function(t,e){if(void 0===e&&(e=!0),t<0&&(t=0),e&&(this._playheadState&=2),this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime)return}else{this._fadeState=1,this._subFadeState=-1,(t<=0||this._fadeProgress<=0)&&(this._fadeProgress=1e-6);for(var i=0,n=this._boneTimelines;i1e-6?t/this._fadeProgress:0,this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)},s.prototype.containsBoneMask=function(t){return 0===this._boneMask.length||this._boneMask.indexOf(t)>=0},s.prototype.addBoneMask=function(t,e){void 0===e&&(e=!0);var i=this._armature.getBone(t);if(null!==i){if(this._boneMask.indexOf(t)<0&&this._boneMask.push(t),e)for(var n=0,r=this._armature.getBones();n=0&&this._boneMask.splice(i,1),e){var n=this._armature.getBone(t);if(null!==n){var r=this._armature.getBones();if(this._boneMask.length>0)for(var s=0,o=r;s=0&&n.contains(a)&&this._boneMask.splice(h,1)}else for(var l=0,c=r;l0},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isFadeComplete",{get:function(){return 0===this._fadeState},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isPlaying",{get:function(){return 0!=(2&this._playheadState)&&this._actionTimeline.playState<=0},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"totalTime",{get:function(){return this._duration},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if((t<0||this._duration0&&e===this.playTimes-1&&t===this._duration&&(t=this._duration-1e-6),this._time!==t){this._time=t,this._actionTimeline.setCurrentTime(this._time),null!==this._zOrderTimeline&&(this._zOrderTimeline.playState=-1);for(var i=0,n=this._boneTimelines;i0))return 0;if(this.layer!==e){if(this.layerWeight>=this.leftWeight)return this.leftWeight=0,0;this.layer=e,this.leftWeight-=this.layerWeight,this.layerWeight=0}return t*=this.leftWeight,this.layerWeight+=t,this.blendWeight=t,1}return this.dirty=!0,this.layer=e,this.layerWeight=t,this.leftWeight=1,this.blendWeight=t,-1},t.prototype.clear=function(){this.dirty=!1,this.layer=0,this.leftWeight=0,this.layerWeight=0,this.blendWeight=0},t})();t.BlendState=n})(n||(n={})),(function(t){var e=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._onClear=function(){this.playState=-1,this.currentPlayTimes=-1,this.currentTime=-1,this._tweenState=0,this._frameRate=0,this._frameValueOffset=0,this._frameCount=0,this._frameOffset=0,this._frameIndex=-1,this._frameRateR=0,this._position=0,this._duration=0,this._timeScale=1,this._timeOffset=0,this._dragonBonesData=null,this._animationData=null,this._timelineData=null,this._armature=null,this._animationState=null,this._actionTimeline=null,this._frameArray=null,this._frameIntArray=null,this._frameFloatArray=null,this._timelineArray=null,this._frameIndices=null},e.prototype._setCurrentTime=function(t){var e=this.playState,i=this.currentPlayTimes,n=this.currentTime;if(null!==this._actionTimeline&&this._frameCount<=1)this.playState=this._actionTimeline.playState>=0?1:-1,this.currentPlayTimes=1,this.currentTime=this._actionTimeline.currentTime;else if(null===this._actionTimeline||1!==this._timeScale||0!==this._timeOffset){var r=this._animationState.playTimes,s=r*this._duration;t*=this._timeScale,0!==this._timeOffset&&(t+=this._timeOffset*this._animationData.duration),r>0&&(t>=s||t<=-s)?(this.playState<=0&&3===this._animationState._playheadState&&(this.playState=1),this.currentPlayTimes=r,this.currentTime=t<0?0:this._duration+1e-6):(0!==this.playState&&3===this._animationState._playheadState&&(this.playState=0),t<0?(t=-t,this.currentPlayTimes=Math.floor(t/this._duration),this.currentTime=this._duration-t%this._duration):(this.currentPlayTimes=Math.floor(t/this._duration),this.currentTime=t%this._duration)),this.currentTime+=this._position}else this.playState=this._actionTimeline.playState,this.currentPlayTimes=this._actionTimeline.currentPlayTimes,this.currentTime=this._actionTimeline.currentTime;return(this.currentPlayTimes!==i||this.currentTime!==n)&&((e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i)&&(this._frameIndex=-1),!0)},e.prototype.init=function(t,e,i){this._armature=t,this._animationState=e,this._timelineData=i,this._actionTimeline=this._animationState._actionTimeline,this===this._actionTimeline&&(this._actionTimeline=null),this._animationData=this._animationState._animationData,this._frameRate=this._animationData.parent.frameRate,this._frameRateR=1/this._frameRate,this._position=this._animationState._position,this._duration=this._animationState._duration,this._dragonBonesData=this._animationData.parent.parent,null!==this._timelineData&&(this._frameIntArray=this._dragonBonesData.frameIntArray,this._frameFloatArray=this._dragonBonesData.frameFloatArray,this._frameArray=this._dragonBonesData.frameArray,this._timelineArray=this._dragonBonesData.timelineArray,this._frameIndices=this._dragonBonesData.frameIndices,this._frameCount=this._timelineArray[this._timelineData.offset+2],this._frameValueOffset=this._timelineArray[this._timelineData.offset+4],this._timeScale=100/this._timelineArray[this._timelineData.offset+0],this._timeOffset=.01*this._timelineArray[this._timelineData.offset+1])},e.prototype.fadeOut=function(){},e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate),i=this._frameIndices[this._timelineData.frameIndicesOffset+e];this._frameIndex!==i&&(this._frameIndex=i,this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex],this._onArriveAtFrame())}else this._frameIndex<0&&(this._frameIndex=0,null!==this._timelineData&&(this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]),this._onArriveAtFrame());0!==this._tweenState&&this._onUpdateFrame()}},e})(t.BaseObject);t.TimelineState=e;var i=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e._getEasingValue=function(t,e,i){var n=e;switch(t){case 3:n=Math.pow(e,2);break;case 4:n=1-Math.pow(1-e,2);break;case 5:n=.5*(1-Math.cos(e*Math.PI))}return(n-e)*i+e},e._getEasingCurveValue=function(t,e,i,n){if(t<=0)return 0;if(t>=1)return 1;var r=i+1,s=Math.floor(t*r),o=0===s?0:e[n+s-1];return 1e-4*(o+((s===r-1?1e4:e[n+s])-o)*(t*r-s))},e.prototype._onClear=function(){t.prototype._onClear.call(this),this._tweenType=0,this._curveCount=0,this._framePosition=0,this._frameDurationR=0,this._tweenProgress=0,this._tweenEasing=0},e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||0===this._animationState.playTimes||this._animationState.currentPlayTimes0?1/e:0}else this._tweenState=1},e.prototype._onUpdateFrame=function(){2===this._tweenState?(this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR,2===this._tweenType?this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3):1!==this._tweenType&&(this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing))):this._tweenProgress=0},e})(e);t.TweenTimelineState=i;var n=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.bone=null,this.bonePose=null},e.prototype.blend=function(t){var e=this.bone._blendState.blendWeight,i=this.bone.animationPose,n=this.bonePose.result;t>0?(i.x+=n.x*e,i.y+=n.y*e,i.rotation+=n.rotation*e,i.skew+=n.skew*e,i.scaleX+=(n.scaleX-1)*e,i.scaleY+=(n.scaleY-1)*e):1!==e?(i.x=n.x*e,i.y=n.y*e,i.rotation=n.rotation*e,i.skew=n.skew*e,i.scaleX=(n.scaleX-1)*e+1,i.scaleY=(n.scaleY-1)*e+1):(i.x=n.x,i.y=n.y,i.rotation=n.rotation,i.skew=n.skew,i.scaleX=n.scaleX,i.scaleY=n.scaleY),0===this._animationState._fadeState&&0===this._animationState._subFadeState||(this.bone._transformDirty=!0)},e})(i);t.BoneTimelineState=n;var s=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.slot=null},e})(i);t.SlotTimelineState=s;var o=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.constraint=null},e})(i);t.ConstraintTimelineState=o})(n||(n={})),(function(t){var e=(function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return r(i,e),i.toString=function(){return"[class dragonBones.ActionTimelineState]"},i.prototype._onCrossFrame=function(e){var i=this._armature.eventDispatcher;if(this._animationState.actionEnabled)for(var n=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+e],r=this._frameArray[n+1],s=this._animationData.parent.actions,o=0;o0&&s.hasDBEventListener(t.EventObject.COMPLETE)&&((l=t.BaseObject.borrowObject(t.EventObject)).type=t.EventObject.COMPLETE,l.armature=this._armature,l.animationState=this._animationState)),this._frameCount>1){var c=this._timelineData,u=Math.floor(this.currentTime*this._frameRate),_=this._frameIndices[c.frameIndicesOffset+u];if(this._frameIndex!==_){var f=this._frameIndex;if(this._frameIndex=_,null!==this._timelineArray)if(this._frameOffset=this._animationData.frameOffset+this._timelineArray[c.offset+5+this._frameIndex],a){if(f<0){var m=Math.floor(r*this._frameRate);f=this._frameIndices[c.frameIndicesOffset+m],this.currentPlayTimes===n&&f===_&&(f=-1)}for(;f>=0;){var d=this._animationData.frameOffset+this._timelineArray[c.offset+5+f],p=this._frameArray[d]/this._frameRate;if(this._position<=p&&p<=this._position+this._duration&&this._onCrossFrame(f),null!==h&&0===f&&(this._armature._dragonBones.bufferEvent(h),h=null),f>0?f--:f=this._frameCount-1,f===_)break}}else{if(f<0){m=Math.floor(r*this._frameRate);f=this._frameIndices[c.frameIndicesOffset+m];d=this._animationData.frameOffset+this._timelineArray[c.offset+5+f],p=this._frameArray[d]/this._frameRate;this.currentPlayTimes===n&&(r<=p?f>0?f--:f=this._frameCount-1:f===_&&(f=-1))}for(;f>=0;){f=0&&(this._frameArray[this._frameOffset+1]>0?this._armature._sortZOrder(this._frameArray,this._frameOffset+2):this._armature._sortZOrder(null,0))},e.prototype._onUpdateFrame=function(){},e})(t.TimelineState);t.ZOrderTimelineState=i;var n=(function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return r(i,e),i.toString=function(){return"[class dragonBones.BoneAllTimelineState]"},i.prototype._onArriveAtFrame=function(){if(e.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var t=this._animationData.frameFloatOffset+this._frameValueOffset+6*this._frameIndex,i=this._armature._armatureData.scale,n=this._frameFloatArray,r=this.bonePose.current,s=this.bonePose.delta;r.x=n[t++]*i,r.y=n[t++]*i,r.rotation=n[t++],r.skew=n[t++],r.scaleX=n[t++],r.scaleY=n[t++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(t=this._animationData.frameFloatOffset+this._frameValueOffset),s.x=n[t++]*i-r.x,s.y=n[t++]*i-r.y,s.rotation=n[t++]-r.rotation,s.skew=n[t++]-r.skew,s.scaleX=n[t++]-r.scaleX,s.scaleY=n[t++]-r.scaleY):(s.x=0,s.y=0,s.rotation=0,s.skew=0,s.scaleX=0,s.scaleY=0)}else{r=this.bonePose.current,s=this.bonePose.delta;r.x=0,r.y=0,r.rotation=0,r.skew=0,r.scaleX=1,r.scaleY=1,s.x=0,s.y=0,s.rotation=0,s.skew=0,s.scaleX=0,s.scaleY=0}},i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current,i=this.bonePose.delta,n=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),n.x=t.x+i.x*this._tweenProgress,n.y=t.y+i.y*this._tweenProgress,n.rotation=t.rotation+i.rotation*this._tweenProgress,n.skew=t.skew+i.skew*this._tweenProgress,n.scaleX=t.scaleX+i.scaleX*this._tweenProgress,n.scaleY=t.scaleY+i.scaleY*this._tweenProgress},i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation),e.skew=t.Transform.normalizeRadian(e.skew)},i})(t.BoneTimelineState);t.BoneAllTimelineState=n;var s=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,i=this._armature._armatureData.scale,n=this._frameFloatArray,r=this.bonePose.current,s=this.bonePose.delta;r.x=n[e++]*i,r.y=n[e++]*i,2===this._tweenState?(this._frameIndex===this._frameCount-1&&(e=this._animationData.frameFloatOffset+this._frameValueOffset),s.x=n[e++]*i-r.x,s.y=n[e++]*i-r.y):(s.x=0,s.y=0)}else{r=this.bonePose.current,s=this.bonePose.delta;r.x=0,r.y=0,s.x=0,s.y=0}},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current,i=this.bonePose.delta,n=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),n.x=e.x+i.x*this._tweenProgress,n.y=e.y+i.y*this._tweenProgress},e})(t.BoneTimelineState);t.BoneTranslateTimelineState=s;var o=(function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return r(i,e),i.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"},i.prototype._onArriveAtFrame=function(){if(e.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var t=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,i=this._frameFloatArray,n=this.bonePose.current,r=this.bonePose.delta;n.rotation=i[t++],n.skew=i[t++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(t=this._animationData.frameFloatOffset+this._frameValueOffset),r.rotation=i[t++]-n.rotation,r.skew=i[t++]-n.skew):(r.rotation=0,r.skew=0)}else{n=this.bonePose.current,r=this.bonePose.delta;n.rotation=0,n.skew=0,r.rotation=0,r.skew=0}},i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current,i=this.bonePose.delta,n=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),n.rotation=t.rotation+i.rotation*this._tweenProgress,n.skew=t.skew+i.skew*this._tweenProgress},i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation),e.skew=t.Transform.normalizeRadian(e.skew)},i})(t.BoneTimelineState);t.BoneRotateTimelineState=o;var a=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,i=this._frameFloatArray,n=this.bonePose.current,r=this.bonePose.delta;n.scaleX=i[e++],n.scaleY=i[e++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(e=this._animationData.frameFloatOffset+this._frameValueOffset),r.scaleX=i[e++]-n.scaleX,r.scaleY=i[e++]-n.scaleY):(r.scaleX=0,r.scaleY=0)}else{n=this.bonePose.current,r=this.bonePose.delta;n.scaleX=1,n.scaleY=1,r.scaleX=0,r.scaleY=0}},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current,i=this.bonePose.delta,n=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),n.scaleX=e.scaleX+i.scaleX*this._tweenProgress,n.scaleY=e.scaleY+i.scaleY*this._tweenProgress},e})(t.BoneTimelineState);t.BoneScaleTimelineState=a;var h=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[],e._delta=[],e._result=[],e}return r(e,t),e.toString=function(){return"[class dragonBones.SurfaceTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.surface=null,this._frameFloatOffset=0,this._valueCount=0,this._deformCount=0,this._valueOffset=0,this._current.length=0,this._delta.length=0,this._result.length=0},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount,i=this._armature._armatureData.scale,n=this._frameFloatArray;if(2===this._tweenState){var r=e+this._valueCount;this._frameIndex===this._frameCount-1&&(r=this._animationData.frameFloatOffset+this._frameValueOffset);for(var s=0;s0?i[n]+=r*e:i[n]=1!==e?r*e:r}0===this._animationState._fadeState&&0===this._animationState._subFadeState||(this.surface._transformDirty=!0)},e})(t.TweenTimelineState);t.SurfaceTimelineState=h;var l=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.toString=function(){return"[class dragonBones.SlotDislayTimelineState]"},e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=null!==this._timelineData?this._frameArray[this._frameOffset+1]:this.slot._slotData.displayIndex;this.slot.displayIndex!==t&&this.slot._setDisplayIndex(t,!0)}},e})(t.SlotTimelineState);t.SlotDislayTimelineState=l;var c=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[0,0,0,0,0,0,0,0],e._delta=[0,0,0,0,0,0,0,0],e._result=[0,0,0,0,0,0,0,0],e}return r(e,t),e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this._dirty=!1},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._dragonBonesData.intArray,i=this._frameIntArray,n=this._animationData.frameIntOffset+this._frameValueOffset+1*this._frameIndex,r=i[n];r<0&&(r+=65536),this._current[0]=e[r++],this._current[1]=e[r++],this._current[2]=e[r++],this._current[3]=e[r++],this._current[4]=e[r++],this._current[5]=e[r++],this._current[6]=e[r++],this._current[7]=e[r++],2===this._tweenState&&((r=this._frameIndex===this._frameCount-1?i[this._animationData.frameIntOffset+this._frameValueOffset]:i[n+1])<0&&(r+=65536),this._delta[0]=e[r++]-this._current[0],this._delta[1]=e[r++]-this._current[1],this._delta[2]=e[r++]-this._current[2],this._delta[3]=e[r++]-this._current[3],this._delta[4]=e[r++]-this._current[4],this._delta[5]=e[r++]-this._current[5],this._delta[6]=e[r++]-this._current[6],this._delta[7]=e[r++]-this._current[7])}else{var s=this.slot._slotData.color;this._current[0]=100*s.alphaMultiplier,this._current[1]=100*s.redMultiplier,this._current[2]=100*s.greenMultiplier,this._current[3]=100*s.blueMultiplier,this._current[4]=s.alphaOffset,this._current[5]=s.redOffset,this._current[6]=s.greenOffset,this._current[7]=s.blueOffset}},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this),this._dirty=!0,2!==this._tweenState&&(this._tweenState=0),this._result[0]=.01*(this._current[0]+this._delta[0]*this._tweenProgress),this._result[1]=.01*(this._current[1]+this._delta[1]*this._tweenProgress),this._result[2]=.01*(this._current[2]+this._delta[2]*this._tweenProgress),this._result[3]=.01*(this._current[3]+this._delta[3]*this._tweenProgress),this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress,this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress,this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress,this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress},e.prototype.fadeOut=function(){this._tweenState=0,this._dirty=!1},e.prototype.update=function(e){if(t.prototype.update.call(this,e),0!==this._tweenState||this._dirty){var i=this.slot._colorTransform;if(0!==this._animationState._fadeState||0!==this._animationState._subFadeState){if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){var n=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*n,i.redMultiplier+=(this._result[1]-i.redMultiplier)*n,i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*n,i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*n,i.alphaOffset+=(this._result[4]-i.alphaOffset)*n,i.redOffset+=(this._result[5]-i.redOffset)*n,i.greenOffset+=(this._result[6]-i.greenOffset)*n,i.blueOffset+=(this._result[7]-i.blueOffset)*n,this.slot._colorDirty=!0}}else this._dirty&&(this._dirty=!1,i.alphaMultiplier===this._result[0]&&i.redMultiplier===this._result[1]&&i.greenMultiplier===this._result[2]&&i.blueMultiplier===this._result[3]&&i.alphaOffset===this._result[4]&&i.redOffset===this._result[5]&&i.greenOffset===this._result[6]&&i.blueOffset===this._result[7]||(i.alphaMultiplier=this._result[0],i.redMultiplier=this._result[1],i.greenMultiplier=this._result[2],i.blueMultiplier=this._result[3],i.alphaOffset=this._result[4],i.redOffset=this._result[5],i.greenOffset=this._result[6],i.blueOffset=this._result[7],this.slot._colorDirty=!0))}},e})(t.SlotTimelineState);t.SlotColorTimelineState=c;var u=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[],e._delta=[],e._result=[],e}return r(e,t),e.toString=function(){return"[class dragonBones.SlotFFDTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.meshOffset=0,this._dirty=!1,this._frameFloatOffset=0,this._valueCount=0,this._deformCount=0,this._valueOffset=0,this._current.length=0,this._delta.length=0,this._result.length=0},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount,i=this._armature._armatureData.scale,n=this._frameFloatArray;if(2===this._tweenState){var r=e+this._valueCount;this._frameIndex===this._frameCount-1&&(r=this._animationData.frameFloatOffset+this._frameValueOffset);for(var s=0;s=0&&(this._floats[2]=this._floats[0]+this._floats[1]*this._tweenProgress),this._floats[5]=this._floats[3]+this._floats[4]*this._tweenProgress},e.prototype.blend=function(t){var e=this.animationState,i=e._blendState.blendWeight;t>0?(e.weight+=this._floats[5]*i,e.currentTime+=this._floats[2]*i):(e.weight=this._floats[5]*i,e.currentTime=this._floats[2]*i)},e})(t.TweenTimelineState);t.AnimationTimelineState=f})(n||(n={})),(function(t){var e=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.toString=function(){return"[class dragonBones.EventObject]"},e.prototype._onClear=function(){this.time=0,this.type="",this.name="",this.armature=null,this.bone=null,this.slot=null,this.animationState=null,this.data=null},e.START="start",e.LOOP_COMPLETE="loopComplete",e.COMPLETE="complete",e.FADE_IN="fadeIn",e.FADE_IN_COMPLETE="fadeInComplete",e.FADE_OUT="fadeOut",e.FADE_OUT_COMPLETE="fadeOutComplete",e.FRAME_EVENT="frameEvent",e.SOUND_EVENT="soundEvent",e})(t.BaseObject);t.EventObject=e})(n||(n={})),(function(t){var e=(function(){function e(){}return e._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}},e._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}},e._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;default:return 0}},e._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}},e._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}},e._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}},e.parseDragonBonesData=function(e){return e instanceof ArrayBuffer?t.BinaryDataParser.getInstance().parseDragonBonesData(e):t.ObjectDataParser.getInstance().parseDragonBonesData(e)},e.parseTextureAtlasData=function(i,n){void 0===n&&(n=1),console.warn("\u5df2\u5e9f\u5f03");for(var r={},s=i[e.SUB_TEXTURE],o=0,a=s.length;o255)return encodeURI(r);return r}return String(r)}return n},n.prototype._getCurvePoint=function(t,e,i,n,r,s,o,a,h,l){var c=1-h,u=c*c,_=h*h,f=c*u,m=3*h*u,d=3*c*_,p=h*_;l.x=f*t+m*i+d*r+p*o,l.y=f*e+m*n+d*s+p*a},n.prototype._samplingEasingCurve=function(t,e){for(var i=t.length,n=-2,r=0,s=e.length;r=0&&n+61e-4;){var v=.5*(y+p);this._getCurvePoint(h,l,c,u,_,f,m,d,v,this._helpPoint),o-this._helpPoint.x>0?p=v:y=v}e[r]=this._helpPoint.y}},n.prototype._parseActionDataInFrame=function(e,i,n,r){t.DataParser.EVENT in e&&this._mergeActionFrame(e[t.DataParser.EVENT],i,10,n,r),t.DataParser.SOUND in e&&this._mergeActionFrame(e[t.DataParser.SOUND],i,11,n,r),t.DataParser.ACTION in e&&this._mergeActionFrame(e[t.DataParser.ACTION],i,0,n,r),t.DataParser.EVENTS in e&&this._mergeActionFrame(e[t.DataParser.EVENTS],i,10,n,r),t.DataParser.ACTIONS in e&&this._mergeActionFrame(e[t.DataParser.ACTIONS],i,0,n,r)},n.prototype._mergeActionFrame=function(e,n,r,s,o){for(var a=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length,h=this._parseActionData(e,r,s,o),l=0,c=null,u=0,_=h;u<_.length;u++){var f=_[u];this._armature.addAction(f,!1)}0===this._actionFrames.length&&((c=new i).frameStart=0,this._actionFrames.push(c),c=null);for(var m=0,d=this._actionFrames;mn)break;l++}null===c&&((c=new i).frameStart=n,this._actionFrames.splice(l+1,0,c));for(var y=0;y0){var f=r.getBone(u);null!==f?_.parent=f:(u in this._cacheBones||(this._cacheBones[u]=[]),this._cacheBones[u].push(_))}if(_.name in this._cacheBones){for(var m=0,d=this._cacheBones[_.name];m0&&null!==i.parent?(s.root=i.parent,s.bone=i):(s.root=i,s.bone=null),s},n.prototype._parseSlot=function(e,i){var r=t.BaseObject.borrowObject(t.SlotData);return r.displayIndex=n._getNumber(e,t.DataParser.DISPLAY_INDEX,0),r.zOrder=i,r.name=n._getString(e,t.DataParser.NAME,""),r.parent=this._armature.getBone(n._getString(e,t.DataParser.PARENT,"")),t.DataParser.BLEND_MODE in e&&"string"==typeof e[t.DataParser.BLEND_MODE]?r.blendMode=t.DataParser._getBlendMode(e[t.DataParser.BLEND_MODE]):r.blendMode=n._getNumber(e,t.DataParser.BLEND_MODE,0),t.DataParser.COLOR in e?(r.color=t.SlotData.createColor(),this._parseColorTransform(e[t.DataParser.COLOR],r.color)):r.color=t.SlotData.DEFAULT_COLOR,t.DataParser.ACTIONS in e&&(this._slotChildActions[r.name]=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null)),r},n.prototype._parseSkin=function(e){var i=t.BaseObject.borrowObject(t.SkinData);if(i.name=n._getString(e,t.DataParser.NAME,t.DataParser.DEFAULT_NAME),0===i.name.length&&(i.name=t.DataParser.DEFAULT_NAME),t.DataParser.SLOT in e){var r=e[t.DataParser.SLOT];this._skin=i;for(var s=0,o=r;s0?r:i,this._parsePivot(e,a);break;case 1:var h=o=t.BaseObject.borrowObject(t.ArmatureDisplayData);if(h.name=i,h.path=r.length>0?r:i,h.inheritAnimation=!0,t.DataParser.ACTIONS in e)for(var l=0,c=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null);l0?r:i,t.DataParser.SHARE in e?(this._cacheRawMeshes.push(e),this._cacheRawMeshes.push(d)):this._parseMesh(e,d),t.DataParser.GLUE_WEIGHTS in e&&t.DataParser.GLUE_MESHES in e&&(this._cacheRawMeshes.push(e),this._cacheRawMeshes.push(d));break;case 3:var p=this._parseBoundingBox(e);if(null!==p){var y=o=t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=i,y.path=r.length>0?r:i,y.boundingBox=p}}return null!==o&&t.DataParser.TRANSFORM in e&&this._parseTransform(e[t.DataParser.TRANSFORM],o.transform,this._armature.scale),o},n.prototype._parsePivot=function(e,i){if(t.DataParser.PIVOT in e){var r=e[t.DataParser.PIVOT];i.pivot.x=n._getNumber(r,t.DataParser.X,0),i.pivot.y=n._getNumber(r,t.DataParser.Y,0)}else i.pivot.x=.5,i.pivot.y=.5},n.prototype._parseMesh=function(e,i){var n=e[t.DataParser.VERTICES],r=e[t.DataParser.UVS],s=e[t.DataParser.TRIANGLES],o=Math.floor(n.length/2),a=Math.floor(s.length/3),h=this._floatArray.length,l=h+2*o,c=this._intArray.length,u=this._skin.name+"_"+this._slot.name+"_"+i.name;i.offset=c,this._intArray.length+=4+3*a,this._intArray[c+0]=o,this._intArray[c+1]=a,this._intArray[c+2]=h;for(var _=0,f=3*a;_i.width&&(i.width=h),li.height&&(i.height=l))}i.width-=i.x,i.height-=i.y}else console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.");return i},n.prototype._parseAnimation=function(e){var i=t.BaseObject.borrowObject(t.AnimationData);if(i.frameCount=Math.max(n._getNumber(e,t.DataParser.DURATION,1),1),i.playTimes=n._getNumber(e,t.DataParser.PLAY_TIMES,1),i.duration=i.frameCount/this._armature.frameRate,i.fadeInTime=n._getNumber(e,t.DataParser.FADE_IN_TIME,0),i.scale=n._getNumber(e,t.DataParser.SCALE,1),i.name=n._getString(e,t.DataParser.NAME,t.DataParser.DEFAULT_NAME),0===i.name.length&&(i.name=t.DataParser.DEFAULT_NAME),i.frameIntOffset=this._frameIntArray.length,i.frameFloatOffset=this._frameFloatArray.length,i.frameOffset=this._frameArray.length,this._animation=i,t.DataParser.FRAME in e){var r=e[t.DataParser.FRAME],s=r.length;if(s>0)for(var o=0,a=0;o0&&(this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,!1,!1,0,this._parseActionFrame),this._actionFrames.length=0),this._animation=null,i},n.prototype._parseTimeline=function(e,r,s,o,a,h,l,c){if(null!==e&&s.length>0&&s in e&&(r=e[s]),null===r)return null;var u=r.length;if(0===u)return null;var _=this._frameIntArray.length,f=this._frameFloatArray.length,m=t.BaseObject.borrowObject(t.TimelineData),d=this._timelineArray.length;if(this._timelineArray.length+=5+u,null!==e?(this._timelineArray[d+0]=Math.round(100*n._getNumber(e,t.DataParser.SCALE,1)),this._timelineArray[d+1]=Math.round(100*n._getNumber(e,t.DataParser.OFFSET,0))):(this._timelineArray[d+0]=100,this._timelineArray[d+1]=0),this._timelineArray[d+2]=u,this._timelineArray[d+3]=l,this._timelineArray[d+4]=a?_-this._animation.frameIntOffset:h?f-this._animation.frameFloatOffset:0,this._timeline=m,m.type=o,m.offset=d,1===u)m.frameIndicesOffset=-1,this._timelineArray[d+5+0]=c.call(this,r[0],0,0)-this._animation.frameOffset;else{var p=this._animation.frameCount+1,y=this._data.frameIndices,v=0;t.DragonBones.webAssembly?(v=y.size(),y.resize(v+p,0)):(v=y.length,y.length+=p),m.frameIndicesOffset=v;for(var g=0,x=0,A=0,b=0;g0)if(t.DataParser.CURVE in e){var o=r+1;this._helpArray.length=o,this._samplingEasingCurve(e[t.DataParser.CURVE],this._helpArray),this._frameArray.length+=2+this._helpArray.length,this._frameArray[s+1]=2,this._frameArray[s+2]=o;for(var a=0;a0){for(var o=this._armature.sortedSlots.length,a=new Array(o-s.length/2),h=new Array(o),l=0;l0?s>=this._prevRotation:s<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),s=this._prevRotation+s-this._prevRotation+t.Transform.PI_D*this._prevClockwise)),this._prevClockwise=n._getNumber(e,t.DataParser.TWEEN_ROTATE,0),this._prevRotation=s;var o=this._parseTweenFrame(e,i,r),a=this._frameFloatArray.length;return this._frameFloatArray.length+=6,this._frameFloatArray[a++]=this._helpTransform.x,this._frameFloatArray[a++]=this._helpTransform.y,this._frameFloatArray[a++]=s,this._frameFloatArray[a++]=this._helpTransform.skew,this._frameFloatArray[a++]=this._helpTransform.scaleX,this._frameFloatArray[a++]=this._helpTransform.scaleY,this._parseActionDataInFrame(e,i,this._bone,this._slot),o},n.prototype._parseBoneTranslateFrame=function(e,i,r){var s=this._parseTweenFrame(e,i,r),o=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[o++]=n._getNumber(e,t.DataParser.X,0),this._frameFloatArray[o++]=n._getNumber(e,t.DataParser.Y,0),s},n.prototype._parseBoneRotateFrame=function(e,i,r){var s=n._getNumber(e,t.DataParser.ROTATE,0)*t.Transform.DEG_RAD;0!==i&&(0===this._prevClockwise?s=this._prevRotation+t.Transform.normalizeRadian(s-this._prevRotation):((this._prevClockwise>0?s>=this._prevRotation:s<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),s=this._prevRotation+s-this._prevRotation+t.Transform.PI_D*this._prevClockwise)),this._prevClockwise=n._getNumber(e,t.DataParser.CLOCK_WISE,0),this._prevRotation=s;var o=this._parseTweenFrame(e,i,r),a=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[a++]=s,this._frameFloatArray[a++]=n._getNumber(e,t.DataParser.SKEW,0)*t.Transform.DEG_RAD,o},n.prototype._parseBoneScaleFrame=function(e,i,r){var s=this._parseTweenFrame(e,i,r),o=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[o++]=n._getNumber(e,t.DataParser.X,1),this._frameFloatArray[o++]=n._getNumber(e,t.DataParser.Y,1),s},n.prototype._parseSurfaceFrame=function(e,i,r){var s=this._frameFloatArray.length,o=this._parseTweenFrame(e,i,r),a=e[t.DataParser.VERTICES],h=n._getNumber(e,t.DataParser.OFFSET,0),l=this._surface.vertices.length/2,c=0,u=0;this._frameFloatArray.length+=2*l;for(var _=0;_<2*l;_+=2)c=_=a.length?0:a[_-h],u=_+1=a.length?0:a[_+1-h],this._frameFloatArray[s+_]=c,this._frameFloatArray[s+_+1]=u;if(0===i){var f=this._frameIntArray.length;this._frameIntArray.length+=5,this._frameIntArray[f+0]=0,this._frameIntArray[f+1]=this._frameFloatArray.length-s,this._frameIntArray[f+2]=this._frameFloatArray.length-s,this._frameIntArray[f+3]=0,this._frameIntArray[f+4]=s-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+3]=f-this._animation.frameIntOffset}return o},n.prototype._parseSlotDisplayFrame=function(e,i,r){var s=this._parseFrame(e,i,r);return this._frameArray.length+=1,t.DataParser.VALUE in e?this._frameArray[s+1]=n._getNumber(e,t.DataParser.VALUE,0):this._frameArray[s+1]=n._getNumber(e,t.DataParser.DISPLAY_INDEX,0),this._parseActionDataInFrame(e,i,this._slot.parent,this._slot),s},n.prototype._parseSlotColorFrame=function(e,i,n){var r=this._parseTweenFrame(e,i,n),s=-1;if(t.DataParser.VALUE in e||t.DataParser.COLOR in e){var o=t.DataParser.VALUE in e?e[t.DataParser.VALUE]:e[t.DataParser.COLOR];for(var a in o){this._parseColorTransform(o,this._helpColorTransform),s=this._intArray.length,this._intArray.length+=8,this._intArray[s++]=Math.round(100*this._helpColorTransform.alphaMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.redMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.greenMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.blueMultiplier),this._intArray[s++]=Math.round(this._helpColorTransform.alphaOffset),this._intArray[s++]=Math.round(this._helpColorTransform.redOffset),this._intArray[s++]=Math.round(this._helpColorTransform.greenOffset),this._intArray[s++]=Math.round(this._helpColorTransform.blueOffset),s-=8;break}}s<0&&(this._defaultColorOffset<0&&(this._defaultColorOffset=s=this._intArray.length,this._intArray.length+=8,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=0,this._intArray[s++]=0,this._intArray[s++]=0,this._intArray[s++]=0),s=this._defaultColorOffset);var h=this._frameIntArray.length;return this._frameIntArray.length+=1,this._frameIntArray[h]=s,r},n.prototype._parseSlotFFDFrame=function(e,i,r){var s=this._frameFloatArray.length,o=this._parseTweenFrame(e,i,r),a=t.DataParser.VERTICES in e?e[t.DataParser.VERTICES]:null,h=n._getNumber(e,t.DataParser.OFFSET,0),l=this._intArray[this._mesh.offset+0],c=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name,u=0,_=0,f=0,m=0;if(null!==this._mesh.weight){var d=this._weightSlotPose[c];this._helpMatrixA.copyFromArray(d,0),this._frameFloatArray.length+=2*this._mesh.weight.count,f=this._mesh.weight.offset+2+this._mesh.weight.bones.length}else this._frameFloatArray.length+=2*l;for(var p=0;p<2*l;p+=2)if(null===a?(u=0,_=0):(u=p=a.length?0:a[p-h],_=p+1=a.length?0:a[p+1-h]),null!==this._mesh.weight){var y=this._weightBonePoses[c],v=this._intArray[f++];this._helpMatrixA.transformPoint(u,_,this._helpPoint,!0),u=this._helpPoint.x,_=this._helpPoint.y;for(var g=0;g=0||t.DataParser.DATA_VERSIONS.indexOf(s)>=0){var o=t.BaseObject.borrowObject(t.DragonBonesData);if(o.version=r,o.name=n._getString(e,t.DataParser.NAME,""),o.frameRate=n._getNumber(e,t.DataParser.FRAME_RATE,24),0===o.frameRate&&(o.frameRate=24),t.DataParser.ARMATURE in e){this._data=o,this._parseArray(e);for(var a=0,h=e[t.DataParser.ARMATURE];a0&&(o.stage=o.getArmature(o.armatureNames[0])),this._data=null}return t.DataParser.TEXTURE_ATLAS in e&&(this._rawTextureAtlases=e[t.DataParser.TEXTURE_ATLAS]),o}return console.assert(!1,"Nonsupport data version: "+r+"\nPlease convert DragonBones data to support version.\nRead more: https://github.com/DragonBones/Tools/"),null},n.prototype.parseTextureAtlasData=function(e,i,r){if(void 0===r&&(r=1),console.assert(void 0!==e),null===e){if(null===this._rawTextureAtlases||0===this._rawTextureAtlases.length)return!1;var s=this._rawTextureAtlases[this._rawTextureAtlasIndex++];return this.parseTextureAtlasData(s,i,r),this._rawTextureAtlasIndex>=this._rawTextureAtlases.length&&(this._rawTextureAtlasIndex=0,this._rawTextureAtlases=null),!0}if(i.width=n._getNumber(e,t.DataParser.WIDTH,0),i.height=n._getNumber(e,t.DataParser.HEIGHT,0),i.scale=1===r?1/n._getNumber(e,t.DataParser.SCALE,1):r,i.name=n._getString(e,t.DataParser.NAME,""),i.imagePath=n._getString(e,t.DataParser.IMAGE_PATH,""),t.DataParser.SUB_TEXTURE in e)for(var o=e[t.DataParser.SUB_TEXTURE],a=0,h=o.length;a0&&_>0&&(c.frame=t.TextureData.createRectangle(),c.frame.x=n._getNumber(l,t.DataParser.FRAME_X,0),c.frame.y=n._getNumber(l,t.DataParser.FRAME_Y,0),c.frame.width=u,c.frame.height=_),i.addTexture(c)}return!0},n.getInstance=function(){return null===n._objectDataParserInstance&&(n._objectDataParserInstance=new n),n._objectDataParserInstance},n._objectDataParserInstance=null,n})(t.DataParser);t.ObjectDataParser=e;var i=(function(){return function(){this.frameStart=0,this.actions=[]}})();t.ActionFrame=i})(n||(n={})),(function(t){var e=(function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return r(i,e),i.prototype._inRange=function(t,e,i){return e<=t&&t<=i},i.prototype._decodeUTF8=function(t){for(var e,i=0,n="",r=0,s=0,o=0,a=0;t.length>i;){var h=t[i++];if(-1===h)e=0!==s?65533:-1;else if(0===s)this._inRange(h,0,127)?e=h:(this._inRange(h,194,223)?(s=1,a=128,r=h-192):this._inRange(h,224,239)?(s=2,a=2048,r=h-224):this._inRange(h,240,244)&&(s=3,a=65536,r=h-240),r*=Math.pow(64,s),e=null);else if(this._inRange(h,128,191))if(o+=1,r+=(h-128)*Math.pow(64,s-o),o!==s)e=null;else{var l=r,c=a;r=0,s=0,o=0,a=0,e=this._inRange(l,c,1114111)&&!this._inRange(l,55296,57343)?l:h}else r=0,s=0,o=0,a=0,i--,e=h;null!==e&&-1!==e&&(e<=65535?e>0&&(n+=String.fromCharCode(e)):(e-=65536,n+=String.fromCharCode(55296+(e>>10&1023)),n+=String.fromCharCode(56320+(1023&e))))}return n},i.prototype._getUTF16Key=function(t){for(var e=0,i=t.length;e255)return encodeURI(t);return t},i.prototype._parseBinaryTimeline=function(e,i,n){void 0===n&&(n=null);var r=null!==n?n:t.BaseObject.borrowObject(t.TimelineData);r.type=e,r.offset=i,this._timeline=r;var s=this._timelineArrayBuffer[r.offset+2];if(1===s)r.frameIndicesOffset=-1;else{var o=0,a=this._animation.frameCount+1,h=this._data.frameIndices;t.DragonBones.webAssembly?(o=h.size(),h.resize(o+a,0)):(o=h.length,h.length+=a),r.frameIndicesOffset=o;for(var l=0,c=0,u=0,_=0;l=0){var r=t.BaseObject.borrowObject(t.WeightData),s=this._intArrayBuffer[i.offset+0],o=this._intArrayBuffer[n+0];r.offset=n;for(var a=0;a0&&e in this._dragonBonesDataMap&&(o=(s=this._dragonBonesDataMap[e]).getArmature(i)),null===o&&(0===e.length||this.autoSearch))for(var a in this._dragonBonesDataMap)if(s=this._dragonBonesDataMap[a],(0===e.length||s.autoSearch)&&null!==(o=s.getArmature(i))){e=a;break}if(null!==o){if(t.dataName=e,t.textureAtlasName=r,t.data=s,t.armature=o,t.skin=null,n.length>0&&(t.skin=o.getSkin(n),null===t.skin&&this.autoSearch))for(var a in this._dragonBonesDataMap){var h=this._dragonBonesDataMap[a].getArmature(n);if(null!==h){t.skin=h.defaultSkin;break}}return null===t.skin&&(t.skin=o.defaultSkin),!0}return!1},e.prototype._buildBones=function(e,i){for(var n=0,r=e.armature.sortedBones;n0&&(o.texture=this._getTextureData(t.textureAtlasName,e.path)),s=null!==i&&2===i.type&&this._isSupportMesh()?n.meshDisplay:n.rawDisplay;break;case 2:var a=e;null===a.texture?a.texture=this._getTextureData(r,a.path):null!==t&&t.textureAtlasName.length>0&&(a.texture=this._getTextureData(t.textureAtlasName,a.path)),s=this._isSupportMesh()?n.meshDisplay:n.rawDisplay;break;case 1:var h=e,l=this._buildChildArmature(t,n,e);if(null!==l){if(l.inheritAnimation=h.inheritAnimation,!l.inheritAnimation){var c=h.actions.length>0?h.actions:l.armatureData.defaultActions;if(c.length>0)for(var u=0,_=c;u<_.length;u++){var f=_[u];l._bufferAction(f,!0)}else l.animation.play()}h.armature=l.armatureData}s=l}return s},e.prototype.parseDragonBonesData=function(t,i,n){void 0===i&&(i=null),void 0===n&&(n=1);for(var r=t instanceof ArrayBuffer?e._binaryParser:this._dataParser,s=r.parseDragonBonesData(t,n);;){var o=this._buildTextureAtlasData(null,null);if(!r.parseTextureAtlasData(null,o,n)){o.returnToPool();break}this.addTextureAtlasData(o,i)}return null!==s&&this.addDragonBonesData(s,i),s},e.prototype.parseTextureAtlasData=function(t,e,i,n){void 0===i&&(i=null),void 0===n&&(n=1);var r=this._buildTextureAtlasData(null,null);return this._dataParser.parseTextureAtlasData(t,r,n),this._buildTextureAtlasData(r,e||null),this.addTextureAtlasData(r,i),r},e.prototype.updateTextureAtlasData=function(t,e){var i=this.getTextureAtlasData(t);if(null!==i)for(var n=0,r=i.length;n=0)){var c=i.getDisplays(l.name);if(c||(null!==o&&i!==o&&(c=o.getDisplays(l.name)),c)){var u=t.DragonBones.webAssembly?c.size():c.length,_=l.displayList;_.length=u;for(var f=0,m=u;f>2,f=n.indiceOffset,c=n.vertexOffset,n.request(r.vertexCount,r.indiceCount),h=n._vData,l=n._uintVData,u=n._iData;var a=t.node,T=a.color;x=T.r/255,A=T.g/255,b=T.b/255,C=T.a/255,S=a._worldMatrix,m=S.m00,d=S.m01,p=S.m04,y=S.m05,v=S.m12,g=S.m13,this.fillIndexBufferWithArmature(i),this.fillVertexBufferWithArmature(i),t.node._renderFlag|=s.FLAG_UPDATE_RENDER_DATA,S=u=h=l=null}},fillVertexBufferWithArmature:function(t){for(var e=t._slots,i=0,n=e.length;i>>0)+(T<<16)+(f<<8)+u,E=0,D=o.length;E":0});sp.Skeleton=cc.Class({name:"sp.Skeleton",extends:r,editor:!1,properties:{paused:{default:!1,visible:!1},skeletonData:{default:null,type:sp.SkeletonData,notify:function(){this.defaultSkin="",this.defaultAnimation="",this._updateSkeletonData()},tooltip:!1},defaultSkin:{default:"",visible:!1},defaultAnimation:{default:"",visible:!1},animation:{get:function(){var t=this.getCurrent(0);return t&&t.animation.name||""},set:function(t){this.defaultAnimation=t,t?this.setAnimation(0,t,this.loop):(this.clearTrack(0),this.setToSetupPose())},visible:!1},_defaultSkinIndex:{get:function(){if(this.skeletonData&&this.defaultSkin){var t=this.skeletonData.getSkinsEnum();if(t){var e=t[this.defaultSkin];if(void 0!==e)return e}}return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getSkinsEnum()),!e)return cc.errorID("",this.name);var i=e[t];void 0!==i?this.defaultSkin=i:cc.errorID(7501,this.name)},type:h,visible:!0,displayName:"Default Skin",tooltip:!1},_animationIndex:{get:function(){var t=this.animation;if(this.skeletonData&&t){var e=this.skeletonData.getAnimsEnum();if(e){var i=e[t];if(void 0!==i)return i}}return 0},set:function(t){if(0!==t){var e;if(this.skeletonData&&(e=this.skeletonData.getAnimsEnum()),!e)return cc.errorID(7502,this.name);var i=e[t];void 0!==i?this.animation=i:cc.errorID(7503,this.name)}else this.animation=""},type:l,visible:!0,displayName:"Animation",tooltip:!1},loop:{default:!0,tooltip:!1},premultipliedAlpha:{default:!0,tooltip:!1},timeScale:{default:1,tooltip:!1},debugSlots:{default:!1,editorOnly:!0,tooltip:!1,notify:function(){this._initDebugDraw()}},debugBones:{default:!1,editorOnly:!0,tooltip:!1,notify:function(){this._initDebugDraw()}}},ctor:function(){this._skeleton=null,this._rootBone=null,this._listener=null,this._boundingBox=cc.rect(),this._material=new o,this._renderDatas=[],this._debugRenderer=null},setSkeletonData:function(t){null!=t.width&&null!=t.height&&this.node.setContentSize(t.width,t.height),this._skeleton=new s.Skeleton(t),this._rootBone=this._skeleton.getRootBone()},setAnimationStateData:function(t){var e=new s.AnimationState(t);this._listener&&(this._state&&this._state.removeListener(this._listener),e.addListener(this._listener)),this._state=e},__preload:function(){this._updateSkeletonData()},update:function(t){var e=this._skeleton,i=this._state;e&&(e.update(t),i&&(t*=this.timeScale,i.update(t),i.apply(e)))},onRestore:function(){this._material||(this._boundingBox=cc.rect(),this._material=new o,this._renderDatas=[])},onDestroy:function(){this._super(),this._renderDatas.length=0},updateWorldTransform:function(){this._skeleton&&this._skeleton.updateWorldTransform()},setToSetupPose:function(){this._skeleton&&this._skeleton.setToSetupPose()},setBonesToSetupPose:function(){this._skeleton&&this._skeleton.setBonesToSetupPose()},setSlotsToSetupPose:function(){this._skeleton&&this._skeleton.setSlotsToSetupPose()},findBone:function(t){return this._skeleton?this._skeleton.findBone(t):null},findSlot:function(t){return this._skeleton?this._skeleton.findSlot(t):null},setSkin:function(t){return this._skeleton?this._skeleton.setSkinByName(t):null},getAttachment:function(t,e){return this._skeleton?this._skeleton.getAttachmentByName(t,e):null},setAttachment:function(t,e){this._skeleton&&this._skeleton.setAttachment(t,e)},getTextureAtlas:function(t){return t.region},setMix:function(t,e,i){this._state&&this._state.data.setMix(t,e,i)},setAnimation:function(t,e,i){if(this._skeleton){var n=this._skeleton.data.findAnimation(e);return n?this._state.setAnimationWith(t,n,i):(cc.logID(7509,e),null)}return null},addAnimation:function(t,e,i,n){if(this._skeleton){n=n||0;var r=this._skeleton.data.findAnimation(e);return r?this._state.addAnimationWith(t,r,i,n):(cc.logID(7510,e),null)}return null},findAnimation:function(t){return this._skeleton?this._skeleton.data.findAnimation(t):null},getCurrent:function(t){return this._state?this._state.getCurrent(t):null},clearTracks:function(){this._state&&this._state.clearTracks()},clearTrack:function(t){this._state&&this._state.clearTrack(t)},setStartListener:function(t){this._ensureListener(),this._listener.start=t},setInterruptListener:function(t){this._ensureListener(),this._listener.interrupt=t},setEndListener:function(t){this._ensureListener(),this._listener.end=t},setDisposeListener:function(t){this._ensureListener(),this._listener.dispose=t},setCompleteListener:function(t){this._ensureListener(),this._listener.complete=t},setEventListener:function(t){this._ensureListener(),this._listener.event=t},setTrackStartListener:function(t,e){n.getListeners(t).start=e},setTrackInterruptListener:function(t,e){n.getListeners(t).interrupt=e},setTrackEndListener:function(t,e){n.getListeners(t).end=e},setTrackDisposeListener:function(t,e){n.getListeners(t).dispose=e},setTrackCompleteListener:function(t,e){n.getListeners(t).complete=function(t){var i=Math.floor(t.trackTime/t.animationEnd);e(t,i)}},setTrackEventListener:function(t,e){n.getListeners(t).event=e},getState:function(){return this._state},_updateAnimEnum:!1,_updateSkinEnum:!1,_ensureListener:function(){this._listener||(this._listener=new n,this._state&&this._state.addListener(this._listener))},_updateSkeletonData:function(){if(this.skeletonData){var t=this.skeletonData.getRuntimeData();if(t){try{this.setSkeletonData(t),this.setAnimationStateData(new s.AnimationStateData(this._skeleton.data)),this.defaultSkin&&this._skeleton.setSkinByName(this.defaultSkin)}catch(t){cc.warn(t)}this.animation=this.defaultAnimation}}},_refreshInspector:function(){this._updateAnimEnum(),this._updateSkinEnum(),Editor.Utils.refreshSelectedInspector("node",this.node.uuid)},_initDebugDraw:function(){if(this.debugBones||this.debugSlots){if(!this._debugRenderer){var t=new cc.PrivateNode;t.name="DEBUG_DRAW_NODE";var e=t.addComponent(a);e.lineWidth=1,e.strokeColor=cc.color(255,0,0,255),this._debugRenderer=e}this._debugRenderer.node.parent=this.node}else this._debugRenderer&&(this._debugRenderer.node.parent=null)}}),e.exports=sp.Skeleton}),{"../../cocos2d/core/components/CCRenderComponent":75,"../../cocos2d/core/graphics/graphics":103,"../../cocos2d/core/renderer/render-engine":198,"./lib/spine":287,"./track-entry-listeners":291}],286:[(function(t,e,i){("undefined"==typeof window?global:window).sp={},sp.ATTACHMENT_TYPE={REGION:0,BOUNDING_BOX:1,MESH:2,SKINNED_MESH:3},sp.AnimationEventType=cc.Enum({START:0,INTERRUPT:1,END:2,DISPOSE:3,COMPLETE:4,EVENT:5}),sp.spine=t("./lib/spine"),t("./skeleton-texture"),t("./skeleton-data"),t("./Skeleton"),t("./spine-assembler")}),{"./Skeleton":285,"./lib/spine":287,"./skeleton-data":288,"./skeleton-texture":289,"./spine-assembler":290}],287:[(function(t,e,i){var n,r=this&&this.__extends||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)};(function(t){var e=(function(){function t(t,e,i){if(null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.duration=i}return t.prototype.apply=function(t,e,i,n,r,s,o,a){if(null==t)throw new Error("skeleton cannot be null.");n&&0!=this.duration&&(i%=this.duration,e>0&&(e%=this.duration));for(var h=this.timelines,l=0,c=h.length;l>>1;;){if(t[(s+1)*i]<=e?n=s+1:r=s,n==r)return(n+1)*i;s=n+r>>>1}},t.linearSearch=function(t,e,i){for(var n=0,r=t.length-i;n<=r;n+=i)if(t[n]>e)return n;return-1},t})();t.Animation=e,(function(t){t[t.rotate=0]="rotate",t[t.translate=1]="translate",t[t.scale=2]="scale",t[t.shear=3]="shear",t[t.attachment=4]="attachment",t[t.color=5]="color",t[t.deform=6]="deform",t[t.event=7]="event",t[t.drawOrder=8]="drawOrder",t[t.ikConstraint=9]="ikConstraint",t[t.transformConstraint=10]="transformConstraint",t[t.pathConstraintPosition=11]="pathConstraintPosition",t[t.pathConstraintSpacing=12]="pathConstraintSpacing",t[t.pathConstraintMix=13]="pathConstraintMix"})(t.TimelineType||(t.TimelineType={}));var i=t.TimelineType,n=(function(){function e(i){if(i<=0)throw new Error("frameCount must be > 0: "+i);this.curves=t.Utils.newFloatArray((i-1)*e.BEZIER_SIZE)}return e.prototype.getFrameCount=function(){return this.curves.length/e.BEZIER_SIZE+1},e.prototype.setLinear=function(t){this.curves[t*e.BEZIER_SIZE]=e.LINEAR},e.prototype.setStepped=function(t){this.curves[t*e.BEZIER_SIZE]=e.STEPPED},e.prototype.getCurveType=function(t){var i=t*e.BEZIER_SIZE;if(i==this.curves.length)return e.LINEAR;var n=this.curves[i];return n==e.LINEAR?e.LINEAR:n==e.STEPPED?e.STEPPED:e.BEZIER},e.prototype.setCurve=function(t,i,n,r,s){var o=.03*(2*-i+r),a=.03*(2*-n+s),h=.006*(3*(i-r)+1),l=.006*(3*(n-s)+1),c=2*o+h,u=2*a+l,_=.3*i+o+.16666667*h,f=.3*n+a+.16666667*l,m=t*e.BEZIER_SIZE,d=this.curves;d[m++]=e.BEZIER;for(var p=_,y=f,v=m+e.BEZIER_SIZE-1;m=n){var c=void 0,u=void 0;return s==h?(c=0,u=0):(c=r[s-2],u=r[s-1]),u+(r[s+1]-u)*(n-c)/(a-c)}var _=r[s-1];return _+(1-_)*(n-a)/(1-a)},e.LINEAR=0,e.STEPPED=1,e.BEZIER=2,e.BEZIER_SIZE=19,e})();t.CurveTimeline=n;var s=(function(n){function s(e){n.call(this,e),this.frames=t.Utils.newFloatArray(e<<1)}return r(s,n),s.prototype.getPropertyId=function(){return(i.rotate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i){t<<=1,this.frames[t]=e,this.frames[t+s.ROTATION]=i},s.prototype.apply=function(t,i,n,r,o,a,h){var l=this.frames,c=t.bones[this.boneIndex];if(n=l[l.length-s.ENTRIES])if(a)c.rotation=c.data.rotation+l[l.length+s.PREV_ROTATION]*o;else{var u=c.data.rotation+l[l.length+s.PREV_ROTATION]-c.rotation;u-=360*(16384-(16384.499999999996-u/360|0)),c.rotation+=u*o}else{var _=e.binarySearch(l,n,s.ENTRIES),f=l[_+s.PREV_ROTATION],m=l[_],d=this.getCurvePercent((_>>1)-1,1-(n-m)/(l[_+s.PREV_TIME]-m)),p=l[_+s.ROTATION]-f;p=f+(p-=360*(16384-(16384.499999999996-p/360|0)))*d,a?(p-=360*(16384-(16384.499999999996-p/360|0)),c.rotation=c.data.rotation+p*o):(p=c.data.rotation+p-c.rotation,p-=360*(16384-(16384.499999999996-p/360|0)),c.rotation+=p*o)}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_ROTATION=-1,s.ROTATION=1,s})(n);t.RotateTimeline=s;var o=(function(n){function s(e){n.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return r(s,n),s.prototype.getPropertyId=function(){return(i.translate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.X]=i,this.frames[t+s.Y]=n},s.prototype.apply=function(t,i,n,r,o,a,h){var l=this.frames,c=t.bones[this.boneIndex];if(n=l[l.length-s.ENTRIES])u=l[l.length+s.PREV_X],_=l[l.length+s.PREV_Y];else{var f=e.binarySearch(l,n,s.ENTRIES);u=l[f+s.PREV_X],_=l[f+s.PREV_Y];var m=l[f],d=this.getCurvePercent(f/s.ENTRIES-1,1-(n-m)/(l[f+s.PREV_TIME]-m));u+=(l[f+s.X]-u)*d,_+=(l[f+s.Y]-_)*d}a?(c.x=c.data.x+u*o,c.y=c.data.y+_*o):(c.x+=(c.data.x+u-c.x)*o,c.y+=(c.data.y+_-c.y)*o)}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_X=-2,s.PREV_Y=-1,s.X=1,s.Y=2,s})(n);t.TranslateTimeline=o;var a=(function(n){function s(t){n.call(this,t)}return r(s,n),s.prototype.getPropertyId=function(){return(i.scale<<24)+this.boneIndex},s.prototype.apply=function(i,n,r,o,a,h,l){var c=this.frames,u=i.bones[this.boneIndex];if(r=c[c.length-s.ENTRIES])_=c[c.length+s.PREV_X]*u.data.scaleX,f=c[c.length+s.PREV_Y]*u.data.scaleY;else{var m=e.binarySearch(c,r,s.ENTRIES);_=c[m+s.PREV_X],f=c[m+s.PREV_Y];var d=c[m],p=this.getCurvePercent(m/s.ENTRIES-1,1-(r-d)/(c[m+s.PREV_TIME]-d));_=(_+(c[m+s.X]-_)*p)*u.data.scaleX,f=(f+(c[m+s.Y]-f)*p)*u.data.scaleY}if(1==a)u.scaleX=_,u.scaleY=f;else{var y=0,v=0;h?(y=u.data.scaleX,v=u.data.scaleY):(y=u.scaleX,v=u.scaleY),l?(_=Math.abs(_)*t.MathUtils.signum(y),f=Math.abs(f)*t.MathUtils.signum(v)):(y=Math.abs(y)*t.MathUtils.signum(_),v=Math.abs(v)*t.MathUtils.signum(f)),u.scaleX=y+(_-y)*a,u.scaleY=v+(f-v)*a}}},s})(o);t.ScaleTimeline=a;var h=(function(t){function n(e){t.call(this,e)}return r(n,t),n.prototype.getPropertyId=function(){return(i.shear<<24)+this.boneIndex},n.prototype.apply=function(t,i,r,s,o,a,h){var l=this.frames,c=t.bones[this.boneIndex];if(r=l[l.length-n.ENTRIES])u=l[l.length+n.PREV_X],_=l[l.length+n.PREV_Y];else{var f=e.binarySearch(l,r,n.ENTRIES);u=l[f+n.PREV_X],_=l[f+n.PREV_Y];var m=l[f],d=this.getCurvePercent(f/n.ENTRIES-1,1-(r-m)/(l[f+n.PREV_TIME]-m));u+=(l[f+n.X]-u)*d,_+=(l[f+n.Y]-_)*d}a?(c.shearX=c.data.shearX+u*o,c.shearY=c.data.shearY+_*o):(c.shearX+=(c.data.shearX+u-c.shearX)*o,c.shearY+=(c.data.shearY+_-c.shearY)*o)}},n})(o);t.ShearTimeline=h;var l=(function(n){function s(e){n.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return r(s,n),s.prototype.getPropertyId=function(){return(i.color<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i,n,r,o){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.R]=i,this.frames[t+s.G]=n,this.frames[t+s.B]=r,this.frames[t+s.A]=o},s.prototype.apply=function(t,i,n,r,o,a,h){var l=t.slots[this.slotIndex],c=this.frames;if(n=c[c.length-s.ENTRIES]){var d=c.length;u=c[d+s.PREV_R],_=c[d+s.PREV_G],f=c[d+s.PREV_B],m=c[d+s.PREV_A]}else{var p=e.binarySearch(c,n,s.ENTRIES);u=c[p+s.PREV_R],_=c[p+s.PREV_G],f=c[p+s.PREV_B],m=c[p+s.PREV_A];var y=c[p],v=this.getCurvePercent(p/s.ENTRIES-1,1-(n-y)/(c[p+s.PREV_TIME]-y));u+=(c[p+s.R]-u)*v,_+=(c[p+s.G]-_)*v,f+=(c[p+s.B]-f)*v,m+=(c[p+s.A]-m)*v}if(1==o)l.color.set(u,_,f,m);else{var g=l.color;a&&g.setFromColor(l.data.color),g.add((u-g.r)*o,(_-g.g)*o,(f-g.b)*o,(m-g.a)*o)}}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_R=-4,s.PREV_G=-3,s.PREV_B=-2,s.PREV_A=-1,s.R=1,s.G=2,s.B=3,s.A=4,s})(n);t.ColorTimeline=l;var c=(function(){function n(e){this.frames=t.Utils.newFloatArray(e),this.attachmentNames=new Array(e)}return n.prototype.getPropertyId=function(){return(i.attachment<<24)+this.slotIndex},n.prototype.getFrameCount=function(){return this.frames.length},n.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.attachmentNames[t]=i},n.prototype.apply=function(t,i,n,r,s,o,a){var h=t.slots[this.slotIndex];if(a&&o){var l=h.data.attachmentName;h.setAttachment(null==l?null:t.getAttachment(this.slotIndex,l))}else{var c=this.frames;if(n=c[c.length-1]?c.length-1:e.binarySearch(c,n,1)-1;var f=this.attachmentNames[_];t.slots[this.slotIndex].setAttachment(null==f?null:t.getAttachment(this.slotIndex,f))}}},n})();t.AttachmentTimeline=c;var u=(function(n){function s(e){n.call(this,e),this.frames=t.Utils.newFloatArray(e),this.frameVertices=new Array(e)}return r(s,n),s.prototype.getPropertyId=function(){return(i.deform<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.frameVertices[t]=i},s.prototype.apply=function(i,n,r,s,o,a,h){var l=i.slots[this.slotIndex],c=l.getAttachment();if(c instanceof t.VertexAttachment&&c.applyDeform(this.attachment)){var u=this.frames,_=l.attachmentVertices;if(r=u[u.length-1]){var p=f[u.length-1];if(1==o)t.Utils.arrayCopy(p,0,d,0,m);else if(a){if(null==(w=c).bones)for(var y=w.vertices,v=0;vn)this.apply(t,i,Number.MAX_VALUE,r,s,o,a),i=-1;else if(i>=h[l-1])return;if(!(n0&&h[c-1]==u;)c--;for(;c=h[c];c++)r.push(this.events[c])}}},n})();t.EventTimeline=_;var f=(function(){function n(e){this.frames=t.Utils.newFloatArray(e),this.drawOrders=new Array(e)}return n.prototype.getPropertyId=function(){return i.drawOrder<<24},n.prototype.getFrameCount=function(){return this.frames.length},n.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.drawOrders[t]=i},n.prototype.apply=function(i,n,r,s,o,a,h){var l=i.drawOrder,c=i.slots;if(h&&a)t.Utils.arrayCopy(i.slots,0,i.drawOrder,0,i.slots.length);else{var u=this.frames;if(r=u[u.length-1]?u.length-1:e.binarySearch(u,r)-1;var f=this.drawOrders[_];if(null==f)t.Utils.arrayCopy(c,0,l,0,c.length);else for(var m=0,d=f.length;m=l[l.length-s.ENTRIES])a?(c.mix=c.data.mix+(l[l.length+s.PREV_MIX]-c.data.mix)*o,c.bendDirection=h?c.data.bendDirection:l[l.length+s.PREV_BEND_DIRECTION]):(c.mix+=(l[l.length+s.PREV_MIX]-c.mix)*o,h||(c.bendDirection=l[l.length+s.PREV_BEND_DIRECTION]));else{var u=e.binarySearch(l,n,s.ENTRIES),_=l[u+s.PREV_MIX],f=l[u],m=this.getCurvePercent(u/s.ENTRIES-1,1-(n-f)/(l[u+s.PREV_TIME]-f));a?(c.mix=c.data.mix+(_+(l[u+s.MIX]-_)*m-c.data.mix)*o,c.bendDirection=h?c.data.bendDirection:l[u+s.PREV_BEND_DIRECTION]):(c.mix+=(_+(l[u+s.MIX]-_)*m-c.mix)*o,h||(c.bendDirection=l[u+s.PREV_BEND_DIRECTION]))}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_MIX=-2,s.PREV_BEND_DIRECTION=-1,s.MIX=1,s.BEND_DIRECTION=2,s})(n);t.IkConstraintTimeline=m;var d=(function(n){function s(e){n.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return r(s,n),s.prototype.getPropertyId=function(){return(i.transformConstraint<<24)+this.transformConstraintIndex},s.prototype.setFrame=function(t,e,i,n,r,o){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=n,this.frames[t+s.SCALE]=r,this.frames[t+s.SHEAR]=o},s.prototype.apply=function(t,i,n,r,o,a,h){var l=this.frames,c=t.transformConstraints[this.transformConstraintIndex];if(n=l[l.length-s.ENTRIES]){var p=l.length;_=l[p+s.PREV_ROTATE],f=l[p+s.PREV_TRANSLATE],m=l[p+s.PREV_SCALE],d=l[p+s.PREV_SHEAR]}else{var y=e.binarySearch(l,n,s.ENTRIES);_=l[y+s.PREV_ROTATE],f=l[y+s.PREV_TRANSLATE],m=l[y+s.PREV_SCALE],d=l[y+s.PREV_SHEAR];var v=l[y],g=this.getCurvePercent(y/s.ENTRIES-1,1-(n-v)/(l[y+s.PREV_TIME]-v));_+=(l[y+s.ROTATE]-_)*g,f+=(l[y+s.TRANSLATE]-f)*g,m+=(l[y+s.SCALE]-m)*g,d+=(l[y+s.SHEAR]-d)*g}if(a){u=c.data;c.rotateMix=u.rotateMix+(_-u.rotateMix)*o,c.translateMix=u.translateMix+(f-u.translateMix)*o,c.scaleMix=u.scaleMix+(m-u.scaleMix)*o,c.shearMix=u.shearMix+(d-u.shearMix)*o}else c.rotateMix+=(_-c.rotateMix)*o,c.translateMix+=(f-c.translateMix)*o,c.scaleMix+=(m-c.scaleMix)*o,c.shearMix+=(d-c.shearMix)*o}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_ROTATE=-4,s.PREV_TRANSLATE=-3,s.PREV_SCALE=-2,s.PREV_SHEAR=-1,s.ROTATE=1,s.TRANSLATE=2,s.SCALE=3,s.SHEAR=4,s})(n);t.TransformConstraintTimeline=d;var p=(function(n){function s(e){n.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return r(s,n),s.prototype.getPropertyId=function(){return(i.pathConstraintPosition<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.VALUE]=i},s.prototype.apply=function(t,i,n,r,o,a,h){var l=this.frames,c=t.pathConstraints[this.pathConstraintIndex];if(n=l[l.length-s.ENTRIES])u=l[l.length+s.PREV_VALUE];else{var _=e.binarySearch(l,n,s.ENTRIES);u=l[_+s.PREV_VALUE];var f=l[_],m=this.getCurvePercent(_/s.ENTRIES-1,1-(n-f)/(l[_+s.PREV_TIME]-f));u+=(l[_+s.VALUE]-u)*m}a?c.position=c.data.position+(u-c.data.position)*o:c.position+=(u-c.position)*o}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_VALUE=-1,s.VALUE=1,s})(n);t.PathConstraintPositionTimeline=p;var y=(function(t){function n(e){t.call(this,e)}return r(n,t),n.prototype.getPropertyId=function(){return(i.pathConstraintSpacing<<24)+this.pathConstraintIndex},n.prototype.apply=function(t,i,r,s,o,a,h){var l=this.frames,c=t.pathConstraints[this.pathConstraintIndex];if(r=l[l.length-n.ENTRIES])u=l[l.length+n.PREV_VALUE];else{var _=e.binarySearch(l,r,n.ENTRIES);u=l[_+n.PREV_VALUE];var f=l[_],m=this.getCurvePercent(_/n.ENTRIES-1,1-(r-f)/(l[_+n.PREV_TIME]-f));u+=(l[_+n.VALUE]-u)*m}a?c.spacing=c.data.spacing+(u-c.data.spacing)*o:c.spacing+=(u-c.spacing)*o}},n})(p);t.PathConstraintSpacingTimeline=y;var v=(function(n){function s(e){n.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return r(s,n),s.prototype.getPropertyId=function(){return(i.pathConstraintMix<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=n},s.prototype.apply=function(t,i,n,r,o,a,h){var l=this.frames,c=t.pathConstraints[this.pathConstraintIndex];if(n=l[l.length-s.ENTRIES])u=l[l.length+s.PREV_ROTATE],_=l[l.length+s.PREV_TRANSLATE];else{var f=e.binarySearch(l,n,s.ENTRIES);u=l[f+s.PREV_ROTATE],_=l[f+s.PREV_TRANSLATE];var m=l[f],d=this.getCurvePercent(f/s.ENTRIES-1,1-(n-m)/(l[f+s.PREV_TIME]-m));u+=(l[f+s.ROTATE]-u)*d,_+=(l[f+s.TRANSLATE]-_)*d}a?(c.rotateMix=c.data.rotateMix+(u-c.data.rotateMix)*o,c.translateMix=c.data.translateMix+(_-c.data.translateMix)*o):(c.rotateMix+=(u-c.rotateMix)*o,c.translateMix+=(_-c.translateMix)*o)}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_ROTATE=-2,s.PREV_TRANSLATE=-1,s.ROTATE=1,s.TRANSLATE=2,s})(n);t.PathConstraintMixTimeline=v})(n||(n={})),(function(t){var e=(function(){function e(e){this.tracks=new Array,this.events=new Array,this.listeners=new Array,this.queue=new n(this),this.propertyIDs=new t.IntSet,this.animationsChanged=!1,this.timeScale=1,this.trackEntryPool=new t.Pool(function(){return new i}),this.data=e}return e.prototype.update=function(t){t*=this.timeScale;for(var e=this.tracks,i=0,n=e.length;i0){if(r.delay-=s,r.delay>0)continue;s=-r.delay,r.delay=0}var o=r.next;if(null!=o){var a=r.trackLast-o.delay;if(a>=0){for(o.delay=0,o.trackTime=a+t*o.timeScale,r.trackTime+=s,this.setCurrent(i,o,!0);null!=o.mixingFrom;)o.mixTime+=s,o=o.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&null==r.mixingFrom){e[i]=null,this.queue.end(r),this.disposeNext(r);continue}this.updateMixingFrom(r,t),r.trackTime+=s}}this.queue.drain()},e.prototype.updateMixingFrom=function(t,e){var i=t.mixingFrom;if(null!=i){if(this.updateMixingFrom(i,e),t.mixTime>=t.mixDuration&&null!=i.mixingFrom&&t.mixTime>0)return t.mixingFrom=null,void this.queue.end(i);i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast,i.trackTime+=e*i.timeScale,t.mixTime+=e*i.timeScale}},e.prototype.apply=function(e){if(null==e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();for(var i=this.events,n=this.tracks,r=0,s=n.length;r0)){var a=o.alpha;null!=o.mixingFrom?a*=this.applyMixingFrom(o,e):o.trackTime>=o.trackEnd&&(a=0);var h=o.animationLast,l=o.getAnimationTime(),c=o.animation.timelines.length,u=o.animation.timelines;if(1==a)for(var _=0;_1&&(r=1);var s=r0&&this.queueEvents(n,l),this.events.length=0,n.nextAnimationLast=l,n.nextTrackLast=n.trackTime,r},e.prototype.applyRotateTimeline=function(e,i,n,r,s,o,a,h){if(h&&(o[a]=0),1!=r){var l=e,c=l.frames,u=i.bones[l.boneIndex];if(n=c[c.length-t.RotateTimeline.ENTRIES])_=u.data.rotation+c[c.length+t.RotateTimeline.PREV_ROTATION];else{var f=t.Animation.binarySearch(c,n,t.RotateTimeline.ENTRIES),m=c[f+t.RotateTimeline.PREV_ROTATION],d=c[f],p=l.getCurvePercent((f>>1)-1,1-(n-d)/(c[f+t.RotateTimeline.PREV_TIME]-d));_=c[f+t.RotateTimeline.ROTATION]-m,_=m+(_-=360*(16384-(16384.499999999996-_/360|0)))*p+u.data.rotation,_-=360*(16384-(16384.499999999996-_/360|0))}var y=s?u.data.rotation:u.rotation,v=0,g=_-y;if(0==g)v=o[a];else{g-=360*(16384-(16384.499999999996-g/360|0));var x=0,A=0;h?(x=0,A=g):(x=o[a],A=o[a+1]);var b=g>0,C=x>=0;t.MathUtils.signum(A)!=t.MathUtils.signum(g)&&Math.abs(A)<=90&&(Math.abs(x)>180&&(x+=360*t.MathUtils.signum(x)),C=b),v=g+x-x%360,C!=b&&(v+=360*t.MathUtils.signum(x)),o[a]=v}o[a+1]=g,y+=v*r,u.rotation=y-360*(16384-(16384.499999999996-y/360|0))}}else e.apply(i,0,n,null,1,s,!1)},e.prototype.queueEvents=function(t,e){for(var i=t.animationStart,n=t.animationEnd,r=n-i,s=t.trackLast%r,o=this.events,a=0,h=o.length;an||this.queue.event(t,l)}for((t.loop?s>t.trackTime%r:e>=n&&t.animationLast=this.tracks.length)){var e=this.tracks[t];if(null!=e){this.queue.end(e),this.disposeNext(e);for(var i=e;;){var n=i.mixingFrom;if(null==n)break;this.queue.end(n),i.mixingFrom=null,i=n}this.tracks[e.trackIndex]=null,this.queue.drain()}}},e.prototype.setCurrent=function(t,e,i){var n=this.expandToIndex(t);this.tracks[t]=e,null!=n&&(i&&this.queue.interrupt(n),e.mixingFrom=n,e.mixTime=0,n.timelinesRotation.length=0,null!=n.mixingFrom&&n.mixDuration>0&&(e.mixAlpha*=Math.min(n.mixTime/n.mixDuration,1))),this.queue.start(e)},e.prototype.setAnimation=function(t,e,i){var n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,n,i)},e.prototype.setAnimationWith=function(t,e,i){if(null==e)throw new Error("animation cannot be null.");var n=!0,r=this.expandToIndex(t);null!=r&&(-1==r.nextTrackLast?(this.tracks[t]=r.mixingFrom,this.queue.interrupt(r),this.queue.end(r),this.disposeNext(r),r=r.mixingFrom,n=!1):this.disposeNext(r));var s=this.trackEntry(t,e,i,r);return this.setCurrent(t,s,n),this.queue.drain(),s},e.prototype.addAnimation=function(t,e,i,n){var r=this.data.skeletonData.findAnimation(e);if(null==r)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,r,i,n)},e.prototype.addAnimationWith=function(t,e,i,n){if(null==e)throw new Error("animation cannot be null.");var r=this.expandToIndex(t);if(null!=r)for(;null!=r.next;)r=r.next;var s=this.trackEntry(t,e,i,r);if(null==r)this.setCurrent(t,s,!0),this.queue.drain();else if(r.next=s,n<=0){var o=r.animationEnd-r.animationStart;0!=o?n+=o*(1+(r.trackTime/o|0))-this.data.getMix(r.animation,e):n=0}return s.delay=n,s},e.prototype.setEmptyAnimation=function(t,i){var n=this.setAnimationWith(t,e.emptyAnimation,!1);return n.mixDuration=i,n.trackEnd=i,n},e.prototype.addEmptyAnimation=function(t,i,n){n<=0&&(n-=i);var r=this.addAnimationWith(t,e.emptyAnimation,!1,n);return r.mixDuration=i,r.trackEnd=i,r},e.prototype.setEmptyAnimations=function(t){this.queue.drainDisabled=!0;for(var e=0,i=this.tracks.length;e=this.tracks.length?null:this.tracks[t]},e.prototype.addListener=function(t){if(null==t)throw new Error("listener cannot be null.");this.listeners.push(t)},e.prototype.removeListener=function(t){var e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)},e.prototype.clearListeners=function(){this.listeners.length=0},e.prototype.clearListenerNotifications=function(){this.queue.clear()},e.emptyAnimation=new t.Animation("",[],0),e})();t.AnimationState=e;var i=(function(){function t(){this.timelinesFirst=new Array,this.timelinesRotation=new Array}return t.prototype.reset=function(){this.next=null,this.mixingFrom=null,this.animation=null,this.listener=null,this.timelinesFirst.length=0,this.timelinesRotation.length=0},t.prototype.getAnimationTime=function(){if(this.loop){var t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)},t.prototype.setAnimationLast=function(t){this.animationLast=t,this.nextAnimationLast=t},t.prototype.isComplete=function(){return this.trackTime>=this.animationEnd-this.animationStart},t.prototype.resetRotationDirections=function(){this.timelinesRotation.length=0},t})();t.TrackEntry=i;var n=(function(){function t(t){this.objects=[],this.drainDisabled=!1,this.animState=t}return t.prototype.start=function(t){this.objects.push(r.start),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.interrupt=function(t){this.objects.push(r.interrupt),this.objects.push(t)},t.prototype.end=function(t){this.objects.push(r.end),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.dispose=function(t){this.objects.push(r.dispose),this.objects.push(t)},t.prototype.complete=function(t){this.objects.push(r.complete),this.objects.push(t)},t.prototype.event=function(t,e){this.objects.push(r.event),this.objects.push(t),this.objects.push(e)},t.prototype.drain=function(){if(!this.drainDisabled){this.drainDisabled=!0;for(var t=this.objects,e=this.animState.listeners,i=0;i=200&&r.status<300?(n.assets[t]=r.responseText,e&&e(t,r.responseText)):(n.errors[t]="Couldn't load text "+t+": status "+r.status+", "+r.responseText,i&&i(t,"Couldn't load text "+t+": status "+r.status+", "+r.responseText)),n.toLoad--,n.loaded++)},r.open("GET",t,!0),r.send()},t.prototype.loadTexture=function(t,e,i){var n=this;void 0===e&&(e=null),void 0===i&&(i=null),t=this.pathPrefix+t,this.toLoad++;var r=new Image;r.crossOrigin="anonymous",r.src=t,r.onload=function(i){var s=n.textureLoader(r);n.assets[t]=s,n.toLoad--,n.loaded++,e&&e(t,r)},r.onerror=function(e){n.errors[t]="Couldn't load image "+t,n.toLoad--,n.loaded++,i&&i(t,"Couldn't load image "+t)}},t.prototype.get=function(t){return t=this.pathPrefix+t,this.assets[t]},t.prototype.remove=function(t){t=this.pathPrefix+t;var e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null},t.prototype.removeAll=function(){for(var t in this.assets){var e=this.assets[t];e.dispose&&e.dispose()}this.assets={}},t.prototype.isLoadingComplete=function(){return 0==this.toLoad},t.prototype.getToLoad=function(){return this.toLoad},t.prototype.getLoaded=function(){return this.loaded},t.prototype.dispose=function(){this.removeAll()},t.prototype.hasErrors=function(){return Object.keys(this.errors).length>0},t.prototype.getErrors=function(){return this.errors},t})();t.AssetManager=e})(n||(n={})),(function(t){var e=(function(){function e(t){this.atlas=t}return e.prototype.newRegionAttachment=function(e,i,n){var r=this.atlas.findRegion(n);if(null==r)throw new Error("Region not found in atlas: "+n+" (region attachment: "+i+")");r.renderObject=r;var s=new t.RegionAttachment(i);return s.setRegion(r),s},e.prototype.newMeshAttachment=function(e,i,n){var r=this.atlas.findRegion(n);if(null==r)throw new Error("Region not found in atlas: "+n+" (mesh attachment: "+i+")");r.renderObject=r;var s=new t.MeshAttachment(i);return s.region=r,s},e.prototype.newBoundingBoxAttachment=function(e,i){return new t.BoundingBoxAttachment(i)},e.prototype.newPathAttachment=function(e,i){return new t.PathAttachment(i)},e})();t.AtlasAttachmentLoader=e})(n||(n={})),(function(t){var e=(function(){return function(t){if(null==t)throw new Error("name cannot be null.");this.name=t}})();t.Attachment=e;var i=(function(t){function e(e){t.call(this,e),this.worldVerticesLength=0}return r(e,t),e.prototype.computeWorldVertices=function(t,e){this.computeWorldVerticesWith(t,0,this.worldVerticesLength,e,0)},e.prototype.computeWorldVerticesWith=function(t,e,i,n,r){i+=r;var s=t.bone.skeleton,o=t.attachmentVertices,a=this.vertices,h=this.bones;if(null!=h){for(var l=0,c=0,u=0;u0&&(a=o);for(var g,x=(g=t.bone).worldX,A=g.worldY,b=g.a,C=g.b,S=g.c,T=g.d,w=e,E=r;E>1);null!=this.worldVertices&&this.worldVertices.length==n||(this.worldVertices=t.Utils.newFloatArray(n));var r=0,s=0,o=0,a=0;if(null==this.region?(r=s=0,o=a=1):(r=this.region.u,s=this.region.v,o=this.region.u2-r,a=this.region.v2-s),this.region.rotate)for(var h=0,l=6;h0&&(c=l);for(var m=(B=t.bone).worldX,d=B.worldY,p=B.a,y=B.b,v=B.c,g=B.d,x=0,A=0;x1e-4?(p=y*(b=Math.abs(d*v-p*y)/b),v=d*b,g=Math.atan2(y,d)*t.MathUtils.radDeg):(d=0,y=0,g=90-Math.atan2(v,p)*t.MathUtils.radDeg);var x=n+o-g,A=n+a-g+90;c=t.MathUtils.cosDeg(x)*r,u=t.MathUtils.cosDeg(A)*s,_=t.MathUtils.sinDeg(x)*r,f=t.MathUtils.sinDeg(A)*s;this.a=d*c-p*_,this.b=d*u-p*f,this.c=y*c+v*_,this.d=y*u+v*f;break;case t.TransformMode.NoScale:case t.TransformMode.NoScaleOrReflection:var b,C=t.MathUtils.cosDeg(n),S=t.MathUtils.sinDeg(n),T=d*C+p*S,w=y*C+v*S;(b=Math.sqrt(T*T+w*w))>1e-5&&(b=1/b),T*=b,w*=b,b=Math.sqrt(T*T+w*w);var E=Math.PI/2+Math.atan2(w,T),D=Math.cos(E)*b,B=Math.sin(E)*b;c=t.MathUtils.cosDeg(o)*r,u=t.MathUtils.cosDeg(90+a)*s,_=t.MathUtils.sinDeg(o)*r,f=t.MathUtils.sinDeg(90+a)*s;return this.a=T*c+D*_,this.b=T*u+D*f,this.c=w*c+B*_,this.d=w*u+B*f,void((this.data.transformMode!=t.TransformMode.NoScaleOrReflection?d*v-p*y<0:this.skeleton.flipX!=this.skeleton.flipY)&&(this.b=-this.b,this.d=-this.d))}this.skeleton.flipX&&(this.a=-this.a,this.b=-this.b),this.skeleton.flipY&&(this.c=-this.c,this.d=-this.d)},e.prototype.setToSetupPose=function(){var t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY},e.prototype.getWorldRotationX=function(){return Math.atan2(this.c,this.a)*t.MathUtils.radDeg},e.prototype.getWorldRotationY=function(){return Math.atan2(this.d,this.b)*t.MathUtils.radDeg},e.prototype.getWorldScaleX=function(){return Math.sqrt(this.a*this.a+this.c*this.c)},e.prototype.getWorldScaleY=function(){return Math.sqrt(this.b*this.b+this.d*this.d)},e.prototype.worldToLocalRotationX=function(){var e=this.parent;if(null==e)return this.arotation;var i=e.a,n=e.b,r=e.c,s=e.d,o=this.a,a=this.c;return Math.atan2(i*a-r*o,s*o-n*a)*t.MathUtils.radDeg},e.prototype.worldToLocalRotationY=function(){var e=this.parent;if(null==e)return this.arotation;var i=e.a,n=e.b,r=e.c,s=e.d,o=this.b,a=this.d;return Math.atan2(i*a-r*o,s*o-n*a)*t.MathUtils.radDeg},e.prototype.rotateWorld=function(e){var i=this.a,n=this.b,r=this.c,s=this.d,o=t.MathUtils.cosDeg(e),a=t.MathUtils.sinDeg(e);this.a=o*i-a*r,this.b=o*n-a*s,this.c=a*i+o*r,this.d=a*n+o*s,this.appliedValid=!1},e.prototype.updateAppliedTransform=function(){this.appliedValid=!0;var e=this.parent;if(null==e)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*t.MathUtils.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*t.MathUtils.radDeg);var i=e.a,n=e.b,r=e.c,s=e.d,o=1/(i*s-n*r),a=this.worldX-e.worldX,h=this.worldY-e.worldY;this.ax=a*s*o-h*n*o,this.ay=h*i*o-a*r*o;var l=o*s,c=o*i,u=o*n,_=o*r,f=l*this.a-u*this.c,m=l*this.b-u*this.d,d=c*this.c-_*this.a,p=c*this.d-_*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(f*f+d*d),this.ascaleX>1e-4){var y=f*p-m*d;this.ascaleY=y/this.ascaleX,this.ashearY=Math.atan2(f*m+d*p,y)*t.MathUtils.radDeg,this.arotation=Math.atan2(d,f)*t.MathUtils.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(m*m+p*p),this.ashearY=0,this.arotation=90-Math.atan2(p,m)*t.MathUtils.radDeg},e.prototype.worldToLocal=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=1/(e*r-i*n),o=t.x-this.worldX,a=t.y-this.worldY;return t.x=o*r*s-a*i*s,t.y=a*e*s-o*n*s,t},e.prototype.localToWorld=function(t){var e=t.x,i=t.y;return t.x=e*this.a+i*this.b+this.worldX,t.y=e*this.c+i*this.d+this.worldY,t},e})();t.Bone=e})(n||(n={})),(function(t){var e=(function(){return function(t,e,n){if(this.x=0,this.y=0,this.rotation=0,this.scaleX=1,this.scaleY=1,this.shearX=0,this.shearY=0,this.transformMode=i.Normal,t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=n}})();t.BoneData=e,(function(t){t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection"})(t.TransformMode||(t.TransformMode={}));var i=t.TransformMode})(n||(n={})),(function(t){var e=(function(){return function(t,e){if(null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}})();t.Event=e})(n||(n={})),(function(t){var e=(function(){return function(t){this.name=t}})();t.EventData=e})(n||(n={})),(function(t){var e=(function(){function e(t,e){if(this.mix=1,this.bendDirection=0,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.bendDirection=t.bendDirection,this.bones=new Array;for(var i=0;i180?u-=360:u<-180&&(u+=360),e.updateWorldTransformWith(e.ax,e.ay,e.arotation+u*r,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)},e.prototype.apply2=function(e,i,n,r,s,o){if(0!=o){e.appliedValid||e.updateAppliedTransform(),i.appliedValid||i.updateAppliedTransform();var a=e.ax,h=e.ay,l=e.ascaleX,c=e.ascaleY,u=i.ascaleX,_=0,f=0,m=0;l<0?(l=-l,_=180,m=-1):(_=0,m=1),c<0&&(c=-c,m=-m),u<0?(u=-u,f=180):f=0;var d=i.ax,p=0,y=0,v=0,g=e.a,x=e.b,A=e.c,b=e.d,C=Math.abs(l-c)<=1e-4;C?(y=g*d+x*(p=i.ay)+e.worldX,v=A*d+b*p+e.worldY):(p=0,y=g*d+e.worldX,v=A*d+e.worldY);var S=e.parent;g=S.a,x=S.b,A=S.c;var T=1/(g*(b=S.d)-x*A),w=n-S.worldX,E=r-S.worldY,D=(w*b-E*x)*T-a,B=(E*g-w*A)*T-h,M=((w=y-S.worldX)*b-(E=v-S.worldY)*x)*T-a,P=(E*g-w*A)*T-h,I=Math.sqrt(M*M+P*P),R=i.data.length*u,L=0,O=0;t:if(C){var F=(D*D+B*B-I*I-(R*=l)*R)/(2*I*R);F<-1?F=-1:F>1&&(F=1),O=Math.acos(F)*s,g=I+R*F,x=R*Math.sin(O),L=Math.atan2(B*g-D*x,D*g+B*x)}else{var V=(g=l*R)*g,N=(x=c*R)*x,k=D*D+B*B,G=Math.atan2(B,D),z=-2*N*I,U=N-V;if((b=z*z-4*U*(A=N*I*I+V*k-V*N))>=0){var W=Math.sqrt(b);z<0&&(W=-W);var j=(W=-(z+W)/2)/U,H=A/W,X=Math.abs(j)Q&&(K=0,Q=b,$=w),(b=(w=I-g)*w)Q&&(K=et,Q=b,$=w,tt=E),k<=(q+Q)/2?(L=G-Math.atan2(Z*s,J),O=Y*s):(L=G-Math.atan2(tt*s,$),O=K*s)}var it=Math.atan2(p,d)*m,nt=e.arotation;(L=(L-it)*t.MathUtils.radDeg+_-nt)>180?L-=360:L<-180&&(L+=360),e.updateWorldTransformWith(a,h,nt+L*o,e.ascaleX,e.ascaleY,0,0),nt=i.arotation,(O=((O+it)*t.MathUtils.radDeg-i.ashearX)*m+f-nt)>180?O-=360:O<-180&&(O+=360),i.updateWorldTransformWith(d,p,nt+O*o,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY)}else i.updateWorldTransform()},e})();t.IkConstraint=e})(n||(n={})),(function(t){var e=(function(){return function(t){this.order=0,this.bones=new Array,this.bendDirection=1,this.mix=1,this.name=t}})();t.IkConstraintData=e})(n||(n={})),(function(t){var e=(function(){function e(t,e){if(this.position=0,this.spacing=0,this.rotateMix=0,this.translateMix=0,this.spaces=new Array,this.positions=new Array,this.world=new Array,this.curves=new Array,this.lengths=new Array,this.segments=new Array,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(var i=0,n=t.bones.length;i0;if(n>0||r){var s=this.data,o=s.spacingMode,a=o==t.SpacingMode.Length,h=s.rotateMode,l=h==t.RotateMode.Tangent,c=h==t.RotateMode.ChainScale,u=this.bones.length,_=l?u:u+1,f=this.bones,m=t.Utils.setArraySize(this.spaces,_),d=null,p=this.spacing;if(c||a){c&&(d=t.Utils.setArraySize(this.lengths,u));for(var y=0,v=_-1;y0?t.MathUtils.degRad:-t.MathUtils.degRad;y=0;for(var E=3;yt.MathUtils.PI?V-=t.MathUtils.PI2:V<-t.MathUtils.PI&&(V+=t.MathUtils.PI2),V*=i,N=Math.cos(V),k=Math.sin(V),D.a=N*R-k*O,D.b=N*L-k*F,D.c=k*R+N*O,D.d=k*L+N*F}D.appliedValid=!1}}}},e.prototype.computeWorldPositions=function(i,n,r,s,o){var a=this.target,h=this.position,l=this.spaces,c=t.Utils.setArraySize(this.positions,3*n+2),u=null,_=i.closed,f=i.worldVerticesLength,m=f/6,d=e.NONE;if(!i.constantSpeed){var p=i.lengths,y=p[m-=_?1:2];if(s&&(h*=y),o)for(var v=0;vy){d!=e.AFTER&&(d=e.AFTER,i.computeWorldVerticesWith(a,f-6,4,u,0)),this.addAfterPosition(A-y,u,0,c,g);continue}}for(;;x++){var b=p[x];if(!(A>b)){if(0==x)A/=b;else A=(A-(J=p[x-1]))/(b-J);break}}x!=d&&(d=x,_&&x==m?(i.computeWorldVerticesWith(a,f-4,4,u,0),i.computeWorldVerticesWith(a,0,4,u,4)):i.computeWorldVerticesWith(a,6*x+2,8,u,0)),this.addCurvePosition(A,u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],c,g,r||v>0&&0==H)}return c}_?(f+=2,u=t.Utils.setArraySize(this.world,f),i.computeWorldVerticesWith(a,2,f-4,u,0),i.computeWorldVerticesWith(a,0,2,u,f-4),u[f-2]=u[0],u[f-1]=u[1]):(m--,f-=4,u=t.Utils.setArraySize(this.world,f),i.computeWorldVerticesWith(a,2,f,u,0));for(var C=t.Utils.setArraySize(this.curves,m),S=0,T=u[0],w=u[1],E=0,D=0,B=0,M=0,P=0,I=0,R=0,L=0,O=0,F=0,V=0,N=0,k=0,G=0,z=(v=0,2);vS){this.addAfterPosition(A-S,u,f-4,c,g);continue}}for(;;x++){var X=C[x];if(!(A>X)){if(0==x)A/=X;else A=(A-(J=C[x-1]))/(X-J);break}}if(x!=d){d=x;var Y=6*x;for(T=u[Y],w=u[Y+1],E=u[Y+2],D=u[Y+3],B=u[Y+4],M=u[Y+5],P=u[Y+6],I=u[Y+7],V=2*(R=.03*(T-2*E+B))+(O=.006*(3*(E-B)-T+P)),N=2*(L=.03*(w-2*D+M))+(F=.006*(3*(D-M)-w+I)),k=.3*(E-T)+R+.16666667*O,G=.3*(D-w)+L+.16666667*F,W=Math.sqrt(k*k+G*G),U[0]=W,Y=1;Y<8;Y++)k+=V,G+=N,V+=O,N+=F,W+=Math.sqrt(k*k+G*G),U[Y]=W;k+=V,G+=N,W+=Math.sqrt(k*k+G*G),U[8]=W,k+=V+O,G+=N+F,W+=Math.sqrt(k*k+G*G),U[9]=W,j=0}for(A*=W;;j++){var q=U[j];if(!(A>q)){var J;if(0==j)A/=q;else A=j+(A-(J=U[j-1]))/(q-J);break}}this.addCurvePosition(.1*A,T,w,E,D,B,M,P,I,c,g,r||v>0&&0==H)}return c},e.prototype.addBeforePosition=function(t,e,i,n,r){var s=e[i],o=e[i+1],a=e[i+2]-s,h=e[i+3]-o,l=Math.atan2(h,a);n[r]=s+t*Math.cos(l),n[r+1]=o+t*Math.sin(l),n[r+2]=l},e.prototype.addAfterPosition=function(t,e,i,n,r){var s=e[i+2],o=e[i+3],a=s-e[i],h=o-e[i+1],l=Math.atan2(h,a);n[r]=s+t*Math.cos(l),n[r+1]=o+t*Math.sin(l),n[r+2]=l},e.prototype.addCurvePosition=function(t,e,i,n,r,s,o,a,h,l,c,u){(0==t||isNaN(t))&&(t=1e-4);var _=t*t,f=_*t,m=1-t,d=m*m,p=d*m,y=m*t,v=3*y,g=m*v,x=v*t,A=e*p+n*g+s*x+a*f,b=i*p+r*g+o*x+h*f;l[c]=A,l[c+1]=b,u&&(l[c+2]=Math.atan2(b-(i*d+r*y*2+o*_),A-(e*d+n*y*2+s*_)))},e.prototype.getOrder=function(){return this.data.order},e.NONE=-1,e.BEFORE=-2,e.AFTER=-3,e})();t.PathConstraint=e})(n||(n={})),(function(t){var e=(function(){return function(t){this.order=0,this.bones=new Array,this.name=t}})();t.PathConstraintData=e,(function(t){t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent"})(t.PositionMode||(t.PositionMode={}));t.PositionMode;(function(t){t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent"})(t.SpacingMode||(t.SpacingMode={}));t.SpacingMode;(function(t){t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale"})(t.RotateMode||(t.RotateMode={}));t.RotateMode})(n||(n={})),(function(t){var e=(function(){function t(t){this.toLoad=new Array,this.assets={},this.clientId=t}return t.prototype.loaded=function(){var t=0;for(var e in this.assets)t++;return t},t})(),i=(function(){function t(t){void 0===t&&(t=""),this.clientAssets={},this.queuedAssets={},this.rawAssets={},this.errors={},this.pathPrefix=t}return t.prototype.queueAsset=function(t,i,n){var r=this.clientAssets[t];return null!==r&&void 0!==r||(r=new e(t),this.clientAssets[t]=r),null!==i&&(r.textureLoader=i),r.toLoad.push(n),this.queuedAssets[n]!==n&&(this.queuedAssets[n]=n,!0)},t.prototype.loadText=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&(n.status>=200&&n.status<300?i.rawAssets[e]=n.responseText:i.errors[e]="Couldn't load text "+e+": status "+n.status+", "+n.responseText)},n.open("GET",e,!0),n.send()}},t.prototype.loadJson=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&(n.status>=200&&n.status<300?i.rawAssets[e]=JSON.parse(n.responseText):i.errors[e]="Couldn't load text "+e+": status "+n.status+", "+n.responseText)},n.open("GET",e,!0),n.send()}},t.prototype.loadTexture=function(t,e,i){var n=this;if(i=this.pathPrefix+i,this.queueAsset(t,e,i)){var r=new Image;r.src=i,r.crossOrigin="anonymous",r.onload=function(t){n.rawAssets[i]=r},r.onerror=function(t){n.errors[i]="Couldn't load image "+i}}},t.prototype.get=function(t,e){e=this.pathPrefix+e;var i=this.clientAssets[t];return null===i||void 0===i||i.assets[e]},t.prototype.updateClientAssets=function(t){for(var e=0;e0},t.prototype.getErrors=function(){return this.errors},t})();t.SharedAssetManager=i})(n||(n={})),(function(t){var e=(function(){function e(e){if(this._updateCache=new Array,this.updateCacheReset=new Array,this.time=0,this.flipX=!1,this.flipY=!1,this.x=0,this.y=0,null==e)throw new Error("data cannot be null.");this.data=e,this.bones=new Array;for(var i=0;i1){var r=i[i.length-1];this._updateCache.indexOf(r)>-1||this.updateCacheReset.push(r)}this._updateCache.push(t),this.sortReset(n.children),i[i.length-1].sorted=!0},e.prototype.sortPathConstraint=function(e){var i=e.target,n=i.data.index,r=i.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,n,r),null!=this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,n,r);for(var s=0,o=this.data.skins.length;s=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY},e.prototype.aabbIntersectsSegment=function(t,e,i,n){var r=this.minX,s=this.minY,o=this.maxX,a=this.maxY;if(t<=r&&i<=r||e<=s&&n<=s||t>=o&&i>=o||e>=a&&n>=a)return!1;var h=(n-e)/(i-t),l=h*(r-t)+e;if(l>s&&ls&&lr&&cr&&ct.minX&&this.minYt.minY},e.prototype.containsPoint=function(t,e){for(var i=this.polygons,n=0,r=i.length;n=i||l=i){var c=n[a];c+(i-h)/(l-h)*(n[s]-c)=c&&g<=f||g>=f&&g<=c)&&(g>=e&&g<=n||g>=n&&g<=e)){var x=(l*y-h*d)/v;if((x>=u&&x<=m||x>=m&&x<=u)&&(x>=i&&x<=r||x>=r&&x<=i))return!0}c=f,u=m}return!1},e.prototype.getPolygon=function(t){if(null==t)throw new Error("boundingBox cannot be null.");var e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]},e.prototype.getWidth=function(){return this.maxX-this.minX},e.prototype.getHeight=function(){return this.maxY-this.minY},e})();t.SkeletonBounds=e})(n||(n={})),(function(t){var e=(function(){function t(){this.bones=new Array,this.slots=new Array,this.skins=new Array,this.events=new Array,this.animations=new Array,this.ikConstraints=new Array,this.transformConstraints=new Array,this.pathConstraints=new Array,this.fps=0}return t.prototype.findBone=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i=0;_--)-1==U[_]&&(U[_]=j[--X])}v.setFrame(u++,z.time,U)}s.push(v),o=Math.max(o,v.frames[v.getFrameCount()-1])}if(e.events){for(v=new t.EventTimeline(e.events.length),u=0,_=0;_=n.length&&(n.length=t+1),n[t]||(n[t]={}),n[t][e]=i},t.prototype.getAttachment=function(t,e){var i=this.attachments[t];return i?i[e]:null},t.prototype.attachAll=function(t,e){for(var i=0,n=0;n= 0.");if(null==i)throw new Error("name cannot be null.");if(null==n)throw new Error("boneData cannot be null.");this.index=e,this.name=i,this.boneData=n}})();t.SlotData=e})(n||(n={})),(function(t){var e=(function(){function t(t){this._image=t}return t.prototype.getImage=function(){return this._image},t.filterFromString=function(t){switch(t.toLowerCase()){case"nearest":return i.Nearest;case"linear":return i.Linear;case"mipmap":return i.MipMap;case"mipmapnearestnearest":return i.MipMapNearestNearest;case"mipmaplinearnearest":return i.MipMapLinearNearest;case"mipmapnearestlinear":return i.MipMapNearestLinear;case"mipmaplinearlinear":return i.MipMapLinearLinear;default:throw new Error("Unknown texture filter "+t)}},t.wrapFromString=function(t){switch(t.toLowerCase()){case"mirroredtepeat":return n.MirroredRepeat;case"clamptoedge":return n.ClampToEdge;case"repeat":return n.Repeat;default:throw new Error("Unknown texture wrap "+t)}},t})();t.Texture=e,(function(t){t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear"})(t.TextureFilter||(t.TextureFilter={}));var i=t.TextureFilter;(function(t){t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat"})(t.TextureWrap||(t.TextureWrap={}));var n=t.TextureWrap,r=(function(){return function(){this.u=0,this.v=0,this.u2=0,this.v2=0,this.width=0,this.height=0,this.rotate=!1,this.offsetX=0,this.offsetY=0,this.originalWidth=0,this.originalHeight=0}})();t.TextureRegion=r})(n||(n={})),(function(t){var e=(function(){function e(t,e){this.pages=new Array,this.regions=new Array,this.load(t,e)}return e.prototype.load=function(e,r){if(null==r)throw new Error("textureLoader cannot be null.");for(var o=new i(e),a=new Array(4),h=null;;){var l=o.readLine();if(null==l)break;if(0==(l=l.trim()).length)h=null;else if(h){var c=new s;c.name=l,c.page=h,c.rotate="true"==o.readValue(),o.readTuple(a);var u=parseInt(a[0]),_=parseInt(a[1]);o.readTuple(a);var f=parseInt(a[0]),m=parseInt(a[1]);c.u=u/h.width,c.v=_/h.height,c.rotate?(c.u2=(u+m)/h.width,c.v2=(_+f)/h.height):(c.u2=(u+f)/h.width,c.v2=(_+m)/h.height),c.x=u,c.y=_,c.width=Math.abs(f),c.height=Math.abs(m),4==o.readTuple(a)&&4==o.readTuple(a)&&o.readTuple(a),c.originalWidth=parseInt(a[0]),c.originalHeight=parseInt(a[1]),o.readTuple(a),c.offsetX=parseInt(a[0]),c.offsetY=parseInt(a[1]),c.index=parseInt(o.readValue()),c.texture=h.texture,this.regions.push(c)}else{(h=new n).name=l,2==o.readTuple(a)&&(h.width=parseInt(a[0]),h.height=parseInt(a[1]),o.readTuple(a)),o.readTuple(a),h.minFilter=t.Texture.filterFromString(a[0]),h.magFilter=t.Texture.filterFromString(a[1]);var d=o.readValue();h.uWrap=t.TextureWrap.ClampToEdge,h.vWrap=t.TextureWrap.ClampToEdge,"x"==d?h.uWrap=t.TextureWrap.Repeat:"y"==d?h.vWrap=t.TextureWrap.Repeat:"xy"==d&&(h.uWrap=h.vWrap=t.TextureWrap.Repeat),h.texture=r(l),h.texture.setFilters(h.minFilter,h.magFilter),h.texture.setWraps(h.uWrap,h.vWrap),h.width=h.texture.getImage().width,h.height=h.texture.getImage().height,this.pages.push(h)}}},e.prototype.findRegion=function(t){for(var e=0;e=this.lines.length?null:this.lines[this.index++]},t.prototype.readValue=function(){var t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()},t.prototype.readTuple=function(t){var e=this.readLine(),i=e.indexOf(":");if(-1==i)throw new Error("Invalid line: "+e);for(var n=0,r=i+1;n<3;n++){var s=e.indexOf(",",r);if(-1==s)break;t[n]=e.substr(r,s-r).trim(),r=s+1}return t[n]=e.substring(r).trim(),n+1},t})(),n=(function(){return function(){}})();t.TextureAtlasPage=n;var s=(function(t){function e(){t.apply(this,arguments)}return r(e,t),e})(t.TextureRegion);t.TextureAtlasRegion=s})(n||(n={})),(function(t){var e=(function(){function e(e,i){if(this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.temp=new t.Vector2,null==e)throw new Error("data cannot be null.");if(null==i)throw new Error("skeleton cannot be null.");this.data=e,this.rotateMix=e.rotateMix,this.translateMix=e.translateMix,this.scaleMix=e.scaleMix,this.shearMix=e.shearMix,this.bones=new Array;for(var n=0;n0?t.MathUtils.degRad:-t.MathUtils.degRad,u=this.data.offsetRotation*c,_=this.data.offsetShearY*c,f=this.bones,m=0,d=f.length;mt.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E*=e;var b=Math.cos(E),C=Math.sin(E);p.a=b*v-C*x,p.b=b*g-C*A,p.c=C*v+b*x,p.d=C*g+b*A,y=!0}if(0!=i){var S=this.temp;s.localToWorld(S.set(this.data.offsetX,this.data.offsetY)),p.worldX+=(S.x-p.worldX)*i,p.worldY+=(S.y-p.worldY)*i,y=!0}if(n>0){var T=Math.sqrt(p.a*p.a+p.c*p.c),w=Math.sqrt(o*o+h*h);T>1e-5&&(T=(T+(w-T+this.data.offsetScaleX)*n)/T),p.a*=T,p.c*=T,T=Math.sqrt(p.b*p.b+p.d*p.d),w=Math.sqrt(a*a+l*l),T>1e-5&&(T=(T+(w-T+this.data.offsetScaleY)*n)/T),p.b*=T,p.d*=T,y=!0}if(r>0){g=p.b,A=p.d;var E,D=Math.atan2(A,g);(E=Math.atan2(l,a)-Math.atan2(h,o)-(D-Math.atan2(p.c,p.a)))>t.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E=D+(E+_)*r;T=Math.sqrt(g*g+A*A);p.b=Math.cos(E)*T,p.d=Math.sin(E)*T,y=!0}y&&(p.appliedValid=!1)}},e.prototype.getOrder=function(){return this.data.order},e})();t.TransformConstraint=e})(n||(n={})),(function(t){var e=(function(){return function(t){if(this.order=0,this.bones=new Array,this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.offsetRotation=0,this.offsetX=0,this.offsetY=0,this.offsetScaleX=0,this.offsetScaleY=0,this.offsetShearY=0,null==t)throw new Error("name cannot be null.");this.name=t}})();t.TransformConstraintData=e})(n||(n={})),(function(t){var e=(function(){function t(){this.array=new Array}return t.prototype.add=function(t){var e=this.contains(t);return this.array[0|t]=0|t,!e},t.prototype.contains=function(t){return void 0!=this.array[0|t]},t.prototype.remove=function(t){this.array[0|t]=void 0},t.prototype.clear=function(){this.array.length=0},t})();t.IntSet=e;var i=(function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.r=t,this.g=e,this.b=i,this.a=n}return t.prototype.set=function(t,e,i,n){return this.r=t,this.g=e,this.b=i,this.a=n,this.clamp(),this},t.prototype.setFromColor=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.setFromString=function(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=(8!=t.length?255:parseInt(t.substr(6,2),16))/255,this},t.prototype.add=function(t,e,i,n){return this.r+=t,this.g+=e,this.b+=i,this.a+=n,this.clamp(),this},t.prototype.clamp=function(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this},t.WHITE=new t(1,1,1,1),t.RED=new t(1,0,0,1),t.GREEN=new t(0,1,0,1),t.BLUE=new t(0,0,1,1),t.MAGENTA=new t(1,0,1,1),t})();t.Color=i;var n=(function(){function t(){}return t.clamp=function(t,e,i){return ti?i:t},t.cosDeg=function(e){return Math.cos(e*t.degRad)},t.sinDeg=function(e){return Math.sin(e*t.degRad)},t.signum=function(t){return t>0?1:t<0?-1:0},t.toInt=function(t){return t>0?Math.floor(t):Math.ceil(t)},t.cbrt=function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},t.PI=3.1415927,t.PI2=2*t.PI,t.radiansToDegrees=180/t.PI,t.radDeg=t.radiansToDegrees,t.degreesToRadians=t.PI/180,t.degRad=t.degreesToRadians,t})();t.MathUtils=n;var r=(function(){function t(){}return t.arrayCopy=function(t,e,i,n,r){for(var s=e,o=n;s=i?e:t.setArraySize(e,i,n)},t.newArray=function(t,e){for(var i=new Array(t),n=0;n0?this.items.pop():this.instantiator()},t.prototype.free=function(t){t.reset&&t.reset(),this.items.push(t)},t.prototype.freeAll=function(t){for(var e=0;ethis.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)},t})();t.TimeKeeper=h})(n||(n={})),e.exports=n}),{}],288:[(function(t,e,i){var n=cc.Class({name:"sp.SkeletonData",extends:cc.Asset,ctor:function(){this.reset()},properties:{_skeletonJson:null,skeletonJson:{get:function(){return this._skeletonJson},set:function(t){this._skeletonJson=t,this.reset()}},_atlasText:"",atlasText:{get:function(){return this._atlasText},set:function(t){this._atlasText=t,this.reset()}},textures:{default:[],type:[cc.Texture2D]},textureNames:{default:[],type:[cc.String]},scale:1},statics:{preventDeferredLoadDependents:!0,preventPreloadNativeObject:!0},createNode:!1,reset:function(){this._skeletonCache=null,this._atlasCache=null},getRuntimeData:function(t){if(this._skeletonCache)return this._skeletonCache;if(!(this.textures&&this.textures.length>0)&&this.textureNames&&this.textureNames.length>0)return t||cc.errorID(7507,this.name),null;var e=this._getAtlas(t);if(!e)return null;var i=new sp.spine.AtlasAttachmentLoader(e),n=new sp.spine.SkeletonJson(i);n.scale=this.scale;var r=this.skeletonJson;return this._skeletonCache=n.readSkeletonData(r),e.dispose(n),this._skeletonCache},getSkinsEnum:!1,getAnimsEnum:!1,_getTexture:function(t){for(var e=this.textureNames,i=0;i>>0)+(x<<16)+(g<<8)+v,b=l[o];b.x=a[p],b.y=a[p+1],b.color=A,b.u=a[p+6],b.v=a[p+7],o++}if(t.debugSlots&&4===h){var C=t._debugRenderer,S=s.RegionAttachment;C.strokeColor=m,C.lineWidth=5,C.moveTo(a[S.X1],a[S.Y1]),C.lineTo(a[S.X2],a[S.Y2]),C.lineTo(a[S.X3],a[S.Y3]),C.lineTo(a[S.X4],a[S.Y4]),C.close(),C.stroke()}return h},genRenderDatas:function(t,e){var i=t._skeleton,n=t.premultipliedAlpha,r=t._debugRenderer;(t.debugBones||t.debugSlots)&&r.clear();var o=void 0,a=void 0,h=void 0,l=void 0,c=0,u=t._renderDatas,_=u[c],f=!1;_||(_=u[c]=t.requestRenderData()),_.dataLength=0;for(var y=void 0,v=null,x=null,A=0,b=0,C=0,S=0,T=0,w=i.drawOrder.length;T0&&S>0?c+1:c,t.debugBones){var B=void 0;r.lineWidth=5,r.strokeColor=d,r.fillColor=m;for(var M=0,P=i.bones.length;M>2,p=o.vertexCount,y=m.indiceOffset,g=m.vertexOffset;m.request(p,o.indiceCount);for(var x=m._vData,A=m._iData,b=m._uintVData,C=void 0,S=0,T=o.dataLength;Si?i:t}var b=isFinite;function C(t){return t*t}function S(t){return 1/Math.sqrt(t)}var T=Math.sqrt,w=Math.pow;var E=Math.cos,D=Math.sin,B=Math.acos,M=Math.asin,P=Math.atan2;var I=(function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.Clone=function(){return new t(this.x,this.y)},t.prototype.SetZero=function(){return this.x=0,this.y=0,this},t.prototype.Set=function(t,e){return this.x=t,this.y=e,this},t.prototype.Copy=function(t){return this.x=t.x,this.y=t.y,this},t.prototype.SelfAdd=function(t){return this.x+=t.x,this.y+=t.y,this},t.prototype.SelfAddXY=function(t,e){return this.x+=t,this.y+=e,this},t.prototype.SelfSub=function(t){return this.x-=t.x,this.y-=t.y,this},t.prototype.SelfSubXY=function(t,e){return this.x-=t,this.y-=e,this},t.prototype.SelfMul=function(t){return this.x*=t,this.y*=t,this},t.prototype.SelfMulAdd=function(t,e){return this.x+=t*e.x,this.y+=t*e.y,this},t.prototype.SelfMulSub=function(t,e){return this.x-=t*e.x,this.y-=t*e.y,this},t.prototype.Dot=function(t){return this.x*t.x+this.y*t.y},t.prototype.Cross=function(t){return this.x*t.y-this.y*t.x},t.prototype.Length=function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},t.prototype.LengthSquared=function(){var t=this.x,e=this.y;return t*t+e*e},t.prototype.Normalize=function(){var t=this.Length();if(t>=n){var e=1/t;this.x*=e,this.y*=e}return t},t.prototype.SelfNormalize=function(){var t=this.Length();if(t>=n){var e=1/t;this.x*=e,this.y*=e}return this},t.prototype.SelfRotate=function(t){var e=Math.cos(t),i=Math.sin(t),n=this.x;return this.x=e*n-i*this.y,this.y=i*n+e*this.y,this},t.prototype.IsValid=function(){return isFinite(this.x)&&isFinite(this.y)},t.prototype.SelfCrossVS=function(t){var e=this.x;return this.x=t*this.y,this.y=-t*e,this},t.prototype.SelfCrossSV=function(t){var e=this.x;return this.x=-t*this.y,this.y=t*e,this},t.prototype.SelfMinV=function(t){return this.x=g(this.x,t.x),this.y=g(this.y,t.y),this},t.prototype.SelfMaxV=function(t){return this.x=x(this.x,t.x),this.y=x(this.y,t.y),this},t.prototype.SelfAbs=function(){return this.x=v(this.x),this.y=v(this.y),this},t.prototype.SelfNeg=function(){return this.x=-this.x,this.y=-this.y,this},t.prototype.SelfSkew=function(){var t=this.x;return this.x=-this.y,this.y=t,this},t.MakeArray=function(e){return m(e,(function(e){return new t}))},t.AbsV=function(t,e){return e.x=v(t.x),e.y=v(t.y),e},t.MinV=function(t,e,i){return i.x=g(t.x,e.x),i.y=g(t.y,e.y),i},t.MaxV=function(t,e,i){return i.x=x(t.x,e.x),i.y=x(t.y,e.y),i},t.ClampV=function(t,e,i,n){return n.x=A(t.x,e.x,i.x),n.y=A(t.y,e.y,i.y),n},t.RotateV=function(t,e,i){var n=t.x,r=t.y,s=Math.cos(e),o=Math.sin(e);return i.x=s*n-o*r,i.y=o*n+s*r,i},t.DotVV=function(t,e){return t.x*e.x+t.y*e.y},t.CrossVV=function(t,e){return t.x*e.y-t.y*e.x},t.CrossVS=function(t,e,i){var n=t.x;return i.x=e*t.y,i.y=-e*n,i},t.CrossVOne=function(t,e){var i=t.x;return e.x=t.y,e.y=-i,e},t.CrossSV=function(t,e,i){var n=e.x;return i.x=-t*e.y,i.y=t*n,i},t.CrossOneV=function(t,e){var i=t.x;return e.x=-t.y,e.y=i,e},t.AddVV=function(t,e,i){return i.x=t.x+e.x,i.y=t.y+e.y,i},t.SubVV=function(t,e,i){return i.x=t.x-e.x,i.y=t.y-e.y,i},t.MulSV=function(t,e,i){return i.x=e.x*t,i.y=e.y*t,i},t.MulVS=function(t,e,i){return i.x=t.x*e,i.y=t.y*e,i},t.AddVMulSV=function(t,e,i,n){return n.x=t.x+e*i.x,n.y=t.y+e*i.y,n},t.SubVMulSV=function(t,e,i,n){return n.x=t.x-e*i.x,n.y=t.y-e*i.y,n},t.AddVCrossSV=function(t,e,i,n){var r=i.x;return n.x=t.x-e*i.y,n.y=t.y+e*r,n},t.MidVV=function(t,e,i){return i.x=.5*(t.x+e.x),i.y=.5*(t.y+e.y),i},t.ExtVV=function(t,e,i){return i.x=.5*(e.x-t.x),i.y=.5*(e.y-t.y),i},t.IsEqualToV=function(t,e){return t.x===e.x&&t.y===e.y},t.DistanceVV=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},t.DistanceSquaredVV=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},t.NegV=function(t,e){return e.x=-t.x,e.y=-t.y,e},t.ZERO=new t(0,0),t.UNITX=new t(1,0),t.UNITY=new t(0,1),t.s_t0=new t,t.s_t1=new t,t.s_t2=new t,t.s_t3=new t,t})(),R=new I(0,0),L=(function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=i}return t.prototype.Clone=function(){return new t(this.x,this.y,this.z)},t.prototype.SetZero=function(){return this.x=0,this.y=0,this.z=0,this},t.prototype.SetXYZ=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},t.prototype.Copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.SelfNeg=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},t.prototype.SelfAdd=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},t.prototype.SelfAddXYZ=function(t,e,i){return this.x+=t,this.y+=e,this.z+=i,this},t.prototype.SelfSub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},t.prototype.SelfSubXYZ=function(t,e,i){return this.x-=t,this.y-=e,this.z-=i,this},t.prototype.SelfMul=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.DotV3V3=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},t.CrossV3V3=function(t,e,i){var n=t.x,r=t.y,s=t.z,o=e.x,a=e.y,h=e.z;return i.x=r*h-s*a,i.y=s*o-n*h,i.z=n*a-r*o,i},t.ZERO=new t(0,0,0),t.s_t0=new t,t})(),O=(function(){function t(){this.ex=new I(1,0),this.ey=new I(0,1)}return t.prototype.Clone=function(){return(new t).Copy(this)},t.FromVV=function(e,i){return(new t).SetVV(e,i)},t.FromSSSS=function(e,i,n,r){return(new t).SetSSSS(e,i,n,r)},t.FromAngle=function(e){return(new t).SetAngle(e)},t.prototype.SetSSSS=function(t,e,i,n){return this.ex.Set(t,i),this.ey.Set(e,n),this},t.prototype.SetVV=function(t,e){return this.ex.Copy(t),this.ey.Copy(e),this},t.prototype.SetAngle=function(t){var e=Math.cos(t),i=Math.sin(t);return this.ex.Set(e,i),this.ey.Set(-i,e),this},t.prototype.Copy=function(t){return this.ex.Copy(t.ex),this.ey.Copy(t.ey),this},t.prototype.SetIdentity=function(){return this.ex.Set(1,0),this.ey.Set(0,1),this},t.prototype.SetZero=function(){return this.ex.SetZero(),this.ey.SetZero(),this},t.prototype.GetAngle=function(){return Math.atan2(this.ex.y,this.ex.x)},t.prototype.GetInverse=function(t){var e=this.ex.x,i=this.ey.x,n=this.ex.y,r=this.ey.y,s=e*r-i*n;return 0!==s&&(s=1/s),t.ex.x=s*r,t.ey.x=-s*i,t.ex.y=-s*n,t.ey.y=s*e,t},t.prototype.Solve=function(t,e,i){var n=this.ex.x,r=this.ey.x,s=this.ex.y,o=this.ey.y,a=n*o-r*s;return 0!==a&&(a=1/a),i.x=a*(o*t-r*e),i.y=a*(n*e-s*t),i},t.prototype.SelfAbs=function(){return this.ex.SelfAbs(),this.ey.SelfAbs(),this},t.prototype.SelfInv=function(){return this.GetInverse(this),this},t.prototype.SelfAddM=function(t){return this.ex.SelfAdd(t.ex),this.ey.SelfAdd(t.ey),this},t.prototype.SelfSubM=function(t){return this.ex.SelfSub(t.ex),this.ey.SelfSub(t.ey),this},t.AbsM=function(t,e){var i=t.ex,n=t.ey;return e.ex.x=v(i.x),e.ex.y=v(i.y),e.ey.x=v(n.x),e.ey.y=v(n.y),e},t.MulMV=function(t,e,i){var n=t.ex,r=t.ey,s=e.x,o=e.y;return i.x=n.x*s+r.x*o,i.y=n.y*s+r.y*o,i},t.MulTMV=function(t,e,i){var n=t.ex,r=t.ey,s=e.x,o=e.y;return i.x=n.x*s+n.y*o,i.y=r.x*s+r.y*o,i},t.AddMM=function(t,e,i){var n=t.ex,r=t.ey,s=e.ex,o=e.ey;return i.ex.x=n.x+s.x,i.ex.y=n.y+s.y,i.ey.x=r.x+o.x,i.ey.y=r.y+o.y,i},t.MulMM=function(t,e,i){var n=t.ex.x,r=t.ex.y,s=t.ey.x,o=t.ey.y,a=e.ex.x,h=e.ex.y,l=e.ey.x,c=e.ey.y;return i.ex.x=n*a+s*h,i.ex.y=r*a+o*h,i.ey.x=n*l+s*c,i.ey.y=r*l+o*c,i},t.MulTMM=function(t,e,i){var n=t.ex.x,r=t.ex.y,s=t.ey.x,o=t.ey.y,a=e.ex.x,h=e.ex.y,l=e.ey.x,c=e.ey.y;return i.ex.x=n*a+r*h,i.ex.y=s*a+o*h,i.ey.x=n*l+r*c,i.ey.y=s*l+o*c,i},t.IDENTITY=new t,t})(),F=(function(){function t(){this.ex=new L(1,0,0),this.ey=new L(0,1,0),this.ez=new L(0,0,1)}return t.prototype.Clone=function(){return(new t).Copy(this)},t.prototype.SetVVV=function(t,e,i){return this.ex.Copy(t),this.ey.Copy(e),this.ez.Copy(i),this},t.prototype.Copy=function(t){return this.ex.Copy(t.ex),this.ey.Copy(t.ey),this.ez.Copy(t.ez),this},t.prototype.SetIdentity=function(){return this.ex.SetXYZ(1,0,0),this.ey.SetXYZ(0,1,0),this.ez.SetXYZ(0,0,1),this},t.prototype.SetZero=function(){return this.ex.SetZero(),this.ey.SetZero(),this.ez.SetZero(),this},t.prototype.SelfAddM=function(t){return this.ex.SelfAdd(t.ex),this.ey.SelfAdd(t.ey),this.ez.SelfAdd(t.ez),this},t.prototype.Solve33=function(t,e,i,n){var r=this.ex.x,s=this.ex.y,o=this.ex.z,a=this.ey.x,h=this.ey.y,l=this.ey.z,c=this.ez.x,u=this.ez.y,_=this.ez.z,f=r*(h*_-l*u)+s*(l*c-a*_)+o*(a*u-h*c);return 0!==f&&(f=1/f),n.x=f*(t*(h*_-l*u)+e*(l*c-a*_)+i*(a*u-h*c)),n.y=f*(r*(e*_-i*u)+s*(i*c-t*_)+o*(t*u-e*c)),n.z=f*(r*(h*i-l*e)+s*(l*t-a*i)+o*(a*e-h*t)),n},t.prototype.Solve22=function(t,e,i){var n=this.ex.x,r=this.ey.x,s=this.ex.y,o=this.ey.y,a=n*o-r*s;return 0!==a&&(a=1/a),i.x=a*(o*t-r*e),i.y=a*(n*e-s*t),i},t.prototype.GetInverse22=function(t){var e=this.ex.x,i=this.ey.x,n=this.ex.y,r=this.ey.y,s=e*r-i*n;0!==s&&(s=1/s),t.ex.x=s*r,t.ey.x=-s*i,t.ex.z=0,t.ex.y=-s*n,t.ey.y=s*e,t.ey.z=0,t.ez.x=0,t.ez.y=0,t.ez.z=0},t.prototype.GetSymInverse33=function(t){var e=L.DotV3V3(this.ex,L.CrossV3V3(this.ey,this.ez,L.s_t0));0!==e&&(e=1/e);var i=this.ex.x,n=this.ey.x,r=this.ez.x,s=this.ey.y,o=this.ez.y,a=this.ez.z;t.ex.x=e*(s*a-o*o),t.ex.y=e*(r*o-n*a),t.ex.z=e*(n*o-r*s),t.ey.x=t.ex.y,t.ey.y=e*(i*a-r*r),t.ey.z=e*(r*n-i*o),t.ez.x=t.ex.z,t.ez.y=t.ey.z,t.ez.z=e*(i*s-n*n)},t.MulM33V3=function(t,e,i){var n=e.x,r=e.y,s=e.z;return i.x=t.ex.x*n+t.ey.x*r+t.ez.x*s,i.y=t.ex.y*n+t.ey.y*r+t.ez.y*s,i.z=t.ex.z*n+t.ey.z*r+t.ez.z*s,i},t.MulM33XYZ=function(t,e,i,n,r){return r.x=t.ex.x*e+t.ey.x*i+t.ez.x*n,r.y=t.ex.y*e+t.ey.y*i+t.ez.y*n,r.z=t.ex.z*e+t.ey.z*i+t.ez.z*n,r},t.MulM33V2=function(t,e,i){var n=e.x,r=e.y;return i.x=t.ex.x*n+t.ey.x*r,i.y=t.ex.y*n+t.ey.y*r,i},t.MulM33XY=function(t,e,i,n){return n.x=t.ex.x*e+t.ey.x*i,n.y=t.ex.y*e+t.ey.y*i,n},t.IDENTITY=new t,t})(),V=(function(){function t(t){void 0===t&&(t=0),this.s=0,this.c=1,t&&(this.s=Math.sin(t),this.c=Math.cos(t))}return t.prototype.Clone=function(){return(new t).Copy(this)},t.prototype.Copy=function(t){return this.s=t.s,this.c=t.c,this},t.prototype.SetAngle=function(t){return this.s=Math.sin(t),this.c=Math.cos(t),this},t.prototype.SetIdentity=function(){return this.s=0,this.c=1,this},t.prototype.GetAngle=function(){return Math.atan2(this.s,this.c)},t.prototype.GetXAxis=function(t){return t.x=this.c,t.y=this.s,t},t.prototype.GetYAxis=function(t){return t.x=-this.s,t.y=this.c,t},t.MulRR=function(t,e,i){var n=t.c,r=t.s,s=e.c,o=e.s;return i.s=r*s+n*o,i.c=n*s-r*o,i},t.MulTRR=function(t,e,i){var n=t.c,r=t.s,s=e.c,o=e.s;return i.s=n*o-r*s,i.c=n*s+r*o,i},t.MulRV=function(t,e,i){var n=t.c,r=t.s,s=e.x,o=e.y;return i.x=n*s-r*o,i.y=r*s+n*o,i},t.MulTRV=function(t,e,i){var n=t.c,r=t.s,s=e.x,o=e.y;return i.x=n*s+r*o,i.y=-r*s+n*o,i},t.IDENTITY=new t,t})(),N=(function(){function t(){this.p=new I,this.q=new V}return t.prototype.Clone=function(){return(new t).Copy(this)},t.prototype.Copy=function(t){return this.p.Copy(t.p),this.q.Copy(t.q),this},t.prototype.SetIdentity=function(){return this.p.SetZero(),this.q.SetIdentity(),this},t.prototype.SetPositionRotation=function(t,e){return this.p.Copy(t),this.q.Copy(e),this},t.prototype.SetPositionAngle=function(t,e){return this.p.Copy(t),this.q.SetAngle(e),this},t.prototype.SetPosition=function(t){return this.p.Copy(t),this},t.prototype.SetPositionXY=function(t,e){return this.p.Set(t,e),this},t.prototype.SetRotation=function(t){return this.q.Copy(t),this},t.prototype.SetRotationAngle=function(t){return this.q.SetAngle(t),this},t.prototype.GetPosition=function(){return this.p},t.prototype.GetRotation=function(){return this.q},t.prototype.GetRotationAngle=function(){return this.q.GetAngle()},t.prototype.GetAngle=function(){return this.q.GetAngle()},t.MulXV=function(t,e,i){var n=t.q.c,r=t.q.s,s=e.x,o=e.y;return i.x=n*s-r*o+t.p.x,i.y=r*s+n*o+t.p.y,i},t.MulTXV=function(t,e,i){var n=t.q.c,r=t.q.s,s=e.x-t.p.x,o=e.y-t.p.y;return i.x=n*s+r*o,i.y=-r*s+n*o,i},t.MulXX=function(t,e,i){return V.MulRR(t.q,e.q,i.q),I.AddVV(V.MulRV(t.q,e.p,i.p),t.p,i.p),i},t.MulTXX=function(t,e,i){return V.MulTRR(t.q,e.q,i.q),V.MulTRV(t.q,I.SubVV(e.p,t.p,i.p),i.p),i},t.IDENTITY=new t,t})(),k=(function(){function t(){this.localCenter=new I,this.c0=new I,this.c=new I,this.a0=0,this.a=0,this.alpha0=0}return t.prototype.Clone=function(){return(new t).Copy(this)},t.prototype.Copy=function(t){return this.localCenter.Copy(t.localCenter),this.c0.Copy(t.c0),this.c.Copy(t.c),this.a0=t.a0,this.a=t.a,this.alpha0=t.alpha0,this},t.prototype.GetTransform=function(t,e){var i=1-e;t.p.x=i*this.c0.x+e*this.c.x,t.p.y=i*this.c0.y+e*this.c.y;var n=i*this.a0+e*this.a;return t.q.SetAngle(n),t.p.SelfSub(V.MulRV(t.q,this.localCenter,I.s_t0)),t},t.prototype.Advance=function(t){var e=(t-this.alpha0)/(1-this.alpha0),i=1-e;this.c0.x=i*this.c0.x+e*this.c.x,this.c0.y=i*this.c0.y+e*this.c.y,this.a0=i*this.a0+e*this.a,this.alpha0=t},t.prototype.Normalize=function(){var t=6.28318530718*Math.floor(this.a0/6.28318530718);this.a0-=t,this.a-=t},t})(),G=(function(){function t(t,e,i,n){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=.5),void 0===n&&(n=1),this.r=t,this.g=e,this.b=i,this.a=n}return t.prototype.Clone=function(){return(new t).Copy(this)},t.prototype.Copy=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.IsEqual=function(t){return this.r===t.r&&this.g===t.g&&this.b===t.b&&this.a===t.a},t.prototype.IsZero=function(){return 0===this.r&&0===this.g&&0===this.b&&0===this.a},t.prototype.Set=function(t,e,i,n){void 0===n&&(n=this.a),this.SetRGBA(t,e,i,n)},t.prototype.SetByteRGB=function(t,e,i){return this.r=t/255,this.g=e/255,this.b=i/255,this},t.prototype.SetByteRGBA=function(t,e,i,n){return this.r=t/255,this.g=e/255,this.b=i/255,this.a=n/255,this},t.prototype.SetRGB=function(t,e,i){return this.r=t,this.g=e,this.b=i,this},t.prototype.SetRGBA=function(t,e,i,n){return this.r=t,this.g=e,this.b=i,this.a=n,this},t.prototype.SelfAdd=function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a,this},t.prototype.Add=function(t,e){return e.r=this.r+t.r,e.g=this.g+t.g,e.b=this.b+t.b,e.a=this.a+t.a,e},t.prototype.SelfSub=function(t){return this.r-=t.r,this.g-=t.g,this.b-=t.b,this.a-=t.a,this},t.prototype.Sub=function(t,e){return e.r=this.r-t.r,e.g=this.g-t.g,e.b=this.b-t.b,e.a=this.a-t.a,e},t.prototype.SelfMul=function(t){return this.r*=t,this.g*=t,this.b*=t,this.a*=t,this},t.prototype.Mul=function(t,e){return e.r=this.r*t,e.g=this.g*t,e.b=this.b*t,e.a=this.a*t,e},t.prototype.Mix=function(e,i){t.MixColors(this,e,i)},t.MixColors=function(t,e,i){var n=i*(e.r-t.r),r=i*(e.g-t.g),s=i*(e.b-t.b),o=i*(e.a-t.a);t.r+=n,t.g+=r,t.b+=s,t.a+=o,e.r-=n,e.g-=r,e.b-=s,e.a-=o},t.prototype.MakeStyleString=function(e){return void 0===e&&(e=this.a),t.MakeStyleString(this.r,this.g,this.b,e)},t.MakeStyleString=function(t,e,i,n){return void 0===n&&(n=1),t*=255,e*=255,i*=255,n<1?"rgba("+t+","+e+","+i+","+n+")":"rgb("+t+","+e+","+i+")"},t.ZERO=new t(0,0,0,0),t.RED=new t(1,0,0),t.GREEN=new t(0,1,0),t.BLUE=new t(0,0,1),t})();(function(t){t[t.e_none=0]="e_none",t[t.e_shapeBit=1]="e_shapeBit",t[t.e_jointBit=2]="e_jointBit",t[t.e_aabbBit=4]="e_aabbBit",t[t.e_pairBit=8]="e_pairBit",t[t.e_centerOfMassBit=16]="e_centerOfMassBit",t[t.e_particleBit=32]="e_particleBit",t[t.e_controllerBit=64]="e_controllerBit",t[t.e_all=63]="e_all"})(t.b2DrawFlags||(t.b2DrawFlags={}));var z=(function(){function t(){this.m_drawFlags=0}return t.prototype.SetFlags=function(t){this.m_drawFlags=t},t.prototype.GetFlags=function(){return this.m_drawFlags},t.prototype.AppendFlags=function(t){this.m_drawFlags|=t},t.prototype.ClearFlags=function(t){this.m_drawFlags&=~t},t})(),U=(function(){function t(){this.m_start=Date.now()}return t.prototype.Reset=function(){return this.m_start=Date.now(),this},t.prototype.GetMilliseconds=function(){return Date.now()-this.m_start},t})(),W=(function(){function t(){this.m_count=0,this.m_min_count=0,this.m_max_count=0}return t.prototype.GetCount=function(){return this.m_count},t.prototype.GetMinCount=function(){return this.m_min_count},t.prototype.GetMaxCount=function(){return this.m_max_count},t.prototype.ResetCount=function(){var t=this.m_count;return this.m_count=0,t},t.prototype.ResetMinCount=function(){this.m_min_count=0},t.prototype.ResetMaxCount=function(){this.m_max_count=0},t.prototype.Increment=function(){this.m_count++,this.m_max_countthis.m_count&&(this.m_min_count=this.m_count)},t})(),j=(function(){function t(t){this.m_stack=[],this.m_count=0,this.m_stack=m(t,(function(t){return null})),this.m_count=0}return t.prototype.Reset=function(){return this.m_count=0,this},t.prototype.Push=function(t){this.m_stack[this.m_count]=t,this.m_count++},t.prototype.Pop=function(){this.m_count--;var t=this.m_stack[this.m_count];if(this.m_stack[this.m_count]=null,null===t)throw new Error;return t},t.prototype.GetCount=function(){return this.m_count},t})(),H=(function(){return function(){}})(),X=(function(){return function(){}})(),Y=(function(){function t(){this.m_buffer=I.MakeArray(2),this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0}return t.prototype.Copy=function(t){return t.m_vertices===t.m_buffer?(this.m_vertices=this.m_buffer,this.m_buffer[0].Copy(t.m_buffer[0]),this.m_buffer[1].Copy(t.m_buffer[1])):this.m_vertices=t.m_vertices,this.m_count=t.m_count,this.m_radius=t.m_radius,this},t.prototype.Reset=function(){return this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0,this},t.prototype.SetShape=function(t,e){t.SetupDistanceProxy(this,e)},t.prototype.SetVerticesRadius=function(t,e,i){this.m_vertices=t,this.m_count=e,this.m_radius=i},t.prototype.GetSupport=function(t){for(var e=0,i=I.DotVV(this.m_vertices[0],t),n=1;ni&&(e=n,i=r)}return e},t.prototype.GetSupportVertex=function(t){for(var e=0,i=I.DotVV(this.m_vertices[0],t),n=1;ni&&(e=n,i=r)}return this.m_vertices[e]},t.prototype.GetVertexCount=function(){return this.m_count},t.prototype.GetVertex=function(t){return this.m_vertices[t]},t})(),q=(function(){function t(){this.metric=0,this.count=0,this.indexA=[0,0,0],this.indexB=[0,0,0]}return t.prototype.Reset=function(){return this.metric=0,this.count=0,this},t})(),J=(function(){function t(){this.proxyA=new Y,this.proxyB=new Y,this.transformA=new N,this.transformB=new N,this.useRadii=!1}return t.prototype.Reset=function(){return this.proxyA.Reset(),this.proxyB.Reset(),this.transformA.SetIdentity(),this.transformB.SetIdentity(),this.useRadii=!1,this},t})(),Z=(function(){function t(){this.pointA=new I,this.pointB=new I,this.distance=0,this.iterations=0}return t.prototype.Reset=function(){return this.pointA.SetZero(),this.pointB.SetZero(),this.distance=0,this.iterations=0,this},t})(),K=(function(){return function(){this.proxyA=new Y,this.proxyB=new Y,this.transformA=new N,this.transformB=new N,this.translationB=new I}})(),Q=(function(){return function(){this.point=new I,this.normal=new I,this.lambda=0,this.iterations=0}})();t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0;var $=(function(){function t(){this.wA=new I,this.wB=new I,this.w=new I,this.a=0,this.indexA=0,this.indexB=0}return t.prototype.Copy=function(t){return this.wA.Copy(t.wA),this.wB.Copy(t.wB),this.w.Copy(t.w),this.a=t.a,this.indexA=t.indexA,this.indexB=t.indexB,this},t})(),tt=(function(){function t(){this.m_v1=new $,this.m_v2=new $,this.m_v3=new $,this.m_vertices=[],this.m_count=0,this.m_vertices[0]=this.m_v1,this.m_vertices[1]=this.m_v2,this.m_vertices[2]=this.m_v3}return t.prototype.ReadCache=function(t,e,i,r,s){this.m_count=t.count;for(var o=this.m_vertices,a=0;a1){var c=t.metric,u=this.GetMetric();(u<.5*c||2*c0?I.CrossOneV(e,t):I.CrossVOne(e,t);default:return t.SetZero()}},t.prototype.GetClosestPoint=function(t){switch(this.m_count){case 0:return t.SetZero();case 1:return t.Copy(this.m_v1.w);case 2:return t.Set(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);case 3:default:return t.SetZero()}},t.prototype.GetWitnessPoints=function(t,e){switch(this.m_count){case 0:break;case 1:t.Copy(this.m_v1.wA),e.Copy(this.m_v1.wB);break;case 2:t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,e.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,e.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:e.x=t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x,e.y=t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y}},t.prototype.GetMetric=function(){switch(this.m_count){case 0:case 1:return 0;case 2:return I.DistanceVV(this.m_v1.w,this.m_v2.w);case 3:return I.CrossVV(I.SubVV(this.m_v2.w,this.m_v1.w,I.s_t0),I.SubVV(this.m_v3.w,this.m_v1.w,I.s_t1));default:return 0}},t.prototype.Solve2=function(){var e=this.m_v1.w,i=this.m_v2.w,n=I.SubVV(i,e,t.s_e12),r=-I.DotVV(e,n);if(r<=0)return this.m_v1.a=1,void(this.m_count=1);var s=I.DotVV(i,n);if(s<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);var o=1/(s+r);this.m_v1.a=s*o,this.m_v2.a=r*o,this.m_count=2},t.prototype.Solve3=function(){var e=this.m_v1.w,i=this.m_v2.w,n=this.m_v3.w,r=I.SubVV(i,e,t.s_e12),s=I.DotVV(e,r),o=I.DotVV(i,r),a=-s,h=I.SubVV(n,e,t.s_e13),l=I.DotVV(e,h),c=I.DotVV(n,h),u=-l,_=I.SubVV(n,i,t.s_e23),f=I.DotVV(i,_),m=I.DotVV(n,_),d=-f,p=I.CrossVV(r,h),y=p*I.CrossVV(i,n),v=p*I.CrossVV(n,e),g=p*I.CrossVV(e,i);if(a<=0&&u<=0)return this.m_v1.a=1,void(this.m_count=1);if(o>0&&a>0&&g<=0){var x=1/(o+a);return this.m_v1.a=o*x,this.m_v2.a=a*x,void(this.m_count=2)}if(c>0&&u>0&&v<=0){var A=1/(c+u);return this.m_v1.a=c*A,this.m_v3.a=u*A,this.m_count=2,void this.m_v2.Copy(this.m_v3)}if(o<=0&&d<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);if(c<=0&&m<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v3);if(m>0&&d>0&&y<=0){var b=1/(m+d);return this.m_v2.a=m*b,this.m_v3.a=d*b,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var C=1/(y+v+g);this.m_v1.a=y*C,this.m_v2.a=v*C,this.m_v3.a=g*C,this.m_count=3},t.s_e12=new I,t.s_e13=new I,t.s_e23=new I,t})(),et=new tt,it=[0,0,0],nt=[0,0,0],rt=new I,st=new I,ot=new I,at=new I,ht=new I;function lt(e,i,s){++t.b2_gjkCalls;var o=s.proxyA,a=s.proxyB,h=s.transformA,l=s.transformB,c=et;c.ReadCache(i,o,h,a,l);for(var u=c.m_vertices,_=it,f=nt,m=0,d=0;d<20;){m=c.m_count;for(var p=0;pA+b&&e.distance>n){e.distance-=A+b;var C=I.SubVV(e.pointB,e.pointA,ot);C.Normalize(),e.pointA.SelfMulAdd(A,C),e.pointB.SelfMulSub(b,C)}else{var S=I.MidVV(e.pointA,e.pointB,rt);e.pointA.Copy(S),e.pointB.Copy(S),e.distance=0}}}var ct=new I,ut=new tt,_t=new I,ft=new I,mt=new I,dt=new I,pt=new I,yt=new I;(function(t){t[t.e_vertex=0]="e_vertex",t[t.e_face=1]="e_face"})(t.b2ContactFeatureType||(t.b2ContactFeatureType={}));var vt=(function(){function t(){this._key=0,this._key_invalid=!1,this._indexA=0,this._indexB=0,this._typeA=0,this._typeB=0}return Object.defineProperty(t.prototype,"key",{get:function(){return this._key_invalid&&(this._key_invalid=!1,this._key=this._indexA|this._indexB<<8|this._typeA<<16|this._typeB<<24),this._key},set:function(t){this._key=t,this._key_invalid=!1,this._indexA=255&this._key,this._indexB=this._key>>8&255,this._typeA=this._key>>16&255,this._typeB=this._key>>24&255},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"indexA",{get:function(){return this._indexA},set:function(t){this._indexA=t,this._key_invalid=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"indexB",{get:function(){return this._indexB},set:function(t){this._indexB=t,this._key_invalid=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"typeA",{get:function(){return this._typeA},set:function(t){this._typeA=t,this._key_invalid=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"typeB",{get:function(){return this._typeB},set:function(t){this._typeB=t,this._key_invalid=!0},enumerable:!0,configurable:!0}),t})(),gt=(function(){function t(){this.cf=new vt}return t.prototype.Copy=function(t){return this.key=t.key,this},t.prototype.Clone=function(){return(new t).Copy(this)},Object.defineProperty(t.prototype,"key",{get:function(){return this.cf.key},set:function(t){this.cf.key=t},enumerable:!0,configurable:!0}),t})(),xt=(function(){function t(){this.localPoint=new I,this.normalImpulse=0,this.tangentImpulse=0,this.id=new gt}return t.MakeArray=function(e){return m(e,(function(e){return new t}))},t.prototype.Reset=function(){this.localPoint.SetZero(),this.normalImpulse=0,this.tangentImpulse=0,this.id.key=0},t.prototype.Copy=function(t){return this.localPoint.Copy(t.localPoint),this.normalImpulse=t.normalImpulse,this.tangentImpulse=t.tangentImpulse,this.id.Copy(t.id),this},t})();(function(t){t[t.e_unknown=-1]="e_unknown",t[t.e_circles=0]="e_circles",t[t.e_faceA=1]="e_faceA",t[t.e_faceB=2]="e_faceB"})(t.b2ManifoldType||(t.b2ManifoldType={}));var At=(function(){function e(){this.points=xt.MakeArray(o),this.localNormal=new I,this.localPoint=new I,this.type=t.b2ManifoldType.e_unknown,this.pointCount=0}return e.prototype.Reset=function(){for(var e=0;er&&I.SubVV(l,h,this.normal).SelfNormalize();var c=I.AddVMulSV(h,s,this.normal,e.Initialize_s_cA),u=I.SubVMulSV(l,a,this.normal,e.Initialize_s_cB);I.MidVV(c,u,this.points[0]),this.separations[0]=I.DotVV(I.SubVV(u,c,I.s_t0),this.normal);break;case t.b2ManifoldType.e_faceA:V.MulRV(n.q,i.localNormal,this.normal);for(var _=N.MulXV(n,i.localPoint,e.Initialize_s_planePoint),f=0;f=0&&e>=0;return i=i&&this.lowerBound.IsValid()&&this.upperBound.IsValid()},t.prototype.GetCenter=function(){return I.MidVV(this.lowerBound,this.upperBound,this.m_cache_center)},t.prototype.GetExtents=function(){return I.ExtVV(this.lowerBound,this.upperBound,this.m_cache_extent)},t.prototype.GetPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+(this.upperBound.y-this.lowerBound.y))},t.prototype.Combine1=function(t){return this.lowerBound.x=g(this.lowerBound.x,t.lowerBound.x),this.lowerBound.y=g(this.lowerBound.y,t.lowerBound.y),this.upperBound.x=x(this.upperBound.x,t.upperBound.x),this.upperBound.y=x(this.upperBound.y,t.upperBound.y),this},t.prototype.Combine2=function(t,e){return this.lowerBound.x=g(t.lowerBound.x,e.lowerBound.x),this.lowerBound.y=g(t.lowerBound.y,e.lowerBound.y),this.upperBound.x=x(t.upperBound.x,e.upperBound.x),this.upperBound.y=x(t.upperBound.y,e.upperBound.y),this},t.Combine=function(t,e,i){return i.Combine2(t,e),i},t.prototype.Contains=function(t){var e=!0;return e=(e=(e=(e=e&&this.lowerBound.x<=t.lowerBound.x)&&this.lowerBound.y<=t.lowerBound.y)&&t.upperBound.x<=this.upperBound.x)&&t.upperBound.y<=this.upperBound.y},t.prototype.RayCast=function(t,e){var r=-i,s=i,o=e.p1.x,a=e.p1.y,h=e.p2.x-e.p1.x,l=e.p2.y-e.p1.y,c=v(h),u=v(l),_=t.normal;if(c(y=(this.upperBound.x-o)*f)){var d=p;p=y,y=d,m=1}if(p>r&&(_.x=m,_.y=0,r=p),r>(s=g(s,y)))return!1}if(u(y=(this.upperBound.y-a)*f)){d=p;p=y,y=d,m=1}if(p>r&&(_.x=0,_.y=m,r=p),r>(s=g(s,y)))return!1}return!(r<0||e.maxFraction0||i>0)&&!(n>0||r>0)},t})();function Et(t,e){var i=e.lowerBound.x-t.upperBound.x,n=e.lowerBound.y-t.upperBound.y,r=t.lowerBound.x-e.upperBound.x,s=t.lowerBound.y-e.upperBound.y;return!(i>0||n>0)&&!(r>0||s>0)}function Dt(e,i,n,r,s){var o=0,a=i[0],h=i[1],l=I.DotVV(n,a.v)-r,c=I.DotVV(n,h.v)-r;if(l<=0&&e[o++].Copy(a),c<=0&&e[o++].Copy(h),l*c<0){var u=l/(l-c),_=e[o].v;_.x=a.v.x+u*(h.v.x-a.v.x),_.y=a.v.y+u*(h.v.y-a.v.y);var f=e[o].id;f.cf.indexA=s,f.cf.indexB=a.id.cf.indexB,f.cf.typeA=t.b2ContactFeatureType.e_vertex,f.cf.typeB=t.b2ContactFeatureType.e_face,++o}return o}var Bt=new J,Mt=new q,Pt=new Z;function It(t,e,i,r,s,o){var a=Bt.Reset();a.proxyA.SetShape(t,e),a.proxyB.SetShape(i,r),a.transformA.Copy(s),a.transformB.Copy(o),a.useRadii=!0;var h=Mt.Reset();h.count=0;var l=Pt.Reset();return lt(l,h,a),l.distance<10*n}function Rt(t){if(null===t)throw new Error;return t}var Lt=(function(){function t(t){void 0===t&&(t=0),this.m_id=0,this.aabb=new wt,this.parent=null,this.child1=null,this.child2=null,this.height=0,this.m_id=t}return t.prototype.IsLeaf=function(){return null===this.child1},t})(),Ot=(function(){function t(){this.m_root=null,this.m_freeList=null,this.m_path=0,this.m_insertionCount=0,this.m_stack=new j(256)}return t.prototype.Query=function(t,e){if(null!==this.m_root){var i=this.m_stack.Reset();for(i.Push(this.m_root);i.GetCount()>0;){var n=i.Pop();if(n.aabb.TestOverlap(t))if(n.IsLeaf()){if(!e(n))return}else i.Push(Rt(n.child1)),i.Push(Rt(n.child2))}}},t.prototype.QueryPoint=function(t,e){if(null!==this.m_root){var i=this.m_stack.Reset();for(i.Push(this.m_root);i.GetCount()>0;){var n=i.Pop();if(n.aabb.TestContain(t))if(n.IsLeaf()){if(!e(n))return}else i.Push(Rt(n.child1)),i.Push(Rt(n.child2))}}},t.prototype.RayCast=function(e,i){if(null!==this.m_root){var n=e.p1,r=e.p2,s=I.SubVV(r,n,t.s_r);s.Normalize();var o=I.CrossOneV(s,t.s_v),a=I.AbsV(o,t.s_abs_v),h=e.maxFraction,l=t.s_segmentAABB,c=n.x+h*(r.x-n.x),u=n.y+h*(r.y-n.y);l.lowerBound.x=g(n.x,c),l.lowerBound.y=g(n.y,u),l.upperBound.x=x(n.x,c),l.upperBound.y=x(n.y,u);var _=this.m_stack.Reset();for(_.Push(this.m_root);_.GetCount()>0;){var f=_.Pop();if(Et(f.aabb,l)){var m=f.aabb.GetCenter(),d=f.aabb.GetExtents();if(!(v(I.DotVV(o,I.SubVV(n,m,I.s_t0)))-I.DotVV(a,d)>0))if(f.IsLeaf()){var p=t.s_subInput;p.p1.Copy(e.p1),p.p2.Copy(e.p2),p.maxFraction=h;var y=i(p,f);if(0===y)return;y>0&&(h=y,c=n.x+h*(r.x-n.x),u=n.y+h*(r.y-n.y),l.lowerBound.x=g(n.x,c),l.lowerBound.y=g(n.y,u),l.upperBound.x=x(n.x,c),l.upperBound.y=x(n.y,u))}else _.Push(Rt(f.child1)),_.Push(Rt(f.child2))}}}},t.prototype.AllocateNode=function(){if(this.m_freeList){var e=this.m_freeList;return this.m_freeList=e.parent,e.parent=null,e.child1=null,e.child2=null,e.height=0,delete e.userData,e}return new Lt(t.s_node_id++)},t.prototype.FreeNode=function(t){t.parent=this.m_freeList,t.child1=null,t.child2=null,t.height=-1,delete t.userData,this.m_freeList=t},t.prototype.CreateProxy=function(t,e){var i=this.AllocateNode();return i.aabb.lowerBound.x=t.lowerBound.x-.1,i.aabb.lowerBound.y=t.lowerBound.y-.1,i.aabb.upperBound.x=t.upperBound.x+.1,i.aabb.upperBound.y=t.upperBound.y+.1,i.userData=e,i.height=0,this.InsertLeaf(i),i},t.prototype.DestroyProxy=function(t){this.RemoveLeaf(t),this.FreeNode(t)},t.prototype.MoveProxy=function(t,e,i){if(t.aabb.Contains(e))return!1;this.RemoveLeaf(t);var n=.1+2*(i.x>0?i.x:-i.x),r=.1+2*(i.y>0?i.y:-i.y);return t.aabb.lowerBound.x=e.lowerBound.x-n,t.aabb.lowerBound.y=e.lowerBound.y-r,t.aabb.upperBound.x=e.upperBound.x+n,t.aabb.upperBound.y=e.upperBound.y+r,this.InsertLeaf(t),!0},t.prototype.InsertLeaf=function(e){if(++this.m_insertionCount,null===this.m_root)return this.m_root=e,void(this.m_root.parent=null);for(var i=e.aabb,n=this.m_root;!n.IsLeaf();){var r=Rt(n.child1),s=Rt(n.child2),o=n.aabb.GetPerimeter(),a=t.s_combinedAABB;a.Combine2(n.aabb,i);var h=a.GetPerimeter(),l=2*h,c=2*(h-o),u=void 0,_=t.s_aabb,f=void 0;r.IsLeaf()?(_.Combine2(i,r.aabb),u=_.GetPerimeter()+c):(_.Combine2(i,r.aabb),f=r.aabb.GetPerimeter(),u=_.GetPerimeter()-f+c);var m=void 0;if(s.IsLeaf()?(_.Combine2(i,s.aabb),m=_.GetPerimeter()+c):(_.Combine2(i,s.aabb),f=s.aabb.GetPerimeter(),m=_.GetPerimeter()-f+c),l1){var r=Rt(i.child1),s=Rt(i.child2);return i.child1=t,i.parent=t.parent,t.parent=i,null!==i.parent?i.parent.child1===t?i.parent.child1=i:i.parent.child2=i:this.m_root=i,r.height>s.height?(i.child2=r,t.child2=s,s.parent=t,t.aabb.Combine2(e.aabb,s.aabb),i.aabb.Combine2(t.aabb,r.aabb),t.height=1+x(e.height,s.height),i.height=1+x(t.height,r.height)):(i.child2=s,t.child2=r,r.parent=t,t.aabb.Combine2(e.aabb,r.aabb),i.aabb.Combine2(t.aabb,s.aabb),t.height=1+x(e.height,r.height),i.height=1+x(t.height,s.height)),i}if(n<-1){var o=Rt(e.child1),a=Rt(e.child2);return e.child1=t,e.parent=t.parent,t.parent=e,null!==e.parent?e.parent.child1===t?e.parent.child1=e:e.parent.child2=e:this.m_root=e,o.height>a.height?(e.child2=o,t.child1=a,a.parent=t,t.aabb.Combine2(i.aabb,a.aabb),e.aabb.Combine2(t.aabb,o.aabb),t.height=1+x(i.height,a.height),e.height=1+x(t.height,o.height)):(e.child2=a,t.child1=o,o.parent=t,t.aabb.Combine2(i.aabb,o.aabb),e.aabb.Combine2(t.aabb,a.aabb),t.height=1+x(i.height,o.height),e.height=1+x(t.height,a.height)),e}return t},t.prototype.GetHeight=function(){return null===this.m_root?0:this.m_root.height},t.GetAreaNode=function(e){if(null===e)return 0;if(e.IsLeaf())return 0;var i=e.aabb.GetPerimeter();return i+=t.GetAreaNode(e.child1),i+=t.GetAreaNode(e.child2)},t.prototype.GetAreaRatio=function(){if(null===this.m_root)return 0;var e=this.m_root.aabb.GetPerimeter();return t.GetAreaNode(this.m_root)/e},t.prototype.ComputeHeightNode=function(t){if(!t||t.IsLeaf())return 0;var e=this.ComputeHeightNode(t.child1),i=this.ComputeHeightNode(t.child2);return 1+x(e,i)},t.prototype.ComputeHeight=function(){return this.ComputeHeightNode(this.m_root)},t.prototype.ValidateStructure=function(t){if(null!==t){this.m_root;var e=t;if(!e.IsLeaf()){var i=Rt(e.child1),n=Rt(e.child2);this.ValidateStructure(i),this.ValidateStructure(n)}}},t.prototype.ValidateMetrics=function(e){if(null!==e){var i=e;if(!i.IsLeaf()){var n=Rt(i.child1),r=Rt(i.child2);t.s_aabb.Combine2(n.aabb,r.aabb),this.ValidateMetrics(n),this.ValidateMetrics(r)}}},t.prototype.Validate=function(){},t.GetMaxBalanceNode=function(t,e){if(null===t)return e;if(t.height<=1)return e;var i=Rt(t.child1),n=Rt(t.child2),r=v(n.height-i.height);return x(e,r)},t.prototype.GetMaxBalance=function(){return t.GetMaxBalanceNode(this.m_root,0)},t.prototype.RebuildBottomUp=function(){this.Validate()},t.ShiftOriginNode=function(e,i){if(null!==e&&!(e.height<=1)){var n=e.child1,r=e.child2;t.ShiftOriginNode(n,i),t.ShiftOriginNode(r,i),e.aabb.lowerBound.SelfSub(i),e.aabb.upperBound.SelfSub(i)}},t.prototype.ShiftOrigin=function(e){t.ShiftOriginNode(this.m_root,e)},t.s_r=new I,t.s_v=new I,t.s_abs_v=new I,t.s_segmentAABB=new wt,t.s_subInput=new St,t.s_combinedAABB=new wt,t.s_aabb=new wt,t.s_node_id=0,t})(),Ft=(function(){return function(t,e){this.proxyA=t,this.proxyB=e}})(),Vt=(function(){function t(){this.m_tree=new Ot,this.m_proxyCount=0,this.m_moveCount=0,this.m_moveBuffer=[],this.m_pairCount=0,this.m_pairBuffer=[]}return t.prototype.CreateProxy=function(t,e){var i=this.m_tree.CreateProxy(t,e);return++this.m_proxyCount,this.BufferMove(i),i},t.prototype.DestroyProxy=function(t){this.UnBufferMove(t),--this.m_proxyCount,this.m_tree.DestroyProxy(t)},t.prototype.MoveProxy=function(t,e,i){this.m_tree.MoveProxy(t,e,i)&&this.BufferMove(t)},t.prototype.TouchProxy=function(t){this.BufferMove(t)},t.prototype.GetProxyCount=function(){return this.m_proxyCount},t.prototype.UpdatePairs=function(t){var e=this;this.m_pairCount=0;for(var i=function(t){var i=n.m_moveBuffer[t];if(null===i)return"continue";var r=i.aabb;n.m_tree.Query(r,(function(t){if(t.m_id===i.m_id)return!0;var n,r;if(t.m_id_+f){e.state=t.b2TOIOutputState.e_separated,e.t=c,S=!0;break}if(B>_-f){m=T;break}var M=C.Evaluate(E[0],D[0],m);if(M<_-f){e.state=t.b2TOIOutputState.e_failed,e.t=m,S=!0;break}if(M<=_+f){e.state=t.b2TOIOutputState.e_touching,e.t=m,S=!0;break}for(var P=0,I=m,R=T;;){var L=0;L=1&P?I+(_-M)*(R-I)/(B-M):.5*(I+R),++P,++t.b2_toiRootIters;var O=C.Evaluate(E[0],D[0],L);if(v(O-_)_?(I=L,M=O):(R=L,B=O),50===P)break}if(t.b2_toiMaxRootIters=x(t.b2_toiMaxRootIters,P),++w===a)break}if(++d,++t.b2_toiIters,S)break;if(20===d){e.state=t.b2TOIOutputState.e_failed,e.t=m;break}}t.b2_toiMaxIters=x(t.b2_toiMaxIters,d);var F=n.GetMilliseconds();t.b2_toiMaxTime=x(t.b2_toiMaxTime,F),t.b2_toiTime+=F}var se=new I,oe=new I;function ae(e,i,n,r,s){e.pointCount=0;var o=N.MulXV(n,i.m_p,se),a=N.MulXV(s,r.m_p,oe),h=I.DistanceSquaredVV(o,a),l=i.m_radius+r.m_radius;h>l*l||(e.type=t.b2ManifoldType.e_circles,e.localPoint.Copy(i.m_p),e.localNormal.SetZero(),e.pointCount=1,e.points[0].localPoint.Copy(r.m_p),e.points[0].id.key=0)}var he=new I,le=new I,ce=new I;function ue(e,r,s,o,a){e.pointCount=0;for(var h=N.MulXV(a,o.m_p,he),l=N.MulTXV(s,h,le),c=0,u=-i,_=r.m_radius+o.m_radius,f=r.m_count,m=r.m_vertices,d=r.m_normals,p=0;p_)return;y>u&&(u=y,c=p)}var v=c,g=(v+1)%f,x=m[v],A=m[g];if(u_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,I.SubVV(l,x,e.localNormal).SelfNormalize(),e.localPoint.Copy(x),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}else if(C<=0){if(I.DistanceSquaredVV(l,A)>_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,I.SubVV(l,A,e.localNormal).SelfNormalize(),e.localPoint.Copy(A),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}else{var S=I.MidVV(x,A,ce);if(I.DotVV(I.SubVV(l,S,I.s_t1),d[v])>_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(d[v]).SelfNormalize(),e.localPoint.Copy(S),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}}var _e=new I,fe=new I,me=new I,de=new I;function pe(t,e,n,r,s){for(var o=t.m_vertices,a=t.m_normals,h=r.m_count,l=r.m_vertices,c=V.MulRV(e.q,a[n],_e),u=V.MulTRV(s.q,c,fe),_=0,f=i,m=0;mu&&(u=f,c=_)}var m=pe(e,n,c,r,s),d=(c+o-1)%o,p=pe(e,n,d,r,s),y=(c+1)%o,v=pe(e,n,y,r,s),g=0,x=0,A=0;if(p>m&&p>v)A=-1,g=d,x=p;else{if(!(v>m))return t[0]=c,m;A=1,g=y,x=v}for(;(m=pe(e,n,c=-1===A?(g+o-1)%o:(g+1)%o,r,s))>x;)g=c,x=m;return t[0]=g,x}var xe=new I;var Ae=Ct.MakeArray(2),be=Ct.MakeArray(2),Ce=Ct.MakeArray(2),Se=[0],Te=[0],we=new I,Ee=new I,De=new I,Be=new I,Me=new I,Pe=new I,Ie=new I,Re=new I;function Le(e,n,r,s,a){e.pointCount=0;var h=n.m_radius+s.m_radius,l=Se;l[0]=0;var c=ge(l,n,r,s,a);if(!(c>h)){var u=Te;u[0]=0;var _=ge(u,s,a,n,r);if(!(_>h)){var f,m,d,p,y=0,v=0;_>.98*c+.001?(f=s,m=n,d=a,p=r,y=u[0],e.type=t.b2ManifoldType.e_faceB,v=1):(f=n,m=s,d=r,p=a,y=l[0],e.type=t.b2ManifoldType.e_faceA,v=0);var g=Ae;(function(e,n,r,s,o,a){for(var h=n.m_normals,l=o.m_count,c=o.m_vertices,u=o.m_normals,_=V.MulTRV(a.q,V.MulRV(r.q,h[s],I.s_t0),xe),f=0,m=i,d=0;d_*_)return;if(i.m_hasVertex0){var p=i.m_vertex0,y=a,v=I.SubVV(y,p,Ne);if(I.DotVV(v,I.SubVV(y,o,I.s_t0))>0)return}return f.cf.indexA=0,f.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(m),e.points[0].id.Copy(f),void e.points[0].localPoint.Copy(r.m_p)}if(c<=0){var g=h,x=I.SubVV(o,g,Ve);if(I.DotVV(x,x)>_*_)return;if(i.m_hasVertex3){var A=i.m_vertex3,b=h,C=I.SubVV(A,b,ke);if(I.DotVV(C,I.SubVV(o,b,I.s_t0))>0)return}return f.cf.indexA=1,f.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(g),e.points[0].id.Copy(f),void e.points[0].localPoint.Copy(r.m_p)}var S=I.DotVV(l,l),T=Ge;T.x=1/S*(c*a.x+u*h.x),T.y=1/S*(c*a.y+u*h.y);var w=I.SubVV(o,T,Ve);if(!(I.DotVV(w,w)>_*_)){var E=ze.Set(-l.y,l.x);I.DotVV(E,I.SubVV(o,a,I.s_t0))<0&&E.Set(-E.x,-E.y),E.Normalize(),f.cf.indexA=0,f.cf.typeA=t.b2ContactFeatureType.e_face,e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(E),e.localPoint.Copy(a),e.points[0].id.Copy(f),e.points[0].localPoint.Copy(r.m_p)}}var je=(function(){return function(){this.type=0,this.index=0,this.separation=0}})(),He=(function(){return function(){this.vertices=I.MakeArray(a),this.normals=I.MakeArray(a),this.count=0}})(),Xe=(function(){return function(){this.i1=0,this.i2=0,this.v1=new I,this.v2=new I,this.normal=new I,this.sideNormal1=new I,this.sideOffset1=0,this.sideNormal2=new I,this.sideOffset2=0}})(),Ye=new(function(){function e(){this.m_polygonB=new He,this.m_xf=new N,this.m_centroidB=new I,this.m_v0=new I,this.m_v1=new I,this.m_v2=new I,this.m_v3=new I,this.m_normal0=new I,this.m_normal1=new I,this.m_normal2=new I,this.m_normal=new I,this.m_type1=0,this.m_type2=0,this.m_lowerLimit=new I,this.m_upperLimit=new I,this.m_radius=0,this.m_front=!1}return e.prototype.Collide=function(i,n,r,s,a){N.MulTXX(r,a,this.m_xf),N.MulXV(this.m_xf,s.m_centroid,this.m_centroidB),this.m_v0.Copy(n.m_vertex0),this.m_v1.Copy(n.m_vertex1),this.m_v2.Copy(n.m_vertex2),this.m_v3.Copy(n.m_vertex3);var h=n.m_hasVertex0,l=n.m_hasVertex3,c=I.SubVV(this.m_v2,this.m_v1,e.s_edge1);c.Normalize(),this.m_normal1.Set(c.y,-c.x);var u=I.DotVV(this.m_normal1,I.SubVV(this.m_centroidB,this.m_v1,I.s_t0)),_=0,f=0,m=!1,d=!1;if(h){var p=I.SubVV(this.m_v1,this.m_v0,e.s_edge0);p.Normalize(),this.m_normal0.Set(p.y,-p.x),m=I.CrossVV(p,c)>=0,_=I.DotVV(this.m_normal0,I.SubVV(this.m_centroidB,this.m_v0,I.s_t0))}if(l){var y=I.SubVV(this.m_v3,this.m_v2,e.s_edge2);y.Normalize(),this.m_normal2.Set(y.y,-y.x),d=I.CrossVV(c,y)>0,f=I.DotVV(this.m_normal2,I.SubVV(this.m_centroidB,this.m_v2,I.s_t0))}h&&l?m&&d?(this.m_front=_>=0||u>=0||f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):m?(this.m_front=_>=0||u>=0&&f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):d?(this.m_front=f>=0||_>=0&&u>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):(this.m_front=_>=0&&u>=0&&f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):h?m?(this.m_front=_>=0||u>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):(this.m_front=_>=0&&u>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):l?d?(this.m_front=u>=0||f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=u>=0&&f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=u>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1))),this.m_polygonB.count=s.m_count;for(var v=0;vthis.m_radius)){var x=this.ComputePolygonSeparation(e.s_polygonAxis);if(!(0!==x.type&&x.separation>this.m_radius)){var A;A=0===x.type?g:x.separation>.98*g.separation+.001?x:g;var b=e.s_ie,C=e.s_rf;if(1===A.type){i.type=t.b2ManifoldType.e_faceA;var S=0,T=I.DotVV(this.m_normal,this.m_polygonB.normals[0]);for(v=1;vthis.m_radius)return n.type=2,n.index=s,n.separation=c,n;if(I.DotVV(o,r)>=0){if(I.DotVV(I.SubVV(o,this.m_upperLimit,I.s_t0),this.m_normal)<-l)continue}else if(I.DotVV(I.SubVV(o,this.m_lowerLimit,I.s_t0),this.m_normal)<-l)continue;c>n.separation&&(n.type=2,n.index=s,n.separation=c)}return n},e.s_edge1=new I,e.s_edge0=new I,e.s_edge2=new I,e.s_ie=Ct.MakeArray(2),e.s_rf=new Xe,e.s_clipPoints1=Ct.MakeArray(2),e.s_clipPoints2=Ct.MakeArray(2),e.s_edgeAxis=new je,e.s_polygonAxis=new je,e.s_n=new I,e.s_perp=new I,e}());function qe(t,e,i,n,r){Ye.Collide(t,e,i,n,r)}var Je=(function(){return function(){this.mass=0,this.center=new I(0,0),this.I=0}})();(function(t){t[t.e_unknown=-1]="e_unknown",t[t.e_circleShape=0]="e_circleShape",t[t.e_edgeShape=1]="e_edgeShape",t[t.e_polygonShape=2]="e_polygonShape",t[t.e_chainShape=3]="e_chainShape",t[t.e_shapeTypeCount=4]="e_shapeTypeCount"})(t.b2ShapeType||(t.b2ShapeType={}));var Ze=(function(){function e(e,i){this.m_type=t.b2ShapeType.e_unknown,this.m_radius=0,this.m_type=e,this.m_radius=i}return e.prototype.Copy=function(t){return this.m_radius=t.m_radius,this},e.prototype.GetType=function(){return this.m_type},e})(),Ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};function Qe(t,e){function i(){this.constructor=t}Ke(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var $e=(function(e){function i(i){void 0===i&&(i=0);var n=e.call(this,t.b2ShapeType.e_circleShape,i)||this;return n.m_p=new I,n}return Qe(i,e),i.prototype.Set=function(t,e){return void 0===e&&(e=this.m_radius),this.m_p.Copy(t),this.m_radius=e,this},i.prototype.Clone=function(){return(new i).Copy(this)},i.prototype.Copy=function(t){return e.prototype.Copy.call(this,t),this.m_p.Copy(t.m_p),this},i.prototype.GetChildCount=function(){return 1},i.prototype.TestPoint=function(t,e){var n=N.MulXV(t,this.m_p,i.TestPoint_s_center),r=I.SubVV(e,n,i.TestPoint_s_d);return I.DotVV(r,r)<=C(this.m_radius)},i.prototype.ComputeDistance=function(t,e,n,r){var s=N.MulXV(t,this.m_p,i.ComputeDistance_s_center);return I.SubVV(e,s,n),n.Normalize()-this.m_radius},i.prototype.RayCast=function(t,e,r,s){var o=N.MulXV(r,this.m_p,i.RayCast_s_position),a=I.SubVV(e.p1,o,i.RayCast_s_s),h=I.DotVV(a,a)-C(this.m_radius),l=I.SubVV(e.p2,e.p1,i.RayCast_s_r),c=I.DotVV(a,l),u=I.DotVV(l,l),_=c*c-u*h;if(_<0||uthis.m_radius)return r.Copy(o),s*this.m_radius*this.m_radius;var h=this.m_radius*this.m_radius,l=a*a,c=h*(M(a/this.m_radius)+s/2)+a*T(h-l),u=-2/3*w(h-l,1.5)/c;return r.x=o.x+t.x*u,r.y=o.y+t.y*u,c},i.prototype.Dump=function(t){t(" const shape: b2CircleShape = new b2CircleShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_p.Set(%.15f, %.15f);\n",this.m_p.x,this.m_p.y)},i.TestPoint_s_center=new I,i.TestPoint_s_d=new I,i.ComputeDistance_s_center=new I,i.RayCast_s_position=new I,i.RayCast_s_s=new I,i.RayCast_s_r=new I,i.ComputeAABB_s_p=new I,i})(Ze),ti=(function(e){function r(){var i=e.call(this,t.b2ShapeType.e_polygonShape,c)||this;return i.m_centroid=new I(0,0),i.m_vertices=[],i.m_normals=[],i.m_count=0,i}return Qe(r,e),r.prototype.Clone=function(){return(new r).Copy(this)},r.prototype.Copy=function(t){e.prototype.Copy.call(this,t),this.m_centroid.Copy(t.m_centroid),this.m_count=t.m_count,this.m_vertices=I.MakeArray(this.m_count),this.m_normals=I.MakeArray(this.m_count);for(var i=0;im||d===m&&s[l].yA.LengthSquared()&&(x=_)}else x=_;if(++y,v=x,x===f)break}this.m_count=y,this.m_vertices=I.MakeArray(this.m_count),this.m_normals=I.MakeArray(this.m_count);for(l=0;l0)return!1}return!0},r.prototype.ComputeDistance=function(t,e,n,s){for(var o=N.MulTXV(t,e,r.ComputeDistance_s_pLocal),a=-i,h=r.ComputeDistance_s_normalForMaxDistance.Copy(o),l=0;la&&(a=c,h.Copy(this.m_normals[l]))}if(a>0){var u=r.ComputeDistance_s_minDistance.Copy(h),_=a*a;for(l=0;lm&&(u.Copy(f),_=m)}return V.MulRV(t.q,u,n),n.Normalize(),Math.sqrt(_)}return V.MulRV(t.q,h,n),a},r.prototype.RayCast=function(t,e,i,n){for(var s=N.MulTXV(i,e.p1,r.RayCast_s_p1),o=N.MulTXV(i,e.p2,r.RayCast_s_p2),a=I.SubVV(o,s,r.RayCast_s_d),h=0,l=e.maxFraction,c=-1,u=0;u0&&_=0&&(t.fraction=h,V.MulRV(i.q,this.m_normals[c],t.normal),!0)},r.prototype.ComputeAABB=function(t,e,i){for(var n=N.MulXV(e,this.m_vertices[0],t.lowerBound),s=t.upperBound.Copy(n),o=0;o0&&(m?_||(c=f-1,l++):_&&(u=f-1,l++)),_=m}switch(l){case 0:if(_){var d=r.ComputeSubmergedArea_s_md;return this.ComputeMass(d,1),N.MulXV(i,d.center,s),d.mass}return 0;case 1:-1===c?c=this.m_count-1:u=this.m_count-1}for(var p,y=(c+1)%this.m_count,v=(u+1)%this.m_count,g=(0-h[c])/(h[y]-h[c]),x=(0-h[u])/(h[v]-h[u]),A=r.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[c].x*(1-g)+this.m_vertices[y].x*g,this.m_vertices[c].y*(1-g)+this.m_vertices[y].y*g),b=r.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[u].x*(1-x)+this.m_vertices[v].x*x,this.m_vertices[u].y*(1-x)+this.m_vertices[v].y*x),C=0,S=r.ComputeSubmergedArea_s_center.SetZero(),T=this.m_vertices[y],w=y;w!==v;){p=(w=(w+1)%this.m_count)===v?b:this.m_vertices[w];var E=.5*((T.x-A.x)*(p.y-A.y)-(T.y-A.y)*(p.x-A.x));C+=E,S.x+=E*(A.x+T.x+p.x)/3,S.y+=E*(A.y+T.y+p.y)/3,T=p}return S.SelfMul(1/C),N.MulXV(i,S,s),C},r.prototype.Dump=function(t){t(" const shape: b2PolygonShape = new b2PolygonShape();\n"),t(" const vs: b2Vec2[] = b2Vec2.MakeArray(%d);\n",a);for(var e=0;e0){var c=I.DotVV(h,h);l>c?I.SubVV(e,o,a):a.SelfMulSub(l/c,h)}return n.Copy(a),n.Normalize()},i.prototype.RayCast=function(t,e,n,r){var s=N.MulTXV(n,e.p1,i.RayCast_s_p1),o=N.MulTXV(n,e.p2,i.RayCast_s_p2),a=I.SubVV(o,s,i.RayCast_s_d),h=this.m_vertex1,l=this.m_vertex2,c=I.SubVV(l,h,i.RayCast_s_e),u=t.normal.Set(c.y,-c.x).SelfNormalize(),_=I.DotVV(u,I.SubVV(h,s,I.s_t0)),f=I.DotVV(u,a);if(0===f)return!1;var m=_/f;if(m<0||e.maxFraction0&&t.normal.SelfNeg(),!0)},i.prototype.ComputeAABB=function(t,e,n){var r=N.MulXV(e,this.m_vertex1,i.ComputeAABB_s_v1),s=N.MulXV(e,this.m_vertex2,i.ComputeAABB_s_v2);I.MinV(r,s,t.lowerBound),I.MaxV(r,s,t.upperBound);var o=this.m_radius;t.lowerBound.SelfSubXY(o,o),t.upperBound.SelfAddXY(o,o)},i.prototype.ComputeMass=function(t,e){t.mass=0,I.MidVV(this.m_vertex1,this.m_vertex2,t.center),t.I=0},i.prototype.SetupDistanceProxy=function(t,e){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_vertex1),t.m_vertices[1].Copy(this.m_vertex2),t.m_count=2,t.m_radius=this.m_radius},i.prototype.ComputeSubmergedArea=function(t,e,i,n){return n.SetZero(),0},i.prototype.Dump=function(t){t(" const shape: b2EdgeShape = new b2EdgeShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_vertex0.Set(%.15f, %.15f);\n",this.m_vertex0.x,this.m_vertex0.y),t(" shape.m_vertex1.Set(%.15f, %.15f);\n",this.m_vertex1.x,this.m_vertex1.y),t(" shape.m_vertex2.Set(%.15f, %.15f);\n",this.m_vertex2.x,this.m_vertex2.y),t(" shape.m_vertex3.Set(%.15f, %.15f);\n",this.m_vertex3.x,this.m_vertex3.y),t(" shape.m_hasVertex0 = %s;\n",this.m_hasVertex0),t(" shape.m_hasVertex3 = %s;\n",this.m_hasVertex3)},i.ComputeDistance_s_v1=new I,i.ComputeDistance_s_v2=new I,i.ComputeDistance_s_d=new I,i.ComputeDistance_s_s=new I,i.RayCast_s_p1=new I,i.RayCast_s_p2=new I,i.RayCast_s_d=new I,i.RayCast_s_e=new I,i.RayCast_s_q=new I,i.RayCast_s_r=new I,i.ComputeAABB_s_v1=new I,i.ComputeAABB_s_v2=new I,i})(Ze),ii=(function(e){function i(){var i=e.call(this,t.b2ShapeType.e_chainShape,c)||this;return i.m_vertices=[],i.m_count=0,i.m_prevVertex=new I,i.m_nextVertex=new I,i.m_hasPrevVertex=!1,i.m_hasNextVertex=!1,i}return Qe(i,e),i.prototype.CreateLoop=function(t,e,i){if(void 0===e&&(e=t.length),void 0===i&&(i=0),e<3)return this;this.m_count=e+1,this.m_vertices=I.MakeArray(this.m_count);for(var n=0;n0?(e.m_vertex0.Copy(this.m_vertices[i-1]),e.m_hasVertex0=!0):(e.m_vertex0.Copy(this.m_prevVertex),e.m_hasVertex0=this.m_hasPrevVertex),i0&&this.ResetMassData(),this.m_world.m_newFixture=!0,e},i.prototype.CreateFixtureShapeDensity=function(t,e){void 0===e&&(e=0);var n=i.CreateFixtureShapeDensity_s_def;return n.shape=t,n.density=e,this.CreateFixtureDef(n)},i.prototype.DestroyFixture=function(t){if(this.m_world.IsLocked())throw new Error;for(var e=this.m_fixtureList,i=null;null!==e;){if(e===t){i?i.m_next=t.m_next:this.m_fixtureList=t.m_next;break}i=e,e=e.m_next}for(var n=this.m_contactList;n;){var r=n.contact;n=n.next;var s=r.GetFixtureA(),o=r.GetFixtureB();t!==s&&t!==o||this.m_world.m_contactManager.Destroy(r)}this.m_activeFlag&&t.DestroyProxies(),t.m_next=null,t.Destroy(),--this.m_fixtureCount,this.ResetMassData()},i.prototype.SetTransformVec=function(t,e){this.SetTransformXY(t.x,t.y,e)},i.prototype.SetTransformXY=function(t,e,i){if(this.m_world.IsLocked())throw new Error;this.m_xf.q.SetAngle(i),this.m_xf.p.Set(t,e),this.m_xf0.Copy(this.m_xf),N.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.a=i,this.m_sweep.c0.Copy(this.m_sweep.c),this.m_sweep.a0=i;for(var n=this.m_fixtureList;n;n=n.m_next)n.Synchronize(this.m_xf,this.m_xf);this.m_world.m_contactManager.FindNewContacts()},i.prototype.SetTransform=function(t){this.SetTransformVec(t.p,t.GetAngle())},i.prototype.GetTransform=function(){return this.m_xf},i.prototype.GetPosition=function(){return this.m_xf.p},i.prototype.SetPosition=function(t){this.SetTransformVec(t,this.GetAngle())},i.prototype.SetPositionXY=function(t,e){this.SetTransformXY(t,e,this.GetAngle())},i.prototype.GetAngle=function(){return this.m_sweep.a},i.prototype.SetAngle=function(t){this.SetTransformVec(this.GetPosition(),t)},i.prototype.GetWorldCenter=function(){return this.m_sweep.c},i.prototype.GetLocalCenter=function(){return this.m_sweep.localCenter},i.prototype.SetLinearVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(I.DotVV(e,e)>0&&this.SetAwake(!0),this.m_linearVelocity.Copy(e))},i.prototype.GetLinearVelocity=function(){return this.m_linearVelocity},i.prototype.SetAngularVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(e*e>0&&this.SetAwake(!0),this.m_angularVelocity=e)},i.prototype.GetAngularVelocity=function(){return this.m_angularVelocity},i.prototype.GetDefinition=function(t){return t.type=this.GetType(),t.allowSleep=this.m_autoSleepFlag,t.angle=this.GetAngle(),t.angularDamping=this.m_angularDamping,t.gravityScale=this.m_gravityScale,t.angularVelocity=this.m_angularVelocity,t.fixedRotation=this.m_fixedRotationFlag,t.bullet=this.m_bulletFlag,t.awake=this.m_awakeFlag,t.linearDamping=this.m_linearDamping,t.linearVelocity.Copy(this.GetLinearVelocity()),t.position.Copy(this.GetPosition()),t.userData=this.GetUserData(),t},i.prototype.ApplyForce=function(e,i,n){void 0===n&&(n=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y,this.m_torque+=(i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x))},i.prototype.ApplyForceToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y))},i.prototype.ApplyTorque=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_torque+=e))},i.prototype.ApplyLinearImpulse=function(e,i,n){void 0===n&&(n=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y,this.m_angularVelocity+=this.m_invI*((i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x)))},i.prototype.ApplyLinearImpulseToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y))},i.prototype.ApplyAngularImpulse=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_angularVelocity+=this.m_invI*e))},i.prototype.GetMass=function(){return this.m_mass},i.prototype.GetInertia=function(){return this.m_I+this.m_mass*I.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter)},i.prototype.GetMassData=function(t){return t.mass=this.m_mass,t.I=this.m_I+this.m_mass*I.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter),t.center.Copy(this.m_sweep.localCenter),t},i.prototype.SetMassData=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type===t.b2BodyType.b2_dynamicBody){this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&!this.m_fixedRotationFlag&&(this.m_I=e.I-this.m_mass*I.DotVV(e.center,e.center),this.m_invI=1/this.m_I);var n=i.SetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e.center),N.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),I.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,I.SubVV(this.m_sweep.c,n,I.s_t0),this.m_linearVelocity)}},i.prototype.ResetMassData=function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero(),this.m_type===t.b2BodyType.b2_staticBody||this.m_type===t.b2BodyType.b2_kinematicBody)return this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);for(var e=i.ResetMassData_s_localCenter.SetZero(),n=this.m_fixtureList;n;n=n.m_next)if(0!==n.m_density){var r=n.GetMassData(i.ResetMassData_s_massData);this.m_mass+=r.mass,e.x+=r.center.x*r.mass,e.y+=r.center.y*r.mass,this.m_I+=r.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.x*=this.m_invMass,e.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&!this.m_fixedRotationFlag?(this.m_I-=this.m_mass*I.DotVV(e,e),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var s=i.ResetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e),N.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),I.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,I.SubVV(this.m_sweep.c,s,I.s_t0),this.m_linearVelocity)},i.prototype.GetWorldPoint=function(t,e){return N.MulXV(this.m_xf,t,e)},i.prototype.GetWorldVector=function(t,e){return V.MulRV(this.m_xf.q,t,e)},i.prototype.GetLocalPoint=function(t,e){return N.MulTXV(this.m_xf,t,e)},i.prototype.GetLocalVector=function(t,e){return V.MulTRV(this.m_xf.q,t,e)},i.prototype.GetLinearVelocityFromWorldPoint=function(t,e){return I.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,I.SubVV(t,this.m_sweep.c,I.s_t0),e)},i.prototype.GetLinearVelocityFromLocalPoint=function(t,e){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t,e),e)},i.prototype.GetLinearDamping=function(){return this.m_linearDamping},i.prototype.SetLinearDamping=function(t){this.m_linearDamping=t},i.prototype.GetAngularDamping=function(){return this.m_angularDamping},i.prototype.SetAngularDamping=function(t){this.m_angularDamping=t},i.prototype.GetGravityScale=function(){return this.m_gravityScale},i.prototype.SetGravityScale=function(t){this.m_gravityScale=t},i.prototype.SetType=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type!==e){this.m_type=e,this.ResetMassData(),this.m_type===t.b2BodyType.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Copy(this.m_sweep.c),this.SynchronizeFixtures()),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var i=this.m_contactList;i;){var n=i;i=i.next,this.m_world.m_contactManager.Destroy(n.contact)}this.m_contactList=null;for(var r=this.m_fixtureList;r;r=r.m_next)r.TouchProxies()}},i.prototype.GetType=function(){return this.m_type},i.prototype.SetBullet=function(t){this.m_bulletFlag=t},i.prototype.IsBullet=function(){return this.m_bulletFlag},i.prototype.SetSleepingAllowed=function(t){this.m_autoSleepFlag=t,t||this.SetAwake(!0)},i.prototype.IsSleepingAllowed=function(){return this.m_autoSleepFlag},i.prototype.SetAwake=function(t){t?(this.m_awakeFlag=!0,this.m_sleepTime=0):(this.m_awakeFlag=!1,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)},i.prototype.IsAwake=function(){return this.m_awakeFlag},i.prototype.SetActive=function(t){if(this.m_world.IsLocked())throw new Error;if(t!==this.IsActive())if(this.m_activeFlag=t,t)for(var e=this.m_fixtureList;e;e=e.m_next)e.CreateProxies(this.m_xf);else{for(e=this.m_fixtureList;e;e=e.m_next)e.DestroyProxies();for(var i=this.m_contactList;i;){var n=i;i=i.next,this.m_world.m_contactManager.Destroy(n.contact)}this.m_contactList=null}},i.prototype.IsActive=function(){return this.m_activeFlag},i.prototype.SetFixedRotation=function(t){this.m_fixedRotationFlag!==t&&(this.m_fixedRotationFlag=t,this.m_angularVelocity=0,this.ResetMassData())},i.prototype.IsFixedRotation=function(){return this.m_fixedRotationFlag},i.prototype.GetFixtureList=function(){return this.m_fixtureList},i.prototype.GetJointList=function(){return this.m_jointList},i.prototype.GetContactList=function(){return this.m_contactList},i.prototype.GetNext=function(){return this.m_next},i.prototype.GetUserData=function(){return this.m_userData},i.prototype.SetUserData=function(t){this.m_userData=t},i.prototype.GetWorld=function(){return this.m_world},i.prototype.Dump=function(e){var i=this.m_islandIndex;e("{\n"),e(" const bd: b2BodyDef = new b2BodyDef();\n");var n="";switch(this.m_type){case t.b2BodyType.b2_staticBody:n="b2BodyType.b2_staticBody";break;case t.b2BodyType.b2_kinematicBody:n="b2BodyType.b2_kinematicBody";break;case t.b2BodyType.b2_dynamicBody:n="b2BodyType.b2_dynamicBody"}e(" bd.type = %s;\n",n),e(" bd.position.Set(%.15f, %.15f);\n",this.m_xf.p.x,this.m_xf.p.y),e(" bd.angle = %.15f;\n",this.m_sweep.a),e(" bd.linearVelocity.Set(%.15f, %.15f);\n",this.m_linearVelocity.x,this.m_linearVelocity.y),e(" bd.angularVelocity = %.15f;\n",this.m_angularVelocity),e(" bd.linearDamping = %.15f;\n",this.m_linearDamping),e(" bd.angularDamping = %.15f;\n",this.m_angularDamping),e(" bd.allowSleep = %s;\n",this.m_autoSleepFlag?"true":"false"),e(" bd.awake = %s;\n",this.m_awakeFlag?"true":"false"),e(" bd.fixedRotation = %s;\n",this.m_fixedRotationFlag?"true":"false"),e(" bd.bullet = %s;\n",this.m_bulletFlag?"true":"false"),e(" bd.active = %s;\n",this.m_activeFlag?"true":"false"),e(" bd.gravityScale = %.15f;\n",this.m_gravityScale),e("\n"),e(" bodies[%d] = this.m_world.CreateBody(bd);\n",this.m_islandIndex),e("\n");for(var r=this.m_fixtureList;r;r=r.m_next)e(" {\n"),r.Dump(e,i),e(" }\n");e("}\n")},i.prototype.SynchronizeFixtures=function(){var t=i.SynchronizeFixtures_s_xf1;t.q.SetAngle(this.m_sweep.a0),V.MulRV(t.q,this.m_sweep.localCenter,t.p),I.SubVV(this.m_sweep.c0,t.p,t.p);for(var e=this.m_fixtureList;e;e=e.m_next)e.Synchronize(t,this.m_xf)},i.prototype.SynchronizeTransform=function(){this.m_xf.q.SetAngle(this.m_sweep.a),V.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),I.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},i.prototype.ShouldCollide=function(e){return(this.m_type!==t.b2BodyType.b2_staticBody||e.m_type!==t.b2BodyType.b2_staticBody)&&this.ShouldCollideConnected(e)},i.prototype.ShouldCollideConnected=function(t){for(var e=this.m_jointList;e;e=e.next)if(e.other===t&&!e.joint.m_collideConnected)return!1;return!0},i.prototype.Advance=function(t){this.m_sweep.Advance(t),this.m_sweep.c.Copy(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.m_xf.q.SetAngle(this.m_sweep.a),V.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),I.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},i.prototype.GetControllerList=function(){return this.m_controllerList},i.prototype.GetControllerCount=function(){return this.m_controllerCount},i.CreateFixtureShapeDensity_s_def=new ri,i.SetMassData_s_oldCenter=new I,i.ResetMassData_s_localCenter=new I,i.ResetMassData_s_oldCenter=new I,i.ResetMassData_s_massData=new Je,i.SynchronizeFixtures_s_xf1=new N,i})();(function(t){t[t.e_unknownJoint=0]="e_unknownJoint",t[t.e_revoluteJoint=1]="e_revoluteJoint",t[t.e_prismaticJoint=2]="e_prismaticJoint",t[t.e_distanceJoint=3]="e_distanceJoint",t[t.e_pulleyJoint=4]="e_pulleyJoint",t[t.e_mouseJoint=5]="e_mouseJoint",t[t.e_gearJoint=6]="e_gearJoint",t[t.e_wheelJoint=7]="e_wheelJoint",t[t.e_weldJoint=8]="e_weldJoint",t[t.e_frictionJoint=9]="e_frictionJoint",t[t.e_ropeJoint=10]="e_ropeJoint",t[t.e_motorJoint=11]="e_motorJoint",t[t.e_areaJoint=12]="e_areaJoint"})(t.b2JointType||(t.b2JointType={})),(function(t){t[t.e_inactiveLimit=0]="e_inactiveLimit",t[t.e_atLowerLimit=1]="e_atLowerLimit",t[t.e_atUpperLimit=2]="e_atUpperLimit",t[t.e_equalLimits=3]="e_equalLimits"})(t.b2LimitState||(t.b2LimitState={}));var li=(function(){function t(){this.linear=new I,this.angularA=0,this.angularB=0}return t.prototype.SetZero=function(){return this.linear.SetZero(),this.angularA=0,this.angularB=0,this},t.prototype.Set=function(t,e,i){return this.linear.Copy(t),this.angularA=e,this.angularB=i,this},t})(),ci=(function(){return function(t,e){this.prev=null,this.next=null,this.joint=t,this.other=e}})(),ui=(function(){return function(e){this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=e}})(),_i=(function(){function i(i){this.m_type=t.b2JointType.e_unknownJoint,this.m_prev=null,this.m_next=null,this.m_index=0,this.m_islandFlag=!1,this.m_collideConnected=!1,this.m_userData=null,this.m_type=i.type,this.m_edgeA=new ci(this,i.bodyB),this.m_edgeB=new ci(this,i.bodyA),this.m_bodyA=i.bodyA,this.m_bodyB=i.bodyB,this.m_collideConnected=e(i.collideConnected,!1),this.m_userData=i.userData}return i.prototype.GetType=function(){return this.m_type},i.prototype.GetBodyA=function(){return this.m_bodyA},i.prototype.GetBodyB=function(){return this.m_bodyB},i.prototype.GetNext=function(){return this.m_next},i.prototype.GetUserData=function(){return this.m_userData},i.prototype.SetUserData=function(t){this.m_userData=t},i.prototype.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()},i.prototype.GetCollideConnected=function(){return this.m_collideConnected},i.prototype.Dump=function(t){t("// Dump is not supported for this joint type.\n")},i.prototype.ShiftOrigin=function(t){},i})(),fi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_distanceJoint)||this;return i.localAnchorA=new I,i.localAnchorB=new I,i.length=1,i.frequencyHz=0,i.dampingRatio=0,i}return Qe(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB),this.length=I.DistanceVV(i,n),this.frequencyHz=0,this.dampingRatio=0},i})(ui),mi=(function(t){function i(i){var n=t.call(this,i)||this;return n.m_frequencyHz=0,n.m_dampingRatio=0,n.m_bias=0,n.m_localAnchorA=new I,n.m_localAnchorB=new I,n.m_gamma=0,n.m_impulse=0,n.m_length=0,n.m_indexA=0,n.m_indexB=0,n.m_u=new I,n.m_rA=new I,n.m_rB=new I,n.m_localCenterA=new I,n.m_localCenterB=new I,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new V,n.m_qB=new V,n.m_lalcA=new I,n.m_lalcB=new I,n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_localAnchorA.Copy(i.localAnchorA),n.m_localAnchorB.Copy(i.localAnchorB),n.m_length=i.length,n}return Qe(i,t),i.prototype.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},i.prototype.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},i.prototype.GetReactionForce=function(t,e){return e.x=t*this.m_impulse*this.m_u.x,e.y=t*this.m_impulse*this.m_u.y,e},i.prototype.GetReactionTorque=function(t){return 0},i.prototype.GetLocalAnchorA=function(){return this.m_localAnchorA},i.prototype.GetLocalAnchorB=function(){return this.m_localAnchorB},i.prototype.SetLength=function(t){this.m_length=t},i.prototype.Length=function(){return this.m_length},i.prototype.SetFrequency=function(t){this.m_frequencyHz=t},i.prototype.GetFrequency=function(){return this.m_frequencyHz},i.prototype.SetDampingRatio=function(t){this.m_dampingRatio=t},i.prototype.GetDampingRatio=function(){return this.m_dampingRatio},i.prototype.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2DistanceJointDef = new b2DistanceJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.length = %.15f;\n",this.m_length),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i.prototype.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,o=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].c,l=t.positions[this.m_indexB].a,c=t.velocities[this.m_indexB].v,u=t.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(n),f=this.m_qB.SetAngle(l);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),V.MulRV(_,this.m_lalcA,this.m_rA),I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),V.MulRV(f,this.m_lalcB,this.m_rB),this.m_u.x=a.x+this.m_rB.x-e.x-this.m_rA.x,this.m_u.y=a.y+this.m_rB.y-e.y-this.m_rA.y;var m=this.m_u.Length();m>h?this.m_u.SelfMul(1/m):this.m_u.SetZero();var d=I.CrossVV(this.m_rA,this.m_u),p=I.CrossVV(this.m_rB,this.m_u),y=this.m_invMassA+this.m_invIA*d*d+this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=0!==y?1/y:0,this.m_frequencyHz>0){var v=m-this.m_length,g=2*s*this.m_frequencyHz,x=2*this.m_mass*this.m_dampingRatio*g,A=this.m_mass*g*g,b=t.step.dt;this.m_gamma=b*(x+b*A),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=v*b*A*this.m_gamma,y+=this.m_gamma,this.m_mass=0!==y?1/y:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var C=I.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);r.SelfMulSub(this.m_invMassA,C),o-=this.m_invIA*I.CrossVV(this.m_rA,C),c.SelfMulAdd(this.m_invMassB,C),u+=this.m_invIB*I.CrossVV(this.m_rB,C)}else this.m_impulse=0;t.velocities[this.m_indexA].w=o,t.velocities[this.m_indexB].w=u},i.prototype.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=I.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),a=I.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=I.DotVV(this.m_u,I.SubVV(a,o,I.s_t0)),l=-this.m_mass*(h+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=l;var c=I.MulSV(l,this.m_u,i.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,c),n-=this.m_invIA*I.CrossVV(this.m_rA,c),r.SelfMulAdd(this.m_invMassB,c),s+=this.m_invIB*I.CrossVV(this.m_rB,c),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},i.prototype.SolvePositionConstraints=function(t){if(this.m_frequencyHz>0)return!0;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s),l=V.MulRV(o,this.m_lalcA,this.m_rA),c=V.MulRV(a,this.m_lalcB,this.m_rB),u=this.m_u;u.x=r.x+c.x-e.x-l.x,u.y=r.y+c.y-e.y-l.y;var _=this.m_u.Normalize()-this.m_length;_=A(_,-.2,.2);var f=-this.m_mass*_,m=I.MulSV(f,u,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,m),n-=this.m_invIA*I.CrossVV(l,m),r.SelfMulAdd(this.m_invMassB,m),s+=this.m_invIB*I.CrossVV(c,m),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,v(_)C(.2)&&f.SelfMul(.2/T(d)),d>C(h)&&(_=!1),a.x+=f.x,a.y+=f.y}return _},i})(_i),yi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_frictionJoint)||this;return i.localAnchorA=new I,i.localAnchorB=new I,i.maxForce=0,i.maxTorque=0,i}return Qe(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB)},i})(ui),vi=(function(t){function i(i){var n=t.call(this,i)||this;return n.m_localAnchorA=new I,n.m_localAnchorB=new I,n.m_linearImpulse=new I,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_indexA=0,n.m_indexB=0,n.m_rA=new I,n.m_rB=new I,n.m_localCenterA=new I,n.m_localCenterB=new I,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new O,n.m_angularMass=0,n.m_qA=new V,n.m_qB=new V,n.m_lalcA=new I,n.m_lalcB=new I,n.m_K=new O,n.m_localAnchorA.Copy(i.localAnchorA),n.m_localAnchorB.Copy(i.localAnchorB),n.m_linearImpulse.SetZero(),n.m_maxForce=e(i.maxForce,0),n.m_maxTorque=e(i.maxTorque,0),n.m_linearMass.SetZero(),n}return Qe(i,t),i.prototype.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.positions[this.m_indexB].a,s=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=this.m_qA.SetAngle(e),h=this.m_qB.SetAngle(r);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=V.MulRV(a,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var c=V.MulRV(h,this.m_lalcB,this.m_rB),u=this.m_invMassA,_=this.m_invMassB,f=this.m_invIA,m=this.m_invIB,d=this.m_K;if(d.ex.x=u+_+f*l.y*l.y+m*c.y*c.y,d.ex.y=-f*l.x*l.y-m*c.x*c.y,d.ey.x=d.ex.y,d.ey.y=u+_+f*l.x*l.x+m*c.x*c.x,d.GetInverse(this.m_linearMass),this.m_angularMass=f+m,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var p=this.m_linearImpulse;i.SelfMulSub(u,p),n-=f*(I.CrossVV(this.m_rA,p)+this.m_angularImpulse),s.SelfMulAdd(_,p),o+=m*(I.CrossVV(this.m_rB,p)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o},i.prototype.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,h=this.m_invIA,l=this.m_invIB,c=t.step.dt,u=s-n,_=-this.m_angularMass*u,f=this.m_angularImpulse,m=c*this.m_maxTorque;this.m_angularImpulse=A(this.m_angularImpulse+_,-m,m),n-=h*(_=this.m_angularImpulse-f),s+=l*_;var d=I.SubVV(I.AddVCrossSV(r,s,this.m_rB,I.s_t0),I.AddVCrossSV(e,n,this.m_rA,I.s_t1),i.SolveVelocityConstraints_s_Cdot_v2),p=O.MulMV(this.m_linearMass,d,i.SolveVelocityConstraints_s_impulseV).SelfNeg(),y=i.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(p);m=c*this.m_maxForce;this.m_linearImpulse.LengthSquared()>m*m&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(m)),I.SubVV(this.m_linearImpulse,y,p),e.SelfMulSub(o,p),n-=h*I.CrossVV(this.m_rA,p),r.SelfMulAdd(a,p),s+=l*I.CrossVV(this.m_rB,p),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},i.prototype.SolvePositionConstraints=function(t){return!0},i.prototype.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},i.prototype.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},i.prototype.GetReactionForce=function(t,e){return e.x=t*this.m_linearImpulse.x,e.y=t*this.m_linearImpulse.y,e},i.prototype.GetReactionTorque=function(t){return t*this.m_angularImpulse},i.prototype.GetLocalAnchorA=function(){return this.m_localAnchorA},i.prototype.GetLocalAnchorB=function(){return this.m_localAnchorB},i.prototype.SetMaxForce=function(t){this.m_maxForce=t},i.prototype.GetMaxForce=function(){return this.m_maxForce},i.prototype.SetMaxTorque=function(t){this.m_maxTorque=t},i.prototype.GetMaxTorque=function(){return this.m_maxTorque},i.prototype.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2FrictionJointDef = new b2FrictionJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i.SolveVelocityConstraints_s_Cdot_v2=new I,i.SolveVelocityConstraints_s_impulseV=new I,i.SolveVelocityConstraints_s_oldImpulseV=new I,i})(_i),gi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_gearJoint)||this;return i.ratio=1,i}return Qe(i,e),i})(ui),xi=(function(i){function n(n){var r,s,o=i.call(this,n)||this;o.m_typeA=t.b2JointType.e_unknownJoint,o.m_typeB=t.b2JointType.e_unknownJoint,o.m_localAnchorA=new I,o.m_localAnchorB=new I,o.m_localAnchorC=new I,o.m_localAnchorD=new I,o.m_localAxisC=new I,o.m_localAxisD=new I,o.m_referenceAngleA=0,o.m_referenceAngleB=0,o.m_constant=0,o.m_ratio=0,o.m_impulse=0,o.m_indexA=0,o.m_indexB=0,o.m_indexC=0,o.m_indexD=0,o.m_lcA=new I,o.m_lcB=new I,o.m_lcC=new I,o.m_lcD=new I,o.m_mA=0,o.m_mB=0,o.m_mC=0,o.m_mD=0,o.m_iA=0,o.m_iB=0,o.m_iC=0,o.m_iD=0,o.m_JvAC=new I,o.m_JvBD=new I,o.m_JwA=0,o.m_JwB=0,o.m_JwC=0,o.m_JwD=0,o.m_mass=0,o.m_qA=new V,o.m_qB=new V,o.m_qC=new V,o.m_qD=new V,o.m_lalcA=new I,o.m_lalcB=new I,o.m_lalcC=new I,o.m_lalcD=new I,o.m_joint1=n.joint1,o.m_joint2=n.joint2,o.m_typeA=o.m_joint1.GetType(),o.m_typeB=o.m_joint2.GetType(),o.m_bodyC=o.m_joint1.GetBodyA(),o.m_bodyA=o.m_joint1.GetBodyB();var a=o.m_bodyA.m_xf,h=o.m_bodyA.m_sweep.a,l=o.m_bodyC.m_xf,c=o.m_bodyC.m_sweep.a;if(o.m_typeA===t.b2JointType.e_revoluteJoint){var u=n.joint1;o.m_localAnchorC.Copy(u.m_localAnchorA),o.m_localAnchorA.Copy(u.m_localAnchorB),o.m_referenceAngleA=u.m_referenceAngle,o.m_localAxisC.SetZero(),r=h-c-o.m_referenceAngleA}else{var _=n.joint1;o.m_localAnchorC.Copy(_.m_localAnchorA),o.m_localAnchorA.Copy(_.m_localAnchorB),o.m_referenceAngleA=_.m_referenceAngle,o.m_localAxisC.Copy(_.m_localXAxisA);var f=o.m_localAnchorC,m=V.MulTRV(l.q,I.AddVV(V.MulRV(a.q,o.m_localAnchorA,I.s_t0),I.SubVV(a.p,l.p,I.s_t1),I.s_t0),I.s_t0);r=I.DotVV(I.SubVV(m,f,I.s_t0),o.m_localAxisC)}o.m_bodyD=o.m_joint2.GetBodyA(),o.m_bodyB=o.m_joint2.GetBodyB();var d=o.m_bodyB.m_xf,p=o.m_bodyB.m_sweep.a,y=o.m_bodyD.m_xf,v=o.m_bodyD.m_sweep.a;if(o.m_typeB===t.b2JointType.e_revoluteJoint){u=n.joint2;o.m_localAnchorD.Copy(u.m_localAnchorA),o.m_localAnchorB.Copy(u.m_localAnchorB),o.m_referenceAngleB=u.m_referenceAngle,o.m_localAxisD.SetZero(),s=p-v-o.m_referenceAngleB}else{_=n.joint2;o.m_localAnchorD.Copy(_.m_localAnchorA),o.m_localAnchorB.Copy(_.m_localAnchorB),o.m_referenceAngleB=_.m_referenceAngle,o.m_localAxisD.Copy(_.m_localXAxisA);var g=o.m_localAnchorD,x=V.MulTRV(y.q,I.AddVV(V.MulRV(d.q,o.m_localAnchorB,I.s_t0),I.SubVV(d.p,y.p,I.s_t1),I.s_t0),I.s_t0);s=I.DotVV(I.SubVV(x,g,I.s_t0),o.m_localAxisD)}return o.m_ratio=e(n.ratio,1),o.m_constant=r+o.m_ratio*s,o.m_impulse=0,o}return Qe(n,i),n.prototype.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_indexC=this.m_bodyC.m_islandIndex,this.m_indexD=this.m_bodyD.m_islandIndex,this.m_lcA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_lcB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_lcC.Copy(this.m_bodyC.m_sweep.localCenter),this.m_lcD.Copy(this.m_bodyD.m_sweep.localCenter),this.m_mA=this.m_bodyA.m_invMass,this.m_mB=this.m_bodyB.m_invMass,this.m_mC=this.m_bodyC.m_invMass,this.m_mD=this.m_bodyD.m_invMass,this.m_iA=this.m_bodyA.m_invI,this.m_iB=this.m_bodyB.m_invI,this.m_iC=this.m_bodyC.m_invI,this.m_iD=this.m_bodyD.m_invI;var i=e.positions[this.m_indexA].a,r=e.velocities[this.m_indexA].v,s=e.velocities[this.m_indexA].w,o=e.positions[this.m_indexB].a,a=e.velocities[this.m_indexB].v,h=e.velocities[this.m_indexB].w,l=e.positions[this.m_indexC].a,c=e.velocities[this.m_indexC].v,u=e.velocities[this.m_indexC].w,_=e.positions[this.m_indexD].a,f=e.velocities[this.m_indexD].v,m=e.velocities[this.m_indexD].w,d=this.m_qA.SetAngle(i),p=this.m_qB.SetAngle(o),y=this.m_qC.SetAngle(l),v=this.m_qD.SetAngle(_);if(this.m_mass=0,this.m_typeA===t.b2JointType.e_revoluteJoint)this.m_JvAC.SetZero(),this.m_JwA=1,this.m_JwC=1,this.m_mass+=this.m_iA+this.m_iC;else{var g=V.MulRV(y,this.m_localAxisC,n.InitVelocityConstraints_s_u);I.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var x=V.MulRV(y,this.m_lalcC,n.InitVelocityConstraints_s_rC);I.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var A=V.MulRV(d,this.m_lalcA,n.InitVelocityConstraints_s_rA);this.m_JvAC.Copy(g),this.m_JwC=I.CrossVV(x,g),this.m_JwA=I.CrossVV(A,g),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_typeB===t.b2JointType.e_revoluteJoint)this.m_JvBD.SetZero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{g=V.MulRV(v,this.m_localAxisD,n.InitVelocityConstraints_s_u);I.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var b=V.MulRV(v,this.m_lalcD,n.InitVelocityConstraints_s_rD);I.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var C=V.MulRV(p,this.m_lalcB,n.InitVelocityConstraints_s_rB);I.MulSV(this.m_ratio,g,this.m_JvBD),this.m_JwD=this.m_ratio*I.CrossVV(b,g),this.m_JwB=this.m_ratio*I.CrossVV(C,g),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0,e.step.warmStarting?(r.SelfMulAdd(this.m_mA*this.m_impulse,this.m_JvAC),s+=this.m_iA*this.m_impulse*this.m_JwA,a.SelfMulAdd(this.m_mB*this.m_impulse,this.m_JvBD),h+=this.m_iB*this.m_impulse*this.m_JwB,c.SelfMulSub(this.m_mC*this.m_impulse,this.m_JvAC),u-=this.m_iC*this.m_impulse*this.m_JwC,f.SelfMulSub(this.m_mD*this.m_impulse,this.m_JvBD),m-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0,e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=h,e.velocities[this.m_indexC].w=u,e.velocities[this.m_indexD].w=m},n.prototype.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,r=t.velocities[this.m_indexB].w,s=t.velocities[this.m_indexC].v,o=t.velocities[this.m_indexC].w,a=t.velocities[this.m_indexD].v,h=t.velocities[this.m_indexD].w,l=I.DotVV(this.m_JvAC,I.SubVV(e,s,I.s_t0))+I.DotVV(this.m_JvBD,I.SubVV(n,a,I.s_t0));l+=this.m_JwA*i-this.m_JwC*o+(this.m_JwB*r-this.m_JwD*h);var c=-this.m_mass*l;this.m_impulse+=c,e.SelfMulAdd(this.m_mA*c,this.m_JvAC),i+=this.m_iA*c*this.m_JwA,n.SelfMulAdd(this.m_mB*c,this.m_JvBD),r+=this.m_iB*c*this.m_JwB,s.SelfMulSub(this.m_mC*c,this.m_JvAC),o-=this.m_iC*c*this.m_JwC,a.SelfMulSub(this.m_mD*c,this.m_JvBD),h-=this.m_iD*c*this.m_JwD,t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=r,t.velocities[this.m_indexC].w=o,t.velocities[this.m_indexD].w=h},n.prototype.SolvePositionConstraints=function(e){var i,r,s,o,a,l,c=e.positions[this.m_indexA].c,u=e.positions[this.m_indexA].a,_=e.positions[this.m_indexB].c,f=e.positions[this.m_indexB].a,m=e.positions[this.m_indexC].c,d=e.positions[this.m_indexC].a,p=e.positions[this.m_indexD].c,y=e.positions[this.m_indexD].a,v=this.m_qA.SetAngle(u),g=this.m_qB.SetAngle(f),x=this.m_qC.SetAngle(d),A=this.m_qD.SetAngle(y),b=this.m_JvAC,C=this.m_JvBD,S=0;if(this.m_typeA===t.b2JointType.e_revoluteJoint)b.SetZero(),s=1,a=1,S+=this.m_iA+this.m_iC,i=u-d-this.m_referenceAngleA;else{var T=V.MulRV(x,this.m_localAxisC,n.SolvePositionConstraints_s_u),w=V.MulRV(x,this.m_lalcC,n.SolvePositionConstraints_s_rC),E=V.MulRV(v,this.m_lalcA,n.SolvePositionConstraints_s_rA);b.Copy(T),a=I.CrossVV(w,T),s=I.CrossVV(E,T),S+=this.m_mC+this.m_mA+this.m_iC*a*a+this.m_iA*s*s;var D=this.m_lalcC,B=V.MulTRV(x,I.AddVV(E,I.SubVV(c,m,I.s_t0),I.s_t0),I.s_t0);i=I.DotVV(I.SubVV(B,D,I.s_t0),this.m_localAxisC)}if(this.m_typeB===t.b2JointType.e_revoluteJoint)C.SetZero(),o=this.m_ratio,l=this.m_ratio,S+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),r=f-y-this.m_referenceAngleB;else{T=V.MulRV(A,this.m_localAxisD,n.SolvePositionConstraints_s_u);var M=V.MulRV(A,this.m_lalcD,n.SolvePositionConstraints_s_rD),P=V.MulRV(g,this.m_lalcB,n.SolvePositionConstraints_s_rB);I.MulSV(this.m_ratio,T,C),l=this.m_ratio*I.CrossVV(M,T),o=this.m_ratio*I.CrossVV(P,T),S+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*l*l+this.m_iB*o*o;var R=this.m_lalcD,L=V.MulTRV(A,I.AddVV(P,I.SubVV(_,p,I.s_t0),I.s_t0),I.s_t0);r=I.DotVV(I.SubVV(L,R,I.s_t0),this.m_localAxisD)}var O=i+this.m_ratio*r-this.m_constant,F=0;return S>0&&(F=-O/S),c.SelfMulAdd(this.m_mA*F,b),u+=this.m_iA*F*s,_.SelfMulAdd(this.m_mB*F,C),f+=this.m_iB*F*o,m.SelfMulSub(this.m_mC*F,b),d-=this.m_iC*F*a,p.SelfMulSub(this.m_mD*F,C),y-=this.m_iD*F*l,e.positions[this.m_indexA].a=u,e.positions[this.m_indexB].a=f,e.positions[this.m_indexC].a=d,e.positions[this.m_indexD].a=y,00&&(this.m_angularMass=1/this.m_angularMass),I.SubVV(I.AddVV(s,_,I.s_t0),I.AddVV(e,u,I.s_t1),this.m_linearError),this.m_angularError=o-i-this.m_angularOffset,t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var v=this.m_linearImpulse;n.SelfMulSub(f,v),r-=d*(I.CrossVV(u,v)+this.m_angularImpulse),a.SelfMulAdd(m,v),h+=p*(I.CrossVV(_,v)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=h},i.prototype.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,h=this.m_invIA,l=this.m_invIB,c=t.step.dt,u=t.step.inv_dt,_=s-n+u*this.m_correctionFactor*this.m_angularError,f=-this.m_angularMass*_,m=this.m_angularImpulse,d=c*this.m_maxTorque;this.m_angularImpulse=A(this.m_angularImpulse+f,-d,d),n-=h*(f=this.m_angularImpulse-m),s+=l*f;var p=this.m_rA,y=this.m_rB,v=I.AddVV(I.SubVV(I.AddVV(r,I.CrossSV(s,y,I.s_t0),I.s_t0),I.AddVV(e,I.CrossSV(n,p,I.s_t1),I.s_t1),I.s_t2),I.MulSV(u*this.m_correctionFactor,this.m_linearError,I.s_t3),i.SolveVelocityConstraints_s_Cdot_v2),g=O.MulMV(this.m_linearMass,v,i.SolveVelocityConstraints_s_impulse_v2).SelfNeg(),x=i.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(g);d=c*this.m_maxForce;this.m_linearImpulse.LengthSquared()>d*d&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(d)),I.SubVV(this.m_linearImpulse,x,g),e.SelfMulSub(o,g),n-=h*I.CrossVV(p,g),r.SelfMulAdd(a,g),s+=l*I.CrossVV(y,g),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},i.prototype.SolvePositionConstraints=function(t){return!0},i.prototype.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2MotorJointDef = new b2MotorJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.linearOffset.Set(%.15f, %.15f);\n",this.m_linearOffset.x,this.m_linearOffset.y),t(" jd.angularOffset = %.15f;\n",this.m_angularOffset),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" jd.correctionFactor = %.15f;\n",this.m_correctionFactor),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i.SolveVelocityConstraints_s_Cdot_v2=new I,i.SolveVelocityConstraints_s_impulse_v2=new I,i.SolveVelocityConstraints_s_oldImpulse_v2=new I,i})(_i),Ci=(function(e){function i(){var i=e.call(this,t.b2JointType.e_mouseJoint)||this;return i.target=new I,i.maxForce=0,i.frequencyHz=5,i.dampingRatio=.7,i}return Qe(i,e),i})(ui),Si=(function(t){function i(i){var n=t.call(this,i)||this;return n.m_localAnchorB=new I,n.m_targetA=new I,n.m_frequencyHz=0,n.m_dampingRatio=0,n.m_beta=0,n.m_impulse=new I,n.m_maxForce=0,n.m_gamma=0,n.m_indexA=0,n.m_indexB=0,n.m_rB=new I,n.m_localCenterB=new I,n.m_invMassB=0,n.m_invIB=0,n.m_mass=new O,n.m_C=new I,n.m_qB=new V,n.m_lalcB=new I,n.m_K=new O,n.m_targetA.Copy(e(i.target,I.ZERO)),N.MulTXV(n.m_bodyB.GetTransform(),n.m_targetA,n.m_localAnchorB),n.m_maxForce=e(i.maxForce,0),n.m_impulse.SetZero(),n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_beta=0,n.m_gamma=0,n}return Qe(i,t),i.prototype.SetTarget=function(t){this.m_bodyB.IsAwake()||this.m_bodyB.SetAwake(!0),this.m_targetA.Copy(t)},i.prototype.GetTarget=function(){return this.m_targetA},i.prototype.SetMaxForce=function(t){this.m_maxForce=t},i.prototype.GetMaxForce=function(){return this.m_maxForce},i.prototype.SetFrequency=function(t){this.m_frequencyHz=t},i.prototype.GetFrequency=function(){return this.m_frequencyHz},i.prototype.SetDampingRatio=function(t){this.m_dampingRatio=t},i.prototype.GetDampingRatio=function(){return this.m_dampingRatio},i.prototype.InitVelocityConstraints=function(t){this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexB].c,i=t.positions[this.m_indexB].a,n=t.velocities[this.m_indexB].v,r=t.velocities[this.m_indexB].w,o=this.m_qB.SetAngle(i),a=this.m_bodyB.GetMass(),h=2*s*this.m_frequencyHz,l=2*a*this.m_dampingRatio*h,c=a*(h*h),u=t.step.dt;this.m_gamma=u*(l+u*c),0!==this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=u*c*this.m_gamma,I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),V.MulRV(o,this.m_lalcB,this.m_rB);var _=this.m_K;_.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,_.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,_.ey.x=_.ex.y,_.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,_.GetInverse(this.m_mass),this.m_C.x=e.x+this.m_rB.x-this.m_targetA.x,this.m_C.y=e.y+this.m_rB.y-this.m_targetA.y,this.m_C.SelfMul(this.m_beta),r*=.98,t.step.warmStarting?(this.m_impulse.SelfMul(t.step.dtRatio),n.x+=this.m_invMassB*this.m_impulse.x,n.y+=this.m_invMassB*this.m_impulse.y,r+=this.m_invIB*I.CrossVV(this.m_rB,this.m_impulse)):this.m_impulse.SetZero(),t.velocities[this.m_indexB].w=r},i.prototype.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexB].v,n=t.velocities[this.m_indexB].w,r=I.AddVCrossSV(e,n,this.m_rB,i.SolveVelocityConstraints_s_Cdot),s=O.MulMV(this.m_mass,I.AddVV(r,I.AddVV(this.m_C,I.MulSV(this.m_gamma,this.m_impulse,I.s_t0),I.s_t0),I.s_t0).SelfNeg(),i.SolveVelocityConstraints_s_impulse),o=i.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse);this.m_impulse.SelfAdd(s);var a=t.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>a*a&&this.m_impulse.SelfMul(a/this.m_impulse.Length()),I.SubVV(this.m_impulse,o,s),e.SelfMulAdd(this.m_invMassB,s),n+=this.m_invIB*I.CrossVV(this.m_rB,s),t.velocities[this.m_indexB].w=n},i.prototype.SolvePositionConstraints=function(t){return!0},i.prototype.GetAnchorA=function(t){return t.x=this.m_targetA.x,t.y=this.m_targetA.y,t},i.prototype.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},i.prototype.GetReactionForce=function(t,e){return I.MulSV(t,this.m_impulse,e)},i.prototype.GetReactionTorque=function(t){return 0},i.prototype.Dump=function(t){t("Mouse joint dumping is not supported.\n")},i.prototype.ShiftOrigin=function(t){this.m_targetA.SelfSub(t)},i.SolveVelocityConstraints_s_Cdot=new I,i.SolveVelocityConstraints_s_impulse=new I,i.SolveVelocityConstraints_s_oldImpulse=new I,i})(_i),Ti=(function(e){function i(){var i=e.call(this,t.b2JointType.e_prismaticJoint)||this;return i.localAnchorA=new I,i.localAnchorB=new I,i.localAxisA=new I(1,0),i.referenceAngle=0,i.enableLimit=!1,i.lowerTranslation=0,i.upperTranslation=0,i.enableMotor=!1,i.maxMotorForce=0,i.motorSpeed=0,i}return Qe(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(n,this.localAxisA),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i})(ui),wi=(function(i){function n(n){var r=i.call(this,n)||this;return r.m_localAnchorA=new I,r.m_localAnchorB=new I,r.m_localXAxisA=new I,r.m_localYAxisA=new I,r.m_referenceAngle=0,r.m_impulse=new L(0,0,0),r.m_motorImpulse=0,r.m_lowerTranslation=0,r.m_upperTranslation=0,r.m_maxMotorForce=0,r.m_motorSpeed=0,r.m_enableLimit=!1,r.m_enableMotor=!1,r.m_limitState=t.b2LimitState.e_inactiveLimit,r.m_indexA=0,r.m_indexB=0,r.m_localCenterA=new I,r.m_localCenterB=new I,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_axis=new I(0,0),r.m_perp=new I(0,0),r.m_s1=0,r.m_s2=0,r.m_a1=0,r.m_a2=0,r.m_K=new F,r.m_K3=new F,r.m_K2=new O,r.m_motorMass=0,r.m_qA=new V,r.m_qB=new V,r.m_lalcA=new I,r.m_lalcB=new I,r.m_rA=new I,r.m_rB=new I,r.m_localAnchorA.Copy(e(n.localAnchorA,I.ZERO)),r.m_localAnchorB.Copy(e(n.localAnchorB,I.ZERO)),r.m_localXAxisA.Copy(e(n.localAxisA,new I(1,0))).SelfNormalize(),I.CrossOneV(r.m_localXAxisA,r.m_localYAxisA),r.m_referenceAngle=e(n.referenceAngle,0),r.m_lowerTranslation=e(n.lowerTranslation,0),r.m_upperTranslation=e(n.upperTranslation,0),r.m_maxMotorForce=e(n.maxMotorForce,0),r.m_motorSpeed=e(n.motorSpeed,0),r.m_enableLimit=e(n.enableLimit,!1),r.m_enableMotor=e(n.enableMotor,!1),r}return Qe(n,i),n.prototype.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,o=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].c,l=e.positions[this.m_indexB].a,c=e.velocities[this.m_indexB].v,u=e.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(r),f=this.m_qB.SetAngle(l);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var m=V.MulRV(_,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var d=V.MulRV(f,this.m_lalcB,this.m_rB),p=I.AddVV(I.SubVV(a,i,I.s_t0),I.SubVV(d,m,I.s_t1),n.InitVelocityConstraints_s_d),y=this.m_invMassA,g=this.m_invMassB,x=this.m_invIA,A=this.m_invIB;if(V.MulRV(_,this.m_localXAxisA,this.m_axis),this.m_a1=I.CrossVV(I.AddVV(p,m,I.s_t0),this.m_axis),this.m_a2=I.CrossVV(d,this.m_axis),this.m_motorMass=y+g+x*this.m_a1*this.m_a1+A*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),V.MulRV(_,this.m_localYAxisA,this.m_perp),this.m_s1=I.CrossVV(I.AddVV(p,m,I.s_t0),this.m_perp),this.m_s2=I.CrossVV(d,this.m_perp),this.m_K.ex.x=y+g+x*this.m_s1*this.m_s1+A*this.m_s2*this.m_s2,this.m_K.ex.y=x*this.m_s1+A*this.m_s2,this.m_K.ex.z=x*this.m_s1*this.m_a1+A*this.m_s2*this.m_a2,this.m_K.ey.x=this.m_K.ex.y,this.m_K.ey.y=x+A,0===this.m_K.ey.y&&(this.m_K.ey.y=1),this.m_K.ey.z=x*this.m_a1+A*this.m_a2,this.m_K.ez.x=this.m_K.ex.z,this.m_K.ez.y=this.m_K.ey.z,this.m_K.ez.z=y+g+x*this.m_a1*this.m_a1+A*this.m_a2*this.m_a2,this.m_enableLimit){var b=I.DotVV(this.m_axis,p);v(this.m_upperTranslation-this.m_lowerTranslation)<2*h?this.m_limitState=t.b2LimitState.e_equalLimits:b<=this.m_lowerTranslation?this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_limitState=t.b2LimitState.e_atLowerLimit,this.m_impulse.z=0):b>=this.m_upperTranslation?this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_limitState=t.b2LimitState.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0;if(this.m_enableMotor||(this.m_motorImpulse=0),e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var C=I.AddVV(I.MulSV(this.m_impulse.x,this.m_perp,I.s_t0),I.MulSV(this.m_motorImpulse+this.m_impulse.z,this.m_axis,I.s_t1),n.InitVelocityConstraints_s_P),S=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,T=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;s.SelfMulSub(y,C),o-=x*S,c.SelfMulAdd(g,C),u+=A*T}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=o,e.velocities[this.m_indexB].w=u},n.prototype.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,o=e.velocities[this.m_indexB].w,a=this.m_invMassA,h=this.m_invMassB,l=this.m_invIA,c=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits){var u=I.DotVV(this.m_axis,I.SubVV(s,i,I.s_t0))+this.m_a2*o-this.m_a1*r,_=this.m_motorMass*(this.m_motorSpeed-u),f=this.m_motorImpulse,m=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=A(this.m_motorImpulse+_,-m,m),_=this.m_motorImpulse-f;var d=I.MulSV(_,this.m_axis,n.SolveVelocityConstraints_s_P),p=_*this.m_a1,y=_*this.m_a2;i.SelfMulSub(a,d),r-=l*p,s.SelfMulAdd(h,d),o+=c*y}var v=I.DotVV(this.m_perp,I.SubVV(s,i,I.s_t0))+this.m_s2*o-this.m_s1*r,b=o-r;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit){var C=I.DotVV(this.m_axis,I.SubVV(s,i,I.s_t0))+this.m_a2*o-this.m_a1*r,S=n.SolveVelocityConstraints_s_f1.Copy(this.m_impulse),T=this.m_K.Solve33(-v,-b,-C,n.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(T),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=x(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=g(this.m_impulse.z,0));var w=-v-(this.m_impulse.z-S.z)*this.m_K.ez.x,E=-b-(this.m_impulse.z-S.z)*this.m_K.ez.y,D=this.m_K.Solve22(w,E,n.SolveVelocityConstraints_s_f2r);D.x+=S.x,D.y+=S.y,this.m_impulse.x=D.x,this.m_impulse.y=D.y,T.x=this.m_impulse.x-S.x,T.y=this.m_impulse.y-S.y,T.z=this.m_impulse.z-S.z;d=I.AddVV(I.MulSV(T.x,this.m_perp,I.s_t0),I.MulSV(T.z,this.m_axis,I.s_t1),n.SolveVelocityConstraints_s_P),p=T.x*this.m_s1+T.y+T.z*this.m_a1,y=T.x*this.m_s2+T.y+T.z*this.m_a2;i.SelfMulSub(a,d),r-=l*p,s.SelfMulAdd(h,d),o+=c*y}else{var B=this.m_K.Solve22(-v,-b,n.SolveVelocityConstraints_s_df2);this.m_impulse.x+=B.x,this.m_impulse.y+=B.y;d=I.MulSV(B.x,this.m_perp,n.SolveVelocityConstraints_s_P),p=B.x*this.m_s1+B.y,y=B.x*this.m_s2+B.y;i.SelfMulSub(a,d),r-=l*p,s.SelfMulAdd(h,d),o+=c*y}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=o},n.prototype.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(i),a=this.m_qB.SetAngle(s),c=this.m_invMassA,u=this.m_invMassB,_=this.m_invIA,f=this.m_invIB,m=V.MulRV(o,this.m_lalcA,this.m_rA),d=V.MulRV(a,this.m_lalcB,this.m_rB),p=I.SubVV(I.AddVV(r,d,I.s_t0),I.AddVV(e,m,I.s_t1),n.SolvePositionConstraints_s_d),y=V.MulRV(o,this.m_localXAxisA,this.m_axis),g=I.CrossVV(I.AddVV(p,m,I.s_t0),y),b=I.CrossVV(d,y),C=V.MulRV(o,this.m_localYAxisA,this.m_perp),S=I.CrossVV(I.AddVV(p,m,I.s_t0),C),T=I.CrossVV(d,C),w=n.SolvePositionConstraints_s_impulse,E=I.DotVV(C,p),D=s-i-this.m_referenceAngle,B=v(E),M=v(D),P=!1,R=0;if(this.m_enableLimit){var L=I.DotVV(y,p);v(this.m_upperTranslation-this.m_lowerTranslation)<2*h?(R=A(L,-.2,.2),B=x(B,v(L)),P=!0):L<=this.m_lowerTranslation?(R=A(L-this.m_lowerTranslation+h,-.2,0),B=x(B,this.m_lowerTranslation-L),P=!0):L>=this.m_upperTranslation&&(R=A(L-this.m_upperTranslation-h,0,.2),B=x(B,L-this.m_upperTranslation),P=!0)}if(P){var O=c+u+_*S*S+f*T*T,F=_*S+f*T,N=_*S*g+f*T*b;0===(U=_+f)&&(U=1);var k=_*g+f*b,G=c+u+_*g*g+f*b*b,z=this.m_K3;z.ex.SetXYZ(O,F,N),z.ey.SetXYZ(F,U,k),z.ez.SetXYZ(N,k,G),w=z.Solve33(-E,-D,-R,w)}else{var U;O=c+u+_*S*S+f*T*T,F=_*S+f*T;0===(U=_+f)&&(U=1);var W=this.m_K2;W.ex.Set(O,F),W.ey.Set(F,U);var j=W.Solve(-E,-D,n.SolvePositionConstraints_s_impulse1);w.x=j.x,w.y=j.y,w.z=0}var H=I.AddVV(I.MulSV(w.x,C,I.s_t0),I.MulSV(w.z,y,I.s_t1),n.SolvePositionConstraints_s_P),X=w.x*S+w.y+w.z*g,Y=w.x*T+w.y+w.z*b;return e.SelfMulSub(c,H),i-=_*X,r.SelfMulAdd(u,H),s+=f*Y,t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,B<=h&&M<=l},n.prototype.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.prototype.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.prototype.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),e.y=t*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y),e},n.prototype.GetReactionTorque=function(t){return t*this.m_impulse.y},n.prototype.GetLocalAnchorA=function(){return this.m_localAnchorA},n.prototype.GetLocalAnchorB=function(){return this.m_localAnchorB},n.prototype.GetLocalAxisA=function(){return this.m_localXAxisA},n.prototype.GetReferenceAngle=function(){return this.m_referenceAngle},n.prototype.GetJointTranslation=function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,n.GetJointTranslation_s_pA),e=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,n.GetJointTranslation_s_pB),i=I.SubVV(e,t,n.GetJointTranslation_s_d),r=this.m_bodyA.GetWorldVector(this.m_localXAxisA,n.GetJointTranslation_s_axis);return I.DotVV(i,r)},n.prototype.GetJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;I.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=V.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=V.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=I.AddVV(t.m_sweep.c,i,I.s_t0),s=I.AddVV(e.m_sweep.c,n,I.s_t1),o=I.SubVV(s,r,I.s_t2),a=t.GetWorldVector(this.m_localXAxisA,this.m_axis),h=t.m_linearVelocity,l=e.m_linearVelocity,c=t.m_angularVelocity,u=e.m_angularVelocity;return I.DotVV(o,I.CrossSV(c,a,I.s_t0))+I.DotVV(a,I.SubVV(I.AddVCrossSV(l,u,n,I.s_t0),I.AddVCrossSV(h,c,i,I.s_t1),I.s_t0))},n.prototype.IsLimitEnabled=function(){return this.m_enableLimit},n.prototype.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},n.prototype.GetLowerLimit=function(){return this.m_lowerTranslation},n.prototype.GetUpperLimit=function(){return this.m_upperTranslation},n.prototype.SetLimits=function(t,e){t===this.m_lowerTranslation&&e===this.m_upperTranslation||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=e,this.m_impulse.z=0)},n.prototype.IsMotorEnabled=function(){return this.m_enableMotor},n.prototype.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},n.prototype.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},n.prototype.GetMotorSpeed=function(){return this.m_motorSpeed},n.prototype.SetMaxMotorForce=function(t){t!==this.m_maxMotorForce&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=t)},n.prototype.GetMaxMotorForce=function(){return this.m_maxMotorForce},n.prototype.GetMotorForce=function(t){return t*this.m_motorImpulse},n.prototype.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2PrismaticJointDef = new b2PrismaticJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerTranslation = %.15f;\n",this.m_lowerTranslation),t(" jd.upperTranslation = %.15f;\n",this.m_upperTranslation),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorForce = %.15f;\n",this.m_maxMotorForce),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n.InitVelocityConstraints_s_d=new I,n.InitVelocityConstraints_s_P=new I,n.SolveVelocityConstraints_s_P=new I,n.SolveVelocityConstraints_s_f2r=new I,n.SolveVelocityConstraints_s_f1=new L,n.SolveVelocityConstraints_s_df3=new L,n.SolveVelocityConstraints_s_df2=new I,n.SolvePositionConstraints_s_d=new I,n.SolvePositionConstraints_s_impulse=new L,n.SolvePositionConstraints_s_impulse1=new I,n.SolvePositionConstraints_s_P=new I,n.GetJointTranslation_s_pA=new I,n.GetJointTranslation_s_pB=new I,n.GetJointTranslation_s_d=new I,n.GetJointTranslation_s_axis=new I,n})(_i),Ei=(function(e){function i(){var i=e.call(this,t.b2JointType.e_pulleyJoint)||this;return i.groundAnchorA=new I(-1,1),i.groundAnchorB=new I(1,1),i.localAnchorA=new I(-1,0),i.localAnchorB=new I(1,0),i.lengthA=0,i.lengthB=0,i.ratio=1,i.collideConnected=!0,i}return Qe(i,e),i.prototype.Initialize=function(t,e,i,n,r,s,o){this.bodyA=t,this.bodyB=e,this.groundAnchorA.Copy(i),this.groundAnchorB.Copy(n),this.bodyA.GetLocalPoint(r,this.localAnchorA),this.bodyB.GetLocalPoint(s,this.localAnchorB),this.lengthA=I.DistanceVV(r,i),this.lengthB=I.DistanceVV(s,n),this.ratio=o},i})(ui),Di=(function(t){function i(i){var n=t.call(this,i)||this;return n.m_groundAnchorA=new I,n.m_groundAnchorB=new I,n.m_lengthA=0,n.m_lengthB=0,n.m_localAnchorA=new I,n.m_localAnchorB=new I,n.m_constant=0,n.m_ratio=0,n.m_impulse=0,n.m_indexA=0,n.m_indexB=0,n.m_uA=new I,n.m_uB=new I,n.m_rA=new I,n.m_rB=new I,n.m_localCenterA=new I,n.m_localCenterB=new I,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new V,n.m_qB=new V,n.m_lalcA=new I,n.m_lalcB=new I,n.m_groundAnchorA.Copy(e(i.groundAnchorA,new I(-1,1))),n.m_groundAnchorB.Copy(e(i.groundAnchorB,new I(1,0))),n.m_localAnchorA.Copy(e(i.localAnchorA,new I(-1,0))),n.m_localAnchorB.Copy(e(i.localAnchorB,new I(1,0))),n.m_lengthA=e(i.lengthA,0),n.m_lengthB=e(i.lengthB,0),n.m_ratio=e(i.ratio,1),n.m_constant=e(i.lengthA,0)+n.m_ratio*e(i.lengthB,0),n.m_impulse=0,n}return Qe(i,t),i.prototype.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c,a=t.positions[this.m_indexB].a,l=t.velocities[this.m_indexB].v,c=t.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(n),_=this.m_qB.SetAngle(a);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),V.MulRV(u,this.m_lalcA,this.m_rA),I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),V.MulRV(_,this.m_lalcB,this.m_rB),this.m_uA.Copy(e).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA),this.m_uB.Copy(o).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB);var f=this.m_uA.Length(),m=this.m_uB.Length();f>10*h?this.m_uA.SelfMul(1/f):this.m_uA.SetZero(),m>10*h?this.m_uB.SelfMul(1/m):this.m_uB.SetZero();var d=I.CrossVV(this.m_rA,this.m_uA),p=I.CrossVV(this.m_rB,this.m_uB),y=this.m_invMassA+this.m_invIA*d*d,v=this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=y+this.m_ratio*this.m_ratio*v,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var g=I.MulSV(-this.m_impulse,this.m_uA,i.InitVelocityConstraints_s_PA),x=I.MulSV(-this.m_ratio*this.m_impulse,this.m_uB,i.InitVelocityConstraints_s_PB);r.SelfMulAdd(this.m_invMassA,g),s+=this.m_invIA*I.CrossVV(this.m_rA,g),l.SelfMulAdd(this.m_invMassB,x),c+=this.m_invIB*I.CrossVV(this.m_rB,x)}else this.m_impulse=0;t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].w=c},i.prototype.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=I.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),a=I.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=-I.DotVV(this.m_uA,o)-this.m_ratio*I.DotVV(this.m_uB,a),l=-this.m_mass*h;this.m_impulse+=l;var c=I.MulSV(-l,this.m_uA,i.SolveVelocityConstraints_s_PA),u=I.MulSV(-this.m_ratio*l,this.m_uB,i.SolveVelocityConstraints_s_PB);e.SelfMulAdd(this.m_invMassA,c),n+=this.m_invIA*I.CrossVV(this.m_rA,c),r.SelfMulAdd(this.m_invMassB,u),s+=this.m_invIB*I.CrossVV(this.m_rB,u),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},i.prototype.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=V.MulRV(o,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var c=V.MulRV(a,this.m_lalcB,this.m_rB),u=this.m_uA.Copy(e).SelfAdd(l).SelfSub(this.m_groundAnchorA),_=this.m_uB.Copy(r).SelfAdd(c).SelfSub(this.m_groundAnchorB),f=u.Length(),m=_.Length();f>10*h?u.SelfMul(1/f):u.SetZero(),m>10*h?_.SelfMul(1/m):_.SetZero();var d=I.CrossVV(l,u),p=I.CrossVV(c,_),y=this.m_invMassA+this.m_invIA*d*d,g=this.m_invMassB+this.m_invIB*p*p,x=y+this.m_ratio*this.m_ratio*g;x>0&&(x=1/x);var A=this.m_constant-f-this.m_ratio*m,b=v(A),C=-x*A,S=I.MulSV(-C,u,i.SolvePositionConstraints_s_PA),T=I.MulSV(-this.m_ratio*C,_,i.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,S),n+=this.m_invIA*I.CrossVV(l,S),r.SelfMulAdd(this.m_invMassB,T),s+=this.m_invIB*I.CrossVV(c,T),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,b0&&(this.m_motorMass=1/this.m_motorMass),this.m_enableMotor&&!p||(this.m_motorImpulse=0),this.m_enableLimit&&!p){var y=o-i-this.m_referenceAngle;v(this.m_upperAngle-this.m_lowerAngle)<2*l?this.m_limitState=t.b2LimitState.e_equalLimits:y<=this.m_lowerAngle?(this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atLowerLimit):y>=this.m_upperAngle?(this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atUpperLimit):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit;if(e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var g=n.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);r.SelfMulSub(_,g),s-=m*(I.CrossVV(this.m_rA,g)+this.m_motorImpulse+this.m_impulse.z),a.SelfMulAdd(f,g),h+=d*(I.CrossVV(this.m_rB,g)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=h},n.prototype.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,o=e.velocities[this.m_indexB].w,a=this.m_invMassA,h=this.m_invMassB,l=this.m_invIA,c=this.m_invIB,u=l+c===0;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits&&!u){var _=o-r-this.m_motorSpeed,f=-this.m_motorMass*_,m=this.m_motorImpulse,d=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=A(this.m_motorImpulse+f,-d,d),r-=l*(f=this.m_motorImpulse-m),o+=c*f}if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!u){var p=I.SubVV(I.AddVCrossSV(s,o,this.m_rB,I.s_t0),I.AddVCrossSV(i,r,this.m_rA,I.s_t1),n.SolveVelocityConstraints_s_Cdot1),y=o-r,v=this.m_mass.Solve33(p.x,p.y,y,n.SolveVelocityConstraints_s_impulse_v3).SelfNeg();if(this.m_limitState===t.b2LimitState.e_equalLimits)this.m_impulse.SelfAdd(v);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){if(this.m_impulse.z+v.z<0){var g=-p.x+this.m_impulse.z*this.m_mass.ez.x,x=-p.y+this.m_impulse.z*this.m_mass.ez.y,b=this.m_mass.Solve22(g,x,n.SolveVelocityConstraints_s_reduced_v2);v.x=b.x,v.y=b.y,v.z=-this.m_impulse.z,this.m_impulse.x+=b.x,this.m_impulse.y+=b.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(v)}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){if(this.m_impulse.z+v.z>0){g=-p.x+this.m_impulse.z*this.m_mass.ez.x,x=-p.y+this.m_impulse.z*this.m_mass.ez.y,b=this.m_mass.Solve22(g,x,n.SolveVelocityConstraints_s_reduced_v2);v.x=b.x,v.y=b.y,v.z=-this.m_impulse.z,this.m_impulse.x+=b.x,this.m_impulse.y+=b.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(v)}var C=n.SolveVelocityConstraints_s_P.Set(v.x,v.y);i.SelfMulSub(a,C),r-=l*(I.CrossVV(this.m_rA,C)+v.z),s.SelfMulAdd(h,C),o+=c*(I.CrossVV(this.m_rB,C)+v.z)}else{var S=I.SubVV(I.AddVCrossSV(s,o,this.m_rB,I.s_t0),I.AddVCrossSV(i,r,this.m_rA,I.s_t1),n.SolveVelocityConstraints_s_Cdot_v2),T=this.m_mass.Solve22(-S.x,-S.y,n.SolveVelocityConstraints_s_impulse_v2);this.m_impulse.x+=T.x,this.m_impulse.y+=T.y,i.SelfMulSub(a,T),r-=l*I.CrossVV(this.m_rA,T),s.SelfMulAdd(h,T),o+=c*I.CrossVV(this.m_rB,T)}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=o},n.prototype.SolvePositionConstraints=function(e){var i,r=e.positions[this.m_indexA].c,s=e.positions[this.m_indexA].a,o=e.positions[this.m_indexB].c,a=e.positions[this.m_indexB].a,c=this.m_qA.SetAngle(s),u=this.m_qB.SetAngle(a),_=0,f=this.m_invIA+this.m_invIB===0;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!f){var m=a-s-this.m_referenceAngle,d=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var p=A(m-this.m_lowerAngle,-.13962634015955555,.13962634015955555);d=-this.m_motorMass*p,_=v(p)}else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){_=-(p=m-this.m_lowerAngle),p=A(p+l,-.13962634015955555,0),d=-this.m_motorMass*p}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){_=p=m-this.m_upperAngle,p=A(p-l,0,.13962634015955555),d=-this.m_motorMass*p}s-=this.m_invIA*d,a+=this.m_invIB*d}c.SetAngle(s),u.SetAngle(a),I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var y=V.MulRV(c,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var g=V.MulRV(u,this.m_lalcB,this.m_rB),x=I.SubVV(I.AddVV(o,g,I.s_t0),I.AddVV(r,y,I.s_t1),n.SolvePositionConstraints_s_C_v2);i=x.Length();var b=this.m_invMassA,C=this.m_invMassB,S=this.m_invIA,T=this.m_invIB,w=this.m_K;w.ex.x=b+C+S*y.y*y.y+T*g.y*g.y,w.ex.y=-S*y.x*y.y-T*g.x*g.y,w.ey.x=w.ex.y,w.ey.y=b+C+S*y.x*y.x+T*g.x*g.x;var E=w.Solve(x.x,x.y,n.SolvePositionConstraints_s_impulse).SelfNeg();return r.SelfMulSub(b,E),s-=S*I.CrossVV(y,E),o.SelfMulAdd(C,E),a+=T*I.CrossVV(g,E),e.positions[this.m_indexA].a=s,e.positions[this.m_indexB].a=a,i<=h&&_<=l},n.prototype.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.prototype.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.prototype.GetReactionForce=function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e},n.prototype.GetReactionTorque=function(t){return t*this.m_impulse.z},n.prototype.GetLocalAnchorA=function(){return this.m_localAnchorA},n.prototype.GetLocalAnchorB=function(){return this.m_localAnchorB},n.prototype.GetReferenceAngle=function(){return this.m_referenceAngle},n.prototype.GetJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle},n.prototype.GetJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity},n.prototype.IsMotorEnabled=function(){return this.m_enableMotor},n.prototype.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},n.prototype.GetMotorTorque=function(t){return t*this.m_motorImpulse},n.prototype.GetMotorSpeed=function(){return this.m_motorSpeed},n.prototype.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},n.prototype.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},n.prototype.IsLimitEnabled=function(){return this.m_enableLimit},n.prototype.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},n.prototype.GetLowerLimit=function(){return this.m_lowerAngle},n.prototype.GetUpperLimit=function(){return this.m_upperAngle},n.prototype.SetLimits=function(t,e){t===this.m_lowerAngle&&e===this.m_upperAngle||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_impulse.z=0,this.m_lowerAngle=t,this.m_upperAngle=e)},n.prototype.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},n.prototype.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2RevoluteJointDef = new b2RevoluteJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerAngle = %.15f;\n",this.m_lowerAngle),t(" jd.upperAngle = %.15f;\n",this.m_upperAngle),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n.InitVelocityConstraints_s_P=new I,n.SolveVelocityConstraints_s_P=new I,n.SolveVelocityConstraints_s_Cdot_v2=new I,n.SolveVelocityConstraints_s_Cdot1=new I,n.SolveVelocityConstraints_s_impulse_v3=new L,n.SolveVelocityConstraints_s_reduced_v2=new I,n.SolveVelocityConstraints_s_impulse_v2=new I,n.SolvePositionConstraints_s_C_v2=new I,n.SolvePositionConstraints_s_impulse=new I,n})(_i),Pi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_ropeJoint)||this;return i.localAnchorA=new I(-1,0),i.localAnchorB=new I(1,0),i.maxLength=0,i}return Qe(i,e),i})(ui),Ii=(function(i){function n(n){var r=i.call(this,n)||this;return r.m_localAnchorA=new I,r.m_localAnchorB=new I,r.m_maxLength=0,r.m_length=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_u=new I,r.m_rA=new I,r.m_rB=new I,r.m_localCenterA=new I,r.m_localCenterB=new I,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_mass=0,r.m_state=t.b2LimitState.e_inactiveLimit,r.m_qA=new V,r.m_qB=new V,r.m_lalcA=new I,r.m_lalcB=new I,r.m_localAnchorA.Copy(e(n.localAnchorA,new I(-1,0))),r.m_localAnchorB.Copy(e(n.localAnchorB,new I(1,0))),r.m_maxLength=e(n.maxLength,0),r}return Qe(n,i),n.prototype.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,o=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].c,l=e.positions[this.m_indexB].a,c=e.velocities[this.m_indexB].v,u=e.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(r),f=this.m_qB.SetAngle(l);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),V.MulRV(_,this.m_lalcA,this.m_rA),I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),V.MulRV(f,this.m_lalcB,this.m_rB),this.m_u.Copy(a).SelfAdd(this.m_rB).SelfSub(i).SelfSub(this.m_rA),this.m_length=this.m_u.Length();var m=this.m_length-this.m_maxLength;if(this.m_state=m>0?t.b2LimitState.e_atUpperLimit:t.b2LimitState.e_inactiveLimit,!(this.m_length>h))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.SelfMul(1/this.m_length);var d=I.CrossVV(this.m_rA,this.m_u),p=I.CrossVV(this.m_rB,this.m_u),y=this.m_invMassA+this.m_invIA*d*d+this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=0!==y?1/y:0,e.step.warmStarting){this.m_impulse*=e.step.dtRatio;var v=I.MulSV(this.m_impulse,this.m_u,n.InitVelocityConstraints_s_P);s.SelfMulSub(this.m_invMassA,v),o-=this.m_invIA*I.CrossVV(this.m_rA,v),c.SelfMulAdd(this.m_invMassB,v),u+=this.m_invIB*I.CrossVV(this.m_rB,v)}else this.m_impulse=0;e.velocities[this.m_indexA].w=o,e.velocities[this.m_indexB].w=u},n.prototype.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=I.AddVCrossSV(e,i,this.m_rA,n.SolveVelocityConstraints_s_vpA),a=I.AddVCrossSV(r,s,this.m_rB,n.SolveVelocityConstraints_s_vpB),h=this.m_length-this.m_maxLength,l=I.DotVV(this.m_u,I.SubVV(a,o,I.s_t0));h<0&&(l+=t.step.inv_dt*h);var c=-this.m_mass*l,u=this.m_impulse;this.m_impulse=g(0,this.m_impulse+c),c=this.m_impulse-u;var _=I.MulSV(c,this.m_u,n.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,_),i-=this.m_invIA*I.CrossVV(this.m_rA,_),r.SelfMulAdd(this.m_invMassB,_),s+=this.m_invIB*I.CrossVV(this.m_rB,_),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=s},n.prototype.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(i),a=this.m_qB.SetAngle(s);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=V.MulRV(o,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var c=V.MulRV(a,this.m_lalcB,this.m_rB),u=this.m_u.Copy(r).SelfAdd(c).SelfSub(e).SelfSub(l),_=u.Normalize(),f=_-this.m_maxLength;f=A(f,0,.2);var m=-this.m_mass*f,d=I.MulSV(m,u,n.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,d),i-=this.m_invIA*I.CrossVV(l,d),r.SelfMulAdd(this.m_invMassB,d),s+=this.m_invIB*I.CrossVV(c,d),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,_-this.m_maxLength0){d.GetInverse22(this.m_mass);var p=f+m,y=p>0?1/p:0,v=o-e-this.m_referenceAngle,g=2*s*this.m_frequencyHz,x=2*y*this.m_dampingRatio*g,A=y*g*g,b=t.step.dt;this.m_gamma=b*(x+b*A),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=v*b*A*this.m_gamma,p+=this.m_gamma,this.m_mass.ez.z=0!==p?1/p:0}else d.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse.SelfMul(t.step.dtRatio);var C=i.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);n.SelfMulSub(u,C),r-=f*(I.CrossVV(this.m_rA,C)+this.m_impulse.z),a.SelfMulAdd(_,C),h+=m*(I.CrossVV(this.m_rB,C)+this.m_impulse.z)}else this.m_impulse.SetZero();t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=h},i.prototype.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,h=this.m_invIA,l=this.m_invIB;if(this.m_frequencyHz>0){var c=s-n,u=-this.m_mass.ez.z*(c+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=u,n-=h*u,s+=l*u;var _=I.SubVV(I.AddVCrossSV(r,s,this.m_rB,I.s_t0),I.AddVCrossSV(e,n,this.m_rA,I.s_t1),i.SolveVelocityConstraints_s_Cdot1),f=F.MulM33XY(this.m_mass,_.x,_.y,i.SolveVelocityConstraints_s_impulse1).SelfNeg();this.m_impulse.x+=f.x,this.m_impulse.y+=f.y;var m=f;e.SelfMulSub(o,m),n-=h*I.CrossVV(this.m_rA,m),r.SelfMulAdd(a,m),s+=l*I.CrossVV(this.m_rB,m)}else{_=I.SubVV(I.AddVCrossSV(r,s,this.m_rB,I.s_t0),I.AddVCrossSV(e,n,this.m_rA,I.s_t1),i.SolveVelocityConstraints_s_Cdot1),c=s-n;var d=F.MulM33XYZ(this.m_mass,_.x,_.y,c,i.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(d);m=i.SolveVelocityConstraints_s_P.Set(d.x,d.y);e.SelfMulSub(o,m),n-=h*(I.CrossVV(this.m_rA,m)+d.z),r.SelfMulAdd(a,m),s+=l*(I.CrossVV(this.m_rB,m)+d.z)}t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},i.prototype.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s),c=this.m_invMassA,u=this.m_invMassB,_=this.m_invIA,f=this.m_invIB;I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var m=V.MulRV(o,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var d,p,y=V.MulRV(a,this.m_lalcB,this.m_rB),g=this.m_K;if(g.ex.x=c+u+m.y*m.y*_+y.y*y.y*f,g.ey.x=-m.y*m.x*_-y.y*y.x*f,g.ez.x=-m.y*_-y.y*f,g.ex.y=g.ey.x,g.ey.y=c+u+m.x*m.x*_+y.x*y.x*f,g.ez.y=m.x*_+y.x*f,g.ex.z=g.ez.x,g.ey.z=g.ez.y,g.ez.z=_+f,this.m_frequencyHz>0){d=(A=I.SubVV(I.AddVV(r,y,I.s_t0),I.AddVV(e,m,I.s_t1),i.SolvePositionConstraints_s_C1)).Length(),p=0;var x=g.Solve22(A.x,A.y,i.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(c,x),n-=_*I.CrossVV(m,x),r.SelfMulAdd(u,x),s+=f*I.CrossVV(y,x)}else{var A=I.SubVV(I.AddVV(r,y,I.s_t0),I.AddVV(e,m,I.s_t1),i.SolvePositionConstraints_s_C1),b=s-n-this.m_referenceAngle;d=A.Length(),p=v(b);var C=g.Solve33(A.x,A.y,b,i.SolvePositionConstraints_s_impulse).SelfNeg();x=i.SolvePositionConstraints_s_P.Set(C.x,C.y);e.SelfMulSub(c,x),n-=_*(I.CrossVV(this.m_rA,x)+C.z),r.SelfMulAdd(u,x),s+=f*(I.CrossVV(this.m_rB,x)+C.z)}return t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,d<=h&&p<=l},i.prototype.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},i.prototype.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},i.prototype.GetReactionForce=function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e},i.prototype.GetReactionTorque=function(t){return t*this.m_impulse.z},i.prototype.GetLocalAnchorA=function(){return this.m_localAnchorA},i.prototype.GetLocalAnchorB=function(){return this.m_localAnchorB},i.prototype.GetReferenceAngle=function(){return this.m_referenceAngle},i.prototype.SetFrequency=function(t){this.m_frequencyHz=t},i.prototype.GetFrequency=function(){return this.m_frequencyHz},i.prototype.SetDampingRatio=function(t){this.m_dampingRatio=t},i.prototype.GetDampingRatio=function(){return this.m_dampingRatio},i.prototype.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WeldJointDef = new b2WeldJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i.InitVelocityConstraints_s_P=new I,i.SolveVelocityConstraints_s_Cdot1=new I,i.SolveVelocityConstraints_s_impulse1=new I,i.SolveVelocityConstraints_s_impulse=new L,i.SolveVelocityConstraints_s_P=new I,i.SolvePositionConstraints_s_C1=new I,i.SolvePositionConstraints_s_P=new I,i.SolvePositionConstraints_s_impulse=new L,i})(_i),Oi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_wheelJoint)||this;return i.localAnchorA=new I(0,0),i.localAnchorB=new I(0,0),i.localAxisA=new I(1,0),i.enableMotor=!1,i.maxMotorTorque=0,i.motorSpeed=0,i.frequencyHz=2,i.dampingRatio=.7,i}return Qe(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(n,this.localAxisA)},i})(ui),Fi=(function(t){function i(i){var n=t.call(this,i)||this;return n.m_frequencyHz=0,n.m_dampingRatio=0,n.m_localAnchorA=new I,n.m_localAnchorB=new I,n.m_localXAxisA=new I,n.m_localYAxisA=new I,n.m_impulse=0,n.m_motorImpulse=0,n.m_springImpulse=0,n.m_maxMotorTorque=0,n.m_motorSpeed=0,n.m_enableMotor=!1,n.m_indexA=0,n.m_indexB=0,n.m_localCenterA=new I,n.m_localCenterB=new I,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_ax=new I,n.m_ay=new I,n.m_sAx=0,n.m_sBx=0,n.m_sAy=0,n.m_sBy=0,n.m_mass=0,n.m_motorMass=0,n.m_springMass=0,n.m_bias=0,n.m_gamma=0,n.m_qA=new V,n.m_qB=new V,n.m_lalcA=new I,n.m_lalcB=new I,n.m_rA=new I,n.m_rB=new I,n.m_frequencyHz=e(i.frequencyHz,2),n.m_dampingRatio=e(i.dampingRatio,.7),n.m_localAnchorA.Copy(e(i.localAnchorA,I.ZERO)),n.m_localAnchorB.Copy(e(i.localAnchorB,I.ZERO)),n.m_localXAxisA.Copy(e(i.localAxisA,I.UNITX)),I.CrossOneV(n.m_localXAxisA,n.m_localYAxisA),n.m_maxMotorTorque=e(i.maxMotorTorque,0),n.m_motorSpeed=e(i.motorSpeed,0),n.m_enableMotor=e(i.enableMotor,!1),n.m_ax.SetZero(),n.m_ay.SetZero(),n}return Qe(i,t),i.prototype.GetMotorSpeed=function(){return this.m_motorSpeed},i.prototype.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},i.prototype.SetSpringFrequencyHz=function(t){this.m_frequencyHz=t},i.prototype.GetSpringFrequencyHz=function(){return this.m_frequencyHz},i.prototype.SetSpringDampingRatio=function(t){this.m_dampingRatio=t},i.prototype.GetSpringDampingRatio=function(){return this.m_dampingRatio},i.prototype.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=this.m_invMassA,n=this.m_invMassB,r=this.m_invIA,o=this.m_invIB,a=t.positions[this.m_indexA].c,h=t.positions[this.m_indexA].a,l=t.velocities[this.m_indexA].v,c=t.velocities[this.m_indexA].w,u=t.positions[this.m_indexB].c,_=t.positions[this.m_indexB].a,f=t.velocities[this.m_indexB].v,m=t.velocities[this.m_indexB].w,d=this.m_qA.SetAngle(h),p=this.m_qB.SetAngle(_);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var y=V.MulRV(d,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var v=V.MulRV(p,this.m_lalcB,this.m_rB),g=I.SubVV(I.AddVV(u,v,I.s_t0),I.AddVV(a,y,I.s_t1),i.InitVelocityConstraints_s_d);if(V.MulRV(d,this.m_localYAxisA,this.m_ay),this.m_sAy=I.CrossVV(I.AddVV(g,y,I.s_t0),this.m_ay),this.m_sBy=I.CrossVV(v,this.m_ay),this.m_mass=e+n+r*this.m_sAy*this.m_sAy+o*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){V.MulRV(d,this.m_localXAxisA,this.m_ax),this.m_sAx=I.CrossVV(I.AddVV(g,y,I.s_t0),this.m_ax),this.m_sBx=I.CrossVV(v,this.m_ax);var x=e+n+r*this.m_sAx*this.m_sAx+o*this.m_sBx*this.m_sBx;if(x>0){this.m_springMass=1/x;var A=I.DotVV(g,this.m_ax),b=2*s*this.m_frequencyHz,C=2*this.m_springMass*this.m_dampingRatio*b,S=this.m_springMass*b*b,T=t.step.dt;this.m_gamma=T*(C+T*S),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=A*T*S*this.m_gamma,this.m_springMass=x+this.m_gamma,this.m_springMass>0&&(this.m_springMass=1/this.m_springMass)}}else this.m_springImpulse=0;if(this.m_enableMotor?(this.m_motorMass=r+o,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass)):(this.m_motorMass=0,this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse*=t.step.dtRatio,this.m_springImpulse*=t.step.dtRatio,this.m_motorImpulse*=t.step.dtRatio;var w=I.AddVV(I.MulSV(this.m_impulse,this.m_ay,I.s_t0),I.MulSV(this.m_springImpulse,this.m_ax,I.s_t1),i.InitVelocityConstraints_s_P),E=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,D=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;l.SelfMulSub(this.m_invMassA,w),c-=this.m_invIA*E,f.SelfMulAdd(this.m_invMassB,w),m+=this.m_invIB*D}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;t.velocities[this.m_indexA].w=c,t.velocities[this.m_indexB].w=m},i.prototype.SolveVelocityConstraints=function(t){var e=this.m_invMassA,n=this.m_invMassB,r=this.m_invIA,s=this.m_invIB,o=t.velocities[this.m_indexA].v,a=t.velocities[this.m_indexA].w,h=t.velocities[this.m_indexB].v,l=t.velocities[this.m_indexB].w,c=I.DotVV(this.m_ax,I.SubVV(h,o,I.s_t0))+this.m_sBx*l-this.m_sAx*a,u=-this.m_springMass*(c+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=u;var _=I.MulSV(u,this.m_ax,i.SolveVelocityConstraints_s_P),f=u*this.m_sAx,m=u*this.m_sBx;o.SelfMulSub(e,_),a-=r*f,h.SelfMulAdd(n,_);c=(l+=s*m)-a-this.m_motorSpeed,u=-this.m_motorMass*c;var d=this.m_motorImpulse,p=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=A(this.m_motorImpulse+u,-p,p),a-=r*(u=this.m_motorImpulse-d),l+=s*u;c=I.DotVV(this.m_ay,I.SubVV(h,o,I.s_t0))+this.m_sBy*l-this.m_sAy*a,u=-this.m_mass*c;this.m_impulse+=u;_=I.MulSV(u,this.m_ay,i.SolveVelocityConstraints_s_P),f=u*this.m_sAy,m=u*this.m_sBy;o.SelfMulSub(e,_),a-=r*f,h.SelfMulAdd(n,_),l+=s*m,t.velocities[this.m_indexA].w=a,t.velocities[this.m_indexB].w=l},i.prototype.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s);I.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=V.MulRV(o,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var c,u=V.MulRV(a,this.m_lalcB,this.m_rB),_=I.AddVV(I.SubVV(r,e,I.s_t0),I.SubVV(u,l,I.s_t1),i.SolvePositionConstraints_s_d),f=V.MulRV(o,this.m_localYAxisA,this.m_ay),m=I.CrossVV(I.AddVV(_,l,I.s_t0),f),d=I.CrossVV(u,f),p=I.DotVV(_,this.m_ay),y=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;c=0!==y?-p/y:0;var g=I.MulSV(c,f,i.SolvePositionConstraints_s_P),x=c*m,A=c*d;return e.SelfMulSub(this.m_invMassA,g),n-=this.m_invIA*x,r.SelfMulAdd(this.m_invMassB,g),s+=this.m_invIB*A,t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,v(p)<=h},i.prototype.GetDefinition=function(t){return t},i.prototype.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},i.prototype.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},i.prototype.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse*this.m_ay.x+this.m_springImpulse*this.m_ax.x),e.y=t*(this.m_impulse*this.m_ay.y+this.m_springImpulse*this.m_ax.y),e},i.prototype.GetReactionTorque=function(t){return t*this.m_motorImpulse},i.prototype.GetLocalAnchorA=function(){return this.m_localAnchorA},i.prototype.GetLocalAnchorB=function(){return this.m_localAnchorB},i.prototype.GetLocalAxisA=function(){return this.m_localXAxisA},i.prototype.GetJointTranslation=function(){return this.GetPrismaticJointTranslation()},i.prototype.GetJointLinearSpeed=function(){return this.GetPrismaticJointSpeed()},i.prototype.GetJointAngle=function(){return this.GetRevoluteJointAngle()},i.prototype.GetJointAngularSpeed=function(){return this.GetRevoluteJointSpeed()},i.prototype.GetPrismaticJointTranslation=function(){var t=this.m_bodyA,e=this.m_bodyB,i=t.GetWorldPoint(this.m_localAnchorA,new I),n=e.GetWorldPoint(this.m_localAnchorB,new I),r=I.SubVV(n,i,new I),s=t.GetWorldVector(this.m_localXAxisA,new I);return I.DotVV(r,s)},i.prototype.GetPrismaticJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;I.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=V.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);I.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=V.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=I.AddVV(t.m_sweep.c,i,I.s_t0),s=I.AddVV(e.m_sweep.c,n,I.s_t1),o=I.SubVV(s,r,I.s_t2),a=t.GetWorldVector(this.m_localXAxisA,new I),h=t.m_linearVelocity,l=e.m_linearVelocity,c=t.m_angularVelocity,u=e.m_angularVelocity;return I.DotVV(o,I.CrossSV(c,a,I.s_t0))+I.DotVV(a,I.SubVV(I.AddVCrossSV(l,u,n,I.s_t0),I.AddVCrossSV(h,c,i,I.s_t1),I.s_t0))},i.prototype.GetRevoluteJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a},i.prototype.GetRevoluteJointSpeed=function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t},i.prototype.IsMotorEnabled=function(){return this.m_enableMotor},i.prototype.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},i.prototype.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},i.prototype.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},i.prototype.GetMotorTorque=function(t){return t*this.m_motorImpulse},i.prototype.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WheelJointDef = new b2WheelJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i.InitVelocityConstraints_s_d=new I,i.InitVelocityConstraints_s_P=new I,i.SolveVelocityConstraints_s_P=new I,i.SolvePositionConstraints_s_d=new I,i.SolvePositionConstraints_s_P=new I,i})(_i);function Vi(t,e){return T(t*e)}function Ni(t,e){return t>e?t:e}var ki=(function(){return function(t){this.prev=null,this.next=null,this.contact=t}})(),Gi=(function(){function t(){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!1,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_prev=null,this.m_next=null,this.m_indexA=0,this.m_indexB=0,this.m_manifold=new At,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new At,this.m_nodeA=new ki(this),this.m_nodeB=new ki(this)}return t.prototype.GetManifold=function(){return this.m_manifold},t.prototype.GetWorldManifold=function(t){var e=this.m_fixtureA.GetBody(),i=this.m_fixtureB.GetBody(),n=this.m_fixtureA.GetShape(),r=this.m_fixtureB.GetShape();t.Initialize(this.m_manifold,e.GetTransform(),n.m_radius,i.GetTransform(),r.m_radius)},t.prototype.IsTouching=function(){return this.m_touchingFlag},t.prototype.SetEnabled=function(t){this.m_enabledFlag=t},t.prototype.IsEnabled=function(){return this.m_enabledFlag},t.prototype.GetNext=function(){return this.m_next},t.prototype.GetFixtureA=function(){return this.m_fixtureA},t.prototype.GetChildIndexA=function(){return this.m_indexA},t.prototype.GetFixtureB=function(){return this.m_fixtureB},t.prototype.GetChildIndexB=function(){return this.m_indexB},t.prototype.FlagForFiltering=function(){this.m_filterFlag=!0},t.prototype.SetFriction=function(t){this.m_friction=t},t.prototype.GetFriction=function(){return this.m_friction},t.prototype.ResetFriction=function(){this.m_friction=Vi(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction)},t.prototype.SetRestitution=function(t){this.m_restitution=t},t.prototype.GetRestitution=function(){return this.m_restitution},t.prototype.ResetRestitution=function(){this.m_restitution=Ni(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},t.prototype.SetTangentSpeed=function(t){this.m_tangentSpeed=t},t.prototype.GetTangentSpeed=function(){return this.m_tangentSpeed},t.prototype.Reset=function(t,e,i,n){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!0,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_fixtureA=t,this.m_fixtureB=i,this.m_indexA=e,this.m_indexB=n,this.m_manifold.pointCount=0,this.m_prev=null,this.m_next=null,delete this.m_nodeA.contact,this.m_nodeA.prev=null,this.m_nodeA.next=null,delete this.m_nodeA.other,delete this.m_nodeB.contact,this.m_nodeB.prev=null,this.m_nodeB.next=null,delete this.m_nodeB.other,this.m_toiCount=0,this.m_friction=Vi(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=Ni(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},t.prototype.Update=function(t){var e=this.m_oldManifold;this.m_oldManifold=this.m_manifold,this.m_manifold=e,this.m_enabledFlag=!0;var i=!1,n=this.m_touchingFlag,r=this.m_fixtureA.IsSensor(),s=this.m_fixtureB.IsSensor(),o=r||s,a=this.m_fixtureA.GetBody(),h=this.m_fixtureB.GetBody(),l=a.GetTransform(),c=h.GetTransform();if(o){var u=this.m_fixtureA.GetShape(),_=this.m_fixtureB.GetShape();i=It(u,this.m_indexA,_,this.m_indexB,l,c),this.m_manifold.pointCount=0}else{this.Evaluate(this.m_manifold,l,c),i=this.m_manifold.pointCount>0;for(var f=0;f0&&!e.IsSensor()&&!i.IsSensor()&&(e.GetBody().SetAwake(!0),i.GetBody().SetAwake(!0));var n=e.GetType(),r=i.GetType(),s=this.m_registers[n][r];s.destroyFcn&&s.destroyFcn(t,this.m_allocator)},e})(),Zi=(function(){function t(){}return t.prototype.SayGoodbyeJoint=function(t){},t.prototype.SayGoodbyeFixture=function(t){},t.prototype.SayGoodbyeParticleGroup=function(t){},t.prototype.SayGoodbyeParticle=function(t,e){},t})(),Ki=(function(){function e(){}return e.prototype.ShouldCollide=function(e,i){var n=e.GetBody(),r=i.GetBody();if(r.GetType()===t.b2BodyType.b2_staticBody&&n.GetType()===t.b2BodyType.b2_staticBody)return!1;if(!r.ShouldCollideConnected(n))return!1;var s=e.GetFilterData(),o=i.GetFilterData();return s.groupIndex===o.groupIndex&&0!==s.groupIndex?s.groupIndex>0:0!=(s.maskBits&o.categoryBits)&&0!=(s.categoryBits&o.maskBits)},e.prototype.ShouldCollideFixtureParticle=function(t,e,i){return!0},e.prototype.ShouldCollideParticleParticle=function(t,e,i){return!0},e.b2_defaultFilter=new e,e})(),Qi=(function(){return function(){this.normalImpulses=d(o),this.tangentImpulses=d(o),this.count=0}})(),$i=(function(){function t(){}return t.prototype.BeginContact=function(t){},t.prototype.EndContact=function(t){},t.prototype.BeginContactFixtureParticle=function(t,e){},t.prototype.EndContactFixtureParticle=function(t,e){},t.prototype.BeginContactParticleParticle=function(t,e){},t.prototype.EndContactParticleParticle=function(t,e){},t.prototype.PreSolve=function(t,e){},t.prototype.PostSolve=function(t,e){},t.b2_defaultListener=new t,t})(),tn=(function(){function t(){}return t.prototype.ReportFixture=function(t){return!0},t.prototype.ReportParticle=function(t,e){return!1},t.prototype.ShouldQueryParticleSystem=function(t){return!0},t})(),en=(function(){function t(){}return t.prototype.ReportFixture=function(t,e,i,n){return n},t.prototype.ReportParticle=function(t,e,i,n,r){return 0},t.prototype.ShouldQueryParticleSystem=function(t){return!0},t})(),nn=(function(){function e(){this.m_broadPhase=new Vt,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=Ki.b2_defaultFilter,this.m_contactListener=$i.b2_defaultListener,this.m_allocator=null,this.m_contactFactory=new Ji(this.m_allocator)}return e.prototype.AddPair=function(t,e){var i=t.fixture,n=e.fixture,r=t.childIndex,s=e.childIndex,o=i.GetBody(),a=n.GetBody();if(o!==a){for(var h=a.GetContactList();h;){if(h.other===o){var l=h.contact.GetFixtureA(),c=h.contact.GetFixtureB(),u=h.contact.GetChildIndexA(),_=h.contact.GetChildIndexB();if(l===i&&c===n&&u===r&&_===s)return;if(l===n&&c===i&&u===s&&_===r)return}h=h.next}if(!this.m_contactFilter||this.m_contactFilter.ShouldCollide(i,n)){var f=this.m_contactFactory.Create(i,r,n,s);null!==f&&(i=f.GetFixtureA(),n=f.GetFixtureB(),r=f.GetChildIndexA(),s=f.GetChildIndexB(),o=i.m_body,a=n.m_body,f.m_prev=null,f.m_next=this.m_contactList,null!==this.m_contactList&&(this.m_contactList.m_prev=f),this.m_contactList=f,f.m_nodeA.contact=f,f.m_nodeA.other=a,f.m_nodeA.prev=null,f.m_nodeA.next=o.m_contactList,null!==o.m_contactList&&(o.m_contactList.prev=f.m_nodeA),o.m_contactList=f.m_nodeA,f.m_nodeB.contact=f,f.m_nodeB.other=o,f.m_nodeB.prev=null,f.m_nodeB.next=a.m_contactList,null!==a.m_contactList&&(a.m_contactList.prev=f.m_nodeB),a.m_contactList=f.m_nodeB,i.IsSensor()||n.IsSensor()||(o.SetAwake(!0),a.SetAwake(!0)),++this.m_contactCount)}}},e.prototype.FindNewContacts=function(){var t=this;this.m_broadPhase.UpdatePairs((function(e,i){t.AddPair(e,i)}))},e.prototype.Destroy=function(t){var e=t.GetFixtureA(),i=t.GetFixtureB(),n=e.GetBody(),r=i.GetBody();this.m_contactListener&&t.IsTouching()&&this.m_contactListener.EndContact(t),t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_contactList&&(this.m_contactList=t.m_next),t.m_nodeA.prev&&(t.m_nodeA.prev.next=t.m_nodeA.next),t.m_nodeA.next&&(t.m_nodeA.next.prev=t.m_nodeA.prev),t.m_nodeA===n.m_contactList&&(n.m_contactList=t.m_nodeA.next),t.m_nodeB.prev&&(t.m_nodeB.prev.next=t.m_nodeB.next),t.m_nodeB.next&&(t.m_nodeB.next.prev=t.m_nodeB.prev),t.m_nodeB===r.m_contactList&&(r.m_contactList=t.m_nodeB.next),this.m_contactFactory.Destroy(t),--this.m_contactCount},e.prototype.Collide=function(){for(var e=this.m_contactList;e;){var i=e.GetFixtureA(),n=e.GetFixtureB(),r=e.GetChildIndexA(),s=e.GetChildIndexB(),o=i.GetBody(),a=n.GetBody();if(e.m_filterFlag){if(this.m_contactFilter&&!this.m_contactFilter.ShouldCollide(i,n)){e=(c=e).m_next,this.Destroy(c);continue}e.m_filterFlag=!1}var h=o.IsAwake()&&o.m_type!==t.b2BodyType.b2_staticBody,l=a.IsAwake()&&a.m_type!==t.b2BodyType.b2_staticBody;if(h||l){var c,u=i.m_proxies[r].treeNode,_=n.m_proxies[s].treeNode;if(Et(u.aabb,_.aabb))e.Update(this.m_contactListener),e=e.m_next;else e=(c=e).m_next,this.Destroy(c)}else e=e.m_next}},e})(),rn=(function(){function t(){this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0}return t.prototype.Reset=function(){return this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0,this},t})(),sn=(function(){function t(){this.dt=0,this.inv_dt=0,this.dtRatio=0,this.velocityIterations=0,this.positionIterations=0,this.particleIterations=0,this.warmStarting=!1}return t.prototype.Copy=function(t){return this.dt=t.dt,this.inv_dt=t.inv_dt,this.dtRatio=t.dtRatio,this.positionIterations=t.positionIterations,this.velocityIterations=t.velocityIterations,this.particleIterations=t.particleIterations,this.warmStarting=t.warmStarting,this},t})(),on=(function(){function t(){this.c=new I,this.a=0}return t.MakeArray=function(e){return m(e,(function(e){return new t}))},t})(),an=(function(){function t(){this.v=new I,this.w=0}return t.MakeArray=function(e){return m(e,(function(e){return new t}))},t})(),hn=(function(){return function(){this.step=new sn}})(),ln=(function(){function t(){this.rA=new I,this.rB=new I,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}return t.MakeArray=function(e){return m(e,(function(e){return new t}))},t})(),cn=(function(){function t(){this.points=ln.MakeArray(o),this.normal=new I,this.tangent=new I,this.normalMass=new O,this.K=new O,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.invIA=0,this.invIB=0,this.friction=0,this.restitution=0,this.tangentSpeed=0,this.pointCount=0,this.contactIndex=0}return t.MakeArray=function(e){return m(e,(function(e){return new t}))},t})(),un=(function(){function e(){this.localPoints=I.MakeArray(o),this.localNormal=new I,this.localPoint=new I,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new I,this.localCenterB=new I,this.invIA=0,this.invIB=0,this.type=t.b2ManifoldType.e_unknown,this.radiusA=0,this.radiusB=0,this.pointCount=0}return e.MakeArray=function(t){return m(t,(function(t){return new e}))},e})(),_n=(function(){return function(){this.step=new sn,this.count=0,this.allocator=null}})(),fn=(function(){function e(){this.normal=new I,this.point=new I,this.separation=0}return e.prototype.Initialize=function(i,n,r,s){var o=e.Initialize_s_pointA,a=e.Initialize_s_pointB,h=e.Initialize_s_planePoint,l=e.Initialize_s_clipPoint;switch(i.type){case t.b2ManifoldType.e_circles:N.MulXV(n,i.localPoint,o),N.MulXV(r,i.localPoints[0],a),I.SubVV(a,o,this.normal).SelfNormalize(),I.MidVV(o,a,this.point),this.separation=I.DotVV(I.SubVV(a,o,I.s_t0),this.normal)-i.radiusA-i.radiusB;break;case t.b2ManifoldType.e_faceA:V.MulRV(n.q,i.localNormal,this.normal),N.MulXV(n,i.localPoint,h),N.MulXV(r,i.localPoints[s],l),this.separation=I.DotVV(I.SubVV(l,h,I.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(l);break;case t.b2ManifoldType.e_faceB:V.MulRV(r.q,i.localNormal,this.normal),N.MulXV(r,i.localPoint,h),N.MulXV(n,i.localPoints[s],l),this.separation=I.DotVV(I.SubVV(l,h,I.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(l),this.normal.SelfNeg()}},e.Initialize_s_pointA=new I,e.Initialize_s_pointB=new I,e.Initialize_s_planePoint=new I,e.Initialize_s_clipPoint=new I,e})(),mn=(function(){function t(){this.m_step=new sn,this.m_allocator=null,this.m_positionConstraints=un.MakeArray(1024),this.m_velocityConstraints=cn.MakeArray(1024),this.m_count=0}return t.prototype.Initialize=function(t){if(this.m_step.Copy(t.step),this.m_allocator=t.allocator,this.m_count=t.count,this.m_positionConstraints.length0?1/P:0;var R=s.tangent,L=I.CrossVV(D.rA,R),O=I.CrossVV(D.rB,R),F=_+f+m*L*L+d*O*O;D.tangentMass=F>0?1/F:0,D.velocityBias=0;var N=I.DotVV(s.normal,I.SubVV(I.AddVCrossSV(S,T,D.rB,I.s_t0),I.AddVCrossSV(x,A,D.rA,I.s_t1),I.s_t0));N<-1&&(D.velocityBias+=-s.restitution*N)}s.pointCount}},t.prototype.WarmStart=function(){for(var e=t.WarmStart_s_P,i=0;i0?-M/L:0;I.MulSV(O,E,o),b.SelfMulSub(m,o),C-=d*I.CrossVV(r,o),S.SelfMulAdd(y,o),T+=v*I.CrossVV(s,o)}this.m_positions[u].a=C,this.m_positions[_].a=T}return a>-3*h},t.prototype.SolveTOIPositionConstraints=function(e,i){for(var n=t.SolveTOIPositionConstraints_s_xfA,r=t.SolveTOIPositionConstraints_s_xfB,s=t.SolveTOIPositionConstraints_s_psm,o=t.SolveTOIPositionConstraints_s_rA,a=t.SolveTOIPositionConstraints_s_rB,l=t.SolveTOIPositionConstraints_s_P,c=0,u=0;u0?-R/F:0;I.MulSV(N,B,l),S.SelfMulSub(v,l),T-=x*I.CrossVV(o,l),w.SelfMulAdd(b,l),E+=C*I.CrossVV(a,l)}this.m_positions[f].a=T,this.m_positions[m].a=E}return c>=-1.5*h},t.InitializeVelocityConstraints_s_xfA=new N,t.InitializeVelocityConstraints_s_xfB=new N,t.InitializeVelocityConstraints_s_worldManifold=new bt,t.WarmStart_s_P=new I,t.SolveVelocityConstraints_s_dv=new I,t.SolveVelocityConstraints_s_dv1=new I,t.SolveVelocityConstraints_s_dv2=new I,t.SolveVelocityConstraints_s_P=new I,t.SolveVelocityConstraints_s_a=new I,t.SolveVelocityConstraints_s_b=new I,t.SolveVelocityConstraints_s_x=new I,t.SolveVelocityConstraints_s_d=new I,t.SolveVelocityConstraints_s_P1=new I,t.SolveVelocityConstraints_s_P2=new I,t.SolveVelocityConstraints_s_P1P2=new I,t.SolvePositionConstraints_s_xfA=new N,t.SolvePositionConstraints_s_xfB=new N,t.SolvePositionConstraints_s_psm=new fn,t.SolvePositionConstraints_s_rA=new I,t.SolvePositionConstraints_s_rB=new I,t.SolvePositionConstraints_s_P=new I,t.SolveTOIPositionConstraints_s_xfA=new N,t.SolveTOIPositionConstraints_s_xfB=new N,t.SolveTOIPositionConstraints_s_psm=new fn,t.SolveTOIPositionConstraints_s_rA=new I,t.SolveTOIPositionConstraints_s_rB=new I,t.SolveTOIPositionConstraints_s_P=new I,t})(),dn=(function(){function e(){this.m_allocator=null,this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=on.MakeArray(1024),this.m_velocities=an.MakeArray(1024),this.m_bodyCount=0,this.m_jointCount=0,this.m_contactCount=0,this.m_bodyCapacity=0,this.m_contactCapacity=0,this.m_jointCapacity=0}return e.prototype.Initialize=function(t,e,i,n,r){if(this.m_bodyCapacity=t,this.m_contactCapacity=e,this.m_jointCapacity=i,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_allocator=n,this.m_listener=r,this.m_positions.length4){var b=2/A.Length();_.SelfMul(b)}var C=h*f;if(C*C>2.4674011002726646)f*=b=1.570796326795/v(C);x.x+=h*_.x,x.y+=h*_.y,u+=h*f,this.m_positions[l].a=u,this.m_velocities[l].w=f}a.Reset();var S=!1;for(l=0;l.0012184696791469947||I.DotVV(c.m_linearVelocity,c.m_linearVelocity)>1e-4?(c.m_sleepTime=0,B=0):(c.m_sleepTime+=h,B=g(B,c.m_sleepTime)))}if(B>=.5&&S)for(l=0;l4){var m=2/f.Length();u.SelfMul(m)}var d=h*_;if(d*d>2.4674011002726646)_*=m=1.570796326795/v(d);l.SelfMulAdd(h,u),c+=h*_,this.m_positions[r].a=c,this.m_velocities[r].w=_;var p=this.m_bodies[r];p.m_sweep.c.Copy(l),p.m_sweep.a=c,p.m_linearVelocity.Copy(u),p.m_angularVelocity=_,p.SynchronizeTransform()}this.Report(a.m_velocityConstraints)},e.prototype.Report=function(t){if(null!==this.m_listener)for(var i=0;i0){var r=1/this.m_mass;this.m_center.SelfMul(r),this.m_linearVelocity.SelfMul(r)}this.m_inertia=0,this.m_angularVelocity=0;for(n=this.m_firstIndex;n0&&(this.m_angularVelocity*=1/this.m_inertia),this.m_timestamp=this.m_system.m_timestamp}},e.GetLinearVelocityFromWorldPoint_s_t0=new I,e})(),An=(function(){function t(t){this.m_front=0,this.m_back=0,this.m_capacity=0,this.m_buffer=m(t,(function(t){return null})),this.m_capacity=t}return t.prototype.Push=function(t){if(this.m_back>=this.m_capacity){for(var e=this.m_front;e=this.m_capacity&&(this.m_capacity>0?(this.m_buffer.concat(m(this.m_capacity,(function(t){return null}))),this.m_capacity*=2):(this.m_buffer.concat(m(1,(function(t){return null}))),this.m_capacity=1))}this.m_buffer[this.m_back]=t,this.m_back++},t.prototype.Pop=function(){this.m_buffer[this.m_front]=null,this.m_front++},t.prototype.Empty=function(){return this.m_front===this.m_back},t.prototype.Front=function(){var t=this.m_buffer[this.m_front];if(!t)throw new Error;return t},t})(),bn=(function(){function t(e){this.m_generatorCapacity=0,this.m_generatorCount=0,this.m_countX=0,this.m_countY=0,this.m_diagram=[],this.m_generatorBuffer=m(e,(function(e){return new t.Generator})),this.m_generatorCapacity=e}return t.prototype.AddGenerator=function(t,e,i){var n=this.m_generatorBuffer[this.m_generatorCount++];n.center.Copy(t),n.tag=e,n.necessary=i},t.prototype.Generate=function(e,n){for(var r=1/e,s=new I(+i,+i),o=new I(-i,-i),a=0,h=0;h=0&&u>=0&&c0&&l.Push(new t.Task(c-1,u,_-1,f)),u>0&&l.Push(new t.Task(c,u-1,_-this.m_countX,f)),cg*g+x*x&&(this.m_diagram[_]=p,c>0&&l.Push(new t.Task(c-1,u,_-1,p)),u>0&&l.Push(new t.Task(c,u-1,_-this.m_countX,p)),c=i)break;Cn(t,h,i)}}if(0===o)break;r=i,i=s[--o]}return t}function wn(t,e,i,n){return void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===n&&(n=Sn),Tn(t,e,i,n)}function En(t,e,i){void 0===i&&(i=t.length);for(var n=0,r=0;r0;){var o=Math.floor(s/2),a=e+o;r(t[a],n)?(e=++a,s-=o+1):s=o}return e}function Bn(t,e,i,n,r){void 0===r&&(r=Sn);for(var s=i-e;s>0;){var o=Math.floor(s/2),a=e+o;r(n,t[a])?s=o:(e=++a,s-=o+1)}return e}function Mn(t,e,i,n){for(var r=i;e!==r;)Cn(t,e++,r++),r===n?r=i:e===i&&(i=r)}(function(t){var e=(function(){return function(){this.center=new I,this.tag=0,this.necessary=!1}})();t.Generator=e;var i=(function(){return function(t,e,i,n){this.m_x=t,this.m_y=e,this.m_i=i,this.m_generator=n}})();t.Task=i})(bn||(bn={}));var Pn=(function(){function t(t){this.data=[],this.count=0,this.capacity=0,this.allocator=t}return t.prototype.Append=function(){return this.count>=this.capacity&&this.Grow(),this.count++},t.prototype.Reserve=function(t){if(!(this.capacity>=t)){for(var e=this.capacity;e=0;)this.ReportFixtureAndParticle(t,i,s);return!0},e.prototype.ReportParticle=function(t,e){return!1},e.prototype.ReportFixtureAndParticle=function(t,e,i){},e})(tn),Rn=(function(){function t(){this.indexA=0,this.indexB=0,this.weight=0,this.normal=new I,this.flags=0}return t.prototype.SetIndices=function(t,e){this.indexA=t,this.indexB=e},t.prototype.SetWeight=function(t){this.weight=t},t.prototype.SetNormal=function(t){this.normal.Copy(t)},t.prototype.SetFlags=function(t){this.flags=t},t.prototype.GetIndexA=function(){return this.indexA},t.prototype.GetIndexB=function(){return this.indexB},t.prototype.GetWeight=function(){return this.weight},t.prototype.GetNormal=function(){return this.normal},t.prototype.GetFlags=function(){return this.flags},t.prototype.IsEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&this.weight===t.weight&&this.normal.x===t.normal.x&&this.normal.y===t.normal.y},t.prototype.IsNotEqual=function(t){return!this.IsEqual(t)},t.prototype.ApproximatelyEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&v(this.weight-t.weight)<.01&&I.DistanceSquaredVV(this.normal,t.normal)<1e-4},t})(),Ln=(function(){return function(){this.index=0,this.weight=0,this.normal=new I,this.mass=0}})(),On=(function(){return function(){this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0}})(),Fn=(function(){return function(){this.indexA=0,this.indexB=0,this.indexC=0,this.flags=0,this.strength=0,this.pa=new I(0,0),this.pb=new I(0,0),this.pc=new I(0,0),this.ka=0,this.kb=0,this.kc=0,this.s=0}})(),Vn=(function(){function t(){this.strictContactCheck=!1,this.density=1,this.gravityScale=1,this.radius=1,this.maxCount=0,this.pressureStrength=.005,this.dampingStrength=1,this.elasticStrength=.25,this.springStrength=.25,this.viscousStrength=.25,this.surfaceTensionPressureStrength=.2,this.surfaceTensionNormalStrength=.2,this.repulsiveStrength=1,this.powderStrength=.5,this.ejectionStrength=.5,this.staticPressureStrength=.2,this.staticPressureRelaxation=.2,this.staticPressureIterations=8,this.colorMixingStrength=.5,this.destroyByAge=!0,this.lifetimeGranularity=1/60}return t.prototype.Copy=function(t){return this.strictContactCheck=t.strictContactCheck,this.density=t.density,this.gravityScale=t.gravityScale,this.radius=t.radius,this.maxCount=t.maxCount,this.pressureStrength=t.pressureStrength,this.dampingStrength=t.dampingStrength,this.elasticStrength=t.elasticStrength,this.springStrength=t.springStrength,this.viscousStrength=t.viscousStrength,this.surfaceTensionPressureStrength=t.surfaceTensionPressureStrength,this.surfaceTensionNormalStrength=t.surfaceTensionNormalStrength,this.repulsiveStrength=t.repulsiveStrength,this.powderStrength=t.powderStrength,this.ejectionStrength=t.ejectionStrength,this.staticPressureStrength=t.staticPressureStrength,this.staticPressureRelaxation=t.staticPressureRelaxation,this.staticPressureIterations=t.staticPressureIterations,this.colorMixingStrength=t.colorMixingStrength,this.destroyByAge=t.destroyByAge,this.lifetimeGranularity=t.lifetimeGranularity,this},t.prototype.Clone=function(){return(new t).Copy(this)},t})();t.b2ParticleSystem=(function(){function n(t,e){this.m_paused=!1,this.m_timestamp=0,this.m_allParticleFlags=0,this.m_needsUpdateAllParticleFlags=!1,this.m_allGroupFlags=0,this.m_needsUpdateAllGroupFlags=!1,this.m_hasForce=!1,this.m_iterationIndex=0,this.m_inverseDensity=0,this.m_particleDiameter=0,this.m_inverseDiameter=0,this.m_squaredDiameter=0,this.m_count=0,this.m_internalAllocatedCapacity=0,this.m_handleIndexBuffer=new n.UserOverridableBuffer,this.m_flagsBuffer=new n.UserOverridableBuffer,this.m_positionBuffer=new n.UserOverridableBuffer,this.m_velocityBuffer=new n.UserOverridableBuffer,this.m_forceBuffer=[],this.m_weightBuffer=[],this.m_staticPressureBuffer=[],this.m_accumulationBuffer=[],this.m_accumulation2Buffer=[],this.m_depthBuffer=[],this.m_colorBuffer=new n.UserOverridableBuffer,this.m_groupBuffer=[],this.m_userDataBuffer=new n.UserOverridableBuffer,this.m_stuckThreshold=0,this.m_lastBodyContactStepBuffer=new n.UserOverridableBuffer,this.m_bodyContactCountBuffer=new n.UserOverridableBuffer,this.m_consecutiveContactStepsBuffer=new n.UserOverridableBuffer,this.m_stuckParticleBuffer=new Pn(function(){return 0}),this.m_proxyBuffer=new Pn(function(){return new n.Proxy}),this.m_contactBuffer=new Pn(function(){return new Rn}),this.m_bodyContactBuffer=new Pn(function(){return new Ln}),this.m_pairBuffer=new Pn(function(){return new On}),this.m_triadBuffer=new Pn(function(){return new Fn}),this.m_expirationTimeBuffer=new n.UserOverridableBuffer,this.m_indexByExpirationTimeBuffer=new n.UserOverridableBuffer,this.m_timeElapsed=0,this.m_expirationTimeBufferRequiresSorting=!1,this.m_groupCount=0,this.m_groupList=null,this.m_def=new Vn,this.m_prev=null,this.m_next=null,this.SetStrictContactCheck(t.strictContactCheck),this.SetDensity(t.density),this.SetGravityScale(t.gravityScale),this.SetRadius(t.radius),this.SetMaxParticleCount(t.maxCount),this.m_def=t.Clone(),this.m_world=e,this.SetDestructionByAge(this.m_def.destroyByAge)}return n.computeTag=function(t,e){return(e+n.yOffset>>>0<>>0)>>>0},n.computeRelativeTag=function(t,e,i){return t+(i<>>0},n.prototype.Drop=function(){for(;this.m_groupList;)this.DestroyParticleGroup(this.m_groupList);this.FreeUserOverridableBuffer(this.m_handleIndexBuffer),this.FreeUserOverridableBuffer(this.m_flagsBuffer),this.FreeUserOverridableBuffer(this.m_lastBodyContactStepBuffer),this.FreeUserOverridableBuffer(this.m_bodyContactCountBuffer),this.FreeUserOverridableBuffer(this.m_consecutiveContactStepsBuffer),this.FreeUserOverridableBuffer(this.m_positionBuffer),this.FreeUserOverridableBuffer(this.m_velocityBuffer),this.FreeUserOverridableBuffer(this.m_colorBuffer),this.FreeUserOverridableBuffer(this.m_userDataBuffer),this.FreeUserOverridableBuffer(this.m_expirationTimeBuffer),this.FreeUserOverridableBuffer(this.m_indexByExpirationTimeBuffer),this.FreeBuffer(this.m_forceBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_weightBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_staticPressureBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulationBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulation2Buffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_depthBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_groupBuffer,this.m_internalAllocatedCapacity)},n.prototype.CreateParticle=function(t){if(this.m_world.IsLocked())throw new Error;if(this.m_count>=this.m_internalAllocatedCapacity){var i=this.m_count?2*this.m_count:256;this.ReallocateInternalAllocatedBuffers(i)}if(this.m_count>=this.m_internalAllocatedCapacity){if(!this.m_def.destroyByAge)return u;this.DestroyOldestParticle(0,!1),this.SolveZombie()}var n=this.m_count++;if(!this.m_flagsBuffer.data)throw new Error;if(this.m_flagsBuffer.data[n]=0,this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[n]=0),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[n]=0),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[n]=0),!this.m_positionBuffer.data)throw new Error;if(!this.m_velocityBuffer.data)throw new Error;this.m_positionBuffer.data[n]=(this.m_positionBuffer.data[n]||new I).Copy(e(t.position,I.ZERO)),this.m_velocityBuffer.data[n]=(this.m_velocityBuffer.data[n]||new I).Copy(e(t.velocity,I.ZERO)),this.m_weightBuffer[n]=0,this.m_forceBuffer[n]=(this.m_forceBuffer[n]||new I).SetZero(),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[n]=0),this.m_depthBuffer&&(this.m_depthBuffer[n]=0);var r=(new G).Copy(e(t.color,G.ZERO));!this.m_colorBuffer.data&&r.IsZero()||(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data[n]=(this.m_colorBuffer.data[n]||new G).Copy(r)),(this.m_userDataBuffer.data||t.userData)&&(this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data[n]=t.userData),this.m_handleIndexBuffer.data&&(this.m_handleIndexBuffer.data[n]=null);var s=this.m_proxyBuffer.data[this.m_proxyBuffer.Append()],o=e(t.lifetime,0),a=o>0;if(this.m_expirationTimeBuffer.data||a){if(this.SetParticleLifetime(n,a?o:this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed())),!this.m_indexByExpirationTimeBuffer.data)throw new Error;this.m_indexByExpirationTimeBuffer.data[n]=n}s.index=n;var h=e(t.group,null);return this.m_groupBuffer[n]=h,h&&(h.m_firstIndex0?n:r,e)},n.prototype.DestroyParticlesInShape=function(t,e,i){void 0===i&&(i=!1);var r=n.DestroyParticlesInShape_s_aabb;if(this.m_world.IsLocked())throw new Error;var s=new n.DestroyParticlesInShapeCallback(this,t,e,i),o=r;return t.ComputeAABB(o,e,0),this.m_world.QueryAABB(s,o),s.Destroyed()},n.prototype.CreateParticleGroup=function(t){var i=n.CreateParticleGroup_s_transform;if(this.m_world.IsLocked())throw new Error;var r=i;r.SetPositionAngle(e(t.position,I.ZERO),e(t.angle,0));var s=this.m_count;if(t.shape&&this.CreateParticlesWithShapeForGroup(t.shape,t,r),t.shapes&&this.CreateParticlesWithShapesForGroup(t.shapes,e(t.shapeCount,t.shapes.length),t,r),t.positionData)for(var o=e(t.particleCount,t.positionData.length),a=0;a0&&(this.m_lastBodyContactStepBuffer.data=this.RequestBuffer(this.m_lastBodyContactStepBuffer.data),this.m_bodyContactCountBuffer.data=this.RequestBuffer(this.m_bodyContactCountBuffer.data),this.m_consecutiveContactStepsBuffer.data=this.RequestBuffer(this.m_consecutiveContactStepsBuffer.data))},n.prototype.GetStuckCandidates=function(){return this.m_stuckParticleBuffer.Data()},n.prototype.GetStuckCandidateCount=function(){return this.m_stuckParticleBuffer.GetCount()},n.prototype.ComputeCollisionEnergy=function(){if(!this.m_velocityBuffer.data)throw new Error;for(var t=n.ComputeCollisionEnergy_s_v,e=this.m_velocityBuffer.data,i=0,r=0;r0?this.GetQuantizedTimeElapsed()+s:s;o!==this.m_expirationTimeBuffer.data[t]&&(this.m_expirationTimeBuffer.data[t]=o,this.m_expirationTimeBufferRequiresSorting=!0)},n.prototype.GetParticleLifetime=function(t){return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[t])},n.prototype.SetDestructionByAge=function(t){t&&this.GetExpirationTimeBuffer(),this.m_def.destroyByAge=t},n.prototype.GetDestructionByAge=function(){return this.m_def.destroyByAge},n.prototype.GetExpirationTimeBuffer=function(){return this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data),this.m_expirationTimeBuffer.data},n.prototype.ExpirationTimeToLifetime=function(t){return(t>0?t-this.GetQuantizedTimeElapsed():t)*this.m_def.lifetimeGranularity},n.prototype.GetIndexByExpirationTimeBuffer=function(){if(this.GetParticleCount()?this.SetParticleLifetime(0,this.GetParticleLifetime(0)):this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data),!this.m_indexByExpirationTimeBuffer.data)throw new Error;return this.m_indexByExpirationTimeBuffer.data},n.prototype.ParticleApplyLinearImpulse=function(t,e){this.ApplyLinearImpulse(t,t+1,e)},n.prototype.ApplyLinearImpulse=function(t,e,i){if(!this.m_velocityBuffer.data)throw new Error;for(var n=this.m_velocityBuffer.data,r=(e-t)*this.GetParticleMass(),s=(new I).Copy(i).SelfMul(1/r),o=t;o=0;){var p=I.SubVV(e,l[u],s),y=I.DotVV(p,f),v=y*y-m*(I.DotVV(p,p)-this.m_squaredDiameter);if(v>=0){var x=T(v),A=(-y-x)/m;if(A>_)continue;if(A<0&&((A=(-y+x)/m)<0||A>_))continue;var b=I.AddVMulSV(p,A,f,a);b.Normalize();var C=t.ReportParticle(this,u,I.AddVMulSV(e,A,f,h),b,A);if((_=g(_,C))<=0)break}}}},n.prototype.ComputeAABB=function(t){var e=this.GetParticleCount();if(t.lowerBound.x=+i,t.lowerBound.y=+i,t.upperBound.x=-i,t.upperBound.y=-i,!this.m_positionBuffer.data)throw new Error;for(var n=this.m_positionBuffer.data,r=0;re?e:t}if(t=e(t=e(t=e(t=e(t=e(t=e(t,this.m_def.maxCount),this.m_flagsBuffer.userSuppliedCapacity),this.m_positionBuffer.userSuppliedCapacity),this.m_velocityBuffer.userSuppliedCapacity),this.m_colorBuffer.userSuppliedCapacity),this.m_userDataBuffer.userSuppliedCapacity),this.m_internalAllocatedCapacity0;this.m_lastBodyContactStepBuffer.data=this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer,this.m_internalAllocatedCapacity,t,i),this.m_bodyContactCountBuffer.data=this.ReallocateBuffer4(this.m_bodyContactCountBuffer,this.m_internalAllocatedCapacity,t,i),this.m_consecutiveContactStepsBuffer.data=this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer,this.m_internalAllocatedCapacity,t,i),this.m_positionBuffer.data=this.ReallocateBuffer4(this.m_positionBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_velocityBuffer.data=this.ReallocateBuffer4(this.m_velocityBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_forceBuffer=this.ReallocateBuffer5(this.m_forceBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_weightBuffer=this.ReallocateBuffer5(this.m_weightBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_staticPressureBuffer=this.ReallocateBuffer5(this.m_staticPressureBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_accumulationBuffer=this.ReallocateBuffer5(this.m_accumulationBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_accumulation2Buffer=this.ReallocateBuffer5(this.m_accumulation2Buffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_depthBuffer=this.ReallocateBuffer5(this.m_depthBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_colorBuffer.data=this.ReallocateBuffer4(this.m_colorBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_groupBuffer=this.ReallocateBuffer5(this.m_groupBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_userDataBuffer.data=this.ReallocateBuffer4(this.m_userDataBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_expirationTimeBuffer.data=this.ReallocateBuffer4(this.m_expirationTimeBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_indexByExpirationTimeBuffer.data=this.ReallocateBuffer4(this.m_indexByExpirationTimeBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_internalAllocatedCapacity=t}},n.prototype.CreateParticleForGroup=function(t,i,n){var r=new pn;r.flags=e(t.flags,0),N.MulXV(i,n,r.position),I.AddVV(e(t.linearVelocity,I.ZERO),I.CrossSV(e(t.angularVelocity,0),I.SubVV(r.position,e(t.position,I.ZERO),I.s_t0),I.s_t0),r.velocity),r.color.Copy(e(t.color,G.ZERO)),r.lifetime=e(t.lifetime,0),r.userData=t.userData,this.CreateParticle(r)},n.prototype.CreateParticlesStrokeShapeForGroup=function(i,r,s){var o=n.CreateParticlesStrokeShapeForGroup_s_edge,a=n.CreateParticlesStrokeShapeForGroup_s_d,h=n.CreateParticlesStrokeShapeForGroup_s_p,l=e(r.stride,0);0===l&&(l=this.GetParticleStride());for(var c=0,u=i.GetChildCount(),_=0;_=e&&f=e&&mv||I.DotVV(p,p)>v||I.DotVV(y,y)>v)return;var x=T.m_groupBuffer[t],A=T.m_groupBuffer[e],b=T.m_groupBuffer[i],C=T.m_triadBuffer.data[T.m_triadBuffer.Append()];C.indexA=t,C.indexB=e,C.indexC=i,C.flags=l|c|u,C.strength=g(g(x?x.m_strength:1,A?A.m_strength:1),b?b.m_strength:1);var S=(_.x+f.x+m.x)/3,w=(_.y+f.y+m.y)/3;C.pa.x=_.x-S,C.pa.y=_.y-w,C.pb.x=f.x-S,C.pb.y=f.y-w,C.pc.x=m.x-S,C.pc.y=m.y-w,C.ka=-I.DotVV(y,d),C.kb=-I.DotVV(d,p),C.kc=-I.DotVV(p,y),C.s=I.CrossVV(_,f)+I.CrossVV(f,m)+I.CrossVV(m,_)}})),wn(this.m_triadBuffer.data,0,this.m_triadBuffer.count,n.CompareTriadIndices),this.m_triadBuffer.Unique(n.MatchTriadIndices)}},n.prototype.UpdatePairsAndTriadsWithReactiveParticles=function(){var e=new n.ReactiveFilter(this.m_flagsBuffer);if(this.UpdatePairsAndTriads(0,this.m_count,e),!this.m_flagsBuffer.data)throw new Error;for(var i=0;i>0,p=0;pb&&(this.m_depthBuffer[s]=b,y=!0),A>C&&(this.m_depthBuffer[o]=C,y=!0)}if(!y)break}for(_=0;_0){if(!this.m_bodyContactCountBuffer.data)throw new Error;if(!this.m_lastBodyContactStepBuffer.data)throw new Error;if(!this.m_consecutiveContactStepsBuffer.data)throw new Error;for(var i=this.GetParticleCount(),r=0;rthis.m_lastBodyContactStepBuffer.data[r]+1&&(this.m_consecutiveContactStepsBuffer.data[r]=0)}this.m_bodyContactBuffer.SetCount(0),this.m_stuckParticleBuffer.SetCount(0);var s=t;this.ComputeAABB(s);var o=new n.UpdateBodyContactsCallback(this,this.GetFixtureContactFilter());this.m_world.QueryAABB(o,s),this.m_def.strictContactCheck&&this.RemoveSpuriousBodyContacts(),this.NotifyBodyContactListenerPostContact(e)},n.prototype.Solve=function(e){var i=n.Solve_s_subStep;if(0!==this.m_count&&(this.m_expirationTimeBuffer.data&&this.SolveLifetimes(e),this.m_allParticleFlags&t.b2ParticleFlag.b2_zombieParticle&&this.SolveZombie(),this.m_needsUpdateAllParticleFlags&&this.UpdateAllParticleFlags(),this.m_needsUpdateAllGroupFlags&&this.UpdateAllGroupFlags(),!this.m_paused))for(this.m_iterationIndex=0;this.m_iterationIndexi&&r.SelfMul(T(i/s))}},n.prototype.SolveGravity=function(t){if(!this.m_velocityBuffer.data)throw new Error;for(var e=n.SolveGravity_s_gravity,i=this.m_velocityBuffer.data,r=I.MulSV(t.dt*this.m_def.gravityScale,this.m_world.GetGravity(),e),s=0;s=0;){var V=d[F],N=this.m_groupBuffer[F];if(D!==N&&B!==N){var k=this.GetLinearVelocity(N,F,V,h),G=I.SubVV(V,S,l),z=I.SubVV(k,M,c),U=I.CrossVV(L,z),W=I.CrossVV(R,z)-I.CrossVV(G,L),j=I.CrossVV(R,G),H=void 0,X=void 0,Y=u,q=_;if(0===U){if(0===W)continue;if(!((X=-j/W)>=0&&X=0&&H<=1))continue}else{var J=W*W-4*j*U;if(J<0)continue;var Z=T(J),K=(-W-Z)/(2*U),Q=(-W+Z)/(2*U);if(K>Q){var $=K;K=Q,Q=$}if(X=K,I.AddVMulSV(R,X,L,Y),I.AddVMulSV(G,X,z,q),H=I.DotVV(Y,q)/I.DotVV(Y,Y),!(X>=0&&X=0&&H<=1)){if(!((X=Q)>=0&&X=0&&H<=1))continue}}var tt=f;tt.x=M.x+H*L.x-k.x,tt.y=M.y+H*L.y-k.y;var et=I.MulSV(g,tt,m);if(N&&this.IsRigidGroup(N)){var it=N.GetMass(),nt=N.GetInertia();it>0&&N.m_linearVelocity.SelfMulAdd(1/it,et),nt>0&&(N.m_angularVelocity+=I.CrossVV(I.SubVV(V,N.GetCenter(),I.s_t0),et)/nt)}else p[F].SelfAdd(tt);this.ParticleApplyForce(F,et.SelfMul(-e.inv_dt))}}}}},n.prototype.SolveStaticPressure=function(e){if(!this.m_flagsBuffer.data)throw new Error;this.m_staticPressureBuffer=this.RequestBuffer(this.m_staticPressureBuffer);for(var i=this.GetCriticalPressure(e),n=this.m_def.staticPressureStrength*i,r=.25*i,s=this.m_def.staticPressureRelaxation,o=0;o.25){var c=d.body,u=d.mass,_=r[l],f=d.normal,m=I.MulSV(o*u*(p-.25),f,i);s[l].SelfMulSub(a,m),c.ApplyLinearImpulse(m,_,!0)}}for(h=0;h.25){l=d.indexA,c=d.indexB,f=d.normal,m=I.MulSV(o*(p-.25),f,i);s[l].SelfSub(m),s[c].SelfAdd(m)}}},n.prototype.SolveSolid=function(t){var e=n.SolveSolid_s_f;if(!this.m_velocityBuffer.data)throw new Error;var i=this.m_velocityBuffer.data;this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer);for(var r=t.inv_dt*this.m_def.ejectionStrength,s=0;s=0?(T=g(T,D),w=x(w,D+1)):E=!0}Tr:s})),this.m_expirationTimeBufferRequiresSorting=!1}for(var s=r-1;s>=0;--s){var o=n[s],a=i[o];if(ee.weight:t.index3)return!0;var a=t.Copy(n.normal);if(a.SelfMul(r.m_particleDiameter*(1-n.weight)),!r.m_positionBuffer.data)throw new Error;var l=I.AddVV(r.m_positionBuffer.data[n.index],a,e);if(!n.fixture.TestPoint(l)){for(var c=n.fixture.GetShape().GetChildCount(),u=0;uthis.m_stuckThreshold&&(this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()]=t)),this.m_lastBodyContactStepBuffer.data[t]=this.m_timestamp}},n.prototype.ValidateParticleIndex=function(t){return t>=0&&t0?1/n:0,e[0]=r>0?1/r:0,i[0]=I.CrossVV(I.SubVV(o,s,I.s_t0),a)},n.prototype.InitDampingParameterWithRigidGroupOrParticle=function(e,i,n,r,s,o,a,h){if(s&&r)this.InitDampingParameter(e,i,n,s.GetMass(),s.GetInertia(),s.GetCenter(),a,h);else{if(!this.m_flagsBuffer.data)throw new Error;var l=this.m_flagsBuffer.data[o];this.InitDampingParameter(e,i,n,l&t.b2ParticleFlag.b2_wallParticle?0:this.GetParticleMass(),0,a,a,h)}},n.prototype.ComputeDampingImpulse=function(t,e,i,n,r,s,o){var a=t+e*i*i+n+r*s*s;return a>0?o/a:0},n.prototype.ApplyDamping=function(t,e,i,n,r,s,o,a){if(r&&n)r.m_linearVelocity.SelfMulAdd(o*t,a),r.m_angularVelocity+=o*i*e;else{if(!this.m_velocityBuffer.data)throw new Error;this.m_velocityBuffer.data[s].SelfMulAdd(o*t,a)}},n.xTruncBits=12,n.yTruncBits=12,n.tagBits=32,n.yOffset=1<>>0,this.m_xUpper=(n&e.xMask)>>>0,this.m_yLower=(i&e.yMask)>>>0,this.m_yUpper=(n&e.yMask)>>>0,this.m_first=r,this.m_last=s}return t.prototype.GetNext=function(){for(;this.m_first>>0;if(t>=this.m_xLower&&t<=this.m_xUpper)return this.m_system.m_proxyBuffer.data[this.m_first++].index;this.m_first++}return u},t})();e.InsideBoundsEnumerator=s;var o=(function(){return function(){this.next=null,this.count=0,this.index=0}})();e.ParticleListNode=o;var a=(function(){function t(){}return t.prototype.Allocate=function(t,e){return e},t.prototype.Clear=function(){},t.prototype.GetCount=function(){return 0},t.prototype.Invalidate=function(t){},t.prototype.GetValidBuffer=function(){return[]},t.prototype.GetBuffer=function(){return[]},t.prototype.SetCount=function(t){},t})();e.FixedSetAllocator=a;var l=(function(){return function(t,e){this.second=u,this.first=t,this.second=e}})();e.FixtureParticle=l;var c=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Qe(e,t),e.prototype.Initialize=function(t,e){},e.prototype.Find=function(t){return u},e})(e.FixedSetAllocator);e.FixtureParticleSet=c;var _=(function(){return function(t,e){this.first=u,this.second=u,this.first=t,this.second=e}})();e.ParticlePair=_;var f=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Qe(e,t),e.prototype.Initialize=function(t,e){},e.prototype.Find=function(t){return u},e})(e.FixedSetAllocator);e.b2ParticlePairSet=f;var m=(function(){function t(){}return t.prototype.IsNecessary=function(t){return!0},t.prototype.ShouldCreatePair=function(t,e){return!0},t.prototype.ShouldCreateTriad=function(t,e,i){return!0},t})();e.ConnectionFilter=m;var d=(function(t){function e(e,i,n,r){var s=t.call(this)||this;return s.m_callDestructionListener=!1,s.m_destroyed=0,s.m_system=e,s.m_shape=i,s.m_xf=n,s.m_callDestructionListener=r,s.m_destroyed=0,s}return Qe(e,t),e.prototype.ReportFixture=function(t){return!1},e.prototype.ReportParticle=function(t,e){if(t!==this.m_system)return!1;if(!this.m_system.m_positionBuffer.data)throw new Error;return this.m_shape.TestPoint(this.m_xf,this.m_system.m_positionBuffer.data[e])&&(this.m_system.DestroyParticle(e,this.m_callDestructionListener),this.m_destroyed++),!0},e.prototype.Destroyed=function(){return this.m_destroyed},e})(tn);e.DestroyParticlesInShapeCallback=d;var p=(function(t){function e(e){var i=t.call(this)||this;return i.m_threshold=0,i.m_threshold=e,i}return Qe(e,t),e.prototype.ShouldCreatePair=function(t,e){return t0?1/_:0,d=f>0?1/f:0,p=this.m_system.m_flagsBuffer.data[r]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),y=I.SubVV(a,u,o),v=I.CrossVV(y,h),g=p+m+d*v*v,x=this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];x.index=r,x.body=c,x.fixture=i,x.weight=1-l*this.m_system.m_inverseDiameter,x.normal.Copy(h.SelfNeg()),x.mass=g>0?1/g:0,this.m_system.DetectStuckParticle(r)}},n.ReportFixtureAndParticle_s_n=new I,n.ReportFixtureAndParticle_s_rp=new I,n})(In);e.UpdateBodyContactsCallback=g;var x=(function(i){function n(t,e){var n=i.call(this,t)||this;return n.m_step=e,n}return Qe(n,i),n.prototype.ReportFixtureAndParticle=function(i,n,r){var s=e.SolveCollisionCallback.ReportFixtureAndParticle_s_p1,o=e.SolveCollisionCallback.ReportFixtureAndParticle_s_output,a=e.SolveCollisionCallback.ReportFixtureAndParticle_s_input,l=e.SolveCollisionCallback.ReportFixtureAndParticle_s_p,c=e.SolveCollisionCallback.ReportFixtureAndParticle_s_v,u=e.SolveCollisionCallback.ReportFixtureAndParticle_s_f,_=i.GetBody();if(!this.m_system.m_positionBuffer.data)throw new Error;if(!this.m_system.m_velocityBuffer.data)throw new Error;var f=this.m_system.m_positionBuffer.data[r],m=this.m_system.m_velocityBuffer.data[r],d=o,p=a;if(0===this.m_system.m_iterationIndex){var y=N.MulTXV(_.m_xf0,f,s);i.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(y.SelfSub(_.GetLocalCenter()),V.MulRV(_.m_xf0.q,y,y),V.MulTRV(_.m_xf.q,y,y),y.SelfAdd(_.GetLocalCenter())),N.MulXV(_.m_xf,y,p.p1)}else p.p1.Copy(f);if(I.AddVMulSV(f,this.m_step.dt,m,p.p2),p.maxFraction=1,i.RayCast(d,p,n)){var v=d.normal,g=l;g.x=(1-d.fraction)*p.p1.x+d.fraction*p.p2.x+h*v.x,g.y=(1-d.fraction)*p.p1.y+d.fraction*p.p2.y+h*v.y;var x=c;x.x=this.m_step.inv_dt*(g.x-f.x),x.y=this.m_step.inv_dt*(g.y-f.y),this.m_system.m_velocityBuffer.data[r].Copy(x);var A=u;A.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(m.x-x.x),A.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(m.y-x.y),this.m_system.ParticleApplyForce(r,A)}},n.prototype.ReportParticle=function(t,e){return!1},n.ReportFixtureAndParticle_s_p1=new I,n.ReportFixtureAndParticle_s_output=new Tt,n.ReportFixtureAndParticle_s_input=new St,n.ReportFixtureAndParticle_s_p=new I,n.ReportFixtureAndParticle_s_v=new I,n.ReportFixtureAndParticle_s_f=new I,n})(In);e.SolveCollisionCallback=x})(t.b2ParticleSystem||(t.b2ParticleSystem={}));var Nn=(function(){function e(t){this.m_newFixture=!1,this.m_locked=!1,this.m_clearForces=!0,this.m_contactManager=new nn,this.m_bodyList=null,this.m_jointList=null,this.m_particleSystemList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_gravity=new I,this.m_allowSleep=!0,this.m_destructionListener=null,this.m_debugDraw=null,this.m_inv_dt0=0,this.m_warmStarting=!0,this.m_continuousPhysics=!0,this.m_subStepping=!1,this.m_stepComplete=!0,this.m_profile=new rn,this.m_island=new dn,this.s_stack=[],this.m_controllerList=null,this.m_controllerCount=0,this.m_gravity.Copy(t)}return e.prototype.SetDestructionListener=function(t){this.m_destructionListener=t},e.prototype.SetContactFilter=function(t){this.m_contactManager.m_contactFilter=t},e.prototype.SetContactListener=function(t){this.m_contactManager.m_contactListener=t},e.prototype.SetDebugDraw=function(t){this.m_debugDraw=t},e.prototype.CreateBody=function(t){if(void 0===t&&(t={}),this.IsLocked())throw new Error;var e=new hi(t,this);return e.m_prev=null,e.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=e),this.m_bodyList=e,++this.m_bodyCount,e},e.prototype.DestroyBody=function(t){if(this.IsLocked())throw new Error;for(var e=t.m_jointList;e;){var i=e;e=e.next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(i.joint),this.DestroyJoint(i.joint),t.m_jointList=e}t.m_jointList=null;for(var n=t.m_controllerList;n;){var r=n;n=n.nextController,r.controller.RemoveBody(t)}for(var s=t.m_contactList;s;){var o=s;s=s.next,this.m_contactManager.Destroy(o.contact)}t.m_contactList=null;for(var a=t.m_fixtureList;a;){var h=a;a=a.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(h),h.DestroyProxies(),h.Destroy(),t.m_fixtureList=a,t.m_fixtureCount-=1}t.m_fixtureList=null,t.m_fixtureCount=0,t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_bodyList&&(this.m_bodyList=t.m_next),--this.m_bodyCount},e._Joint_Create=function(e,i){switch(e.type){case t.b2JointType.e_distanceJoint:return new mi(e);case t.b2JointType.e_mouseJoint:return new Si(e);case t.b2JointType.e_prismaticJoint:return new wi(e);case t.b2JointType.e_revoluteJoint:return new Mi(e);case t.b2JointType.e_pulleyJoint:return new Di(e);case t.b2JointType.e_gearJoint:return new xi(e);case t.b2JointType.e_wheelJoint:return new Fi(e);case t.b2JointType.e_weldJoint:return new Li(e);case t.b2JointType.e_frictionJoint:return new vi(e);case t.b2JointType.e_ropeJoint:return new Ii(e);case t.b2JointType.e_motorJoint:return new bi(e);case t.b2JointType.e_areaJoint:return new pi(e)}throw new Error},e._Joint_Destroy=function(t,e){},e.prototype.CreateJoint=function(t){if(this.IsLocked())throw new Error;var i=e._Joint_Create(t,null);i.m_prev=null,i.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=i),this.m_jointList=i,++this.m_jointCount,i.m_edgeA.prev=null,i.m_edgeA.next=i.m_bodyA.m_jointList,i.m_bodyA.m_jointList&&(i.m_bodyA.m_jointList.prev=i.m_edgeA),i.m_bodyA.m_jointList=i.m_edgeA,i.m_edgeB.prev=null,i.m_edgeB.next=i.m_bodyB.m_jointList,i.m_bodyB.m_jointList&&(i.m_bodyB.m_jointList.prev=i.m_edgeB),i.m_bodyB.m_jointList=i.m_edgeB;var n=t.bodyA,r=t.bodyB;if(!t.collideConnected)for(var s=r.GetContactList();s;)s.other===n&&s.contact.FlagForFiltering(),s=s.next;return i},e.prototype.DestroyJoint=function(t){if(this.IsLocked())throw new Error;var i=t.m_collideConnected;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_jointList&&(this.m_jointList=t.m_next);var n=t.m_bodyA,r=t.m_bodyB;if(n.SetAwake(!0),r.SetAwake(!0),t.m_edgeA.prev&&(t.m_edgeA.prev.next=t.m_edgeA.next),t.m_edgeA.next&&(t.m_edgeA.next.prev=t.m_edgeA.prev),t.m_edgeA===n.m_jointList&&(n.m_jointList=t.m_edgeA.next),t.m_edgeA.prev=null,t.m_edgeA.next=null,t.m_edgeB.prev&&(t.m_edgeB.prev.next=t.m_edgeB.next),t.m_edgeB.next&&(t.m_edgeB.next.prev=t.m_edgeB.prev),t.m_edgeB===r.m_jointList&&(r.m_jointList=t.m_edgeB.next),t.m_edgeB.prev=null,t.m_edgeB.next=null,e._Joint_Destroy(t,null),--this.m_jointCount,!i)for(var s=r.GetContactList();s;)s.other===n&&s.contact.FlagForFiltering(),s=s.next},e.prototype.CreateParticleSystem=function(e){if(this.IsLocked())throw new Error;var i=new t.b2ParticleSystem(e,this);return i.m_prev=null,i.m_next=this.m_particleSystemList,this.m_particleSystemList&&(this.m_particleSystemList.m_prev=i),this.m_particleSystemList=i,i},e.prototype.DestroyParticleSystem=function(t){if(this.IsLocked())throw new Error;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_particleSystemList&&(this.m_particleSystemList=t.m_next)},e.prototype.CalculateReasonableParticleIterations=function(t){if(null===this.m_particleSystemList)return 1;return yn(this.m_gravity.Length(),(function(t){for(var e=i,n=t.GetParticleSystemList();null!==n;n=n.m_next)e=g(e,n.GetRadius());return e})(this),t)},e.prototype.Step=function(t,i,n,r){void 0===r&&(r=this.CalculateReasonableParticleIterations(t));var s=e.Step_s_stepTimer.Reset();this.m_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_newFixture=!1),this.m_locked=!0;var o=e.Step_s_step;o.dt=t,o.velocityIterations=i,o.positionIterations=n,o.particleIterations=r,o.inv_dt=t>0?1/t:0,o.dtRatio=this.m_inv_dt0*t,o.warmStarting=this.m_warmStarting;var a=e.Step_s_timer.Reset();if(this.m_contactManager.Collide(),this.m_profile.collide=a.GetMilliseconds(),this.m_stepComplete&&o.dt>0){for(var h=e.Step_s_timer.Reset(),l=this.m_particleSystemList;l;l=l.m_next)l.Solve(o);this.Solve(o),this.m_profile.solve=h.GetMilliseconds()}if(this.m_continuousPhysics&&o.dt>0){var c=e.Step_s_timer.Reset();this.SolveTOI(o),this.m_profile.solveTOI=c.GetMilliseconds()}o.dt>0&&(this.m_inv_dt0=o.inv_dt),this.m_clearForces&&this.ClearForces(),this.m_locked=!1,this.m_profile.step=s.GetMilliseconds()},e.prototype.ClearForces=function(){for(var t=this.m_bodyList;t;t=t.m_next)t.m_force.SetZero(),t.m_torque=0},e.prototype.DrawParticleSystem=function(t){if(null!==this.m_debugDraw){var e=t.GetParticleCount();if(e){var i=t.GetRadius(),n=t.GetPositionBuffer();if(t.m_colorBuffer.data){var r=t.GetColorBuffer();this.m_debugDraw.DrawParticles(n,i,r,e)}else this.m_debugDraw.DrawParticles(n,i,null,e)}}},e.prototype.DrawDebugData=function(){if(null!==this.m_debugDraw){var i=this.m_debugDraw.GetFlags(),n=e.DrawDebugData_s_color.SetRGB(0,0,0);if(i&t.b2DrawFlags.e_shapeBit)for(var r=this.m_bodyList;r;r=r.m_next){var s=r.m_xf;this.m_debugDraw.PushTransform(s);for(var o=r.GetFixtureList();o;o=o.m_next)r.IsActive()?r.GetType()===t.b2BodyType.b2_staticBody?(n.SetRGB(.5,.9,.5),this.DrawShape(o,n)):r.GetType()===t.b2BodyType.b2_kinematicBody?(n.SetRGB(.5,.5,.9),this.DrawShape(o,n)):r.IsAwake()?(n.SetRGB(.9,.7,.7),this.DrawShape(o,n)):(n.SetRGB(.6,.6,.6),this.DrawShape(o,n)):(n.SetRGB(.5,.5,.3),this.DrawShape(o,n));this.m_debugDraw.PopTransform(s)}if(i&t.b2DrawFlags.e_particleBit)for(var a=this.m_particleSystemList;a;a=a.m_next)this.DrawParticleSystem(a);if(i&t.b2DrawFlags.e_jointBit)for(var h=this.m_jointList;h;h=h.m_next)this.DrawJoint(h);if(i&t.b2DrawFlags.e_aabbBit){n.SetRGB(.9,.3,.9);var l=e.DrawDebugData_s_vs;for(r=this.m_bodyList;r;r=r.m_next)if(r.IsActive())for(o=r.GetFixtureList();o;o=o.m_next)for(var c=0;c0;){if(!(i=a[--l]))throw new Error;if(r.AddBody(i),i.m_awakeFlag=!0,i.GetType()!==t.b2BodyType.b2_staticBody){for(var c=i.m_contactList;c;c=c.next){var u=c.contact;if(!u.m_islandFlag&&(u.IsEnabled()&&u.IsTouching())){var _=u.m_fixtureA.m_isSensor,f=u.m_fixtureB.m_isSensor;if(!_&&!f){if(r.AddContact(u),u.m_islandFlag=!0,!(d=c.other))throw new Error;d.m_islandFlag||(a[l++]=d,d.m_islandFlag=!0)}}}for(var m=i.m_jointList;m;m=m.next){var d;if(!m.joint.m_islandFlag)(d=m.other).IsActive()&&(r.AddJoint(m.joint),m.joint.m_islandFlag=!0,d.m_islandFlag||(a[l++]=d,d.m_islandFlag=!0))}}}var p=new rn;r.Solve(p,e,this.m_gravity,this.m_allowSleep),this.m_profile.solveInit+=p.solveInit,this.m_profile.solveVelocity+=p.solveVelocity,this.m_profile.solvePosition+=p.solvePosition;for(var y=0;y8)){var l=1;if(o.m_toiFlag)l=o.m_toi;else{var c=o.GetFixtureA(),u=o.GetFixtureB();if(c.IsSensor()||u.IsSensor())continue;var _=c.GetBody(),f=u.GetBody(),m=_.m_type,d=f.m_type,p=_.IsAwake()&&m!==t.b2BodyType.b2_staticBody,y=f.IsAwake()&&d!==t.b2BodyType.b2_staticBody;if(!p&&!y)continue;var v=_.IsBullet()||m!==t.b2BodyType.b2_dynamicBody,x=f.IsBullet()||d!==t.b2BodyType.b2_dynamicBody;if(!v&&!x)continue;var A=_.m_sweep.alpha0;_.m_sweep.alpha0this.maxTimestep&&this.maxTimestep>0&&(i=this.maxTimestep);for(var r=this.m_bodyList;r;r=r.nextBody){var s=r.body;if(s.IsAwake()){var o=s.GetWorldVector(O.MulMV(this.T,s.GetLocalVector(s.GetLinearVelocity(),I.s_t0),I.s_t1),e.Step_s_damping);s.SetLinearVelocity(I.AddVV(s.GetLinearVelocity(),I.MulSV(i,o,I.s_t0),I.s_t1))}}}},e.prototype.Draw=function(t){},e.prototype.SetAxisAligned=function(t,e){this.T.ex.x=-t,this.T.ex.y=0,this.T.ey.x=0,this.T.ey.y=-e,this.maxTimestep=t>0||e>0?1/x(t,e):0},e.Step_s_damping=new I,e})(Gn),Xn=(function(){return function(){this.vertices=[],this.count=0,this.masses=[],this.gravity=new I(0,0),this.damping=.1,this.k2=.9,this.k3=.1}})(),Yn=(function(){function t(){this.m_count=0,this.m_ps=[],this.m_p0s=[],this.m_vs=[],this.m_ims=[],this.m_Ls=[],this.m_as=[],this.m_gravity=new I,this.m_damping=0,this.m_k2=1,this.m_k3=.1}return t.prototype.GetVertexCount=function(){return this.m_count},t.prototype.GetVertices=function(){return this.m_ps},t.prototype.Initialize=function(t){this.m_count=t.count,this.m_ps=I.MakeArray(this.m_count),this.m_p0s=I.MakeArray(this.m_count),this.m_vs=I.MakeArray(this.m_count),this.m_ims=d(this.m_count);for(var e=0;e0?1/i:0}var n=this.m_count-1,r=this.m_count-2;this.m_Ls=d(n),this.m_as=d(r);for(e=0;e0&&this.m_vs[n].SelfMulAdd(t,this.m_gravity),this.m_vs[n].SelfMul(i),this.m_ps[n].SelfMulAdd(t,this.m_vs[n]);for(n=0;ns;)C=(p-=2*s)-this.m_as[i];for(;C<-s;)C=(p+=2*s)-this.m_as[i];var S=-this.m_k3*b*C;n.SelfMulAdd(a*S,g),r.SelfMulAdd(h*S,x),o.SelfMulAdd(l*S,A)}}}},t.prototype.Draw=function(t){for(var e=new G(.4,.5,.7),i=0;i>1&2147483647,t|=t>>2&1073741823,t|=t>>4&268435455,t|=t>>8&16777215,1+(t|=t>>16&65535)},t.b2IsPowerOfTwo=function(t){return t>0&&0==(t&t-1)},t.b2Random=function(){return 2*Math.random()-1},t.b2RandomRange=function(t,e){return(e-t)*Math.random()+t},t.b2Vec2=I,t.b2Vec2_zero=R,t.b2Vec3=L,t.b2Mat22=O,t.b2Mat33=F,t.b2Rot=V,t.b2Transform=N,t.b2Sweep=k,t.b2Color=G,t.b2Draw=z,t.b2Timer=U,t.b2Counter=W,t.b2GrowableStack=j,t.b2BlockAllocator=H,t.b2StackAllocator=X,t.b2ContactFeature=vt,t.b2ContactID=gt,t.b2ManifoldPoint=xt,t.b2Manifold=At,t.b2WorldManifold=bt,t.b2GetPointStates=function(e,i,n,r){var s;for(s=0;sb;){t.iterations+=1,m=i.GetSupport(V.MulTRV(s.q,I.NegV(g,I.s_t1),I.s_t0)),d=N.MulXV(s,i.GetVertex(m),_t),p=n.GetSupport(V.MulTRV(o.q,g,I.s_t0)),y=N.MulXV(o,n.GetVertex(p),ft);var S=I.SubVV(d,y,dt);g.Normalize();var T=I.DotVV(g,S),w=I.DotVV(g,a);if(T-A>u*w){if(w<=0)return!1;if((u=(T-A)/w)>1)return!1;l.Copy(g).SelfNeg(),_.m_count=0}var E=f[_.m_count];switch(E.indexA=p,E.wA.Copy(y).SelfMulAdd(u,a),E.indexB=m,E.wB.Copy(d),E.w.Copy(E.wB).SelfSub(E.wA),E.a=1,_.m_count+=1,_.m_count){case 1:break;case 2:_.Solve2();break;case 3:_.Solve3()}if(3===_.m_count)return!1;_.GetClosestPoint(g),++C}var D=pt,B=yt;return _.GetWitnessPoints(D,B),g.LengthSquared()>0&&(l.Copy(g).SelfNeg(),l.Normalize()),t.normal.Copy(l),t.lambda=u,t.iterations=C,!0},t.b2Pair=Ft,t.b2BroadPhase=Vt,t.b2PairLessThan=Nt,t.b2TreeNode=Lt,t.b2DynamicTree=Ot,t.b2_toi_reset=function(){t.b2_toiTime=0,t.b2_toiMaxTime=0,t.b2_toiCalls=0,t.b2_toiIters=0,t.b2_toiMaxIters=0,t.b2_toiRootIters=0,t.b2_toiMaxRootIters=0},t.b2TOIInput=Xt,t.b2TOIOutput=Yt,t.b2SeparationFunction=qt,t.b2TimeOfImpact=re,t.b2CollideCircles=ae,t.b2CollidePolygonAndCircle=ue,t.b2CollidePolygons=Le,t.b2CollideEdgeAndCircle=We,t.b2CollideEdgeAndPolygon=qe,t.b2MassData=Je,t.b2Shape=Ze,t.b2CircleShape=$e,t.b2PolygonShape=ti,t.b2EdgeShape=ei,t.b2ChainShape=ii,t.b2Filter=ni,t.b2FixtureDef=ri,t.b2FixtureProxy=si,t.b2Fixture=oi,t.b2BodyDef=ai,t.b2Body=hi,t.b2World=Nn,t.b2DestructionListener=Zi,t.b2ContactFilter=Ki,t.b2ContactImpulse=Qi,t.b2ContactListener=$i,t.b2QueryCallback=tn,t.b2RayCastCallback=en,t.b2Island=dn,t.b2Profile=rn,t.b2TimeStep=sn,t.b2Position=on,t.b2Velocity=an,t.b2SolverData=hn,t.b2ContactManager=nn,t.b2MixFriction=Vi,t.b2MixRestitution=Ni,t.b2ContactEdge=ki,t.b2Contact=Gi,t.b2ContactRegister=qi,t.b2ContactFactory=Ji,t.g_blockSolve=!1,t.b2VelocityConstraintPoint=ln,t.b2ContactVelocityConstraint=cn,t.b2ContactPositionConstraint=un,t.b2ContactSolverDef=_n,t.b2PositionSolverManifold=fn,t.b2ContactSolver=mn,t.b2CircleContact=zi,t.b2PolygonContact=Ui,t.b2PolygonAndCircleContact=Wi,t.b2EdgeAndCircleContact=ji,t.b2EdgeAndPolygonContact=Hi,t.b2ChainAndCircleContact=Xi,t.b2ChainAndPolygonContact=Yi,t.b2Jacobian=li,t.b2JointEdge=ci,t.b2JointDef=ui,t.b2Joint=_i,t.b2AreaJointDef=di,t.b2AreaJoint=pi,t.b2DistanceJointDef=fi,t.b2DistanceJoint=mi,t.b2FrictionJointDef=yi,t.b2FrictionJoint=vi,t.b2GearJointDef=gi,t.b2GearJoint=xi,t.b2MotorJointDef=Ai,t.b2MotorJoint=bi,t.b2MouseJointDef=Ci,t.b2MouseJoint=Si,t.b2PrismaticJointDef=Ti,t.b2PrismaticJoint=wi,t.b2_minPulleyLength=2,t.b2PulleyJointDef=Ei,t.b2PulleyJoint=Di,t.b2RevoluteJointDef=Bi,t.b2RevoluteJoint=Mi,t.b2RopeJointDef=Pi,t.b2RopeJoint=Ii,t.b2WeldJointDef=Ri,t.b2WeldJoint=Li,t.b2WheelJointDef=Oi,t.b2WheelJoint=Fi,t.b2ControllerEdge=kn,t.b2Controller=Gn,t.b2BuoyancyController=zn,t.b2ConstantAccelController=Un,t.b2ConstantForceController=Wn,t.b2GravityController=jn,t.b2TensorDampingController=Hn,t.b2ParticleDef=pn,t.b2CalculateParticleIterations=yn,t.b2ParticleHandle=vn,t.b2ParticleGroupDef=gn,t.b2ParticleGroup=xn,t.b2GrowableBuffer=Pn,t.b2FixtureParticleQueryCallback=In,t.b2ParticleContact=Rn,t.b2ParticleBodyContact=Ln,t.b2ParticlePair=On,t.b2ParticleTriad=Fn,t.b2ParticleSystemDef=Vn,t.b2RopeDef=Xn,t.b2Rope=Yn,Object.defineProperty(t,"__esModule",{value:!0})}))}),{}],293:[(function(t,e,i){var n="undefined"==typeof window?global:window;n.cc=n.cc||{},n._cc=n._cc||{},t("./predefine"),t("./polyfill/string"),t("./polyfill/misc"),t("./polyfill/array"),t("./polyfill/object"),t("./polyfill/typescript"),t("./cocos2d/core/predefine"),t("./cocos2d"),t("./extends"),e.exports=n.cc}),{"./cocos2d":253,"./cocos2d/core/predefine":181,"./extends":273,"./package":void 0,"./polyfill/array":294,"./polyfill/misc":295,"./polyfill/object":296,"./polyfill/string":297,"./polyfill/typescript":298,"./predefine":299}],294:[(function(t,e,i){Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)})}),{}],295:[(function(t,e,i){if(Math.sign||(Math.sign=function(t){return 0===(t=+t)||isNaN(t)?t:t>0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),!console.time){var n=window.performance||Date,r=Object.create(null);console.time=function(t){r[t]=n.now()},console.timeEnd=function(t){var e=r[t],i=n.now()-e;console.log(t+": "+i+"ms")}}}),{}],296:[(function(t,e,i){Object.assign||(Object.assign=function(t,e){cc.js.mixin(t,e)})}),{}],297:[(function(t,e,i){String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.lastIndexOf(t,e)===e}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){(void 0===e||e>this.length)&&(e=this.length),e-=t.length;var i=this.indexOf(t,e);return-1!==i&&i===e})}),{}],298:[(function(t,e,i){var n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};window.__extends=function(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)},window.__assign=Object.assign||function(t){for(var e,i=1,n=arguments.length;i=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o},window.__param=function(t,e){return function(i,n){e(i,n,t)}},window.__metadata=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},window.__awaiter=function(t,e,i,n){return new(i||(i=Promise))(function(r,s){function o(t){try{h(n.next(t))}catch(t){s(t)}}function a(t){try{h(n.throw(t))}catch(t){s(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(o,a)}h((n=n.apply(t,e||[])).next())})},window.__generator=function(t,e){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return (function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=n[2&s[0]?"return":s[0]?"throw":"next"])&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[0,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=(r=o.trys).length>0&&r[r.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}}},window.__read=function(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,r,s=i.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return o},window.__spread=function(){for(var t=[],e=0;e1||a(t,e)})})}function a(t,e){try{(function(t){t.value instanceof __await?Promise.resolve(t.value.v).then(h,l):c(s[0][2],t)})(r[t](e))}catch(t){c(s[0][3],t)}}function h(t){a("next",t)}function l(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}},window.__asyncDelegator=function(t){var e,i;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,r){t[n]&&(e[n]=function(e){return(i=!i)?{value:__await(t[n](e)),done:"return"===n}:r?r(e):e})}},window.__asyncValues=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator];return e?e.call(t):"function"==typeof __values?__values(t):t[Symbol.iterator]()}}),{}],299:[(function(t,e,i){var n="undefined"==typeof window?global:window;function r(t,e){void 0===n[t]&&(n[t]=e)}function s(t){return"object"==typeof n[t]}r("CC_TEST",s("tap")||s("QUnit")),r("CC_EDITOR",s("Editor")&&s("process")&&"electron"in process.versions),r("CC_PREVIEW",!0),r("CC_DEV",!0),r("CC_DEBUG",!0),r("CC_JSB",s("jsb")),r("CC_BUILD",!1),r("CC_WECHATGAME_SUB",!(!s("wx")||!wx.getSharedCanvas)),r("CC_WECHATGAME",!(!s("wx")||!wx.getSystemInfoSync&&!wx.getSharedCanvas)),r("CC_QQPLAY",s("bk")),r("CC_RUNTIME","function"==typeof loadRuntime),r("CC_SUPPORT_JIT",!0);n.CocosEngine=cc.ENGINE_VERSION="2.0.2"}),{}]},{},[293]);