(function(t,e,i){function n(i){var r=e[i];if(!r){var s=t[i];if(!s)return;var o={};r=e[i]={exports:o},s[0]((function(t){return n(s[1][t]||t)}),r,o)}return r.exports}for(var r=0;r=0;i--)e.push(cc.v2(t[i].x,t[i].y));return e}function n(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(){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._startAngle=e,this._angle=cc.RotateTo._reverse?i:-i},reverse:function(){cc.logID(1016)},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.angle=this._startAngle+this._angle*t)}}),cc.rotateTo=function(t,e){return new cc.RotateTo(t,e)},cc.RotateBy=cc.Class({name:"cc.RotateBy",extends:cc.ActionInterval,statics:{_reverse:!1},ctor:function(t,e){e*=cc.RotateBy._reverse?1:-1,this._deltaAngle=0,this._startAngle=0,void 0!==e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._deltaAngle=e,!0)},clone:function(){var t=new cc.RotateBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._deltaAngle),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._startAngle=t.angle},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.angle=this._startAngle+this._deltaAngle*t)},reverse:function(){var t=new cc.RotateBy;return t.initWithDuration(this._duration,-this._deltaAngle),this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.rotateBy=function(t,e){return new cc.RotateBy(t,e)},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(){},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){"use strict";t("../core/platform/CCClass");var e=t("../core/platform/js"),i=function(){this.actions=[],this.target=null,this.actionIndex=0,this.currentAction=null,this.paused=!1,this.lock=!1};cc.ActionManager=function(){this._hashTargets=e.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}}},_removeActionByTag:function(t,e,i){for(var n=0,r=e.actions.length;n=0;--n){var r=e.actions[n];if(r&&r.getTag()===t){if(i&&r.getOriginalTarget()!==i)continue;this._removeActionAtIndex(n,e)}}},removeActionByTag:function(t,e){t===cc.Action.TAG_INVALID&&cc.logID(1002);var i=this._hashTargets;if(e){var n=i[e._id];n&&this._removeActionByTag(t,n,e)}else for(var r in i){var s=i[r];this._removeActionByTag(t,s)}},removeAllActionsByTag:function(t,e){t===cc.Action.TAG_INVALID&&cc.logID(1002);var i=this._hashTargets;if(e){var n=i[e._id];n&&this._removeAllActionsByTag(t,n,e)}else for(var r in i){var s=i[r];this._removeAllActionsByTag(t,s)}},getActionByTag:function(t,e){t===cc.Action.TAG_INVALID&&cc.logID(1004);var i=this._hashTargets[e._id];if(i){if(null!=i.actions)for(var n=0;n=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;n=1?t:r%n>n/2?255:0},this.to(t,{opacity:1},i)}});var o=[];function a(t){return function(){o.length=0;for(var e=arguments.length,i=0;i=0?d=l.events[p]:(d=new o,l.ratios.push(f),l.events.push(d)),d.add(_.func,_.params)}}u.playState=function(t,e){t.clip&&(t.curveLoaded||h(this.target,t),t.animator=this,t.play(),"number"==typeof e&&t.setTime(e),this.play())},u.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(3907),t.animator=null},u.sample=function(){var t=this._anims,e=t.array;for(t.i=0;t.i1e-6){g=!1;break}l._findFrameIndex=g?s:a;var C=l.values[0];return null==C||l._lerp||("number"==typeof C?l._lerp=r.prototype._lerpNumber:C instanceof cc.Quat?l._lerp=r.prototype._lerpQuat:C instanceof cc.Vec2?l._lerp=r.prototype._lerpVector2:C instanceof cc.Vec3?l._lerp=r.prototype._lerpVector3:C.lerp&&(l._lerp=r.prototype._lerpObject)),l},createTargetCurves:function(t,e,i){var n=e.props,r=e.comps;if(n)for(var s in n){var o=n[s],a=this.createPropCurve(t,s,o);i.push(a)}if(r)for(var c in r){var l=t.getComponent(c);if(l){var u=r[c];for(var h in u){var _=u[h],f=this.createPropCurve(l,h,_);i.push(f)}}}},createCurves:function(t,e){var i=this.curveData,n=i.paths,r=[];for(var s in this.createTargetCurves(e,i,r),n){var o=cc.find(s,e);if(o){var a=n[s];this.createTargetCurves(o,a,r)}}return r}});cc.AnimationClip=e.exports=c}),{"../core/utils/binary-search":244,"./animation-curves":11,"./motion-path-helper":17,"./types":19}],11:[(function(t,e){"use strict";var i=t("./bezier").bezierByTime,n=t("../core/utils/binary-search").binarySearchEpsilon,r=t("./types").WrapModeMask,s=t("./types").WrappedInfo;function o(t,e){if("string"==typeof e){var n=cc.easing[e];n?t=n(t):cc.errorID(3906,e)}else Array.isArray(e)&&(t=i(e,t));return t}var a=cc.Class({name:"cc.AnimCurve",sample:function(){},onTimeChangedManually:void 0});var c,l=cc.Class({name:"cc.DynamicAnimCurve",extends:a,ctor:function(){this._cachedIndex=0},properties:{target:null,prop:"",values:[],ratios:[],types:[]},_findFrameIndex:n,_lerp:void 0,_lerpNumber:function(t,e,i){return t+(e-t)*i},_lerpObject:function(t,e,i){return t.lerp(e,i)},_lerpQuat:(c=cc.quat(),function(t,e,i){return t.lerp(e,i,c)}),_lerpVector2:(function(){var t=cc.v2();return function(e,i,n){return e.lerp(i,n,t)}})(),_lerpVector3:(function(){var t=cc.v3();return function(e,i,n){return e.lerp(i,n,t)}})(),sample:function(t,e){var i=this.values,n=this.ratios,r=n.length;if(0!==r){var s,a=!0,c=this._cachedIndex;if(c<0&&(c=~c)>0&&cl&&e=r)s=i[r-1];else{var _=i[h-1];if(this._lerp){var f=n[h-1],d=n[h],p=this.types[h-1],m=(e-f)/(d-f);p&&(m=o(m,p));var v=i[h];s=this._lerp(_,v,m)}else s=_}else s=i[h];this.target[this.prop]=s}}});l.Linear=null,l.Bezier=function(t){return t};var u=function(){this.events=[]};u.prototype.add=function(t,e){this.events.push({func:t||"",params:e||[]})};var h=cc.Class({name:"cc.EventAnimCurve",extends:a,properties:{target:null,ratios:[],events:[],_wrappedInfo:{default:function(){return new s}},_lastWrappedInfo:null,_ignoreIndex:NaN},_wrapIterations:function(t){return t-(0|t)==0&&(t-=1),0|t},sample:function(t,e,i){var o=this.ratios.length,a=i.getWrappedInfo(i.time,this._wrappedInfo),c=a.direction,l=n(this.ratios,a.ratio);if(l<0&&(l=~l-1,c<0&&(l+=1)),this._ignoreIndex!==l&&(this._ignoreIndex=NaN),a.frameIndex=l,!this._lastWrappedInfo)return this._fireEvent(l),void(this._lastWrappedInfo=new s(a));var u=i.wrapMode,h=this._wrapIterations(a.iterations),_=this._lastWrappedInfo,f=this._wrapIterations(_.iterations),d=_.frameIndex,p=_.direction,m=-1!==f&&h!==f;if(d===l&&m&&1===o)this._fireEvent(0);else if(d!==l||m){c=p;do{if(d!==l){if(-1===c&&0===d&&l>0?((u&r.PingPong)===r.PingPong?c*=-1:d=o,f++):1===c&&d===o-1&&lh)break}d+=c,cc.director.getAnimationManager().pushDelayEvent(this,"_fireEvent",[d])}while(d!==l&&d>-1&&d=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~t.length;var s=(e=(e-n)/(r-n))/(1/i),o=0|s;return s-o<1e-6?o:o+1-s<1e-6?o+1:~(o+1)}}}),{"../core/utils/binary-search":244,"./bezier":14,"./types":19}],12:[(function(t,e){"use strict";var i=cc.js,n=cc.Class({ctor:function(){this._anims=new i.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=n}),{}],13:[(function(t,e){"use strict";var i=cc.js,n=t("./playable"),r=t("./types"),s=r.WrappedInfo,o=r.WrapMode,a=r.WrapModeMask;function c(t,e){n.call(this),this._currentFramePlayed=!1,this._delay=0,this._delayTime=0,this._wrappedInfo=new s,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=o.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 h(){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())},l._needRevers=function(t){var e=this.wrapMode,i=!1;return(e&a.PingPong)===a.PingPong&&(t-(0|t)==0&&t>0&&(t-=1),1&t&&(i=!i)),(e&a.Reverse)===a.Reverse&&(i=!i),i},l.getWrappedInfo=function(t,e){e=e||new s;var i=!1,n=this.duration,r=this.repeatCount,o=t>0?t/n:-t/n;if(o>=r){o=r,i=!0;var c=r-(0|r);0===c&&(c=1),t=c*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 u=!1,h=this._wrapMode&a.ShouldWrap;h&&(u=this._needRevers(o));var _=u?-1:1;return this.speed<0&&(_*=-1),h&&u&&(t=n-t),e.ratio=t/n,e.time=t,e.direction=_,e.stopped=i,e.iterations=o,e},l.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})),i.getset(l,"wrapMode",(function(){return this._wrapMode}),(function(t){this._wrapMode=t,this.time=0,t&a.Loop?this.repeatCount=1/0:this.repeatCount=1})),i.getset(l,"repeatCount",(function(){return this._repeatCount}),(function(t){this._repeatCount=t;var e=this._wrapMode&a.ShouldWrap,i=(this.wrapMode&a.Reverse)===a.Reverse;this._process=t!==1/0||e||i?u:h})),i.getset(l,"delay",(function(){return this._delay}),(function(t){this._delayTime=this._delay=t})),cc.AnimationState=e.exports=c}),{"./playable":18,"./types":19}],14:[(function(t,e){"use strict";var i=Math.cos,n=Math.acos,r=Math.max,s=2*Math.PI,o=Math.sqrt;function a(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}function c(t,e){var c,l,u,h,_=e-0,f=e-t[0],d=3*_,p=3*f,m=3*(e-t[2]),v=1/(-_+p-m+(e-1)),y=(d-6*f+m)*v,g=y*(1/3),x=(-d+p)*v,A=1/3*(3*x-y*y),C=A*(1/3),S=(2*y*y*y-9*y*x+_*v*27)/27,b=S/2,T=b*b+C*C*C;if(T<0){var w=1/3*-A,E=o(w*w*w),B=-S/(2*E),M=n(B<-1?-1:B>1?1:B),R=2*a(E);return l=R*i(M*(1/3))-g,u=R*i((M+s)*(1/3))-g,h=R*i((M+2*s)*(1/3))-g,0<=l&&l<=1?0<=u&&u<=1?0<=h&&h<=1?r(l,u,h):r(l,u):0<=h&&h<=1?r(l,h):l:0<=u&&u<=1?0<=h&&h<=1?r(u,h):u:h}if(0===T)return u=-(c=b<0?a(-b):-a(b))-g,0<=(l=2*c-g)&&l<=1?0<=u&&u<=1?r(l,u):l:u;var P=o(T);return(c=a(-b+P))-a(b+P)-g}e.exports={bezier:function(t,e,i,n,r){var s=1-r;return s*(s*(t+(3*e-t)*r)+3*i*r*r)+n*r*r*r},bezierByTime:function(t,e){var i=c(t,e),n=t[1];return((1-i)*(n+(t[3]-n)*i)*3+i*i)*i}}}),{}],15:[(function(t,e){"use strict";var i={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(2*(t-e)*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(2*(t-e)*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(2*(t-e)*Math.PI/.4)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin(2*(t-e)*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)},bounceIn:function(t){return 1-i.bounceOut(1-t)},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},bounceInOut:function(t){return t<.5?.5*i.bounceIn(2*t):.5*i.bounceOut(2*t-1)+.5},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 n(t,e){return function(i){return i<.5?e(2*i)/2:t(2*i-1)/2+.5}}i.quadOutIn=n(i.quadIn,i.quadOut),i.cubicOutIn=n(i.cubicIn,i.cubicOut),i.quartOutIn=n(i.quartIn,i.quartOut),i.quintOutIn=n(i.quintIn,i.quintOut),i.sineOutIn=n(i.sineIn,i.sineOut),i.expoOutIn=n(i.expoIn,i.expoOut),i.circOutIn=n(i.circIn,i.circOut),i.backOutIn=n(i.backIn,i.backOut),i.bounceIn=function(t){return 1-i.bounceOut(1-t)},i.bounceInOut=function(t){return t<.5?.5*i.bounceIn(2*t):.5*i.bounceOut(2*t-1)+.5},i.bounceOutIn=n(i.bounceIn,i.bounceOut),cc.easing=e.exports=i}),{}],16:[(function(t){"use strict";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":9,"./animation-clip":10,"./animation-curves":11,"./animation-manager":12,"./animation-state":13,"./bezier":14,"./easing":15,"./motion-path-helper":17,"./types":19}],17:[(function(t,e){"use strict";var i=t("./animation-curves").DynamicAnimCurve,n=t("./animation-curves").computeRatioByType,r=t("./bezier").bezier,s=t("../core/utils/binary-search").binarySearchEpsilon,o=cc.v2;function a(t){this.points=t||[],this.beziers=[],this.ratios=[],this.progresses=[],this.length=0,this.computeBeziers()}function c(){this.start=o(),this.end=o(),this.startCtrlPoint=o(),this.endCtrlPoint=o()}function l(t){if(!Array.isArray(t))return!1;for(var e=0,i=t.length;e0)){c=r;break}c=r-1}if(n[r=c]===i)return r/(s-1);var l=n[r];return(r+(i-l)/(n[r+1]-l))/(s-1)},e.exports={sampleMotionPaths:function(t,e,r,c,u){function h(t){return t instanceof cc.Vec2?{in:t,pos:t,out:t}:Array.isArray(t)&&6===t.length?{in:o(t[2],t[3]),pos:o(t[0],t[1]),out:o(t[4],t[5])}:{in:cc.Vec2.ZERO,pos:cc.Vec2.ZERO,out:cc.Vec2.ZERO}}var _=e.values=e.values.map((function(t){return Array.isArray(t)&&(t=2===t.length?cc.v2(t[0],t[1]):cc.v3(t[0],t[1],t[2])),t}));if(0!==t.length&&0!==_.length){for(var f=!1,d=0;d0){f=!0;break}}if(f&&1!==_.length){for(var m=e.types,v=e.ratios,y=e.values=[],g=e.types=[],x=e.ratios=[],A=0,C=i.Linear,S=0,b=t.length;S0){var L=[];L.push(h(M));for(var O=0,F=w.length;O1e-6;){var z,U,H,W;if((T=n(T=D,P))<0)W=(0-T)*(U=G.beziers[0]).getLength(),H=U.start.sub(U.endCtrlPoint).normalize(),z=U.start.add(H.mul(W));else if(T>1)W=(T-1)*(U=G.beziers[G.beziers.length-1]).getLength(),H=U.end.sub(U.startCtrlPoint).normalize(),z=U.end.add(H.mul(W));else{var j=s(k,T);j<0&&(j=~j),T-=j>0?k[j-1]:0,T/=G.ratios[j],z=G.beziers[j].getPointAt(T)}I.push(z),D+=V}}else for(;1-D>1e-6;)T=n(T=D,P),I.push(M.lerp(R,T)),D+=V;for(C="constant"===P?P:i.Linear,O=0,F=I.length;O1e-6?(D-1)*B:0}v[v.length-1]!==x[x.length-1]&&q(_[_.length-1],C,v[v.length-1])}}function q(t,e,i){y.push(t),g.push(e),x.push(i)}},Curve:a,Bezier:c}}),{"../core/utils/binary-search":244,"./animation-curves":11,"./bezier":14}],18:[(function(t,e){"use strict";var i=cc.js,n=t("../core/CCDebug");function r(){this._isPlaying=!1,this._isPaused=!1,this._stepOnce=!1}var s=r.prototype;i.get(s,"isPlaying",(function(){return this._isPlaying}),!0),i.get(s,"isPaused",(function(){return this._isPaused}),!0);var o=function(){};s.onPlay=o,s.onPause=o,s.onResume=o,s.onStop=o,s.onError=o,s.play=function(){this._isPlaying?this._isPaused?(this._isPaused=!1,this.onResume()):this.onError(n.getError(3912)):(this._isPlaying=!0,this.onPlay())},s.stop=function(){this._isPlaying&&(this._isPlaying=!1,this.onStop(),this._isPaused=!1)},s.pause=function(){this._isPlaying&&!this._isPaused&&(this._isPaused=!0,this.onPause())},s.resume=function(){this._isPlaying&&this._isPaused&&(this._isPaused=!1,this.onResume())},s.step=function(){this.pause(),this._stepOnce=!0,this._isPlaying||this.play()},e.exports=r}),{"../core/CCDebug":22}],19:[(function(t,e){"use strict";var i={Loop:2,ShouldWrap:4,PingPong:22,Reverse:36},n=cc.Enum({Default:0,Normal:1,Reverse:i.Reverse,Loop:i.Loop,LoopReverse:i.Loop|i.Reverse,PingPong:i.PingPong,PingPongReverse:i.PingPong|i.Reverse});function r(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=n,r.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:i,WrapMode:n,WrappedInfo:r}}),{}],20:[(function(t,e){"use strict";var i,n,r=t("../core/event/event-target"),s=t("../core/platform/CCSys"),o=t("../core/assets/CCAudioClip").LoadMode,a=!1,c=[],l=function t(e){r.call(this),this._shouldRecycleOnEnded=!1,this._src=e,this._element=null,this.id=0,this._state=t.State.INITIALZING;var i=this;this._onended=function(){i._state=t.State.STOPPED,i.emit("ended")},this._onendedSecond=function(){i._unbindEnded(i._onendedSecond),i._bindEnded()}};cc.js.extend(l,r),l.State={ERROR:-1,INITIALZING:0,PLAYING:1,PAUSED:2,STOPPED:3},(i=l.prototype)._bindEnded=function(t){if(!(t=t||this._onended)._binded){t._binded=!0;var e=this._element;this._src&&e instanceof HTMLAudioElement?e.addEventListener("ended",t):e.onended=t}},i._unbindEnded=function(t){if((t=t||this._onended)._binded){t._binded=!1;var e=this._element;e instanceof HTMLAudioElement?e.removeEventListener("ended",t):e&&(e.onended=null)}},i._onLoaded=function(){this._createElement(),this._state=l.State.INITIALZING,this.setVolume(1),this.setLoop(!1)},i._createElement=function(){var t=this._src._nativeAsset;t instanceof HTMLAudioElement?(this._element||(this._element=document.createElement("audio")),this._element.src=t.src):this._element=new u(t,this)},i.play=function(){var t=this;this._src&&this._src._ensureLoaded((function(){t._state=l.State.PLAYING,t._bindEnded();var e=t._element.play();window.Promise&&e instanceof Promise&&e.catch((function(){})),t._touchToPlay()}))},i._touchToPlay=function(){if(this._src&&this._src.loadMode===o.DOM_AUDIO&&this._element.paused&&c.push({instance:this,offset:0,audio:this._element}),!a){a=!0;var t="ontouchend"in window?"touchend":"mousedown";cc.game.canvas.addEventListener(t,(function(){for(var t;t=c.pop();)t.audio.play(t.offset)}))}},i.destroy=function(){this._element=null},i.pause=function(){if(this.getState()===l.State.PLAYING){var t=this;this._src&&this._src._ensureLoaded((function(){t._unbindEnded(),t._element.pause(),t._state=l.State.PAUSED}))}},i.resume=function(){if(this.getState()===l.State.PAUSED){var t=this;this._src&&this._src._ensureLoaded((function(){t._bindEnded(),t._element.play(),t._state=l.State.PLAYING}))}},i.stop=function(){var t=this;this._src&&this._src._ensureLoaded((function(){t._element.pause(),t._element.currentTime=0;for(var e=0;ethis._buffer.duration)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"loop",{get:function(){return this._loop},set:function(t){this._currentSource&&(this._currentSource.loop=t),this._loop=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"volume",{get:function(){return this._volume},set:function(t){if(this._volume=t,this._gainObj.gain.setTargetAtTime)try{this._gainObj.gain.setTargetAtTime(t,this._context.currentTime,n)}catch(e){this._gainObj.gain.setTargetAtTime(t,this._context.currentTime,.01)}else this._gainObj.gain.value=t;s.os===s.OS_IOS&&!this.paused&&this._currentSource&&(this._currentSource.onended=null,this.pause(),this.play())},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTime",{get:function(){return this.paused?this.playedLength:(this.playedLength=this._context.currentTime-this._startTime,this.playedLength%=this._buffer.duration,this.playedLength)},set:function(t){this.paused?this.playedLength=t:(this.pause(),this.playedLength=t,this.play())},enumerable:!0,configurable:!0}),Object.defineProperty(t,"duration",{get:function(){return this._buffer.duration},enumerable:!0,configurable:!0})})(u.prototype),e.exports=cc._Audio=l}),{"../core/assets/CCAudioClip":59,"../core/event/event-target":130,"../core/platform/CCSys":187}],21:[(function(t,e){"use strict";var i=t("./CCAudio"),n=t("../core/assets/CCAudioClip"),r=cc.js,s=0,o=r.createMap(!0),a={},c=[],l=function(t){t._shouldRecycleOnEnded&&(t._finishCallback=null,t.off("ended"),t.off("stop"),t.src=null,cc.sys.platform===cc.sys.ALIPAY_GAME?t.destroy():c.includes(t)||(c.length0;){var n=i.pop(),r=o[n];r&&(r.stop(),delete o[n])}},uncacheAll:function(){var t;for(var e in this.stopAll(),o)(t=o[e])&&t.destroy();for(;t=c.pop();)t.destroy();o=r.createMap(!0),a={}},_breakCache:null,_break:function(){for(var t in this._breakCache=[],o){var e=o[t];e.getState()===i.State.PLAYING&&(this._breakCache.push(t),e.pause())}},_restore:function(){if(this._breakCache){for(;this._breakCache.length>0;){var t=this._breakCache.pop(),e=h(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){t=_(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){t=_(t);var e=this._music.id;for(var i in this._effect.volume=t,o){var n=o[i];n&&n.id!==e&&f.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,o){var n=o[i];n&&n.id!==t&&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;eu.ERROR){var e=function(t){if(cc.game.canvas){if(!i){var e=document.createElement("Div");e.setAttribute("id","logInfoDiv"),e.setAttribute("width","200"),e.setAttribute("height",cc.game.canvas.height);var n=e.style;n.zIndex="99999",n.position="absolute",n.top=n.left="0",(i=document.createElement("textarea")).setAttribute("rows","20"),i.setAttribute("cols","30"),i.setAttribute("disabled","true");var r=i.style;r.backgroundColor="transparent",r.borderBottom="1px solid #cccccc",r.borderTopWidth=r.borderLeftWidth=r.borderRightWidth="0px",r.borderTopStyle=r.borderLeftStyle=r.borderRightStyle="none",r.padding="0px",r.margin=0,e.appendChild(i),cc.game.canvas.parentNode.appendChild(e)}i.value=i.value+t+"\r\n",i.scrollTop=i.scrollHeight}};cc.error=function(){e("ERROR : "+cc.js.formatStr.apply(null,arguments))},cc.assert=function(t,i){!t&&i&&(i=cc.js.formatStr.apply(null,cc.js.shiftArguments.apply(null,arguments)),e("ASSERT: "+i))},t!==u.ERROR_FOR_WEB_PAGE&&(cc.warn=function(){e("WARN : "+cc.js.formatStr.apply(null,arguments))}),t===u.INFO_FOR_WEB_PAGE&&(cc.log=function(){e(cc.js.formatStr.apply(null,arguments))})}else 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!==u.ERROR&&(console.warn.bind?cc.warn=console.warn.bind(console):cc.warn=function(){return console.warn.apply(console,arguments)}),t===u.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&&cc.game.renderType!==cc.game.RENDER_TYPE_CANVAS&&(t?cc.profiler.showStats():cc.profiler.hideStats(),cc.game.config.showFPS=!!t)}}}),{"../../DebugInfos":void 0,"./platform/utils":202}],23:[(function(t,e){"use strict";var i=t("./event/event-target"),n=t("./component-scheduler"),r=t("./node-activator"),s=t("./platform/CCObject"),o=t("./CCGame"),a=t("./renderer"),c=t("./event-manager"),l=t("./CCScheduler");cc.Director=function(){i.call(this),this._paused=!1,this._purgeDirectorInNextLoop=!1,this._winSizeInPoints=null,this._scene=null,this._loadingScene="",this._totalFrames=0,this._lastUpdate=0,this._deltaTime=0,this._startTime=0,this._maxParticleDeltaTime=0,this._scheduler=null,this._compScheduler=null,this._nodeActivator=null,this._actionManager=null;var t=this;o.on(o.EVENT_SHOW,(function(){t._lastUpdate=performance.now()})),o.once(o.EVENT_ENGINE_INITED,this.init,this)},cc.Director.prototype={constructor:cc.Director,init:function(){return this._totalFrames=0,this._lastUpdate=performance.now(),this._startTime=this._lastUpdate,this._paused=!1,this._purgeDirectorInNextLoop=!1,this._winSizeInPoints=cc.size(0,0),this._scheduler=new l,cc.ActionManager?(this._actionManager=new cc.ActionManager,this._scheduler.scheduleUpdate(this._actionManager,l.PRIORITY_SYSTEM,!1)):this._actionManager=null,this.sharedInit(),!0},sharedInit:function(){this._compScheduler=new n,this._nodeActivator=new r,c&&c.setEnabled(!0),cc.AnimationManager?(this._animationManager=new cc.AnimationManager,this._scheduler.scheduleUpdate(this._animationManager,l.PRIORITY_SYSTEM,!1)):this._animationManager=null,cc.CollisionManager?(this._collisionManager=new cc.CollisionManager,this._scheduler.scheduleUpdate(this._collisionManager,l.PRIORITY_SYSTEM,!1)):this._collisionManager=null,cc.PhysicsManager?(this._physicsManager=new cc.PhysicsManager,this._scheduler.scheduleUpdate(this._physicsManager,l.PRIORITY_SYSTEM,!1)):this._physicsManager=null,cc.Physics3DManager,this._physics3DManager=null,cc._widgetManager&&cc._widgetManager.init(this)},calculateDeltaTime:function(t){t||(t=performance.now()),this._deltaTime=t>this._lastUpdate?(t-this._lastUpdate)/1e3:0,this._lastUpdate=t},convertToGL:function(t){var e=o.container,i=cc.view,n=e.getBoundingClientRect(),r=n.left+window.pageXOffset-e.clientLeft,s=n.top+window.pageYOffset-e.clientTop,a=i._devicePixelRatio*(t.x-r),c=i._devicePixelRatio*(s+n.height-t.y);return i._isRotated?cc.v2(i._viewportRect.width-c,a):cc.v2(a,c)},convertToUI:function(t){var e=o.container,i=cc.view,n=e.getBoundingClientRect(),r=n.left+window.pageXOffset-e.clientLeft,s=n.top+window.pageYOffset-e.clientTop,a=cc.v2(0,0);return i._isRotated?(a.x=r+t.y/i._devicePixelRatio,a.y=s+n.height-(i._viewportRect.width-t.x)/i._devicePixelRatio):(a.x=r+t.x*i._devicePixelRatio,a.y=s+n.height-t.y*i._devicePixelRatio),a},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.assetManager.releaseAll()},purgeDirector:function(){this._scheduler.unscheduleAll(),this._compScheduler.unscheduleAll(),this._nodeActivator.reset(),c&&c.setEnabled(!1),cc.isValid(this._scene)&&this._scene.destroy(),this._scene=null,cc.renderer.clear(),cc.assetManager.builtins.clear(),cc.game.pause(),cc.assetManager.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),cc.game.resume()},runSceneImmediate:function(t,e,i){cc.assertID(t instanceof cc.Scene||t instanceof cc.SceneAsset,1216),t instanceof cc.SceneAsset&&(t=t.scene),t._load();for(var n=Object.keys(o._persistRootNodes).map((function(t){return o._persistRootNodes[t]})),r=0;r2||e<0)&&(t.renderMode=0),"boolean"!=typeof t.registerSystemEvent&&(t.registerSystemEvent=!0),t.showFPS=1!==e&&!!t.showFPS,this.collisionMatrix=t.collisionMatrix||[],this.groupList=t.groupList||[],n._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(n.getError(3820,e))},_initRenderer:function(){if(!this._rendererInitialized){var t,e,i,n,o=this.config.id,a=o instanceof HTMLElement?o:document.querySelector(o)||document.querySelector("#"+o);if("CANVAS"===a.tagName?(t=a.width,e=a.height,this.canvas=i=a,this.container=n=document.createElement("DIV"),i.parentNode&&i.parentNode.insertBefore(n,i)):("DIV"!==a.tagName&&cc.warnID(3819),t=a.clientWidth,e=a.clientHeight,this.canvas=i=document.createElement("CANVAS"),this.container=n=document.createElement("DIV"),a.appendChild(n)),n.setAttribute("id","Cocos2dGameContainer"),n.appendChild(i),this.frame=n.parentNode===document.body?document.documentElement:n.parentNode,(function(t){(" "+t.className+" ").indexOf(" gameCanvas ")>-1||(t.className&&(t.className+=" "),t.className+="gameCanvas")})(i),i.setAttribute("width",t||480),i.setAttribute("height",e||320),i.setAttribute("tabindex",99),this._determineRenderType(),this.renderType===this.RENDER_TYPE_WEBGL){var c={stencil:!0,antialias:cc.macro.ENABLE_WEBGL_ANTIALIAS,alpha:cc.macro.ENABLE_TRANSPARENT_CANVAS};r.initWebGL(i,c),this._renderContext=r.device._gl,!cc.macro.CLEANUP_IMAGE_CACHE&&s&&(s.enabled=!0)}this._renderContext||(this.renderType=this.RENDER_TYPE_CANVAS,r.initCanvas(i),this._renderContext=r.device._ctx),this.canvas.oncontextmenu=function(){if(!cc._isContextMenuEnable)return!1},this._rendererInitialized=!0}},_initEvents:function(){var t,e=window;this.config.registerSystemEvent&&cc.internal.inputManager.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,o.emit(o.EVENT_HIDE))}function r(t,e,n,r,s){i&&(i=!1,o.emit(o.EVENT_SHOW,t,e,n,r,s))}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(o.EVENT_HIDE,(function(){o.pause()})),this.on(o.EVENT_SHOW,(function(){o.resume()}))}};i.call(o),cc.js.addon(o,i.prototype),cc.game=e.exports=o}),{"../audio/CCAudioEngine":21,"../core/renderer/utils/dynamic-atlas/manager":void 0,"./CCDebug":22,"./event/event-target":130,"./renderer/index.js":209}],25:[(function(t,e){"use strict";var i=t("./value-types"),n=t("./value-types/utils"),r=t("./utils/base-node"),s=t("./utils/prefab-helper"),o=t("./utils/trans-pool").NodeMemPool,a=t("./utils/affine-transform"),c=t("./event-manager"),l=t("./platform/CCMacro"),u=t("./platform/js"),h=(t("./event/event"),t("./event/event-target")),_=t("./renderer/render-flow"),f=cc.Object.Flags.Destroying,d=Math.PI/180,p=!!cc.ActionManager,m=function(){},v=new i.Vec3,y=new i.Quat,g=new i.Vec3,x=new i.Vec3,A=new i.Quat,C=new i.Quat,S=new i.Vec3,b=new i.Vec3,T=new i.Vec3,w=new i.Vec3,E=new i.Vec3,B=new i.Quat,M=new i.Quat,R=new i.Vec3,P=new i.Quat,I=new i.Vec3,D=new i.Quat,V=new i.Vec3,L=new i.Vec3,O=new i.Quat,F=new i.Quat,N=(new i.Quat,cc.mat4()),G=new i.Vec3,k=new u.Pool;k.get=function(){return this._get()||[]};var z=cc.Enum({DEBUG:31}),U=cc.Enum({POSITION:1,SCALE:2,ROTATION:4,SKEW:8,TRS:7,RS:6,TRSS:15,PHYSICS_POSITION:16,PHYSICS_SCALE:32,PHYSICS_ROTATION:64,PHYSICS_TRS:112,PHYSICS_RS:96,ALL_POSITION:17,ALL_SCALE:34,ALL_ROTATION:68,ALL_TRS:119,ALL:65535}),H=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",COLOR_CHANGED:"color-changed",CHILD_ADDED:"child-added",CHILD_REMOVED:"child-removed",CHILD_REORDER:"child-reorder",GROUP_CHANGED:"group-changed",SIBLING_ORDER_CHANGED:"sibling-order-changed"}),W=[H.TOUCH_START,H.TOUCH_MOVE,H.TOUCH_END,H.TOUCH_CANCEL],j=[H.MOUSE_DOWN,H.MOUSE_ENTER,H.MOUSE_MOVE,H.MOUSE_LEAVE,H.MOUSE_UP,H.MOUSE_WHEEL],X=!0,q=function(t){if(0!==t){X&&cc.warn("`cc.Node.skewX/Y` is deprecated since v2.2.1, please use 3D node instead.",""),X=!1}},Y=null,J=function(t,e){var i=t.getLocation(),n=this.owner;return!!n._hitTest(i,this)&&(e.type=H.TOUCH_START,e.touch=t,e.bubbles=!0,n.dispatchEvent(e),!0)},Z=function(t,e){var i=this.owner;e.type=H.TOUCH_MOVE,e.touch=t,e.bubbles=!0,i.dispatchEvent(e)},K=function(t,e){var i=t.getLocation(),n=this.owner;n._hitTest(i,this)?e.type=H.TOUCH_END:e.type=H.TOUCH_CANCEL,e.touch=t,e.bubbles=!0,n.dispatchEvent(e)},Q=function(t,e){t.getLocation();var i=this.owner;e.type=H.TOUCH_CANCEL,e.touch=t,e.bubbles=!0,i.dispatchEvent(e)},$=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=H.MOUSE_DOWN,t.bubbles=!0,i.dispatchEvent(t))},tt=function(t){var e=t.getLocation(),i=this.owner;if(i._hitTest(e,this))this._previousIn||(Y&&Y._mouseListener&&(t.type=H.MOUSE_LEAVE,Y.dispatchEvent(t),Y._mouseListener._previousIn=!1),Y=this.owner,t.type=H.MOUSE_ENTER,i.dispatchEvent(t),this._previousIn=!0),t.type=H.MOUSE_MOVE,t.bubbles=!0,i.dispatchEvent(t);else{if(!this._previousIn)return;t.type=H.MOUSE_LEAVE,i.dispatchEvent(t),this._previousIn=!1,Y=null}t.stopPropagation()},et=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=H.MOUSE_UP,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())},it=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=H.MOUSE_WHEEL,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())};function nt(t,e){if(e){for(var i=0,n=null,r=t;r&&cc.Node.isNode(r);r=r._parent,++i)if(r.getComponent(e)){var s={index:i,node:r};n?n.push(s):n=[s]}return n}return null}function rt(t,e){if(!(t._objFlags&f)){if(t._bubblingListeners)for(var i=0,n=e.length;i=0;--r)if((n=i[r])._capturingListeners&&(e.currentTarget=n,n._capturingListeners.emit(e.type,e,i),e._propagationStopped))return void(i.length=0);if(i.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,i),e.eventPhase=3,r=0;r>16},set:function(t){t>l.MAX_ZINDEX?(cc.warnID(1636),t=l.MAX_ZINDEX):t0&&(this._renderFlag|=_.FLAG_CHILDREN)},_checkListenerMask:function(){if(this._touchListener){var t=this._touchListener.mask=nt(this,cc.Mask);this._mouseListener&&(this._mouseListener.mask=t)}else this._mouseListener&&(this._mouseListener.mask=nt(this,cc.Mask))},_checknSetupSysEvent:function(t){var e=!1,i=!1;return-1!==W.indexOf(t)?(this._touchListener||(this._touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,owner:this,mask:nt(this,cc.Mask),onTouchBegan:J,onTouchMoved:Z,onTouchEnded:K,onTouchCancelled:Q}),c.addListener(this._touchListener,this),e=!0),i=!0):-1!==j.indexOf(t)&&(this._mouseListener||(this._mouseListener=cc.EventListener.create({event:cc.EventListener.MOUSE,_previousIn:!1,owner:this,mask:nt(this,cc.Mask),onMouseDown:$,onMouseMove:tt,onMouseUp:et,onMouseScroll:it}),c.addListener(this._mouseListener,this),e=!0),i=!0),e&&!this._activeInHierarchy&&cc.director.getScheduler().schedule((function(){this._activeInHierarchy||c.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 H.POSITION_CHANGED:this._eventMask|=1;break;case H.SCALE_CHANGED:this._eventMask|=2;break;case H.ROTATION_CHANGED:this._eventMask|=4;break;case H.SIZE_CHANGED:this._eventMask|=8;break;case H.ANCHOR_CHANGED:this._eventMask|=16;break;case H.COLOR_CHANGED:this._eventMask|=32}return this._bubblingListeners||(this._bubblingListeners=new h),this._bubblingListeners.on(t,e,i)},once:function(t,e,i,n){var r=this,s=null;(s=this._checknSetupSysEvent(t)&&n?this._capturingListeners=this._capturingListeners||new h:this._bubblingListeners=this._bubblingListeners||new h).once(t,e,i),s.once(t,(function(){r.off(t,e,i)}),void 0)},_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 h:this._bubblingListeners=this._bubblingListeners||new h).hasEventListener(t,e,i)||(r.on(t,e,i),i&&i.__eventTargets&&i.__eventTargets.push(this)),e}cc.errorID(6800)},off:function(t,e,i,n){var r=-1!==W.indexOf(t),s=!r&&-1!==j.indexOf(t);if(r||s)this._offDispatch(t,e,i,n),r?this._touchListener&&!rt(this,W)&&(c.removeListener(this._touchListener),this._touchListener=null):s&&this._mouseListener&&!rt(this,j)&&(c.removeListener(this._mouseListener),this._mouseListener=null);else if(this._bubblingListeners&&(this._bubblingListeners.off(t,e,i),!this._bubblingListeners.hasEventListener(t)))switch(t){case H.POSITION_CHANGED:this._eventMask&=-2;break;case H.SCALE_CHANGED:this._eventMask&=-3;break;case H.ROTATION_CHANGED:this._eventMask&=-5;break;case H.SIZE_CHANGED:this._eventMask&=-9;break;case H.ANCHOR_CHANGED:this._eventMask&=-17;break;case H.COLOR_CHANGED:this._eventMask&=-33}},_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.off(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(H.POSITION_CHANGED)&&(this._eventMask&=-2),2&this._eventMask&&!e.hasEventListener(H.SCALE_CHANGED)&&(this._eventMask&=-3),4&this._eventMask&&!e.hasEventListener(H.ROTATION_CHANGED)&&(this._eventMask&=-5),8&this._eventMask&&!e.hasEventListener(H.SIZE_CHANGED)&&(this._eventMask&=-9),16&this._eventMask&&!e.hasEventListener(H.ANCHOR_CHANGED)&&(this._eventMask&=-17),32&this._eventMask&&!e.hasEventListener(H.COLOR_CHANGED)&&(this._eventMask&=-33)),this._capturingListeners&&this._capturingListeners.targetOff(t),t&&t.__eventTargets&&u.array.fastRemove(t.__eventTargets,this),this._touchListener&&!rt(this,W)&&(c.removeListener(this._touchListener),this._touchListener=null),this._mouseListener&&!rt(this,j)&&(c.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){var e=k.get();st(this,t,e),k.put(e)},pauseSystemEvents:function(t){c.pauseTarget(this,t)},resumeSystemEvents:function(t){c.resumeTarget(this,t)},_hitTest:function(t,e){var n=this._contentSize.width,r=this._contentSize.height,s=V,o=L,a=cc.Camera.findCamera(this);if(a?a.getScreenToWorldPoint(t,s):s.set(t),this._updateWorldMatrix(),!i.Mat4.invert(N,this._worldMatrix))return!1;i.Vec2.transformMat4(o,s,N),o.x+=this._anchorPoint.x*n,o.y+=this._anchorPoint.y*r;var c=!1;if(o.x>=0&&o.y>=0&&o.x<=n&&o.y<=r&&(c=!0,e&&e.mask))for(var l=e.mask,u=this,h=l?l.length:0,_=0,f=0;u&&fd.index){l.length=f;break}}return c},_getCapturingTargets:function(t,e){for(var i=this.parent;i;)i._capturingListeners&&i._capturingListeners.hasEventListener(t)&&e.push(i),i=i.parent},_getBubblingTargets:function(t,e){for(var i=this.parent;i;)i._bubblingListeners&&i._bubblingListeners.hasEventListener(t)&&e.push(i),i=i.parent},runAction:p?function(t){if(this.active){cc.assertID(t,1618);var e=cc.director.getActionManager();return e._suppressDeprecation||(e._suppressDeprecation=!0,cc.warnID(1639)),e.addAction(t,this,!1),t}}:m,pauseAllActions:p?function(){cc.director.getActionManager().pauseTarget(this)}:m,resumeAllActions:p?function(){cc.director.getActionManager().resumeTarget(this)}:m,stopAllActions:p?function(){cc.director.getActionManager().removeAllActionsFromTarget(this)}:m,stopAction:p?function(t){cc.director.getActionManager().removeAction(t)}:m,stopActionByTag:p?function(t){t!==cc.Action.TAG_INVALID?cc.director.getActionManager().removeActionByTag(t,this):cc.logID(1612)}:m,getActionByTag:p?function(t){return t===cc.Action.TAG_INVALID?(cc.logID(1613),null):cc.director.getActionManager().getActionByTag(t,this)}:function(){return null},getNumberOfRunningActions:p?function(){return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this)}:function(){return 0},getPosition:function(t){return t=t||new i.Vec3,i.Trs.toPosition(t,this._trs)},setPosition:function(t,e,i){var n;void 0===e?(n=t.x,e=t.y,i=t.z):n=t;var r=this._trs;void 0===i&&(i=r[2]),(r[0]!==n||r[1]!==e||r[2]!==i)&&(r[0]=n,r[1]=e,r[2]=i,this.setLocalDirty(U.ALL_POSITION),this._renderFlag|=_.FLAG_WORLD_TRANSFORM,1&this._eventMask&&this.emit(H.POSITION_CHANGED))},getScale:function(t){return void 0!==t?i.Trs.toScale(t,this._trs):(cc.errorID(1400,"cc.Node.getScale","cc.Node.scale or cc.Node.getScale(cc.Vec3)"),this._trs[7])},setScale:function(t,e,i){var n;t&&"number"!=typeof t?(n=t.x,e=t.y,i=t.z):void 0!==t&&void 0===e?(n=t,e=t,i=t):n=t;var r=this._trs;void 0===i&&(i=r[9]),r[7]===n&&r[8]===e&&r[9]===i||(r[7]=n,r[8]=e,r[9]=i,this.setLocalDirty(U.ALL_SCALE),this._renderFlag|=_.FLAG_TRANSFORM,2&this._eventMask&&this.emit(H.SCALE_CHANGED))},getRotation:function(t){return t instanceof i.Quat?i.Trs.toRotation(t,this._trs):-this.angle},setRotation:function(t,e,i,n){if("number"==typeof t&&void 0===e)this.angle=-t;else{var r=t;void 0===e&&(r=t.x,e=t.y,i=t.z,n=t.w);var s=this._trs;s[3]===r&&s[4]===e&&s[5]===i&&s[6]===n||(s[3]=r,s[4]=e,s[5]=i,s[6]=n,this.setLocalDirty(U.ALL_ROTATION),4&this._eventMask&&this.emit(H.ROTATION_CHANGED))}},getContentSize:function(){return cc.size(this._contentSize.width,this._contentSize.height)},setContentSize:function(t,e){var i=this._contentSize;if(void 0===e){if((0,n.approx)(t.width,i.width)&&(0,n.approx)(t.height,i.height))return;i.width=t.width,i.height=t.height}else{if((0,n.approx)(t,i.width)&&(0,n.approx)(e,i.height))return;i.width=t,i.height=e}8&this._eventMask&&this.emit(H.SIZE_CHANGED)},getAnchorPoint:function(){return cc.v2(this._anchorPoint)},setAnchorPoint:function(t,e){var i=this._anchorPoint;if(void 0===e){if(t.x===i.x&&t.y===i.y)return;i.x=t.x,i.y=t.y}else{if(t===i.x&&e===i.y)return;i.x=t,i.y=e}this.setLocalDirty(U.ALL_POSITION),16&this._eventMask&&this.emit(H.ANCHOR_CHANGED)},_invTransformPoint:function(t,e){this._parent?this._parent._invTransformPoint(t,e):i.Vec3.copy(t,e);var n=this._trs;return i.Trs.toPosition(g,n),i.Vec3.sub(t,t,g),i.Trs.toRotation(A,n),i.Quat.conjugate(C,A),i.Vec3.transformQuat(t,t,C),i.Trs.toScale(g,n),i.Vec3.inverseSafe(x,g),i.Vec3.mul(t,t,x),t},getWorldPosition:function(t){i.Trs.toPosition(t,this._trs);for(var e,n=this._parent;n;)e=n._trs,i.Trs.toScale(v,e),i.Vec3.mul(t,t,v),i.Trs.toRotation(y,e),i.Vec3.transformQuat(t,t,y),i.Trs.toPosition(v,e),i.Vec3.add(t,t,v),n=n._parent;return t},setWorldPosition:function(t){var e=this._trs;this._parent?this._parent._invTransformPoint(S,t):i.Vec3.copy(S,t),i.Trs.fromPosition(e,S),this.setLocalDirty(U.ALL_POSITION),1&this._eventMask&&this.emit(H.POSITION_CHANGED)},getWorldRotation:function(t){i.Trs.toRotation(O,this._trs),i.Quat.copy(t,O);for(var e=this._parent;e;)i.Trs.toRotation(O,e._trs),i.Quat.mul(t,O,t),e=e._parent;return t},setWorldRotation:function(t){this._parent?(this._parent.getWorldRotation(F),i.Quat.conjugate(F,F),i.Quat.mul(F,F,t)):i.Quat.copy(F,t),i.Trs.fromRotation(this._trs,F),this.setLocalDirty(U.ALL_ROTATION)},getWorldScale:function(t){i.Trs.toScale(b,this._trs),i.Vec3.copy(t,b);for(var e=this._parent;e;)i.Trs.toScale(b,e._trs),i.Vec3.mul(t,t,b),e=e._parent;return t},setWorldScale:function(t){this._parent?(this._parent.getWorldScale(T),i.Vec3.div(T,t,T)):i.Vec3.copy(T,t),i.Trs.fromScale(this._trs,T),this.setLocalDirty(U.ALL_SCALE)},getWorldRT:function(t){var e=w,n=B,r=this._trs;i.Trs.toPosition(e,r),i.Trs.toRotation(n,r);for(var s=this._parent;s;)r=s._trs,i.Trs.toScale(E,r),i.Vec3.mul(e,e,E),i.Trs.toRotation(M,r),i.Vec3.transformQuat(e,e,M),i.Trs.toPosition(E,r),i.Vec3.add(e,e,E),i.Quat.mul(n,M,n),s=s._parent;return i.Mat4.fromRT(t,n,e),t},lookAt:function(t,e){this.getWorldPosition(R),i.Vec3.sub(R,R,t),i.Vec3.normalize(R,R),i.Quat.fromViewUp(P,R,e),this.setWorldRotation(P)},_updateLocalMatrix:lt,_calculWorldMatrix:function(){this._localMatDirty&U.TRSS&&this._updateLocalMatrix();var t=this._parent;t?this._mulMat(this._worldMatrix,t._worldMatrix,this._matrix):i.Mat4.copy(this._worldMatrix,this._matrix),this._worldMatDirty=!1},_mulMat:_t,_updateWorldMatrix:function(){if(this._parent&&this._parent._updateWorldMatrix(),this._worldMatDirty){this._calculWorldMatrix();for(var t=this._children,e=0,i=t.length;e1){for(var n,r,s=1,o=t.length;s0&&(r=t[a-1])._localZOrder>n._localZOrder;a--)t[a]=r;t[a]=n}this.emit(H.CHILD_REORDER,this)}cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE,this.sortAllChildren,this)}},_delaySort:function(){this._reorderChildDirty||(this._reorderChildDirty=!0,cc.director.__fastOn(cc.Director.EVENT_AFTER_UPDATE,this.sortAllChildren,this))},_restoreProperties:!1,onRestore:!1},pt=cc.Class(dt),mt=pt.prototype;u.getset(mt,"position",mt.getPosition,mt.setPosition,!1,!0),cc.Node=e.exports=pt}),{"./event-manager":128,"./event/event":131,"./event/event-target":130,"./platform/CCMacro":183,"./platform/js":199,"./renderer/render-flow":210,"./utils/affine-transform":242,"./utils/base-node":243,"./utils/prefab-helper":254,"./utils/trans-pool":260,"./value-types":266,"./value-types/utils":273}],26:[(function(t,e){"use strict";var i=t("./CCNode"),n=t("./renderer/render-flow"),r=(cc.Object.Flags.HideInHierarchy,i._LocalDirtyFlag),s=cc.Class({name:"cc.PrivateNode",extends:i,properties:{x:{get:function(){return this._originPos.x},set:function(t){var e=this._originPos;t!==e.x&&(e.x=t,this._posDirty(!0))},override:!0},y:{get:function(){return this._originPos.y},set:function(t){var e=this._originPos;t!==e.y&&(e.y=t,this._posDirty(!0))},override:!0},zIndex:{get:function(){return cc.macro.MIN_ZINDEX},set:function(){},override:!0},showInEditor:{default:!1,editorOnly:!0,override:!0}},ctor:function(){this._localZOrder=cc.macro.MIN_ZINDEX<<16,this._originPos=cc.v2()},_posDirty:function(t){this.setLocalDirty(r.POSITION),this._renderFlag|=n.FLAG_TRANSFORM,!0===t&&1&this._eventMask&&this.emit(i.EventType.POSITION_CHANGED)},_updateLocalMatrix:function(){if(this._localMatDirty){var t=this.parent;t&&(this._trs[0]=this._originPos.x-(t._anchorPoint.x-.5)*t._contentSize.width,this._trs[1]=this._originPos.y-(t._anchorPoint.y-.5)*t._contentSize.height),this._super()}},getPosition:function(){return new cc.Vec2(this._originPos)},setPosition:function(t,e){void 0===e&&(e=(t=t.x).y);var i=this._originPos;i.x===t&&i.y===e||(i.x=t,i.y=e,this._posDirty(!0))},setParent:function(t){var e=this._parent;this._super(t),e!==t&&(e&&e.off(i.EventType.ANCHOR_CHANGED,this._posDirty,this),t&&t.on(i.EventType.ANCHOR_CHANGED,this._posDirty,this))},_updateOrderOfArrival:function(){}}),o=s.prototype;cc.js.getset(o,"parent",o.getParent,o.setParent),cc.js.getset(o,"position",o.getPosition,o.setPosition),cc.PrivateNode=e.exports=s}),{"./CCNode":25,"./renderer/render-flow":210}],27:[(function(t,e){"use strict";cc.Scene=cc.Class({name:"cc.Scene",extends:t("./CCNode"),properties:{_is3DNode:{default:!0,override:!0},autoReleaseAssets:!1},ctor:function(){this._anchorPoint.x=0,this._anchorPoint.y=0,this._activeInHierarchy=!1,this._inited=!cc.game._isCloning,this.dependAssets=null},destroy:function(){if(cc.Object.prototype.destroy.call(this))for(var t=this._children,e=0;e0,this._repeat=r,this._runForever=this._repeat===cc.macro.REPEAT_FOREVER,!0},h.getInterval=function(){return this._interval},h.setInterval=function(t){this._interval=t},h.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()))},h.getCallback=function(){return this._callback},h.trigger=function(){this._target&&this._callback&&(this._lock=!0,this._callback.call(this._target,this._elapsed),this._lock=!1)},h.cancel=function(){this._scheduler.unschedule(this._callback,this._target)};var _=[];u.get=function(){return _.pop()||new u},u.put=function(t){_.length<20&&!t._lock&&(t._scheduler=t._target=t._callback=null,_.push(t))},cc.Scheduler=function(){this._timeScale=1,this._updatesNegList=[],this._updates0List=[],this._updatesPosList=[],this._hashForUpdates=i.createMap(!0),this._hashForTimers=i.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;e1?n:n[0]}},cc.AssetManager=V,cc.assetManager=new V,Object.defineProperty(cc,"resources",{get:function(){return I.get(D.RESOURCES)}}),e.exports=cc.assetManager}),{"./builtins":30,"./bundle":31,"./cache":32,"./depend-util":34,"./downloader":41,"./factory":42,"./fetch":43,"./helper":45,"./load":47,"./pack-manager":48,"./parser":49,"./pipeline":50,"./preprocess":51,"./releaseManager":52,"./request-item":53,"./shared":54,"./task":55,"./urlTransformer":56,"./utilities":57}],30:[(function(t,e){"use strict";var i=t("./cache"),n=t("./releaseManager"),r=t("./shared").BuiltinBundleName,s={_assets:new i({material:new i,effect:new i}),_loadBuiltins:function(t,e){var i=t+"s",n=this._assets.get(t);return cc.assetManager.internal.loadDir(i,null,null,(function(t,i){if(t)cc.error(t.message,t.stack);else for(var r=0;re.length)||47===t.charCodeAt(e.length)}return this.paths.forEach((function(n,r){if(r.startsWith(t)&&o(r,t)||!t)for(var a=0,c=n.length;a1){var f=Object.create(null);n.forEach((function(t){f[t._uuid]=t})),r={isCompleted:u,_map:f}}else r=n[0]}i&&i(e,r)}))},getXMLHttpRequest:function(){return new XMLHttpRequest},_parseLoadResArgs:i.parseLoadResArgs,getItem:function(t){return cc.assetManager.assets.has(t)?{content:cc.assetManager.assets.get(t)}:null},loadRes:function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=(e=r.type,r.onProgress),o=r.onComplete,a=cc.path.extname(t);a&&(t=t.slice(0,-a.length)),cc.resources.load(t,e,s,o)},loadResArray:function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=(e=r.type,r.onProgress),o=r.onComplete;t.forEach((function(e,i){var n=cc.path.extname(e);n&&(t[i]=e.slice(0,-n.length))})),cc.resources.load(t,e,s,o)},loadResDir:function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=(e=r.type,r.onProgress),o=r.onComplete;cc.resources.loadDir(t,e,s,(function(i,n){var r=[];i||(r=cc.resources.getDirWithPath(t,e).map((function(t){return t.path}))),o&&o(i,n,r)}))},getRes:function(t,e){return cc.assetManager.assets.has(t)?cc.assetManager.assets.get(t):cc.resources.get(t,e)},getResCount:function(){return cc.assetManager.assets.count},getDependsRecursively:function(t){return t?n.getDepsRecursively("string"==typeof t?t:t._uuid).concat([t._uuid]):[]},get assetLoader(){},get md5Pipe(){return h},get downloader(){return cc.assetManager.downloader},get loader(){return cc.assetManager.parser},addDownloadHandlers:function(t){var e=Object.create(null);for(var i in t){var n=t[i];e["."+i]=function(t,e,i){n({url:t},i)}}cc.assetManager.downloader.register(e)},addLoadHandlers:function(t){var e=Object.create(null);for(var i in t){var n=t[i];e["."+i]=function(t,e,i){n({content:t},i)}}cc.assetManager.parser.register(e)},flowInDeps:function(){},release:function(t){if(Array.isArray(t))for(var e=0;eL._maxInterval?L._maxInterval:cc.director._deltaTime;t-P>1e3*e&&(R=0,P=t)},V=function t(e,i){for(I=!1,D();E.length>0&&M0&&M0&&(s(V,y,g),I=!0),o.apply(this,arguments)}))}D(),M0){var i=n.create({name:t.name+" dependencies",input:c,progress:f,options:s,onProgress:t.onProgress,onError:n.prototype.recycle,onComplete:function(n){n||(t.output.push.apply(t.output,this.output),i.recycle()),r&&h(t),e(n)}});u.async(i)}else r&&h(t),e()}))}}),{"./pack-manager":48,"./shared":54,"./task":55,"./utilities":57}],44:[(function(t,e){"use strict";var i,n=t("../utils/text-utils"),r=null,s="BES bswy:->@123\u4e01\u3041\u1101",o=Object.create(null),a=-1,c=[],l=3e3,u=(i=void 0,function(){if(void 0===i)if(window.FontFace){var t=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),e=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);i=t?parseInt(t[1],10)>42:!e}else i=!1;return i});function h(){for(var t=!0,e=Date.now(),i=c.length-1;i>=0;i--){var o=c[i],u=o.fontFamilyName;if(e-o.startTime>l)cc.warnID(4933,u),o.onComplete(null,u),c.splice(i,1);else{var h=o.refWidth,_="40px "+u;r.font=_,h!==n.safeMeasureText(r,s,_)?(c.splice(i,1),o.onComplete(null,u)):t=!1}}t&&(clearInterval(a),a=-1)}var _={loadFont:function(t,e,i){var f=_._getFontFamily(t);if(o[f])return i(null,f);if(!r){var d=document.createElement("canvas");d.width=100,d.height=100,r=d.getContext("2d")}var p="40px "+f;r.font=p;var m=n.safeMeasureText(r,s,p),v=document.createElement("style");v.type="text/css";var y="";isNaN(f-0)?y+="@font-face { font-family:"+f+"; src:":y+="@font-face { font-family:'"+f+"'; src:",y+="url('"+t+"');",v.textContent=y+"}",document.body.appendChild(v);var g,x,A,C,S,b,T=document.createElement("div"),w=T.style;if(w.fontFamily=f,T.innerHTML=".",w.position="absolute",w.left="-100px",w.top="-100px",document.body.appendChild(T),u())g=Date.now(),x=f,A=i,C=new Promise(function(t,e){(function i(){Date.now()-g>=l?e():document.fonts.load("40px "+x).then((function(e){e.length>=1?t():setTimeout(i,100)}),(function(){e()}))})()}),S=null,b=new Promise(function(t,e){S=setTimeout(e,l)}),Promise.race([b,C]).then((function(){S&&(clearTimeout(S),S=null),A(null,x)}),(function(){cc.warnID(4933,x),A(null,x)}));else{var E={fontFamilyName:f,refWidth:m,onComplete:i,startTime:Date.now()};c.push(E),-1===a&&(a=setInterval(h,100))}o[f]=v},_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=_}),{"../utils/text-utils":258}],45:[(function(t,e){"use strict";var i,n=t("./shared").bundles,r={decodeUuid:t("../utils/decode-uuid"),getUuidFromURL:(i=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-]{8,})/,function(t){var e=t.match(i);return e?e[1]:""}),getUrlWithUuid:function(t,e){(e=e||Object.create(null)).__isNative__=e.isNative,e.ext=e.nativeExt;var i=n.find((function(e){return e.getAssetInfo(t)}));return i&&(e.bundle=i.name),cc.assetManager._transform(t,e)},isScene:function(t){return t&&(t.constructor===cc.SceneAsset||t instanceof cc.Scene)},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}};e.exports=r}),{"../utils/decode-uuid":246,"./shared":54}],46:[(function(t){"use strict";t("./deprecated"),t("./CCAssetManager")}),{"./CCAssetManager":29,"./deprecated":35}],47:[(function(t,e){"use strict";var i=t("./pack-manager"),n=t("./pipeline"),r=t("./parser"),s=t("./utilities"),o=s.getDepends,a=s.cache,c=s.gatherAsset,l=s.setProperties,u=s.forEach,h=s.clear,_=s.checkCircleReference,f=t("./shared"),d=f.assets,p=f.files,m=f.parsed,v=f.pipeline,y=t("./task"),g=new n("loadOneAsset",[function(t,e){var n=t.output=t.input,r=n.options,s=n.isNative,o=n.uuid,a=n.file,c=r.reload;if(a||!c&&!s&&d.has(o))return e();i.load(n,t.options,(function(t,i){n.file=i,e(t)}))},function(t,e){var i=t.output=t.input,n=t.progress,s=t.options.__exclude__,o=i.id,a=i.file,c=i.options;if(i.isNative)r.parse(o,a,i.ext,c,(function(r,s){if(r)return e(r);i.content=s,n.canInvoke&&t.dispatch("progress",++n.finish,n.total,i),p.remove(o),m.remove(o),e()}));else{var l=i.uuid;if(l in s){var u=s[l],h=u.finish,f=u.content,v=u.err,y=u.callbacks;n.canInvoke&&t.dispatch("progress",++n.finish,n.total,i),h||_(l,l,s)?(f&&f.addRef&&f.addRef(),i.content=f,e(v)):y.push({done:e,item:i})}else if(!c.reload&&d.has(l)){var g=d.get(l);c.__asyncLoadAssets__||!g.__asyncLoadAssets__?(i.content=g.addRef(),n.canInvoke&&t.dispatch("progress",++n.finish,n.total,i),e()):x(t,g,e,!1)}else r.parse(o,a,"import",c,(function(i,n){if(i)return e(i);n._uuid=l,x(t,n,e,!0)}))}}]);function x(t,e,i,n){var r=t.input,s=t.progress,c=r.uuid,u=r.id,h=r.options,_=r.config,f=h.__asyncLoadAssets__,d=h.cacheAsset,g=[];e.addRef&&e.addRef(),o(c,e,Object.create(null),g,!1,f,_),s.canInvoke&&t.dispatch("progress",++s.finish,s.total+=g.length,r);var x=t.options.__exclude__[c]={content:e,finish:!1,callbacks:[{done:i,item:r}]},A=y.create({input:g,options:t.options,onProgress:t.onProgress,onError:y.prototype.recycle,progress:s,onComplete:function(t){if(e.decRef&&e.decRef(!1),e.__asyncLoadAssets__=f,x.finish=!0,x.err=t,!t){for(var i=Array.isArray(A.output)?A.output:[A.output],r=Object.create(null),s=0,o=i.length;s6||l<3||l>6||u<3||u>6)&&(c<4||7===c||9===c||11===c||c>12||l<4||7===l||9===l||11===l||l>12||1!==u))return new Error("Invalid block number in ASTC header");var h=t(c,l),_=a[7]+(a[8]<<8)+(a[9]<<16),f=a[10]+(a[11]<<8)+(a[12]<<16);a[13],a[14],a[15],s={_data:new Uint8Array(o,16),_compressed:!0,width:_,height:f,format:h}}catch(d){r=d}n(r,s)}})(),parsePlist:function(t,e,n){var r=null,s=i.parse(t);s||(r=new Error("parse failed")),n&&n(r,s)},parseImport:function(t,e,i){if(!t)return i&&i(new Error("Json is empty"));var n,s=null;try{n=r(t,e)}catch(o){s=o}i&&i(s,n)},init:function(){f.clear()},register:function(t,e){"object"==typeof t?n.mixin(p,t):p[t]=e},parse:function(t,e,i,n,r){var s,a,u;(s=c.get(t))?r(null,s):(a=f.get(t))?a.push(r):(u=p[i])?(f.add(t,[r]),u(e,n,(function(e,i){e?l.remove(t):o(i)||c.add(t,i);for(var n=f.remove(t),r=0,s=n.length;rthis.pipes.length))return this.pipes.splice(e,0,t),this;cc.warnID(4921)},append:function(t){if("function"==typeof t)return this.pipes.push(t),this},remove:function(t){if("number"==typeof t)return this.pipes.splice(t,1),this},sync:function(t){var e=this.pipes;if(t instanceof i&&0!==e.length){null!=t.output&&(t.input=t.output,t.output=null),t._isFinish=!1;for(var n=0,r=e.length;n0&&h(t)>0)){r.remove(t._uuid);for(var n=i.getDeps(t._uuid),s=0,o=n.length;s0&&this._ref--,!1!==t&&cc.assetManager._releaseManager.tryRelease(this),this},destroy:function(){return this.loaded=!1,this._super()}}),e.exports=cc.Asset}),{"../platform/CCObject":184}],59:[(function(t,e){"use strict";var i=t("./CCAsset"),n=t("../event/event-target"),r=cc.Enum({WEB_AUDIO:0,DOM_AUDIO:1}),s=cc.Class({name:"cc.AudioClip",extends:i,mixins:[n],ctor:function(){this._loading=!1,this.loaded=!1,this._audio=null},properties:{duration:0,loadMode:{default:r.WEB_AUDIO,type:r},_nativeAsset:{get:function(){return this._audio},set:function(t){t instanceof cc.AudioClip?this._audio=t._nativeAsset:this._audio=t,this._audio&&(this.loaded=!0,this.emit("load"))},override:!0},_nativeDep:{get:function(){return{uuid:this._uuid,audioLoadMode:this.loadMode,ext:cc.path.extname(this._native),__isNative__:!0}},override:!0}},statics:{LoadMode:r,_loadByUrl:function(t,e){var i=cc.assetManager.assets.get(t);i?e(null,i):cc.assetManager.loadRemote(t,(function(t,i){if(t)return e(t);e(null,i)}))}},_ensureLoaded:function(t){if(this.isValid){if(this.loaded)return t&&t();if(t&&this.once("load",t),!this._loading){this._loading=!0;var e=this;cc.assetManager.postLoadNative(this,(function(){e._loading=!1}))}}},destroy:function(){cc.audioEngine.uncache(this),this._super()}});cc.AudioClip=s,e.exports=s}),{"../event/event-target":130,"./CCAsset":58}],60:[(function(t,e){"use strict";var i=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.offsetX=0,this.offsetY=0,this.textureID=0,this.valid=!1,this.xAdvance=0},n=function(t){this._letterDefinitions={},this._texture=t};n.prototype={constructor:n,addLetterDefinitions:function(t,e){this._letterDefinitions[t]=e},cloneLetterDefinition:function(){var t={};for(var e in this._letterDefinitions){var n=new i;cc.js.mixin(n,this._letterDefinitions[e]),t[e]=n}return t},getTexture:function(){return this._texture},getLetter:function(t){return this._letterDefinitions[t]},getLetterDefinitionForChar:function(t){var e=t.charCodeAt(0);return this._letterDefinitions.hasOwnProperty(e)?this._letterDefinitions[e]:null},clear:function(){this._letterDefinitions={}}};var r=cc.Class({name:"cc.BitmapFont",extends:cc.Font,properties:{fntDataStr:{default:""},spriteFrame:{default:null,type:cc.SpriteFrame},fontSize:{default:-1},_fntConfig:null,_fontDefDictionary:null},onLoad:function(){var t=this.spriteFrame;this._fontDefDictionary||(this._fontDefDictionary=new n,t&&(this._fontDefDictionary._texture=t._texture));var e=this._fntConfig;if(e){var r=e.fontDefDictionary;for(var s in r){var o=new i,a=r[s].rect;o.offsetX=r[s].xOffset,o.offsetY=r[s].yOffset,o.w=a.width,o.h=a.height,o.u=a.x,o.v=a.y,o.textureID=0,o.valid=!0,o.xAdvance=r[s].xAdvance,this._fontDefDictionary.addLetterDefinitions(s,o)}}}});cc.BitmapFont=r,cc.BitmapFont.FontLetterDefinition=i,cc.BitmapFont.FontAtlas=n,e.exports=r}),{}],61:[(function(t,e){"use strict";var i=cc.Class({name:"cc.BufferAsset",extends:cc.Asset,ctor:function(){this._buffer=null},properties:{_nativeAsset:{get:function(){return this._buffer},set:function(t){this._buffer=t.buffer||t},override:!0},buffer:function(){return this._buffer}}});cc.BufferAsset=e.exports=i}),{}],62:[(function(t,e){"use strict";var i=cc.Class({name:"cc.Font",extends:cc.Asset});cc.Font=e.exports=i}),{}],63:[(function(t,e){"use strict";var i=cc.Class({name:"cc.JsonAsset",extends:cc.Asset,properties:{json:null}});e.exports=cc.JsonAsset=i}),{}],64:[(function(t,e){"use strict";var i=cc.Class({name:"cc.LabelAtlas",extends:cc.BitmapFont,onLoad:function(){this.spriteFrame?this._fntConfig?this._super():cc.warnID(9101,this.name):cc.warnID(9100,this.name)}});cc.LabelAtlas=i,e.exports=i}),{}],65:[(function(t,e){"use strict";var i=cc.Enum({AUTO:0,SINGLE_INSTANCE:1,MULTI_INSTANCE:2}),n=cc.Class({name:"cc.Prefab",extends:cc.Asset,ctor:function(){this._createFunction=null,this._instantiatedTimes=0},properties:{data:null,optimizationPolicy:i.AUTO,asyncLoadAssets:!1,readonly:{default:!1,editorOnly:!0}},statics:{OptimizationPolicy:i,OptimizationPolicyThreshold:3},createNode:!1,compileCreateFunction:function(){var e=t("../platform/instantiate-jit");this._createFunction=e.compile(this.data)},_doInstantiate:function(t){return this.data._prefab||cc.warnID(3700),this._createFunction||this.compileCreateFunction(),this._createFunction(t)},_instantiate:function(){var t;return t=this.data._instantiate(),++this._instantiatedTimes,t},destroy:function(){this.data&&this.data.destroy(),this._super()}});cc.Prefab=e.exports=n,cc.js.obsolete(cc,"cc._Prefab","Prefab")}),{"../platform/instantiate-jit":197}],66:[(function(t,e){"use strict";var i,n=(i=t("../../renderer/gfx"))&&i.__esModule?i:{default:i},r=t("../renderer"),s=t("./CCTexture2D"),o=cc.Enum({RB_FMT_D24S8:n.default.RB_FMT_D24S8,RB_FMT_S8:n.default.RB_FMT_S8,RB_FMT_D16:n.default.RB_FMT_D16}),a=cc.Class({name:"cc.RenderTexture",extends:s,statics:{DepthStencilFormat: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),this._resetUnderlyingMipmaps();var s,o={colors:[this._texture]};this._depthStencilBuffer&&this._depthStencilBuffer.destroy(),i&&(s=new n.default.RenderBuffer(r.device,i,t,e),i===n.default.RB_FMT_D24S8?o.depthStencil=s:i===n.default.RB_FMT_S8?o.stencil=s:i===n.default.RB_FMT_D16&&(o.depth=s)),this._depthStencilBuffer=s,this._framebuffer&&this._framebuffer.destroy(),this._framebuffer=new n.default.FrameBuffer(r.device,t,e,o),this._packable=!1,this.loaded=!0,this.emit("load")},updateSize:function(t,e){this.width=Math.floor(t||cc.visibleRect.width),this.height=Math.floor(e||cc.visibleRect.height),this._resetUnderlyingMipmaps();var i=this._depthStencilBuffer;i&&i.update(this.width,this.height),this._framebuffer._width=t,this._framebuffer._height=e},drawTextureAt:function(t,e,i){t._image&&0!==t._image.width&&this._texture.updateSubImage({x:e,y:i,image:t._image,width:t.width,height:t.height,level:0,flipY:!1,premultiplyAlpha:t._premultiplyAlpha})},readPixels:function(t,e,i,n,r){if(!this._framebuffer||!this._texture)return t;e=e||0,i=i||0;var s=n||this.width,o=r||this.height;t=t||new Uint8Array(s*o*4);var a=cc.game._renderContext,c=a.getParameter(a.FRAMEBUFFER_BINDING);return a.bindFramebuffer(a.FRAMEBUFFER,this._framebuffer.getHandle()),a.readPixels(e,i,s,o,a.RGBA,a.UNSIGNED_BYTE,t),a.bindFramebuffer(a.FRAMEBUFFER,c),t},destroy:function(){this._super(),this._framebuffer&&(this._framebuffer.destroy(),this._framebuffer=null)}});cc.RenderTexture=e.exports=a}),{"../../renderer/gfx":293,"../renderer":209,"./CCTexture2D":73}],67:[(function(t,e){"use strict";var i=cc.Class({name:"cc.SceneAsset",extends:cc.Asset,properties:{scene:null,asyncLoadAssets:void 0}});cc.SceneAsset=i,e.exports=i}),{}],68:[(function(){"use strict";var t=cc.Class({name:"cc.Script",extends:cc.Asset});cc._Script=t;var e=cc.Class({name:"cc.JavaScript",extends:t});cc._JavaScript=e;var i=cc.Class({name:"cc.TypeScript",extends:t});cc._TypeScript=i}),{}],69:[(function(t,e){"use strict";var i=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=i,e.exports=i}),{}],70:[(function(t,e){"use strict";var i=t("../event/event-target"),n=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],r=cc.Class({name:"cc.SpriteFrame",extends:t("../assets/CCAsset"),mixins:[i],properties:{_textureSetter:{set:function(t){t&&this._texture!==t&&this._refreshTexture(t)}},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(){i.call(this);var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3],s=arguments[4];this._rect=null,this.uv=[],this._texture=null,this._original=null,this._offset=null,this._originalSize=null,this._rotated=!1,this._flipX=!1,this._flipY=!1,this.vertices=null,this._capInsets=[0,0,0,0],this.uvSliced=[],void 0!==t&&this.setTexture(t,e,n,r,s)},textureLoaded:function(){return this._texture&&this._texture.loaded},onTextureLoaded:function(t,e){return this.textureLoaded()?(t.call(e),!0):(this.once("load",t,e),this.ensureLoadTexture(),!1)},isRotated:function(){return this._rotated},setRotated:function(t){this._rotated=t,this._texture&&this._calculateUV()},isFlipX:function(){return this._flipX},isFlipY:function(){return this._flipY},setFlipX:function(t){this._flipX=t,this._texture&&this._calculateUV()},setFlipY:function(t){this._flipY=t,this._texture&&this._calculateUV()},getRect:function(){return cc.rect(this._rect)},setRect:function(t){this._rect=t,this._texture&&this._calculateUV()},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._rect?this._checkRect(this._texture):this._rect=cc.rect(0,0,e,i),this._originalSize||(this._originalSize=cc.size(e,i)),this._offset||(this._offset=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 r(this._texture,this.getRect(),this._rotated,this.getOffset(),this.getOriginalSize())},setTexture:function(t,e,i,n,r){if(1!==arguments.length||t!==this._texture){if(this._rect=e||null,n?this.setOffset(n):this._offset=null,r?this.setOriginalSize(r):this._originalSize=null,this._rotated=i||!1,"string"!=typeof t)return t instanceof cc.Texture2D&&this._refreshTexture(t),!0;cc.errorID(3401)}},ensureLoadTexture:function(){this._texture&&(this._texture.loaded||(this._refreshTexture(this._texture),cc.assetManager.postLoadNative(this._texture)))},_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.nativeUrl+"/"+this.name,i,t.width),n>t.height&&cc.errorID(3400,t.nativeUrl+"/"+this.name,n,t.height)},_flipXY:function(t){if(this._flipX){var e=t[0];t[0]=t[1],t[1]=e,e=t[2],t[2]=t[3],t[3]=e}if(this._flipY){var i=t[0];t[0]=t[2],t[2]=i,i=t[1],t[1]=t[3],t[3]=i}},_calculateSlicedUV:function(){var t=this._rect,e=this._texture.width,i=this._texture.height,r=this._capInsets[0],s=this._capInsets[2],o=t.width-r-s,a=this._capInsets[1],c=this._capInsets[3],l=t.height-a-c,u=this.uvSliced;if(u.length=0,this._rotated){n[0].u=t.x/e,n[1].u=(t.x+c)/e,n[2].u=(t.x+c+l)/e,n[3].u=(t.x+t.height)/e,n[3].v=t.y/i,n[2].v=(t.y+r)/i,n[1].v=(t.y+r+o)/i,n[0].v=(t.y+t.width)/i,this._flipXY(n);for(var h=0;h<4;++h)for(var _=n[h],f=0;f<4;++f){var d=n[3-f];u.push({u:_.u,v:d.v})}}else{n[0].u=t.x/e,n[1].u=(t.x+r)/e,n[2].u=(t.x+r+o)/e,n[3].u=(t.x+t.width)/e,n[3].v=t.y/i,n[2].v=(t.y+a)/i,n[1].v=(t.y+a+l)/i,n[0].v=(t.y+t.height)/i,this._flipXY(n);for(var p=0;p<4;++p)for(var m=n[p],v=0;v<4;++v){var y=n[v];u.push({u:y.u,v:m.v})}}},_setDynamicAtlasFrame:function(t){t&&(this._original={_texture:this._texture,_x:this._rect.x,_y:this._rect.y},this._texture=t.texture,this._rect.x=t.x,this._rect.y=t.y,this._calculateUV())},_resetDynamicAtlasFrame:function(){this._original&&(this._rect.x=this._original._x,this._rect.y=this._original._y,this._texture=this._original._texture,this._original=null,this._texture.loaded?this._calculateUV():this.ensureLoadTexture())},_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,c=0===r?0:t.y/r;i[0]=s,i[1]=c,i[2]=s,i[3]=a,i[4]=o,i[5]=c,i[6]=o,i[7]=a}else{var l=0===n?0:t.x/n,u=0===n?0:(t.x+t.width)/n,h=0===r?0:(t.y+t.height)/r,_=0===r?0:t.y/r;i[0]=l,i[1]=h,i[2]=u,i[3]=h,i[4]=l,i[5]=_,i[6]=u,i[7]=_}if(this._flipX){var f=i[0];i[0]=i[2],i[2]=f,f=i[1],i[1]=i[3],i[3]=f,f=i[4],i[4]=i[6],i[6]=f,f=i[5],i[5]=i[7],i[7]=f}if(this._flipY){var d=i[0];i[0]=i[4],i[4]=d,d=i[1],i[1]=i[5],i[5]=d,d=i[2],i[2]=i[6],i[6]=d,d=i[3],i[3]=i[7],i[7]=d}var p=this.vertices;if(p){p.nu.length=0,p.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)),this._texture&&this._texture.update(t),this._hashDirty=!0},initWithElement:function(t){if(t)if(this._image=t,t.complete||t instanceof HTMLCanvasElement)this.handleLoadedTexture();else if(cc.sys.capabilities.imageBitmap&&t instanceof ImageBitmap)this._checkImageBitmap(this.handleLoadedTexture.bind(this));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=d();return r.image=t,r.images=[r.image],r.genMipmaps=this._genMipmaps,r.premultiplyAlpha=this._premultiplyAlpha,r.flipY=this._flipY,r.minFilter=h[this._minFilter],r.magFilter=h[this._magFilter],r.wrapS=this._wrapS,r.wrapT=this._wrapT,r.format=this._getGFXPixelFormat(e),r.width=i,r.height=n,this._texture?this._texture.update(r):this._texture=new s.Texture2D(s.device,r),this.width=i,this.height=n,this._updateFormat(),this._checkPackable(),this.loaded=!0,this.emit("load"),!0},getHtmlElementObj:function(){return this._image},destroy:function(){cc.sys.capabilities.imageBitmap&&this._image instanceof ImageBitmap&&this._image.close&&this._image.close(),this._packable&&cc.dynamicAtlasManager&&cc.dynamicAtlasManager.deleteAtlasTexture(this),this._image=null,this._texture&&this._texture.destroy(),this._super()},getPixelFormat:function(){return this._format},hasPremultipliedAlpha:function(){return this._premultiplyAlpha||!1},isAlphaAtlas:function(){return this._isAlphaAtlas},handleLoadedTexture:function(){if(this._image&&this._image.width&&this._image.height){this.width=this._image.width,this.height=this._image.height;var t=d();t.image=this._image,t.images=[t.image],t.width=this.width,t.height=this.height,t.genMipmaps=this._genMipmaps,t.format=this._getGFXPixelFormat(this._format),t.premultiplyAlpha=this._premultiplyAlpha,t.flipY=this._flipY,t.minFilter=h[this._minFilter],t.magFilter=h[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._updateFormat(),this._checkPackable(),this.loaded=!0,this.emit("load"),cc.macro.CLEANUP_IMAGE_CACHE&&this._cleanupImageCache()}},_cleanupImageCache:function(){this._image instanceof HTMLImageElement?this._clearImage():cc.sys.capabilities.imageBitmap&&this._image instanceof ImageBitmap&&this._image.close&&this._image.close()},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=d();i.wrapS=t,i.wrapT=e,this.update(i)}},setFilters:function(t,e){if(this._minFilter!==t||this._magFilter!==e){var i=d();i.minFilter=t,i.magFilter=e,this.update(i)}},setFlipY:function(t){if(this._flipY!==t){var e=d();e.flipY=t,e.premultiplyAlpha=this._premultiplyAlpha,this.update(e)}},setPremultiplyAlpha:function(t){if(this._premultiplyAlpha!==t){var e=d();e.flipY=this._flipY,e.premultiplyAlpha=t,this.update(e)}},_updateFormat:function(){this._isAlphaAtlas=this._format===c.RGBA_ETC1||this._format===c.RGB_A_PVRTC_4BPPV1||this._format===c.RGB_A_PVRTC_2BPPV1},_checkPackable:function(){var t=cc.dynamicAtlasManager;if(t)if(this._isCompressed())this._packable=!1;else{var e=this.width,i=this.height;!this._image||e>t.maxFrameSize||i>t.maxFrameSize||this._getHash()!==t.Atlas.DEFAULT_HASH?this._packable=!1:this._image&&this._image instanceof HTMLCanvasElement&&(this._packable=!0)}},_getOpts:function(){var t=d();return t.width=this.width,t.height=this.height,t.genMipmaps=this._genMipmaps,t.format=this._format,t.premultiplyAlpha=this._premultiplyAlpha,t.anisotropy=this._anisotropy,t.flipY=this._flipY,t.minFilter=h[this._minFilter],t.magFilter=h[this._magFilter],t.mipFilter=h[this._mipFilter],t.wrapS=this._wrapS,t.wrapT=this._wrapT,t},_getGFXPixelFormat:function(t){return t===c.RGBA_ETC1?t=c.RGB_ETC1:t===c.RGB_A_PVRTC_4BPPV1?t=c.RGB_PVRTC_4BPPV1:t===c.RGB_A_PVRTC_2BPPV1&&(t=c.RGB_PVRTC_2BPPV1),t},_resetUnderlyingMipmaps:function(t){var e=this._getOpts();e.images=t||[null],this._texture?this._texture.update(e):this._texture=new s.Texture2D(s.device,e)},_serialize:!1,_deserialize:function(t){var e=t.split(","),i=e[0];if(i){var n=p._parseExt(i,this._format);if(n.bestExt)this._setRawAsset(n.bestExt),this._format=n.bestFormat;else{if(!n.defaultExt)throw new Error(cc.debug.getError(3121));this._setRawAsset(n.defaultExt),cc.warnID(3120,n.defaultExt,n.defaultExt)}}8===e.length&&(this._minFilter=parseInt(e[1]),this._magFilter=parseInt(e[2]),this._wrapS=parseInt(e[3]),this._wrapT=parseInt(e[4]),this._premultiplyAlpha=49===e[5].charCodeAt(0),this._genMipmaps=49===e[6].charCodeAt(0),this._packable=49===e[7].charCodeAt(0))},_getHash:function(){if(!this._hashDirty)return this._hash;var t=this._genMipmaps?1:0,e=this._premultiplyAlpha?1:0,i=this._flipY?1:0,n=this._minFilter===u.LINEAR?1:2,r=this._magFilter===u.LINEAR?1:2,s=this._wrapS===l.REPEAT?1:this._wrapS===l.CLAMP_TO_EDGE?2:3,o=this._wrapT===l.REPEAT?1:this._wrapT===l.CLAMP_TO_EDGE?2:3,a=this._format;return this._image,this._hash=Number(""+n+r+a+s+o+t+e+i),this._hashDirty=!1,this._hash},_isCompressed:function(){return this._formatc.RGBA32F},_clearImage:function(){this._image.src=""},_checkImageBitmap:function(t){var e=this,i=this._image,n=this._flipY,r=this._premultiplyAlpha;this._flipY!==i.flipY||this._premultiplyAlpha!==i.premultiplyAlpha?createImageBitmap(i,{imageOrientation:n!==i.flipY?"flipY":"none",premultiplyAlpha:r?"premultiply":"none"}).then((function(s){i.close&&i.close(),s.flipY=n,s.premultiplyAlpha=r,e._image=s,t()}),(function(t){cc.error(t.message)})):t()}});cc.Texture2D=e.exports=p}),{"../../renderer/gfx":293,"../assets/CCAsset":58,"../event/event-target":130,"../platform/CCClass":178,"../platform/id-generater":195,"../renderer":209}],74:[(function(t,e){"use strict";var i=t("./CCAsset"),n=t("../event/event-target"),r=cc.Class({name:"cc.VideoClip",extends:i,mixins:[n]});cc.VideoClip=r,e.exports=r}),{"../event/event-target":130,"./CCAsset":58}],75:[(function(t){"use strict";t("./CCAsset"),t("./CCFont"),t("./CCPrefab"),t("./CCAudioClip"),t("./CCVideoClip"),t("./CCScripts"),t("./CCSceneAsset"),t("./CCSpriteFrame"),t("./CCTexture2D"),t("./CCRenderTexture"),t("./CCTTFFont"),t("./CCSpriteAtlas"),t("./CCBitmapFont"),t("./CCLabelAtlas"),t("./CCTextAsset"),t("./CCJsonAsset"),t("./CCBufferAsset"),t("./material")}),{"./CCAsset":58,"./CCAudioClip":59,"./CCBitmapFont":60,"./CCBufferAsset":61,"./CCFont":62,"./CCJsonAsset":63,"./CCLabelAtlas":64,"./CCPrefab":65,"./CCRenderTexture":66,"./CCSceneAsset":67,"./CCScripts":68,"./CCSpriteAtlas":69,"./CCSpriteFrame":70,"./CCTTFFont":71,"./CCTextAsset":72,"./CCTexture2D":73,"./CCVideoClip":74,"./material":82}],76:[(function(t,e){"use strict";var i,n=(i=t("../CCAsset"))&&i.__esModule?i:{default:i},r=t("./effect-parser"),s=cc.Class({name:"cc.EffectAsset",extends:n.default,ctor:function(){this._effect=null},properties:{properties:Object,techniques:[],shaders:[]},onLoad:function(){if(cc.game.renderType!==cc.game.RENDER_TYPE_CANVAS){for(var t=cc.renderer._forward._programLib,e=0;e=i.length)){var n=0,r=i.length;void 0!==e&&(n=e,r=e+1);for(var s=n;s=i.length)){var n=0,r=i.length;void 0!==e&&(n=e,r=e+1);for(var s=n;s=this._techniques.length?cc.warn("Can not switch to technique with index ["+t+"]"):this._technique=this._techniques[t]},c.clear=function(){this._techniques=[]},c.clone=function(){for(var t=[],e=0;ethis.maxSize||(this._clean(t),e[i][r].push(t),this.count++)}},s.clear=function(){this._pool={},this.count=0},s._clean=function(t){t._owner=null},r}(r.default));r.default.register("material",a);var c=a;i.default=c,e.exports=i.default}),{"../../utils/pool":253,"./utils":85}],84:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=a(t("./CCMaterial")),s=a(t("./effect-variant")),o=a(t("./material-pool"));function a(t){return t&&t.__esModule?t:{default:t}}function c(t,e){for(var i=0;i0},render:function(t){if(!(t=t||cc.director.getScene()))return null;this.node.getWorldMatrix(l),this.beforeDraw(),o.renderCamera(this._camera,t)},_onAlignWithScreen:function(){var t=cc.game.canvas.height/cc.view._scaleY;this._targetTexture&&(t=cc.visibleRect.height);var e=this._fov*cc.macro.RAD;this.node.z=t/(2*Math.tan(e/2)),e=2*Math.atan(Math.tan(e/2)/this.zoomRatio),this._camera.setFov(e),this._camera.setOrthoHeight(t/2/this.zoomRatio),this.node.setRotation(0,0,0,1)},beforeDraw:function(){if(this._camera){if(this._alignWithScreen)this._onAlignWithScreen();else{var t=this._fov*cc.macro.RAD;t=2*Math.atan(Math.tan(t/2)/this.zoomRatio),this._camera.setFov(t),this._camera.setOrthoHeight(this._orthoSize/this.zoomRatio)}this._camera.dirty=!0}}});cc.js.mixin(x.prototype,{getNodeToCameraTransform:function(t){var e=r.identity();return t.getWorldMatrix(u),this.containsNode(t)&&(this.getWorldToCameraMatrix(l),i.Mat4.mul(u,u,l)),r.fromMat4(e,u),e},getCameraToWorldPoint:function(t,e){return this.getScreenToWorldPoint(t,e)},getWorldToCameraPoint:function(t,e){return this.getWorldToScreenPoint(t,e)},getCameraToWorldMatrix:function(t){return this.getScreenToWorldMatrix2D(t)},getWorldToCameraMatrix:function(t){return this.getWorldToScreenMatrix2D(t)}}),e.exports=cc.Camera=x}),{"../../renderer/scene/camera":313,"../CCGame":24,"../geom-utils":138,"../renderer/index":209,"../renderer/render-flow":210,"../utils/affine-transform":242,"../value-types":266}],88:[(function(t,e){"use strict";cc.Collider.Box=cc.Class({properties:{_offset:cc.v2(0,0),_size:cc.size(100,100),offset:{tooltip:!1,get:function(){return this._offset},set:function(t){this._offset=t},type:cc.Vec2},size:{tooltip:!1,get:function(){return this._size},set:function(t){this._size.width=t.width<0?0:t.width,this._size.height=t.height<0?0:t.height},type:cc.Size}},resetInEditor:!1});var i=cc.Class({name:"cc.BoxCollider",extends:cc.Collider,mixins:[cc.Collider.Box],editor:!1});cc.BoxCollider=e.exports=i}),{}],89:[(function(t,e){"use strict";cc.Collider.Circle=cc.Class({properties:{_offset:cc.v2(0,0),_radius:50,offset:{tooltip:!1,get:function(){return this._offset},set:function(t){this._offset=t},type:cc.Vec2},radius:{tooltip:!1,get:function(){return this._radius},set:function(t){this._radius=t<0?0:t}}},resetInEditor:!1});var i=cc.Class({name:"cc.CircleCollider",extends:cc.Collider,mixins:[cc.Collider.Circle],editor:!1});cc.CircleCollider=e.exports=i}),{}],90:[(function(t,e){"use strict";var i=cc.Class({name:"cc.Collider",extends:cc.Component,properties:{editing:{default:!1,serializable:!1,tooltip:!1},tag:{tooltip:!1,default:0,range:[0,1e7],type:cc.Integer}},onDisable:function(){cc.director.getCollisionManager().removeCollider(this)},onEnable:function(){cc.director.getCollisionManager().addCollider(this)}});cc.Collider=e.exports=i}),{}],91:[(function(t,e){"use strict";var i,n=(i=t("../value-types/vec2"))&&i.__esModule?i:{default:i},r=t("./CCContact"),s=r.CollisionType,o=t("../CCNode").EventType,a=new n.default;function c(t,e,i,n,r,s){var o=t.x,a=t.y,c=t.width,l=t.height,u=e.m,h=u[0],_=u[1],f=u[4],d=u[5],p=h*o+f*a+u[12],m=_*o+d*a+u[13],v=h*c,y=_*c,g=f*l,x=d*l;n.x=p,n.y=m,r.x=v+p,r.y=y+m,i.x=g+p,i.y=x+m,s.x=v+g+p,s.y=y+x+m}var l=cc.Class({mixins:[cc.EventTarget],properties:{enabled:!1,enabledDrawBoundingBox:!1},ctor:function(){this._contacts=[],this._colliders=[],this._debugDrawer=null,this._enabledDebugDraw=!1,cc.director._scheduler&&cc.director._scheduler.enableForTarget(this)},update:function(){if(this.enabled){var t,e,i=this._colliders;for(t=0,e=i.length;tE&&(E=P),PB&&(B=I),I=0){e.splice(i,1);for(var n=this._contacts,r=n.length-1;r>=0;r--){var a=n[r];a.collider1!==t&&a.collider2!==t||(a.touching&&this._doCollide(s.CollisionExit,a),n.splice(r,1))}t.node.off(o.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!=h>r&&n<(u-c)*(r-l)/(h-l)+c&&(i=!i)}return i}function o(t,e,i,n){var r,s=i.x-e.x,o=i.y-e.y,a=s*s+o*o,c=((t.x-e.x)*s+(t.y-e.y)*o)/a;return r=n?a?c<0?e:c>1?i:cc.v2(e.x+c*s,e.y+c*o):e:cc.v2(e.x+c*s,e.y+c*o),s=t.x-r.x,o=t.y-r.y,Math.sqrt(s*s+o*o)}i.lineLine=n,i.lineRect=function(t,e,i){var r=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!!(n(t,e,r,s)||n(t,e,s,o)||n(t,e,o,a)||n(t,e,a,r))},i.linePolygon=r,i.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,c=e.x+e.width,l=e.y+e.height;return i<=c&&r>=o&&n<=l&&s>=a},i.rectPolygon=function(t,e){var i,n,o=new cc.Vec2(t.x,t.y),a=new cc.Vec2(t.x,t.yMax),c=new cc.Vec2(t.xMax,t.yMax),l=new cc.Vec2(t.xMax,t.y);if(r(o,a,e))return!0;if(r(a,c,e))return!0;if(r(c,l,e))return!0;if(r(l,o,e))return!0;for(i=0,n=e.length;i>>1;r<=s;o=r+s>>>1){var a=t[o],c=a.constructor._executionOrder;if(c>i)s=o-1;else if(cn)s=o-1;else{if(!(l0&&(t.array.sort(l),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(l),this._invoke(e),e.array.length=0)}}),h=cc.Class({extends:c,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=o(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=o(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 _(t,e,i,n){return function(e,r){try{n(e,r)}catch(o){cc._throw(o);var s=e.array;for(i&&(s[e.i]._objFlags|=i),++e.i;e.i=0?n.fastRemoveAt(this._deferredComps,e):(!t.start||t._objFlags&r||this.startInvoker.remove(t),t.update&&this.updateInvoker.remove(t),t.lateUpdate&&this.lateUpdateInvoker.remove(t))},enableComp:function(t,e){if(!(t._objFlags&s)){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&s&&(t.onDisable&&t.onDisable(),this._onDisabled(t))},_scheduleImmediate:function(t){"function"!=typeof t.start||t._objFlags&r||this.startInvoker.add(t),"function"==typeof t.update&&this.updateInvoker.add(t),"function"==typeof t.lateUpdate&&this.lateUpdateInvoker.add(t)},_deferredSchedule:function(){for(var t=this._deferredComps,e=0,i=t.length;e0&&(this._deferredSchedule(),this.startInvoker.invoke())},startPhase:function(){this._updating=!0,this.startInvoker.invoke(),this._startForNewComps()},updatePhase:function(t){this.updateInvoker.invoke(t)},lateUpdatePhase:function(t){this.lateUpdateInvoker.invoke(t),this._updating=!1,this._startForNewComps()}});e.exports=v}),{"./platform/CCClass":178,"./platform/CCObject":184,"./platform/js":199,"./utils/misc":251}],97:[(function(t,e){"use strict";var i=t("../../animation/animation-animator"),n=t("../../animation/animation-clip"),r=t("../event/event-target"),s=t("../platform/js"),o=function(t,e){return t===e},a=cc.Enum({PLAY:"play",STOP:"stop",PAUSE:"pause",RESUME:"resume",LASTFRAME:"lastframe",FINISHED:"finished"}),c=cc.Class({name:"cc.Animation",extends:t("./CCComponent"),mixins:[r],editor:!1,statics:{EventType:a},ctor:function(){cc.EventTarget.call(this),this._animator=null,this._nameToState=s.createMap(!0),this._didInit=!1,this._currentClip=null},properties:{_defaultClip:{default:null,type:n},defaultClip:{type:n,get:function(){return this._defaultClip},set:function(){},tooltip:!1},currentClip:{get:function(){return this._currentClip},set:function(t){this._currentClip=t},type:n,visible:!1},_writableClips:{get:function(){return this._clips},set:function(t){this._didInit=!1,this._clips=t,this._init()},type:[n]},_clips:{default:[],type:[n],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.getAnimationState(t);e&&this._animator.resumeState(e)}else this.enabled=!0},setCurrentTime:function(t,e){if(this._init(),e){var i=this.getAnimationState(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},hasAnimationState:function(t){return this._init(),!!this._nameToState[t]},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],o(i.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!o(e,t)})),i&&delete this._nameToState[i.name]}else cc.warnID(3901)},sample:function(t){if(this._init(),t){var e=this.getAnimationState(t);e&&e.sample()}else this._animator.sample()},on:function(t,e,i,n){this._init();var r=this._EventTargetOn(t,e,i,n);if("lastframe"===t){var s=this._nameToState;for(var o in s)s[o]._lastframeEventOn=!0}return r},off:function(t,e,i,n){if(this._init(),"lastframe"===t){var r=this._nameToState;for(var s in r)r[s]._lastframeEventOn=!1}this._EventTargetOff(t,e,i,n)},_init:function(){this._didInit||(this._didInit=!0,this._animator=new i(this.node,this),this._createStates())},_createStates:function(){this._nameToState=s.createMap(!0);for(var t=null,e=!1,i=0;i0&&(i=this.time/this.duration),i>=1&&(i=1),this.transition===r.COLOR){var n=this._fromColor.lerp(this._toColor,i);this._setTargetColor(n)}else this.transition===r.SCALE&&this._originalScale&&(e.scale=this._fromScale.lerp(this._toScale,i));1===i&&(this._transitionFinished=!0)}},_registerNodeEvent: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)},_unregisterNodeEvent:function(){this.node.off(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.off(cc.Node.EventType.TOUCH_MOVE,this._onTouchMove,this),this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.off(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(cc.Node.EventType.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(cc.Node.EventType.MOUSE_LEAVE,this._onMouseMoveOut,this)},_registerTargetEvent:function(t){t.on(cc.Node.EventType.SCALE_CHANGED,this._onTargetScaleChanged,this)},_unregisterTargetEvent:function(t){t.off(cc.Node.EventType.SCALE_CHANGED,this._onTargetScaleChanged,this)},_getTargetSprite:function(t){var e=null;return t&&(e=t.getComponent(cc.Sprite)),e},_applyTarget:function(){var t=this._getTarget();this._sprite=this._getTargetSprite(t),this._originalScale||(this._originalScale=cc.Vec2.ZERO),this._originalScale.x=t.scaleX,this._originalScale.y=t.scaleY,this._registerTargetEvent(t)},_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,i=t.touch,n=this.node._hitTest(i.getLocation()),o=this._getTarget(),a=this._originalScale;this.transition===r.SCALE&&a?n?(this._fromScale.x=a.x,this._fromScale.y=a.y,this._toScale.x=a.x*this.zoomScale,this._toScale.y=a.y*this.zoomScale,this._transitionFinished=!1):(this.time=0,this._transitionFinished=!0,o.setScale(a.x,a.y)):(e=n?s.PRESSED:s.NORMAL,this._applyTransition(e)),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!==r.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?s.PRESSED:this._hovered?s.HOVER:s.NORMAL:s.DISABLED},_updateColorTransitionImmediately:function(t){var e=this._getStateColor(t);this._setTargetColor(e),this._fromColor=e.clone(),this._toColor=e},_updateColorTransition:function(t){if(t===s.DISABLED)this._updateColorTransitionImmediately(t);else{var e=this._getTarget(),i=this._getStateColor(t);this._fromColor=e.color.clone(),this._toColor=i,this.time=0,this._transitionFinished=!1}},_updateSpriteTransition:function(t){var e=this._getStateSprite(t);this._sprite&&e&&(this._sprite.spriteFrame=e)},_updateScaleTransition:function(t){t===s.PRESSED?this._zoomUp():this._zoomBack()},_zoomUp:function(){this._originalScale&&(this._fromScale.x=this._originalScale.x,this._fromScale.y=this._originalScale.y,this._toScale.x=this._originalScale.x*this.zoomScale,this._toScale.y=this._originalScale.y*this.zoomScale,this.time=0,this._transitionFinished=!1)},_zoomBack:function(){if(this._originalScale){var t=this._getTarget();this._fromScale.x=t.scaleX,this._fromScale.y=t.scaleY,this._toScale.x=this._originalScale.x,this._toScale.y=this._originalScale.y,this.time=0,this._transitionFinished=!1}},_updateTransition:function(t){t===r.COLOR?this._updateColorTransitionImmediately(s.NORMAL):t===r.SPRITE&&this._updateSpriteTransition(s.NORMAL),this._updateState()},_applyTransition:function(t){var e=this.transition;e===r.COLOR?this._updateColorTransition(t):e===r.SPRITE?this._updateSpriteTransition(t):e===r.SCALE&&this._updateScaleTransition(t)},_resizeNodeToTargetNode:!1,_updateDisabledState:function(t){if(this._sprite&&(this.enableAutoGrayEffect||t)){var e=!1;this.transition===r.SPRITE&&this.disabledSprite||(e=this.enableAutoGrayEffect&&!this.interactable),this._switchGrayMaterial(e,this._sprite)}}});cc.Button=e.exports=o}),{"../utils/gray-sprite-state":248,"./CCComponent":102}],101:[(function(t,e){"use strict";var i=t("../camera/CCCamera"),n=t("./CCComponent"),r=cc.Class({name:"cc.Canvas",extends:n,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}},_fitDesignResolution:!1,__preload:function(){if(r.instance)return cc.warnID(6700,this.node.name,r.instance.node.name);r.instance=this,this.applySettings();var t=this.getComponent(cc.Widget);t&&t.updateAlignment()},start:function(){if(!i.main&&cc.game.renderType!==cc.game.RENDER_TYPE_CANVAS){var t=new cc.Node("Main Camera");t.parent=this.node,t.setSiblingIndex(0);var e=t.addComponent(i),n=i.ClearFlags;e.clearFlags=n.COLOR|n.DEPTH|n.STENCIL,e.depth=-1}},onDestroy:function(){r.instance===this&&(r.instance=null)},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=r}),{"../camera/CCCamera":87,"./CCComponent":102}],102:[(function(t,e){"use strict";var i=t("../platform/CCObject"),n=t("../platform/js"),r=new(t("../platform/id-generater"))("Comp"),s=(i.Flags.IsOnEnableCalled,i.Flags.IsOnLoadCalled),o=!!cc.ActionManager,a=cc.Class({name:"cc.Component",extends:i,ctor:function(){this._id=r.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,animatable:!0},enabledInHierarchy:{get:function(){return this._enabled&&this.node&&this.node._activeInHierarchy},visible:!1},_isOnLoadCalled:{get:function(){return this._objFlags&s}}},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(){o&&cc.director.getActionManager().removeAllActionsFromTarget(this),this.unscheduleAllCallbacks();for(var t=this.__eventTargets,e=t.length-1;e>=0;--e){var i=t[e];i&&i.targetOff(this)}t.length=0,cc.director._nodeActivator.destroyComp(this),this.node._removeComponent(this)},_instantiate:function(t){return t||(t=cc.instantiate._clone(this,this)),t.node=null,t},schedule:function(t,e,i,n){cc.assertID(t,1619),e=e||0,cc.assertID(e>=0,1620),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)}});a._requireComponent=null,a._executionOrder=0,n.value(a,"_registerEditorProps",(function(t,e){var i=e.requireComponent;i&&(t._requireComponent=i);var n=e.executionOrder;n&&"number"==typeof n&&(t._executionOrder=n)})),a.prototype.__scriptUuid="",cc.Component=e.exports=a}),{"../platform/CCObject":184,"../platform/id-generater":195,"../platform/js":199}],103:[(function(){"use strict";cc.Component.EventHandler=cc.Class({name:"cc.ClickEvent",properties:{target:{default:null,type:cc.Node},component:"",_componentId:"",_componentName:{get:function(){return this._genCompIdIfNeeded(),this._compId2Name(this._componentId)},set:function(t){this._componentId=this._compName2Id(t)}},handler:{default:""},customEventData:{default:""}},statics:{emitEvents:function(t){var e;if(arguments.length>0)for(var i=0,n=(e=new Array(arguments.length-1)).length;ip&&(p=m),B>=p&&(m=p,p=B,g=S.getAnchorPoint().y),this.horizontalDirection===a.RIGHT_TO_LEFT&&(w=1-S.anchorX),f=f+u*w*E+u*this.spacingX;var M=u*(1-w)*E;if(e){var R=f+M+u*(u>0?this.paddingRight:this.paddingLeft),P=this.horizontalDirection===a.LEFT_TO_RIGHT&&R>(1-c.x)*t,I=this.horizontalDirection===a.RIGHT_TO_LEFT&&R<-c.x*t;(P||I)&&(B>=p?(0===m&&(m=p),d+=m,m=p):(d+=p,m=B,p=0),f=_+u*(h+w*E),v++)}var D=i(S,d,v);t>=E+this.paddingLeft+this.paddingRight&&s&&S.setPosition(cc.v2(f,D));var V,L=1,O=0===p?B:p;this.verticalDirection===o.TOP_TO_BOTTOM?(y=y||this.node._contentSize.height,(V=D+(L=-1)*(O*g+this.paddingBottom))y&&(y=V)),f+=M}}return y},_getVerticalBaseHeight:function(t){var e=0,i=0;if(this.resizeMode===r.CONTAINER){for(var n=0;np&&(p=m),E>=p&&(m=p,p=E,g=S.getAnchorPoint().x),this.verticalDirection===o.TOP_TO_BOTTOM&&(w=1-S.anchorY),f=f+u*w*B+u*this.spacingY;var M=u*(1-w)*B;if(e){var R=f+M+u*(u>0?this.paddingTop:this.paddingBottom),P=this.verticalDirection===o.BOTTOM_TO_TOP&&R>(1-c.y)*t,I=this.verticalDirection===o.TOP_TO_BOTTOM&&R<-c.y*t;(P||I)&&(E>=p?(0===m&&(m=p),d+=m,m=p):(d+=p,m=E,p=0),f=_+u*(h+w*B),v++)}var D=i(S,d,v);t>=B+(this.paddingTop+this.paddingBottom)&&s&&S.setPosition(cc.v2(D,f));var V,L=1,O=0===p?E:p;this.horizontalDirection===a.RIGHT_TO_LEFT?(L=-1,y=y||this.node._contentSize.width,(V=D+L*(O*g+this.paddingLeft))y&&(y=V)),f+=M}}return y},_doLayoutBasic:function(){for(var t=this.node.children,e=null,i=0;i0&&this.node.children.find((function(t){return t.activeInHierarchy}))&&(this._doLayout(),this._layoutDirty=!1)}});cc.Layout=e.exports=c}),{"../CCNode":25,"./CCComponent":102}],108:[(function(t,e){"use strict";var i=o(t("../../renderer/gfx")),n=o(t("../value-types/mat4")),r=o(t("../value-types/vec2")),s=o(t("../assets/material/material-variant"));function o(t){return t&&t.__esModule?t:{default:t}}var a=t("../utils/misc"),c=t("./CCRenderComponent"),l=t("../renderer/render-flow"),u=t("../graphics/graphics"),h=new r.default,_=new n.default,f=[];function d(t,e,i){f.length=0;for(var n=2*Math.PI/i,r=0;r=0&&a.y>=0&&a.x<=s&&a.y<=o;else if(this.type===p.ELLIPSE){var l=s/2,u=o/2,f=a.x-.5*s,d=a.y-.5*o;c=f*f/(l*l)+d*d/(u*u)<1}return this.inverted&&(c=!c),c},markForRender:function(t){var e=l.FLAG_RENDER|l.FLAG_UPDATE_RENDER_DATA|l.FLAG_POST_RENDER;t?(this.node._renderFlag|=e,this.markForValidate()):t||(this.node._renderFlag&=~e)},disableRender:function(){this.node._renderFlag&=~(l.FLAG_RENDER|l.FLAG_UPDATE_RENDER_DATA|l.FLAG_POST_RENDER)}});cc.Mask=e.exports=m}),{"../../renderer/gfx":293,"../assets/material/material-variant":84,"../graphics/graphics":146,"../renderer/render-flow":210,"../utils/misc":251,"../value-types/mat4":268,"../value-types/vec2":275,"./CCRenderComponent":111}],109:[(function(t,e){"use strict";var i=t("../components/CCRenderComponent"),n=t("../../core/utils/blend-func"),r=cc.Class({name:"cc.MotionStreak",extends:i,mixins:[n],editor:!1,ctor:function(){this._points=[],this._lastWPos=new cc.Vec2,this._lastWPosUpdated=!1},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,this._updateMaterial())},type:cc.Texture2D,animatable:!1,tooltip:!1},_color:cc.Color.WHITE,color:{get:function(){return this._color.clone()},set:function(t){this._color.equals(t)||this._color.set(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.reset()},_updateMaterial:function(){var t=this.getMaterial(0);t&&t.setProperty("texture",this._texture),n.prototype._updateMaterial.call(this)},onFocusInEditor:!1,onLostFocusInEditor:!1,reset:function(){this._points.length=0,this._assembler&&this._assembler._renderData.clear(),this._lastWPosUpdated=!1},lateUpdate:function(t){this._assembler&&this._assembler.update(this,t)}});cc.MotionStreak=e.exports=r}),{"../../core/utils/blend-func":245,"../components/CCRenderComponent":111}],110:[(function(t,e){"use strict";var i=t("../utils/misc"),n=t("./CCComponent"),r=cc.Enum({HORIZONTAL:0,VERTICAL:1,FILLED:2}),s=cc.Class({name:"cc.ProgressBar",extends:n,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=r.FILLED);var s=t.getContentSize();if(this.mode===r.HORIZONTAL?this.totalLength=s.width:this.mode===r.VERTICAL?this.totalLength=s.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,n,s,o=t.getAnchorPoint(),a=t.getContentSize(),c=t.getPosition(),l=cc.v2(0,.5),u=i.clamp01(this.progress),h=this.totalLength*u;switch(this.mode){case r.HORIZONTAL:this.reverse&&(l=cc.v2(1,.5)),e=cc.size(h,a.height),n=this.totalLength,s=a.height;break;case r.VERTICAL:l=this.reverse?cc.v2(.5,1):cc.v2(.5,0),e=cc.size(a.width,h),n=a.width,s=this.totalLength}if(this.mode===r.FILLED)this.barSprite.type!==cc.Sprite.Type.FILLED?cc.warn("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"):(this.reverse&&(h*=-1),this.barSprite.fillRange=h);else if(this.barSprite.type!==cc.Sprite.Type.FILLED){var _=l.x-o.x,f=l.y-o.y,d=cc.v2(n*_,s*f);t.setPosition(c.x+d.x,c.y+d.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:r.HORIZONTAL,type:r,tooltip:!1,notify:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e=t.getContentSize();this.mode===r.HORIZONTAL?this.totalLength=e.width:this.mode===r.VERTICAL?this.totalLength=e.height:this.mode===r.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===r.FILLED&&(t=i.clamp01(t)),this._N$totalLength=t,this._updateBarStatus()}},progress:{default:1,type:cc.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:r}});cc.ProgressBar=e.exports=s}),{"../utils/misc":251,"./CCComponent":102}],111:[(function(t,e){"use strict";var i=s(t("../renderer/assembler")),n=s(t("../assets/material/material-variant")),r=t("../value-types");function s(t){return t&&t.__esModule?t:{default:t}}var o=t("./CCComponent"),a=t("../renderer/render-flow"),c=t("../assets/material/CCMaterial"),l=new r.Color,u=cc.Class({name:"RenderComponent",extends:o,editor:!1,properties:{_materials:{default:[],type:c},materials:{get:function(){return this._materials},set:function(t){this._materials=t,this._activateMaterial()},type:[c],displayName:"Materials",animatable:!1}},ctor:function(){this._vertsDirty=!0,this._assembler=null},_resetAssembler:function(){i.default.init(this),this._updateColor(),this.setVertsDirty()},__preload:function(){this._resetAssembler(),this._activateMaterial()},onEnable:function(){this.node._renderComponent&&(this.node._renderComponent.enabled=!1),this.node._renderComponent=this,this.node._renderFlag|=a.FLAG_OPACITY_COLOR,this.setVertsDirty()},onDisable:function(){this.node._renderComponent=null,this.disableRender()},onDestroy:function(){for(var t=this._materials,e=0;e=this._materials.length)return null;var e=this._materials[t];if(!e)return null;var i=n.default.create(e,this);return i!==e&&this.setMaterial(t,i),i},getMaterials:function(){for(var t=this._materials,e=0;eRichText",multiline:!0,tooltip:!1,notify:function(){this._updateRichTextStatus()}},horizontalAlign:{default:o.LEFT,type:o,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())}},_fontFamily:"Arial",fontFamily:{tooltip:!1,get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._layoutDirty=!0,this._updateRichTextStatus())},animatable:!1},font:{default:null,type:cc.TTFFont,tooltip:!1,notify:function(t){this.font!==t&&(this._layoutDirty=!0,this.font?(this.useSystemFont=!1,this._onTTFLoaded()):this.useSystemFont=!0,this._updateRichTextStatus())}},_isSystemFontUsed:!0,useSystemFont:{get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this._isSystemFontUsed=t,this._layoutDirty=!0,this._updateRichTextStatus())},animatable:!1,tooltip:!1},cacheMode:{default:c.NONE,type:c,tooltip:!1,notify:function(t){this.cacheMode!==t&&this._updateRichTextStatus()},animatable:!1},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:o,VerticalAlign:a},onEnable:function(){this.handleTouchEvent&&this._addEventListeners(),this._onTTFLoaded(),this._activateChildren(!0)},onDisable:function(){this.handleTouchEvent&&this._removeEventListeners(),this._activateChildren(!1)},_onColorChanged:function(t){this.node.children.forEach((function(e){e.color=t}))},_addEventListeners:function(){this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.on(cc.Node.EventType.COLOR_CHANGED,this._onColorChanged,this)},_removeEventListeners:function(){this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.off(cc.Node.EventType.COLOR_CHANGED,this._onColorChanged,this)},_updateLabelSegmentTextAttributes:function(){this._labelSegments.forEach(function(t){this._applyTextAttribute(t,null,!0)}.bind(this))},_createFontLabel:function(t){return l.get(t,this)},_onTTFLoaded:function(){if(this.font instanceof cc.TTFFont)if(this.font._nativeAsset)this._layoutDirty=!0,this._updateRichTextStatus();else{var t=this;cc.assetManager.postLoadNative(this.font,(function(){t._layoutDirty=!0,t._updateRichTextStatus()}))}else this._layoutDirty=!0,this._updateRichTextStatus()},_measureText:function(t,e){var i=this,n=function(e){var n;return 0===i._labelSegmentsCache.length?(n=i._createFontLabel(e),i._labelSegmentsCache.push(n)):n=i._labelSegmentsCache[0],n._styleIndex=t,i._applyTextAttribute(n,e,!0),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,o=r._clickParam;s&&e._containsTouchLocation(r,t.touch.getLocation())&&(i.forEach((function(e){e.enabledInHierarchy&&e[s]&&e[s](t,o)})),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;return(i=0===this._labelSegmentsCache.length?this._createFontLabel(t):this._labelSegmentsCache.pop())._styleIndex=e,i._lineCount=this._lineCount,i.active=this.node.active,i.setAnchorPoint(0,0),this._applyTextAttribute(i,t,!1),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 s=0;this._lineOffsetX<=this.maxWidth;){var o=this._getFirstWordLen(t,s,t.length),a=t.substr(s,o),c=this._measureText(i,a);if(!(this._lineOffsetX+c<=this.maxWidth)){if(s>0){var l=t.substr(0,s);this._addLabelSegment(l,i),t=t.substr(s,t.length),n=this._measureText(i,t)}this._updateLineInfo();break}this._lineOffsetX+=c,s+=o}if(n>this.maxWidth)for(var u=r.fragmentText(t,n,this.maxWidth,this._measureText(i)),h=0;h1&&h0?(a*=o=u/c,c*=o):(a*=o=this.lineHeight/c,c*=o),l>0&&(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,c),n._lineCount=this._lineCount,t.style.event?(t.style.event.click&&(n._clickHandler=t.style.event.click),t.style.event.param?n._clickParam=t.style.event.param:n._clickParam=""):n._clickHandler=null}else cc.warnID(4400)},_updateRichText:function(){if(this.enabledInHierarchy){var t=s.parse(this.string);if(!this._needsUpdateTextLayout(t))return this._textArray=t,void this._updateLabelSegmentTextAttributes();this._textArray=t,this._resetState();for(var e,i=!1,n=0;n0){var h=this._measureText(n,u);this._updateRichTextWithMaxWidth(u,h,n),c.length>1&&lthis._labelWidth&&(this._labelWidth=this._lineOffsetX),c.length>1&&l0&&(this._labelWidth=this.maxWidth),this._labelHeight=(this._lineCount+r.BASELINE_RATIO)*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(r.isUnicodeCJK(n)||r.isUnicodeSpace(n))return 1;for(var s=1,o=e+1;oe&&(t=0,e=a);var c=0;switch(this.horizontalAlign){case o.LEFT:c=-this._labelWidth/2;break;case o.CENTER:c=-this._linesWidth[a-1]/2;break;case o.RIGHT:c=this._labelWidth/2-this._linesWidth[a-1]}s.x=t+c;var l=s.getContentSize();if(s.y=this.lineHeight*(i-a)-this._labelHeight/2,a===e&&(t+=l.width),s.getComponent(cc.Sprite)){var u=this.lineHeight,h=this.lineHeight*(1+r.BASELINE_RATIO);switch(s.anchorY){case 1:s.y+=u+(h-u)/2;break;case.5:s.y+=h/2;break;default:s.y+=(h-u)/2}if(s._imageOffset){var _=s._imageOffset.split(",");if(1===_.length&&_[0]){var f=parseFloat(_[0]);Number.isInteger(f)&&(s.y+=f)}else if(2===_.length){var d=parseFloat(_[0]),p=parseFloat(_[1]);Number.isInteger(d)&&(s.x+=d),Number.isInteger(p)&&(s.y+=p)}}}var m=s.getComponent(cc.LabelOutline);m&&m.width&&(s.y=s.y-m.width)}},_convertLiteralColorValue:function(t){var e=t.toUpperCase();return cc.Color[e]?cc.Color[e]:cc.color().fromHEX(t)},_applyTextAttribute:function(t,e,i){var n=t.getComponent(cc.Label);if(n){var r=t._styleIndex,s=null;if(this._textArray[r]&&(s=this._textArray[r].style),s&&s.color?t.color=this._convertLiteralColorValue(s.color):t.color=this.node.color,n.cacheMode=this.cacheMode,this.font instanceof cc.Font&&!this._isSystemFontUsed?n.font=this.font:n.fontFamily=this.fontFamily,n.useSystemFont=this._isSystemFontUsed,n.lineHeight=this.lineHeight,n.enableBold=s&&s.bold,n.enableItalics=s&&s.italic,s&&s.italic&&(t.skewX=12),n.enableUnderline=s&&s.underline,s&&s.outline){var o=t.getComponent(cc.LabelOutline);o||(o=t.addComponent(cc.LabelOutline)),o.color=this._convertLiteralColorValue(s.outline.color),o.width=s.outline.width}s&&s.size?n.fontSize=s.size:n.fontSize=this.fontSize,null!==e&&("string"!=typeof e&&(e=""+e),n.string=e),i&&n._forceUpdateRenderData(),s&&s.event?(s.event.click&&(t._clickHandler=s.event.click),s.event.param?t._clickParam=s.event.param:t._clickParam=""):t._clickHandler=null}},onDestroy:function(){for(var t=0;t0?n:-n)),i*(e/r)},_calculatePosition:function(t,e,r,s,o,a){var c=t-e;o&&(c+=Math.abs(o));var l=0;c&&(l=s/c,l=i.clamp01(l));var u=(r-a)*l;return this.direction===n.VERTICAL?cc.v2(0,u):cc.v2(u,0)},_updateLength:function(t){if(this.handle){var e=this.handle.node,i=e.getContentSize();e.setAnchorPoint(cc.v2(0,0)),this.direction===n.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=r}),{"../utils/misc":251,"./CCComponent":102}],114:[(function(t,e){"use strict";var i=t("../CCNode").EventType,n=cc.v2(),r=cc.v2(),s=function(){return(new Date).getMilliseconds()},o=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}),a={"scroll-to-top":o.SCROLL_TO_TOP,"scroll-to-bottom":o.SCROLL_TO_BOTTOM,"scroll-to-left":o.SCROLL_TO_LEFT,"scroll-to-right":o.SCROLL_TO_RIGHT,scrolling:o.SCROLLING,"bounce-bottom":o.BOUNCE_BOTTOM,"bounce-left":o.BOUNCE_LEFT,"bounce-right":o.BOUNCE_RIGHT,"bounce-top":o.BOUNCE_TOP,"scroll-ended":o.SCROLL_ENDED,"touch-up":o.TOUCH_UP,"scroll-ended-with-threshold":o.AUTOSCROLL_ENDED_WITH_THRESHOLD,"scroll-began":o.SCROLL_BEGAN},c=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(){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:cc.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},_view:{get:function(){if(this.content)return this.content.parent}}},statics:{EventType:o},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._view.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;cc.sys.os===cc.sys.OS_WINDOWS&&cc.sys.browserType===cc.sys.BROWSER_TYPE_FIREFOX&&(n=-.1/3),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),this._dispatchEvent("scroll-ended"),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this.unschedule(this._checkMouseWheel),this._dispatchEvent("scroll-ended"),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._view.getContentSize(),s=this.content.getContentSize(),o=this._getContentBottomBoundary()-this._bottomBoundary;o=-o;var a=this._getContentLeftBoundary()-this._leftBoundary;a=-a;var c=cc.v2(0,0),l=0;return i&&(l=s.width-r.width,c.x=a-l*e.x),n&&(l=s.height-r.height,c.y=o-l*e.y),c},_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)},_getLocalAxisAlignDelta:function(t){return this.node.convertToNodeSpaceAR(t.getLocation(),n),this.node.convertToNodeSpaceAR(t.getPreviousLocation(),r),n.sub(r)},_handleMoveLogic:function(t){var e=this._getLocalAxisAlignDelta(t);this._processDeltaMove(e)},_scrollChildren:function(t){var e,i=t=this._clampDelta(t);this.elastic&&(e=this._getHowMuchOutOfBoundary(),i.x*=0===e.x?1:.5,i.y*=0===e.y?1:.5),this.elastic||(e=this._getHowMuchOutOfBoundary(i),i=i.add(e));var n="",r="";this.vertical&&(i.y>0?this.content.y-this.content.anchorY*this.content.height+i.y>=this._bottomBoundary&&(n="scroll-to-bottom"):i.y<0&&this.content.y-this.content.anchorY*this.content.height+this.content.height+i.y<=this._topBoundary&&(n="scroll-to-top")),this.horizontal&&(i.x<0?this.content.x-this.content.anchorX*this.content.width+this.content.width+i.x<=this._rightBoundary&&(r="scroll-to-right"):i.x>0&&this.content.x-this.content.anchorX*this.content.width+i.x>=this._leftBoundary&&(r="scroll-to-left")),this._moveContent(i,!1),(this.horizontal&&0!==i.x||this.vertical&&0!==i.y)&&(this._scrolling||(this._scrolling=!0,this._dispatchEvent("scroll-began")),this._dispatchEvent("scrolling")),""!==n&&this._dispatchEvent(n),""!==r&&this._dispatchEvent(r)},_handlePressLogic:function(){this._autoScrolling&&this._dispatchEvent("scroll-ended"),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=s(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},_clampDelta:function(t){var e=this.content.getContentSize(),i=this._view.getContentSize();return e.width=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(t);var e=s();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=this._getLocalAxisAlignDelta(t);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,r=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(n=r,r=(n-=1)*n*n*n*n+1);var s=this._autoScrollStartPosition.add(this._autoScrollTargetDelta.mul(r)),o=Math.abs(r-1)<=1e-4;if(Math.abs(r-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent("scroll-ended-with-threshold"),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var a=s.sub(this._autoScrollBrakingStartPosition);e&&(a=a.mul(i)),s=this._autoScrollBrakingStartPosition.add(a)}else{var c=s.sub(this.getContentPosition()),l=this._getHowMuchOutOfBoundary(c);l.fuzzyEquals(cc.v2(0,0),1e-4)||(s=s.add(l),o=!0)}o&&(this._autoScrolling=!1);var u=s.sub(this.getContentPosition());this._moveContent(this._clampDelta(u),o),this._dispatchEvent("scrolling"),this._autoScrolling||(this._isBouncing=!1,this._scrolling=!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._view.getContentSize(),o=r.width-s.width,a=r.height-s.height,c=this._calculateAttenuatedFactor(o),l=this._calculateAttenuatedFactor(a);n=cc.v2(n.x*o*(1-this.brake)*c,n.y*a*l*(1-this.brake));var u=t.mag(),h=n.mag()/u;n=n.add(t),this.brake>0&&h>7&&(h=Math.sqrt(h),n=t.mul(h).add(t)),this.brake>0&&h>3&&(i*=h=3),0===this.brake&&h>1&&(i*=h),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),this._clampDelta(e)},_updateScrollBarState:function(){if(this.content){var t=this.content.getContentSize(),e=this._view.getContentSize();this.verticalScrollBar&&(t.height0&&t[0].check()}},onEnable:function(){this._makeAtLeastOneToggleChecked(),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)}});t("../platform/js").get(i.prototype,"toggleItems",(function(){return this.node._children.map((function(t){return t.getComponent(cc.Toggle)})).filter(Boolean)})),cc.ToggleContainer=e.exports=i}),{"../platform/js":199}],118:[(function(t,e){"use strict";var i=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._hideCheckMark()}))},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._hideCheckMark(),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()}}),n=t("../platform/js"),r=!1;n.get(cc,"ToggleGroup",(function(){return r||(cc.errorID(1405,"cc.ToggleGroup","cc.ToggleContainer"),r=!0),i})),e.exports=i}),{"../platform/js":199}],119:[(function(t,e){"use strict";var i=cc.Class({name:"cc.ViewGroup",extends:t("./CCComponent")});cc.ViewGroup=e.exports=i}),{"./CCComponent":102}],120:[(function(t,e){"use strict";var i=t("../base-ui/CCWidgetManager"),n=i.AlignMode,r=i._AlignFlags,s=r.TOP,o=r.MID,a=r.BOT,c=r.LEFT,l=r.CENTER,u=r.RIGHT,h=s|a,_=c|u,f=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&s)>0},set:function(t){this._setAlign(s,t)},animatable:!1,tooltip:!1},isAlignVerticalCenter:{get:function(){return(this._alignFlags&o)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=o):this._alignFlags&=~o},animatable:!1,tooltip:!1},isAlignBottom:{get:function(){return(this._alignFlags&a)>0},set:function(t){this._setAlign(a,t)},animatable:!1,tooltip:!1},isAlignLeft:{get:function(){return(this._alignFlags&c)>0},set:function(t){this._setAlign(c,t)},animatable:!1,tooltip:!1},isAlignHorizontalCenter:{get:function(){return(this._alignFlags&l)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=l):this._alignFlags&=~l},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&_)===_},visible:!1},isStretchHeight:{get:function(){return(this._alignFlags&h)===h},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:n.ON_WINDOW_RESIZE,type:n,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:n},onLoad:function(){void 0!==this._wasAlignOnce&&(this.alignMode=this._wasAlignOnce?n.ONCE:n.ALWAYS,this._wasAlignOnce=void 0)},onEnable:function(){i.add(this)},onDisable:function(){i.remove(this)},_validateTargetInDEV:!1,_setAlign:function(t,e){if(e!==(this._alignFlags&t)>0){var i=(t&_)>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(){i.updateAlignment(this.node)}});Object.defineProperty(f.prototype,"isAlignOnce",{get:function(){return this.alignMode===n.ONCE},set:function(t){this.alignMode=t?n.ONCE:n.ALWAYS}}),cc.Widget=e.exports=f}),{"../base-ui/CCWidgetManager":86,"./CCComponent":102}],121:[(function(t,e){"use strict";var i=t("./CCComponent"),n=cc.Class({name:"cc.SubContextView",extends:i,editor:!1,properties:{_firstlyEnabled:!0,_fps:60,fps:{get:function(){return this._fps},set:function(t){this._fps!==t&&(this._fps=t,this._updateInterval=1/t,this._updateSubContextFrameRate())},tooltip:!1}},ctor:function(){this._sprite=null,this._tex=new cc.Texture2D,this._tex._packable=!1,this._context=null,this._updatedTime=performance.now(),this._updateInterval=0},onLoad:function(){if(window.__globalAdapter&&__globalAdapter.getOpenDataContext){this._updateInterval=1e3/this._fps,this._context=__globalAdapter.getOpenDataContext(),this.reset();var t=this._context.canvas;this._tex.setPremultiplyAlpha(!0),this._tex.initWithElement(t),this._tex._packable=!1,this._sprite=this.node.getComponent(cc.Sprite),this._sprite||(this._sprite=this.node.addComponent(cc.Sprite),this._sprite.srcBlendFactor=cc.macro.BlendFactor.ONE),this._sprite.spriteFrame=new cc.SpriteFrame(this._tex)}else this.enabled=!1},reset:function(){if(this._context){this.updateSubContextViewport();var t=this._context.canvas;t&&(t.width=this.node.width,t.height=this.node.height)}},onEnable:function(){this._firstlyEnabled&&this._context?(this._context.postMessage({fromEngine:!0,event:"boot"}),this._firstlyEnabled=!1):this._runSubContextMainLoop(),this._registerNodeEvent(),this._updateSubContextFrameRate(),this.updateSubContextViewport()},onDisable:function(){this._unregisterNodeEvent(),this._stopSubContextMainLoop()},update:function(t){if(void 0===t)return this._context&&this._context.postMessage({fromEngine:!0,event:"step"}),void this._updateSubContextTexture();performance.now()-this._updatedTime>=this._updateInterval&&(this._updatedTime+=this._updateInterval,this._updateSubContextTexture())},_updateSubContextTexture:function(){this._tex&&this._context&&(this._tex.initWithElement(this._context.canvas),this._tex._packable=!1,this._sprite._activateMaterial())},updateSubContextViewport:function(){if(this._context){var t=this.node.getBoundingBoxToWorld(),e=cc.view._scaleX,i=cc.view._scaleY;this._context.postMessage({fromEngine:!0,event:"viewport",x:t.x*e+cc.view._viewportRect.x,y:t.y*i+cc.view._viewportRect.y,width:t.width*e,height:t.height*i})}},_registerNodeEvent:function(){this.node.on("position-changed",this.updateSubContextViewport,this),this.node.on("scale-changed",this.updateSubContextViewport,this),this.node.on("size-changed",this.updateSubContextViewport,this)},_unregisterNodeEvent:function(){this.node.off("position-changed",this.updateSubContextViewport,this),this.node.off("scale-changed",this.updateSubContextViewport,this),this.node.off("size-changed",this.updateSubContextViewport,this)},_runSubContextMainLoop:function(){this._context&&this._context.postMessage({fromEngine:!0,event:"mainLoop",value:!0})},_stopSubContextMainLoop:function(){this._context&&this._context.postMessage({fromEngine:!0,event:"mainLoop",value:!1})},_updateSubContextFrameRate:function(){this._context&&this._context.postMessage({fromEngine:!0,event:"frameRate",value:this._fps})}});cc.SubContextView=e.exports=n,cc.WXSubContextView=n,cc.SwanSubContextView=n}),{"./CCComponent":102}],122:[(function(t,e){"use strict";t("./CCComponent"),t("./CCComponentEventHandler"),t("./missing-script");var i=t("./SubContextView");i||(i=cc.Class({name:"cc.SubContextView",extends:cc.Component}),cc.SubContextView=cc.WXSubContextView=cc.SwanSubContextView=i);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("./CCLabelShadow"),t("./CCRichText"),t("./CCToggleContainer"),t("./CCToggleGroup"),t("./CCToggle"),t("./CCBlockInputEvents"),t("./CCMotionStreak"),t("./CCSafeArea"),i];e.exports=n}),{"./CCAnimation":97,"./CCAudioSource":98,"./CCBlockInputEvents":99,"./CCButton":100,"./CCCanvas":101,"./CCComponent":102,"./CCComponentEventHandler":103,"./CCLabel":104,"./CCLabelOutline":105,"./CCLabelShadow":106,"./CCLayout":107,"./CCMask":108,"./CCMotionStreak":109,"./CCPageView":void 0,"./CCPageViewIndicator":void 0,"./CCProgressBar":110,"./CCRichText":112,"./CCSafeArea":void 0,"./CCScrollBar":113,"./CCScrollView":114,"./CCSlider":void 0,"./CCSprite":115,"./CCToggle":116,"./CCToggleContainer":117,"./CCToggleGroup":118,"./CCWidget":120,"./SubContextView":121,"./editbox/CCEditBox":void 0,"./missing-script":123}],123:[(function(t,e){"use strict";var i=cc.js,n=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){return i._getClassById(t)||(cc.deserialize.reportMissingClass(t),n)}},onLoad:function(){cc.warnID(4600,this.node.name)}});cc._MissingScript=e.exports=n}),{}],124:[(function(t,e){"use strict";var i=cc.js;t("../event/event");var n=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};i.extend(n,cc.Event);var r=n.prototype;r.setScrollData=function(t,e){this._scrollX=t,this._scrollY=e},r.getScrollX=function(){return this._scrollX},r.getScrollY=function(){return this._scrollY},r.setLocation=function(t,e){this._x=t,this._y=e},r.getLocation=function(){return cc.v2(this._x,this._y)},r.getLocationInView=function(){return cc.v2(this._x,cc.view._designResolutionSize.height-this._y)},r._setPrevCursor=function(t,e){this._prevX=t,this._prevY=e},r.getPreviousLocation=function(){return cc.v2(this._prevX,this._prevY)},r.getDelta=function(){return cc.v2(this._x-this._prevX,this._y-this._prevY)},r.getDeltaX=function(){return this._x-this._prevX},r.getDeltaY=function(){return this._y-this._prevY},r.setButton=function(t){this._button=t},r.getButton=function(){return this._button},r.getLocationX=function(){return this._x},r.getLocationY=function(){return this._y},n.NONE=0,n.DOWN=1,n.UP=2,n.MOVE=3,n.SCROLL=4,n.BUTTON_LEFT=0,n.BUTTON_RIGHT=2,n.BUTTON_MIDDLE=1,n.BUTTON_4=3,n.BUTTON_5=4,n.BUTTON_6=5,n.BUTTON_7=6,n.BUTTON_8=7;var s=function(t,e){cc.Event.call(this,cc.Event.TOUCH,e),this._eventCode=0,this._touches=t||[],this.touch=null,this.currentTouch=null};i.extend(s,cc.Event),(r=s.prototype).getEventCode=function(){return this._eventCode},r.getTouches=function(){return this._touches},r._setEventCode=function(t){this._eventCode=t},r._setTouches=function(t){this._touches=t},r.setLocation=function(t,e){this.touch&&this.touch.setTouchInfo(this.touch.getID(),t,e)},r.getLocation=function(){return this.touch?this.touch.getLocation():cc.v2()},r.getLocationInView=function(){return this.touch?this.touch.getLocationInView():cc.v2()},r.getPreviousLocation=function(){return this.touch?this.touch.getPreviousLocation():cc.v2()},r.getStartLocation=function(){return this.touch?this.touch.getStartLocation():cc.v2()},r.getID=function(){return this.touch?this.touch.getID():null},r.getDelta=function(){return this.touch?this.touch.getDelta():cc.v2()},r.getDeltaX=function(){return this.touch?this.touch.getDelta().x:0},r.getDeltaY=function(){return this.touch?this.touch.getDelta().y:0},r.getLocationX=function(){return this.touch?this.touch.getLocationX():0},r.getLocationY=function(){return this.touch?this.touch.getLocationY():0},s.MAX_TOUCHES=5,s.BEGAN=0,s.MOVED=1,s.ENDED=2,s.CANCELED=3;var o=function(t,e){cc.Event.call(this,cc.Event.ACCELERATION,e),this.acc=t};i.extend(o,cc.Event);var a=function(t,e,i){cc.Event.call(this,cc.Event.KEYBOARD,i),this.keyCode=t,this.isPressed=e};i.extend(a,cc.Event),cc.Event.EventMouse=n,cc.Event.EventTouch=s,cc.Event.EventAcceleration=o,cc.Event.EventKeyboard=a,e.exports=cc.Event}),{"../event/event":131}],125:[(function(t,e){"use strict";var i=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 n=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"},r=function(t,e){this._onCustomEvent=e,cc.EventListener.call(this,cc.EventListener.CUSTOM,t,this._callback)};i.extend(r,cc.EventListener),i.mixin(r.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 r(this._listenerID,this._onCustomEvent)}});var s=function(){cc.EventListener.call(this,cc.EventListener.MOUSE,n.MOUSE,this._callback)};i.extend(s,cc.EventListener),i.mixin(s.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 s;return t.onMouseDown=this.onMouseDown,t.onMouseUp=this.onMouseUp,t.onMouseMove=this.onMouseMove,t.onMouseScroll=this.onMouseScroll,t},checkAvailable:function(){return!0}});var o=function(){cc.EventListener.call(this,cc.EventListener.TOUCH_ONE_BY_ONE,n.TOUCH_ONE_BY_ONE,null),this._claimedTouches=[]};i.extend(o,cc.EventListener),i.mixin(o.prototype,{constructor:o,_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 o;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 a=function(){cc.EventListener.call(this,cc.EventListener.TOUCH_ALL_AT_ONCE,n.TOUCH_ALL_AT_ONCE,null)};i.extend(a,cc.EventListener),i.mixin(a.prototype,{constructor:a,onTouchesBegan:null,onTouchesMoved:null,onTouchesEnded:null,onTouchesCancelled:null,clone:function(){var t=new a;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 c=function(t){this._onAccelerationEvent=t,cc.EventListener.call(this,cc.EventListener.ACCELERATION,n.ACCELERATION,this._callback)};i.extend(c,cc.EventListener),i.mixin(c.prototype,{constructor:c,_onAccelerationEvent:null,_callback:function(t){this._onAccelerationEvent(t.acc,t)},checkAvailable:function(){return cc.assertID(this._onAccelerationEvent,1803),!0},clone:function(){return new c(this._onAccelerationEvent)}});var l=function(){cc.EventListener.call(this,cc.EventListener.KEYBOARD,n.KEYBOARD,this._callback)};i.extend(l,cc.EventListener),i.mixin(l.prototype,{constructor:l,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 l;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 o:e===cc.EventListener.TOUCH_ALL_AT_ONCE?i=new a:e===cc.EventListener.MOUSE?i=new s:e===cc.EventListener.CUSTOM?(i=new r(t.eventName,t.callback),delete t.eventName,delete t.callback):e===cc.EventListener.KEYBOARD?i=new l:e===cc.EventListener.ACCELERATION&&(i=new c(t.callback),delete t.callback),t)i[n]=t[n];return i},e.exports=cc.EventListener}),{"../platform/js":199}],126:[(function(t,e){"use strict";var i=t("../platform/js");t("./CCEventListener");var n=cc.EventListener.ListenerID,r=function(){this._fixedListeners=[],this._sceneGraphListeners=[],this.gt0Index=0};r.prototype={constructor:r,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 s=function(t){var e=cc.Event,i=t.type;return i===e.ACCELERATION?n.ACCELERATION:i===e.KEYBOARD?n.KEYBOARD:i.startsWith(e.MOUSE)?n.MOUSE:(i.startsWith(e.TOUCH)&&cc.logID(2e3),"")},o={DIRTY_NONE:0,DIRTY_FIXED_PRIORITY:1,DIRTY_SCENE_GRAPH_PRIORITY:2,DIRTY_ALL:3,_listenersMap:{},_priorityDirtyFlagMap:{},_nodeListenersMap:{},_toAddedListeners:[],_toRemovedListeners:[],_dirtyListeners:{},_inDispatch:0,_isEnabled:!1,_currentTouch:null,_currentTouchListener:null,_internalCustomListenerIDs:[],_setDirtyForNode:function(t){var e=this._nodeListenersMap[t._id];if(e)for(var i=0,n=e.length;i0)for(var s=t._children,o=0,a=s.length;o=0;i--)(e=t[i])._setRegistered(!1),null!=e._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(e._getSceneGraphPriority(),e),e._setSceneGraphPriority(null)),0===this._inDispatch&&cc.js.array.removeAt(t,i)},_removeListenersForListenerID:function(t){var e,i=this._listenersMap[t];if(i){var n=i.getFixedPriorityListeners(),r=i.getSceneGraphPriorityListeners();this._removeAllListenersInVector(r),this._removeAllListenersInVector(n),delete this._priorityDirtyFlagMap[t],this._inDispatch||(i.clear(),delete this._listenersMap[t])}var s,o=this._toAddedListeners;for(e=o.length-1;e>=0;e--)(s=o[e])&&s._getListenerID()===t&&cc.js.array.removeAt(o,e)},_sortEventListeners:function(t){var e=this.DIRTY_NONE,i=this._priorityDirtyFlagMap;i[t]&&(e=i[t]),e!==this.DIRTY_NONE&&(i[t]=this.DIRTY_NONE,e&this.DIRTY_FIXED_PRIORITY&&this._sortListenersOfFixedPriority(t),e&this.DIRTY_SCENE_GRAPH_PRIORITY&&cc.director.getScene()&&this._sortListenersOfSceneGraphPriority(t))},_sortListenersOfSceneGraphPriority:function(t){var e=this._getListeners(t);if(e){var i=e.getSceneGraphPriorityListeners();i&&0!==i.length&&e.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes)}},_sortEventListenersOfSceneGraphPriorityDes:function(t,e){var i=t._getSceneGraphPriority(),n=e._getSceneGraphPriority();if(!(e&&n&&n._activeInHierarchy&&null!==n._parent))return-1;if(!t||!i||!i._activeInHierarchy||null===i._parent)return 1;for(var r=i,s=n,o=!1;r._parent._id!==s._parent._id;)r=null===r._parent._parent?(o=!0)&&n:r._parent,s=null===s._parent._parent?(o=!0)&&i:s._parent;if(r._id===s._id){if(r._id===n._id)return-1;if(r._id===i._id)return 1}return o?r._localZOrder-s._localZOrder:s._localZOrder-r._localZOrder},_sortListenersOfFixedPriority:function(t){var e=this._listenersMap[t];if(e){var i=e.getFixedPriorityListeners();if(i&&0!==i.length){i.sort(this._sortListenersOfFixedPriorityAsc);for(var n=0,r=i.length;n=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=s.length-1;e>=0;e--)(i=s[e])._isRegistered()||(cc.js.array.removeAt(s,e),-1!==(n=o.indexOf(i))&&o.splice(n,1));if(r)for(e=r.length-1;e>=0;e--)(i=r[e])._isRegistered()||(cc.js.array.removeAt(r,e),-1!==(n=o.indexOf(i))&&o.splice(n,1));s&&0===s.length&&t.clearSceneGraphListeners(),r&&0===r.length&&t.clearFixedListeners()},frameUpdateListeners:function(){var t=this._listenersMap,e=this._priorityDirtyFlagMap;for(var i in t)t[i].empty()&&(delete e[i],delete t[i]);var n=this._toAddedListeners;if(0!==n.length){for(var r=0,s=n.length;r0,3508),!(t>1)){var e;(e=this._listenersMap[n.TOUCH_ONE_BY_ONE])&&this._onUpdateListeners(e),(e=this._listenersMap[n.TOUCH_ALL_AT_ONCE])&&this._onUpdateListeners(e),cc.assertID(1===t,3509);var i=this._toAddedListeners;if(0!==i.length){for(var r=0,s=i.length;r0&&-1!==(r=t._claimedTouches.indexOf(n))){if(s=!0,!cc.macro.ENABLE_MULTI_TOUCH&&o._currentTouch&&o._currentTouch!==n)return!1;a===c.MOVED&&t.onTouchMoved?t.onTouchMoved(n,i):a===c.ENDED?(t.onTouchEnded&&t.onTouchEnded(n,i),t._registered&&t._claimedTouches.splice(r,1),o._clearCurTouch()):a===c.CANCELED&&(t.onTouchCancelled&&t.onTouchCancelled(n,i),t._registered&&t._claimedTouches.splice(r,1),o._clearCurTouch())}return i.isStopped()?(o._updateTouchListeners(i),!0):!(!s||!t.swallowTouches||(e.needsMutableSet&&e.touches.splice(n,1),0))},_dispatchTouchEvent:function(t){this._sortEventListeners(n.TOUCH_ONE_BY_ONE),this._sortEventListeners(n.TOUCH_ALL_AT_ONCE);var e=this._getListeners(n.TOUCH_ONE_BY_ONE),i=this._getListeners(n.TOUCH_ALL_AT_ONCE);if(null!==e||null!==i){var r=t.getTouches(),s=cc.js.array.copy(r),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.CANCELED&&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(),c=0;if(o&&0!==o.length)for(;c=0;c--){var l=a[c];if(l===t){cc.js.array.removeAt(a,c),l._setRegistered(!1);break}}this._currentTouchListener===t&&this._clearCurTouch()}},_clearCurTouch:function(){this._currentTouchListener=null,this._currentTouch=null},_removeListenerInCallback:function(t,e){if(null==t)return!1;for(var i=t.length-1;i>=0;i--){var n=t[i];if(n._onCustomEvent===e||n._onEvent===e)return n._setRegistered(!1),null!=n._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(n._getSceneGraphPriority(),n),n._setSceneGraphPriority(null)),0===this._inDispatch?cc.js.array.removeAt(t,i):this._toRemovedListeners.push(n),!0}return!1},_removeListenerInVector:function(t,e){if(null==t)return!1;for(var i=t.length-1;i>=0;i--){var n=t[i];if(n===e)return n._setRegistered(!1),null!=n._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(n._getSceneGraphPriority(),n),n._setSceneGraphPriority(null)),0===this._inDispatch?cc.js.array.removeAt(t,i):this._toRemovedListeners.push(n),!0}return!1},removeListeners:function(t,e){var i=this;if(cc.js.isNumber(t)||t instanceof cc._BaseNode)if(void 0!==t._id){var r,s=i._nodeListenersMap[t._id];if(s){var o=cc.js.array.copy(s);for(r=0;r=0;i--){var n=e[i];n&&this.off(t,n.callback,n.target)}},cc.EventTarget=e.exports=s}),{"../platform/callbacks-invoker":191,"../platform/js":199}],131:[(function(t,e){"use strict";var i=t("../platform/js");cc.Event=function(t,e){this.type=t,this.bubbles=!!e,this.target=null,this.currentTarget=null,this.eventPhase=0,this._propagationStopped=!1,this._propagationImmediateStopped=!1},cc.Event.prototype={constructor:cc.Event,unuse:function(){this.type=cc.Event.NO_TYPE,this.target=null,this.currentTarget=null,this.eventPhase=cc.Event.NONE,this._propagationStopped=!1,this._propagationImmediateStopped=!1},reuse:function(t,e){this.type=t,this.bubbles=e||!1},stopPropagation:function(){this._propagationStopped=!0},stopPropagationImmediate:function(){this._propagationImmediateStopped=!0},isStopped:function(){return this._propagationStopped||this._propagationImmediateStopped},getCurrentTarget:function(){return this.currentTarget},getType:function(){return this.type}},cc.Event.NO_TYPE="no_type",cc.Event.TOUCH="touch",cc.Event.MOUSE="mouse",cc.Event.KEYBOARD="keyboard",cc.Event.ACCELERATION="acceleration",cc.Event.NONE=0,cc.Event.CAPTURING_PHASE=1,cc.Event.AT_TARGET=2,cc.Event.BUBBLING_PHASE=3;var n=function(t,e){cc.Event.call(this,t,e),this.detail=null};i.extend(n,cc.Event),n.prototype.reset=n,n.prototype.setUserData=function(t){this.detail=t},n.prototype.getUserData=function(){return this.detail},n.prototype.getEventName=cc.Event.prototype.getType;var r=new i.Pool(10);n.put=function(t){r.put(t)},n.get=function(t,e){var i=r._get();return i?i.reset(t,e):i=new n(t,e),i},cc.Event.EventCustom=n,e.exports=cc.Event}),{"../platform/js":199}],132:[(function(t){"use strict";t("./event"),t("./event-listeners"),t("./event-target"),t("./system-event")}),{"./event":131,"./event-listeners":129,"./event-target":130,"./system-event":133}],133:[(function(t,e){"use strict";var i=t("../event/event-target"),n=t("../event-manager"),r=t("../platform/CCInputManager"),s=cc.Enum({KEY_DOWN:"keydown",KEY_UP:"keyup",DEVICEMOTION:"devicemotion"}),o=null,a=null,c=cc.Class({name:"SystemEvent",extends:i,statics:{EventType:s},setAccelerometerEnabled:function(t){t&&window.DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceMotionEvent.requestPermission().then((function(t){console.log("Device Motion Event request permission: "+t),r.setAccelerometerEnabled("granted"===t)})):r.setAccelerometerEnabled(t)},setAccelerometerInterval:function(t){r.setAccelerometerInterval(t)},on:function(t,e,i,r){this._super(t,e,i,r),t!==s.KEY_DOWN&&t!==s.KEY_UP||(o||(o=cc.EventListener.create({event:cc.EventListener.KEYBOARD,onKeyPressed:function(t,e){e.type=s.KEY_DOWN,cc.systemEvent.dispatchEvent(e)},onKeyReleased:function(t,e){e.type=s.KEY_UP,cc.systemEvent.dispatchEvent(e)}})),n.hasEventListener(cc.EventListener.ListenerID.KEYBOARD)||n.addListener(o,1)),t===s.DEVICEMOTION&&(a||(a=cc.EventListener.create({event:cc.EventListener.ACCELERATION,callback:function(t,e){e.type=s.DEVICEMOTION,cc.systemEvent.dispatchEvent(e)}})),n.hasEventListener(cc.EventListener.ListenerID.ACCELERATION)||n.addListener(a,1))},off:function(t,e,i){if(this._super(t,e,i),o&&(t===s.KEY_DOWN||t===s.KEY_UP)){var r=this.hasEventListener(s.KEY_DOWN),c=this.hasEventListener(s.KEY_UP);r||c||n.removeListener(o)}a&&t===s.DEVICEMOTION&&n.removeListener(a)}});cc.SystemEvent=e.exports=c,cc.systemEvent=new cc.SystemEvent}),{"../event-manager":128,"../event/event-target":130,"../platform/CCInputManager":182}],134:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=o(t("../value-types/vec3")),r=o(t("../value-types/mat3")),s=o(t("./enums"));function o(t){return t&&t.__esModule?t:{default:t}}var a=new n.default,c=new n.default,l=new r.default,u=function(t,e,i){var r=l.m,s=i.m;r[0]=Math.abs(s[0]),r[1]=Math.abs(s[1]),r[2]=Math.abs(s[2]),r[3]=Math.abs(s[4]),r[4]=Math.abs(s[5]),r[5]=Math.abs(s[6]),r[6]=Math.abs(s[8]),r[7]=Math.abs(s[9]),r[8]=Math.abs(s[10]),n.default.transformMat3(t,e,l)},h=(function(){function t(t,e,i,r,o,a){this.center=void 0,this.halfExtents=void 0,this._type=void 0,this._type=s.default.SHAPE_AABB,this.center=new n.default(t,e,i),this.halfExtents=new n.default(r,o,a)}t.create=function(e,i,n,r,s,o){return new t(e,i,n,r,s,o)},t.clone=function(e){return new t(e.center.x,e.center.y,e.center.z,e.halfExtents.x,e.halfExtents.y,e.halfExtents.z)},t.copy=function(t,e){return n.default.copy(t.center,e.center),n.default.copy(t.halfExtents,e.halfExtents),t},t.fromPoints=function(t,e,i){return n.default.scale(t.center,n.default.add(a,e,i),.5),n.default.scale(t.halfExtents,n.default.sub(c,i,e),.5),t},t.set=function(t,e,i,r,s,o,a){return n.default.set(t.center,e,i,r),n.default.set(t.halfExtents,s,o,a),t};var e=t.prototype;return e.getBoundary=function(t,e){n.default.sub(t,this.center,this.halfExtents),n.default.add(e,this.center,this.halfExtents)},e.transform=function(t,e,i,r,s){s||(s=this),n.default.transformMat4(s.center,this.center,t),u(s.halfExtents,this.halfExtents,t)},t})();i.default=h,e.exports=i.default}),{"../value-types/mat3":267,"../value-types/vec3":276,"./enums":136}],135:[(function(t,e,i){"use strict";i.__esModule=!0,i.point_plane=_,i.pt_point_aabb=function(t,e,i){return n.Vec3.copy(t,e),n.Vec3.subtract(c,i.center,i.halfExtents),n.Vec3.add(l,i.center,i.halfExtents),t.x=t.xl.x?l.x:t.x,t.y=t.y>l.x?l.y:t.y,t.z=t.z>l.x?l.z:t.z,t},i.pt_point_obb=function(t,e,i){var c=i.orientation.m;n.Vec3.set(r,c[0],c[1],c[2]),n.Vec3.set(s,c[3],c[4],c[5]),n.Vec3.set(o,c[6],c[7],c[8]),u[0]=r,u[1]=s,u[2]=o,h[0]=i.halfExtents.x,h[1]=i.halfExtents.y,h[2]=i.halfExtents.z,n.Vec3.subtract(a,e,i.center),n.Vec3.set(t,i.center.x,i.center.y,i.center.z);for(var l=0;l<3;l++){var _=n.Vec3.dot(a,u[l]);_>h[l]&&(_=h[l]),_<-h[l]&&(_=-h[l]),t.x+=_*u[l].x,t.y+=_*u[l].y,t.z+=_*u[l].z}return t},i.pt_point_plane=function(t,e,i){var r=_(e,i);return n.Vec3.subtract(t,e,n.Vec3.multiplyScalar(t,i.n,r))};var n=t("../value-types"),r=new n.Vec3,s=new n.Vec3,o=new n.Vec3,a=new n.Vec3,c=new n.Vec3,l=new n.Vec3,u=new Array(3),h=new Array(3);function _(t,e){return n.Vec3.dot(e.n,t)-e.d}}),{"../value-types":266}],136:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0,i.default={SHAPE_RAY:1,SHAPE_LINE:2,SHAPE_SPHERE:4,SHAPE_AABB:8,SHAPE_OBB:16,SHAPE_PLANE:32,SHAPE_TRIANGLE:64,SHAPE_FRUSTUM:128,SHAPE_FRUSTUM_ACCURATE:256},e.exports=i.default}),{}],137:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=t("../value-types"),r=o(t("./enums")),s=o(t("./plane"));function o(t){return t&&t.__esModule?t:{default:t}}function a(t,e){for(var i=0;i0&&f=0;r--)t(n[r],i);i(e)}function e(t,e){return t.distance-e.distance}function i(t,e,i){var n=i.m,r=e.x,s=e.y,o=e.z,a=n[3]*r+n[7]*s+n[11]*o;return a=a?1/a:1,t.x=(n[0]*r+n[4]*s+n[8]*o)*a,t.y=(n[1]*r+n[5]*s+n[9]*o)*a,t.z=(n[2]*r+n[6]*s+n[10]*o)*a,t}var n=new r.default(function(){return{distance:0,node:null}},1),a=[],c=o.default.create(),u=new s.Vec3,h=new s.Vec3,_=new l.default,f=cc.mat4(),d=cc.mat4(),p=new s.Vec3;function m(t){return t>0&&t<1/0}return function(r,l,v,y){return n.reset(),a.length=0,t(r=r||cc.director.getScene(),(function(t){if(!y||y(t)){s.Mat4.invert(d,t.getWorldMatrix(f)),s.Vec3.transformMat4(_.o,l.o,d),s.Vec3.normalize(_.d,i(_.d,l.d,d));var e=1/0,r=t._renderComponent;if(r instanceof cc.MeshRenderer?e=F(_,r._boundingBox):t.width&&t.height&&(s.Vec3.set(u,-t.width*t.anchorX,-t.height*t.anchorY,t.z),s.Vec3.set(h,t.width*(1-t.anchorX),t.height*(1-t.anchorY),t.z),o.default.fromPoints(c,u,h),e=F(_,c)),m(e)&&(v&&(e=v(_,t,e)),m(e))){s.Vec3.scale(p,_.d,e),i(p,p,f);var g=n.add();g.node=t,g.distance=s.Vec3.mag(p),a.push(g)}}})),a.sort(e),a}})(),R=(f=new s.Vec3(0,0,0),function(t,e){var i=s.Vec3.dot(t.d,e.n);if(Math.abs(i)1?0:i}),I=(function(){var t=new s.Vec3(0,0,0),e=new s.Vec3(0,0,0),i=new s.Vec3(0,0,0),n=new s.Vec3(0,0,0),r=new s.Vec3(0,0,0);return function(o,a,c){s.Vec3.subtract(t,a.b,a.a),s.Vec3.subtract(e,a.c,a.a),s.Vec3.cross(i,o.d,e);var l=s.Vec3.dot(t,i);if(l-Number.EPSILON))return 0;var u=1/l;s.Vec3.subtract(n,o.o,a.a);var h=s.Vec3.dot(n,i)*u;if(h<0||h>1)return 0;s.Vec3.cross(r,n,t);var _=s.Vec3.dot(o.d,r)*u;if(_<0||h+_>1)return 0;var f=s.Vec3.dot(e,r)*u;return f<0?0:f}})(),D=I,V=(function(){var t=new s.Vec3(0,0,0),e=new s.Vec3(0,0,0),i=new s.Vec3(0,0,0),n=new s.Vec3(0,0,0),r=new s.Vec3(0,0,0),o=new s.Vec3(0,0,0);return function(a,c,l){s.Vec3.subtract(t,c.b,c.a),s.Vec3.subtract(e,c.c,c.a),s.Vec3.subtract(i,a.s,a.e),s.Vec3.cross(r,t,e);var u=s.Vec3.dot(i,r);if(u<=0)return 0;s.Vec3.subtract(n,a.s,c.a);var h=s.Vec3.dot(n,r);if(h<0||h>u)return 0;s.Vec3.cross(o,i,n);var _=s.Vec3.dot(e,o);if(_<0||_>u)return 0;var f=-s.Vec3.dot(t,o);if(f<0||_+f>u)return 0;if(l){var d=1/u,p=1-(_*=d)-(f*=d);s.Vec3.set(l,c.a.x*p+c.b.x*_+c.c.x*f,c.a.y*p+c.b.y*_+c.c.y*f,c.a.z*p+c.b.z*_+c.c.z*f)}return 1}})(),L=(p=new s.Vec3(0,0,0),m=new s.Vec3(0,0,0),v=new s.Vec3(0,0,0),y=new s.Vec3(0,0,0),g=new s.Vec3(0,0,0),x=new s.Vec3(0,0,0),A=new s.Vec3(0,0,0),function(t,e,i,n,r,o,a){s.Vec3.subtract(p,e,t),s.Vec3.subtract(m,i,t),s.Vec3.subtract(v,n,t),s.Vec3.subtract(y,r,t),s.Vec3.cross(x,y,p);var c=s.Vec3.dot(m,x);if(c>=0){var l=-s.Vec3.dot(v,x);if(l<0)return 0;var u=s.Vec3.dot(s.Vec3.cross(A,p,v),m);if(u<0)return 0;if(a){var h=1/(l+c+u);l*=h,c*=h,u*=h,s.Vec3.set(a,i.x*l+n.x*c+r.x*u,i.y*l+n.y*c+r.y*u,i.z*l+n.z*c+r.z*u)}}else{s.Vec3.subtract(g,o,t);var _=s.Vec3.dot(g,x);if(_<0)return 0;var f=s.Vec3.dot(s.Vec3.cross(A,p,m),g);if(f<0)return 0;if(a){var d=1/(_+(c=-c)+f);_*=d,c*=d,f*=d,s.Vec3.set(a,i.x*_+o.x*c+r.x*f,i.y*_+o.y*c+r.y*f,i.z*_+o.z*c+r.z*f)}}return 1}),O=(function(){var t=new s.Vec3(0,0,0);return function(e,i){var n=i.radius,r=i.center,o=e.o,a=e.d,c=n*n;s.Vec3.subtract(t,r,o);var l=t.lengthSqr(),u=s.Vec3.dot(t,a),h=c-(l-u*u);if(h<0)return 0;var _=Math.sqrt(h),f=lp?0:d}),N=F,G=(function(){var t=new s.Vec3,e=new s.Vec3,i=new s.Vec3,n=new s.Vec3,r=new s.Vec3,o=new s.Vec3,a=new s.Vec3,c=new Array(3),l=new Array(3),u=new Array(3),h=new Array(6);return function(_,f){c[0]=f.halfExtents.x,c[1]=f.halfExtents.y,c[2]=f.halfExtents.z,t=f.center,e=_.o,i=_.d;var d=f.orientation.m;s.Vec3.set(n,d[0],d[1],d[2]),s.Vec3.set(r,d[3],d[4],d[5]),s.Vec3.set(o,d[6],d[7],d[8]),s.Vec3.subtract(a,t,e),l[0]=s.Vec3.dot(n,i),l[1]=s.Vec3.dot(r,i),l[2]=s.Vec3.dot(o,i),u[0]=s.Vec3.dot(n,a),u[1]=s.Vec3.dot(r,a),u[2]=s.Vec3.dot(o,a);for(var p=0;p<3;++p){if(0===l[p]){if(-u[p]-c[p]>0||-u[p]+c[p]<0)return 0;l[p]=1e-7}h[2*p+0]=(u[p]+c[p])/l[p],h[2*p+1]=(u[p]-c[p])/l[p]}var m=Math.max(Math.max(Math.min(h[0],h[1]),Math.min(h[2],h[3])),Math.min(h[4],h[5])),v=Math.min(Math.min(Math.max(h[0],h[1]),Math.max(h[2],h[3])),Math.max(h[4],h[5]));return v<0||m>v||m<0?0:m}})(),k=(b=new s.Vec3,T=new s.Vec3,w=new s.Vec3,E=new s.Vec3,function(t,e){return s.Vec3.subtract(b,t.center,t.halfExtents),s.Vec3.add(T,t.center,t.halfExtents),s.Vec3.subtract(w,e.center,e.halfExtents),s.Vec3.add(E,e.center,e.halfExtents),b.x<=E.x&&T.x>=w.x&&b.y<=E.y&&T.y>=w.y&&b.z<=E.z&&T.z>=w.z});function z(t,e,i){s.Vec3.set(i[0],t.x,e.y,e.z),s.Vec3.set(i[1],t.x,e.y,t.z),s.Vec3.set(i[2],t.x,t.y,e.z),s.Vec3.set(i[3],t.x,t.y,t.z),s.Vec3.set(i[4],e.x,e.y,e.z),s.Vec3.set(i[5],e.x,e.y,t.z),s.Vec3.set(i[6],e.x,t.y,e.z),s.Vec3.set(i[7],e.x,t.y,t.z)}function U(t,e,i,n,r,o){s.Vec3.set(o[0],t.x+i.x*e.x+n.x*e.y+r.x*e.z,t.y+i.y*e.x+n.y*e.y+r.y*e.z,t.z+i.z*e.x+n.z*e.y+r.z*e.z),s.Vec3.set(o[1],t.x-i.x*e.x+n.x*e.y+r.x*e.z,t.y-i.y*e.x+n.y*e.y+r.y*e.z,t.z-i.z*e.x+n.z*e.y+r.z*e.z),s.Vec3.set(o[2],t.x+i.x*e.x-n.x*e.y+r.x*e.z,t.y+i.y*e.x-n.y*e.y+r.y*e.z,t.z+i.z*e.x-n.z*e.y+r.z*e.z),s.Vec3.set(o[3],t.x+i.x*e.x+n.x*e.y-r.x*e.z,t.y+i.y*e.x+n.y*e.y-r.y*e.z,t.z+i.z*e.x+n.z*e.y-r.z*e.z),s.Vec3.set(o[4],t.x-i.x*e.x-n.x*e.y-r.x*e.z,t.y-i.y*e.x-n.y*e.y-r.y*e.z,t.z-i.z*e.x-n.z*e.y-r.z*e.z),s.Vec3.set(o[5],t.x+i.x*e.x-n.x*e.y-r.x*e.z,t.y+i.y*e.x-n.y*e.y-r.y*e.z,t.z+i.z*e.x-n.z*e.y-r.z*e.z),s.Vec3.set(o[6],t.x-i.x*e.x+n.x*e.y-r.x*e.z,t.y-i.y*e.x+n.y*e.y-r.y*e.z,t.z-i.z*e.x+n.z*e.y-r.z*e.z),s.Vec3.set(o[7],t.x-i.x*e.x-n.x*e.y+r.x*e.z,t.y-i.y*e.x-n.y*e.y+r.y*e.z,t.z-i.z*e.x-n.z*e.y+r.z*e.z)}function H(t,e){for(var i=s.Vec3.dot(e,t[0]),n=i,r=1;r<8;++r){var o=s.Vec3.dot(e,t[r]);i=on?o:n}return[i,n]}var W,j=(function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=new s.Vec3(0,0,0);for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=new s.Vec3(0,0,0),n[r]=new s.Vec3(0,0,0);var o=new s.Vec3,a=new s.Vec3;return function(e,r){var c=r.orientation.m;s.Vec3.set(t[0],1,0,0),s.Vec3.set(t[1],0,1,0),s.Vec3.set(t[2],0,0,1),s.Vec3.set(t[3],c[0],c[1],c[2]),s.Vec3.set(t[4],c[3],c[4],c[5]),s.Vec3.set(t[5],c[6],c[7],c[8]);for(var l=0;l<3;++l)s.Vec3.cross(t[6+3*l],t[l],t[0]),s.Vec3.cross(t[7+3*l],t[l],t[1]),s.Vec3.cross(t[7+3*l],t[l],t[2]);s.Vec3.subtract(o,e.center,e.halfExtents),s.Vec3.add(a,e.center,e.halfExtents),z(o,a,i),U(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var u=0;u<15;++u){var h=H(i,t[u]),_=H(n,t[u]);if(_[0]>h[1]||h[0]>_[1])return 0}return 1}})(),X=function(t,e){var i=t.halfExtents.x*Math.abs(e.n.x)+t.halfExtents.y*Math.abs(e.n.y)+t.halfExtents.z*Math.abs(e.n.z),n=s.Vec3.dot(e.n,t.center);return n+ie.d?0:1},q=function(t,e){for(var i=0;in.halfExtents.x?e++:t[u].x<-n.halfExtents.x&&i++;if(e===r.vertices.length||i===r.vertices.length)return 0;e=0,i=0;for(var h=0;hn.halfExtents.y?e++:t[h].y<-n.halfExtents.y&&i++;if(e===r.vertices.length||i===r.vertices.length)return 0;e=0,i=0;for(var _=0;_n.halfExtents.z?e++:t[_].z<-n.halfExtents.z&&i++;return e===r.vertices.length||i===r.vertices.length?0:1}})(),J=(function(){var t=new s.Vec3(0,0,0),e=new s.Mat3;return function(i,n){return s.Vec3.subtract(t,n,i.center),s.Vec3.transformMat3(t,t,s.Mat3.transpose(e,i.orientation)),r=t,o=i.halfExtents,Math.abs(r.x)e.d?0:1}),K=function(t,e){for(var i=0;ir.halfExtents.x?i++:e<-r.halfExtents.x&&n++;if(i===a.vertices.length||n===a.vertices.length)return 0;i=0,n=0;for(var d=0;dr.halfExtents.y?i++:e<-r.halfExtents.y&&n++;if(i===a.vertices.length||n===a.vertices.length)return 0;i=0,n=0;for(var p=0;pr.halfExtents.z?i++:e<-r.halfExtents.z&&n++;return i===a.vertices.length||n===a.vertices.length?0:1}})(),$=(function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=new s.Vec3(0,0,0);for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=new s.Vec3(0,0,0),n[r]=new s.Vec3(0,0,0);return function(e,r){var o=e.orientation.m,a=r.orientation.m;s.Vec3.set(t[0],o[0],o[1],o[2]),s.Vec3.set(t[1],o[3],o[4],o[5]),s.Vec3.set(t[2],o[6],o[7],o[8]),s.Vec3.set(t[3],a[0],a[1],a[2]),s.Vec3.set(t[4],a[3],a[4],a[5]),s.Vec3.set(t[5],a[6],a[7],a[8]);for(var c=0;c<3;++c)s.Vec3.cross(t[6+3*c],t[c],t[0]),s.Vec3.cross(t[7+3*c],t[c],t[1]),s.Vec3.cross(t[7+3*c],t[c],t[2]);U(e.center,e.halfExtents,t[0],t[1],t[2],i),U(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var l=0;l<15;++l){var u=H(i,t[l]),h=H(n,t[l]);if(h[0]>u[1]||u[0]>h[1])return 0}return 1}})(),tt=function(t,e){var i=s.Vec3.dot(e.n,t.center),n=t.radius*e.n.length();return i+ne.d?0:1},et=function(t,e){for(var i=0;iu)){s.Vec3.add(t,c,s.Vec3.multiplyScalar(t,l,a));for(var _=0;_<6;_++)if(_!==r&&_!==r+e[r]){var f=n.planes[_];if(s.Vec3.dot(f.n,t)0&&(t.d=e.d/i),t},t.prototype.transform=function(t){r.Mat4.invert(c,t),r.Mat4.transpose(c,c),r.Vec4.set(l,this.n.x,this.n.y,this.n.z,this.d),r.Vec4.transformMat4(l,l,c),r.Vec3.set(this.n,l.x,l.y,l.z),this.d=l.w},t})();i.default=u,e.exports=i.default}),{"../value-types":266,"./enums":136}],143:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=t("../value-types"),s=(n=t("./enums"))&&n.__esModule?n:{default:n},o=(function(){function t(t,e,i,n,o,a){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=0),void 0===a&&(a=-1),this.o=void 0,this.d=void 0,this._type=void 0,this._type=s.default.SHAPE_RAY,this.o=new r.Vec3(t,e,i),this.d=new r.Vec3(n,o,a)}return t.create=function(e,i,n,r,s,o){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=1),new t(e,i,n,r,s,o)},t.clone=function(e){return new t(e.o.x,e.o.y,e.o.z,e.d.x,e.d.y,e.d.z)},t.copy=function(t,e){return r.Vec3.copy(t.o,e.o),r.Vec3.copy(t.d,e.d),t},t.fromPoints=function(t,e,i){return r.Vec3.copy(t.o,e),r.Vec3.normalize(t.d,r.Vec3.subtract(t.d,i,e)),t},t.set=function(t,e,i,n,r,s,o){return t.o.x=e,t.o.y=i,t.o.z=n,t.d.x=r,t.d.y=s,t.d.z=o,t},t.prototype.computeHit=function(t,e){r.Vec3.normalize(t,this.d),r.Vec3.scaleAndAdd(t,this.o,t,e)},t})();i.default=o,e.exports=i.default}),{"../value-types":266,"./enums":136}],144:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=t("../value-types"),s=(n=t("./enums"))&&n.__esModule?n:{default:n},o=new r.Vec3,a=(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=1),this.center=void 0,this.radius=void 0,this._type=void 0,this._type=s.default.SHAPE_SPHERE,this.center=new r.Vec3(t,e,i),this.radius=n}t.create=function(e,i,n,r){return new t(e,i,n,r)},t.clone=function(e){return new t(e.center.x,e.center.y,e.center.z,e.radius)},t.copy=function(t,e){return r.Vec3.copy(t.center,e.center),t.radius=e.radius,t},t.fromPoints=function(t,e,i){return r.Vec3.multiplyScalar(t.center,r.Vec3.add(o,e,i),.5),t.radius=.5*r.Vec3.subtract(o,i,e).len(),t},t.set=function(t,e,i,n,r){return t.center.x=e,t.center.y=i,t.center.z=n,t.radius=r,t};var e=t.prototype;return e.clone=function(){return t.clone(this)},e.copy=function(e){return t.copy(this,e)},e.getBoundary=function(t,e){r.Vec3.set(t,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),r.Vec3.set(e,this.center.x+this.radius,this.center.y+this.radius,this.center.z+this.radius)},e.transform=function(t,e,i,n,s){r.Vec3.transformMat4(s.center,this.center,t),s.radius=this.radius*n.maxAxis()},e.translateAndRotate=function(t,e,i){r.Vec3.transformMat4(i.center,this.center,t)},e.setScale=function(t,e){e.radius=this.radius*t.maxAxis()},t})();i.default=a,e.exports=i.default}),{"../value-types":266,"./enums":136}],145:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=s(t("../value-types/vec3")),r=s(t("./enums"));function s(t){return t&&t.__esModule?t:{default:t}}var o=(function(){function t(t,e,i,s,o,a,c,l,u){this.a=void 0,this.b=void 0,this.c=void 0,this._type=void 0,this.a=new n.default(t,e,i),this.b=new n.default(s,o,a),this.c=new n.default(c,l,u),this._type=r.default.SHAPE_TRIANGLE}return t.create=function(e,i,n,r,s,o,a,c,l){return new t(e,i,n,r,s,o,a,c,l)},t.clone=function(e){return new t(e.a.x,e.a.y,e.a.z,e.b.x,e.b.y,e.b.z,e.c.x,e.c.y,e.c.z)},t.copy=function(t,e){return n.default.copy(t.a,e.a),n.default.copy(t.b,e.b),n.default.copy(t.c,e.c),t},t.fromPoints=function(t,e,i,r){return n.default.copy(t.a,e),n.default.copy(t.b,i),n.default.copy(t.c,r),t},t.set=function(t,e,i,n,r,s,o,a,c,l){return t.a.x=e,t.a.y=i,t.a.z=n,t.b.x=r,t.b.y=s,t.b.z=o,t.c.x=a,t.c.y=c,t.c.z=l,t},t})();i.default=o,e.exports=i.default}),{"../value-types/vec3":276,"./enums":136}],146:[(function(t,e){"use strict";var i=t("../components/CCRenderComponent"),n=t("../assets/material/CCMaterial"),r=t("./types"),s=r.LineCap,o=r.LineJoin,a=cc.Class({name:"cc.Graphics",extends:i,editor:!1,ctor:function(){this._impl=new a._Impl(this)},properties:{_lineWidth:2,_strokeColor:cc.Color.BLACK,_lineJoin:o.MITER,_lineCap:s.BUTT,_fillColor:cc.Color.WHITE,_miterLimit:10,lineWidth:{get:function(){return this._lineWidth},set:function(t){this._lineWidth=t,this._impl.lineWidth=t}},lineJoin:{get:function(){return this._lineJoin},set:function(t){this._lineJoin=t,this._impl.lineJoin=t},type:o},lineCap:{get:function(){return this._lineCap},set:function(t){this._lineCap=t,this._impl.lineCap=t},type:s},strokeColor:{get:function(){return this._strokeColor},set:function(t){this._impl.strokeColor=this._strokeColor=cc.color(t)}},fillColor:{get:function(){return this._fillColor},set:function(t){this._impl.fillColor=this._fillColor=cc.color(t)}},miterLimit:{get:function(){return this._miterLimit},set:function(t){this._miterLimit=t,this._impl.miterLimit=t}}},statics:{LineJoin:o,LineCap:s},onRestore:function(){this._impl||(this._impl=new a._Impl(this))},onDestroy:function(){this.clear(!0),this._super(),this._impl=null},_getDefaultMaterial:function(){return n.getBuiltinMaterial("2d-graphics")},_updateMaterial:function(){var t=this._materials[0];t&&(void 0!==t.getDefine("CC_USE_MODEL")&&t.define("CC_USE_MODEL",!0),void 0!==t.getDefine("CC_SUPPORT_standard_derivatives")&&cc.sys.glExtension("OES_standard_derivatives")&&t.define("CC_SUPPORT_standard_derivatives",!0))},moveTo:function(t,e){this._impl.moveTo(t,e)},lineTo:function(t,e){this._impl.lineTo(t,e)},bezierCurveTo:function(t,e,i,n,r,s){this._impl.bezierCurveTo(t,e,i,n,r,s)},quadraticCurveTo:function(t,e,i,n){this._impl.quadraticCurveTo(t,e,i,n)},arc:function(t,e,i,n,r,s){this._impl.arc(t,e,i,n,r,s)},ellipse:function(t,e,i,n){this._impl.ellipse(t,e,i,n)},circle:function(t,e,i){this._impl.circle(t,e,i)},rect:function(t,e,i,n){this._impl.rect(t,e,i,n)},roundRect:function(t,e,i,n,r){this._impl.roundRect(t,e,i,n,r)},fillRect:function(t,e,i,n){this.rect(t,e,i,n),this.fill()},clear:function(t){this._impl.clear(t),this._assembler&&this._assembler.clear(t)},close:function(){this._impl.close()},stroke:function(){this._assembler||this._resetAssembler(),this._assembler.stroke(this)},fill:function(){this._assembler||this._resetAssembler(),this._assembler.fill(this)}});cc.Graphics=e.exports=a,cc.Graphics.Types=r,cc.Graphics.Helper=t("./helper")}),{"../assets/material/CCMaterial":77,"../components/CCRenderComponent":111,"./helper":147,"./types":149}],147:[(function(t,e){"use strict";var i=t("./types").PointFlags,n=Math.PI,r=Math.min,s=Math.max,o=Math.cos,a=Math.sin,c=Math.abs,l=Math.sign,u=.5522847493;e.exports={arc:function(t,e,i,l,u,h,_){var f,d,p,m=0,v=0,y=0,g=0,x=0,A=0,C=0,S=0,b=0,T=0,w=0,E=0,B=0;if(v=h-u,_=_||!1)if(c(v)>=2*n)v=2*n;else for(;v<0;)v+=2*n;else if(c(v)>=2*n)v=2*-n;else for(;v>0;)v-=2*n;for(p=0|s(1,r(c(v)/(.5*n)+.5,5)),y=c(4/3*(1-o(f=v/p/2))/a(f)),_||(y=-y),d=0;d<=p;d++)A=e+(g=o(m=u+v*(d/p)))*l,C=i+(x=a(m))*l,S=-x*l*y,b=g*l*y,0===d?t.moveTo(A,C):t.bezierCurveTo(T+E,w+B,A-S,C-b,A,C),T=A,w=C,E=S,B=b},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,s,o){if(o<.1)t.rect(e,i,n,s);else{var a=r(o,.5*c(n))*l(n),h=r(o,.5*c(s))*l(s);t.moveTo(e,i+h),t.lineTo(e,i+s-h),t.bezierCurveTo(e,i+s-h*(1-u),e+a*(1-u),i+s,e+a,i+s),t.lineTo(e+n-a,i+s),t.bezierCurveTo(e+n-a*(1-u),i+s,e+n,i+s-h*(1-u),e+n,i+s-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,n,r,s,o,a,l,u,h,_,f){var d,p,m,v,y,g,x,A,C,S,b,T,w,E,B,M;_>10||(y=.5*(a+u),g=.5*(l+h),x=.5*((d=.5*(n+s))+(m=.5*(s+a))),A=.5*((p=.5*(r+o))+(v=.5*(o+l))),((B=c((s-u)*(E=h-r)-(o-h)*(w=u-n)))+(M=c((a-u)*E-(l-h)*w)))*(B+M)s&&(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,c=0,l=a.length;c0){for(var o=n.getPoints(),c=n.getNormals(),l=n.getFractions(),u=[],h=0,d=r.length;h0}function c(t,e,i){return m(t,e,i)>=0}function l(t,e,i){return m(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 h(t){_(t)||t.reverse()}function _(t){return t.length<3||f(t)>0}function f(t){var e,i=0;for(e=0;eE&&(B=T,E=M)}v=n(b,B,e),y=n(B,b,e)}return(g=g.concat(t(v))).concat(t(y))}for(g.push(e),b=g.length-1;b>=0;b--)0==g[b].length&&g.splice(b,0);return g},ForceCounterClockWise:h,IsCounterClockWise:_}}),{}],156:[(function(t,e){"use strict";var i=t("../CCNode").EventType,n=t("./CCPhysicsTypes").PTM_RATIO,r=t("./CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,s=t("./CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE,o=t("./utils").getWorldRotation,a=t("./CCPhysicsTypes").BodyType,c=new b2.Vec2,l=new b2.Vec2,u=cc.Vec2.ZERO,h=cc.Class({name:"cc.RigidBody",extends:cc.Component,editor:!1,properties:{_type:a.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:a,tooltip:!1,get:function(){return this._type},set:function(t){this._type=t,this._b2Body&&(t===a.Animated?this._b2Body.SetType(a.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*n,t.y=e.y*n}return t},set:function(t){this._linearVelocity=t;var e=this._b2Body;if(e){var i=e.m_linearVelocity;i.Set(t.x/n,t.y/n),e.SetLinearVelocity(i)}}},angularVelocity:{tooltip:!1,get:function(){return this._b2Body?this._b2Body.GetAngularVelocity()*s:this._angularVelocity},set:function(t){this._angularVelocity=t,this._b2Body&&this._b2Body.SetAngularVelocity(t*r)}},fixedRotation:{tooltip:!1,get:function(){return this._fixedRotation},set:function(t){this._fixedRotation=t,this._b2Body&&this._b2Body.SetFixedRotation(t)}},awake:{visible:!1,tooltip:!1,get:function(){return!!this._b2Body&&this._b2Body.IsAwake()},set:function(t){this._b2Body&&this._b2Body.SetAwake(t)}},awakeOnLoad:{default:!0,tooltip:!1,animatable:!1},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){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLocalPoint(c,e);e.x=i.x*n,e.y=i.y*n}return e},getWorldPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetWorldPoint(c,e);e.x=i.x*n,e.y=i.y*n}return e},getWorldVector:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetWorldVector(c,e);e.x=i.x*n,e.y=i.y*n}return e},getLocalVector:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLocalVector(c,e);e.x=i.x*n,e.y=i.y*n}return e},getWorldPosition:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetPosition();t.x=e.x*n,t.y=e.y*n}return t},getWorldRotation:function(){return this._b2Body?this._b2Body.GetAngle()*s:0},getLocalCenter:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetLocalCenter();t.x=e.x*n,t.y=e.y*n}return t},getWorldCenter:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetWorldCenter();t.x=e.x*n,t.y=e.y*n}return t},getLinearVelocityFromWorldPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLinearVelocityFromWorldPoint(c,e);e.x=i.x*n,e.y=i.y*n}return e},getMass:function(){return this._b2Body?this._b2Body.GetMass():0},getInertia:function(){return this._b2Body?this._b2Body.GetInertia()*n*n: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&&(c.Set(t.x/n,t.y/n),l.Set(e.x/n,e.y/n),this._b2Body.ApplyForce(c,l,i))},applyForceToCenter:function(t,e){this._b2Body&&(c.Set(t.x/n,t.y/n),this._b2Body.ApplyForceToCenter(c,e))},applyTorque:function(t,e){this._b2Body&&this._b2Body.ApplyTorque(t/n,e)},applyLinearImpulse:function(t,e,i){this._b2Body&&(c.Set(t.x/n,t.y/n),l.Set(e.x/n,e.y/n),this._b2Body.ApplyLinearImpulse(c,l,i))},applyAngularImpulse:function(t,e){this._b2Body&&this._b2Body.ApplyAngularImpulse(t/n/n,e)},syncPosition:function(t){var e=this._b2Body;if(e){var i,r=this.node.convertToWorldSpaceAR(u);if((i=this.type===a.Animated?e.GetLinearVelocity():e.GetPosition()).x=r.x/n,i.y=r.y/n,this.type===a.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=r*o(this.node);if(this.type===a.Animated&&t){var n=e.GetAngle(),s=cc.game.config.frameRate;e.SetAwake(!0),e.SetAngularVelocity((i-n)*s)}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(i.POSITION_CHANGED,this._onNodePositionChanged,this),t.on(i.ROTATION_CHANGED,this._onNodeRotationChanged,this),t.on(i.SCALE_CHANGED,this._onNodeScaleChanged,this)},_unregisterNodeEvents:function(){var t=this.node;t.off(i.POSITION_CHANGED,this._onNodePositionChanged,this),t.off(i.ROTATION_CHANGED,this._onNodeRotationChanged,this),t.off(i.SCALE_CHANGED,this._onNodeScaleChanged,this)},_onNodePositionChanged:function(){this.syncPosition(!0)},_onNodeRotationChanged:function(){this.syncRotation(!0)},_onNodeScaleChanged:function(){if(this._b2Body)for(var t=this.getComponents(cc.PhysicsCollider),e=0;e=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,n=-1e7,s=-1e7,o=this.body._getBody().GetTransform(),a=this._fixtures,c=0;cn&&(n=r.upperBound.x),r.upperBound.y>s&&(s=r.upperBound.y);t*=i,e*=i,n*=i,s*=i;var _=this._rect;return _.x=t,_.y=e,_.width=n-t,_.height=s-e,_}});cc.PhysicsCollider=e.exports=s}),{"../CCPhysicsTypes":154,"../utils":177}],162:[(function(t,e){"use strict";var i=t("../CCPhysicsTypes").PTM_RATIO,n=t("../CCPolygonSeparator"),r=cc.Class({name:"cc.PhysicsPolygonCollider",extends:cc.PhysicsCollider,mixins:[cc.Collider.Polygon],editor:{menu:!1,inspector:!1,help:"i18n:COMPONENT.help_url.edit-collider-component",requireComponent:cc.RigidBody},_createShape:function(t){var e=[],r=this.points;r.length>0&&r[0].equals(r[r.length-1])&&(r.length-=1);for(var s=n.ConvexPartition(r),o=this.offset,a=0;a=2?1:n)},i.prototype.getFixtures=function(){return this._fixtures},i.prototype.getPoints=function(){return this._points},i.prototype.getNormals=function(){return this._normals},i.prototype.getFractions=function(){return this._fractions},cc.PhysicsRayCastCallback=e.exports=i}),{}],177:[(function(t,e){"use strict";e.exports={getWorldRotation:function(t){for(var e=t.angle,i=t.parent;i.parent;)e+=i.angle,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.angle;for(var i=t.parent;i.parent;)e-=-i.angle,i=i.parent;return e}}}),{}],178:[(function(t,e){"use strict";var i=t("./js"),n=t("./CCEnum"),r=t("./utils"),s=(r.isPlainEmptyObj_DEV,r.cloneable_DEV,t("./attribute")),o=s.DELIMETER,a=t("./preprocess-class");t("./requiring-frame");var c=["name","extends","mixins","ctor","__ctor__","properties","statics","editor","__ES6__"];function l(t,e){t.indexOf(e)<0&&t.push(e)}var u={datas:null,push:function(t){if(this.datas)this.datas.push(t);else{this.datas=[t];var e=this;setTimeout((function(){e.init()}),0)}},init:function(){var t=this.datas;if(t){for(var e=0;e0?o:null,!0);var h=a.prototype;if(e&&(u||(i.extend(a,e),h=a.prototype),a.$super=e),n){for(var _=n.length-1;_>=0;_--){var f=n[_];p(h,f.prototype),p(a,f,(function(t){return f.hasOwnProperty(t)&&!0})),T._isCCClass(f)&&p(s.getClassAttrs(a),s.getClassAttrs(f))}h.constructor=a}return u||(h.__initProps__=g),i.setClassName(t,a),a}function v(t,e,n,r){var s=cc.Component,o=cc._RF.peek();if(o&&i.isChildClassOf(e,s)){if(i.isChildClassOf(o.cls,s))return cc.errorID(3615),null;t=t||o.script}var a=m(t,e,n,r);if(o)if(i.isChildClassOf(e,s)){var c=o.uuid;c&&i._setClassId(c,a),o.cls=a}else i.isChildClassOf(o.cls,s)||(o.cls=a);return a}function y(t,e){var i=null,n=0,r=0;return (function(){for(var s=null,a=null,c=null,l=0;l0?s?2===o?function(){this._super=null,this.__initProps__(r),t[0].apply(this,arguments),t[1].apply(this,arguments)}:function(){this._super=null,this.__initProps__(r);for(var e=0;e=0)){var s=e[r];if("function"==typeof s){var o=i.getPropertyDescriptor(t.prototype,r);if(o){var a=o.value;if("function"==typeof a){C.test(s)&&(n=!0,e[r]=(function(t,e){return function(){var i=this._super;this._super=t;var n=e.apply(this,arguments);return this._super=i,n}})(a,s));continue}}}}return n}function b(t,e,i,n,r,c){if(t.__props__=[],n&&n.__props__&&(t.__props__=n.__props__.slice()),r)for(var l=0;l=0)){var f=t[_];a.validateMethodWithProps(f,_,e,s,n)&&i.value(s.prototype,_,f,!0,!0)}var d=t.editor;return d&&cc.Component._registerEditorProps(s,d),s}/xyz/.test((function(){xyz})),T._isCCClass=function(t){return t&&t.hasOwnProperty("__ctors__")},T._fastDefine=function(t,e,n){i.setClassName(t,e);for(var r=e.__props__=e.__values__=Object.keys(n),a=s.getClassAttrs(e),c=0;c=2&&((a||l())[c+"min"]=_[0],a[c+"max"]=_[1],_.length>2&&(a[c+"step"]=_[2])),h("min","number"),h("max","number"),h("step","number"),h("userData","object")}cc.Class=T,e.exports={isArray:function(t){return t=d(t),Array.isArray(t)},fastDefine:T._fastDefine,getNewValueTypeCode:!1,IDENTIFIER_RE:/^[A-Za-z_$][0-9A-Za-z_$]*$/,escapeForJS:function(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},getDefault:d}}),{"./CCEnum":180,"./attribute":190,"./js":199,"./preprocess-class":200,"./requiring-frame":201,"./utils":202}],179:[(function(t,e){"use strict";t("./CCClass");var i=t("./preprocess-class"),n=t("./js"),r="__ccclassCache__";function s(t){return t}function o(t,e){return t[e]||(t[e]={})}function a(t){return function(e){return"function"==typeof e?t(e):function(i){return t(i,e)}}}function c(t,e){return function(t){return function(i){return e(i,t)}}}var l=c.bind(null,!1);function u(){return c.bind(null,!1)}var h=u(),_=u();function f(t){return o(t,r)}function d(t){var e;try{e=t()}catch(i){return t}return"object"!=typeof e||null===e?e:t}function p(t){var e;try{e=new t}catch(i){return{}}return e}function m(t,e,r,s,o,a){var c,l=o&&(o.get||o.set);s&&(c=i.getFullFormOfProperty(s,l));var u=e[r],h=n.mixin(u||{},c||s||{});if(l)o.get&&(h.get=o.get),o.set&&(h.set=o.set);else{var _=void 0;if(o)o.initializer&&(_=d(o.initializer));else{var f=a.default||(a.default=p(t));f.hasOwnProperty(r)&&(_=f[r])}h.default=_}e[r]=h}var v=a((function(t,e){var i=n.getSuper(t);i===Object&&(i=null);var s={name:e,extends:i,ctor:t,__ES6__:!0},o=t[r];if(o){var a=o.proto;a&&n.mixin(s,a),t[r]=void 0}return cc.Class(s)}));function y(t,e,i){return t((function(t,n){var r=f(t);if(r){var s=void 0!==i?i:n,a=o(r,"proto");o(a,"editor")[e]=s}}),e)}function g(t){return t(s)}var x=g(a),A=y(l,"requireComponent"),C=g(h),S=y(_,"executionOrder"),b=g(a),T=g(a),w=g(h),E=g(h),B=g(h);cc._decorator=e.exports={ccclass:v,property:function(t,e,i){var n=null;function r(t,e,i){var r=f(t.constructor);if(r){var s=o(r,"proto"),a=o(s,"properties");m(t.constructor,a,e,n,i,r)}}if(void 0===e)return n=t,r;r(t,e,i)},executeInEditMode:x,requireComponent:A,menu:C,executionOrder:S,disallowMultiple:b,playOnFocus:T,inspector:w,icon:E,help:B,mixins:function(){for(var t=[],e=0;ee){var u=l.getID();delete o[u],delete a[u],this._touchCount--,-1===r?(r=c,this._indexBitsUsed|=1<>=1}return r},_glView:null,_updateCanvasBoundingRect:function(){var t=cc.game.canvas,e=this._canvasBoundingRect,i=document.documentElement,n=window.pageXOffset-i.clientLeft,r=window.pageYOffset-i.clientTop;if(t.getBoundingClientRect){var s=t.getBoundingClientRect();e.left=s.left+n,e.top=s.top+r,e.width=s.width,e.height=s.height}else t instanceof HTMLCanvasElement?(e.left=n,e.top=r,e.width=t.width,e.height=t.height):(e.left=n,e.top=r,e.width=parseInt(t.style.width),e.height=parseInt(t.style.height))},handleTouchesBegin:function(t){for(var e,i,s=n.now(),o=[],a=this._touches,c=this._touchesIntegerDict,l=this._touchesCache,u=0,h=t.length;u0){this._glView._convertTouchesWithScale(o);var d=new cc.Event.EventTouch(o);d._eventCode=cc.Event.EventTouch.BEGAN,r.dispatchEvent(d)}},handleTouchesMove:function(t){for(var e,i,s=n.now(),o=[],a=this._touches,c=this._touchesIntegerDict,l=0,u=t.length;l0){this._glView._convertTouchesWithScale(o);var _=new cc.Event.EventTouch(o);_._eventCode=cc.Event.EventTouch.MOVED,r.dispatchEvent(_)}},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,r.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.CANCELED,r.dispatchEvent(i)}this._preTouchPool.length=0},getSetOfTouchesEndOrCancel:function(t){for(var e,i,n,r=[],s=this._touches,o=this._touchesIntegerDict,a=this._touchesCache,c=0,l=t.length;c=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 cc.sys.browserType!==cc.sys.BROWSER_TYPE_QQ&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_UC&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_SAFARI||this._updateCanvasBoundingRect(),null!=t.pageX?{x:t.pageX,y:t.pageY}:(e.left-=document.body.scrollLeft,e.top-=document.body.scrollTop,{x:t.clientX,y:t.clientY})},getTouchesByEvent:function(t,e){for(var i,r,o,a=[],c=this._glView,l=this._preTouchPoint,u=t.changedTouches.length,h=0;hthis._accelInterval&&(this._accelCurTime-=this._accelInterval,r.dispatchEvent(new cc.Event.EventAcceleration(this._acceleration))),this._accelCurTime+=t}};e.exports=cc.internal.inputManager=o}),{"../event-manager":128,"./CCMacro":183,"./CCSys":187}],183:[(function(t,e){"use strict";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,ENABLE_TRANSPARENT_CANVAS:!1,ENABLE_WEBGL_ANTIALIAS:!1,ENABLE_CULLING:!1,CLEANUP_IMAGE_CACHE:!1,SHOW_MESH_WIREFRAME:!1,SHOW_MESH_NORMAL:!1,ENABLE_MULTI_TOUCH:!0,ALLOW_IMAGE_BITMAP:!cc.sys.isMobile,ENABLE_NATIVE_TTF_RENDERER:!0},Object.defineProperty(cc.macro,"ROTATE_ACTION_CCW",{set:function(t){cc.RotateTo&&cc.RotateBy&&(cc.RotateTo._reverse=cc.RotateBy._reverse=t)}}),cc.macro.SUPPORT_TEXTURE_FORMATS=[".astc",".pkm",".pvr",".webp",".jpg",".jpeg",".bmp",".png"],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}),{}],184:[(function(t,e){"use strict";var i=t("./js"),n=t("./CCClass"),r=1;function s(){this._name="",this._objFlags=0}n.fastDefine("cc.Object",s,{_name:"",_objFlags:0}),i.value(s,"Flags",{Destroyed:r,DontSave:8,EditorOnly:16,Dirty:32,DontDestroy:64,PersistentMask:-4192741,Destroying:128,Deactivating:256,LockedInEditor:512,HideInHierarchy:1024,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 o=[];i.value(s,"_deferredDestroy",(function(){for(var t=o.length,e=0;e0)return void(t.webkitEnterFullscreen&&t.webkitEnterFullscreen());t.setAttribute("x5-video-player-fullscreen","true")}if(this._supportsFullScreen){if(t=t||document.documentElement,e){var n=this._fn.fullscreenchange;this._onfullscreenchange&&document.removeEventListener(n,this._onfullscreenchange),this._onfullscreenchange=e,document.addEventListener(n,e,!1)}if(i){var r=this._fn.fullscreenerror;this._onfullscreenerror&&document.removeEventListener(r,this._onfullscreenerror),this._onfullscreenerror=i,document.addEventListener(r,i,{once:!0})}var s=t[this._fn.requestFullscreen]();void 0===document[this._fn.fullscreenerror]&&window.Promise&&s instanceof Promise&&s.catch((function(){}))}},exitFullScreen:function(t){if(t&&"video"===t.tagName.toLowerCase()){if(cc.sys.os===cc.sys.OS_IOS&&cc.sys.isBrowser)return void(t.webkitExitFullscreen&&t.webkitExitFullscreen());t.setAttribute("x5-video-player-fullscreen","false")}return!this._supportsFullScreen||document[this._fn.exitFullscreen]()},autoFullScreen:function(t,e){t=t||document.body,this._ensureFullScreen(t,e),this.requestFullScreen(t,e)},disableAutoFullScreen:function(t){var e=cc.game.canvas||t,i=this._touchEvent;this._preOnTouch&&(e.removeEventListener(i,this._preOnTouch),this._preOnTouch=null)},_ensureFullScreen:function(t,e){var i=this,n=cc.game.canvas||t,r=this._fn.fullscreenerror,s=this._touchEvent;function o(){i._preOnFullScreenError=null,i._preOnTouch&&n.removeEventListener(s,i._preOnTouch),i._preOnTouch=function(){i._preOnTouch=null,i.requestFullScreen(t,e)},n.addEventListener(s,i._preOnTouch,{once:!0})}this._preOnFullScreenError&&t.removeEventListener(r,this._preOnFullScreenError),this._preOnFullScreenError=o,t.addEventListener(r,o,{once:!0})}},cc.screen.init()}),{}],187:[(function(t,e){"use strict";window._CCSettings&&_CCSettings.platform;var i="undefined"==typeof window?global:window,n=cc&&cc.sys?cc.sys:(function(){cc.sys={};var t,e,n=cc.sys;if(n.LANGUAGE_ENGLISH="en",n.LANGUAGE_CHINESE="zh",n.LANGUAGE_FRENCH="fr",n.LANGUAGE_ITALIAN="it",n.LANGUAGE_GERMAN="de",n.LANGUAGE_SPANISH="es",n.LANGUAGE_DUTCH="du",n.LANGUAGE_RUSSIAN="ru",n.LANGUAGE_KOREAN="ko",n.LANGUAGE_JAPANESE="ja",n.LANGUAGE_HUNGARIAN="hu",n.LANGUAGE_PORTUGUESE="pt",n.LANGUAGE_ARABIC="ar",n.LANGUAGE_NORWEGIAN="no",n.LANGUAGE_POLISH="pl",n.LANGUAGE_TURKISH="tr",n.LANGUAGE_UKRAINIAN="uk",n.LANGUAGE_ROMANIAN="ro",n.LANGUAGE_BULGARIAN="bg",n.LANGUAGE_UNKNOWN="unknown",n.OS_OPENHARMONY="OpenHarmony",n.OS_IOS="iOS",n.OS_ANDROID="Android",n.OS_WINDOWS="Windows",n.OS_MARMALADE="Marmalade",n.OS_LINUX="Linux",n.OS_BADA="Bada",n.OS_BLACKBERRY="Blackberry",n.OS_OSX="OS X",n.OS_WP8="WP8",n.OS_WINRT="WINRT",n.OS_UNKNOWN="Unknown",n.UNKNOWN=-1,n.WIN32=0,n.LINUX=1,n.MACOS=2,n.ANDROID=3,n.IPHONE=4,n.IPAD=5,n.BLACKBERRY=6,n.NACL=7,n.EMSCRIPTEN=8,n.TIZEN=9,n.WINRT=10,n.WP8=11,n.OPENHARMONY=12,n.MOBILE_BROWSER=100,n.DESKTOP_BROWSER=101,n.EDITOR_PAGE=102,n.EDITOR_CORE=103,n.WECHAT_GAME=104,n.QQ_PLAY=105,n.FB_PLAYABLE_ADS=106,n.BAIDU_GAME=107,n.VIVO_GAME=108,n.OPPO_GAME=109,n.HUAWEI_GAME=110,n.XIAOMI_GAME=111,n.JKW_GAME=112,n.ALIPAY_GAME=113,n.WECHAT_GAME_SUB=114,n.BAIDU_GAME_SUB=115,n.QTT_GAME=116,n.BYTEDANCE_GAME=117,n.BYTEDANCE_GAME_SUB=118,n.LINKSURE=119,n.TAOBAO=120,n.TAOBAO_MINIGAME=121,n.BROWSER_TYPE_WECHAT="wechat",n.BROWSER_TYPE_ANDROID="androidbrowser",n.BROWSER_TYPE_IE="ie",n.BROWSER_TYPE_EDGE="edge",n.BROWSER_TYPE_QQ="qqbrowser",n.BROWSER_TYPE_MOBILE_QQ="mqqbrowser",n.BROWSER_TYPE_UC="ucbrowser",n.BROWSER_TYPE_UCBS="ucbs",n.BROWSER_TYPE_360="360browser",n.BROWSER_TYPE_BAIDU_APP="baiduboxapp",n.BROWSER_TYPE_BAIDU="baidubrowser",n.BROWSER_TYPE_MAXTHON="maxthon",n.BROWSER_TYPE_OPERA="opera",n.BROWSER_TYPE_OUPENG="oupeng",n.BROWSER_TYPE_MIUI="miuibrowser",n.BROWSER_TYPE_FIREFOX="firefox",n.BROWSER_TYPE_SAFARI="safari",n.BROWSER_TYPE_CHROME="chrome",n.BROWSER_TYPE_LIEBAO="liebao",n.BROWSER_TYPE_QZONE="qzone",n.BROWSER_TYPE_SOUGOU="sogou",n.BROWSER_TYPE_HUAWEI="huawei",n.BROWSER_TYPE_UNKNOWN="unknown",n.isNative=!1,n.isBrowser="object"==typeof window&&"object"==typeof document&&!0,n.glExtension=function(t){return!!cc.renderer.device.ext(t)},n.getMaxJointMatrixSize=function(){if(!n._maxJointMatrixSize){var t=cc.game._renderContext,e=Math.floor(t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS)/4)-10;n._maxJointMatrixSize=e<50?0:50}return n._maxJointMatrixSize},n.getSafeAreaRect=function(){var t=cc.view.getVisibleSize();return cc.rect(0,0,t.width,t.height)},i.__globalAdapter&&i.__globalAdapter.adaptSys)i.__globalAdapter.adaptSys(n);else{var r=window,s=r.navigator,o=document,a=o.documentElement,c=s.userAgent.toLowerCase();n.isMobile=/mobile|android|iphone|ipad/.test(c),"undefined"!=typeof FbPlayableAd?n.platform=n.FB_PLAYABLE_ADS:n.platform=n.isMobile?n.MOBILE_BROWSER:n.DESKTOP_BROWSER;var l=s.language;l=l||s.browserLanguage,n.languageCode=l.toLowerCase(),l=l?l.split("-")[0]:n.LANGUAGE_ENGLISH,n.language=l;var u=!1,h=!1,_="",f=0,d=/android\s*(\d+(?:\.\d+)*)/i.exec(c)||/android\s*(\d+(?:\.\d+)*)/i.exec(s.platform);d&&(u=!0,_=d[1]||"",f=parseInt(_)||0),(d=/(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(c))?(h=!0,_=d[2]||"",f=parseInt(_)||0):(/(iPhone|iPad|iPod)/.exec(s.platform)||"MacIntel"===s.platform&&s.maxTouchPoints&&s.maxTouchPoints>1)&&(h=!0,_="",f=0);var p=n.OS_UNKNOWN;-1!==s.appVersion.indexOf("Win")?p=n.OS_WINDOWS:h?p=n.OS_IOS:-1!==s.appVersion.indexOf("Mac")?p=n.OS_OSX:-1!==s.appVersion.indexOf("X11")&&-1===s.appVersion.indexOf("Linux")?p=n.OS_UNIX:u?p=n.OS_ANDROID:-1===s.appVersion.indexOf("Linux")&&-1===c.indexOf("ubuntu")||(p=n.OS_LINUX),n.os=p,n.osVersion=_,n.osMainVersion=f,n.browserType=n.BROWSER_TYPE_UNKNOWN,(function(){var t=/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(c)||/qq|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(c)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(c),e=t?t[0].toLowerCase():n.BROWSER_TYPE_UNKNOWN;"safari"===e&&u?e=n.BROWSER_TYPE_ANDROID:"qq"===e&&c.match(/android.*applewebkit/i)&&(e=n.BROWSER_TYPE_ANDROID);var i={micromessenger:n.BROWSER_TYPE_WECHAT,trident:n.BROWSER_TYPE_IE,edge:n.BROWSER_TYPE_EDGE,"360 aphone":n.BROWSER_TYPE_360,mxbrowser:n.BROWSER_TYPE_MAXTHON,"opr/":n.BROWSER_TYPE_OPERA,ubrowser:n.BROWSER_TYPE_UC,huaweibrowser:n.BROWSER_TYPE_HUAWEI};"qqbrowser"!==e&&"mqqbrowser"!==e||c.match(/wechat|micromessenger/i)&&(e=n.BROWSER_TYPE_WECHAT),n.browserType=i[e]||e})(),n.browserVersion="",(e=c.match(/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i))||(e=c.match(/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i)),n.browserVersion=e?e[4]:"";var m=window.innerWidth||document.documentElement.clientWidth,v=window.innerHeight||document.documentElement.clientHeight,y=window.devicePixelRatio||1;n.windowPixelResolution={width:y*m,height:y*v},n._checkWebGLRenderMode=function(){if(cc.game.renderType!==cc.game.RENDER_TYPE_WEBGL)throw new Error("This feature supports WebGL render mode only.")};var g=document.createElement("canvas");try{var x=n.localStorage=r.localStorage;x.setItem("storage",""),x.removeItem("storage"),x=null}catch(B){var A=function(){cc.warnID(5200)};n.localStorage={getItem:A,setItem:A,removeItem:A,clear:A}}var C=g.toDataURL("image/webp").startsWith("data:image/webp"),S=!!g.getContext("2d"),b=!1;r.WebGLRenderingContext&&(b=!0);var T,w=n.capabilities={canvas:S,opengl:b,webp:C,imageBitmap:!1};"undefined"!=typeof createImageBitmap&&"undefined"!=typeof Blob&&(g.width=g.height=2,createImageBitmap(g,{}).then((function(t){w.imageBitmap=!0,t.close&&t.close()})).catch((function(){}))),(void 0!==a.ontouchstart||void 0!==o.ontouchstart||s.msPointerEnabled||"string"==typeof __wxjs_environment&&"miniprogram"===__wxjs_environment)&&(w.touches=!0),void 0!==a.onmouseup&&(w.mouse=!0),void 0!==a.onkeyup&&(w.keyboard=!0),(r.DeviceMotionEvent||r.DeviceOrientationEvent)&&(w.accelerometer=!0),(function(){n.browserVersion;var t=!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext);T={ONLY_ONE:!1,WEB_AUDIO:t,DELAY_CREATE_CTX:!1},n.os===n.OS_IOS&&(T.USE_LOADER_EVENT="loadedmetadata"),n.browserType===n.BROWSER_TYPE_FIREFOX&&(T.DELAY_CREATE_CTX=!0,T.USE_LOADER_EVENT="canplay"),n.os===n.OS_ANDROID&&n.browserType===n.BROWSER_TYPE_UC&&(T.ONE_SOURCE=!0)})();try{T.WEB_AUDIO&&(T.context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),T.DELAY_CREATE_CTX&&setTimeout((function(){T.context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}),0))}catch(M){T.WEB_AUDIO=!1,cc.logID(5201)}var E=[];(t=document.createElement("audio")).canPlayType&&(t.canPlayType('audio/ogg; codecs="vorbis"')&&E.push(".ogg"),t.canPlayType("audio/mpeg")&&E.push(".mp3"),t.canPlayType('audio/wav; codecs="1"')&&E.push(".wav"),t.canPlayType("audio/mp4")&&E.push(".mp4"),t.canPlayType("audio/x-m4a")&&E.push(".m4a")),T.format=E,n.__audioSupport=T}return n.NetworkType={NONE:0,LAN:1,WWAN:2},n.getNetworkType=function(){return n.NetworkType.LAN},n.getBatteryLevel=function(){return 1},n.garbageCollect=function(){},n.restartVM=function(){},n.isObjectValid=function(t){return!!t},n.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)},n.openURL=function(t){window.open(t)},n.now=function(){return Date.now?Date.now():+new Date},n})();e.exports=n}),{}],188:[(function(t,e){"use strict";var i=t("../event/event-target"),n=t("../platform/js"),r=t("../renderer");t("../platform/CCClass");var s={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&&(s.adaptationType=cc.sys.BROWSER_TYPE_SAFARI),s.adaptationType){case cc.sys.BROWSER_TYPE_SAFARI:case cc.sys.BROWSER_TYPE_SOUGOU:case cc.sys.BROWSER_TYPE_UC:s.meta["minimal-ui"]="true",s.availWidth=function(t){return t.clientWidth},s.availHeight=function(t){return t.clientHeight}}var o=null,a=function(){i.call(this);var t=this,e=cc.ContainerStrategy,n=cc.ContentStrategy;s.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._maxPixelRatio=2,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,n.EXACT_FIT),t._rpShowAll=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,n.SHOW_ALL),t._rpNoBorder=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,n.NO_BORDER),t._rpFixedHeight=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,n.FIXED_HEIGHT),t._rpFixedWidth=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,n.FIXED_WIDTH),cc.game.once(cc.game.EVENT_ENGINE_INITED,this.init,this)};cc.js.extend(a,i),cc.js.mixin(a.prototype,{init:function(){this._initFrameSize();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(t){var e;e=this.setDesignResolutionSize?this:cc.view;var i=cc.sys;if(i.browserType!==i.BROWSER_TYPE_UC||i.os!==i.OS_IOS){var n=e._frameSize.width,r=e._frameSize.height,s=e._isRotated;if(cc.sys.isMobile){var o=cc.game.container.style,a=o.margin;o.margin="0",o.display="none",e._initFrameSize(),o.margin=a,o.display="block"}else e._initFrameSize();if(!0===t||e._isRotated!==s||e._frameSize.width!==n||e._frameSize.height!==r){var c=e._originalDesignResolutionSize.width,l=e._originalDesignResolutionSize.height;e._resizing=!0,c>0&&e.setDesignResolutionSize(c,l,e._resolutionPolicy),e._resizing=!1,e.emit("canvas-resize"),e._resizeCallback&&e._resizeCallback.call()}}else setTimeout((function(){e._resizeEvent(t)}),0)},_orientationChange:function(){cc.view._orientationChanging=!0,cc.view._resizeEvent(),cc.sys.browserType===cc.sys.BROWSER_TYPE_SAFARI&&cc.sys.isMobile&&setTimeout((function(){window.innerHeight>window.innerWidth&&window.scrollTo(0,1)}),500)},_resize:function(){cc.view._resizeEvent(!1)},resizeWithBrowserSize:function(t){t?this._resizeWithBrowserSize||(this._resizeWithBrowserSize=!0,window.addEventListener("resize",this._resize),window.addEventListener("orientationchange",this._orientationChange)):this._resizeWithBrowserSize&&(this._resizeWithBrowserSize=!1,window.removeEventListener("resize",this._resize),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=s.availWidth(cc.game.frame),i=s.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),this._orientationChanging&&setTimeout((function(){cc.view._orientationChanging=!1}),1e3)},_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=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(s.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(cc.warnID(9200),this._antiAliasEnabled!==t)if(this._antiAliasEnabled=t,cc.game.renderType===cc.game.RENDER_TYPE_WEBGL)cc.assetManager.assets.forEach((function(e){if(e instanceof cc.Texture2D){var i=cc.Texture2D.Filter;t?e.setFilters(i.LINEAR,i.LINEAR):e.setFilters(i.NEAREST,i.NEAREST)}}));else if(cc.game.renderType===cc.game.RENDER_TYPE_CANVAS){var e=cc.game.canvas.getContext("2d");e.imageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t}},isAntiAliasEnabled:function(){return this._antiAliasEnabled},enableAutoFullScreen:function(t){t&&t!==this._autoFullScreen&&cc.sys.isMobile?(this._autoFullScreen=!0,cc.screen.autoFullScreen(cc.game.frame)):(this._autoFullScreen=!1,cc.screen.disableAutoFullScreen(cc.game.frame))},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(!0)},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 s=n.apply(this,this._designResolutionSize);if(s.scale&&2===s.scale.length&&(this._scaleX=s.scale[0],this._scaleY=s.scale[1]),s.viewport){var o=this._viewportRect,a=this._visibleRect,c=s.viewport;o.x=c.x,o.y=c.y,o.width=c.width,o.height=c.height,a.x=0,a.y=0,a.width=c.width/this._scaleX,a.height=c.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),r.updateCameraViewport(),cc.internal.inputManager._updateCanvasBoundingRect(),this.emit("design-resolution-changed")}else cc.logID(2201)}else cc.errorID(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,a=Math.ceil(t*r+this._viewportRect.x),c=Math.ceil(e*s+this._viewportRect.y),l=Math.ceil(i*r),u=Math.ceil(n*s),h=cc.game._renderContext;if(!o){var _=h.getParameter(h.SCISSOR_BOX);o=cc.rect(_[0],_[1],_[2],_[3])}o.x===a&&o.y===c&&o.width===l&&o.height===u||(o.x=a,o.y=c,o.width=l,o.height=u,h.scissor(a,c,l,u))},isScissorEnabled:function(){return cc.game._renderContext.isEnabled(gl.SCISSOR_TEST)},getScissorRect:function(){if(!o){var t=gl.getParameter(gl.SCISSOR_BOX);o=cc.rect(t[0],t[1],t[2],t[3])}var e=1/this._scaleX,i=1/this._scaleY;return cc.rect((o.x-this._viewportRect.x)*e,(o.y-this._viewportRect.y)*i,o.width*e,o.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=i.adjustedLeft?i.adjustedLeft:i.left,o=i.adjustedTop?i.adjustedTop:i.top,a=this._devicePixelRatio*(t-s),c=this._devicePixelRatio*(o+i.height-e);return this._isRotated?(r.x=cc.game.canvas.width-c,r.y=a):(r.x=a,r.y=c),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 s=i[n];s.hasOwnProperty("__attrs__")&&s.__attrs__||r(s,(e=i[n+1])&&e.__attrs__)}return r(t,(e=i[0])&&e.__attrs__),t.__attrs__}function o(t){return t.hasOwnProperty("__attrs__")&&t.__attrs__||s(t)}function a(t,e){this.name=t,this.default=e}a.prototype.toString=function(){return this.name},cc.Integer=new a("Integer",0),cc.Float=new a("Float",0),cc.Boolean=new a("Boolean",!1),cc.String=new a("String",""),e.exports={PrimitiveType:a,attr:function(t,e){var i=o(t),r=e+n,s={};for(var a in i)a.startsWith(r)&&(s[a.slice(r.length)]=i[a]);return s},getClassAttrs:o,setClassAttr:function(t,e,i,r){o(t)[e+n+i]=r},DELIMETER:n,getTypeChecker_ET:!1,getObjTypeChecker_ET:!1,ScriptUuid:{}}}),{"./CCClass":178,"./js":199,"./utils":202}],191:[(function(t,e){"use strict";var i=t("./js"),n=i.array.fastRemoveAt;function r(){}function s(){this.callback=r,this.target=void 0,this.once=!1}s.prototype.set=function(t,e,i){this.callback=t,this.target=e,this.once=!!i};var o=new i.Pool(function(t){return t.callback=r,t.target=void 0,t.once=!1,!0},32);function a(){this.callbackInfos=[],this.isInvoking=!1,this.containCanceled=!1}o.get=function(){return this._get()||new s};var c=a.prototype;c.removeByCallback=function(t){for(var e=0;e=0;--t)this.callbackInfos[t]||n(this.callbackInfos,t);this.containCanceled=!1},c.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1};var l=new i.Pool(function(t){return t.callbackInfos=[],t.isInvoking=!1,t.containCanceled=!1,!0},16);function u(){this._callbackTable=i.createMap(!0)}l.get=function(){return this._get()||new a},(c=u.prototype).on=function(t,e,i,n){var r=this._callbackTable[t];r||(r=this._callbackTable[t]=l.get());var s=o.get();s.set(e,i,n),r.callbackInfos.push(s)},c.hasEventListener=function(t,e,i){var n=this._callbackTable[t];if(!n)return!1;var r=n.callbackInfos;if(!e){if(n.isInvoking){for(var s=0;s0}for(var o=0;o=0?o[i[c]]=a:o[~c]=a}for(;r=0?l[i[h]]=u:l[~h]=u}}function A(t,e){for(var i=t[4][e[0]],n=i[0],r=new(0,n[0]),s=n[1],o=n[2],a=i[i.length-1],c=1;c=0?e[i]=t[5][n]:t[7][3*~n]=e}function b(t){return function(e,i,n,r){i[n]=r;for(var s=0;s=0){var h=a[l];e[o]=C(t,h,u)}else(0,E[l=~l])(t,e,o,u)}return r}function M(t,e){return t||V.reportMissingClass(e),Object}function R(t,e,i,n,r,s){var o=t(e);if(!o){if(r)return void(i[n]=(function(e,i,n){return function(){var r=t(n)||M(s,n);return e[i]=r,new r}})(i,n,e));o=M(s,e)}i[n]=o}function P(t,e,i){for(var r=i||n.default._getClassById,s=t[3],o=0;o=0?i[l]:~l,s[a]=l);var u=o[a];"number"==typeof u&&(o[a]=n[u])}}function V(t,e,i){"string"==typeof t&&(t=JSON.parse(t));var n=!e;(e=e||g.pool.get()).init(t),i=i||{};var r=t[0],s=!1;if("object"==typeof r&&(s=r.preprocessed,r=r.version),r<1)throw new Error(cc.debug.getError(5304,r));i._version=r,i.result=e,t[0]=i,s||(P(t,!1,i.classFinder),I(t)),cc.game._isCloning=!0;var o=t[5],a=B(t);return cc.game._isCloning=!1,t[7]&&x(t[7],o,t[2]),D(t),n&&g.pool.put(e),o[a]}E[0]=function(t,e,i,n){e[i]=n},E[1]=S,E[2]=b(S),E[3]=b(T),E[4]=w,E[5]=function(t,e,i,n){m[n[0]](e[i],n)},E[6]=T,E[7]=function(t,e,i,n){e[i].set(n)},E[8]=function(t,e,i,n){var r=new d[n[0]];m[n[0]](r,n),e[i]=r},E[9]=b(w),E[10]=function(t,e,i,n){var r=t[3][n[0]];e[i]=C(t,r,n[1])},E[11]=function(t,e,i,n){var r=n[0];e[i]=r;for(var s=1;s0&&(i=_+this.globalVariables.join(",")+";");var n=c.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&&(_(t,i),!0)}function d(t,e){void 0===e&&(e=t,t=null),this.get=null,this.count=0,this._pool=new Array(e),this._cleanup=t}s.formatStr=function(){var t=arguments.length;if(0===t)return"";var e=arguments[0];if(1===t)return""+e;var i="string"==typeof e&&u.test(e);if(i)for(var n=1;n=0&&(t[i]=t[t.length-1],--t.length)},removeAt:_,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},d.prototype.put=function(t){var e=this._pool;if(this.count=0&&(this._pool.length=t,this.count>t&&(this.count=t))},s.Pool=d,cc.js=s,e.exports=s}),{"../utils/mutable-forward-iterator":252,"./id-generater":195}],200:[(function(t,e,i){"use strict";var n=t("./js"),r=t("./attribute"),s={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function o(t,e,i,n){if(!t.get&&!t.set&&t.hasOwnProperty("default")){var r="_N$"+e;t.get=function(){return this[r]},t.set=function(t){var e=this[r];this[r]=t,i.call(this,e)};var o={};for(var a in n[r]=o,s){var c=s[a];t.hasOwnProperty(a)&&(o[a]=t[a],c.canUsedInGet||delete t[a])}}}function a(t,e,i,n){if(Array.isArray(e)){if(!(e.length>0))return cc.errorID(5508,i,n);t.type=e=e[0]}"function"==typeof e&&(e===String?t.type=cc.String:e===Boolean?t.type=cc.Boolean:e===Number&&(t.type=cc.Float))}function c(t,e,i){var n=t?{_short:!0}:{_short:!0,default:e};return i&&(n.type=i),n}i.getFullFormOfProperty=function(t,e){return t&&t.constructor===Object?null:Array.isArray(t)&&t.length>0?c(e,[],t):"function"==typeof t?c(e,n.isChildClassOf(t,cc.ValueType)?new t:null,t):t instanceof r.PrimitiveType?c(e,t.default):c(e,t)},i.preprocessAttrs=function(t,e){for(var n in t){var r=t[n],s=i.getFullFormOfProperty(r,!1);if(s&&(r=t[n]=s),r){var c=r.notify;c&&o(r,n,c,t),"type"in r&&a(r,r.type,e,n)}}},i.validateMethodWithProps=function(t){return"function"==typeof t||null===t}}),{"./CCClass":178,"./attribute":190,"./js":199}],201:[(function(){"use strict";var t=[];cc._RF={push:function(e,i,n){void 0===n&&(n=i,i=""),t.push({uuid:i,script:n,module:e,exports:e.exports,beh:null})},pop:function(){var e=t.pop(),i=e.module,n=i.exports;if(n===e.exports){for(var r in n)return;i.exports=n=e.cls}},peek:function(){return t[t.length-1]}}}),{}],202:[(function(t,e){"use strict";t("./js"),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)}}}),{"./js":199}],203:[(function(t){"use strict";t("./platform/js"),t("./value-types"),t("./utils"),t("./platform/CCInputManager"),t("./platform/CCInputExtension"),t("./event"),t("./platform/CCSys"),t("./platform/CCMacro"),t("./asset-manager"),t("./CCDirector"),t("./renderer"),t("./platform/CCView"),t("./platform/CCScreen"),t("./CCScheduler"),t("./event-manager")}),{"./CCDirector":23,"./CCScheduler":28,"./asset-manager":46,"./event":132,"./event-manager":128,"./platform/CCInputExtension":181,"./platform/CCInputManager":182,"./platform/CCMacro":183,"./platform/CCScreen":186,"./platform/CCSys":187,"./platform/CCView":188,"./platform/js":199,"./renderer":209,"./utils":250,"./value-types":266}],204:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=o(t("./assembler")),r=o(t("./utils/dynamic-atlas/manager")),s=o(t("./webgl/render-data"));function o(t){return t&&t.__esModule?t:{default:t}}function a(t,e){for(var i=0;i>2,c=s._vData;n.length+a>c.length?c.set(n.subarray(0,c.length-a),a):c.set(n,a);for(var l=s._iData,u=o.indiceOffset,h=o.vertexOffset,_=0,f=r.length;_this.maxSize||(this._clean(t),i[e].push(t),this.count++)}},r.get=function(t){var e;if(this.enabled){var i=this._pool,n=a(t);e=i[n]&&i[n].pop()}return e?this.count--:e=new t,e},r.clear=function(){this._pool={},this.count=0},r._clean=function(t){t._renderComp=null},n}(r.default));r.default.register("assembler",c);var l=c;i.default=l,e.exports=i.default}),{"../utils/pool":253}],206:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=t("./webgl/vertex-format"),s=(n=t("./assembler-pool"))&&n.__esModule?n:{default:n},o=(function(){function t(){this._extendNative&&this._extendNative()}var e=t.prototype;return e.init=function(t){this._renderComp=t},e.updateRenderData=function(){},e.fillBuffers=function(){},e.getVfmt=function(){return r.vfmtPosUvColor},t})();i.default=o,o.register=function(t,e){t.__assembler__=e},o.init=function(t){for(var e=t.constructor,i=e.__assembler__;!i;){if(!(e=e.$super))return void cc.warn("Can not find assembler for render component : ["+cc.js.getClassName(t)+"]");i=e.__assembler__}if(i.getConstructor&&(i=i.getConstructor(t)),!t._assembler||t._assembler.constructor!==i){var n=s.default.get(i);n.init(t),t._assembler=n}},cc.Assembler=o,e.exports=i.default}),{"./assembler-pool":205,"./webgl/vertex-format":240}],207:[(function(t,e){"use strict";var i=function(t){var e;try{e=t.getContext("2d")}catch(i){return void console.error(i)}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};i.prototype._restoreTexture=function(){},i.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)},i.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)},i.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))},i.prototype.resetDrawCalls=function(){this._stats.drawcalls=0},i.prototype.getDrawCalls=function(){return this._stats.drawcalls},e.exports=i}),{}],208:[(function(t,e){"use strict";var i=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))};i.prototype.update=function(t){this.updateImage(t)},i.prototype.updateImage=function(t){if(t.images&&t.images[0]){var e=t.images[0];e&&e!==this._image&&(this._image=e)}},i.prototype.destroy=function(){this._image=null},e.exports=i}),{}],209:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=o(t("../../renderer/gfx")),r=o(t("../../renderer/core/input-assembler")),s=o(t("../../renderer/core/pass"));function o(t){return t&&t.__esModule?t:{default:t}}var a=cc.renderer={Texture2D:null,InputAssembler:r.default,Pass:s.default,renderEngine:null,canvas:null,device:null,scene:null,drawCalls:0,_handle:null,_cameraNode:null,_camera:null,_forward:null,_flow:null,initWebGL:function(e,i){t("./webgl/assemblers");var r=t("./webgl/model-batcher");this.Texture2D=n.default.Texture2D,this.canvas=e,this._flow=cc.RenderFlow;var s=t("../../renderer/scene/scene"),o=t("../../renderer/renderers/forward-renderer");this.device=new n.default.Device(e,i),this.scene=new s;var a,c=(a=this.device,{defaultTexture:new n.default.Texture2D(a,{images:[],width:128,height:128,wrapS:n.default.WRAP_REPEAT,wrapT:n.default.WRAP_REPEAT,format:n.default.TEXTURE_FMT_RGB8,genMipmaps:!1}),programTemplates:[],programChunks:{}});this._forward=new o(this.device,c),this._handle=new r(this.device,this.scene),this._flow.init(this._handle,this._forward)},initCanvas:function(e){var i=t("./canvas"),n=t("./canvas/Texture2D"),r=t("./canvas/Device");this.Device=r,this.Texture2D=n,this.canvas=e,this.device=new r(e),this._camera={a:1,b:0,c:0,d:1,tx:0,ty:0},this._handle=new i.RenderComponentHandle(this.device,this._camera),this._forward=new i.ForwardRenderer,this._flow=cc.RenderFlow,this._flow.init(this._handle,this._forward)},updateCameraViewport:function(){if(cc.director){var t=cc.director.getScene();t&&t.setScale(1,1,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}},render:function(t,e){this.device.resetDrawCalls(),t&&(this._flow.render(t,e),this.drawCalls=this.device.getDrawCalls())},clear:function(){this._handle.reset(),this._forward.clear()}};i.default=a,e.exports=i.default}),{"../../renderer/core/input-assembler":283,"../../renderer/core/pass":284,"../../renderer/gfx":293,"../../renderer/renderers/forward-renderer":312,"../../renderer/scene/scene":315,"./canvas":void 0,"./canvas/Device":207,"./canvas/Texture2D":208,"./webgl/assemblers":219,"./webgl/model-batcher":236}],210:[(function(t,e){"use strict";var i,n,r=0,s=1<0;)i&t&&(e=S(i,e)),i>>=1;return e}function T(t){var e=t._renderFlag;(C[e]=b(e))._func(t)}g.flows=C,g.createFlow=S;var w=[];g.registerValidate=function(t){t._inValidateList||(w.push(t),t._inValidateList=!0)},g.validateRenderers=function(){for(var t=0,e=w.length;t0&&n>0&&z+_.w*S>F&&!o.isUnicodeSpace(x)){p.push(a),a=0,i++,n=0,r-=I*this._getFontScale()+0,N=!0;break}d.x=z,d.y=r-_.offsetY*S+l.margin,this._recordLetterInfo(d,x,k,i),k+1d.y-_.h*S&&(B=d.y-_.h*S)}else{this._recordPlaceholderInfo(k,x);var U="";v&&(U=v.atlasName),console.log("Can't find letter definition in texture atlas "+U+" for letter:"+x)}else this._recordPlaceholderInfo(k,x)}N||(n=R,uB&&(h=B),s<(a=M)&&(s=a),m+=b)}else p.push(a),a=0,i++,n=0,r-=I*this._getFontScale()+0,this._recordPlaceholderInfo(m,x),m++}return p.push(a),g=(y=i+1)*I*this._getFontScale(),y>1&&(g+=0*(y-1)),T.width=L,T.height=O,L<=0&&(T.width=parseFloat(s.toFixed(2))+2*l.margin),O<=0&&(T.height=parseFloat(g.toFixed(2))+2*l.margin),A=T.height,C=0,D!==c.CLAMP&&(u>0&&(A=T.height+u),h<-g&&(C=g+h)),!0},r._getFirstCharLen=function(){return 1},r._getFontScale=function(){return D===c.SHRINK?S:1},r._getFirstWordLen=function(t,e,i){var n=t.charAt(e);if(o.isUnicodeCJK(n)||"\n"===n||o.isUnicodeSpace(n))return 1;var r=1,s=l.fontAtlas.getLetterDefinitionForChar(n,l);if(!s)return r;for(var a=s.xAdvance*S+P,c=e+1;cF&&!o.isUnicodeSpace(n)&&F>0)return r;if(a+=s.xAdvance*S+P,"\n"===n||o.isUnicodeSpace(n)||o.isUnicodeCJK(n))break;r++}return r},r._multilineTextWrapByWord=function(){return this._multilineTextWrap(this._getFirstWordLen)},r._multilineTextWrapByChar=function(){return this._multilineTextWrap(this._getFirstCharLen)},r._recordPlaceholderInfo=function(t,e){if(t>=d.length){var i=new u;d.push(i)}d[t].char=e,d[t].hash=e.charCodeAt(0)+l.hash,d[t].valid=!1},r._recordLetterInfo=function(t,e,i,n){if(i>=d.length){var r=new u;d.push(r)}var s=e.charCodeAt(0)+l.hash;d[i].line=n,d[i].char=e,d[i].hash=s,d[i].valid=l.fontAtlas.getLetter(s).valid,d[i].x=t.x,d[i].y=t.y},r._alignText=function(){g=0,p.length=0,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),D===c.SHRINK&&E>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp),this._updateQuads()||D===c.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp)},r._scaleFontSizeDown=function(t){var e=!0;t||(t=.1,e=!1),E=t,e&&this._updateContent()},r._shrinkLabelToContentSize=function(t){for(var e=0,i=0|E,n=0;e>1;if(r<=0)break;S=r/B,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),t()?i=n-1:e=n}var s=e;s>=0&&this._scaleFontSizeDown(s)},r._isVerticalClamp=function(){return g>T.height},r._isHorizontalClamp=function(){for(var t=!1,e=0,i=w.length;e0)if(V){if(p[o]>T.width&&(s>T.width||s<0)){t=!0;break}}else if(s>T.width){t=!0;break}}}return t},r._isHorizontalClamped=function(t,e){var i=p[e],n=t>T.width||t<0;return V?i>T.width&&n:n},r._updateQuads=function(){var t=b?b._texture:l.fontAtlas.getTexture(),e=_.node;this.verticesCount=this.indicesCount=0,this._renderData&&(this._renderData.dataLength=0);for(var i=T,n=e._anchorPoint.x*i.width,r=e._anchorPoint.y*i.height,s=!0,o=0,a=w.length;o0){if(p>A){var v=p-A;h.y+=v,h.height-=v,p-=v}p-f.h*S0&&this._isHorizontalClamped(g,y))if(D===c.CLAMP)h.width=0;else if(D===c.SHRINK){if(T.width>f.w){s=!1;break}h.width=0}if(h.height>0&&h.width>0){var E=this._determineRect(h),B=u.x+m[u.line];this.appendQuad(_,t,h,E,B-n,p-r,S)}}}return this._quadsUpdated(_),s},r._determineRect=function(t){var e=b.isRotated(),i=b._originalSize,n=b._rect,r=b._offset,s=r.x+(i.width-n.width)/2,o=r.y-(i.height-n.height)/2;if(e){var a=t.x;t.x=n.x+n.height-t.y-t.height-o,t.y=a+n.y-s,t.y<0&&(t.height=t.height+o)}else t.x+=n.x-s,t.y+=n.y+o;return e},r._computeAlignmentOffset=function(){switch(m.length=0,M){case a.TextAlignment.LEFT:for(var t=0;t0){var l=e.out||m;t.strokeStyle="rgba("+l.r+", "+l.g+", "+l.b+", "+l.a/255+")",t.lineWidth=2*e.margin,t.strokeText(this._char,s,o)}t.fillText(this._char,s,o),this._texture.handleLoadedTexture()},destroy:function(){this._texture.destroy(),this._texture=null,o._canvasPool.put(this._data)}},cc.js.mixin(x.prototype,{insertLetterTexture:function(t){var e=t._texture,i=e.width,n=e.height;if(this._x+i+v>this._width&&(this._x=v,this._y=this._nexty),this._y+n>this._nexty&&(this._nexty=this._y+n+v),this._nexty>this._height)return null;this._fontDefDictionary._texture.drawTextureAt(e,this._x,this._y),this._dirty=!0;var r=new d;return r.u=this._x+1,r.v=this._y+1,r.texture=this._fontDefDictionary._texture,r.valid=!0,r.w=t._width-2,r.h=t._height-2,r.xAdvance=r.w,r.offsetY=t._offsetY,this._x+=i+v,this._fontDefDictionary.addLetterDefinitions(t._hash,r),r},update:function(){this._dirty&&(this._fontDefDictionary._texture.update(),this._dirty=!1)},reset:function(){this._x=v,this._y=v,this._nexty=v;for(var t=this._fontDefDictionary._letterDefinitions,e=0,i=t.length;e0&&(n=n+e.margin+e.out.toHEX()),""+e.fontSize+e.fontFamily+i+n)},r._getFontDesc=function(){return f.fontSize.toString()+"px "+f.fontFamily},r._computeHorizontalKerningForText=function(){},r._determineRect=function(){return!1},n})(r.default);i.default=C,e.exports=i.default}),{"../../../assets/CCRenderTexture":66,"../../../components/CCComponent":102,"../../../components/CCLabel":104,"../../../components/CCLabelOutline":105,"../../../utils/text-utils":258,"../../webgl/assemblers/label/2d/bmfont":220,"../utils":215}],214:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=(n=t("../../assembler-2d"))&&n.__esModule?n:{default:n};function s(t,e){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var o,a=t("../../../utils/text-utils"),c=t("../../../platform/CCMacro"),l=t("../../../components/CCLabel"),u=t("../../../components/CCLabelOutline"),h=t("../../../components/CCLabelShadow"),_=l.Overflow,f=t("../utils").deleteFromDynamicAtlas,d=t("../utils").getFontFamily,p=(1/255).toFixed(3),m=null,v=null,y=null,g="",x="",A=0,C=0,S=[],b=cc.Size.ZERO,T=0,w=0,E=0,B=null,M="",R=_.NONE,P=!1,I=!1,D=null,V=cc.Color.WHITE,L=null,O=cc.Color.BLACK,F=cc.rect(),N=cc.Size.ZERO,G=cc.Size.ZERO,k=!1,z=!1,U=!1,H=0,W=cc.Vec2.ZERO,j=0,X=["left","center","right"],q=(function(t){var e,i;function n(){return t.apply(this,arguments)||this}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,s(e,i);var r=n.prototype;return r._getAssemblerData=function(){return(o=l._canvasPool.get()).canvas.width=o.canvas.height=1,o},r._resetAssemblerData=function(t){t&&l._canvasPool.put(t)},r.updateRenderData=function(e){t.prototype.updateRenderData.call(this,e),e._vertsDirty&&(this._updateProperties(e),this._calculateLabelFont(),this._updateLabelDimensions(),this._updateTexture(e),this._calDynamicAtlas(e),e._actualFontSize=A,e.node.setContentSize(G),this.updateVerts(e),e._vertsDirty=!1,m=null,v=null,y=null)},r.updateVerts=function(){},r._updatePaddingRect=function(){var t=0,e=0,i=0,n=0,r=0;if(N.width=N.height=0,D&&(t=e=i=n=r=D.width,N.width=N.height=2*r),L){var s=L.blur+r;i=Math.max(i,-L._offset.x+s),n=Math.max(n,L._offset.x+s),t=Math.max(t,L._offset.y+s),e=Math.max(e,-L._offset.y+s)}if(z){var o=C*Math.tan(.20943951);n+=o,N.width+=o}F.x=i,F.y=t,F.width=i+n,F.height=t+e},r._updateProperties=function(t){var e=t._assemblerData;m=e.context,v=e.canvas,y=t._frame._original?t._frame._original._texture:t._frame._texture,x=t.string.toString(),A=t._fontSize,C=A,H=t.underlineHeight||C/8,R=t.overflow,b.width=t.node.width,b.height=t.node.height,G=t.node.getContentSize(),T=t._lineHeight,w=t.horizontalAlign,E=t.verticalAlign,B=t.node.color,k=t.enableBold,z=t.enableItalic,U=t.enableUnderline,M=d(t),I=t.srcBlendFactor===cc.macro.BlendFactor.ONE,P=R!==_.NONE&&(R===_.RESIZE_HEIGHT||t.enableWrapText),(D=(D=u&&t.getComponent(u))&&D.enabled&&D.width>0?D:null)&&V.set(D.color),(L=(L=h&&t.getComponent(h))&&L.enabled?L:null)&&(O.set(L.color),O.a=O.a*t.node.color.a/255),this._updatePaddingRect()},r._calculateFillTextStartPosition=function(){var t=0;w===c.TextAlignment.RIGHT?t=b.width-F.width:w===c.TextAlignment.CENTER&&(t=(b.width-F.width)/2);var e=this._getLineHeight()*(S.length-1),i=A*(1-a.BASELINE_RATIO/2);if(E!==c.VerticalTextAlignment.TOP){var n=e+F.height+A-b.height;E===c.VerticalTextAlignment.BOTTOM?i-=n+=a.BASELINE_RATIO/2*A:i-=n/2}return i+=a.BASELINE_OFFSET*A,cc.v2(t+F.x,i+F.y)},r._setupOutline=function(){m.strokeStyle="rgba("+V.r+", "+V.g+", "+V.b+", "+V.a/255+")",m.lineWidth=2*D.width},r._setupShadow=function(){m.shadowColor="rgba("+O.r+", "+O.g+", "+O.b+", "+O.a/255+")",m.shadowBlur=L.blur,m.shadowOffsetX=L.offset.x,m.shadowOffsetY=-L.offset.y},r._drawTextEffect=function(t,e){if(L||D||U){var i=S.length>1&&L,n=this._measureText(m,g),r=0,s=0;L&&this._setupShadow(),D&&this._setupOutline();for(var o=0;ot||b.height>t)&&cc.warn("The maximum texture size supported by the device is "+t),b.width=Math.min(b.width,t),b.height=Math.min(b.height,t);var e=!1;v.width!==b.width&&(v.width=b.width,e=!0),v.height!==b.height&&(v.height=b.height,e=!0),e&&(m.font=g),m.textAlign=X[w]},r._getFontDesc=function(){var t=A.toString()+"px ";return t+=M,k&&(t="bold "+t),z&&(t="italic "+t),t},r._getLineHeight=function(){return 0|(0===T?A:T*A/C)},r._calculateParagraphLength=function(t,e){for(var i=[],n=0;n>1)<=0){cc.logID(4003);break}A=u,g=this._getFontDesc(),m.font=g;var h=this._getLineHeight();for(n=0,i=0;io?l=u-1:c=u}0===c?cc.logID(4003):(A=c,g=this._getFontDesc(),m.font=g)}else{for(n=t.length*this._getLineHeight(),i=0;ir?e:r}i=(S.length+a.BASELINE_RATIO)*this._getLineHeight();var s=parseFloat(e.toFixed(2)),o=parseFloat(i.toFixed(2));b.width=s+F.width,b.height=o+F.height,G.width=s+N.width,G.height=o+N.height;break;case _.SHRINK:this._calculateShrinkFont(t),this._calculateWrapText(t);break;case _.CLAMP:this._calculateWrapText(t);break;case _.RESIZE_HEIGHT:this._calculateWrapText(t);var c=(S.length+a.BASELINE_RATIO)*this._getLineHeight();b.height=c+F.height,G.height=c+N.height}},n})(r.default);i.default=q,e.exports=i.default}),{"../../../components/CCLabel":104,"../../../components/CCLabelOutline":105,"../../../components/CCLabelShadow":106,"../../../platform/CCMacro":183,"../../../utils/text-utils":258,"../../assembler-2d":204,"../utils":215}],215:[(function(t,e){"use strict";var i=t("./dynamic-atlas/manager"),n=cc.Color.WHITE,r={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:n,isOutlined:!1,out:n,margin:0};e.exports={deleteFromDynamicAtlas:function(t,e){e&&e._original&&i&&(i.deleteAtlasSpriteFrame(e),e._resetDynamicAtlasFrame())},getFontFamily:function(t){return t.useSystemFont?t.fontFamily||"Arial":t.font?t.font._nativeAsset?t.font._nativeAsset:(cc.assetManager.postLoadNative(t.font,(function(){t.isValid&&t.setVertsDirty()})),"Arial"):"Arial"},shareLabelInfo:r}}),{"./dynamic-atlas/manager":void 0}],216:[(function(t,e){"use strict";function i(t,e,i){i=i||2;var r,o,a,c,l,h,_,f=e&&e.length,d=f?e[0]*i:t.length,p=n(t,0,d,i,!0),m=[];if(!p)return m;if(f&&(p=u(t,e,p,i)),t.length>80*i){r=a=t[0],o=c=t[1];for(var v=i;va&&(a=l),h>c&&(c=h);_=Math.max(a-r,c-o)}return s(p,m,i,r,o,_),m}function n(t,e,i,n,r){var s,o;if(r===R(t,e,i,n)>0)for(s=e;s=e;s-=n)o=E(s,t[s],t[s+1],o);return o&&A(o,o.next)&&(B(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!A(n,n.next)&&0!==x(n.prev,n,n.next))n=n.next;else{if(B(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function s(t,e,i,n,u,h,_){if(t){!_&&h&&d(t,n,u,h);for(var f,p,m=t;t.prev!==t.next;)if(f=t.prev,p=t.next,h?a(t,n,u,h):o(t))e.push(f.i/i),e.push(t.i/i),e.push(p.i/i),B(t),t=p.next,m=p.next;else if((t=p)===m){_?1===_?s(t=c(t,e,i),e,i,n,u,h,2):2===_&&l(t,e,i,n,u,h):s(r(t),e,i,n,u,h,1);break}}}function o(t){var e=t.prev,i=t,n=t.next;if(x(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(y(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&x(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function a(t,e,i,n){var r=t.prev,s=t,o=t.next;if(x(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,u=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,h=m(a,c,e,i,n),_=m(l,u,e,i,n),f=t.nextZ;f&&f.z<=_;){if(f!==t.prev&&f!==t.next&&y(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&x(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=h;){if(f!==t.prev&&f!==t.next&&y(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&x(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function c(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!A(r,s)&&C(r,n,n.next,s)&&b(r,s)&&b(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),B(n),B(n.next),n=t=s),n=n.next}while(n!==t);return n}function l(t,e,i,n,o,a){var c=t;do{for(var l=c.next.next;l!==c.prev;){if(c.i!==l.i&&g(c,l)){var u=w(c,l);return c=r(c,c.next),u=r(u,u.next),s(c,e,i,n,o,a),void s(u,e,i,n,o,a)}l=l.next}c=c.next}while(c!==t)}function u(t,e,i,s){var o,a,c,l=[];for(o=0,a=e.length;o=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>=u&&y(si.x)&&b(n,t)&&(i=n,_=c),n=n.next;return i}function d(t,e,i,n){var r=t;do{null===r.z&&(r.z=m(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,p(r)}function p(t){var e,i,n,r,s,o,a,c,l=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||c>0&&n;)0===a?(r=n,n=n.nextZ,c--):0!==c&&n?i.z<=n.z?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,c--):(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);return t}function m(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 v(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 g(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!S(t,e)&&b(t,e)&&b(e,t)&&T(t,e)}function x(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function A(t,e){return t.x===e.x&&t.y===e.y}function C(t,e,i,n){return!!(A(t,e)&&A(i,n)||A(t,n)&&A(i,e))||x(t,e,i)>0!=x(t,e,n)>0&&x(i,n,t)>0!=x(i,n,e)>0}function S(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&&C(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}function b(t,e){return x(t.prev,t,t.next)<0?x(t,e,t.next)>=0&&x(t,t.prev,e)>=0:x(t,e,t.prev)<0||x(t,t.next,e)<0}function T(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}function w(t,e){var i=new M(t.i,t.x,t.y),n=new M(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 E(t,e,i,n){var r=new M(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 B(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 M(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 R(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}}),{}],217:[(function(t,e){"use strict";var i=t("../../../../graphics/helper"),n=t("../../../../graphics/types").PointFlags,r=cc.Graphics.Point=cc.Class({name:"cc.GraphicsPoint",extends:cc.Vec2,ctor:function(){this.reset()},reset:function(){this.dx=0,this.dy=0,this.dmx=0,this.dmy=0,this.flags=0,this.len=0}});function s(){this.reset()}function o(){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=[]}cc.js.mixin(s.prototype,{reset:function(){this.closed=!1,this.nbevel=0,this.complex=!0,this.points?this.points.length=0:this.points=[]}}),cc.js.mixin(o.prototype,{moveTo:function(t,e){this._updatePathOffset&&(this._pathOffset=this._pathLength,this._updatePathOffset=!1),this._addPath(),this._addPoint(t,e,n.PT_CORNER),this._commandx=t,this._commandy=e},lineTo:function(t,e){this._addPoint(t,e,n.PT_CORNER),this._commandx=t,this._commandy=e},bezierCurveTo:function(t,e,r,s,o,a){var c=this._curPath,l=c.points[c.points.length-1];l.x!==t||l.y!==e||r!==o||s!==a?(i.tesselateBezier(this,l.x,l.y,t,e,r,s,o,a,0,n.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,n,r,s,o){i.arc(this,t,e,n,r,s,o)},ellipse:function(t,e,n,r){i.ellipse(this,t,e,n,r),this._curPath.complex=!1},circle:function(t,e,n){i.ellipse(this,t,e,n,n),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,n,r,s){i.roundRect(this,t,e,n,r,s),this._curPath.complex=!1},clear:function(t){this._pathLength=0,this._pathOffset=0,this._pointsOffset=0,this._curPath=null,t&&(this._paths.length=0,this._points.length=0)},close:function(){this._curPath.closed=!0},_addPath:function(){var t=this._pathLength,e=this._paths[t];return e?e.reset():(e=new s,this._paths.push(e)),this._pathLength++,this._curPath=e,e},_addPoint:function(t,e,i){var n=this._curPath;if(n){var s,o=this._points,a=n.points;(s=o[this._pointsOffset++])?(s.x=t,s.y=e):(s=new r(t,e),o.push(s)),s.flags=i,a.push(s)}}}),cc.Graphics._Impl=o,e.exports=o}),{"../../../../graphics/helper":147,"../../../../graphics/types":149}],218:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=s(t("../../../assembler")),r=s(t("../../../../../renderer/core/input-assembler"));function s(t){return t&&t.__esModule?t:{default:t}}function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var a=t("../../mesh-buffer"),c=t("../../../index"),l=t("../../../../graphics/graphics"),u=t("../../../../graphics/types").PointFlags,h=l.LineJoin,_=l.LineCap,f=t("./earcut");t("./impl");var d=Math.PI,p=Math.min,m=Math.max,v=Math.ceil,y=Math.acos,g=Math.cos,x=Math.sin,A=Math.atan2;function C(t,e,i){return ti?i:t}var S=cc.gfx,b=new S.VertexFormat([{name:S.ATTR_POSITION,type:S.ATTR_TYPE_FLOAT32,num:2},{name:S.ATTR_COLOR,type:S.ATTR_TYPE_UINT8,num:4,normalize:!0},{name:"a_dist",type:S.ATTR_TYPE_FLOAT32,num:1}]);b.name="vfmtPosColorSdf";var T=(function(t){var e,i;function n(e){var i;return(i=t.call(this,e)||this)._buffer=null,i._buffers=[],i._bufferOffset=0,i}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,o(e,i);var s=n.prototype;return s.getVfmt=function(){return b},s.getVfmtFloatCount=function(){return 4},s.requestBuffer=function(){var t={indiceStart:0,vertexStart:0},e=new a(c._handle,this.getVfmt());t.meshbuffer=e;var i=new r.default(e._vb,e._ib);return t.ia=i,this._buffers.push(t),t},s.getBuffers=function(){return 0===this._buffers.length&&this.requestBuffer(),this._buffers},s.clear=function(t){this._bufferOffset=0;var e=this._buffers;if(t){for(var i=0,n=e.length;i65535||3*s>131070)&&(++this._bufferOffset,s=e,this._bufferOffsetr.vertexOffset&&r.requestStatic(e,3*e),this._buffer=n,n},s.stroke=function(t){this._curColor=t._strokeColor._val,this._flattenPaths(t._impl),this._expandStroke(t),t._impl._updatePathOffset=!0},s.fill=function(t){this._curColor=t._fillColor._val,this._expandFill(t),t._impl._updatePathOffset=!0},s._expandStroke=function(t){var e,i,n,r,s=.5*t.lineWidth,o=t.lineCap,a=t.lineJoin,c=t.miterLimit,l=t._impl,f=(e=s,i=d,n=l._tessTol,r=2*y(e/(e+n)),m(2,v(i/r)));this._calculateJoins(l,s,a,c);for(var p=l._paths,g=0,x=l._pathOffset,A=l._pathLength;x0&&(r=1/e);for(var o=t._paths,a=t._pathOffset,c=t._pathLength;a1e-6){var T=1/g;T>600&&(T=600),v.dmx*=T,v.dmy*=T}v.dx*d.dy-d.dx*v.dy>0&&(v.flags|=u.PT_LEFT),g*(x=m(11,p(d.len,v.len)*r))*x<1&&(v.flags|=u.PT_INNERBEVEL);var w=v.dmx*e,E=v.dmy*e,B=w*w+E*E;B>v.len*v.len+s&&B>d.len*d.len+s&&(v.flags|=u.PT_INNERBEVEL),v.flags&u.PT_CORNER&&(g*n*n<1||i===h.BEVEL||i===h.ROUND)&&(v.flags|=u.PT_BEVEL),0!=(v.flags&(u.PT_BEVEL|u.PT_INNERBEVEL))&&l.nbevel++,d=v,v=_[y+1]}}},s._flattenPaths=function(t){for(var e=t._paths,i=t._pathOffset,n=t._pathLength;i2&&o.equals(a)&&(r.closed=!0,s.pop(),o=s[s.length-1]);for(var c=0,l=s.length;cS&&(b-=2*d),this._vset(f,p,1),this._vset(l-s*n,e.y-o*n,-1);for(var T=C(v((S-b)/d)*r,2,r),w=0;w "+n+"/"+i+".")},e._updateCfgFlag=function(t){var e=this._cfgFields.updateFlags;this._setBufferFlag(this._cfg,e.offset,e.size,e.type,t)},e._setBufferValue=function(t,e,i,n,r){"float"==n&&4==i?t.setFloat32(e,r,jsb.__isLittleEndian__):"int32"==n&&4==i?t.setInt32(e,r,jsb.__isLittleEndian__):"bool"==n&&1==i?t.setInt8(e,r?1:0,jsb.__isLittleEndian__):"Color4B"==n&&4==i?(t.setUint8(e,r.r),t.setUint8(e+1,r.g),t.setUint8(e+2,r.b),t.setUint8(e+3,r.a)):"int8"==n&&1==i?t.setUint8(e,r):cc.warn("dont know how to set value to buffer, type/size -> "+n+"/"+i+".")},e._setFieldValue=function(t,e,i,n){var r=e[i];this._setBufferValue(t,r.offset,r.size,r.type,n)},e._getBufferValue=function(t,e,i,n){return"float"==n&&4==i?t.getFloat32(e,jsb.__isLittleEndian__):"int32"==n&&4==i?t.getInt32(e,jsb.__isLittleEndian__):"bool"==n&&1==i?0!=t.getInt8(e,jsb.__isLittleEndian__):"Color4B"==n&&4==i?{r:t.getUint8(e),g:t.getUint8(e+1),b:t.getUint8(e+2),a:t.getUint8(e+3)}:"int8"==n&&1==i?t.getUint8(e):void cc.warn("dont know how to get value from buffer, type/size -> "+n+"/"+i+".")},e._getFieldValue=function(t,e,i){var n=e[i];return this._getBufferValue(t,n.offset,n.size,n.type)},e._getLayoutValue=function(t){return this._getFieldValue(this._layoutInfo,this._layoutFields,t)},e._setLayoutValue=function(t,e){return this._setFieldValue(this._layoutInfo,this._layoutFields,t,e)},e._updateCfgFlag_Content=function(){this._updateCfgFlag(1)},e._updateCfgFlag_Font=function(){this._updateCfgFlag(2)},e._colorEqual=function(t,e){return t.r==e.r&&t.g==e.g&&t.b==e.b&&t.a==e.a},e._colorToObj=function(t,e,i,n){return{r:t,g:e,b:i,a:n}},e.setString=function(t){t!=this._layout.string&&(this._layout.string=t,this._updateCfgFlag_Content())},e.setFontPath=function(t){t!=this._layout.fontPath&&(this._layout.fontPath=t,this._updateCfgFlag_Font())},e.setFontSize=function(t,e){this._getFieldValue(this._cfg,this._cfgFields,"fontSize")!=t&&(this._setFieldValue(this._cfg,this._cfgFields,"fontSize",t),this._setFieldValue(this._cfg,this._cfgFields,"fontSizeRetina",e),this._updateCfgFlag_Font())},e.setOutline=function(t){var e=this._getLayoutValue("outlineSize");e>0!=t>0&&this._updateCfgFlag_Font(),e!=t&&(this._updateCfgFlag_Content(),this._setLayoutValue("outlineSize",t))},e.setOutlineColor=function(t){var e=this._getLayoutValue("outlineColor");this._colorEqual(e,t)||(this._setLayoutValue("outlineColor",t),this._updateCfgFlag_Content())},e.setLineHeight=function(t){this._getLayoutValue("lineHeight")!=t&&(this._setLayoutValue("lineHeight",t),this._updateCfgFlag_Content())},e.setOverFlow=function(t){this._getLayoutValue("overflow")!=t&&(this._setLayoutValue("overflow",t),this._updateCfgFlag_Content())},e.setEnableWrap=function(t){this._getLayoutValue("wrap")!=t&&(this._setLayoutValue("wrap",t),this._updateCfgFlag_Content())},e.setVerticalAlign=function(t){this._getLayoutValue("valign")!=t&&(this._setLayoutValue("valign",t),this._updateCfgFlag_Content())},e.setHorizontalAlign=function(t){this._getLayoutValue("halign")!=t&&(this._setLayoutValue("halign",t),this._updateCfgFlag_Content())},e.setContentSize=function(t,e){var i=this._getLayoutValue("width"),n=this._getLayoutValue("height");i==t&&n==e||(this._setLayoutValue("height",e),this._setLayoutValue("width",t),this._updateCfgFlag_Content())},e.setAnchorPoint=function(t,e){var i=this._getLayoutValue("anchorX"),n=this._getLayoutValue("anchorY");i==t&&n==e||(this._setLayoutValue("anchorX",t),this._setLayoutValue("anchorY",e),this._updateCfgFlag_Content())},e.setColor=function(t){var e=this._getLayoutValue("color");this._colorEqual(e,t)||(this._setLayoutValue("color",t),this._updateCfgFlag_Content())},e.setShadow=function(t,e,i){var n=this._getLayoutValue("shadowBlur"),r=this._getLayoutValue("shadowX"),s=this._getLayoutValue("shadowY");n>0!=i>0&&this._updateCfgFlag_Font();var o=!1;n!=i&&(this._setLayoutValue("shadowBlur",i),o=!0),r!=t&&(this._setLayoutValue("shadowX",t),o=!0),s!=e&&(this._setLayoutValue("shadowY",e),o=!0),o&&this._updateCfgFlag_Content()},e.setShadowColor=function(t){var e=this._getLayoutValue("shadowColor");this._colorEqual(e,t)||(this._setLayoutValue("shadowColor",t),this._updateCfgFlag_Content())},e.setItalic=function(t){this._getLayoutValue("italic")!=t&&(this._setLayoutValue("italic",t),this._updateCfgFlag_Content())},e.setBold=function(t){this._getLayoutValue("bold")!=t&&(this._setLayoutValue("bold",t),this._updateCfgFlag_Content(),this._updateCfgFlag_Font())},e.setUnderline=function(t){this._getLayoutValue("underline")!=t&&(this._setLayoutValue("underline",t),this._updateCfgFlag_Content())},e.setSpacingX=function(t){this._getLayoutValue("spaceX")==t||"number"!=typeof t||isNaN(t)||(this._setLayoutValue("spaceX",t),this._updateCfgFlag_Content())},e.updateRenderData=function(t){if(t._vertsDirty){t.font&&t.font.nativeUrl&&this.setFontPath(cc.assetManager.cacheManager.getCache(t.font.nativeUrl)||t.font.nativeUrl);var e=this._layout,i=t.node.color,n=t.node,r=t.fontSize;this.setString(t.string),this.setFontSize(t.fontSize,r/72*t.fontSize),this.setLineHeight(t.lineHeight),this.setEnableWrap(t.enableWrapText),this.setItalic(t.enableItalic),this.setUnderline(t.enableUnderline),this.setBold(t.enableBold),this.setOverFlow(t.overflow),this.setVerticalAlign(t.verticalAlign),this.setHorizontalAlign(t.horizontalAlign),this.setSpacingX(t.spacingX),this.setContentSize(n.getContentSize().width,n.getContentSize().height),this.setAnchorPoint(n.anchorX,n.anchorY),this.setColor(this._colorToObj(i.getR(),i.getG(),i.getB(),Math.ceil(i.getA()*n.opacity/255)));var s=n.getComponent(cc.LabelShadow);if(s&&s.enabled){var o=s.color;this.setShadow(s.offset.x,s.offset.y,s.blur),this.setShadowColor(this._colorToObj(o.getR(),o.getG(),o.getB(),Math.ceil(o.getA()*n.opacity/255)))}else this.setShadow(0,0,-1);this._updateTTFMaterial(t),e.render()}},e._bindMaterial=function(t){var e=this.labelMaterial;return e||(e=r.default.createWithBuiltin("2d-label",t),this.labelMaterial=e),e},e._updateTTFMaterial=function(t){var e=this._bindMaterial(t),i=this._label.node,n=this._layout,r=i.getComponent(cc.LabelOutline),s=0;if(r&&r.enabled&&r.width>0){s=Math.max(Math.min(r.width/10,.4),.1);var o=r.color;this.setOutlineColor(this._colorToObj(o.getR(),o.getG(),o.getB(),Math.ceil(o.getA()*i.opacity/255)))}this.setOutline(s),e.define("CC_USE_MODEL",!0),e.define("USE_TEXTURE_ALPHAONLY",!0),e.define("USE_SDF",s>0||t.enableBold),e.define("USE_SDF_EXTEND",t.enableBold?1:0),void 0!==e.getDefine("CC_SUPPORT_standard_derivatives")&&cc.sys.glExtension("OES_standard_derivatives")&&e.define("CC_SUPPORT_standard_derivatives",!0),n.setEffect(e.effect._nativeObj)},e.fillBuffers=function(){this._layout.render()},e.getVfmt=function(){},t})();i.default=s,e.exports=i.default}),{"../../../../../assets/material/CCMaterial":77,"../../../../../assets/material/material-variant":84,"../../../../../components/CCLabel":104,"../../../../../components/CCLabelOutline":105,"../../../../../components/CCLabelShadow":106}],223:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=(n=t("../../../../utils/label/ttf"))&&n.__esModule?n:{default:n};function s(t,e){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var o=t("../../../../../components/CCLabelShadow"),a=cc.color(255,255,255,255),c=(function(t){var e,i;function n(){return t.apply(this,arguments)||this}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,s(e,i);var r=n.prototype;return r.updateUVs=function(t){for(var e=this._renderData.vDatas[0],i=t._frame.uv,n=this.uvOffset,r=this.floatsPerVert,s=0;s<4;s++){var o=2*s,a=r*s+n;e[a]=i[o],e[a+1]=i[o+1]}},r.updateColor=function(e){a._fastSetA(e.node._color.a);var i=a._val;t.prototype.updateColor.call(this,e,i)},r.updateVerts=function(t){var e=t.node,i=t._ttfTexture.width,n=t._ttfTexture.height,r=e.anchorX*e.width,s=e.anchorY*e.height,a=o&&t.getComponent(o);if(a&&a._enabled){var c=(i-e.width)/2,l=(n-e.height)/2,u=a.offset;-u.x>c?r+=i-e.width:c>u.x&&(r+=c-u.x),-u.y>l?s+=n-e.height:l>u.y&&(s+=l-u.y)}var h=this._local;h[0]=-r,h[1]=-s,h[2]=i-r,h[3]=n-s,this.updateUVs(t),this.updateWorldVerts(t)},n})(r.default);i.default=c,e.exports=i.default}),{"../../../../../components/CCLabelShadow":106,"../../../../utils/label/ttf":214}],224:[(function(t){"use strict";var e=l(t("../../../assembler")),i=l(t("../../../../components/CCLabel")),n=l(t("./2d/ttf")),r=l(t("./2d/bmfont")),s=l(t("./2d/letter")),o=l(t("./3d/ttf")),a=l(t("./3d/bmfont")),c=l(t("./3d/letter"));function l(t){return t&&t.__esModule?t:{default:t}}i.default._canvasPool={pool:[],get:function(){var t=this.pool.pop();if(!t){var e=document.createElement("canvas"),i=e.getContext("2d");t={canvas:e,context:i},i.textBaseline="alphabetic"}return t},put:function(t){this.pool.length>=32||this.pool.push(t)}},e.default.register(cc.Label,{getConstructor:function(t){var e=t.node.is3DNode,l=e?o.default:n.default;return t.font instanceof cc.BitmapFont?l=e?a.default:r.default:t.cacheMode===i.default.CacheMode.CHAR&&(cc.sys.platform===cc.sys.WECHAT_GAME_SUB?cc.warn("sorry, subdomain does not support CHAR mode currently!"):l=e?c.default:s.default),l},TTF:n.default,Bmfont:r.default,Letter:s.default,TTF3D:o.default,Bmfont3D:a.default,Letter3D:c.default,NativeTTF:void 0})}),{"../../../../components/CCLabel":104,"../../../assembler":206,"./2d/bmfont":220,"./2d/letter":221,"./2d/nativeTTF":222,"./2d/ttf":223,"./3d/bmfont":void 0,"./3d/letter":void 0,"./3d/ttf":void 0}],225:[(function(t,e,i){"use strict";i.__esModule=!0,i.MaskAssembler=void 0;var n,r=(n=t("../../assembler"))&&n.__esModule?n:{default:n};function s(t,e){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var o=t("../../../components/CCMask"),a=t("../../render-flow"),c=t("./sprite/2d/simple"),l=t("./graphics"),u=t("../../../../renderer/gfx"),h=t("../vertex-format").vfmtPos,_=8,f=[];function d(){return 1<_&&cc.errorID(9e3,_),f.push(t)}function y(t,e){0===f.length&&cc.errorID(9001),f.pop(),0===f.length?e._flushMaterial(t._exitMaterial):A(e)}function g(t,e){var i=u.DS_FUNC_NEVER,n=d(),r=n,s=n,o=t.inverted?u.STENCIL_OP_REPLACE:u.STENCIL_OP_ZERO;m(t._clearMaterial,i,o,n,r,s);var a=e.getBuffer("mesh",h),c=a.request(4,6),l=c.indiceOffset,_=c.byteOffset>>2,f=c.vertexOffset,p=a._vData,v=a._iData;p[_++]=-1,p[_++]=-1,p[_++]=-1,p[_++]=1,p[_++]=1,p[_++]=1,p[_++]=1,p[_++]=-1,v[l++]=f,v[l++]=f+3,v[l++]=f+1,v[l++]=f+1,v[l++]=f+3,v[l++]=f+2,e.node=e._dummyNode,e.material=t._clearMaterial,e._flush()}function x(t,e){var i=u.DS_FUNC_NEVER,n=d(),r=n,s=n,a=t.inverted?u.STENCIL_OP_ZERO:u.STENCIL_OP_REPLACE;m(t._materials[0],i,a,n,r,s),e.material=t._materials[0],t._type===o.Type.IMAGE_STENCIL?(e.node=e._dummyNode,c.prototype.fillBuffers.call(t._assembler,t,e),e._flush()):(e.node=t.node,l.prototype.fillBuffers.call(t._graphics._assembler,t._graphics,e))}function A(t){var e=u.DS_FUNC_EQUAL,i=u.STENCIL_OP_KEEP,n=p(),r=n,s=d(),o=f[f.length-1];m(o._enableMaterial,e,i,n,r,s),t._flushMaterial(o._enableMaterial)}var C=(function(t){var e,i;function n(){return t.apply(this,arguments)||this}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,s(e,i);var r=n.prototype;return r.updateRenderData=function(t){t._type===o.Type.IMAGE_STENCIL?t.spriteFrame?c.prototype.updateRenderData.call(this,t):t.setMaterial(0,null):(t._graphics.setMaterial(0,t._materials[0]),l.prototype.updateRenderData.call(t._graphics._assembler,t._graphics,t._graphics))},r.fillBuffers=function(t,e){(t._type!==o.Type.IMAGE_STENCIL||t.spriteFrame)&&(v(t),g(t,e),x(t,e),A(e)),t.node._renderFlag|=a.FLAG_UPDATE_RENDER_DATA},r.postFillBuffers=function(t,e){(t._type!==o.Type.IMAGE_STENCIL||t.spriteFrame)&&y(t,e),t.node._renderFlag|=a.FLAG_UPDATE_RENDER_DATA},n})(c);i.MaskAssembler=C,r.default.register(o,C)}),{"../../../../renderer/gfx":293,"../../../components/CCMask":108,"../../assembler":206,"../../render-flow":210,"../vertex-format":240,"./graphics":218,"./sprite/2d/simple":230}],226:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=s(t("../../assembler-2d")),r=s(t("../../../value-types/mat4"));function s(t){return t&&t.__esModule?t:{default:t}}function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var a=t("../../../components/CCMotionStreak"),c=t("../../render-flow");function l(t,e){this.point=t||cc.v2(),this.dir=e||cc.v2(),this.distance=0,this.time=0}l.prototype.setPoint=function(t,e){this.point.x=t,this.point.y=e},l.prototype.setDir=function(t,e){this.dir.x=t,this.dir.y=e},cc.v2(),cc.v2();var u=cc.v2(),h=cc.v2(),_=new r.default;function f(t,e){return t.x=-e.y,t.y=e.x,t}var d=(function(t){var e,i;function n(){var e;return(e=t.call(this)||this)._tailShortenTime=0,e}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,o(e,i);var r=n.prototype;return r.initData=function(){this._renderData.createFlexData(0,16,42)},r.update=function(t,e){var i=t._stroke/2;t.node.getWorldMatrix(_);var n=_.m[12],r=_.m[13],s=t._points,o=t._lastWPos,a=t._fadeTime;if(t._lastWPosUpdated&&(o.x!==n||o.y!==r)){var c,d=!1;if(0===s.length){var p=new l;p.setPoint(o.x,o.y),this._tailShortenTime=p.time=a,s.push(p),c=new l,s.unshift(c)}else{c=s[0];var m=s[1],v=m.point.x-n,y=m.point.y-r;d=v*v+y*y>=t.minSeg*t.minSeg}c.setPoint(n,r),c.time=a+e;var g=s[1];if(c.distance=c.point.sub(g.point,h).mag(),h.normalizeSelf(),c.setDir(h.x,h.y),2===s.length&&g.setDir(h.x,h.y),d){var x=new l(c.point.clone(),c.dir.clone());x.distance=c.distance,x.time=c.time,s.unshift(x)}}if(o.x=n,o.y=r,t._lastWPosUpdated=!0,!(s.length<2)){var A,C=t._color,S=C.a,b=C.b<<16|C.g<<8|C.r,T=0,w=this._renderData._flexBuffer;w.reserve(2*s.length,6*(s.length-1));for(var E=w.vData,B=w.uintVData,M=s.length-1;M>=0;M--){var R=s[M],P=R.point,I=R.dir;R.time-=e;var D=M===s.length-1;if(R.time<=0)D&&M-1>=0&&(this._tailShortenTime=s[M-1].time-e),s.splice(M,1);else{var V=R.time/a;if(D){var L=s[M-1];if(!L){s.splice(M,1);continue}if(s.length>=3){var O=R.time/this._tailShortenTime;O<=1&&(P.x=L.point.x-L.distance*L.dir.x*O,P.y=L.point.y-L.distance*L.dir.y*O)}else this._tailShortenTime=R.time}f(u,I);var F=V*S<<24>>>0|b,N=5*T;E[N]=P.x+u.x*i,E[N+1]=P.y+u.y*i,E[N+2]=1,E[N+3]=V,B[N+4]=F,E[N+=5]=P.x-u.x*i,E[N+1]=P.y-u.y*i,E[N+2]=0,E[N+3]=V,B[N+4]=F,T+=2}}A=T<=2?0:3*(T-2),w.used(T,A)}},r.fillBuffers=function(t,e){var i=this._renderData._flexBuffer,n=i.vData,r=i.usedVertices,s=i.usedIndices,o=i.usedVerticesFloats,a=e._meshBuffer,l=a.request(r,s),u=l.byteOffset>>2,h=a._vData;n.length+u>h.length?h.set(n.subarray(0,o),u):h.set(n,u);for(var _=a._iData,f=l.indiceOffset,d=l.vertexOffset,p=0,m=r;p1?1:n)<0?0:n;var r=(i=(i=i>1?1:i)<0?0:i)+(n=(n-=i)<0?0:n);r=r>1?1:r,this.updateUVs(t,i,r),this.updateVerts(t,i,r),t._vertsDirty=!1}},r.updateUVs=function(t,e,i){var n,r,s,a,c,l,u,h,_,f,d=t._spriteFrame,p=d._texture.width,m=d._texture.height,v=d._rect;d._rotated?(n=v.x/p,r=(v.y+v.width)/m,s=c=n,u=_=(v.x+v.height)/p,l=f=r,a=h=v.y/m):(n=v.x/p,r=(v.y+v.height)/m,s=u=n,c=_=(v.x+v.width)/p,a=l=r,h=f=v.y/m);var y=this._renderData.vDatas[0],g=this.uvOffset,x=this.floatsPerVert;switch(t._fillType){case o.HORIZONTAL:y[g]=s+(c-s)*e,y[g+1]=a+(l-a)*e,y[g+x]=s+(c-s)*i,y[g+x+1]=a+(l-a)*i,y[g+2*x]=u+(_-u)*e,y[g+2*x+1]=h+(f-h)*e,y[g+3*x]=u+(_-u)*i,y[g+3*x+1]=h+(f-h)*i;break;case o.VERTICAL:y[g]=s+(u-s)*e,y[g+1]=a+(h-a)*e,y[g+x]=c+(_-c)*e,y[g+x+1]=l+(f-l)*e,y[g+2*x]=s+(u-s)*i,y[g+2*x+1]=a+(h-a)*i,y[g+3*x]=c+(_-c)*i,y[g+3*x+1]=l+(f-l)*i;break;default:cc.errorID(2626)}},r.updateVerts=function(t,e,i){var n,r=t.node,s=r.width,a=r.height,c=r.anchorX*s,l=r.anchorY*a,u=-c,h=-l,_=s-c,f=a-l;switch(t._fillType){case o.HORIZONTAL:n=u+(_-u)*i,u+=(_-u)*e,_=n;break;case o.VERTICAL:n=h+(f-h)*i,h+=(f-h)*e,f=n;break;default:cc.errorID(2626)}var d=this._local;d[0]=u,d[1]=h,d[2]=_,d[3]=f,this.updateWorldVerts(t)},n})(r.default);i.default=a,e.exports=i.default}),{"../../../../../components/CCSprite":115,"../../../../assembler-2d":204}],228:[(function(t,e,i){"use strict";var n;function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}i.__esModule=!0,i.default=void 0;var s=(function(t){var e,i;function n(){return t.apply(this,arguments)||this}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,r(e,i);var s=n.prototype;return s.initData=function(){this._renderData.createFlexData(0,4,6,this.getVfmt())},s.updateRenderData=function(t){this.packToDynamicAtlas(t,t._spriteFrame);var e=t.spriteFrame;if(e){var i=e.vertices;if(i){this.verticesCount=i.x.length,this.indicesCount=i.triangles.length;var n=this._renderData._flexBuffer;n.reserve(this.verticesCount,this.indicesCount)&&(this.updateColor(t),t._vertsDirty=!0),n.used(this.verticesCount,this.indicesCount),this.updateIndices(i.triangles),t._vertsDirty&&(this.updateUVs(t),this.updateVerts(t),this.updateWorldVerts(t),t._vertsDirty=!1)}}},s.updateIndices=function(t){this._renderData.iDatas[0].set(t)},s.updateUVs=function(t){for(var e=t.spriteFrame.vertices,i=e.nu,n=e.nv,r=this.uvOffset,s=this.floatsPerVert,o=this._renderData.vDatas[0],a=0;a0){var h=r.y+a*(t-r.x);o[0].x=t,o[0].y=h}if((e-r.x)*u>0){var _=r.y+a*(e-r.x);o[2].x=e,o[2].y=_}}if(0!==Math.sin(s)){if(c=u/l,(n-r.y)*l>0){var f=r.x+c*(n-r.y);o[3].x=f,o[3].y=n}if((i-r.y)*l>0){var d=r.x+c*(i-r.y);o[1].x=d,o[1].y=i}}}function p(t){var e=t.node,i=e.width,n=e.height,r=e.anchorX*i,s=e.anchorY*n,o=-r,l=-s,u=i-r,h=n-s,d=c;d[0]=o,d[1]=l,d[2]=u,d[3]=h;var p=t._fillCenter,m=_.x=Math.min(Math.max(0,p.x),1)*(u-o)+o,v=_.y=Math.min(Math.max(0,p.y),1)*(h-l)+l;a[0].x=a[3].x=o,a[1].x=a[2].x=u,a[0].y=a[1].y=l,a[2].y=a[3].y=h,f.length=0,m!==d[0]&&(f[0]=[3,0]),m!==d[2]&&(f[2]=[1,2]),v!==d[1]&&(f[1]=[0,1]),v!==d[3]&&(f[3]=[2,3])}function m(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}}var v=(function(t){var e,i;function n(){return t.apply(this,arguments)||this}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,s(e,i);var r=n.prototype;return r.initData=function(){this._renderData.createFlexData(0,4,6,this.getVfmt()),this.updateIndices()},r.updateRenderData=function(e){t.prototype.updateRenderData.call(this,e);var i,n,r,s,a,f,m,v,y,g=e.spriteFrame;if(this.packToDynamicAtlas(e,g),e._vertsDirty){var x=e._fillStart,A=e._fillRange;for(A<0&&(x+=A,A=-A);x>=1;)x-=1;for(;x<0;)x+=1;x*=o,A*=o,p(e),f=(i=g)._texture.width,m=i._texture.height,v=i._rect,y=l,i._rotated?(n=v.x/f,r=(v.x+v.height)/f,s=v.y/m,a=(v.y+v.width)/m,y[0]=y[2]=n,y[4]=y[6]=r,y[3]=y[7]=a,y[1]=y[5]=s):(n=v.x/f,r=(v.x+v.width)/f,s=v.y/m,a=(v.y+v.height)/m,y[0]=y[4]=n,y[2]=y[6]=r,y[1]=y[3]=a,y[5]=y[7]=s),d(c[0],c[2],c[1],c[3],_,x,u),d(c[0],c[2],c[1],c[3],_,x+A,h),this.updateVerts(e,x,A),e._vertsDirty=!1}},r.updateVerts=function(t,e,i){var n=e+i,r=this._local;r.length=0;for(var s=0,c=3*this.floatsPerVert,l=0;l<4;++l){var d=f[l];if(d)if(i>=o)r.length=s+c,this._generateTriangle(r,s,_,a[d[0]],a[d[1]]),s+=c;else{var p=m(_,a[d[0]]),v=m(_,a[d[1]]);v=n||(p>=e?(r.length=s+c,v>=n?this._generateTriangle(r,s,_,a[d[0]],h[l]):this._generateTriangle(r,s,_,a[d[0]],a[d[1]]),s+=c):v<=e||(v<=n?(r.length=s+c,this._generateTriangle(r,s,_,u[l],a[d[1]]),s+=c):(r.length=s+c,this._generateTriangle(r,s,_,u[l],h[l]),s+=c))),p+=o,v+=o}}this.allocWorldVerts(t),this.updateWorldVerts(t)},r.allocWorldVerts=function(t){var e=t.node._color._val,i=this._renderData,n=this.floatsPerVert,r=this._local,s=r.length/n;this.verticesCount=this.indicesCount=s;var o=i._flexBuffer;o.reserve(s,s)&&this.updateIndices(),o.used(this.verticesCount,this.indicesCount);for(var a=i.vDatas[0],c=i.uintVDatas[0],l=this.uvOffset,u=0;u0)){this._renderData.createData(0,this.verticesFloats,this.indicesCount);for(var t=this._renderData.iDatas[0],e=0,i=0;i<3;++i)for(var n=0;n<3;++n){var r=4*i+n;t[e++]=r,t[e++]=r+1,t[e++]=r+4,t[e++]=r+1,t[e++]=r+5,t[e++]=r+4}}},s.initLocal=function(){this._local=[],this._local.length=8},s.updateRenderData=function(t){var e=t._spriteFrame;this.packToDynamicAtlas(t,e),t._vertsDirty&&(this.updateUVs(t),this.updateVerts(t),t._vertsDirty=!1)},s.updateVerts=function(t){var e=t.node,i=e.width,n=e.height,r=e.anchorX*i,s=e.anchorY*n,o=t.spriteFrame,a=o.insetLeft,c=o.insetRight,l=o.insetTop,u=o.insetBottom,h=i-a-c,_=n-l-u,f=i/(a+c),d=n/(l+u);f=isNaN(f)||f>1?1:f,d=isNaN(d)||d>1?1:d,h=h<0?0:h,_=_<0?0:_;var p=this._local;p[0]=-r,p[1]=-s,p[2]=a*f-r,p[3]=u*d-s,p[4]=p[2]+h,p[5]=p[3]+_,p[6]=i-r,p[7]=n-s,this.updateWorldVerts(t)},s.updateUVs=function(t){for(var e=this._renderData.vDatas[0],i=t.spriteFrame.uvSliced,n=this.uvOffset,r=this.floatsPerVert,s=0;s<4;++s)for(var o=0;o<4;++o){var a=4*s+o,c=i[a],l=a*r;e[l+n]=c.u,e[l+n+1]=c.v}},s.updateWorldVerts=function(t){for(var e=t.node._worldMatrix.m,i=e[0],n=e[1],r=e[4],s=e[5],o=e[12],a=e[13],c=this._local,l=this._renderData.vDatas[0],u=this.floatsPerVert,h=0;h<4;++h)for(var _=c[2*h+1],f=0;f<4;++f){var d=c[2*f],p=(4*h+f)*u;l[p]=d*i+_*r+o,l[p+1]=d*n+_*s+a}},n})(((n=t("../../../../assembler-2d"))&&n.__esModule?n:{default:n}).default);i.default=s,Object.assign(s.prototype,{verticesCount:16,indicesCount:54}),e.exports=i.default}),{"../../../../assembler-2d":204}],232:[(function(t,e,i){"use strict";var n;function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}i.__esModule=!0,i.default=void 0;var s=(function(t){var e,i;function n(){return t.apply(this,arguments)||this}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,r(e,i);var s=n.prototype;return s.initData=function(){this.verticesCount=0,this.contentWidth=0,this.contentHeight=0,this.rectWidth=0,this.rectHeight=0,this.hRepeat=0,this.vRepeat=0,this.row=0,this.col=0,this._renderData.createFlexData(0,4,6,this.getVfmt()),this._updateIndices()},s.initLocal=function(){this._local={x:[],y:[]}},s._updateIndices=function(){for(var t=this._renderData.iDatas[0],e=0,i=0,n=t.length;e0?this.sizableWidth:0,this.sizableHeight=this.sizableHeight>0?this.sizableHeight:0;var _=this.hRepeat=0===c?this.sizableWidth:this.sizableWidth/c,f=this.vRepeat=0===h?this.sizableHeight:this.sizableHeight/h,d=(this.row=Math.ceil(f+2))*(this.col=Math.ceil(_+2));this.verticesCount=4*d,this.indicesCount=6*d;var p=this._renderData._flexBuffer;p.reserve(this.verticesCount,this.indicesCount)&&(this._updateIndices(),this.updateColor(t)),p.used(this.verticesCount,this.indicesCount),t._vertsDirty&&(this.updateUVs(t),this.updateVerts(t),t._vertsDirty=!1)},s.updateVerts=function(t){var e=t._spriteFrame,i=e._rect,n=t.node,r=n.anchorX*n.width,s=n.anchorY*n.height,o=this.row,a=this.col,c=this.contentWidth,l=this.contentHeight,u=this._local,h=u.x,_=u.y;h.length=_.length=0;var f,d,p=e.insetLeft,m=e.insetRight,v=i.width-p-m,y=e.insetTop,g=e.insetBottom,x=i.height-y-g,A=n.width/(p+m)>1?1:n.width/(p+m),C=n.height/(y+g)>1?1:n.height/(y+g);f=v>0?Math.floor(1e3*this.sizableWidth)/1e3%v==0?v:this.sizableWidth%v:this.sizableWidth,d=x>0?Math.floor(1e3*this.sizableHeight)/1e3%x==0?x:this.sizableHeight%x:this.sizableHeight;for(var S=0;S<=a;S++)0===S?h[S]=-r:S>0&&S0?S===a-1?p+f+v*(S-2)-r:p+Math.min(v,this.sizableWidth)+v*(S-2)-r:p+this.sizableWidth-r:S===a&&(h[S]=Math.min(p+this.sizableWidth+m,c)-r);for(var b=0;b<=o;b++)0===b?_[b]=-s:b>0&&b0?b===o-1?g+d+(b-2)*x-s:g+Math.min(x,this.sizableHeight)+(b-2)*x-s:g+this.sizableHeight-s:b===o&&(_[b]=Math.min(g+this.sizableHeight+y,l)-s);this.updateWorldVerts(t)},s.updateWorldVerts=function(t){for(var e,i,n,r,s=this._renderData,o=this._local,a=o.x,c=o.y,l=s.vDatas[0],u=this.row,h=this.col,_=t.node._worldMatrix.m,f=_[0],d=_[1],p=_[4],m=_[5],v=_[12],y=_[13],g=this.floatsPerVert,x=0,A=0,C=u;Al?this.sizableHeight>=S*l?1:f%1:f;for(var T=0,w=h;To?this.sizableWidth>=T*o?1:_%1:_,y?(0===S?(A[0]=v[0].u,A[1]=v[0].u,A[2]=v[4].u+(v[8].u-v[4].u)*p):S>2,n=this.vData.length,r=!1;if(i>n){for(;ns){for(;s>2,this._handler.updateMeshRange(t,e)},e.reset=function(){var t=this._initVerticesCount*this._verticesBytes>>2;this._reallocVData(t),this._reallocIData(this._initIndicesCount),this.usedVertices=0,this.usedVerticesFloats=0,this.usedIndices=0},t})();i.default=n,cc.FlexBuffer=n,e.exports=i.default}),{}],235:[(function(t,e){"use strict";var i,n,r,s=(i=t("../../../renderer/gfx"))&&i.__esModule?i:{default:i};n=cc.sys.platform===cc.sys.WECHAT_GAME?(cc.sys.os===cc.sys.OS_IOS||cc.sys.os===cc.sys.OS_OSX)&&(null==(r=GameGlobal)?void 0:r.isIOSHighPerformanceMode)&&/(OS 1[4-9])|(Version\/1[4-9])/.test(window.navigator.userAgent):(cc.sys.os===cc.sys.OS_IOS||cc.sys.os===cc.sys.OS_OSX)&&cc.sys.isBrowser&&/(OS 1[4-9])|(Version\/1[4-9])/.test(window.navigator.userAgent);var o=cc.Class({name:"cc.MeshBuffer",ctor:function(t,e){this.init(t,e)},init:function(t,e){this.byteOffset=0,this.indiceOffset=0,this.vertexOffset=0,this.indiceStart=0,this._dirty=!1,this._vertexFormat=e,this._vertexBytes=this._vertexFormat._bytes,this._arrOffset=0,this._vbArr=[],this._vb=new s.default.VertexBuffer(t._device,e,s.default.USAGE_DYNAMIC,new ArrayBuffer,0),this._vbArr[0]=this._vb,this._ibArr=[],this._ib=new s.default.IndexBuffer(t._device,s.default.INDEX_FMT_UINT16,s.default.USAGE_STATIC,new ArrayBuffer,0),this._ibArr[0]=this._ib,this._vData=null,this._uintVData=null,this._iData=null,this._batcher=t,this._initVDataCount=256*e._bytes,this._initIDataCount=1536,this._offsetInfo={byteOffset:0,vertexOffset:0,indiceOffset:0},this._reallocBuffer()},uploadData:function(){if(0!==this.byteOffset&&this._dirty){var t=new Float32Array(this._vData.buffer,0,this.byteOffset>>2),e=new Uint16Array(this._iData.buffer,0,this.indiceOffset);this._vb.update(0,t),this._ib.update(0,e),this._dirty=!1}},switchBuffer:function(){var t=++this._arrOffset;this.byteOffset=0,this.vertexOffset=0,this.indiceOffset=0,this.indiceStart=0,t65535&&(this.uploadData(),this._batcher._flush(),this.switchBuffer())},requestStatic:function(t,e){this.checkAndSwitchBuffer(t);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(;r65535&&(this.uploadData(),this._batcher._flush())},o.prototype.forwardIndiceStartToOffset=function(){this.uploadData(),this.switchBuffer()}),cc.MeshBuffer=e.exports=o}),{"../../../renderer/gfx":293}],236:[(function(t,e){"use strict";var i=s(t("../../../renderer/core/input-assembler")),n=s(t("../../../renderer/memop/recycle-pool")),r=s(t("../../../renderer/scene/model"));function s(t){return t&&t.__esModule?t:{default:t}}var o=t("./vertex-format"),a=o.vfmtPosUvColor,c=o.vfmt3D,l=t("./quad-buffer"),u=t("./mesh-buffer"),h=t("./spine-buffer"),_=t("../../assets/material/CCMaterial"),f=(new(t("../../platform/id-generater"))("VertextFormat"),{}),d=new _,p=new i.default;p._count=0;var m=function(t,e){this._renderScene=e,this._device=t,this.walking=!1,this.material=d,this.cullingMask=1,this._iaPool=new n.default(function(){return new i.default},16),this._modelPool=new n.default(function(){return new r.default},16),this._quadBuffer=this.getBuffer("quad",a),this._meshBuffer=this.getBuffer("mesh",a),this._quadBuffer3D=this.getBuffer("quad",c),this._meshBuffer3D=this.getBuffer("mesh",c),this._buffer=this._meshBuffer,this._batchedModels=[],this._dummyNode=new cc.Node,this._sortKey=0,this.node=this._dummyNode,this.parentOpacity=1,this.parentOpacityDirty=0,this.worldMatDirty=0};m.prototype={constructor:m,reset:function(){this._iaPool.reset();for(var t=this._renderScene,e=this._batchedModels,i=0;i>2);this._vb.update(0,t),this._dirty=!1}},switchBuffer:function(){this._super();var t=new Uint16Array(this._iData.buffer,0,this._initIDataCount);this._ib.update(0,t)},_reallocBuffer:function(){this._reallocVData(!0),this._reallocIData(),this._fillQuadBuffer()}});cc.QuadBuffer=e.exports=n}),{"./mesh-buffer":235}],238:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=o;var n,r=(n=t("./flex-buffer"))&&n.__esModule?n:{default:n},s=t("./vertex-format");function o(){this.vDatas=[],this.uintVDatas=[],this.iDatas=[],this.meshCount=0,this._infos=null,this._flexBuffer=null}cc.js.mixin(o.prototype,{init:function(){},clear:function(){this.vDatas.length=0,this.iDatas.length=0,this.uintVDatas.length=0,this.meshCount=0,this._infos=null,this._flexBuffer&&this._flexBuffer.reset()},updateMesh:function(t,e,i){this.vDatas[t]=e,this.uintVDatas[t]=new Uint32Array(e.buffer,0,e.length),this.iDatas[t]=i,this.meshCount=this.vDatas.length},updateMeshRange:function(){},createData:function(t,e,i){var n=new Float32Array(e),r=new Uint16Array(i);this.updateMesh(t,n,r)},createQuadData:function(t,e,i){this.createData(t,e,i),this.initQuadIndices(this.iDatas[t])},createFlexData:function(t,e,i,n){n=n||s.vfmtPosUvColor,this._flexBuffer=new r.default(this,t,e,i,n)},initQuadIndices:function(t){for(var e=t.length/6,i=0,n=0;ir||n>s){for(;r0&&(t=t.substring(0,i));var n=/(\/|\\)([^\/\\]+)$/g.exec(t.replace(/(\/|\\)$/,""));if(!n)return t;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=n.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(r,"")}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":187}],242:[(function(t,e){"use strict";var i=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};i.create=function(t,e,i,n,r,s){return{a:t,b:e,c:i,d:n,tx:r,ty:s}},i.identity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}},i.clone=function(t){return{a:t.a,b:t.b,c:t.c,d:t.d,tx:t.tx,ty:t.ty}},i.concat=function(t,e,i){var n=e.a,r=e.b,s=e.c,o=e.d,a=e.tx,c=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+c*i.c+i.tx,t.ty=a*i.b+c*i.d+i.ty,t},i.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,c=e.ty;return t.a=o*s,t.b=-o*n,t.c=-o*r,t.d=o*i,t.tx=o*(r*c-s*a),t.ty=o*(n*a-i*c),t},i.fromMat4=function(t,e){var i=e.m;return t.a=i[0],t.b=i[1],t.c=i[4],t.d=i[5],t.tx=i[12],t.ty=i[13],t},i.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},i.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},i.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,c=i.b*n+i.d*r+i.ty,l=i.a*s+i.c*r+i.tx,u=i.b*s+i.d*r+i.ty,h=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,d=i.b*s+i.d*o+i.ty,p=Math.min(a,l,h,f),m=Math.max(a,l,h,f),v=Math.min(c,u,_,d),y=Math.max(c,u,_,d);return t.x=p,t.y=v,t.width=m-p,t.height=y-v,t},i.transformObb=function(t,e,i,n,r,s){var o=r.x,a=r.y,c=r.width,l=r.height,u=s.a*o+s.c*a+s.tx,h=s.b*o+s.d*a+s.ty,_=s.a*c,f=s.b*c,d=s.c*l,p=s.d*l;e.x=u,e.y=h,i.x=_+u,i.y=f+h,t.x=d+u,t.y=p+h,n.x=_+d+u,n.y=f+p+h},cc.AffineTransform=e.exports=i}),{}],243:[(function(t,e){"use strict";var i=t("../platform/CCObject").Flags,n=t("./misc"),r=t("../platform/js"),s=t("../platform/id-generater"),o=t("../event-manager"),a=t("../renderer/render-flow"),c=i.Destroying,l=i.DontDestroy,u=i.Deactivating,h=new s("Node");function _(t){return t?"string"==typeof t?r.getClassByName(t):t:(cc.errorID(3804),null)}function f(t,e){if(e._sealed)for(var i=0;i0&&(r=p(n._children,e)))return r}return null}function m(t,e,i){for(var n=0;n0&&m(r._children,e,i)}}var v=cc.Class({name:"cc._BaseNode",extends:cc.Object,properties:{_parent:null,_children:[],_active:!0,_components:[],_prefab:null,_persistNode:{get:function(){return(this._objFlags&l)>0},set:function(t){t?this._objFlags|=l:this._objFlags&=~l}},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;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=h.getNewId(),cc.director._scheduler&&cc.director._scheduler.enableForTarget(this),this.__eventTargets=[]},getParent:function(){return this._parent},setParent:function(t){if(this._parent!==t){var e=this._parent;if(this._parent=t||null,this._onSetParent(t),t&&(o._setDirtyForNode(this),t._children.push(this),t.emit&&t.emit("child-added",this),t._renderFlag|=a.FLAG_CHILDREN),e){if(!(e._objFlags&c)){var i=e._children.indexOf(this);e._children.splice(i,1),e.emit&&e.emit("child-removed",this),this._onHierarchyChanged(e),0===e._children.length&&(e._renderFlag&=~a.FLAG_CHILDREN)}}else t&&this._onHierarchyChanged(null)}},attr:function(t){r.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,c[a]=i[r],a++):(c[a]=n,a++,s=!0);c.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=_(t);return e?f(this,e):null},getComponents:function(t){var e=_(t),i=[];return e&&d(this,e,i),i},getComponentInChildren:function(t){var e=_(t);return e?p(this._children,e):null},getComponentsInChildren:function(t){var e=_(t),i=[];return e&&(d(this,e,i),m(this._children,e,i)),i},_checkMultipleComp:!1,addComponent:function(t){var e;if("string"==typeof t){if(!(e=r.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(!r.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&c)){var e=this._components.indexOf(t);-1!==e?this._components.splice(e,1):t.node!==this&&cc.errorID(3815)}}else cc.errorID(3814)},destroy:function(){cc.Object.prototype.destroy.call(this)&&(this.active=!1)},destroyAllChildren:function(){for(var t=this._children,e=0;e>>1;i<=n;r=i+n>>>1){var s=t[r];if(s>e+1e-6)n=r-1;else{if(!(s>2],s[o[r++]]=n[(3&a)<<2|c>>4],s[o[r++]]=n[15&c]}return s.join("")}}),{"./misc":251}],247:[(function(t,e){"use strict";cc.find=e.exports=function(t,e){if(null==t)return cc.errorID(3814),null;if(e);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,"'"]),this._specialSymbolArray.push([/ /g," "])};r.prototype={constructor:r,parse:function(t){if(this._resultObjectArray=[],!t)return this._resultObjectArray;this._stack=[];for(var e=0,i=t.length;e",e),r=-1;if(n>=0&&(r=t.lastIndexOf("<",n))",r+1)),r<0)this._stack.pop(),this._processResult(t.substring(e)),e=i;else{var s=t.substring(e,r),o=t.substring(r+1,n);""===o&&(s=t.substring(e,n+1)),this._processResult(s),-1===n?n=r:"/"===t.charAt(r+1)?this._stack.pop():this._addToStack(o),e=n+1}}return this._resultObjectArray},_attributeToObject:function(t){var e,i,r,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(),r=this._processEventHandler(s),o.event=r),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 c;a=t.match(n);for(var l=!1;a;){if(e=(t=t.substring(t.indexOf(a[0]))).substr(0,a[0].length),h=(i=(c=t.substring(e.length).trim()).indexOf(" "))>-1?c.substr(0,i):c,e=(e=e.replace(/[^a-zA-Z]/g,"").trim()).toLocaleLowerCase(),t=c.substring(i).trim(),h.endsWith("/")&&(h=h.slice(0,-1)),"src"===e){switch(h.charCodeAt(0)){case 34:case 39:l=!0,h=h.slice(1,-1)}o.isImage=!0,o.src=h}else if("height"===e)o.imageHeight=parseInt(h);else if("width"===e)o.imageWidth=parseInt(h);else if("align"===e){switch(h.charCodeAt(0)){case 34:case 39:h=h.slice(1,-1)}o.imageAlign=h.toLocaleLowerCase()}else"offset"===e?o.imageOffset=h:"click"===e&&(o.event=this._processEventHandler(e+"="+h));o.event&&"param"===e&&(o.event.param=h.replace(/^\"|\"$/g,"")),a=t.match(n)}return l&&o.isImage&&this._resultObjectArray.push({text:"",style:o}),{}}if(a=t.match(/^(outline(\s)*[^>]*)/)){var u={color:"#ffffff",width:1};if(t=a[0].substring("outline".length).trim()){var h,_=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(a=t.match(_);a;)e=(t=t.substring(t.indexOf(a[0]))).substr(0,a[0].length),h=(i=(c=t.substring(e.length).trim()).indexOf(" "))>-1?c.substr(0,i):c,e=(e=e.replace(/[^a-zA-Z]/g,"").trim()).toLocaleLowerCase(),t=c.substring(i).trim(),"click"===e?o.event=this._processEventHandler(e+"="+h):"color"===e?u.color=h:"width"===e&&(u.width=parseInt(h)),o.event&&"param"===e&&(o.event.param=h.replace(/^\"|\"$/g,"")),a=t.match(_)}o.outline=u}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;r=this._processEventHandler(t),o.event=r}return o},_processEventHandler:function(t){for(var e=0,n={},r=t.match(i),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 c=t.match(/(\S)+/);e=(a=c?c[0]:"").length}s&&(n[o=o.substring(0,o.length-1).trim()]=a),r=(t=t.substring(e).trim()).match(i)}return n},_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,1+(t|=t>>16)},BUILTIN_CLASSID_RE:/^(?:cc|dragonBones|sp|ccsg)\..+/},r=new Array(123),s=0;s<123;++s)r[s]=64;for(var o=0;o<64;++o)r["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(o)]=o;n.BASE64_VALUES=r,n.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},n.clampf=function(t,e,i){if(e>i){var n=e;e=i,i=n}return t=0&&this.removeAt(e)},n.removeAt=function(t){this.array.splice(t,1),t<=this.i&&--this.i},n.fastRemove=function(t){var e=this.array.indexOf(t);e>=0&&this.fastRemoveAt(e)},n.fastRemoveAt=function(t){var e=this.array;e[t]=e[e.length-1],--e.length,t<=this.i&&--this.i},n.push=function(t){this.array.push(t)},e.exports=i}),{}],253:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=(function(){function t(){this.enabled=!1,this.count=0,this.maxSize=1024}var e=t.prototype;return e.get=function(){},e.put=function(){},e.clear=function(){},t})();i.default=n,cc.pool={},n.register=function(t,e){cc.pool[t]=e},e.exports=i.default}),{}],254:[(function(t,e){"use strict";cc._PrefabInfo=cc.Class({name:"cc.PrefabInfo",properties:{root:null,asset:null,fileId:"",sync:!1}}),e.exports={syncWithPrefab:function(t){var e=t._prefab;if(!e.asset)return cc.errorID(3701,t.name),void(t._prefab=null);var i=t._objFlags,n=t._parent,r=t._id,s=t._name,o=t._active,a=t._eulerAngles.x,c=t._eulerAngles.y,l=t._eulerAngles.z,u=t._localZOrder,h=t._trs,_=h[0],f=h[1],d=h[2];cc.game._isCloning=!0;var p=e.asset.data;p._iN$t=t,cc.instantiate._clone(p,p),cc.game._isCloning=!1,t._objFlags=i,t._parent=n,t._id=r,t._prefab=e,t._name=s,t._active=o,t._localZOrder=u,(h=t._trs)[0]=_,h[1]=f,h[2]=d,t._eulerAngles.x=a,t._eulerAngles.y=c,t._eulerAngles.z=l}}}),{}],255:[(function(t,e){"use strict";var i=t("../../platform/CCMacro"),n=t("./perf-counter"),r=!1,s=15,o=null,a=null,c=null;function l(){if(!o){o={fps:{desc:"Framerate (FPS)",below:30,average:500},draws:{desc:"Draw Call"},frame:{desc:"Frame time (ms)",min:0,max:50,average:500},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 o)o[e]._counter=new n(e,o[e],t)}}function u(){if(!a||!a.isValid){(a=new cc.Node("PROFILER-NODE")).x=a.y=10,a.groupIndex=cc.Node.BuiltinGroupIndex.DEBUG,cc.Camera._setupDebugCamera(),a.zIndex=i.MAX_ZINDEX,cc.game.addPersistRootNode(a);var t=new cc.Node("LEFT-PANEL");t.anchorX=t.anchorY=0;var e=t.addComponent(cc.Label);e.fontSize=s,e.lineHeight=s,t.parent=a;var n=new cc.Node("RIGHT-PANEL");n.anchorX=1,n.anchorY=0,n.x=200;var r=n.addComponent(cc.Label);r.horizontalAlign=cc.Label.HorizontalAlign.RIGHT,r.fontSize=s,r.lineHeight=s,n.parent=a,cc.sys.platform!==cc.sys.BAIDU_GAME_SUB&&cc.sys.platform!==cc.sys.WECHAT_GAME_SUB&&(e.cacheMode=cc.Label.CacheMode.CHAR,r.cacheMode=cc.Label.CacheMode.CHAR),c={left:e,right:r}}}function h(){u();var t=cc.director._lastUpdate;o.frame._counter.start(t),o.logic._counter.start(t)}function _(){var t=performance.now();cc.director.isPaused()?o.frame._counter.start(t):o.logic._counter.end(t),o.render._counter.start(t)}function f(){var t=performance.now();o.render._counter.end(t),o.draws._counter.value=cc.renderer.drawCalls,o.frame._counter.end(t),o.fps._counter.frame(t);var e="",i="";for(var n in o){var r=o[n];r._counter.sample(t),e+=r.desc+"\n",i+=r._counter.human()+"\n"}c&&(c.left.string=e,c.right.string=i)}cc.profiler=e.exports={isShowingStats:function(){return r},hideStats:function(){r&&(a&&(a.active=!1),cc.director.off(cc.Director.EVENT_BEFORE_UPDATE,h),cc.director.off(cc.Director.EVENT_AFTER_UPDATE,_),cc.director.off(cc.Director.EVENT_AFTER_DRAW,f),r=!1)},showStats:function(){r||(l(),a&&(a.active=!0),cc.director.on(cc.Director.EVENT_BEFORE_UPDATE,h),cc.director.on(cc.Director.EVENT_AFTER_UPDATE,_),cc.director.on(cc.Director.EVENT_AFTER_DRAW,f),r=!0)}}}),{"../../platform/CCMacro":183,"./perf-counter":257}],256:[(function(t,e){"use strict";var i=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=i}),{}],257:[(function(t,e){"use strict";var i=t("./counter"),n=cc.Class({name:"cc.PerfCounter",extends:i,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=n}),{"./counter":256}],258:[(function(t,e){"use strict";var i,n=new(((i=t("../platform/js"))&&i.__esModule?i:{default:i}).default.Pool)(2);function r(t){this.count=0,this.limit=t,this.datas={},this.head=null,this.tail=null}n.get=function(){return this._get()||{key:null,value:null,prev:null,next:null}},r.prototype.moveToHead=function(t){t.next=this.head,t.prev=null,null!==this.head&&(this.head.prev=t),this.head=t,null===this.tail&&(this.tail=t),this.count++,this.datas[t.key]=t},r.prototype.put=function(t,e){var i=n.get();if(i.key=t,i.value=e,this.count>=this.limit){var r=this.tail;delete this.datas[r.key],this.count--,this.tail=r.prev,this.tail.next=null,r.prev=null,r.next=null,n.put(r)}this.moveToHead(i)},r.prototype.remove=function(t){null!==t.prev?t.prev.next=t.next:this.head=t.next,null!==t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.datas[t.key],this.count--},r.prototype.get=function(t){var e=this.datas[t];return e?(this.remove(e),this.moveToHead(e),e.value):null},r.prototype.clear=function(){this.count=0,this.datas={},this.head=null,this.tail=null},r.prototype.has=function(t){return!!this.datas[t]},r.prototype.delete=function(t){var e=this.datas[t];this.remove(e)};var s=new r(100),o={BASELINE_RATIO:.26,MIDDLE_RATIO:.37,BASELINE_OFFSET:0,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]/,highSurrogateRex:/[\uD800-\uDBFF]/,lowSurrogateRex:/[\uDC00-\uDFFF]/,label_wrapinspection:!0,__CHINESE_REG:/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/,__JAPANESE_REG:/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g,__KOREAN_REG:/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/,isUnicodeCJK:function(t){return this.__CHINESE_REG.test(t)||this.__JAPANESE_REG.test(t)||this.__KOREAN_REG.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,i){var n=(i||t.font)+"\ud83c\udfae"+e,r=s.get(n);if(null!==r)return r;var o=t.measureText(e),a=o&&o.width||0;return s.put(n,a),a},_safeSubstring:function(t,e,i){var n=e,r=i,s=t[e];if(this.lowSurrogateRex.test(s)&&n--,void 0!==i)if(i-1!==e){var o=t[i-1];this.highSurrogateRex.test(o)&&r--}else this.highSurrogateRex.test(s)&&r++;return t.substring(n,r)},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=this._safeSubstring(s,o),c=e-n(a),l=a,u=0,h=0;c>i&&h++<10;)o*=i/c,o|=0,c=e-n(a=this._safeSubstring(s,o));for(h=0;c<=i&&h++<10;){if(a){var _=this.label_wordRex.exec(a);u=_?_[0].length:1,l=a}o+=u,c=e-n(a=this._safeSubstring(s,o))}0==(o-=u)?(o=1,l=this._safeSubstring(s,1)):1===o&&this.highSurrogateRex.test(s[0])&&(o=2,l=this._safeSubstring(s,2));var f,d=this._safeSubstring(s,0,o);this.label_wrapinspection&&this.label_symbolRex.test(l||a)&&(0==(o-=(f=this.label_lastWordRex.exec(d))?f[0].length:0)&&(o=1),l=this._safeSubstring(s,o),d=this._safeSubstring(s,0,o)),this.label_firstEnglish.test(l)&&(f=this.label_lastEnglish.exec(d))&&d!==f[0]&&(o-=f[0].length,l=this._safeSubstring(s,o),d=this._safeSubstring(s,0,o)),0===r.length?r.push(d):(d=d.trimLeft()).length>0&&r.push(d),e=n(s=l||a)}return 0===r.length?r.push(s):(s=s.trimLeft()).length>0&&r.push(s),r}};cc.textUtils=e.exports=o}),{"../platform/js":199}],259:[(function(t,e){"use strict";var i=t("../assets/CCTexture2D"),n={loadImage:function(t,e,i){cc.assertID(t,3103);var n=cc.assetManager.assets.get(t);if(n)return n.loaded?(e&&e.call(i,null,n),n):(n.once("load",(function(){e&&e.call(i,null,n)}),i),n);cc.assetManager.loadRemote(t,(function(t,n){e&&e.call(i,t,n)}))},cacheImage:function(t,e){if(t&&e){var n=new i;return n.initWithElement(e),cc.assetManager.assets.add(t,n),n}},postLoadTexture:function(t,e){t.loaded?e&&e():t.nativeUrl?cc.assetManager.postLoadNative(t,e):e&&e()}};e.exports=n}),{"../assets/CCTexture2D":73}],260:[(function(t,e){"use strict";var i=t("./node-unit"),n=t("./node-mem-pool");e.exports={NodeMemPool:new n(i)}}),{"./node-mem-pool":262,"./node-unit":263}],261:[(function(t,e){"use strict";var i=function(t){this._unitClass=t,this._pool=[],this._findOrder=[]},n=i.prototype;n._initNative=function(){this._nativeMemPool=new renderer.MemPool},n._buildUnit=function(t){return new this._unitClass(t,this)},n._destroyUnit=function(t){this._pool[t]=null;for(var e=0,i=this._findOrder.length;e1&&e.isAllFree()&&this._destroyUnit(t.unitID),e},e.exports=i}),{}],262:[(function(t,e){"use strict";var i,n=t("./mem-pool"),r=function(t){n.call(this,t)};(i=function(){}).prototype=n.prototype;var s=r.prototype=new i;s._initNative=function(){this._nativeMemPool=new renderer.NodeMemPool},s._destroyUnit=function(t){n.prototype._destroyUnit.call(this,t)},e.exports=r}),{"./mem-pool":261}],263:[(function(t,e){"use strict";var i,n=t("../../value-types/utils"),r=(Uint32Array,10*n.FLOAT_BYTES),s=16*n.FLOAT_BYTES,o=16*n.FLOAT_BYTES,a=(Uint32Array,Uint32Array,Int32Array,Uint8Array,Uint8Array,Uint32Array,n.FLOAT_BYTES,t("./unit-base")),c=function(t,e){a.call(this,t,e);var i=this._contentNum;this.trsList=new n.FLOAT_ARRAY_TYPE(10*i),this.localMatList=new n.FLOAT_ARRAY_TYPE(16*i),this.worldMatList=new n.FLOAT_ARRAY_TYPE(16*i);for(var c=0;c",e=this._signData[2*e+0];for(var n=0,r="",s=this._contentNum,o=0;o");var a=t+n;console.log("unitID:",this.unitID,"spaceNum:",t,"calc using num:",n,"store using num:",this._data[1],"calc total num:",a,"actually total num:",this._contentNum),console.log("free info:",i),console.log("using info:",r),n!=this._data[1]&&cc.error("using num error","calc using num:",n,"store using num:",this._data[1]),t+n!=this._contentNum&&cc.error("total num error","calc total num:",a,"actually total num:",this._contentNum)},e.exports=i}),{}],265:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=o(t("./value-type")),r=o(t("../platform/CCClass")),s=o(t("../utils/misc"));function o(t){return t&&t.__esModule?t:{default:t}}function a(t,e){for(var i=0;i>>0)+(n<<16)+(i<<8)+(0|e),s}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,c(e,i),n.copy=function(t,e){return t.r=e.r,t.g=e.g,t.b=e.b,t.a=e.a,t},n.clone=function(t){return new n(t.r,t.g,t.b,t.a)},n.set=function(t,e,i,n,r){return void 0===e&&(e=255),void 0===i&&(i=255),void 0===n&&(n=255),void 0===r&&(r=255),t.r=e,t.g=i,t.b=n,t.a=r,t},n.fromHex=function(t,e){var i=e>>24&255,n=e>>16&255,r=e>>8&255,s=255&e;return t.r=i,t.g=n,t.b=r,t.a=s,t},n.fromHEX=function(t,e){return e=0===e.indexOf("#")?e.substring(1):e,t.r=parseInt(e.substr(0,2),16)||0,t.g=parseInt(e.substr(2,2),16)||0,t.b=parseInt(e.substr(4,2),16)||0,t.a=parseInt(e.substr(6,2),16)||255,t._val=(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r,t},n.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},n.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},n.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},n.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},n.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},n.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},n.toArray=function(t,e,i){void 0===i&&(i=0);var r=e instanceof n||e.a>1?1/255:1;return t[i+0]=e.r*r,t[i+1]=e.g*r,t[i+2]=e.b*r,t[i+3]=e.a*r,t},n.fromArray=function(t,e,i){return void 0===i&&(i=0),e.r=255*t[i+0],e.g=255*t[i+1],e.b=255*t[i+2],e.a=255*t[i+3],e},n.premultiplyAlpha=function(t,e){var i=e.a/255;return t.r=e.r*i,t.g=e.g*i,t.b=e.b*i,t._fastSetA(e.a),t};var r,o,l,u=n.prototype;return u.clone=function(){var t=new n;return t._val=this._val,t},u.equals=function(t){return t&&this._val===t._val},u.lerp=function(t,e,i){i=i||new n;var r=this.r,s=this.g,o=this.b,a=this.a;return i.r=r+(t.r-r)*e,i.g=s+(t.g-s)*e,i.b=o+(t.b-o)*e,i.a=a+(t.a-a)*e,i},u.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},u.getR=function(){return 255&this._val},u.setR=function(t){return t=~~s.default.clampf(t,0,255),this._val=(4294967040&this._val|t)>>>0,this},u.getG=function(){return(65280&this._val)>>8},u.setG=function(t){return t=~~s.default.clampf(t,0,255),this._val=(4294902015&this._val|t<<8)>>>0,this},u.getB=function(){return(16711680&this._val)>>16},u.setB=function(t){return t=~~s.default.clampf(t,0,255),this._val=(4278255615&this._val|t<<16)>>>0,this},u.getA=function(){return(4278190080&this._val)>>>24},u.setA=function(t){return t=~~s.default.clampf(t,0,255),this._val=(16777215&this._val|t<<24)>>>0,this},u.toCSS=function(t){return t&&"rgba"!==t?"rgb"===t?"rgb("+this.r+","+this.g+","+this.b+")":"#"+this.toHEX(t):"rgba("+this.r+","+this.g+","+this.b+","+(this.a/255).toFixed(2)+")"},u.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},u.toHEX=function(t){var e=[(this.r<16?"0":"")+this.r.toString(16),(this.g<16?"0":"")+this.g.toString(16),(this.b<16?"0":"")+this.b.toString(16)];return"#rgb"===t?(e[0]=e[0][0],e[1]=e[1][0],e[2]=e[2][0]):"#rrggbbaa"===t&&e.push((this.a<16?"0":"")+this.a.toString(16)),e.join("")},u.toRGBValue=function(){return 16777215&this._val},u.fromHSV=function(t,e,i){var n,r,s;if(0===e)n=r=s=i;else if(0===i)n=r=s=0;else{1===t&&(t=0),t*=6;var o=Math.floor(t),a=t-o,c=i*(1-e),l=i*(1-e*a),u=i*(1-e*(1-a));switch(o){case 0:n=i,r=u,s=c;break;case 1:n=l,r=i,s=c;break;case 2:n=c,r=i,s=u;break;case 3:n=c,r=l,s=i;break;case 4:n=u,r=c,s=i;break;case 5:n=i,r=c,s=l}}return n*=255,r*=255,s*=255,this._val=(this.a<<24>>>0)+(s<<16)+(r<<8)+(0|n),this},u.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},u.set=function(t){return t._val?this._val=t._val:(this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a),this},u._fastSetA=function(t){this._val=(16777215&this._val|t<<24)>>>0},u.multiply=function(t){var e=(255&this._val)*t.r>>8,i=(65280&this._val)*t.g>>8,n=(16711680&this._val)*t.b>>8,r=((4278190080&this._val)>>>8)*t.a;return this._val=4278190080&r|16711680&n|65280&i|255&e,this},r=n,l=[{key:"WHITE",get:function(){return new n(255,255,255,255)}},{key:"BLACK",get:function(){return new n(0,0,0,255)}},{key:"TRANSPARENT",get:function(){return new n(0,0,0,0)}},{key:"GRAY",get:function(){return new n(127.5,127.5,127.5)}},{key:"RED",get:function(){return new n(255,0,0)}},{key:"GREEN",get:function(){return new n(0,255,0)}},{key:"BLUE",get:function(){return new n(0,0,255)}},{key:"YELLOW",get:function(){return new n(255,235,4)}},{key:"ORANGE",get:function(){return new n(255,127,0)}},{key:"CYAN",get:function(){return new n(0,255,255)}},{key:"MAGENTA",get:function(){return new n(255,0,255)}}],(o=[{key:"r",get:function(){return this.getR()},set:function(t){this.setR(t)}},{key:"g",get:function(){return this.getG()},set:function(t){this.setG(t)}},{key:"b",get:function(){return this.getB()},set:function(t){this.setB(t)}},{key:"a",get:function(){return this.getA()},set:function(t){this.setA(t)}}])&&a(r.prototype,o),l&&a(r,l),Object.defineProperty(r,"prototype",{writable:!1}),n})(n.default);i.default=l,l.div=l.divide,l.sub=l.subtract,l.mul=l.multiply,l.WHITE_R=l.WHITE,l.BLACK_R=l.BLACK,l.TRANSPARENT_R=l.TRANSPARENT,l.GRAY_R=l.GRAY,l.RED_R=l.RED,l.GREEN_R=l.GREEN,l.BLUE_R=l.BLUE,l.YELLOW_R=l.YELLOW,l.ORANGE_R=l.ORANGE,l.CYAN_R=l.CYAN,l.MAGENTA_R=l.MAGENTA,r.default.fastDefine("cc.Color",l,{r:0,g:0,b:0,a:255}),cc.Color=l,cc.color=function(t,e,i,n){return"string"==typeof t?(new l).fromHEX(t):"object"==typeof t?new l(t.r,t.g,t.b,t.a):new l(t,e,i,n)},e.exports=i.default}),{"../platform/CCClass":178,"../utils/misc":251,"./value-type":274}],266:[(function(t,e,i){"use strict";i.__esModule=!0;var n={Vec2:!0,Vec3:!0,Vec4:!0,Mat4:!0,Mat3:!0,Rect:!0,Size:!0,Color:!0,Quat:!0,Trs:!0};i.Vec4=i.Vec3=i.Vec2=i.Trs=i.Size=i.Rect=i.Quat=i.Mat4=i.Mat3=i.Color=void 0;var r=p(t("./vec2"));i.Vec2=r.default;var s=p(t("./vec3"));i.Vec3=s.default;var o=p(t("./vec4"));i.Vec4=o.default;var a=p(t("./mat4"));i.Mat4=a.default;var c=p(t("./mat3"));i.Mat3=c.default;var l=p(t("./rect"));i.Rect=l.default;var u=p(t("./size"));i.Size=u.default;var h=p(t("./color"));i.Color=h.default;var _=p(t("./quat"));i.Quat=_.default;var f=p(t("./trs"));i.Trs=f.default;var d=t("./utils");function p(t){return t&&t.__esModule?t:{default:t}}Object.keys(d).forEach((function(t){"default"!==t&&"__esModule"!==t&&(Object.prototype.hasOwnProperty.call(n,t)||t in i&&i[t]===d[t]||(i[t]=d[t]))})),cc.math=e.exports}),{"./color":265,"./mat3":267,"./mat4":268,"./quat":269,"./rect":270,"./size":271,"./trs":272,"./utils":273,"./vec2":275,"./vec3":276,"./vec4":277}],267:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=t("../value-types/utils"),s=(n=t("./vec3"))&&n.__esModule?n:{default:n},o=(function(){function t(t,e,i,n,s,o,a,c,l){if(void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=1),void 0===o&&(o=0),void 0===a&&(a=0),void 0===c&&(c=0),void 0===l&&(l=1),this.m=void 0,t instanceof r.FLOAT_ARRAY_TYPE)this.m=t;else{this.m=new r.FLOAT_ARRAY_TYPE(9);var u=this.m;u[0]=t,u[1]=e,u[2]=i,u[3]=n,u[4]=s,u[5]=o,u[6]=a,u[7]=c,u[8]=l}}return t.create=function(e,i,n,r,s,o,a,c,l){return void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=1),void 0===o&&(o=0),void 0===a&&(a=0),void 0===c&&(c=0),void 0===l&&(l=1),new t(e,i,n,r,s,o,a,c,l)},t.clone=function(e){var i=e.m;return new t(i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},t.copy=function(t,e){return t.m.set(e.m),t},t.set=function(t,e,i,n,r,s,o,a,c,l){var u=t.m;return u[0]=e,u[1]=i,u[2]=n,u[3]=r,u[4]=s,u[5]=o,u[6]=a,u[7]=c,u[8]=l,t},t.identity=function(t){var e=t.m;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,t},t.transpose=function(t,e){var i=e.m,n=t.m;if(t===e){var r=i[1],s=i[2],o=i[5];n[1]=i[3],n[2]=i[6],n[3]=r,n[5]=i[7],n[6]=s,n[7]=o}else n[0]=i[0],n[1]=i[3],n[2]=i[6],n[3]=i[1],n[4]=i[4],n[5]=i[7],n[6]=i[2],n[7]=i[5],n[8]=i[8];return t},t.invert=function(t,e){var i=e.m,n=t.m,r=i[0],s=i[1],o=i[2],a=i[3],c=i[4],l=i[5],u=i[6],h=i[7],_=i[8],f=_*c-l*h,d=-_*a+l*u,p=h*a-c*u,m=r*f+s*d+o*p;return m?(m=1/m,n[0]=f*m,n[1]=(-_*s+o*h)*m,n[2]=(l*s-o*c)*m,n[3]=d*m,n[4]=(_*r-o*u)*m,n[5]=(-l*r+o*a)*m,n[6]=p*m,n[7]=(-h*r+s*u)*m,n[8]=(c*r-s*a)*m,t):t},t.adjoint=function(t,e){var i=e.m,n=t.m,r=i[0],s=i[1],o=i[2],a=i[3],c=i[4],l=i[5],u=i[6],h=i[7],_=i[8];return n[0]=c*_-l*h,n[1]=o*h-s*_,n[2]=s*l-o*c,n[3]=l*u-a*_,n[4]=r*_-o*u,n[5]=o*a-r*l,n[6]=a*h-c*u,n[7]=s*u-r*h,n[8]=r*c-s*a,t},t.determinant=function(t){var e=t.m,i=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return i*(u*o-a*l)+n*(-u*s+a*c)+r*(l*s-o*c)},t.multiply=function(t,e,i){var n=e.m,r=i.m,s=t.m,o=n[0],a=n[1],c=n[2],l=n[3],u=n[4],h=n[5],_=n[6],f=n[7],d=n[8],p=r[0],m=r[1],v=r[2],y=r[3],g=r[4],x=r[5],A=r[6],C=r[7],S=r[8];return s[0]=p*o+m*l+v*_,s[1]=p*a+m*u+v*f,s[2]=p*c+m*h+v*d,s[3]=y*o+g*l+x*_,s[4]=y*a+g*u+x*f,s[5]=y*c+g*h+x*d,s[6]=A*o+C*l+S*_,s[7]=A*a+C*u+S*f,s[8]=A*c+C*h+S*d,t},t.multiplyMat4=function(t,e,i){var n=e.m,r=i.m,s=t.m,o=n[0],a=n[1],c=n[2],l=n[3],u=n[4],h=n[5],_=n[6],f=n[7],d=n[8],p=r[0],m=r[1],v=r[2],y=r[4],g=r[5],x=r[6],A=r[8],C=r[9],S=r[10];return s[0]=p*o+m*l+v*_,s[1]=p*a+m*u+v*f,s[2]=p*c+m*h+v*d,s[3]=y*o+g*l+x*_,s[4]=y*a+g*u+x*f,s[5]=y*c+g*h+x*d,s[6]=A*o+C*l+S*_,s[7]=A*a+C*u+S*f,s[8]=A*c+C*h+S*d,t},t.translate=function(t,e,i){var n=e.m,r=t.m,s=n[0],o=n[1],a=n[2],c=n[3],l=n[4],u=n[5],h=n[6],_=n[7],f=n[8],d=i.x,p=i.y;return r[0]=s,r[1]=o,r[2]=a,r[3]=c,r[4]=l,r[5]=u,r[6]=d*s+p*c+h,r[7]=d*o+p*l+_,r[8]=d*a+p*u+f,t},t.rotate=function(t,e,i){var n=e.m,r=t.m,s=n[0],o=n[1],a=n[2],c=n[3],l=n[4],u=n[5],h=n[6],_=n[7],f=n[8],d=Math.sin(i),p=Math.cos(i);return r[0]=p*s+d*c,r[1]=p*o+d*l,r[2]=p*a+d*u,r[3]=p*c-d*s,r[4]=p*l-d*o,r[5]=p*u-d*a,r[6]=h,r[7]=_,r[8]=f,t},t.scale=function(t,e,i){var n=i.x,r=i.y,s=e.m,o=t.m;return o[0]=n*s[0],o[1]=n*s[1],o[2]=n*s[2],o[3]=r*s[3],o[4]=r*s[4],o[5]=r*s[5],o[6]=s[6],o[7]=s[7],o[8]=s[8],t},t.fromMat4=function(t,e){var i=e.m,n=t.m;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[4],n[4]=i[5],n[5]=i[6],n[6]=i[8],n[7]=i[9],n[8]=i[10],t},t.fromTranslation=function(t,e){var i=t.m;return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=1,i[5]=0,i[6]=e.x,i[7]=e.y,i[8]=1,t},t.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e),r=t.m;return r[0]=n,r[1]=i,r[2]=0,r[3]=-i,r[4]=n,r[5]=0,r[6]=0,r[7]=0,r[8]=1,t},t.fromScaling=function(t,e){var i=t.m;return i[0]=e.x,i[1]=0,i[2]=0,i[3]=0,i[4]=e.y,i[5]=0,i[6]=0,i[7]=0,i[8]=1,t},t.fromQuat=function(t,e){var i=t.m,n=e.x,r=e.y,s=e.z,o=e.w,a=n+n,c=r+r,l=s+s,u=n*a,h=r*a,_=r*c,f=s*a,d=s*c,p=s*l,m=o*a,v=o*c,y=o*l;return i[0]=1-_-p,i[3]=h-y,i[6]=f+v,i[1]=h+y,i[4]=1-u-p,i[7]=d-m,i[2]=f-v,i[5]=d+m,i[8]=1-u-_,t},t.fromViewUp=function(e,i,n){var o,a,c;return(o=new s.default(0,1,0),a=new s.default,c=new s.default,function(e,i,n){return s.default.lengthSqr(i)0?(r=2*Math.sqrt(n+1),t.w=.25*r,t.x=(i[6]-i[9])/r,t.y=(i[8]-i[2])/r,t.z=(i[1]-i[4])/r):i[0]>i[5]&&i[0]>i[10]?(r=2*Math.sqrt(1+i[0]-i[5]-i[10]),t.w=(i[6]-i[9])/r,t.x=.25*r,t.y=(i[1]+i[4])/r,t.z=(i[8]+i[2])/r):i[5]>i[10]?(r=2*Math.sqrt(1+i[5]-i[0]-i[10]),t.w=(i[8]-i[2])/r,t.x=(i[1]+i[4])/r,t.y=.25*r,t.z=(i[6]+i[9])/r):(r=2*Math.sqrt(1+i[10]-i[0]-i[5]),t.w=(i[1]-i[4])/r,t.x=(i[8]+i[2])/r,t.y=(i[6]+i[9])/r,t.z=.25*r),t},r.toRTS=function(t,e,i,n){var r=t.m,a=M.m;n.x=s.default.set(B,r[0],r[1],r[2]).mag(),a[0]=r[0]/n.x,a[1]=r[1]/n.x,a[2]=r[2]/n.x,n.y=s.default.set(B,r[4],r[5],r[6]).mag(),a[3]=r[4]/n.y,a[4]=r[5]/n.y,a[5]=r[6]/n.y,n.z=s.default.set(B,r[8],r[9],r[10]).mag(),a[6]=r[8]/n.z,a[7]=r[9]/n.z,a[8]=r[10]/n.z,c.default.determinant(M)<0&&(n.x*=-1,a[0]*=-1,a[1]*=-1,a[2]*=-1),o.default.fromMat3(e,M),s.default.set(i,r[12],r[13],r[14])},r.fromRTS=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=e.w,c=r+r,l=s+s,u=o+o,h=r*c,_=r*l,f=r*u,d=s*l,p=s*u,m=o*u,v=a*c,y=a*l,g=a*u,x=n.x,A=n.y,C=n.z,S=t.m;return S[0]=(1-(d+m))*x,S[1]=(_+g)*x,S[2]=(f-y)*x,S[3]=0,S[4]=(_-g)*A,S[5]=(1-(h+m))*A,S[6]=(p+v)*A,S[7]=0,S[8]=(f+y)*C,S[9]=(p-v)*C,S[10]=(1-(h+d))*C,S[11]=0,S[12]=i.x,S[13]=i.y,S[14]=i.z,S[15]=1,t},r.fromRTSOrigin=function(t,e,i,n,r){var s=e.x,o=e.y,a=e.z,c=e.w,l=s+s,u=o+o,h=a+a,_=s*l,f=s*u,d=s*h,p=o*u,m=o*h,v=a*h,y=c*l,g=c*u,x=c*h,A=n.x,C=n.y,S=n.z,b=r.x,T=r.y,w=r.z,E=t.m;return E[0]=(1-(p+v))*A,E[1]=(f+x)*A,E[2]=(d-g)*A,E[3]=0,E[4]=(f-x)*C,E[5]=(1-(_+v))*C,E[6]=(m+y)*C,E[7]=0,E[8]=(d+g)*S,E[9]=(m-y)*S,E[10]=(1-(_+p))*S,E[11]=0,E[12]=i.x+b-(E[0]*b+E[4]*T+E[8]*w),E[13]=i.y+T-(E[1]*b+E[5]*T+E[9]*w),E[14]=i.z+w-(E[2]*b+E[6]*T+E[10]*w),E[15]=1,t},r.fromQuat=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w,o=i+i,a=n+n,c=r+r,l=i*o,u=n*o,h=n*a,_=r*o,f=r*a,d=r*c,p=s*o,m=s*a,v=s*c,y=t.m;return y[0]=1-h-d,y[1]=u+v,y[2]=_-m,y[3]=0,y[4]=u-v,y[5]=1-l-d,y[6]=f+p,y[7]=0,y[8]=_+m,y[9]=f-p,y[10]=1-l-h,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,t},r.frustum=function(t,e,i,n,r,s,o){var a=1/(i-e),c=1/(r-n),l=1/(s-o),u=t.m;return u[0]=2*s*a,u[1]=0,u[2]=0,u[3]=0,u[4]=0,u[5]=2*s*c,u[6]=0,u[7]=0,u[8]=(i+e)*a,u[9]=(r+n)*c,u[10]=(o+s)*l,u[11]=-1,u[12]=0,u[13]=0,u[14]=o*s*2*l,u[15]=0,t},r.perspective=function(t,e,i,n,r){var s=1/Math.tan(e/2),o=1/(n-r),a=t.m;return a[0]=s/i,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=s,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=(r+n)*o,a[11]=-1,a[12]=0,a[13]=0,a[14]=2*r*n*o,a[15]=0,t},r.ortho=function(t,e,i,n,r,s,o){var a=1/(e-i),c=1/(n-r),l=1/(s-o),u=t.m;return u[0]=-2*a,u[1]=0,u[2]=0,u[3]=0,u[4]=0,u[5]=-2*c,u[6]=0,u[7]=0,u[8]=0,u[9]=0,u[10]=2*l,u[11]=0,u[12]=(e+i)*a,u[13]=(r+n)*c,u[14]=(o+s)*l,u[15]=1,t},r.lookAt=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=n.x,c=n.y,l=n.z,u=r-i.x,h=s-i.y,_=o-i.z,f=1/Math.sqrt(u*u+h*h+_*_),d=c*(_*=f)-l*(h*=f),p=l*(u*=f)-a*_,m=a*h-c*u,v=h*(m*=f=1/Math.sqrt(d*d+p*p+m*m))-_*(p*=f),y=_*(d*=f)-u*m,g=u*p-h*d,x=t.m;return x[0]=d,x[1]=v,x[2]=u,x[3]=0,x[4]=p,x[5]=y,x[6]=h,x[7]=0,x[8]=m,x[9]=g,x[10]=_,x[11]=0,x[12]=-(d*r+p*s+m*o),x[13]=-(v*r+y*s+g*o),x[14]=-(u*r+h*s+_*o),x[15]=1,t},r.inverseTranspose=function(t,e){var i=e.m;h=i[0],_=i[1],f=i[2],d=i[3],p=i[4],m=i[5],v=i[6],y=i[7],g=i[8],x=i[9],A=i[10],C=i[11],S=i[12],b=i[13],T=i[14],w=i[15];var n=h*m-_*p,r=h*v-f*p,s=h*y-d*p,o=_*v-f*m,a=_*y-d*m,c=f*y-d*v,l=g*b-x*S,u=g*T-A*S,E=g*w-C*S,B=x*T-A*b,M=x*w-C*b,R=A*w-C*T,P=n*R-r*M+s*B+o*E-a*u+c*l;return P?(P=1/P,(i=t.m)[0]=(m*R-v*M+y*B)*P,i[1]=(v*E-p*R-y*u)*P,i[2]=(p*M-m*E+y*l)*P,i[3]=0,i[4]=(f*M-_*R-d*B)*P,i[5]=(h*R-f*E+d*u)*P,i[6]=(_*E-h*M-d*l)*P,i[7]=0,i[8]=(b*c-T*a+w*o)*P,i[9]=(T*s-S*c-w*r)*P,i[10]=(S*a-b*s+w*n)*P,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,t):null},r.add=function(t,e,i){var n=t.m,r=e.m,s=i.m;return n[0]=r[0]+s[0],n[1]=r[1]+s[1],n[2]=r[2]+s[2],n[3]=r[3]+s[3],n[4]=r[4]+s[4],n[5]=r[5]+s[5],n[6]=r[6]+s[6],n[7]=r[7]+s[7],n[8]=r[8]+s[8],n[9]=r[9]+s[9],n[10]=r[10]+s[10],n[11]=r[11]+s[11],n[12]=r[12]+s[12],n[13]=r[13]+s[13],n[14]=r[14]+s[14],n[15]=r[15]+s[15],t},r.subtract=function(t,e,i){var n=t.m,r=e.m,s=i.m;return n[0]=r[0]-s[0],n[1]=r[1]-s[1],n[2]=r[2]-s[2],n[3]=r[3]-s[3],n[4]=r[4]-s[4],n[5]=r[5]-s[5],n[6]=r[6]-s[6],n[7]=r[7]-s[7],n[8]=r[8]-s[8],n[9]=r[9]-s[9],n[10]=r[10]-s[10],n[11]=r[11]-s[11],n[12]=r[12]-s[12],n[13]=r[13]-s[13],n[14]=r[14]-s[14],n[15]=r[15]-s[15],t},r.multiplyScalar=function(t,e,i){var n=t.m,r=e.m;return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=r[3]*i,n[4]=r[4]*i,n[5]=r[5]*i,n[6]=r[6]*i,n[7]=r[7]*i,n[8]=r[8]*i,n[9]=r[9]*i,n[10]=r[10]*i,n[11]=r[11]*i,n[12]=r[12]*i,n[13]=r[13]*i,n[14]=r[14]*i,n[15]=r[15]*i,t},r.multiplyScalarAndAdd=function(t,e,i,n){var r=t.m,s=e.m,o=i.m;return r[0]=s[0]+o[0]*n,r[1]=s[1]+o[1]*n,r[2]=s[2]+o[2]*n,r[3]=s[3]+o[3]*n,r[4]=s[4]+o[4]*n,r[5]=s[5]+o[5]*n,r[6]=s[6]+o[6]*n,r[7]=s[7]+o[7]*n,r[8]=s[8]+o[8]*n,r[9]=s[9]+o[9]*n,r[10]=s[10]+o[10]*n,r[11]=s[11]+o[11]*n,r[12]=s[12]+o[12]*n,r[13]=s[13]+o[13]*n,r[14]=s[14]+o[14]*n,r[15]=s[15]+o[15]*n,t},r.strictEquals=function(t,e){var i=t.m,n=e.m;return i[0]===n[0]&&i[1]===n[1]&&i[2]===n[2]&&i[3]===n[3]&&i[4]===n[4]&&i[5]===n[5]&&i[6]===n[6]&&i[7]===n[7]&&i[8]===n[8]&&i[9]===n[9]&&i[10]===n[10]&&i[11]===n[11]&&i[12]===n[12]&&i[13]===n[13]&&i[14]===n[14]&&i[15]===n[15]},r.equals=function(t,e,i){void 0===i&&(i=a.EPSILON);var n=t.m,r=e.m;return Math.abs(n[0]-r[0])<=i*Math.max(1,Math.abs(n[0]),Math.abs(r[0]))&&Math.abs(n[1]-r[1])<=i*Math.max(1,Math.abs(n[1]),Math.abs(r[1]))&&Math.abs(n[2]-r[2])<=i*Math.max(1,Math.abs(n[2]),Math.abs(r[2]))&&Math.abs(n[3]-r[3])<=i*Math.max(1,Math.abs(n[3]),Math.abs(r[3]))&&Math.abs(n[4]-r[4])<=i*Math.max(1,Math.abs(n[4]),Math.abs(r[4]))&&Math.abs(n[5]-r[5])<=i*Math.max(1,Math.abs(n[5]),Math.abs(r[5]))&&Math.abs(n[6]-r[6])<=i*Math.max(1,Math.abs(n[6]),Math.abs(r[6]))&&Math.abs(n[7]-r[7])<=i*Math.max(1,Math.abs(n[7]),Math.abs(r[7]))&&Math.abs(n[8]-r[8])<=i*Math.max(1,Math.abs(n[8]),Math.abs(r[8]))&&Math.abs(n[9]-r[9])<=i*Math.max(1,Math.abs(n[9]),Math.abs(r[9]))&&Math.abs(n[10]-r[10])<=i*Math.max(1,Math.abs(n[10]),Math.abs(r[10]))&&Math.abs(n[11]-r[11])<=i*Math.max(1,Math.abs(n[11]),Math.abs(r[11]))&&Math.abs(n[12]-r[12])<=i*Math.max(1,Math.abs(n[12]),Math.abs(r[12]))&&Math.abs(n[13]-r[13])<=i*Math.max(1,Math.abs(n[13]),Math.abs(r[13]))&&Math.abs(n[14]-r[14])<=i*Math.max(1,Math.abs(n[14]),Math.abs(r[14]))&&Math.abs(n[15]-r[15])<=i*Math.max(1,Math.abs(n[15]),Math.abs(r[15]))},r.adjoint=function(t,e){var i=e.m,n=t.m,r=i[0],s=i[1],o=i[2],a=i[3],c=i[4],l=i[5],u=i[6],h=i[7],_=i[8],f=i[9],d=i[10],p=i[11],m=i[12],v=i[13],y=i[14],g=i[15];return n[0]=l*(d*g-p*y)-f*(u*g-h*y)+v*(u*p-h*d),n[1]=-(s*(d*g-p*y)-f*(o*g-a*y)+v*(o*p-a*d)),n[2]=s*(u*g-h*y)-l*(o*g-a*y)+v*(o*h-a*u),n[3]=-(s*(u*p-h*d)-l*(o*p-a*d)+f*(o*h-a*u)),n[4]=-(c*(d*g-p*y)-_*(u*g-h*y)+m*(u*p-h*d)),n[5]=r*(d*g-p*y)-_*(o*g-a*y)+m*(o*p-a*d),n[6]=-(r*(u*g-h*y)-c*(o*g-a*y)+m*(o*h-a*u)),n[7]=r*(u*p-h*d)-c*(o*p-a*d)+_*(o*h-a*u),n[8]=c*(f*g-p*v)-_*(l*g-h*v)+m*(l*p-h*f),n[9]=-(r*(f*g-p*v)-_*(s*g-a*v)+m*(s*p-a*f)),n[10]=r*(l*g-h*v)-c*(s*g-a*v)+m*(s*h-a*l),n[11]=-(r*(l*p-h*f)-c*(s*p-a*f)+_*(s*h-a*l)),n[12]=-(c*(f*y-d*v)-_*(l*y-u*v)+m*(l*d-u*f)),n[13]=r*(f*y-d*v)-_*(s*y-o*v)+m*(s*d-o*f),n[14]=-(r*(l*y-u*v)-c*(s*y-o*v)+m*(s*u-o*l)),n[15]=r*(l*d-u*f)-c*(s*d-o*f)+_*(s*u-o*l),t},r.toArray=function(t,e,i){void 0===i&&(i=0);for(var n=e.m,r=0;r<16;r++)t[i+r]=n[r];return t},r.fromArray=function(t,e,i){void 0===i&&(i=0);for(var n=t.m,r=0;r<16;r++)n[r]=e[i+r];return t},n.clone=function(){var t=this.m;return new r(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},n.set=function(t){var e=this.m,i=t.m;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},n.equals=function(t){return r.strictEquals(this,t)},n.fuzzyEquals=function(t){return r.equals(this,t)},n.toString=function(){var t=this.m;return t?"[\n"+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+",\n"+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+",\n"+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+",\n"+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+"\n]":"[\n1, 0, 0, 0\n0, 1, 0, 0\n0, 0, 1, 0\n0, 0, 0, 1\n]"},n.identity=function(){return r.identity(this)},n.transpose=function(t){return t=t||new r,r.transpose(t,this)},n.invert=function(t){return t=t||new r,r.invert(t,this)},n.adjoint=function(t){return t=t||new r,r.adjoint(t,this)},n.determinant=function(){return r.determinant(this)},n.add=function(t,e){return e=e||new r,r.add(e,this,t)},n.subtract=function(t){return r.subtract(this,this,t)},n.multiply=function(t){return r.multiply(this,this,t)},n.multiplyScalar=function(t){return r.multiplyScalar(this,this,t)},n.translate=function(t,e){return e=e||new r,r.translate(e,this,t)},n.scale=function(t,e){return e=e||new r,r.scale(e,this,t)},n.rotate=function(t,e,i){return i=i||new r,r.rotate(i,this,t,e)},n.getTranslation=function(t){return t=t||new s.default,r.getTranslation(t,this)},n.getScale=function(t){return t=t||new s.default,r.getScaling(t,this)},n.getRotation=function(t){return t=t||new o.default,r.getRotation(t,this)},n.fromRTS=function(t,e,i){return r.fromRTS(this,t,e,i)},n.fromQuat=function(t){return r.fromQuat(this,t)},r})(n.default);i.default=E,E.mul=E.multiply,E.sub=E.subtract,E.IDENTITY=Object.freeze(new E);var B=new s.default,M=new c.default;r.default.fastDefine("cc.Mat4",E,{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});for(var R=function(t){Object.defineProperty(E.prototype,"m"+t,{get:function(){return this.m[t]},set:function(e){this.m[t]=e}})},P=0;P<16;P++)R(P);cc.mat4=function(t,e,i,n,r,s,o,a,c,l,u,h,_,f,d,p){var m=new E(t,e,i,n,r,s,o,a,c,l,u,h,_,f,d,p);return void 0===t&&E.identity(m),m},cc.Mat4=E,e.exports=i.default}),{"../platform/CCClass":178,"./mat3":267,"./quat":269,"./utils":273,"./value-type":274,"./vec3":276}],269:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=c(t("./value-type")),r=c(t("../platform/CCClass")),s=c(t("./vec3")),o=c(t("./mat3")),a=t("./utils");function c(t){return t&&t.__esModule?t:{default:t}}function l(t,e){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var u=0,h=0,_=0,f=0,d=(function(t){var e,i;i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,l(e,i);var n=r.prototype;function r(e,i,n,r){var s;return void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),(s=t.call(this)||this).x=void 0,s.y=void 0,s.z=void 0,s.w=void 0,e&&"object"==typeof e?(s.x=e.x,s.y=e.y,s.z=e.z,s.w=e.w):(s.x=e,s.y=i,s.z=n,s.w=r),s}return n.mul=function(t,e){return r.multiply(e||new r,this,t)},r.clone=function(t){return new r(t.x,t.y,t.z,t.w)},r.copy=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t},r.set=function(t,e,i,n,r){return t.x=e,t.y=i,t.z=n,t.w=r,t},r.identity=function(t){return t.x=0,t.y=0,t.z=0,t.w=1,t},r.rotationTo=function(t,e,i){var n=s.default.dot(e,i);return n<-.999999?(s.default.cross(v,s.default.RIGHT,e),v.mag()<1e-6&&s.default.cross(v,s.default.UP,e),s.default.normalize(v,v),r.fromAxisAngle(t,v,Math.PI),t):n>.999999?(t.x=0,t.y=0,t.z=0,t.w=1,t):(s.default.cross(v,e,i),t.x=v.x,t.y=v.y,t.z=v.z,t.w=1+n,r.normalize(t,t))},r.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},r.multiply=function(t,e,i){return u=e.x*i.w+e.w*i.x+e.y*i.z-e.z*i.y,h=e.y*i.w+e.w*i.y+e.z*i.x-e.x*i.z,_=e.z*i.w+e.w*i.z+e.x*i.y-e.y*i.x,f=e.w*i.w-e.x*i.x-e.y*i.y-e.z*i.z,t.x=u,t.y=h,t.z=_,t.w=f,t},r.multiplyScalar=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},r.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},r.rotateX=function(t,e,i){i*=.5;var n=Math.sin(i),r=Math.cos(i);return u=e.x*r+e.w*n,h=e.y*r+e.z*n,_=e.z*r-e.y*n,f=e.w*r-e.x*n,t.x=u,t.y=h,t.z=_,t.w=f,t},r.rotateY=function(t,e,i){i*=.5;var n=Math.sin(i),r=Math.cos(i);return u=e.x*r-e.z*n,h=e.y*r+e.w*n,_=e.z*r+e.x*n,f=e.w*r-e.y*n,t.x=u,t.y=h,t.z=_,t.w=f,t},r.rotateZ=function(t,e,i){i*=.5;var n=Math.sin(i),r=Math.cos(i);return u=e.x*r+e.y*n,h=e.y*r-e.x*n,_=e.z*r+e.w*n,f=e.w*r-e.z*n,t.x=u,t.y=h,t.z=_,t.w=f,t},r.rotateAround=function(t,e,i,n){return r.invert(p,e),s.default.transformQuat(v,i,p),r.fromAxisAngle(p,v,n),r.multiply(t,e,p),t},r.rotateAroundLocal=function(t,e,i,n){return r.fromAxisAngle(p,i,n),r.multiply(t,e,p),t},r.calculateW=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=Math.sqrt(Math.abs(1-e.x*e.x-e.y*e.y-e.z*e.z)),t},r.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},r.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t.w=e.w+n*(i.w-e.w),t},r.slerp=function(t,e,i,n){var r=0,s=0,o=e.x*i.x+e.y*i.y+e.z*i.z+e.w*i.w;if(o<0&&(o=-o,i.x=-i.x,i.y=-i.y,i.z=-i.z,i.w=-i.w),1-o>1e-6){var a=Math.acos(o),c=Math.sin(a);r=Math.sin((1-n)*a)/c,s=Math.sin(n*a)/c}else r=1-n,s=n;return t.x=r*e.x+s*i.x,t.y=r*e.y+s*i.y,t.z=r*e.z+s*i.z,t.w=r*e.w+s*i.w,t},r.sqlerp=function(t,e,i,n,s,o){return r.slerp(p,e,s,o),r.slerp(m,i,n,o),r.slerp(t,p,m,2*o*(1-o)),t},r.invert=function(t,e){var i=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w,n=i?1/i:0;return t.x=-e.x*n,t.y=-e.y*n,t.z=-e.z*n,t.w=e.w*n,t},r.conjugate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w,t},r.len=function(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w)},r.lengthSqr=function(t){return t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},r.normalize=function(t,e){var i=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w;return i>0&&(i=1/Math.sqrt(i),t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i),t},r.fromAxes=function(t,e,i,n){return o.default.set(y,e.x,e.y,e.z,i.x,i.y,i.z,n.x,n.y,n.z),r.normalize(t,r.fromMat3(t,y))},r.fromViewUp=function(t,e,i){return o.default.fromViewUp(y,e,i),r.normalize(t,r.fromMat3(t,y))},r.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},r.fromAngleZ=function(t,e){return e*=g,t.x=t.y=0,t.z=Math.sin(e),t.w=Math.cos(e),t},r.fromMat3=function(t,e){var i=e.m,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],c=i[5],l=i[6],u=i[7],h=i[8],_=n+a+h;if(_>0){var f=.5/Math.sqrt(_+1);t.w=.25/f,t.x=(c-u)*f,t.y=(l-s)*f,t.z=(r-o)*f}else if(n>a&&n>h){var d=2*Math.sqrt(1+n-a-h);t.w=(c-u)/d,t.x=.25*d,t.y=(o+r)/d,t.z=(l+s)/d}else if(a>h){var p=2*Math.sqrt(1+a-n-h);t.w=(l-s)/p,t.x=(o+r)/p,t.y=.25*p,t.z=(u+c)/p}else{var m=2*Math.sqrt(1+h-n-a);t.w=(r-o)/m,t.x=(l+s)/m,t.y=(u+c)/m,t.z=.25*m}return t},r.fromEuler=function(t,e,i,n){e*=g,i*=g,n*=g;var r=Math.sin(e),s=Math.cos(e),o=Math.sin(i),a=Math.cos(i),c=Math.sin(n),l=Math.cos(n);return t.x=r*a*l+s*o*c,t.y=s*o*l+r*a*c,t.z=s*a*c-r*o*l,t.w=s*a*l-r*o*c,t},r.toAxisX=function(t,e){var i=2*e.y,n=2*e.z;return t.x=1-i*e.y-n*e.z,t.y=i*e.x+n*e.w,t.z=n*e.x+i*e.w,t},r.toAxisY=function(t,e){var i=2*e.x,n=2*e.y,r=2*e.z;return t.x=n*e.x-r*e.w,t.y=1-i*e.x-r*e.z,t.z=r*e.y+i*e.w,t},r.toAxisZ=function(t,e){var i=2*e.x,n=2*e.y,r=2*e.z;return t.x=r*e.x-n*e.w,t.y=r*e.y-i*e.w,t.z=1-i*e.x-n*e.y,t},r.toEuler=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=e.w,c=0,l=0,u=0,h=n*r+s*o;if(h>.499999)c=0,l=(0,a.toDegree)(2*Math.atan2(n,o)),u=90;else if(h<-.499999)c=0,l=-(0,a.toDegree)(2*Math.atan2(n,o)),u=-90;else{var _=n*n,f=r*r,d=s*s;c=(0,a.toDegree)(Math.atan2(2*n*o-2*r*s,1-2*_-2*d)),l=(0,a.toDegree)(Math.atan2(2*r*o-2*n*s,1-2*f-2*d)),u=(0,a.toDegree)(Math.asin(2*h)),i&&(c=-180*Math.sign(c+1e-6)+c,l=-180*Math.sign(l+1e-6)+l,u=180*Math.sign(u+1e-6)-u)}return t.x=c,t.y=l,t.z=u,t},r.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},r.equals=function(t,e,i){return void 0===i&&(i=a.EPSILON),Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(e.y))&&Math.abs(t.z-e.z)<=i*Math.max(1,Math.abs(t.z),Math.abs(e.z))&&Math.abs(t.w-e.w)<=i*Math.max(1,Math.abs(t.w),Math.abs(e.w))},r.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t[i+3]=e.w,t},r.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t.w=e[i+3],t},n.clone=function(){return new r(this.x,this.y,this.z,this.w)},n.set=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},n.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},n.toEuler=function(t){return r.toEuler(t,this)},n.fromEuler=function(t){return r.fromEuler(this,t.x,t.y,t.z)},n.lerp=function(t,e,i){return i=i||new r,r.slerp(i,this,t,e),i},n.multiply=function(t){return r.multiply(this,this,t)},n.rotateAround=function(t,e,i,n){return n=n||new r,r.rotateAround(n,t,e,i)},r})(n.default);i.default=d,d.mul=d.multiply,d.scale=d.multiplyScalar,d.mag=d.len,d.IDENTITY=Object.freeze(new d);var p=new d,m=new d,v=new s.default,y=new o.default,g=.5*Math.PI/180;r.default.fastDefine("cc.Quat",d,{x:0,y:0,z:0,w:1}),cc.quat=function(t,e,i,n){return new d(t,e,i,n)},cc.Quat=d,e.exports=i.default}),{"../platform/CCClass":178,"./mat3":267,"./utils":273,"./value-type":274,"./vec3":276}],270:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=a(t("./value-type")),r=a(t("../platform/CCClass")),s=a(t("./vec2")),o=a(t("./size"));function a(t){return t&&t.__esModule?t:{default:t}}function c(t,e){for(var i=0;i=t.x&&this.y<=t.y&&this.y+this.height>=t.y},u.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},u.union=function(t,e){var i=this.x,n=this.y,r=this.width,s=this.height,o=e.x,a=e.y,c=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+c)-t.x,t.height=Math.max(n+s,a+l)-t.y,t},u.transformMat4=function(t,e){var i=this.x,n=this.y,r=i+this.width,s=n+this.height,o=e.m,a=o[0]*i+o[4]*n+o[12],c=o[1]*i+o[5]*n+o[13],l=o[0]*r+o[4]*n+o[12],u=o[1]*r+o[5]*n+o[13],h=o[0]*i+o[4]*s+o[12],_=o[1]*i+o[5]*s+o[13],f=o[0]*r+o[4]*s+o[12],d=o[1]*r+o[5]*s+o[13],p=Math.min(a,l,h,f),m=Math.max(a,l,h,f),v=Math.min(c,u,_,d),y=Math.max(c,u,_,d);return t.x=p,t.y=v,t.width=m-p,t.height=y-v,t},u.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},r=n,(a=[{key:"xMin",get:function(){return this.x},set:function(t){this.width+=this.x-t,this.x=t}},{key:"yMin",get:function(){return this.y},set:function(t){this.height+=this.y-t,this.y=t}},{key:"xMax",get:function(){return this.x+this.width},set:function(t){this.width=t-this.x}},{key:"yMax",get:function(){return this.y+this.height},set:function(t){this.height=t-this.y}},{key:"center",get:function(){return new s.default(this.x+.5*this.width,this.y+.5*this.height)},set:function(t){this.x=t.x-.5*this.width,this.y=t.y-.5*this.height}},{key:"origin",get:function(){return new s.default(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}},{key:"size",get:function(){return new o.default(this.width,this.height)},set:function(t){this.width=t.width,this.height=t.height}}])&&c(r.prototype,a),Object.defineProperty(r,"prototype",{writable:!1}),n})(n.default);i.default=u,r.default.fastDefine("cc.Rect",u,{x:0,y:0,width:0,height:0}),cc.Rect=u,cc.rect=function(t,e,i,n){return new u(t,e,i,n)},e.exports=i.default}),{"../platform/CCClass":178,"./size":271,"./value-type":274,"./vec2":275}],271:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=s(t("./value-type")),r=s(t("../platform/CCClass"));function s(t){return t&&t.__esModule?t:{default:t}}function o(t,e){for(var i=0;ii?i:t},i.clamp01=function(t){return t<0?0:t>1?1:t},i.equals=function(t,e){return Math.abs(t-e)<=s*Math.max(1,Math.abs(t),Math.abs(e))},i.inverseLerp=function(t,e,i){return(i-t)/(e-t)},i.lerp=function(t,e,i){return t+(e-t)*i},i.nextPow2=function(t){return--t,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},i.pingPong=function(t,e){return t=h(t,2*e),e-Math.abs(t-e)},i.pseudoRandom=l,i.pseudoRandomRange=u,i.pseudoRandomRangeInt=function(t,e,i){return Math.floor(u(t,e,i))},i.random=void 0,i.randomRange=c,i.randomRangeInt=function(t,e){return Math.floor(c(t,e))},i.repeat=h,i.sign=function(t){return(t>0)-(t<0)},i.toDegree=function(t){return t*r},i.toRadian=function(t){return t*n};var n=Math.PI/180,r=180/Math.PI,s=1e-6;i.EPSILON=s,i.INT_BITS=32,i.INT_MAX=2147483647,i.INT_MIN=-1<<31;var o=Float64Array;i.FLOAT_ARRAY_TYPE=o,i.FLOAT_BYTES=8;var a=Math.random;function c(t,e){return Math.random()*(e-t)+t}function l(t){return(t=(9301*t+49297)%233280)/233280}function u(t,e,i){return l(t)*(i-e)+e}function h(t,e){return t-Math.floor(t/e)*e}i.random=a}),{}],274:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=(n=t("../platform/js"))&&n.__esModule?n:{default:n},s=(function(){function t(){}var e=t.prototype;return e.clone=function(){return cc.errorID("0100",r.default.getClassName(this)+".clone"),null},e.equals=function(){return cc.errorID("0100",r.default.getClassName(this)+".equals"),!1},e.lerp=function(){return cc.errorID("0100",r.default.getClassName(this)+".lerp"),this.clone()},e.set=function(){cc.errorID("0100",r.default.getClassName(this)+".set")},e.toString=function(){return""+{}},t})();i.default=s,r.default.setClassName("cc.ValueType",s),cc.ValueType=s,e.exports=i.default}),{"../platform/js":199}],275:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=a(t("./value-type")),r=a(t("../platform/CCClass")),s=a(t("../utils/misc")),o=t("./utils");function a(t){return t&&t.__esModule?t:{default:t}}function c(t,e){for(var i=0;i0&&(i=1/Math.sqrt(i),t.x=u*i,t.y=h*i),t},_.dot=function(t,e){return t.x*e.x+t.y*e.y},_.cross=function(t,e,i){return t.x=t.y=0,t.z=e.x*i.y-e.y*i.x,t},_.lerp=function(t,e,i,n){return u=e.x,h=e.y,t.x=u+n*(i.x-u),t.y=h+n*(i.y-h),t},_.random=function(t,e){e=e||1;var i=2*(0,o.random)()*Math.PI;return t.x=Math.cos(i)*e,t.y=Math.sin(i)*e,t},_.transformMat3=function(t,e,i){u=e.x,h=e.y;var n=i.m;return t.x=n[0]*u+n[3]*h+n[6],t.y=n[1]*u+n[4]*h+n[7],t},_.transformMat4=function(t,e,i){u=e.x,h=e.y;var n=i.m;return t.x=n[0]*u+n[4]*h+n[12],t.y=n[1]*u+n[5]*h+n[13],t},_.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y},_.equals=function(t,e,i){return void 0===i&&(i=o.EPSILON),Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(e.y))},_.angle=function(t,e){_.normalize(f,t),_.normalize(d,e);var i=_.dot(f,d);return i>1?0:i<-1?Math.PI:Math.acos(i)},_.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t},_.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t},a.clone=function(){return new _(this.x,this.y)},a.set=function(t){return this.x=t.x,this.y=t.y,this},a.equals=function(t){return t&&this.x===t.x&&this.y===t.y},a.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},a.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+")"},a.lerp=function(t,e,i){i=i||new _;var n=this.x,r=this.y;return i.x=n+(t.x-n)*e,i.y=r+(t.y-r)*e,i},a.clampf=function(t,e){return this.x=s.default.clampf(this.x,t.x,e.x),this.y=s.default.clampf(this.y,t.y,e.y),this},a.add=function(t,e){return(e=e||new _).x=this.x+t.x,e.y=this.y+t.y,e},a.addSelf=function(t){return this.x+=t.x,this.y+=t.y,this},a.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},a.multiplyScalar=function(t){return this.x*=t,this.y*=t,this},a.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},a.divide=function(t){return this.x/=t,this.y/=t,this},a.negate=function(){return this.x=-this.x,this.y=-this.y,this},a.dot=function(t){return this.x*t.x+this.y*t.y},a.cross=function(t){return this.x*t.y-this.y*t.x},a.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},a.lengthSqr=function(){return this.x*this.x+this.y*this.y},a.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},a.normalize=function(t){return(t=t||new _).x=this.x,t.y=this.y,t.normalizeSelf(),t},a.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=s.default.clampf(n,-1,1),Math.acos(n)},a.signAngle=function(t){var e=this.angle(t);return this.cross(t)<0?-e:e},a.rotate=function(t,e){return(e=e||new _).x=this.x,e.y=this.y,e.rotateSelf(t)},a.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},a.project=function(t){return t.multiplyScalar(this.dot(t)/t.dot(t))},a.transformMat4=function(t,e){return e=e||new _,_.transformMat4(e,this,t),e},a.maxAxis=function(){return Math.max(this.x,this.y)},n=_,r=[{key:"ONE",get:function(){return new _(1,1)}},{key:"ZERO",get:function(){return new _(0,0)}},{key:"UP",get:function(){return new _(0,1)}},{key:"RIGHT",get:function(){return new _(1,0)}}],null&&c(n.prototype,null),r&&c(n,r),Object.defineProperty(n,"prototype",{writable:!1}),_})(n.default);i.default=_,_.sub=_.subtract,_.mul=_.multiply,_.scale=_.multiplyScalar,_.mag=_.len,_.squaredMagnitude=_.lengthSqr,_.div=_.divide,_.ONE_R=_.ONE,_.ZERO_R=_.ZERO,_.UP_R=_.UP,_.RIGHT_R=_.RIGHT;var f=new _,d=new _;r.default.fastDefine("cc.Vec2",_,{x:0,y:0}),cc.v2=function(t,e){return new _(t,e)},cc.Vec2=_,e.exports=i.default}),{"../platform/CCClass":178,"../utils/misc":251,"./utils":273,"./value-type":274}],276:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=c(t("./value-type")),r=c(t("../platform/CCClass")),s=c(t("../utils/misc")),o=c(t("./vec2")),a=t("./utils");function c(t){return t&&t.__esModule?t:{default:t}}function l(t,e){for(var i=0;i0&&(i=1/Math.sqrt(i),t.x=h*i,t.y=_*i,t.z=f*i),t},d.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},d.cross=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.x,a=i.y,c=i.z;return t.x=r*c-s*a,t.y=s*o-n*c,t.z=n*a-r*o,t},d.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t},d.random=function(t,e){e=e||1;var i=2*(0,a.random)()*Math.PI,n=2*(0,a.random)()-1,r=Math.sqrt(1-n*n);return t.x=r*Math.cos(i)*e,t.y=r*Math.sin(i)*e,t.z=n*e,t},d.transformMat4=function(t,e,i){h=e.x,_=e.y,f=e.z;var n=i.m,r=n[3]*h+n[7]*_+n[11]*f+n[15];return r=r?1/r:1,t.x=(n[0]*h+n[4]*_+n[8]*f+n[12])*r,t.y=(n[1]*h+n[5]*_+n[9]*f+n[13])*r,t.z=(n[2]*h+n[6]*_+n[10]*f+n[14])*r,t},d.transformMat4Normal=function(t,e,i){h=e.x,_=e.y,f=e.z;var n=i.m,r=n[3]*h+n[7]*_+n[11]*f;return r=r?1/r:1,t.x=(n[0]*h+n[4]*_+n[8]*f)*r,t.y=(n[1]*h+n[5]*_+n[9]*f)*r,t.z=(n[2]*h+n[6]*_+n[10]*f)*r,t},d.transformMat3=function(t,e,i){h=e.x,_=e.y,f=e.z;var n=i.m;return t.x=h*n[0]+_*n[3]+f*n[6],t.y=h*n[1]+_*n[4]+f*n[7],t.z=h*n[2]+_*n[5]+f*n[8],t},d.transformAffine=function(t,e,i){h=e.x,_=e.y,f=e.z;var n=i.m;return t.x=n[0]*h+n[1]*_+n[2]*f+n[3],t.y=n[4]*h+n[5]*_+n[6]*f+n[7],t.x=n[8]*h+n[9]*_+n[10]*f+n[11],t},d.transformQuat=function(t,e,i){var n=i.w*e.x+i.y*e.z-i.z*e.y,r=i.w*e.y+i.z*e.x-i.x*e.z,s=i.w*e.z+i.x*e.y-i.y*e.x,o=-i.x*e.x-i.y*e.y-i.z*e.z;return t.x=n*i.w+o*-i.x+r*-i.z-s*-i.y,t.y=r*i.w+o*-i.y+s*-i.x-n*-i.z,t.z=s*i.w+o*-i.z+n*-i.y-r*-i.x,t},d.transformRTS=function(t,e,i,n,r){var s=e.x*r.x,o=e.y*r.y,a=e.z*r.z,c=i.w*s+i.y*a-i.z*o,l=i.w*o+i.z*s-i.x*a,u=i.w*a+i.x*o-i.y*s,h=-i.x*s-i.y*o-i.z*a;return t.x=c*i.w+h*-i.x+l*-i.z-u*-i.y+n.x,t.y=l*i.w+h*-i.y+u*-i.x-c*-i.z+n.y,t.z=u*i.w+h*-i.z+c*-i.y-l*-i.x+n.z,t},d.transformInverseRTS=function(t,e,i,n,r){var s=e.x-n.x,o=e.y-n.y,a=e.z-n.z,c=i.w*s-i.y*a+i.z*o,l=i.w*o-i.z*s+i.x*a,u=i.w*a-i.x*o+i.y*s,h=i.x*s+i.y*o+i.z*a;return t.x=(c*i.w+h*i.x+l*i.z-u*i.y)/r.x,t.y=(l*i.w+h*i.y+u*i.x-c*i.z)/r.y,t.z=(u*i.w+h*i.z+c*i.y-l*i.x)/r.z,t},d.rotateX=function(t,e,i,n){h=e.x-i.x,_=e.y-i.y,f=e.z-i.z;var r=Math.cos(n),s=Math.sin(n),o=h,a=_*r-f*s,c=_*s+f*r;return t.x=o+i.x,t.y=a+i.y,t.z=c+i.z,t},d.rotateY=function(t,e,i,n){h=e.x-i.x,_=e.y-i.y,f=e.z-i.z;var r=Math.cos(n),s=Math.sin(n),o=f*s+h*r,a=_,c=f*r-h*s;return t.x=o+i.x,t.y=a+i.y,t.z=c+i.z,t},d.rotateZ=function(t,e,i,n){h=e.x-i.x,_=e.y-i.y,f=e.z-i.z;var r=Math.cos(n),s=Math.sin(n),o=h*r-_*s,a=h*s+_*r,c=f;return t.x=o+i.x,t.y=a+i.y,t.z=c+i.z,t},d.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z},d.equals=function(t,e,i){void 0===i&&(i=a.EPSILON);var n=t.x,r=t.y,s=t.z,o=e.x,c=e.y,l=e.z;return Math.abs(n-o)<=i*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-c)<=i*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=i*Math.max(1,Math.abs(s),Math.abs(l))},d.angle=function(t,e){d.normalize(p,t),d.normalize(m,e);var i=d.dot(p,m);return i>1?0:i<-1?Math.PI:Math.acos(i)},d.projectOnPlane=function(t,e,i){return d.subtract(t,e,d.project(t,e,i))},d.project=function(t,e,i){var n=d.lengthSqr(i);return n<1e-6?d.set(t,0,0,0):d.multiplyScalar(t,i,d.dot(e,i)/n)},d.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t},d.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t},c.clone=function(){return new d(this.x,this.y,this.z)},c.set=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},c.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z},c.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},c.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+")"},c.lerp=function(t,e,i){return i=i||new d,d.lerp(i,this,t,e),i},c.clampf=function(t,e){return this.x=s.default.clampf(this.x,t.x,e.x),this.y=s.default.clampf(this.y,t.y,e.y),this.z=s.default.clampf(this.z,t.z,e.z),this},c.addSelf=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},c.add=function(t,e){return(e=e||new d).x=this.x+t.x,e.y=this.y+t.y,e.z=this.z+t.z,e},c.subtract=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},c.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},c.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},c.divide=function(t){return this.x/=t,this.y/=t,this.z/=t,this},c.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},c.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},c.cross=function(t,e){return e=e||new d,d.cross(e,this,t),e},c.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},c.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z},c.normalizeSelf=function(){return d.normalize(this,this),this},c.normalize=function(t){return t=t||new d,d.normalize(t,this),t},c.transformMat4=function(t,e){return e=e||new d,d.transformMat4(e,this,t),e},c.maxAxis=function(){return Math.max(this.x,this.y,this.z)},c.signAngle=function(t){cc.warnID(1408,"vec3.signAngle","v2.1","cc.v2(selfVector).signAngle(vector)");var e=new o.default(this.x,this.y),i=new o.default(t.x,t.y);return e.signAngle(i)},c.rotate=function(t,e){return cc.warnID(1408,"vec3.rotate","v2.1","cc.v2(selfVector).rotate(radians, out)"),o.default.prototype.rotate.call(this,t,e)},c.rotateSelf=function(t){return cc.warnID(1408,"vec3.rotateSelf","v2.1","cc.v2(selfVector).rotateSelf(radians)"),o.default.prototype.rotateSelf.call(this,t)},n=d,r=[{key:"ONE",get:function(){return new d(1,1,1)}},{key:"ZERO",get:function(){return new d}},{key:"UP",get:function(){return new d(0,1,0)}},{key:"RIGHT",get:function(){return new d(1,0,0)}},{key:"FORWARD",get:function(){return new d(0,0,1)}}],null&&l(n.prototype,null),r&&l(n,r),Object.defineProperty(n,"prototype",{writable:!1}),d})(n.default);i.default=d,d.sub=d.subtract,d.mul=d.multiply,d.scale=d.multiplyScalar,d.mag=d.len,d.squaredMagnitude=d.lengthSqr,d.div=d.divide,d.ONE_R=d.ONE,d.ZERO_R=d.ZERO,d.UP_R=d.UP,d.RIGHT_R=d.RIGHT,d.FRONT_R=d.FORWARD;var p=new d,m=new d;r.default.fastDefine("cc.Vec3",d,{x:0,y:0,z:0}),cc.v3=function(t,e,i){return new d(t,e,i)},cc.Vec3=d,e.exports=i.default}),{"../platform/CCClass":178,"../utils/misc":251,"./utils":273,"./value-type":274,"./vec2":275}],277:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0,i.v4=d;var n=o(t("../platform/CCClass")),r=o(t("./value-type")),s=t("./utils");function o(t){return t&&t.__esModule?t:{default:t}}function a(t,e){for(var i=0;i0&&(i=1/Math.sqrt(i),t.x=l*i,t.y=u*i,t.z=h*i,t.w=_*i),t},f.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},f.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t.w=e.w+n*(i.w-e.w),t},f.random=function(t,e){e=e||1;var i=2*(0,s.random)()*Math.PI,n=2*(0,s.random)()-1,r=Math.sqrt(1-n*n);return t.x=r*Math.cos(i)*e,t.y=r*Math.sin(i)*e,t.z=n*e,t.w=0,t},f.transformMat4=function(t,e,i){l=e.x,u=e.y,h=e.z,_=e.w;var n=i.m;return t.x=n[0]*l+n[4]*u+n[8]*h+n[12]*_,t.y=n[1]*l+n[5]*u+n[9]*h+n[13]*_,t.z=n[2]*l+n[6]*u+n[10]*h+n[14]*_,t.w=n[3]*l+n[7]*u+n[11]*h+n[15]*_,t},f.transformAffine=function(t,e,i){l=e.x,u=e.y,h=e.z,_=e.w;var n=i.m;return t.x=n[0]*l+n[1]*u+n[2]*h+n[3]*_,t.y=n[4]*l+n[5]*u+n[6]*h+n[7]*_,t.x=n[8]*l+n[9]*u+n[10]*h+n[11]*_,t.w=e.w,t},f.transformQuat=function(t,e,i){var n=e.x,r=e.y,s=e.z;l=i.x,u=i.y,h=i.z;var o=(_=i.w)*n+u*s-h*r,a=_*r+h*n-l*s,c=_*s+l*r-u*n,f=-l*n-u*r-h*s;return t.x=o*_+f*-l+a*-h-c*-u,t.y=a*_+f*-u+c*-l-o*-h,t.z=c*_+f*-h+o*-u-a*-l,t.w=e.w,t},f.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},f.equals=function(t,e,i){return void 0===i&&(i=s.EPSILON),Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(e.y))&&Math.abs(t.z-e.z)<=i*Math.max(1,Math.abs(t.z),Math.abs(e.z))&&Math.abs(t.w-e.w)<=i*Math.max(1,Math.abs(t.w),Math.abs(e.w))},f.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t[i+3]=e.w,t},f.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t.w=e[i+3],t},o.clone=function(){return new f(this.x,this.y,this.z,this.w)},o.set=function(t,e,i,n){return t&&"object"==typeof t?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},o.equals=function(t,e){return void 0===e&&(e=s.EPSILON),Math.abs(this.x-t.x)<=e*Math.max(1,Math.abs(this.x),Math.abs(t.x))&&Math.abs(this.y-t.y)<=e*Math.max(1,Math.abs(this.y),Math.abs(t.y))&&Math.abs(this.z-t.z)<=e*Math.max(1,Math.abs(this.z),Math.abs(t.z))&&Math.abs(this.w-t.w)<=e*Math.max(1,Math.abs(this.w),Math.abs(t.w))},o.equals4f=function(t,e,i,n,r){return void 0===r&&(r=s.EPSILON),Math.abs(this.x-t)<=r*Math.max(1,Math.abs(this.x),Math.abs(t))&&Math.abs(this.y-e)<=r*Math.max(1,Math.abs(this.y),Math.abs(e))&&Math.abs(this.z-i)<=r*Math.max(1,Math.abs(this.z),Math.abs(i))&&Math.abs(this.w-n)<=r*Math.max(1,Math.abs(this.w),Math.abs(n))},o.strictEquals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},o.strictEquals4f=function(t,e,i,n){return this.x===t&&this.y===e&&this.z===i&&this.w===n},o.lerp=function(t,e){return l=this.x,u=this.y,h=this.z,_=this.w,this.x=l+e*(t.x-l),this.y=u+e*(t.y-u),this.z=h+e*(t.z-h),this.w=_+e*(t.w-_),this},o.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+", "+this.w.toFixed(2)+")"},o.clampf=function(t,e){return this.x=(0,s.clamp)(this.x,t.x,e.x),this.y=(0,s.clamp)(this.y,t.y,e.y),this.z=(0,s.clamp)(this.z,t.z,e.z),this.w=(0,s.clamp)(this.w,t.w,e.w),this},o.addSelf=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},o.add=function(t,e){return(e=e||new f).x=this.x+t.x,e.y=this.y+t.y,e.z=this.z+t.z,e.w=this.w+t.w,e},o.subtract=function(t,e){return(e=e||new f).x=this.x-t.x,e.y=this.y-t.y,e.z=this.z-t.z,e.w=this.w-t.w,e},o.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},o.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this},o.divide=function(t){return this.x/=t,this.y/=t,this.z/=t,this.w/=t,this},o.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},o.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},o.cross=function(t,e){e=e||new f;var i=this.x,n=this.y,r=this.z,s=t.x,o=t.y,a=t.z;return e.x=n*a-r*o,e.y=r*s-i*a,e.z=i*o-n*s,e},o.len=function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},o.lengthSqr=function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},o.normalizeSelf=function(){return this.normalize(this),this},o.normalize=function(t){t=t||new f,l=this.x,u=this.y,h=this.z,_=this.w;var e=l*l+u*u+h*h+_*_;return e>0&&(e=1/Math.sqrt(e),t.x=l*e,t.y=u*e,t.z=h*e,t.w=_*e),t},o.transformMat4=function(t,e){e=e||new f,l=this.x,u=this.y,h=this.z,_=this.w;var i=t.m;return e.x=i[0]*l+i[4]*u+i[8]*h+i[12]*_,e.y=i[1]*l+i[5]*u+i[9]*h+i[13]*_,e.z=i[2]*l+i[6]*u+i[10]*h+i[14]*_,e.w=i[3]*l+i[7]*u+i[11]*h+i[15]*_,e},o.maxAxis=function(){return Math.max(this.x,this.y,this.z,this.w)},n=f,r=[{key:"ZERO",get:function(){return new f(0,0,0,0)}},{key:"ONE",get:function(){return new f(1,1,1,1)}},{key:"NEG_ONE",get:function(){return new f(-1,-1,-1,-1)}}],null&&a(n.prototype,null),r&&a(n,r),Object.defineProperty(n,"prototype",{writable:!1}),f})(r.default);function d(t,e,i,n){return new f(t,e,i,n)}i.default=f,f.sub=f.subtract,f.mul=f.multiply,f.div=f.divide,f.scale=f.multiplyScalar,f.mag=f.len,f.squaredMagnitude=f.lengthSqr,f.ZERO_R=f.ZERO,f.ONE_R=f.ONE,f.NEG_ONE_R=f.NEG_ONE,n.default.fastDefine("cc.Vec4",f,{x:0,y:0,z:0,w:0}),cc.v4=d,cc.Vec4=f}),{"../platform/CCClass":178,"./utils":273,"./value-type":274}],278:[(function(){"use strict";cc.js}),{}],279:[(function(t){"use strict";t("./core/CCGame"),t("./actions")}),{"./actions":7,"./core/CCGame":24}],280:[(function(t,e){"use strict";var i=t("../core/assets/CCAsset"),n=t("../core/assets/CCSpriteFrame"),r=cc.Class({name:"cc.ParticleAsset",extends:i,properties:{spriteFrame:{default:null,type:n}}});cc.ParticleAsset=e.exports=r}),{"../core/assets/CCAsset":58,"../core/assets/CCSpriteFrame":70}],281:[(function(t,e){"use strict";var i,n,r,s,o,a,c,l,u,h,_,f,d,p,m,v,y,g,x,A,C,S,b,T,w,E,B,M,R,P,I,D,V,L,O,F,N,G,k,z,U,H;(function(t){t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL"})(i||(i={})),(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.BUFFER=1]="BUFFER",t[t.TEXTURE=2]="TEXTURE",t[t.TEXTURE_VIEW=3]="TEXTURE_VIEW",t[t.RENDER_PASS=4]="RENDER_PASS",t[t.FRAMEBUFFER=5]="FRAMEBUFFER",t[t.SAMPLER=6]="SAMPLER",t[t.SHADER=7]="SHADER",t[t.PIPELINE_LAYOUT=8]="PIPELINE_LAYOUT",t[t.PIPELINE_STATE=9]="PIPELINE_STATE",t[t.BINDING_LAYOUT=10]="BINDING_LAYOUT",t[t.INPUT_ASSEMBLER=11]="INPUT_ASSEMBLER",t[t.COMMAND_ALLOCATOR=12]="COMMAND_ALLOCATOR",t[t.COMMAND_BUFFER=13]="COMMAND_BUFFER",t[t.QUEUE=14]="QUEUE",t[t.WINDOW=15]="WINDOW"})(n||(n={})),(function(t){t[t.UNREADY=0]="UNREADY",t[t.FAILED=1]="FAILED",t[t.SUCCESS=2]="SUCCESS"})(r||(r={})),(function(){function t(t){this._gfxType=n.UNKNOWN,this._status=r.UNREADY,this._gfxType=t}Object.defineProperty(t.prototype,"gfxType",{get:function(){return this._gfxType},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this._status},enumerable:!0,configurable:!0})})(),(function(t){t.ATTR_POSITION="a_position",t.ATTR_NORMAL="a_normal",t.ATTR_TANGENT="a_tangent",t.ATTR_BITANGENT="a_bitangent",t.ATTR_WEIGHTS="a_weights",t.ATTR_JOINTS="a_joints",t.ATTR_COLOR="a_color",t.ATTR_COLOR1="a_color1",t.ATTR_COLOR2="a_color2",t.ATTR_TEX_COORD="a_texCoord",t.ATTR_TEX_COORD1="a_texCoord1",t.ATTR_TEX_COORD2="a_texCoord2",t.ATTR_TEX_COORD3="a_texCoord3",t.ATTR_TEX_COORD4="a_texCoord4",t.ATTR_TEX_COORD5="a_texCoord5",t.ATTR_TEX_COORD6="a_texCoord6",t.ATTR_TEX_COORD7="a_texCoord7",t.ATTR_TEX_COORD8="a_texCoord8"})(s||(s={})),(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.BOOL=1]="BOOL",t[t.BOOL2=2]="BOOL2",t[t.BOOL3=3]="BOOL3",t[t.BOOL4=4]="BOOL4",t[t.INT=5]="INT",t[t.INT2=6]="INT2",t[t.INT3=7]="INT3",t[t.INT4=8]="INT4",t[t.UINT=9]="UINT",t[t.UINT2=10]="UINT2",t[t.UINT3=11]="UINT3",t[t.UINT4=12]="UINT4",t[t.FLOAT=13]="FLOAT",t[t.FLOAT2=14]="FLOAT2",t[t.FLOAT3=15]="FLOAT3",t[t.FLOAT4=16]="FLOAT4",t[t.COLOR4=17]="COLOR4",t[t.MAT2=18]="MAT2",t[t.MAT2X3=19]="MAT2X3",t[t.MAT2X4=20]="MAT2X4",t[t.MAT3X2=21]="MAT3X2",t[t.MAT3=22]="MAT3",t[t.MAT3X4=23]="MAT3X4",t[t.MAT4X2=24]="MAT4X2",t[t.MAT4X3=25]="MAT4X3",t[t.MAT4=26]="MAT4",t[t.SAMPLER1D=27]="SAMPLER1D",t[t.SAMPLER1D_ARRAY=28]="SAMPLER1D_ARRAY",t[t.SAMPLER2D=29]="SAMPLER2D",t[t.SAMPLER2D_ARRAY=30]="SAMPLER2D_ARRAY",t[t.SAMPLER3D=31]="SAMPLER3D",t[t.SAMPLER_CUBE=32]="SAMPLER_CUBE",t[t.COUNT=33]="COUNT"})(o||(o={})),(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.A8=1]="A8",t[t.L8=2]="L8",t[t.LA8=3]="LA8",t[t.R8=4]="R8",t[t.R8SN=5]="R8SN",t[t.R8UI=6]="R8UI",t[t.R8I=7]="R8I",t[t.R16F=8]="R16F",t[t.R16UI=9]="R16UI",t[t.R16I=10]="R16I",t[t.R32F=11]="R32F",t[t.R32UI=12]="R32UI",t[t.R32I=13]="R32I",t[t.RG8=14]="RG8",t[t.RG8SN=15]="RG8SN",t[t.RG8UI=16]="RG8UI",t[t.RG8I=17]="RG8I",t[t.RG16F=18]="RG16F",t[t.RG16UI=19]="RG16UI",t[t.RG16I=20]="RG16I",t[t.RG32F=21]="RG32F",t[t.RG32UI=22]="RG32UI",t[t.RG32I=23]="RG32I",t[t.RGB8=24]="RGB8",t[t.SRGB8=25]="SRGB8",t[t.RGB8SN=26]="RGB8SN",t[t.RGB8UI=27]="RGB8UI",t[t.RGB8I=28]="RGB8I",t[t.RGB16F=29]="RGB16F",t[t.RGB16UI=30]="RGB16UI",t[t.RGB16I=31]="RGB16I",t[t.RGB32F=32]="RGB32F",t[t.RGB32UI=33]="RGB32UI",t[t.RGB32I=34]="RGB32I",t[t.RGBA8=35]="RGBA8",t[t.SRGB8_A8=36]="SRGB8_A8",t[t.RGBA8SN=37]="RGBA8SN",t[t.RGBA8UI=38]="RGBA8UI",t[t.RGBA8I=39]="RGBA8I",t[t.RGBA16F=40]="RGBA16F",t[t.RGBA16UI=41]="RGBA16UI",t[t.RGBA16I=42]="RGBA16I",t[t.RGBA32F=43]="RGBA32F",t[t.RGBA32UI=44]="RGBA32UI",t[t.RGBA32I=45]="RGBA32I",t[t.R5G6B5=46]="R5G6B5",t[t.R11G11B10F=47]="R11G11B10F",t[t.RGB5A1=48]="RGB5A1",t[t.RGBA4=49]="RGBA4",t[t.RGB10A2=50]="RGB10A2",t[t.RGB10A2UI=51]="RGB10A2UI",t[t.RGB9E5=52]="RGB9E5",t[t.D16=53]="D16",t[t.D16S8=54]="D16S8",t[t.D24=55]="D24",t[t.D24S8=56]="D24S8",t[t.D32F=57]="D32F",t[t.D32F_S8=58]="D32F_S8",t[t.BC1=59]="BC1",t[t.BC1_ALPHA=60]="BC1_ALPHA",t[t.BC1_SRGB=61]="BC1_SRGB",t[t.BC1_SRGB_ALPHA=62]="BC1_SRGB_ALPHA",t[t.BC2=63]="BC2",t[t.BC2_SRGB=64]="BC2_SRGB",t[t.BC3=65]="BC3",t[t.BC3_SRGB=66]="BC3_SRGB",t[t.BC4=67]="BC4",t[t.BC4_SNORM=68]="BC4_SNORM",t[t.BC5=69]="BC5",t[t.BC5_SNORM=70]="BC5_SNORM",t[t.BC6H_UF16=71]="BC6H_UF16",t[t.BC6H_SF16=72]="BC6H_SF16",t[t.BC7=73]="BC7",t[t.BC7_SRGB=74]="BC7_SRGB",t[t.ETC_RGB8=75]="ETC_RGB8",t[t.ETC2_RGB8=76]="ETC2_RGB8",t[t.ETC2_SRGB8=77]="ETC2_SRGB8",t[t.ETC2_RGB8_A1=78]="ETC2_RGB8_A1",t[t.ETC2_SRGB8_A1=79]="ETC2_SRGB8_A1",t[t.ETC2_RGBA8=80]="ETC2_RGBA8",t[t.ETC2_SRGB8_A8=81]="ETC2_SRGB8_A8",t[t.EAC_R11=82]="EAC_R11",t[t.EAC_R11SN=83]="EAC_R11SN",t[t.EAC_RG11=84]="EAC_RG11",t[t.EAC_RG11SN=85]="EAC_RG11SN",t[t.PVRTC_RGB2=86]="PVRTC_RGB2",t[t.PVRTC_RGBA2=87]="PVRTC_RGBA2",t[t.PVRTC_RGB4=88]="PVRTC_RGB4",t[t.PVRTC_RGBA4=89]="PVRTC_RGBA4",t[t.PVRTC2_2BPP=90]="PVRTC2_2BPP",t[t.PVRTC2_4BPP=91]="PVRTC2_4BPP",t[t.ASTC_RGBA_4x4=92]="ASTC_RGBA_4x4",t[t.ASTC_RGBA_5x4=92]="ASTC_RGBA_5x4",t[t.ASTC_RGBA_5x5=92]="ASTC_RGBA_5x5",t[t.ASTC_RGBA_6x5=92]="ASTC_RGBA_6x5",t[t.ASTC_RGBA_6x6=92]="ASTC_RGBA_6x6",t[t.ASTC_RGBA_8x5=92]="ASTC_RGBA_8x5",t[t.ASTC_RGBA_8x6=92]="ASTC_RGBA_8x6",t[t.ASTC_RGBA_8x8=92]="ASTC_RGBA_8x8",t[t.ASTC_RGBA_10x5=92]="ASTC_RGBA_10x5",t[t.ASTC_RGBA_10x6=92]="ASTC_RGBA_10x6",t[t.ASTC_RGBA_10x8=92]="ASTC_RGBA_10x8",t[t.ASTC_RGBA_10x10=92]="ASTC_RGBA_10x10",t[t.ASTC_RGBA_12x10=92]="ASTC_RGBA_12x10",t[t.ASTC_RGBA_12x12=92]="ASTC_RGBA_12x12",t[t.ASTC_SRGBA_4x4=92]="ASTC_SRGBA_4x4",t[t.ASTC_SRGBA_5x4=92]="ASTC_SRGBA_5x4",t[t.ASTC_SRGBA_5x5=92]="ASTC_SRGBA_5x5",t[t.ASTC_SRGBA_6x5=92]="ASTC_SRGBA_6x5",t[t.ASTC_SRGBA_6x6=92]="ASTC_SRGBA_6x6",t[t.ASTC_SRGBA_8x5=92]="ASTC_SRGBA_8x5",t[t.ASTC_SRGBA_8x6=92]="ASTC_SRGBA_8x6",t[t.ASTC_SRGBA_8x8=92]="ASTC_SRGBA_8x8",t[t.ASTC_SRGBA_10x5=92]="ASTC_SRGBA_10x5",t[t.ASTC_SRGBA_10x6=92]="ASTC_SRGBA_10x6",t[t.ASTC_SRGBA_10x8=92]="ASTC_SRGBA_10x8",t[t.ASTC_SRGBA_10x10=92]="ASTC_SRGBA_10x10",t[t.ASTC_SRGBA_12x10=92]="ASTC_SRGBA_12x10",t[t.ASTC_SRGBA_12x12=92]="ASTC_SRGBA_12x12"})(a||(a={})),(function(t){t[t.NONE=0]="NONE",t[t.TRANSFER_SRC=1]="TRANSFER_SRC",t[t.TRANSFER_DST=2]="TRANSFER_DST",t[t.INDEX=4]="INDEX",t[t.VERTEX=8]="VERTEX",t[t.UNIFORM=16]="UNIFORM",t[t.STORAGE=32]="STORAGE",t[t.INDIRECT=64]="INDIRECT"})(c||(c={})),(function(t){t[t.NONE=0]="NONE",t[t.DEVICE=1]="DEVICE",t[t.HOST=2]="HOST"})(l||(l={})),(function(t){t[t.NONE=0]="NONE",t[t.READ=1]="READ",t[t.WRITE=2]="WRITE"})(u||(u={})),(function(t){t[t.POINT_LIST=0]="POINT_LIST",t[t.LINE_LIST=1]="LINE_LIST",t[t.LINE_STRIP=2]="LINE_STRIP",t[t.LINE_LOOP=3]="LINE_LOOP",t[t.LINE_LIST_ADJACENCY=4]="LINE_LIST_ADJACENCY",t[t.LINE_STRIP_ADJACENCY=5]="LINE_STRIP_ADJACENCY",t[t.ISO_LINE_LIST=6]="ISO_LINE_LIST",t[t.TRIANGLE_LIST=7]="TRIANGLE_LIST",t[t.TRIANGLE_STRIP=8]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=9]="TRIANGLE_FAN",t[t.TRIANGLE_LIST_ADJACENCY=10]="TRIANGLE_LIST_ADJACENCY",t[t.TRIANGLE_STRIP_ADJACENCY=11]="TRIANGLE_STRIP_ADJACENCY",t[t.TRIANGLE_PATCH_ADJACENCY=12]="TRIANGLE_PATCH_ADJACENCY",t[t.QUAD_PATCH_LIST=13]="QUAD_PATCH_LIST"})(h||(h={})),(function(t){t[t.FILL=0]="FILL",t[t.POINT=1]="POINT",t[t.LINE=2]="LINE"})(_||(_={})),(function(t){t[t.GOURAND=0]="GOURAND",t[t.FLAT=1]="FLAT"})(f||(f={})),(function(t){t[t.NONE=0]="NONE",t[t.FRONT=1]="FRONT",t[t.BACK=2]="BACK"})(d||(d={})),(function(t){t[t.NEVER=0]="NEVER",t[t.LESS=1]="LESS",t[t.EQUAL=2]="EQUAL",t[t.LESS_EQUAL=3]="LESS_EQUAL",t[t.GREATER=4]="GREATER",t[t.NOT_EQUAL=5]="NOT_EQUAL",t[t.GREATER_EQUAL=6]="GREATER_EQUAL",t[t.ALWAYS=7]="ALWAYS"})(p||(p={})),(function(t){t[t.ZERO=0]="ZERO",t[t.KEEP=1]="KEEP",t[t.REPLACE=2]="REPLACE",t[t.INCR=3]="INCR",t[t.DECR=4]="DECR",t[t.INVERT=5]="INVERT",t[t.INCR_WRAP=6]="INCR_WRAP",t[t.DECR_WRAP=7]="DECR_WRAP"})(m||(m={})),(function(t){t[t.ADD=0]="ADD",t[t.SUB=1]="SUB",t[t.REV_SUB=2]="REV_SUB",t[t.MIN=3]="MIN",t[t.MAX=4]="MAX"})(v||(v={})),(function(t){t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=2]="SRC_ALPHA",t[t.DST_ALPHA=3]="DST_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=4]="ONE_MINUS_SRC_ALPHA",t[t.ONE_MINUS_DST_ALPHA=5]="ONE_MINUS_DST_ALPHA",t[t.SRC_COLOR=6]="SRC_COLOR",t[t.DST_COLOR=7]="DST_COLOR",t[t.ONE_MINUS_SRC_COLOR=8]="ONE_MINUS_SRC_COLOR",t[t.ONE_MINUS_DST_COLOR=9]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=10]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=11]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=12]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=13]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=14]="ONE_MINUS_CONSTANT_ALPHA"})(y||(y={})),(function(t){t[t.NONE=0]="NONE",t[t.R=1]="R",t[t.G=2]="G",t[t.B=4]="B",t[t.A=8]="A",t[t.ALL=15]="ALL"})(g||(g={})),(function(t){t[t.NONE=0]="NONE",t[t.POINT=1]="POINT",t[t.LINEAR=2]="LINEAR",t[t.ANISOTROPIC=3]="ANISOTROPIC"})(x||(x={})),(function(t){t[t.WRAP=0]="WRAP",t[t.MIRROR=1]="MIRROR",t[t.CLAMP=2]="CLAMP",t[t.BORDER=3]="BORDER"})(A||(A={})),(function(t){t[t.TEX1D=0]="TEX1D",t[t.TEX2D=1]="TEX2D",t[t.TEX3D=2]="TEX3D"})(C||(C={})),(function(t){t[t.NONE=0]="NONE",t[t.TRANSFER_SRC=1]="TRANSFER_SRC",t[t.TRANSFER_DST=2]="TRANSFER_DST",t[t.SAMPLED=4]="SAMPLED",t[t.STORAGE=8]="STORAGE",t[t.COLOR_ATTACHMENT=16]="COLOR_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=32]="DEPTH_STENCIL_ATTACHMENT",t[t.TRANSIENT_ATTACHMENT=64]="TRANSIENT_ATTACHMENT",t[t.INPUT_ATTACHMENT=128]="INPUT_ATTACHMENT"})(S||(S={})),(function(t){t[t.X1=0]="X1",t[t.X2=1]="X2",t[t.X4=2]="X4",t[t.X8=3]="X8",t[t.X16=4]="X16",t[t.X32=5]="X32",t[t.X64=6]="X64"})(b||(b={})),(function(t){t[t.NONE=0]="NONE",t[t.GEN_MIPMAP=1]="GEN_MIPMAP",t[t.CUBEMAP=2]="CUBEMAP",t[t.BAKUP_BUFFER=4]="BAKUP_BUFFER"})(T||(T={})),(function(t){t[t.TV1D=0]="TV1D",t[t.TV2D=1]="TV2D",t[t.TV3D=2]="TV3D",t[t.CUBE=3]="CUBE",t[t.TV1D_ARRAY=4]="TV1D_ARRAY",t[t.TV2D_ARRAY=5]="TV2D_ARRAY"})(w||(w={})),(function(t){t[t.VERTEX=0]="VERTEX",t[t.HULL=1]="HULL",t[t.DOMAIN=2]="DOMAIN",t[t.GEOMETRY=3]="GEOMETRY",t[t.FRAGMENT=4]="FRAGMENT",t[t.COMPUTE=5]="COMPUTE",t[t.COUNT=6]="COUNT"})(E||(E={})),(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.UNIFORM_BUFFER=1]="UNIFORM_BUFFER",t[t.SAMPLER=2]="SAMPLER",t[t.STORAGE_BUFFER=3]="STORAGE_BUFFER"})(B||(B={})),(function(t){t[t.PRIMARY=0]="PRIMARY",t[t.SECONDARY=1]="SECONDARY"})(M||(M={})),(function(t){t[t.LOAD=0]="LOAD",t[t.CLEAR=1]="CLEAR",t[t.DISCARD=2]="DISCARD"})(R||(R={})),(function(t){t[t.STORE=0]="STORE",t[t.DISCARD=1]="DISCARD"})(P||(P={})),(function(t){t[t.UNDEFINED=0]="UNDEFINED",t[t.GENERAL=1]="GENERAL",t[t.COLOR_ATTACHMENT_OPTIMAL=2]="COLOR_ATTACHMENT_OPTIMAL",t[t.DEPTH_STENCIL_ATTACHMENT_OPTIMAL=3]="DEPTH_STENCIL_ATTACHMENT_OPTIMAL",t[t.DEPTH_STENCIL_READONLY_OPTIMAL=4]="DEPTH_STENCIL_READONLY_OPTIMAL",t[t.SHADER_READONLY_OPTIMAL=5]="SHADER_READONLY_OPTIMAL",t[t.TRANSFER_SRC_OPTIMAL=6]="TRANSFER_SRC_OPTIMAL",t[t.TRANSFER_DST_OPTIMAL=7]="TRANSFER_DST_OPTIMAL",t[t.PREINITIALIZED=8]="PREINITIALIZED",t[t.PRESENT_SRC=9]="PRESENT_SRC"})(I||(I={})),(function(t){t[t.GRAPHICS=0]="GRAPHICS",t[t.COMPUTE=1]="COMPUTE",t[t.RAY_TRACING=2]="RAY_TRACING"})(D||(D={})),(function(t){t[t.VIEWPORT=0]="VIEWPORT",t[t.SCISSOR=1]="SCISSOR",t[t.LINE_WIDTH=2]="LINE_WIDTH",t[t.DEPTH_BIAS=3]="DEPTH_BIAS",t[t.BLEND_CONSTANTS=4]="BLEND_CONSTANTS",t[t.DEPTH_BOUNDS=5]="DEPTH_BOUNDS",t[t.STENCIL_WRITE_MASK=6]="STENCIL_WRITE_MASK",t[t.STENCIL_COMPARE_MASK=7]="STENCIL_COMPARE_MASK"})(V||(V={})),(function(t){t[t.FRONT=0]="FRONT",t[t.BACK=1]="BACK",t[t.ALL=2]="ALL"})(L||(L={})),(function(t){t[t.GRAPHICS=0]="GRAPHICS",t[t.COMPUTE=1]="COMPUTE",t[t.TRANSFER=2]="TRANSFER"})(O||(O={})),(function(t){t[t.NONE=0]="NONE",t[t.COLOR=1]="COLOR",t[t.DEPTH=2]="DEPTH",t[t.STENCIL=4]="STENCIL",t[t.DEPTH_STENCIL=6]="DEPTH_STENCIL",t[t.ALL=7]="ALL"})(F||(F={})),(function(t){t[t.DEFAULT=100]="DEFAULT"})(N||(N={})),(function(t){t[t.MIN=0]="MIN",t[t.MAX=255]="MAX",t[t.DEFAULT=128]="DEFAULT"})(G||(G={})),(function(t){t[t.UBO_GLOBAL=23]="UBO_GLOBAL",t[t.UBO_SHADOW=22]="UBO_SHADOW",t[t.UBO_LOCAL=21]="UBO_LOCAL",t[t.UBO_FORWARD_LIGHTS=20]="UBO_FORWARD_LIGHTS",t[t.UBO_SKINNING=19]="UBO_SKINNING",t[t.UBO_SKINNING_TEXTURE=18]="UBO_SKINNING_TEXTURE",t[t.UBO_UI=17]="UBO_UI",t[t.SAMPLER_JOINTS=25]="SAMPLER_JOINTS",t[t.SAMPLER_ENVIRONMENT=26]="SAMPLER_ENVIRONMENT",t[t.CUSTUM_UBO_BINDING_END_POINT=17]="CUSTUM_UBO_BINDING_END_POINT",t[t.CUSTOM_SAMPLER_BINDING_START_POINT=30]="CUSTOM_SAMPLER_BINDING_START_POINT"})(k||(k={})),(function(t){t[t.minFilter=0]="minFilter",t[t.magFilter=1]="magFilter",t[t.mipFilter=2]="mipFilter",t[t.addressU=3]="addressU",t[t.addressV=4]="addressV",t[t.addressW=5]="addressW",t[t.maxAnisotropy=6]="maxAnisotropy",t[t.cmpFunc=7]="cmpFunc",t[t.minLOD=8]="minLOD",t[t.maxLOD=9]="maxLOD",t[t.mipLODBias=10]="mipLODBias",t[t.borderColor=11]="borderColor",t[t.total=15]="total"})(H||(H={}));var W={};W[W.bool=o.BOOL]="bool",W[W.int=o.INT]="int",W[W.ivec2=o.INT2]="ivec2invTypeParams",W[W.ivec3=o.INT3]="ivec3",W[W.ivec4=o.INT4]="ivec4",W[W.float=o.FLOAT]="float",W[W.vec2=o.FLOAT2]="vec2",W[W.vec3=o.FLOAT3]="vec3",W[W.vec4=o.FLOAT4]="vec4",W[W.mat2=o.MAT2]="mat2",W[W.mat3=o.MAT3]="mat3",W[W.mat4=o.MAT4]="mat4",W[W.sampler2D=o.SAMPLER2D]="sampler2D",W[W.samplerCube=o.SAMPLER_CUBE]="samplerCube";var j=((z={})[o.BOOL]=4,z[o.INT]=4,z[o.INT2]=8,z[o.INT3]=12,z[o.INT4]=16,z[o.FLOAT]=4,z[o.FLOAT2]=8,z[o.FLOAT3]=12,z[o.FLOAT4]=16,z[o.MAT2]=16,z[o.MAT3]=36,z[o.MAT4]=64,z[o.SAMPLER2D]=4,z[o.SAMPLER_CUBE]=4,z),X=((U={})[o.BOOL]=a.R32I,U[o.INT]=a.R32I,U[o.INT2]=a.RG32I,U[o.INT3]=a.RGB32I,U[o.INT4]=a.RGBA32I,U[o.FLOAT]=a.R32F,U[o.FLOAT2]=a.RG32F,U[o.FLOAT3]=a.RGB32F,U[o.FLOAT4]=a.RGBA32F,U),q={BACK:1029,FRONT:1028,NONE:0,ADD:32774,SUB:32778,REV_SUB:32779,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,SRC_ALPHA_SATURATE:776,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,INCR_WRAP:34055,DECR:7683,DECR_WRAP:34056,INVERT:5386};Object.assign(q,N);var Y={murmurhash2_32_gc:function(t,e){for(var i,n=t.length,r=e^n,s=0;n>=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},SamplerInfoIndex:H,effectStructure:{$techniques:[{$passes:[{depthStencilState:{},rasterizerState:{},blendState:{targets:[{}]},properties:{any:{sampler:{},inspector:{}}}}]}]},typeMap:W,sizeMap:j,formatMap:X,passParams:q,RenderQueue:{OPAQUE:0,TRANSPARENT:1,OVERLAY:2},RenderPriority:G,GFXGetTypeSize:function(t){switch(t){case o.BOOL:case o.INT:case o.UINT:case o.FLOAT:return 4;case o.BOOL2:case o.INT2:case o.UINT2:case o.FLOAT2:return 8;case o.BOOL3:case o.INT3:case o.UINT3:case o.FLOAT3:return 12;case o.BOOL4:case o.INT4:case o.UINT4:case o.FLOAT4:case o.MAT2:return 16;case o.MAT2X3:return 24;case o.MAT2X4:return 32;case o.MAT3X2:return 24;case o.MAT3:return 36;case o.MAT3X4:return 48;case o.MAT4X2:case o.MAT4X2:return 32;case o.MAT4:return 64;case o.SAMPLER1D:case o.SAMPLER1D_ARRAY:case o.SAMPLER2D:case o.SAMPLER2D_ARRAY:case o.SAMPLER3D:case o.SAMPLER_CUBE:return 4;default:return 0}},UniformBinding:k};e.exports=Y}),{}],282:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=t("../memop"),r=l(t("../enums")),s=t("../../core/value-types"),o=l(t("./program-lib")),a=l(t("./view")),c=l(t("../gfx"));function l(t){return t&&t.__esModule?t:{default:t}}var u=new s.Mat4,h=new n.RecyclePool(function(){return{stage:null,items:null}},8),_=new n.RecyclePool(function(){return new Float32Array(2)},8),f=new n.RecyclePool(function(){return new Float32Array(3)},8),d=new n.RecyclePool(function(){return new Float32Array(4)},8),p=new n.RecyclePool(function(){return new Float32Array(9)},8),m=new n.RecyclePool(function(){return new Float32Array(16)},8),v=new n.RecyclePool(function(){return new Float32Array(64)},8),y=new n.RecyclePool(function(){return new Int32Array(2)},8),g=new n.RecyclePool(function(){return new Int32Array(3)},8),x=new n.RecyclePool(function(){return new Int32Array(4)},8),A=new n.RecyclePool(function(){return new Int32Array(64)},8),C=(function(){function t(t,e){var i;this._device=t,this._programLib=new o.default(t),this._opts=e,this._type2defaultValue=((i={})[r.default.PARAM_INT]=0,i[r.default.PARAM_INT2]=new s.Vec2(0,0),i[r.default.PARAM_INT3]=new s.Vec3(0,0,0),i[r.default.PARAM_INT4]=new s.Vec4(0,0,0,0),i[r.default.PARAM_FLOAT]=0,i[r.default.PARAM_FLOAT2]=new s.Vec2(0,0),i[r.default.PARAM_FLOAT3]=new s.Vec3(0,0,0),i[r.default.PARAM_FLOAT4]=new s.Vec4(0,0,0,0),i[r.default.PARAM_COLOR4]=new s.Color(0,0,0,1),i[r.default.PARAM_MAT3]=new s.Mat3,i[r.default.PARAM_MAT4]=new s.Mat4,i[r.default.PARAM_TEXTURE_2D]=e.defaultTexture,i[r.default.PARAM_TEXTURE_CUBE]=e.defaultTextureCube,i),this._stage2fn={},this._usedTextureUnits=0,this._viewPools=new n.RecyclePool(function(){return new a.default},8),this._drawItemsPools=new n.RecyclePool(function(){return{model:null,node:null,ia:null,effect:null,defines:null,uniforms:null}},100),this._stageItemsPools=new n.RecyclePool(function(){return new n.RecyclePool(function(){return{model:null,node:null,ia:null,effect:null,defines:null,passes:[],sortKey:-1,uniforms:null}},100)},16),this._definesChanged=!1}var e=t.prototype;return e._resetTextuerUnit=function(){this._usedTextureUnits=0},e._allocTextureUnit=function(){var t=this._device,e=this._usedTextureUnits;return e>=t._caps.maxTextureUnits&&console.warn("Trying to use "+e+" texture units while this GPU supports only "+t._caps.maxTextureUnits),this._usedTextureUnits+=1,e},e._registerStage=function(t,e){this._stage2fn[t]=e},e.clear=function(){this._programLib.clear(),this.reset()},e.reset=function(){this._viewPools.reset(),this._stageItemsPools.reset(),this._definesChanged=!1},e._requestView=function(){return this._viewPools.add()},e._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&r.default.CLEAR_COLOR&&(n.color=s.Vec4.toArray([],t._color)),t._clearFlags&r.default.CLEAR_DEPTH&&(n.depth=t._depth),t._clearFlags&r.default.CLEAR_STENCIL&&(n.stencil=t._stencil),i.clear(n),this._drawItemsPools.reset();for(var o=0;ot.count)return void console.error("Failed to set property ["+t.name+"] : The length of texture array ["+i.length+"] is bigger than ["+t.count+"].");for(var n=A.add(),s=0;s0&&n&&n.precision>0}e||cc.warnID(9102),this._highpSupported=e},t})();i.default=u,e.exports=i.default}),{"../gfx":293}],286:[(function(t,e,i){"use strict";function n(t,e){for(var i=0;i>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)))}function d(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=o.enums.DS_FUNC_ALWAYS,t.enable(t.DEPTH_TEST),t.depthFunc(i.depthFunc))}function p(t,e,i){if(i.stencilTest!==o.enums.STENCIL_INHERIT)return i.stencilTest!==e.stencilTest?i.stencilTest===o.enums.STENCIL_DISABLE?void t.disable(t.STENCIL_TEST):(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(i.stencilTest!==o.enums.STENCIL_DISABLE&&(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))))}function m(t,e,i){e.cullMode!==i.cullMode&&(i.cullMode!==o.enums.CULL_NONE?(t.enable(t.CULL_FACE),t.cullFace(i.cullMode)):t.disable(t.CULL_FACE))}function v(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>>0},n.setBlendFunc=function(t,e){this._next.blendSep=!1,this._next.blendSrc=t,this._next.blendDst=e},n.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},n.setBlendEq=function(t){this._next.blendSep=!1,this._next.blendEq=t},n.setBlendEqSep=function(t,e){this._next.blendSep=!0,this._next.blendEq=t,this._next.blendAlphaEq=e},n.setCullMode=function(t){this._next.cullMode=t},n.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;rthis._bytes){if(t)return void console.error("Failed to update data, bytes exceed.");this._needExpandDataStore=!0,this._bytes=t+e.byteLength,this._numIndices=this._bytes/this._bytesPerIndex}var i=this._device._gl,n=this._usage;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._glID),this._needExpandDataStore?(i.bufferData(i.ELEMENT_ARRAY_BUFFER,e,n),this._needExpandDataStore=!1):i.bufferSubData(i.ELEMENT_ARRAY_BUFFER,t,e),this._device._restoreIndexBuffer()}}else console.error("The buffer is destroyed")},n.setUsage=function(t){this._usage=t},e=t,(i=[{key:"count",get:function(){return this._numIndices}}])&&s(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t})();a.BYTES_PER_INDEX=o;var c=a;i.default=c,e.exports=i.default}),{"./enums":290}],293:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=t("./enums");n={VertexFormat:t("./vertex-format"),IndexBuffer:t("./index-buffer"),VertexBuffer:t("./vertex-buffer"),Program:t("./program"),Texture:t("./texture"),Texture2D:t("./texture-2d"),TextureCube:t("./texture-cube"),RenderBuffer:t("./render-buffer"),FrameBuffer:t("./frame-buffer"),Device:t("./device"),attrTypeBytes:r.attrTypeBytes,glFilter:r.glFilter,glTextureFmt:r.glTextureFmt},Object.assign(n,r.enums);var s=n;i.default=s,cc.gfx=n,e.exports=i.default}),{"./device":289,"./enums":290,"./frame-buffer":291,"./index-buffer":292,"./program":295,"./render-buffer":296,"./texture":300,"./texture-2d":298,"./texture-cube":299,"./vertex-buffer":301,"./vertex-format":302}],294:[(function(t,e,i){"use strict";i.__esModule=!0,i.isPow2=function(t){return!(t&t-1||!t)}}),{}],295:[(function(t,e,i){"use strict";function n(t,e){for(var i=0;i0&&t.push({type:e,fileID:-1,line:0,message:i})}}))}var o=(function(){function t(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=r++}var e,i,o=t.prototype;return o.link=function(){if(!this._linked){var t=this._device._gl,e=a(t,t.VERTEX_SHADER,this._vertSource),i=a(t,t.FRAGMENT_SHADER,this._fragSource),n=t.createProgram();t.attachShader(n,e),t.attachShader(n,i),t.linkProgram(n);var r=!1,o=this._errors;if(t.getShaderParameter(e,t.COMPILE_STATUS)||(s(o,"vs",t.getShaderInfoLog(e)),r=!0),t.getShaderParameter(i,t.COMPILE_STATUS)||(s(o,"fs",t.getShaderInfoLog(i)),r=!0),t.deleteShader(e),t.deleteShader(i),r)return o;if(!t.getProgramParameter(n,t.LINK_STATUS))return o.push({info:"Failed to link shader program: "+t.getProgramInfoLog(n)}),o;this._glID=n;for(var c=t.getProgramParameter(n,t.ACTIVE_ATTRIBUTES),l=0;l=s.enums.TEXTURE_FMT_RGB_DXT1&&this._format<=s.enums.TEXTURE_FMT_RGBA_PVRTC_4BPPV1||this._format>=s.enums.TEXTURE_FMT_RGB_ETC2&&this._format<=s.enums.TEXTURE_FMT_RGBA_ETC2||this._format>=s.enums.TEXTURE_FMT_RGBA_ASTC_4X4&&this._format<=s.enums.TEXTURE_FMT_SRGBA_ASTC_12X12),void 0!==t.genMipmaps&&(this._genMipmap=t.genMipmaps,i=t.genMipmaps);var n=this._device.caps.maxTextureSize||Number.MAX_VALUE,r=Math.max(t.width||0,t.height||0);n1&&(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."))}(0,o.isPow2)(this._width)&&(0,o.isPow2)(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),t.images.length>1&&(this._genMipmap=!0)),i&&(e.hint(e.GENERATE_MIPMAP_HINT,e.NICEST),e.generateMipmap(e.TEXTURE_2D),this._genMipmap=!0),this._setTexInfo(),this._device._restoreTexture(0)},r.updateSubImage=function(t){var e=this._device._gl,i=(0,s.glTextureFmt)(this._format);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this._glID),this._setSubImage(i,t),this._device._restoreTexture(0)},r.updateImage=function(t){var e=this._device._gl,i=(0,s.glTextureFmt)(this._format);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this._glID),this._setImage(i,t),this._device._restoreTexture(0)},r._setSubImage=function(t,e){var i=this._device._gl,n=e.flipY,r=e.premultiplyAlpha,s=e.image;!s||ArrayBuffer.isView(s)||s instanceof ArrayBuffer?(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)):(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))},r._setImage=function(t,e){var i=this._device._gl,n=e.flipY,r=e.premultiplyAlpha,s=e.image;!s||ArrayBuffer.isView(s)||s instanceof ArrayBuffer?(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)):(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))},r._setMipmap=function(t,e,i){for(var n=(0,s.glTextureFmt)(this._format),r={width:this._width,height:this._height,flipY:e,premultiplyAlpha:i,level:0,image:null},o=0;o>o,r.height=this._height>>o,r.image=t[o],this._setImage(n,r)},r._setTexInfo=function(){var t=this._device._gl,e=(0,o.isPow2)(this._width)&&(0,o.isPow2)(this._height);e||this._wrapS===s.enums.WRAP_CLAMP&&this._wrapT===s.enums.WRAP_CLAMP||(console.warn("WebGL1 doesn't support all wrap modes with NPOT textures"),this._wrapS=s.enums.WRAP_CLAMP,this._wrapT=s.enums.WRAP_CLAMP);var i=this._genMipmap?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,(0,s.glFilter)(t,this._minFilter,i)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,(0,s.glFilter)(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&&t.texParameteri(t.TEXTURE_2D,n.TEXTURE_MAX_ANISOTROPY_EXT,this._anisotropy)},n})(r.default);i.default=c,e.exports=i.default}),{"./enums":290,"./misc":294,"./texture":300}],299:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=(n=t("./texture"))&&n.__esModule?n:{default:n},s=t("./enums"),o=t("./misc");function a(t,e){return(a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var c=(function(t){var e,i;function n(e,i){var n,r=(n=t.call(this,e)||this)._device._gl;return n._target=r.TEXTURE_CUBE_MAP,n._glID=r.createTexture(),n.update(i),n}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,a(e,i);var r=n.prototype;return r.update=function(t){var e=this._device._gl,i=this._genMipmaps;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>=s.enums.TEXTURE_FMT_RGB_DXT1&&this._format<=s.enums.TEXTURE_FMT_RGBA_PVRTC_4BPPV1||this._format>=s.enums.TEXTURE_FMT_RGB_ETC2&&this._format<=s.enums.TEXTURE_FMT_RGBA_ETC2||this._format>=s.enums.TEXTURE_FMT_RGBA_ASTC_4X4&&this._format<=s.enums.TEXTURE_FMT_SRGBA_ASTC_12X12),void 0!==t.genMipmaps&&(this._genMipmaps=t.genMipmaps,i=t.genMipmaps),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"))),(0,o.isPow2)(this._width)&&(0,o.isPow2)(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),t.images.length>1&&(this._genMipmaps=!0)),i&&(e.hint(e.GENERATE_MIPMAP_HINT,e.NICEST),e.generateMipmap(e.TEXTURE_CUBE_MAP),this._genMipmaps=!0),this._setTexInfo(),this._device._restoreTexture(0)},r.updateSubImage=function(t){var e=this._device._gl,i=(0,s.glTextureFmt)(this._format);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,this._glID),this._setSubImage(i,t),this._device._restoreTexture(0)},r.updateImage=function(t){var e=this._device._gl,i=(0,s.glTextureFmt)(this._format);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,this._glID),this._setImage(i,t),this._device._restoreTexture(0)},r._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||ArrayBuffer.isView(o)||o instanceof ArrayBuffer?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):i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.level,e.x,e.y,t.format,t.pixelType,o)},r._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||ArrayBuffer.isView(o)||o instanceof ArrayBuffer?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):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.level,t.internalFormat,t.format,t.pixelType,o)},r._setMipmap=function(t,e,i){for(var n=(0,s.glTextureFmt)(this._format),r={width:this._width,height:this._height,faceIndex:0,flipY:e,premultiplyAlpha:i,level:0,image:null},o=0;o>o,r.height=this._height>>o;for(var c=0;c<6;++c)r.faceIndex=c,r.image=a[c],this._setImage(n,r)}},r._setTexInfo=function(){var t=this._device._gl,e=(0,o.isPow2)(this._width)&&(0,o.isPow2)(this._height);e||this._wrapS===s.enums.WRAP_CLAMP&&this._wrapT===s.enums.WRAP_CLAMP||(console.warn("WebGL1 doesn't support all wrap modes with NPOT textures"),this._wrapS=s.enums.WRAP_CLAMP,this._wrapT=s.enums.WRAP_CLAMP);var i=this._genMipmaps?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,(0,s.glFilter)(t,this._minFilter,i)),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,(0,s.glFilter)(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&&t.texParameteri(t.TEXTURE_CUBE_MAP,n.TEXTURE_MAX_ANISOTROPY_EXT,this._anisotropy)},n})(r.default);i.default=c,e.exports=i.default}),{"./enums":290,"./misc":294,"./texture":300}],300:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=t("./enums"),r=0,s=(function(){function t(t){this._device=t,this._width=4,this._height=4,this._genMipmaps=!1,this._compressed=!1,this._anisotropy=1,this._minFilter=n.enums.FILTER_LINEAR,this._magFilter=n.enums.FILTER_LINEAR,this._mipFilter=n.enums.FILTER_LINEAR,this._wrapS=n.enums.WRAP_REPEAT,this._wrapT=n.enums.WRAP_REPEAT,this._format=n.enums.TEXTURE_FMT_RGBA8,this._target=-1,this._id=r++}return t.prototype.destroy=function(){null!==this._glID?(this._device._gl.deleteTexture(this._glID),this._device._stats.tex-=this.bytes,this._glID=null):console.error("The texture already destroyed")},t})();i.default=s,e.exports=i.default}),{"./enums":290}],301:[(function(t,e,i){"use strict";function n(t,e){for(var i=0;ithis._bytes){if(t)return void console.error("Failed to update data, bytes exceed.");this._needExpandDataStore=!0,this._bytes=t+e.byteLength,this._numVertices=this._bytes/this._bytesPerVertex}var i=this._device._gl,n=this._usage;i.bindBuffer(i.ARRAY_BUFFER,this._glID),this._needExpandDataStore?(i.bufferData(i.ARRAY_BUFFER,e,n),this._needExpandDataStore=!1):i.bufferSubData(i.ARRAY_BUFFER,t,e),i.bindBuffer(i.ARRAY_BUFFER,null)}}else console.error("The buffer is destroyed")},r.getFormat=function(t){return this._format.element(t)},r.setUsage=function(t){this._usage=t},e=t,(i=[{key:"count",get:function(){return this._numVertices}}])&&n(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t})();i.default=r,e.exports=i.default}),{"./enums":290}],302:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=t("./enums"),s=(n=t("../murmurhash2_gc"))&&n.__esModule?n:{default:n},o=(function(){function t(t){this._attr2el={},this._elements=[],this._bytes=0;for(var e="",i=0,n=t.length;ithis._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},n.pop=function(){--this._count,this._count<0&&(this._count=0);var t=this._data[this._count];return this._data[this._count]=void 0,t},n.fastRemove=function(t){if(!(t>=this._count||t<0)){var e=this._count-1;this._data[t]=this._data[e],this._data[e]=void 0,this._count-=1}},n.indexOf=function(t){return this._data.indexOf(t)},n.sort=function(t){return(0,r.default)(this._data,0,this._count,t)},e=t,(i=[{key:"length",get:function(){return this._count}},{key:"data",get:function(){return this._data}}])&&s(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t})();i.default=o,e.exports=i.default}),{"./timsort":309}],305:[(function(t,e,i){"use strict";i.__esModule=!0,i.TypedArrayPool=i.RecyclePool=i.Pool=i.LinkedArray=i.FixedArray=i.CircularPool=void 0;var n=l(t("./circular-pool"));i.CircularPool=n.default;var r=l(t("./fixed-array"));i.FixedArray=r.default;var s=l(t("./linked-array"));i.LinkedArray=s.default;var o=l(t("./pool"));i.Pool=o.default;var a=l(t("./recycle-pool"));i.RecyclePool=a.default;var c=l(t("./typed-array-pool"));function l(t){return t&&t.__esModule?t:{default:t}}i.TypedArrayPool=c.default}),{"./circular-pool":303,"./fixed-array":304,"./linked-array":306,"./pool":307,"./recycle-pool":308,"./typed-array-pool":310}],306:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n,r=(n=t("./pool"))&&n.__esModule?n:{default:n};function s(t,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++]},n.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}},n.sort=function(t){return(0,r.default)(this._data,0,this._count,t)},e=t,(i=[{key:"length",get:function(){return this._count}},{key:"data",get:function(){return this._data}}])&&s(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t})();i.default=o,cc.RecyclePool=o,e.exports=i.default}),{"./timsort":309}],309:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=function(t,e,i,r){if(!Array.isArray(t))throw new TypeError("Can only sort arrays");void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=c);var s=i-e;if(!(s<2)){var o=0;if(sh&&(f=h),_(t,e,e+f,e+o,r),o=f}a.pushRun(e,o),a.mergeRuns(),s-=o,e+=o}while(0!==s);a.forceMergeRuns()}};var n=32,r=7,s=256,o=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function a(t){return t<1e5?t<100?t<10?0:1:t<1e4?t<1e3?2:3:4:t<1e7?t<1e6?5:6:t<1e9?t<1e8?7:8:9}function c(t,e){if(t===e)return 0;if(~~t===t&&~~e===e){if(0===t||0===e)return t=0)return-1;if(t>=0)return 1;t=-t,e=-e}var i=a(t),n=a(e),r=0;return in&&(e*=o[i-n-1],t/=10,r=1),t===e?r:t=n;)e|=1&t,t>>=1;return t+e}function u(t,e,i,n){var r=e+1;if(r===i)return 1;if(n(t[r++],t[e])<0){for(;r=0;)r++;return r-e}function h(t,e,i){for(i--;e>>1;r(s,t[c])<0?a=c:o=c+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 f(t,e,i,n,r,s){var o=0,a=0,c=1;if(s(t,e[i+r])>0){for(a=n-r;c0;)o=c,(c=1+(c<<1))<=0&&(c=a);c>a&&(c=a),o+=r,c+=r}else{for(a=r+1;ca&&(c=a);var l=o;o=r-c,c=r-l}for(o++;o>>1);s(t,e[i+u])>0?o=u+1:c=u}return c}function d(t,e,i,n,r,s){var o=0,a=0,c=1;if(s(t,e[i+r])<0){for(a=r+1;ca&&(c=a);var l=o;o=r-c,c=r-l}else{for(a=n-r;c=0;)o=c,(c=1+(c<<1))<=0&&(c=a);c>a&&(c=a),o+=r,c+=r}for(o++;o>>1);s(t,e[i+u])<0?c=u:o=u+1}return c}var p=(function(){function t(t,e){this.array=t,this.compare=e,this.minGallop=r,this.length=t.length,this.tmpStorageLength=s,this.length<2*s&&(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}var e=t.prototype;return e.pushRun=function(t,e){this.runStart[this.stackSize]=t,this.runLength[this.stackSize]=e,this.stackSize+=1},e.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)}},e.forceMergeRuns=function(){for(;this.stackSize>1;){var t=this.stackSize-2;t>0&&this.runLength[t-1]=r||m>=r);if(v)break;_<0&&(_=0),_+=2}if(this.minGallop=_,_<1&&(this.minGallop=1),1===e){for(c=0;c=0;c--)o[p+c]=o[_+c];if(0===e){g=!0;break}}if(o[h--]=a[u--],1==--n){g=!0;break}if(0!=(y=n-f(o[l],a,0,n,n-1,s))){for(n-=y,p=1+(h-=y),_=1+(u-=y),c=0;c=r||y>=r);if(g)break;m<0&&(m=0),m+=2}if(this.minGallop=m,m<1&&(this.minGallop=1),1===n){for(p=1+(h-=e),_=1+(l-=e),c=e-1;c>=0;c--)o[p+c]=o[_+c];o[h]=a[u]}else{if(0===n)throw new Error("mergeHigh preconditions were not respected");for(_=h-(n-1),c=0;c=0;c--)o[p+c]=o[_+c];o[h]=a[u]}else for(_=h-(n-1),c=0;c65535)<<4,e|=i=((t>>>=e)>255)<<3,e|=i=((t>>>=i)>15)<<2,(e|=i=((t>>>=i)>3)<<1)|(t>>>=i)>>1}function a(t){var e=s(t),i=n[o(e)>>2];return i.length>0?i.pop():new ArrayBuffer(e)}var c={alloc_int8:function(t){var e=new Int8Array(a(t),0,t);return e.length!==t?e.subarray(0,t):e},alloc_uint8:function(t){var e=new Uint8Array(a(t),0,t);return e.length!==t?e.subarray(0,t):e},alloc_int16:function(t){var e=new Int16Array(a(2*t),0,t);return e.length!==t?e.subarray(0,t):e},alloc_uint16:function(t){var e=new Uint16Array(a(2*t),0,t);return e.length!==t?e.subarray(0,t):e},alloc_int32:function(t){var e=new Int32Array(a(4*t),0,t);return e.length!==t?e.subarray(0,t):e},alloc_uint32:function(t){var e=new Uint32Array(a(4*t),0,t);return e.length!==t?e.subarray(0,t):e},alloc_float32:function(t){var e=new Float32Array(a(4*t),0,t);return e.length!==t?e.subarray(0,t):e},alloc_float64:function(t){var e=new Float64Array(a(8*t),0,t);return e.length!==t?e.subarray(0,t):e},alloc_dataview:function(t){var e=new DataView(a(t),0,t);return e.length!==t?e.subarray(0,t):e},free:function(t){var e;e=t.buffer,n[o(e.byteLength)>>2].push(e)},reset:function(){for(var t=Array(8),e=0;e<8;++e)t[e]=[]}};i.default=c,e.exports=i.default}),{}],311:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=function(t,e){for(var i,n=t.length,r=e^n,s=0;n>=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},e.exports=i.default}),{}],312:[(function(t,e,i){"use strict";i.__esModule=!0,i.default=void 0;var n=t("../../core/value-types"),r=a(t("../core/base-renderer")),s=a(t("../enums")),o=t("../memop");function a(t){return t&&t.__esModule?t:{default:t}}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,e){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var u=new Float32Array(16),h=new Float32Array(16),_=new Float32Array(16),f=new Float32Array(16),d=new Float32Array(4),p=new Float32Array(64),m=[],v=new Float32Array(4),y=new n.Vec4(0,0,0,0),g=new n.Vec3(0,0,0),x=new n.Vec3(0,0,0),A=new o.RecyclePool(function(){return new Float32Array(16)},8);function C(t,e){return t._priority-e._priority}var S=(function(t){var e,i;function r(e,i){var n;return(n=t.call(this,e,i)||this)._time=new Float32Array(4),n._lights=[],n._shadowLights=[],n._numLights=0,n._defines={},n._registerStage("shadowcast",n._shadowStage.bind(c(n))),n._registerStage("opaque",n._opaqueStage.bind(c(n))),n._registerStage("transparent",n._transparentStage.bind(c(n))),n}i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,l(e,i);var o=r.prototype;return o.reset=function(){A.reset(),t.prototype.reset.call(this)},o.render=function(t,e){this.reset(),e&&(this._time[0]+=e,this._time[1]=e,this._time[2]++),this._device.setUniform("cc_time",this._time),this._updateLights(t);for(var i=this._device._gl.canvas,n=0;n0){for(var e=A.add(),i=A.add(),n=A.add(),r=Math.min(4,this._lights.length),o=0;oi?i:t}var x=isFinite;function A(t){return t*t}function C(t){return 1/Math.sqrt(t)}var S,b=Math.sqrt,T=Math.pow,w=Math.cos,E=Math.sin,B=Math.acos,M=Math.asin,R=Math.atan2,P=(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=v(this.x,t.x),this.y=v(this.y,t.y),this},t.prototype.SelfMaxV=function(t){return this.x=y(this.x,t.x),this.y=y(this.y,t.y),this},t.prototype.SelfAbs=function(){return this.x=m(this.x),this.y=m(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 d(e,(function(){return new t}))},t.AbsV=function(t,e){return e.x=m(t.x),e.y=m(t.y),e},t.MinV=function(t,e,i){return i.x=v(t.x,e.x),i.y=v(t.y,e.y),i},t.MaxV=function(t,e,i){return i.x=y(t.x,e.x),i.y=y(t.y,e.y),i},t.ClampV=function(t,e,i,n){return n.x=g(t.x,e.x,i.x),n.y=g(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})(),I=new P(0,0),D=(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,c=e.z;return i.x=r*c-s*a,i.y=s*o-n*c,i.z=n*a-r*o,i},t.ZERO=new t(0,0,0),t.s_t0=new t,t})(),V=(function(){function t(){this.ex=new P(1,0),this.ey=new P(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=m(i.x),e.ex.y=m(i.y),e.ey.x=m(n.x),e.ey.y=m(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,c=e.ex.y,l=e.ey.x,u=e.ey.y;return i.ex.x=n*a+s*c,i.ex.y=r*a+o*c,i.ey.x=n*l+s*u,i.ey.y=r*l+o*u,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,c=e.ex.y,l=e.ey.x,u=e.ey.y;return i.ex.x=n*a+r*c,i.ex.y=s*a+o*c,i.ey.x=n*l+r*u,i.ey.y=s*l+o*u,i},t.IDENTITY=new t,t})(),L=(function(){function t(){this.ex=new D(1,0,0),this.ey=new D(0,1,0),this.ez=new D(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,c=this.ey.y,l=this.ey.z,u=this.ez.x,h=this.ez.y,_=this.ez.z,f=r*(c*_-l*h)+s*(l*u-a*_)+o*(a*h-c*u);return 0!==f&&(f=1/f),n.x=f*(t*(c*_-l*h)+e*(l*u-a*_)+i*(a*h-c*u)),n.y=f*(r*(e*_-i*h)+s*(i*u-t*_)+o*(t*h-e*u)),n.z=f*(r*(c*i-l*e)+s*(l*t-a*i)+o*(a*e-c*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=D.DotV3V3(this.ex,D.CrossV3V3(this.ey,this.ez,D.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})(),O=(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})(),F=(function(){function t(){this.p=new P,this.q=new O}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 O.MulRR(t.q,e.q,i.q),P.AddVV(O.MulRV(t.q,e.p,i.p),t.p,i.p),i},t.MulTXX=function(t,e,i){return O.MulTRR(t.q,e.q,i.q),O.MulTRV(t.q,P.SubVV(e.p,t.p,i.p),i.p),i},t.IDENTITY=new t,t})(),N=(function(){function t(){this.localCenter=new P,this.c0=new P,this.c=new P,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(O.MulRV(t.q,this.localCenter,P.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})();(S=t.b2DrawFlags||(t.b2DrawFlags={}))[S.e_none=0]="e_none",S[S.e_shapeBit=1]="e_shapeBit",S[S.e_jointBit=2]="e_jointBit",S[S.e_aabbBit=4]="e_aabbBit",S[S.e_pairBit=8]="e_pairBit",S[S.e_centerOfMassBit=16]="e_centerOfMassBit",S[S.e_particleBit=32]="e_particleBit",S[S.e_controllerBit=64]="e_controllerBit",S[S.e_all=63]="e_all";var k=(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})(),z=(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})(),U=(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})(),H=(function(){function t(t){this.m_stack=[],this.m_count=0,this.m_stack=d(t,(function(){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})(),W=(function(){function t(){this.m_buffer=P.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=P.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=P.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})(),j=(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})(),X=(function(){function t(){this.proxyA=new W,this.proxyB=new W,this.transformA=new F,this.transformB=new F,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})(),q=(function(){function t(){this.pointA=new P,this.pointB=new P,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})();t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0;var Y=(function(){function t(){this.wA=new P,this.wB=new P,this.w=new P,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})(),J=(function(){function t(){this.m_v1=new Y,this.m_v2=new Y,this.m_v3=new Y,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 u=t.metric,h=this.GetMetric();(h<.5*u||2*u0?P.CrossOneV(e,t):P.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 P.DistanceVV(this.m_v1.w,this.m_v2.w);case 3:return P.CrossVV(P.SubVV(this.m_v2.w,this.m_v1.w,P.s_t0),P.SubVV(this.m_v3.w,this.m_v1.w,P.s_t1));default:return 0}},t.prototype.Solve2=function(){var e=this.m_v1.w,i=this.m_v2.w,n=P.SubVV(i,e,t.s_e12),r=-P.DotVV(e,n);if(r<=0)return this.m_v1.a=1,void(this.m_count=1);var s=P.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=P.SubVV(i,e,t.s_e12),s=P.DotVV(e,r),o=P.DotVV(i,r),a=-s,c=P.SubVV(n,e,t.s_e13),l=P.DotVV(e,c),u=P.DotVV(n,c),h=-l,_=P.SubVV(n,i,t.s_e23),f=P.DotVV(i,_),d=P.DotVV(n,_),p=-f,m=P.CrossVV(r,c),v=m*P.CrossVV(i,n),y=m*P.CrossVV(n,e),g=m*P.CrossVV(e,i);if(a<=0&&h<=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(u>0&&h>0&&y<=0){var A=1/(u+h);return this.m_v1.a=u*A,this.m_v3.a=h*A,this.m_count=2,void this.m_v2.Copy(this.m_v3)}if(o<=0&&p<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);if(u<=0&&d<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v3);if(d>0&&p>0&&v<=0){var C=1/(d+p);return this.m_v2.a=d*C,this.m_v3.a=p*C,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var S=1/(v+y+g);this.m_v1.a=v*S,this.m_v2.a=y*S,this.m_v3.a=g*S,this.m_count=3},t.s_e12=new P,t.s_e13=new P,t.s_e23=new P,t})(),Z=new J,K=[0,0,0],Q=[0,0,0],$=new P,tt=new P,et=new P,it=new P,nt=new P;function rt(e,i,s){++t.b2_gjkCalls;var o=s.proxyA,a=s.proxyB,c=s.transformA,l=s.transformB,u=Z;u.ReadCache(i,o,c,a,l);for(var h=u.m_vertices,_=K,f=Q,d=0,p=0;p<20;){d=u.m_count;for(var m=0;mA+C&&e.distance>n){e.distance-=A+C;var S=P.SubVV(e.pointB,e.pointA,et);S.Normalize(),e.pointA.SelfMulAdd(A,S),e.pointB.SelfMulSub(C,S)}else{var b=P.MidVV(e.pointA,e.pointB,$);e.pointA.Copy(b),e.pointB.Copy(b),e.distance=0}}}var st,ot=new P,at=new J,ct=new P,lt=new P,ut=new P,ht=new P,_t=new P,ft=new P;(st=t.b2ContactFeatureType||(t.b2ContactFeatureType={}))[st.e_vertex=0]="e_vertex",st[st.e_face=1]="e_face";var dt,pt=(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})(),mt=(function(){function t(){this.cf=new pt}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})(),vt=(function(){function t(){this.localPoint=new P,this.normalImpulse=0,this.tangentImpulse=0,this.id=new mt}return t.MakeArray=function(e){return d(e,(function(){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})();(dt=t.b2ManifoldType||(t.b2ManifoldType={}))[dt.e_unknown=-1]="e_unknown",dt[dt.e_circles=0]="e_circles",dt[dt.e_faceA=1]="e_faceA",dt[dt.e_faceB=2]="e_faceB";var yt,gt=(function(){function e(){this.points=vt.MakeArray(o),this.localNormal=new P,this.localPoint=new P,this.type=t.b2ManifoldType.e_unknown,this.pointCount=0}return e.prototype.Reset=function(){for(var e=0;er&&P.SubVV(l,c,this.normal).SelfNormalize();var u=P.AddVMulSV(c,s,this.normal,e.Initialize_s_cA),h=P.SubVMulSV(l,a,this.normal,e.Initialize_s_cB);P.MidVV(u,h,this.points[0]),this.separations[0]=P.DotVV(P.SubVV(h,u,P.s_t0),this.normal);break;case t.b2ManifoldType.e_faceA:O.MulRV(n.q,i.localNormal,this.normal);for(var _=F.MulXV(n,i.localPoint,e.Initialize_s_planePoint),f=0;f=0&&e>=0;return i&&this.lowerBound.IsValid()&&this.upperBound.IsValid()},t.prototype.GetCenter=function(){return P.MidVV(this.lowerBound,this.upperBound,this.m_cache_center)},t.prototype.GetExtents=function(){return P.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=v(this.lowerBound.x,t.lowerBound.x),this.lowerBound.y=v(this.lowerBound.y,t.lowerBound.y),this.upperBound.x=y(this.upperBound.x,t.upperBound.x),this.upperBound.y=y(this.upperBound.y,t.upperBound.y),this},t.prototype.Combine2=function(t,e){return this.lowerBound.x=v(t.lowerBound.x,e.lowerBound.x),this.lowerBound.y=v(t.lowerBound.y,e.lowerBound.y),this.upperBound.x=y(t.upperBound.x,e.upperBound.x),this.upperBound.y=y(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&&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,s,o=-i,a=i,c=e.p1.x,l=e.p1.y,u=e.p2.x-e.p1.x,h=e.p2.y-e.p1.y,_=m(u),f=m(h),d=t.normal;if(_(s=(this.upperBound.x-c)*p)){var g=r;r=s,s=g,y=1}if(r>o&&(d.x=y,d.y=0,o=r),o>(a=v(a,s)))return!1}if(f(s=(this.upperBound.y-l)*p)&&(g=r,r=s,s=g,y=1),r>o&&(d.x=0,d.y=y,o=r),o>(a=v(a,s)))return!1;return!(o<0||e.maxFraction0||i>0||n>0||r>0)},t})();function Tt(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 wt(e,i,n,r,s){var o=0,a=i[0],c=i[1],l=P.DotVV(n,a.v)-r,u=P.DotVV(n,c.v)-r;if(l<=0&&e[o++].Copy(a),u<=0&&e[o++].Copy(c),l*u<0){var h=l/(l-u),_=e[o].v;_.x=a.v.x+h*(c.v.x-a.v.x),_.y=a.v.y+h*(c.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 Et=new X,Bt=new j,Mt=new q;function Rt(t,e,i,r,s,o){var a=Et.Reset();a.proxyA.SetShape(t,e),a.proxyB.SetShape(i,r),a.transformA.Copy(s),a.transformB.Copy(o),a.useRadii=!0;var c=Bt.Reset();c.count=0;var l=Mt.Reset();return rt(l,c,a),l.distance<10*n}function Pt(t){if(null===t)throw new Error;return t}var It=(function(){function t(t){void 0===t&&(t=0),this.m_id=0,this.aabb=new bt,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})(),Dt=(function(){function t(){this.m_root=null,this.m_freeList=null,this.m_path=0,this.m_insertionCount=0,this.m_stack=new H(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(Pt(n.child1)),i.Push(Pt(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(Pt(n.child1)),i.Push(Pt(n.child2))}}},t.prototype.RayCast=function(e,i){if(null!==this.m_root){var n=e.p1,r=e.p2,s=P.SubVV(r,n,t.s_r);s.Normalize();var o=P.CrossOneV(s,t.s_v),a=P.AbsV(o,t.s_abs_v),c=e.maxFraction,l=t.s_segmentAABB,u=n.x+c*(r.x-n.x),h=n.y+c*(r.y-n.y);l.lowerBound.x=v(n.x,u),l.lowerBound.y=v(n.y,h),l.upperBound.x=y(n.x,u),l.upperBound.y=y(n.y,h);var _=this.m_stack.Reset();for(_.Push(this.m_root);_.GetCount()>0;){var f=_.Pop();if(Tt(f.aabb,l)){var d=f.aabb.GetCenter(),p=f.aabb.GetExtents();if(!(m(P.DotVV(o,P.SubVV(n,d,P.s_t0)))-P.DotVV(a,p)>0))if(f.IsLeaf()){var g=t.s_subInput;g.p1.Copy(e.p1),g.p2.Copy(e.p2),g.maxFraction=c;var x=i(g,f);if(0===x)return;x>0&&(c=x,u=n.x+c*(r.x-n.x),h=n.y+c*(r.y-n.y),l.lowerBound.x=v(n.x,u),l.lowerBound.y=v(n.y,h),l.upperBound.x=y(n.x,u),l.upperBound.y=y(n.y,h))}else _.Push(Pt(f.child1)),_.Push(Pt(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 It(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=Pt(n.child1),s=Pt(n.child2),o=n.aabb.GetPerimeter(),a=t.s_combinedAABB;a.Combine2(n.aabb,i);var c=a.GetPerimeter(),l=2*c,u=2*(c-o),h=void 0,_=t.s_aabb,f=void 0;r.IsLeaf()?(_.Combine2(i,r.aabb),h=_.GetPerimeter()+u):(_.Combine2(i,r.aabb),f=r.aabb.GetPerimeter(),h=_.GetPerimeter()-f+u);var d=void 0;if(s.IsLeaf()?(_.Combine2(i,s.aabb),d=_.GetPerimeter()+u):(_.Combine2(i,s.aabb),f=s.aabb.GetPerimeter(),d=_.GetPerimeter()-f+u),l1){var r=Pt(i.child1),s=Pt(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+y(e.height,s.height),i.height=1+y(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+y(e.height,r.height),i.height=1+y(t.height,s.height)),i}if(n<-1){var o=Pt(e.child1),a=Pt(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+y(i.height,a.height),e.height=1+y(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+y(i.height,o.height),e.height=1+y(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))+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+y(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=Pt(e.child1),n=Pt(e.child2);this.ValidateStructure(i),this.ValidateStructure(n)}}},t.prototype.ValidateMetrics=function(e){if(null!==e){var i=e;if(!i.IsLeaf()){var n=Pt(i.child1),r=Pt(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=Pt(t.child1),n=Pt(t.child2),r=m(n.height-i.height);return y(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 P,t.s_v=new P,t.s_abs_v=new P,t.s_segmentAABB=new bt,t.s_subInput=new Ct,t.s_combinedAABB=new bt,t.s_aabb=new bt,t.s_node_id=0,t})(),Vt=function(t,e){this.proxyA=t,this.proxyB=e},Lt=(function(){function t(){this.m_tree=new Dt,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=u,b=!0;break}if(M>_-f){d=T;break}var R=S.Evaluate(E[0],B[0],d);if(R<_-f){e.state=t.b2TOIOutputState.e_failed,e.t=d,b=!0;break}if(R<=_+f){e.state=t.b2TOIOutputState.e_touching,e.t=d,b=!0;break}for(var P=0,I=d,D=T;;){var V;V=1&P?I+(_-R)*(D-I)/(M-R):.5*(I+D),++P,++t.b2_toiRootIters;var L=S.Evaluate(E[0],B[0],V);if(m(L-_)_?(I=V,R=L):(D=V,M=L),50===P)break}if(t.b2_toiMaxRootIters=y(t.b2_toiMaxRootIters,P),++w===a)break}if(++p,++t.b2_toiIters,b)break;if(20===p){e.state=t.b2TOIOutputState.e_failed,e.t=d;break}}t.b2_toiMaxIters=y(t.b2_toiMaxIters,p);var O=n.GetMilliseconds();t.b2_toiMaxTime=y(t.b2_toiMaxTime,O),t.b2_toiTime+=O}var se=new P,oe=new P;function ae(e,i,n,r,s){e.pointCount=0;var o=F.MulXV(n,i.m_p,se),a=F.MulXV(s,r.m_p,oe),c=P.DistanceSquaredVV(o,a),l=i.m_radius+r.m_radius;c>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 ce=new P,le=new P,ue=new P;function he(e,r,s,o,a){e.pointCount=0;for(var c=F.MulXV(a,o.m_p,ce),l=F.MulTXV(s,c,le),u=0,h=-i,_=r.m_radius+o.m_radius,f=r.m_count,d=r.m_vertices,p=r.m_normals,m=0;m_)return;v>h&&(h=v,u=m)}var y=u,g=(y+1)%f,x=d[y],A=d[g];if(h_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,P.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(S<=0){if(P.DistanceSquaredVV(l,A)>_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,P.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 b=P.MidVV(x,A,ue);if(P.DotVV(P.SubVV(l,b,P.s_t1),p[y])>_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(p[y]).SelfNormalize(),e.localPoint.Copy(b),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}}var _e=new P,fe=new P,de=new P,pe=new P;function me(t,e,n,r,s){for(var o=t.m_vertices,a=t.m_normals,c=r.m_count,l=r.m_vertices,u=O.MulRV(e.q,a[n],_e),h=O.MulTRV(s.q,u,fe),_=0,f=i,d=0;dh&&(h=f,u=_)}var d=me(e,n,u,r,s),p=(u+o-1)%o,m=me(e,n,p,r,s),v=(u+1)%o,y=me(e,n,v,r,s),g=0,x=0,A=0;if(m>d&&m>y)A=-1,g=p,x=m;else{if(!(y>d))return t[0]=u,d;A=1,g=v,x=y}for(;(d=me(e,n,u=-1===A?(g+o-1)%o:(g+1)%o,r,s))>x;)g=u,x=d;return t[0]=g,x}var xe=new P;function Ae(e,n,r,s,o,a){for(var c=n.m_normals,l=o.m_count,u=o.m_vertices,h=o.m_normals,_=O.MulTRV(a.q,O.MulRV(r.q,c[s],P.s_t0),xe),f=0,d=i,p=0;pa)){var u=we;u[0]=0;var h=ge(u,r,s,i,n);if(!(h>a)){var _,f,d,p,m=0,v=0;h>.98*l+.001?(_=r,f=i,d=s,p=n,m=u[0],e.type=t.b2ManifoldType.e_faceB,v=1):(_=i,f=r,d=n,p=s,m=c[0],e.type=t.b2ManifoldType.e_faceA,v=0);var y=Ce;Ae(y,_,d,m,f,p);var g=_.m_count,x=_.m_vertices,A=m,C=(m+1)%g,S=x[A],b=x[C],T=P.SubVV(b,S,Ee);T.Normalize();var w=P.CrossVOne(T,Be),E=P.MidVV(S,b,Me),B=O.MulRV(d.q,T,Pe),M=P.CrossVOne(B,Re),R=F.MulXV(d,S,De),I=F.MulXV(d,b,Ve),D=P.DotVV(M,R),V=-P.DotVV(B,R)+a,L=P.DotVV(B,I)+a,N=Se,G=be;if(!(wt(N,y,P.NegV(B,Ie),V,A)<2||wt(G,N,B,L,C)<2)){e.localNormal.Copy(w),e.localPoint.Copy(E);for(var k=0,z=0;z_*_)return;if(i.m_hasVertex0){var m=i.m_vertex0,v=a,y=P.SubVV(v,m,Ge);if(P.DotVV(y,P.SubVV(v,o,P.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(d),e.points[0].id.Copy(f),void e.points[0].localPoint.Copy(r.m_p)}if(u<=0){var g=c,x=P.SubVV(o,g,Ne);if(P.DotVV(x,x)>_*_)return;if(i.m_hasVertex3){var A=i.m_vertex3,C=c,S=P.SubVV(A,C,ke);if(P.DotVV(S,P.SubVV(o,C,P.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 b=P.DotVV(l,l),T=ze;T.x=1/b*(u*a.x+h*c.x),T.y=1/b*(u*a.y+h*c.y);var w=P.SubVV(o,T,Ne);if(!(P.DotVV(w,w)>_*_)){var E=Ue.Set(-l.y,l.x);P.DotVV(E,P.SubVV(o,a,P.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(){this.type=0,this.index=0,this.separation=0},Xe=function(){this.vertices=P.MakeArray(a),this.normals=P.MakeArray(a),this.count=0},qe=function(){this.i1=0,this.i2=0,this.v1=new P,this.v2=new P,this.normal=new P,this.sideNormal1=new P,this.sideOffset1=0,this.sideNormal2=new P,this.sideOffset2=0},Ye=new(function(){function e(){this.m_polygonB=new Xe,this.m_xf=new F,this.m_centroidB=new P,this.m_v0=new P,this.m_v1=new P,this.m_v2=new P,this.m_v3=new P,this.m_normal0=new P,this.m_normal1=new P,this.m_normal2=new P,this.m_normal=new P,this.m_type1=0,this.m_type2=0,this.m_lowerLimit=new P,this.m_upperLimit=new P,this.m_radius=0,this.m_front=!1}return e.prototype.Collide=function(i,n,r,s,a){F.MulTXX(r,a,this.m_xf),F.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 c=n.m_hasVertex0,l=n.m_hasVertex3,u=P.SubVV(this.m_v2,this.m_v1,e.s_edge1);u.Normalize(),this.m_normal1.Set(u.y,-u.x);var h=P.DotVV(this.m_normal1,P.SubVV(this.m_centroidB,this.m_v1,P.s_t0)),_=0,f=0,d=!1,p=!1;if(c){var m=P.SubVV(this.m_v1,this.m_v0,e.s_edge0);m.Normalize(),this.m_normal0.Set(m.y,-m.x),d=P.CrossVV(m,u)>=0,_=P.DotVV(this.m_normal0,P.SubVV(this.m_centroidB,this.m_v0,P.s_t0))}if(l){var v=P.SubVV(this.m_v3,this.m_v2,e.s_edge2);v.Normalize(),this.m_normal2.Set(v.y,-v.x),p=P.CrossVV(u,v)>0,f=P.DotVV(this.m_normal2,P.SubVV(this.m_centroidB,this.m_v2,P.s_t0))}c&&l?d&&p?(this.m_front=_>=0||h>=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())):d?(this.m_front=_>=0||h>=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())):p?(this.m_front=f>=0||_>=0&&h>=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&&h>=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())):c?d?(this.m_front=_>=0||h>=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&&h>=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?p?(this.m_front=h>=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=h>=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=h>=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 y=0;ythis.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 C=e.s_ie,S=e.s_rf;if(1===A.type){i.type=t.b2ManifoldType.e_faceA;var b=0,T=P.DotVV(this.m_normal,this.m_polygonB.normals[0]);for(y=1;ythis.m_radius)return n.type=2,n.index=s,n.separation=u,n;if(P.DotVV(o,r)>=0){if(P.DotVV(P.SubVV(o,this.m_upperLimit,P.s_t0),this.m_normal)<-l)continue}else if(P.DotVV(P.SubVV(o,this.m_lowerLimit,P.s_t0),this.m_normal)<-l)continue;u>n.separation&&(n.type=2,n.index=s,n.separation=u)}return n},e.s_edge1=new P,e.s_edge0=new P,e.s_edge2=new P,e.s_ie=At.MakeArray(2),e.s_rf=new qe,e.s_clipPoints1=At.MakeArray(2),e.s_clipPoints2=At.MakeArray(2),e.s_edgeAxis=new je,e.s_polygonAxis=new je,e.s_n=new P,e.s_perp=new P,e}());function Je(t,e,i,n,r){Ye.Collide(t,e,i,n,r)}var Ze,Ke=function(){this.mass=0,this.center=new P(0,0),this.I=0};(Ze=t.b2ShapeType||(t.b2ShapeType={}))[Ze.e_unknown=-1]="e_unknown",Ze[Ze.e_circleShape=0]="e_circleShape",Ze[Ze.e_edgeShape=1]="e_edgeShape",Ze[Ze.e_polygonShape=2]="e_polygonShape",Ze[Ze.e_chainShape=3]="e_chainShape",Ze[Ze.e_shapeTypeCount=4]="e_shapeTypeCount";var Qe=(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})(),$e=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 ti(t,e){function i(){this.constructor=t}$e(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var ei,ii=(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 P,n}return ti(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=F.MulXV(t,this.m_p,i.TestPoint_s_center),r=P.SubVV(e,n,i.TestPoint_s_d);return P.DotVV(r,r)<=A(this.m_radius)},i.prototype.ComputeDistance=function(t,e,n){var r=F.MulXV(t,this.m_p,i.ComputeDistance_s_center);return P.SubVV(e,r,n),n.Normalize()-this.m_radius},i.prototype.RayCast=function(t,e,r){var s=F.MulXV(r,this.m_p,i.RayCast_s_position),o=P.SubVV(e.p1,s,i.RayCast_s_s),a=P.DotVV(o,o)-A(this.m_radius),c=P.SubVV(e.p2,e.p1,i.RayCast_s_r),l=P.DotVV(o,c),u=P.DotVV(c,c),h=l*l-u*a;if(h<0||uthis.m_radius)return r.Copy(o),s*this.m_radius*this.m_radius;var c=this.m_radius*this.m_radius,l=a*a,u=c*(M(a/this.m_radius)+s/2)+a*b(c-l),h=-2/3*T(c-l,1.5)/u;return r.x=o.x+t.x*h,r.y=o.y+t.y*h,u},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 P,i.TestPoint_s_d=new P,i.ComputeDistance_s_center=new P,i.RayCast_s_position=new P,i.RayCast_s_s=new P,i.RayCast_s_r=new P,i.ComputeAABB_s_p=new P,i})(Qe),ni=(function(e){function r(){var i=e.call(this,t.b2ShapeType.e_polygonShape,u)||this;return i.m_centroid=new P(0,0),i.m_vertices=[],i.m_normals=[],i.m_count=0,i}return ti(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=P.MakeArray(this.m_count),this.m_normals=P.MakeArray(this.m_count);for(var i=0;id||p===d&&s[l].yA.LengthSquared()&&(x=_)}else x=_;if(++y,g=x,x===f)break}for(this.m_count=y,this.m_vertices=P.MakeArray(this.m_count),this.m_normals=P.MakeArray(this.m_count),l=0;l0)return!1;return!0},r.prototype.ComputeDistance=function(t,e,n){for(var s=F.MulTXV(t,e,r.ComputeDistance_s_pLocal),o=-i,a=r.ComputeDistance_s_normalForMaxDistance.Copy(s),c=0;co&&(o=l,a.Copy(this.m_normals[c]))}if(o>0){var u=r.ComputeDistance_s_minDistance.Copy(a),h=o*o;for(c=0;cf&&(u.Copy(_),h=f)}return O.MulRV(t.q,u,n),n.Normalize(),Math.sqrt(h)}return O.MulRV(t.q,a,n),o},r.prototype.RayCast=function(t,e,i){for(var n=F.MulTXV(i,e.p1,r.RayCast_s_p1),s=F.MulTXV(i,e.p2,r.RayCast_s_p2),o=P.SubVV(s,n,r.RayCast_s_d),a=0,c=e.maxFraction,l=-1,u=0;u0&&h=0&&(t.fraction=a,O.MulRV(i.q,this.m_normals[l],t.normal),!0)},r.prototype.ComputeAABB=function(t,e){for(var i=F.MulXV(e,this.m_vertices[0],t.lowerBound),n=t.upperBound.Copy(i),s=0;s0&&(d?_||(u=f-1,l++):_&&(h=f-1,l++)),_=d}switch(l){case 0:if(_){var p=r.ComputeSubmergedArea_s_md;return this.ComputeMass(p,1),F.MulXV(i,p.center,s),p.mass}return 0;case 1:-1===u?u=this.m_count-1:h=this.m_count-1}for(var m,v=(u+1)%this.m_count,y=(h+1)%this.m_count,g=(0-c[u])/(c[v]-c[u]),x=(0-c[h])/(c[y]-c[h]),A=r.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[u].x*(1-g)+this.m_vertices[v].x*g,this.m_vertices[u].y*(1-g)+this.m_vertices[v].y*g),C=r.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[h].x*(1-x)+this.m_vertices[y].x*x,this.m_vertices[h].y*(1-x)+this.m_vertices[y].y*x),S=0,b=r.ComputeSubmergedArea_s_center.SetZero(),T=this.m_vertices[v],w=v;w!==y;){m=(w=(w+1)%this.m_count)===y?C:this.m_vertices[w];var E=.5*((T.x-A.x)*(m.y-A.y)-(T.y-A.y)*(m.x-A.x));S+=E,b.x+=E*(A.x+T.x+m.x)/3,b.y+=E*(A.y+T.y+m.y)/3,T=m}return b.SelfMul(1/S),F.MulXV(i,b,s),S},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 l=P.DotVV(a,a);c>l?P.SubVV(e,s,o):o.SelfMulSub(c/l,a)}return n.Copy(o),n.Normalize()},i.prototype.RayCast=function(t,e,n){var r=F.MulTXV(n,e.p1,i.RayCast_s_p1),s=F.MulTXV(n,e.p2,i.RayCast_s_p2),o=P.SubVV(s,r,i.RayCast_s_d),a=this.m_vertex1,c=this.m_vertex2,l=P.SubVV(c,a,i.RayCast_s_e),u=t.normal.Set(l.y,-l.x).SelfNormalize(),h=P.DotVV(u,P.SubVV(a,r,P.s_t0)),_=P.DotVV(u,o);if(0===_)return!1;var f=h/_;if(f<0||e.maxFraction0&&t.normal.SelfNeg(),0))},i.prototype.ComputeAABB=function(t,e){var n=F.MulXV(e,this.m_vertex1,i.ComputeAABB_s_v1),r=F.MulXV(e,this.m_vertex2,i.ComputeAABB_s_v2);P.MinV(n,r,t.lowerBound),P.MaxV(n,r,t.upperBound);var s=this.m_radius;t.lowerBound.SelfSubXY(s,s),t.upperBound.SelfAddXY(s,s)},i.prototype.ComputeMass=function(t){t.mass=0,P.MidVV(this.m_vertex1,this.m_vertex2,t.center),t.I=0},i.prototype.SetupDistanceProxy=function(t){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 P,i.ComputeDistance_s_v2=new P,i.ComputeDistance_s_d=new P,i.ComputeDistance_s_s=new P,i.RayCast_s_p1=new P,i.RayCast_s_p2=new P,i.RayCast_s_d=new P,i.RayCast_s_e=new P,i.RayCast_s_q=new P,i.RayCast_s_r=new P,i.ComputeAABB_s_v1=new P,i.ComputeAABB_s_v2=new P,i})(Qe),si=(function(e){function i(){var i=e.call(this,t.b2ShapeType.e_chainShape,u)||this;return i.m_vertices=[],i.m_count=0,i.m_prevVertex=new P,i.m_nextVertex=new P,i.m_hasPrevVertex=!1,i.m_hasNextVertex=!1,i}return ti(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=P.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),F.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&&(P.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*P.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*P.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*P.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),F.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),P.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,P.SubVV(this.m_sweep.c,n,P.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*P.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),F.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),P.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,P.SubVV(this.m_sweep.c,s,P.s_t0),this.m_linearVelocity)},i.prototype.GetWorldPoint=function(t,e){return F.MulXV(this.m_xf,t,e)},i.prototype.GetWorldVector=function(t,e){return O.MulRV(this.m_xf.q,t,e)},i.prototype.GetLocalPoint=function(t,e){return F.MulTXV(this.m_xf,t,e)},i.prototype.GetLocalVector=function(t,e){return O.MulTRV(this.m_xf.q,t,e)},i.prototype.GetLinearVelocityFromWorldPoint=function(t,e){return P.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,P.SubVV(t,this.m_sweep.c,P.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),O.MulRV(t.q,this.m_sweep.localCenter,t.p),P.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),O.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),P.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),O.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),P.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 ai,i.SetMassData_s_oldCenter=new P,i.ResetMassData_s_localCenter=new P,i.ResetMassData_s_oldCenter=new P,i.ResetMassData_s_massData=new Ke,i.SynchronizeFixtures_s_xf1=new F,i})();(ui=t.b2JointType||(t.b2JointType={}))[ui.e_unknownJoint=0]="e_unknownJoint",ui[ui.e_revoluteJoint=1]="e_revoluteJoint",ui[ui.e_prismaticJoint=2]="e_prismaticJoint",ui[ui.e_distanceJoint=3]="e_distanceJoint",ui[ui.e_pulleyJoint=4]="e_pulleyJoint",ui[ui.e_mouseJoint=5]="e_mouseJoint",ui[ui.e_gearJoint=6]="e_gearJoint",ui[ui.e_wheelJoint=7]="e_wheelJoint",ui[ui.e_weldJoint=8]="e_weldJoint",ui[ui.e_frictionJoint=9]="e_frictionJoint",ui[ui.e_ropeJoint=10]="e_ropeJoint",ui[ui.e_motorJoint=11]="e_motorJoint",ui[ui.e_areaJoint=12]="e_areaJoint",(hi=t.b2LimitState||(t.b2LimitState={}))[hi.e_inactiveLimit=0]="e_inactiveLimit",hi[hi.e_atLowerLimit=1]="e_atLowerLimit",hi[hi.e_atUpperLimit=2]="e_atUpperLimit",hi[hi.e_equalLimits=3]="e_equalLimits";var fi=(function(){function t(){this.linear=new P,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})(),di=function(t,e){this.prev=null,this.next=null,this.joint=t,this.other=e},pi=function(e){this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=e},mi=(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 di(this,i.bodyB),this.m_edgeB=new di(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(){},i})(),vi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_distanceJoint)||this;return i.localAnchorA=new P,i.localAnchorB=new P,i.length=1,i.frequencyHz=0,i.dampingRatio=0,i}return ti(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=P.DistanceVV(i,n),this.frequencyHz=0,this.dampingRatio=0},i})(pi),yi=(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 P,n.m_localAnchorB=new P,n.m_gamma=0,n.m_impulse=0,n.m_length=0,n.m_indexA=0,n.m_indexB=0,n.m_u=new P,n.m_rA=new P,n.m_rB=new P,n.m_localCenterA=new P,n.m_localCenterB=new P,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new O,n.m_qB=new O,n.m_lalcA=new P,n.m_lalcB=new P,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 ti(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(){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,u=t.velocities[this.m_indexB].v,h=t.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(n),f=this.m_qB.SetAngle(l);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),O.MulRV(_,this.m_lalcA,this.m_rA),P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),O.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 d=this.m_u.Length();d>c?this.m_u.SelfMul(1/d):this.m_u.SetZero();var p=P.CrossVV(this.m_rA,this.m_u),m=P.CrossVV(this.m_rB,this.m_u),v=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==v?1/v:0,this.m_frequencyHz>0){var y=d-this.m_length,g=2*s*this.m_frequencyHz,x=2*this.m_mass*this.m_dampingRatio*g,A=this.m_mass*g*g,C=t.step.dt;this.m_gamma=C*(x+C*A),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=y*C*A*this.m_gamma,v+=this.m_gamma,this.m_mass=0!==v?1/v:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var S=P.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);r.SelfMulSub(this.m_invMassA,S),o-=this.m_invIA*P.CrossVV(this.m_rA,S),u.SelfMulAdd(this.m_invMassB,S),h+=this.m_invIB*P.CrossVV(this.m_rB,S)}else this.m_impulse=0;t.velocities[this.m_indexA].w=o,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=P.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),a=P.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),c=P.DotVV(this.m_u,P.SubVV(a,o,P.s_t0)),l=-this.m_mass*(c+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=l;var u=P.MulSV(l,this.m_u,i.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,u),n-=this.m_invIA*P.CrossVV(this.m_rA,u),r.SelfMulAdd(this.m_invMassB,u),s+=this.m_invIB*P.CrossVV(this.m_rB,u),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=O.MulRV(o,this.m_lalcA,this.m_rA),u=O.MulRV(a,this.m_lalcB,this.m_rB),h=this.m_u;h.x=r.x+u.x-e.x-l.x,h.y=r.y+u.y-e.y-l.y;var _=this.m_u.Normalize()-this.m_length;_=g(_,-.2,.2);var f=-this.m_mass*_,d=P.MulSV(f,h,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,d),n-=this.m_invIA*P.CrossVV(l,d),r.SelfMulAdd(this.m_invMassB,d),s+=this.m_invIB*P.CrossVV(u,d),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,m(_)A(.2)&&f.SelfMul(.2/b(p)),p>A(c)&&(_=!1),a.x+=f.x,a.y+=f.y}return _},i})(mi),Ai=(function(e){function i(){var i=e.call(this,t.b2JointType.e_frictionJoint)||this;return i.localAnchorA=new P,i.localAnchorB=new P,i.maxForce=0,i.maxTorque=0,i}return ti(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})(pi),Ci=(function(t){function i(i){var n=t.call(this,i)||this;return n.m_localAnchorA=new P,n.m_localAnchorB=new P,n.m_linearImpulse=new P,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_indexA=0,n.m_indexB=0,n.m_rA=new P,n.m_rB=new P,n.m_localCenterA=new P,n.m_localCenterB=new P,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new V,n.m_angularMass=0,n.m_qA=new O,n.m_qB=new O,n.m_lalcA=new P,n.m_lalcB=new P,n.m_K=new V,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 ti(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),c=this.m_qB.SetAngle(r);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=O.MulRV(a,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=O.MulRV(c,this.m_lalcB,this.m_rB),h=this.m_invMassA,_=this.m_invMassB,f=this.m_invIA,d=this.m_invIB,p=this.m_K;if(p.ex.x=h+_+f*l.y*l.y+d*u.y*u.y,p.ex.y=-f*l.x*l.y-d*u.x*u.y,p.ey.x=p.ex.y,p.ey.y=h+_+f*l.x*l.x+d*u.x*u.x,p.GetInverse(this.m_linearMass),this.m_angularMass=f+d,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 m=this.m_linearImpulse;i.SelfMulSub(h,m),n-=f*(P.CrossVV(this.m_rA,m)+this.m_angularImpulse),s.SelfMulAdd(_,m),o+=d*(P.CrossVV(this.m_rB,m)+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,c=this.m_invIA,l=this.m_invIB,u=t.step.dt,h=s-n,_=-this.m_angularMass*h,f=this.m_angularImpulse,d=u*this.m_maxTorque;this.m_angularImpulse=g(this.m_angularImpulse+_,-d,d),n-=c*(_=this.m_angularImpulse-f),s+=l*_;var p=P.SubVV(P.AddVCrossSV(r,s,this.m_rB,P.s_t0),P.AddVCrossSV(e,n,this.m_rA,P.s_t1),i.SolveVelocityConstraints_s_Cdot_v2),m=V.MulMV(this.m_linearMass,p,i.SolveVelocityConstraints_s_impulseV).SelfNeg(),v=i.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(m),d=u*this.m_maxForce,this.m_linearImpulse.LengthSquared()>d*d&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(d)),P.SubVV(this.m_linearImpulse,v,m),e.SelfMulSub(o,m),n-=c*P.CrossVV(this.m_rA,m),r.SelfMulAdd(a,m),s+=l*P.CrossVV(this.m_rB,m),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},i.prototype.SolvePositionConstraints=function(){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 P,i.SolveVelocityConstraints_s_impulseV=new P,i.SolveVelocityConstraints_s_oldImpulseV=new P,i})(mi),Si=(function(e){function i(){var i=e.call(this,t.b2JointType.e_gearJoint)||this;return i.ratio=1,i}return ti(i,e),i})(pi),bi=(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 P,o.m_localAnchorB=new P,o.m_localAnchorC=new P,o.m_localAnchorD=new P,o.m_localAxisC=new P,o.m_localAxisD=new P,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 P,o.m_lcB=new P,o.m_lcC=new P,o.m_lcD=new P,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 P,o.m_JvBD=new P,o.m_JwA=0,o.m_JwB=0,o.m_JwC=0,o.m_JwD=0,o.m_mass=0,o.m_qA=new O,o.m_qB=new O,o.m_qC=new O,o.m_qD=new O,o.m_lalcA=new P,o.m_lalcB=new P,o.m_lalcC=new P,o.m_lalcD=new P,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,c=o.m_bodyA.m_sweep.a,l=o.m_bodyC.m_xf,u=o.m_bodyC.m_sweep.a;if(o.m_typeA===t.b2JointType.e_revoluteJoint){var h=n.joint1;o.m_localAnchorC.Copy(h.m_localAnchorA),o.m_localAnchorA.Copy(h.m_localAnchorB),o.m_referenceAngleA=h.m_referenceAngle,o.m_localAxisC.SetZero(),r=c-u-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,d=O.MulTRV(l.q,P.AddVV(O.MulRV(a.q,o.m_localAnchorA,P.s_t0),P.SubVV(a.p,l.p,P.s_t1),P.s_t0),P.s_t0);r=P.DotVV(P.SubVV(d,f,P.s_t0),o.m_localAxisC)}o.m_bodyD=o.m_joint2.GetBodyA(),o.m_bodyB=o.m_joint2.GetBodyB();var p=o.m_bodyB.m_xf,m=o.m_bodyB.m_sweep.a,v=o.m_bodyD.m_xf,y=o.m_bodyD.m_sweep.a;if(o.m_typeB===t.b2JointType.e_revoluteJoint)h=n.joint2,o.m_localAnchorD.Copy(h.m_localAnchorA),o.m_localAnchorB.Copy(h.m_localAnchorB),o.m_referenceAngleB=h.m_referenceAngle,o.m_localAxisD.SetZero(),s=m-y-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=O.MulTRV(v.q,P.AddVV(O.MulRV(p.q,o.m_localAnchorB,P.s_t0),P.SubVV(p.p,v.p,P.s_t1),P.s_t0),P.s_t0);s=P.DotVV(P.SubVV(x,g,P.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 ti(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,c=e.velocities[this.m_indexB].w,l=e.positions[this.m_indexC].a,u=e.velocities[this.m_indexC].v,h=e.velocities[this.m_indexC].w,_=e.positions[this.m_indexD].a,f=e.velocities[this.m_indexD].v,d=e.velocities[this.m_indexD].w,p=this.m_qA.SetAngle(i),m=this.m_qB.SetAngle(o),v=this.m_qC.SetAngle(l),y=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=O.MulRV(v,this.m_localAxisC,n.InitVelocityConstraints_s_u);P.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var x=O.MulRV(v,this.m_lalcC,n.InitVelocityConstraints_s_rC);P.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var A=O.MulRV(p,this.m_lalcA,n.InitVelocityConstraints_s_rA);this.m_JvAC.Copy(g),this.m_JwC=P.CrossVV(x,g),this.m_JwA=P.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=O.MulRV(y,this.m_localAxisD,n.InitVelocityConstraints_s_u),P.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var C=O.MulRV(y,this.m_lalcD,n.InitVelocityConstraints_s_rD);P.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var S=O.MulRV(m,this.m_lalcB,n.InitVelocityConstraints_s_rB);P.MulSV(this.m_ratio,g,this.m_JvBD),this.m_JwD=this.m_ratio*P.CrossVV(C,g),this.m_JwB=this.m_ratio*P.CrossVV(S,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),c+=this.m_iB*this.m_impulse*this.m_JwB,u.SelfMulSub(this.m_mC*this.m_impulse,this.m_JvAC),h-=this.m_iC*this.m_impulse*this.m_JwC,f.SelfMulSub(this.m_mD*this.m_impulse,this.m_JvBD),d-=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=c,e.velocities[this.m_indexC].w=h,e.velocities[this.m_indexD].w=d},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,c=t.velocities[this.m_indexD].w,l=P.DotVV(this.m_JvAC,P.SubVV(e,s,P.s_t0))+P.DotVV(this.m_JvBD,P.SubVV(n,a,P.s_t0));l+=this.m_JwA*i-this.m_JwC*o+(this.m_JwB*r-this.m_JwD*c);var u=-this.m_mass*l;this.m_impulse+=u,e.SelfMulAdd(this.m_mA*u,this.m_JvAC),i+=this.m_iA*u*this.m_JwA,n.SelfMulAdd(this.m_mB*u,this.m_JvBD),r+=this.m_iB*u*this.m_JwB,s.SelfMulSub(this.m_mC*u,this.m_JvAC),o-=this.m_iC*u*this.m_JwC,a.SelfMulSub(this.m_mD*u,this.m_JvBD),c-=this.m_iD*u*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=c},n.prototype.SolvePositionConstraints=function(e){var i,r,s,o,a,l,u=e.positions[this.m_indexA].c,h=e.positions[this.m_indexA].a,_=e.positions[this.m_indexB].c,f=e.positions[this.m_indexB].a,d=e.positions[this.m_indexC].c,p=e.positions[this.m_indexC].a,m=e.positions[this.m_indexD].c,v=e.positions[this.m_indexD].a,y=this.m_qA.SetAngle(h),g=this.m_qB.SetAngle(f),x=this.m_qC.SetAngle(p),A=this.m_qD.SetAngle(v),C=this.m_JvAC,S=this.m_JvBD,b=0;if(this.m_typeA===t.b2JointType.e_revoluteJoint)C.SetZero(),s=1,a=1,b+=this.m_iA+this.m_iC,i=h-p-this.m_referenceAngleA;else{var T=O.MulRV(x,this.m_localAxisC,n.SolvePositionConstraints_s_u),w=O.MulRV(x,this.m_lalcC,n.SolvePositionConstraints_s_rC),E=O.MulRV(y,this.m_lalcA,n.SolvePositionConstraints_s_rA);C.Copy(T),a=P.CrossVV(w,T),s=P.CrossVV(E,T),b+=this.m_mC+this.m_mA+this.m_iC*a*a+this.m_iA*s*s;var B=this.m_lalcC,M=O.MulTRV(x,P.AddVV(E,P.SubVV(u,d,P.s_t0),P.s_t0),P.s_t0);i=P.DotVV(P.SubVV(M,B,P.s_t0),this.m_localAxisC)}if(this.m_typeB===t.b2JointType.e_revoluteJoint)S.SetZero(),o=this.m_ratio,l=this.m_ratio,b+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),r=f-v-this.m_referenceAngleB;else{T=O.MulRV(A,this.m_localAxisD,n.SolvePositionConstraints_s_u);var R=O.MulRV(A,this.m_lalcD,n.SolvePositionConstraints_s_rD),I=O.MulRV(g,this.m_lalcB,n.SolvePositionConstraints_s_rB);P.MulSV(this.m_ratio,T,S),l=this.m_ratio*P.CrossVV(R,T),o=this.m_ratio*P.CrossVV(I,T),b+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*l*l+this.m_iB*o*o;var D=this.m_lalcD,V=O.MulTRV(A,P.AddVV(I,P.SubVV(_,m,P.s_t0),P.s_t0),P.s_t0);r=P.DotVV(P.SubVV(V,D,P.s_t0),this.m_localAxisD)}var L=i+this.m_ratio*r-this.m_constant,F=0;return b>0&&(F=-L/b),u.SelfMulAdd(this.m_mA*F,C),h+=this.m_iA*F*s,_.SelfMulAdd(this.m_mB*F,S),f+=this.m_iB*F*o,d.SelfMulSub(this.m_mC*F,C),p-=this.m_iC*F*a,m.SelfMulSub(this.m_mD*F,S),v-=this.m_iD*F*l,e.positions[this.m_indexA].a=h,e.positions[this.m_indexB].a=f,e.positions[this.m_indexC].a=p,e.positions[this.m_indexD].a=v,00&&(this.m_angularMass=1/this.m_angularMass),P.SubVV(P.AddVV(s,_,P.s_t0),P.AddVV(e,h,P.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 y=this.m_linearImpulse;n.SelfMulSub(f,y),r-=p*(P.CrossVV(h,y)+this.m_angularImpulse),a.SelfMulAdd(d,y),c+=m*(P.CrossVV(_,y)+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=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=this.m_invMassA,a=this.m_invMassB,c=this.m_invIA,l=this.m_invIB,u=t.step.dt,h=t.step.inv_dt,_=s-n+h*this.m_correctionFactor*this.m_angularError,f=-this.m_angularMass*_,d=this.m_angularImpulse,p=u*this.m_maxTorque;this.m_angularImpulse=g(this.m_angularImpulse+f,-p,p),n-=c*(f=this.m_angularImpulse-d),s+=l*f;var m=this.m_rA,v=this.m_rB,y=P.AddVV(P.SubVV(P.AddVV(r,P.CrossSV(s,v,P.s_t0),P.s_t0),P.AddVV(e,P.CrossSV(n,m,P.s_t1),P.s_t1),P.s_t2),P.MulSV(h*this.m_correctionFactor,this.m_linearError,P.s_t3),i.SolveVelocityConstraints_s_Cdot_v2),x=V.MulMV(this.m_linearMass,y,i.SolveVelocityConstraints_s_impulse_v2).SelfNeg(),A=i.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(x),p=u*this.m_maxForce,this.m_linearImpulse.LengthSquared()>p*p&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(p)),P.SubVV(this.m_linearImpulse,A,x),e.SelfMulSub(o,x),n-=c*P.CrossVV(m,x),r.SelfMulAdd(a,x),s+=l*P.CrossVV(v,x),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},i.prototype.SolvePositionConstraints=function(){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 P,i.SolveVelocityConstraints_s_impulse_v2=new P,i.SolveVelocityConstraints_s_oldImpulse_v2=new P,i})(mi),Ei=(function(e){function i(){var i=e.call(this,t.b2JointType.e_mouseJoint)||this;return i.target=new P,i.maxForce=0,i.frequencyHz=5,i.dampingRatio=.7,i}return ti(i,e),i})(pi),Bi=(function(t){function i(i){var n=t.call(this,i)||this;return n.m_localAnchorB=new P,n.m_targetA=new P,n.m_frequencyHz=0,n.m_dampingRatio=0,n.m_beta=0,n.m_impulse=new P,n.m_maxForce=0,n.m_gamma=0,n.m_indexA=0,n.m_indexB=0,n.m_rB=new P,n.m_localCenterB=new P,n.m_invMassB=0,n.m_invIB=0,n.m_mass=new V,n.m_C=new P,n.m_qB=new O,n.m_lalcB=new P,n.m_K=new V,n.m_targetA.Copy(e(i.target,P.ZERO)),F.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 ti(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(),c=2*s*this.m_frequencyHz,l=2*a*this.m_dampingRatio*c,u=a*c*c,h=t.step.dt;this.m_gamma=h*(l+h*u),0!==this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=h*u*this.m_gamma,P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),O.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*P.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=P.AddVCrossSV(e,n,this.m_rB,i.SolveVelocityConstraints_s_Cdot),s=V.MulMV(this.m_mass,P.AddVV(r,P.AddVV(this.m_C,P.MulSV(this.m_gamma,this.m_impulse,P.s_t0),P.s_t0),P.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()),P.SubVV(this.m_impulse,o,s),e.SelfMulAdd(this.m_invMassB,s),n+=this.m_invIB*P.CrossVV(this.m_rB,s),t.velocities[this.m_indexB].w=n},i.prototype.SolvePositionConstraints=function(){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 P.MulSV(t,this.m_impulse,e)},i.prototype.GetReactionTorque=function(){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 P,i.SolveVelocityConstraints_s_impulse=new P,i.SolveVelocityConstraints_s_oldImpulse=new P,i})(mi),Mi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_prismaticJoint)||this;return i.localAnchorA=new P,i.localAnchorB=new P,i.localAxisA=new P(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 ti(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})(pi),Ri=(function(i){function n(n){var r=i.call(this,n)||this;return r.m_localAnchorA=new P,r.m_localAnchorB=new P,r.m_localXAxisA=new P,r.m_localYAxisA=new P,r.m_referenceAngle=0,r.m_impulse=new D(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 P,r.m_localCenterB=new P,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_axis=new P(0,0),r.m_perp=new P(0,0),r.m_s1=0,r.m_s2=0,r.m_a1=0,r.m_a2=0,r.m_K=new L,r.m_K3=new L,r.m_K2=new V,r.m_motorMass=0,r.m_qA=new O,r.m_qB=new O,r.m_lalcA=new P,r.m_lalcB=new P,r.m_rA=new P,r.m_rB=new P,r.m_localAnchorA.Copy(e(n.localAnchorA,P.ZERO)),r.m_localAnchorB.Copy(e(n.localAnchorB,P.ZERO)),r.m_localXAxisA.Copy(e(n.localAxisA,new P(1,0))).SelfNormalize(),P.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 ti(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,u=e.velocities[this.m_indexB].v,h=e.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(r),f=this.m_qB.SetAngle(l);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var d=O.MulRV(_,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p=O.MulRV(f,this.m_lalcB,this.m_rB),v=P.AddVV(P.SubVV(a,i,P.s_t0),P.SubVV(p,d,P.s_t1),n.InitVelocityConstraints_s_d),y=this.m_invMassA,g=this.m_invMassB,x=this.m_invIA,A=this.m_invIB;if(O.MulRV(_,this.m_localXAxisA,this.m_axis),this.m_a1=P.CrossVV(P.AddVV(v,d,P.s_t0),this.m_axis),this.m_a2=P.CrossVV(p,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),O.MulRV(_,this.m_localYAxisA,this.m_perp),this.m_s1=P.CrossVV(P.AddVV(v,d,P.s_t0),this.m_perp),this.m_s2=P.CrossVV(p,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 C=P.DotVV(this.m_axis,v);m(this.m_upperTranslation-this.m_lowerTranslation)<2*c?this.m_limitState=t.b2LimitState.e_equalLimits:C<=this.m_lowerTranslation?this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_limitState=t.b2LimitState.e_atLowerLimit,this.m_impulse.z=0):C>=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 S=P.AddVV(P.MulSV(this.m_impulse.x,this.m_perp,P.s_t0),P.MulSV(this.m_motorImpulse+this.m_impulse.z,this.m_axis,P.s_t1),n.InitVelocityConstraints_s_P),b=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,S),o-=x*b,u.SelfMulAdd(g,S),h+=A*T}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=o,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,c=this.m_invMassB,l=this.m_invIA,u=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits){var h=P.DotVV(this.m_axis,P.SubVV(s,i,P.s_t0))+this.m_a2*o-this.m_a1*r,_=this.m_motorMass*(this.m_motorSpeed-h),f=this.m_motorImpulse,d=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=g(this.m_motorImpulse+_,-d,d),_=this.m_motorImpulse-f;var p=P.MulSV(_,this.m_axis,n.SolveVelocityConstraints_s_P),m=_*this.m_a1,x=_*this.m_a2;i.SelfMulSub(a,p),r-=l*m,s.SelfMulAdd(c,p),o+=u*x}var A=P.DotVV(this.m_perp,P.SubVV(s,i,P.s_t0))+this.m_s2*o-this.m_s1*r,C=o-r;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit){var S=P.DotVV(this.m_axis,P.SubVV(s,i,P.s_t0))+this.m_a2*o-this.m_a1*r,b=n.SolveVelocityConstraints_s_f1.Copy(this.m_impulse),T=this.m_K.Solve33(-A,-C,-S,n.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(T),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=y(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=v(this.m_impulse.z,0));var w=-A-(this.m_impulse.z-b.z)*this.m_K.ez.x,E=-C-(this.m_impulse.z-b.z)*this.m_K.ez.y,B=this.m_K.Solve22(w,E,n.SolveVelocityConstraints_s_f2r);B.x+=b.x,B.y+=b.y,this.m_impulse.x=B.x,this.m_impulse.y=B.y,T.x=this.m_impulse.x-b.x,T.y=this.m_impulse.y-b.y,T.z=this.m_impulse.z-b.z,p=P.AddVV(P.MulSV(T.x,this.m_perp,P.s_t0),P.MulSV(T.z,this.m_axis,P.s_t1),n.SolveVelocityConstraints_s_P),m=T.x*this.m_s1+T.y+T.z*this.m_a1,x=T.x*this.m_s2+T.y+T.z*this.m_a2,i.SelfMulSub(a,p),r-=l*m,s.SelfMulAdd(c,p),o+=u*x}else{var M=this.m_K.Solve22(-A,-C,n.SolveVelocityConstraints_s_df2);this.m_impulse.x+=M.x,this.m_impulse.y+=M.y,p=P.MulSV(M.x,this.m_perp,n.SolveVelocityConstraints_s_P),m=M.x*this.m_s1+M.y,x=M.x*this.m_s2+M.y,i.SelfMulSub(a,p),r-=l*m,s.SelfMulAdd(c,p),o+=u*x}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),u=this.m_invMassA,h=this.m_invMassB,_=this.m_invIA,f=this.m_invIB,d=O.MulRV(o,this.m_lalcA,this.m_rA),p=O.MulRV(a,this.m_lalcB,this.m_rB),v=P.SubVV(P.AddVV(r,p,P.s_t0),P.AddVV(e,d,P.s_t1),n.SolvePositionConstraints_s_d),x=O.MulRV(o,this.m_localXAxisA,this.m_axis),A=P.CrossVV(P.AddVV(v,d,P.s_t0),x),C=P.CrossVV(p,x),S=O.MulRV(o,this.m_localYAxisA,this.m_perp),b=P.CrossVV(P.AddVV(v,d,P.s_t0),S),T=P.CrossVV(p,S),w=n.SolvePositionConstraints_s_impulse,E=P.DotVV(S,v),B=s-i-this.m_referenceAngle,M=m(E),R=m(B),I=!1,D=0;if(this.m_enableLimit){var V=P.DotVV(x,v);m(this.m_upperTranslation-this.m_lowerTranslation)<2*c?(D=g(V,-.2,.2),M=y(M,m(V)),I=!0):V<=this.m_lowerTranslation?(D=g(V-this.m_lowerTranslation+c,-.2,0),M=y(M,this.m_lowerTranslation-V),I=!0):V>=this.m_upperTranslation&&(D=g(V-this.m_upperTranslation-c,0,.2),M=y(M,V-this.m_upperTranslation),I=!0)}if(I){var L=u+h+_*b*b+f*T*T,F=_*b+f*T,N=_*b*A+f*T*C;0===(U=_+f)&&(U=1);var G=_*A+f*C,k=u+h+_*A*A+f*C*C,z=this.m_K3;z.ex.SetXYZ(L,F,N),z.ey.SetXYZ(F,U,G),z.ez.SetXYZ(N,G,k),w=z.Solve33(-E,-B,-D,w)}else{var U;L=u+h+_*b*b+f*T*T,F=_*b+f*T,0===(U=_+f)&&(U=1);var H=this.m_K2;H.ex.Set(L,F),H.ey.Set(F,U);var W=H.Solve(-E,-B,n.SolvePositionConstraints_s_impulse1);w.x=W.x,w.y=W.y,w.z=0}var j=P.AddVV(P.MulSV(w.x,S,P.s_t0),P.MulSV(w.z,x,P.s_t1),n.SolvePositionConstraints_s_P),X=w.x*b+w.y+w.z*A,q=w.x*T+w.y+w.z*C;return e.SelfMulSub(u,j),i-=_*X,r.SelfMulAdd(h,j),s+=f*q,t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,M<=c&&R<=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=P.SubVV(e,t,n.GetJointTranslation_s_d),r=this.m_bodyA.GetWorldVector(this.m_localXAxisA,n.GetJointTranslation_s_axis);return P.DotVV(i,r)},n.prototype.GetJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;P.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=O.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=O.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=P.AddVV(t.m_sweep.c,i,P.s_t0),s=P.AddVV(e.m_sweep.c,n,P.s_t1),o=P.SubVV(s,r,P.s_t2),a=t.GetWorldVector(this.m_localXAxisA,this.m_axis),c=t.m_linearVelocity,l=e.m_linearVelocity,u=t.m_angularVelocity,h=e.m_angularVelocity;return P.DotVV(o,P.CrossSV(u,a,P.s_t0))+P.DotVV(a,P.SubVV(P.AddVCrossSV(l,h,n,P.s_t0),P.AddVCrossSV(c,u,i,P.s_t1),P.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 P,n.InitVelocityConstraints_s_P=new P,n.SolveVelocityConstraints_s_P=new P,n.SolveVelocityConstraints_s_f2r=new P,n.SolveVelocityConstraints_s_f1=new D,n.SolveVelocityConstraints_s_df3=new D,n.SolveVelocityConstraints_s_df2=new P,n.SolvePositionConstraints_s_d=new P,n.SolvePositionConstraints_s_impulse=new D,n.SolvePositionConstraints_s_impulse1=new P,n.SolvePositionConstraints_s_P=new P,n.GetJointTranslation_s_pA=new P,n.GetJointTranslation_s_pB=new P,n.GetJointTranslation_s_d=new P,n.GetJointTranslation_s_axis=new P,n})(mi),Pi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_pulleyJoint)||this;return i.groundAnchorA=new P(-1,1),i.groundAnchorB=new P(1,1),i.localAnchorA=new P(-1,0),i.localAnchorB=new P(1,0),i.lengthA=0,i.lengthB=0,i.ratio=1,i.collideConnected=!0,i}return ti(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=P.DistanceVV(r,i),this.lengthB=P.DistanceVV(s,n),this.ratio=o},i})(pi),Ii=(function(t){function i(i){var n=t.call(this,i)||this;return n.m_groundAnchorA=new P,n.m_groundAnchorB=new P,n.m_lengthA=0,n.m_lengthB=0,n.m_localAnchorA=new P,n.m_localAnchorB=new P,n.m_constant=0,n.m_ratio=0,n.m_impulse=0,n.m_indexA=0,n.m_indexB=0,n.m_uA=new P,n.m_uB=new P,n.m_rA=new P,n.m_rB=new P,n.m_localCenterA=new P,n.m_localCenterB=new P,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new O,n.m_qB=new O,n.m_lalcA=new P,n.m_lalcB=new P,n.m_groundAnchorA.Copy(e(i.groundAnchorA,new P(-1,1))),n.m_groundAnchorB.Copy(e(i.groundAnchorB,new P(1,0))),n.m_localAnchorA.Copy(e(i.localAnchorA,new P(-1,0))),n.m_localAnchorB.Copy(e(i.localAnchorB,new P(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 ti(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,u=t.velocities[this.m_indexB].w,h=this.m_qA.SetAngle(n),_=this.m_qB.SetAngle(a);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),O.MulRV(h,this.m_lalcA,this.m_rA),P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),O.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(),d=this.m_uB.Length();f>10*c?this.m_uA.SelfMul(1/f):this.m_uA.SetZero(),d>10*c?this.m_uB.SelfMul(1/d):this.m_uB.SetZero();var p=P.CrossVV(this.m_rA,this.m_uA),m=P.CrossVV(this.m_rB,this.m_uB),v=this.m_invMassA+this.m_invIA*p*p,y=this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=v+this.m_ratio*this.m_ratio*y,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var g=P.MulSV(-this.m_impulse,this.m_uA,i.InitVelocityConstraints_s_PA),x=P.MulSV(-this.m_ratio*this.m_impulse,this.m_uB,i.InitVelocityConstraints_s_PB);r.SelfMulAdd(this.m_invMassA,g),s+=this.m_invIA*P.CrossVV(this.m_rA,g),l.SelfMulAdd(this.m_invMassB,x),u+=this.m_invIB*P.CrossVV(this.m_rB,x)}else this.m_impulse=0;t.velocities[this.m_indexA].w=s,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=P.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),a=P.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),c=-P.DotVV(this.m_uA,o)-this.m_ratio*P.DotVV(this.m_uB,a),l=-this.m_mass*c;this.m_impulse+=l;var u=P.MulSV(-l,this.m_uA,i.SolveVelocityConstraints_s_PA),h=P.MulSV(-this.m_ratio*l,this.m_uB,i.SolveVelocityConstraints_s_PB);e.SelfMulAdd(this.m_invMassA,u),n+=this.m_invIA*P.CrossVV(this.m_rA,u),r.SelfMulAdd(this.m_invMassB,h),s+=this.m_invIB*P.CrossVV(this.m_rB,h),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);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=O.MulRV(o,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=O.MulRV(a,this.m_lalcB,this.m_rB),h=this.m_uA.Copy(e).SelfAdd(l).SelfSub(this.m_groundAnchorA),_=this.m_uB.Copy(r).SelfAdd(u).SelfSub(this.m_groundAnchorB),f=h.Length(),d=_.Length();f>10*c?h.SelfMul(1/f):h.SetZero(),d>10*c?_.SelfMul(1/d):_.SetZero();var p=P.CrossVV(l,h),v=P.CrossVV(u,_),y=this.m_invMassA+this.m_invIA*p*p,g=this.m_invMassB+this.m_invIB*v*v,x=y+this.m_ratio*this.m_ratio*g;x>0&&(x=1/x);var A=this.m_constant-f-this.m_ratio*d,C=m(A),S=-x*A,b=P.MulSV(-S,h,i.SolvePositionConstraints_s_PA),T=P.MulSV(-this.m_ratio*S,_,i.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,b),n+=this.m_invIA*P.CrossVV(l,b),r.SelfMulAdd(this.m_invMassB,T),s+=this.m_invIB*P.CrossVV(u,T),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,C0&&(this.m_motorMass=1/this.m_motorMass),this.m_enableMotor&&!v||(this.m_motorImpulse=0),this.m_enableLimit&&!v){var y=o-i-this.m_referenceAngle;m(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-=d*(P.CrossVV(this.m_rA,g)+this.m_motorImpulse+this.m_impulse.z),a.SelfMulAdd(f,g),c+=p*(P.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=c},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,c=this.m_invMassB,l=this.m_invIA,u=this.m_invIB,h=l+u===0;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits&&!h){var _=o-r-this.m_motorSpeed,f=-this.m_motorMass*_,d=this.m_motorImpulse,p=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=g(this.m_motorImpulse+f,-p,p),r-=l*(f=this.m_motorImpulse-d),o+=u*f}if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!h){var m=P.SubVV(P.AddVCrossSV(s,o,this.m_rB,P.s_t0),P.AddVCrossSV(i,r,this.m_rA,P.s_t1),n.SolveVelocityConstraints_s_Cdot1),v=o-r,y=this.m_mass.Solve33(m.x,m.y,v,n.SolveVelocityConstraints_s_impulse_v3).SelfNeg();if(this.m_limitState===t.b2LimitState.e_equalLimits)this.m_impulse.SelfAdd(y);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit)if(this.m_impulse.z+y.z<0){var x=-m.x+this.m_impulse.z*this.m_mass.ez.x,A=-m.y+this.m_impulse.z*this.m_mass.ez.y,C=this.m_mass.Solve22(x,A,n.SolveVelocityConstraints_s_reduced_v2);y.x=C.x,y.y=C.y,y.z=-this.m_impulse.z,this.m_impulse.x+=C.x,this.m_impulse.y+=C.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(y);else this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z+y.z>0?(x=-m.x+this.m_impulse.z*this.m_mass.ez.x,A=-m.y+this.m_impulse.z*this.m_mass.ez.y,C=this.m_mass.Solve22(x,A,n.SolveVelocityConstraints_s_reduced_v2),y.x=C.x,y.y=C.y,y.z=-this.m_impulse.z,this.m_impulse.x+=C.x,this.m_impulse.y+=C.y,this.m_impulse.z=0):this.m_impulse.SelfAdd(y));var S=n.SolveVelocityConstraints_s_P.Set(y.x,y.y);i.SelfMulSub(a,S),r-=l*(P.CrossVV(this.m_rA,S)+y.z),s.SelfMulAdd(c,S),o+=u*(P.CrossVV(this.m_rB,S)+y.z)}else{var b=P.SubVV(P.AddVCrossSV(s,o,this.m_rB,P.s_t0),P.AddVCrossSV(i,r,this.m_rA,P.s_t1),n.SolveVelocityConstraints_s_Cdot_v2),T=this.m_mass.Solve22(-b.x,-b.y,n.SolveVelocityConstraints_s_impulse_v2);this.m_impulse.x+=T.x,this.m_impulse.y+=T.y,i.SelfMulSub(a,T),r-=l*P.CrossVV(this.m_rA,T),s.SelfMulAdd(c,T),o+=u*P.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,u=this.m_qA.SetAngle(s),h=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 d=a-s-this.m_referenceAngle,p=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var v=g(d-this.m_lowerAngle,-.13962634015955555,.13962634015955555);p=-this.m_motorMass*v,_=m(v)}else this.m_limitState===t.b2LimitState.e_atLowerLimit?(_=-(v=d-this.m_lowerAngle),v=g(v+l,-.13962634015955555,0),p=-this.m_motorMass*v):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(_=v=d-this.m_upperAngle,v=g(v-l,0,.13962634015955555),p=-this.m_motorMass*v);s-=this.m_invIA*p,a+=this.m_invIB*p}u.SetAngle(s),h.SetAngle(a),P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var y=O.MulRV(u,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var x=O.MulRV(h,this.m_lalcB,this.m_rB),A=P.SubVV(P.AddVV(o,x,P.s_t0),P.AddVV(r,y,P.s_t1),n.SolvePositionConstraints_s_C_v2);i=A.Length();var C=this.m_invMassA,S=this.m_invMassB,b=this.m_invIA,T=this.m_invIB,w=this.m_K;w.ex.x=C+S+b*y.y*y.y+T*x.y*x.y,w.ex.y=-b*y.x*y.y-T*x.x*x.y,w.ey.x=w.ex.y,w.ey.y=C+S+b*y.x*y.x+T*x.x*x.x;var E=w.Solve(A.x,A.y,n.SolvePositionConstraints_s_impulse).SelfNeg();return r.SelfMulSub(C,E),s-=b*P.CrossVV(y,E),o.SelfMulAdd(S,E),a+=T*P.CrossVV(x,E),e.positions[this.m_indexA].a=s,e.positions[this.m_indexB].a=a,i<=c&&_<=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 P,n.SolveVelocityConstraints_s_P=new P,n.SolveVelocityConstraints_s_Cdot_v2=new P,n.SolveVelocityConstraints_s_Cdot1=new P,n.SolveVelocityConstraints_s_impulse_v3=new D,n.SolveVelocityConstraints_s_reduced_v2=new P,n.SolveVelocityConstraints_s_impulse_v2=new P,n.SolvePositionConstraints_s_C_v2=new P,n.SolvePositionConstraints_s_impulse=new P,n})(mi),Li=(function(e){function i(){var i=e.call(this,t.b2JointType.e_ropeJoint)||this;return i.localAnchorA=new P(-1,0),i.localAnchorB=new P(1,0),i.maxLength=0,i}return ti(i,e),i})(pi),Oi=(function(i){function n(n){var r=i.call(this,n)||this;return r.m_localAnchorA=new P,r.m_localAnchorB=new P,r.m_maxLength=0,r.m_length=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_u=new P,r.m_rA=new P,r.m_rB=new P,r.m_localCenterA=new P,r.m_localCenterB=new P,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 O,r.m_qB=new O,r.m_lalcA=new P,r.m_lalcB=new P,r.m_localAnchorA.Copy(e(n.localAnchorA,new P(-1,0))),r.m_localAnchorB.Copy(e(n.localAnchorB,new P(1,0))),r.m_maxLength=e(n.maxLength,0),r}return ti(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,u=e.velocities[this.m_indexB].v,h=e.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(r),f=this.m_qB.SetAngle(l);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),O.MulRV(_,this.m_lalcA,this.m_rA),P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),O.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 d=this.m_length-this.m_maxLength;if(this.m_state=d>0?t.b2LimitState.e_atUpperLimit:t.b2LimitState.e_inactiveLimit,!(this.m_length>c))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.SelfMul(1/this.m_length);var p=P.CrossVV(this.m_rA,this.m_u),m=P.CrossVV(this.m_rB,this.m_u),v=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==v?1/v:0,e.step.warmStarting){this.m_impulse*=e.step.dtRatio;var y=P.MulSV(this.m_impulse,this.m_u,n.InitVelocityConstraints_s_P);s.SelfMulSub(this.m_invMassA,y),o-=this.m_invIA*P.CrossVV(this.m_rA,y),u.SelfMulAdd(this.m_invMassB,y),h+=this.m_invIB*P.CrossVV(this.m_rB,y)}else this.m_impulse=0;e.velocities[this.m_indexA].w=o,e.velocities[this.m_indexB].w=h},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=P.AddVCrossSV(e,i,this.m_rA,n.SolveVelocityConstraints_s_vpA),a=P.AddVCrossSV(r,s,this.m_rB,n.SolveVelocityConstraints_s_vpB),c=this.m_length-this.m_maxLength,l=P.DotVV(this.m_u,P.SubVV(a,o,P.s_t0));c<0&&(l+=t.step.inv_dt*c);var u=-this.m_mass*l,h=this.m_impulse;this.m_impulse=v(0,this.m_impulse+u),u=this.m_impulse-h;var _=P.MulSV(u,this.m_u,n.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,_),i-=this.m_invIA*P.CrossVV(this.m_rA,_),r.SelfMulAdd(this.m_invMassB,_),s+=this.m_invIB*P.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);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=O.MulRV(o,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=O.MulRV(a,this.m_lalcB,this.m_rB),h=this.m_u.Copy(r).SelfAdd(u).SelfSub(e).SelfSub(l),_=h.Normalize(),f=_-this.m_maxLength;f=g(f,0,.2);var d=-this.m_mass*f,p=P.MulSV(d,h,n.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,p),i-=this.m_invIA*P.CrossVV(l,p),r.SelfMulAdd(this.m_invMassB,p),s+=this.m_invIB*P.CrossVV(u,p),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,_-this.m_maxLength0){p.GetInverse22(this.m_mass);var m=f+d,v=m>0?1/m:0,y=o-e-this.m_referenceAngle,g=2*s*this.m_frequencyHz,x=2*v*this.m_dampingRatio*g,A=v*g*g,C=t.step.dt;this.m_gamma=C*(x+C*A),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=y*C*A*this.m_gamma,m+=this.m_gamma,this.m_mass.ez.z=0!==m?1/m:0}else p.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse.SelfMul(t.step.dtRatio);var S=i.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);n.SelfMulSub(h,S),r-=f*(P.CrossVV(this.m_rA,S)+this.m_impulse.z),a.SelfMulAdd(_,S),c+=d*(P.CrossVV(this.m_rB,S)+this.m_impulse.z)}else this.m_impulse.SetZero();t.velocities[this.m_indexA].w=r,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=this.m_invMassA,a=this.m_invMassB,c=this.m_invIA,l=this.m_invIB;if(this.m_frequencyHz>0){var u=s-n,h=-this.m_mass.ez.z*(u+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=h,n-=c*h,s+=l*h;var _=P.SubVV(P.AddVCrossSV(r,s,this.m_rB,P.s_t0),P.AddVCrossSV(e,n,this.m_rA,P.s_t1),i.SolveVelocityConstraints_s_Cdot1),f=L.MulM33XY(this.m_mass,_.x,_.y,i.SolveVelocityConstraints_s_impulse1).SelfNeg();this.m_impulse.x+=f.x,this.m_impulse.y+=f.y;var d=f;e.SelfMulSub(o,d),n-=c*P.CrossVV(this.m_rA,d),r.SelfMulAdd(a,d),s+=l*P.CrossVV(this.m_rB,d)}else{_=P.SubVV(P.AddVCrossSV(r,s,this.m_rB,P.s_t0),P.AddVCrossSV(e,n,this.m_rA,P.s_t1),i.SolveVelocityConstraints_s_Cdot1),u=s-n;var p=L.MulM33XYZ(this.m_mass,_.x,_.y,u,i.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(p),d=i.SolveVelocityConstraints_s_P.Set(p.x,p.y),e.SelfMulSub(o,d),n-=c*(P.CrossVV(this.m_rA,d)+p.z),r.SelfMulAdd(a,d),s+=l*(P.CrossVV(this.m_rB,d)+p.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),u=this.m_invMassA,h=this.m_invMassB,_=this.m_invIA,f=this.m_invIB;P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var d=O.MulRV(o,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p,v,y=O.MulRV(a,this.m_lalcB,this.m_rB),g=this.m_K;if(g.ex.x=u+h+d.y*d.y*_+y.y*y.y*f,g.ey.x=-d.y*d.x*_-y.y*y.x*f,g.ez.x=-d.y*_-y.y*f,g.ex.y=g.ey.x,g.ey.y=u+h+d.x*d.x*_+y.x*y.x*f,g.ez.y=d.x*_+y.x*f,g.ex.z=g.ez.x,g.ey.z=g.ez.y,g.ez.z=_+f,this.m_frequencyHz>0){p=(A=P.SubVV(P.AddVV(r,y,P.s_t0),P.AddVV(e,d,P.s_t1),i.SolvePositionConstraints_s_C1)).Length(),v=0;var x=g.Solve22(A.x,A.y,i.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(u,x),n-=_*P.CrossVV(d,x),r.SelfMulAdd(h,x),s+=f*P.CrossVV(y,x)}else{var A=P.SubVV(P.AddVV(r,y,P.s_t0),P.AddVV(e,d,P.s_t1),i.SolvePositionConstraints_s_C1),C=s-n-this.m_referenceAngle;p=A.Length(),v=m(C);var S=g.Solve33(A.x,A.y,C,i.SolvePositionConstraints_s_impulse).SelfNeg();x=i.SolvePositionConstraints_s_P.Set(S.x,S.y),e.SelfMulSub(u,x),n-=_*(P.CrossVV(this.m_rA,x)+S.z),r.SelfMulAdd(h,x),s+=f*(P.CrossVV(this.m_rB,x)+S.z)}return t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,p<=c&&v<=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 P,i.SolveVelocityConstraints_s_Cdot1=new P,i.SolveVelocityConstraints_s_impulse1=new P,i.SolveVelocityConstraints_s_impulse=new D,i.SolveVelocityConstraints_s_P=new P,i.SolvePositionConstraints_s_C1=new P,i.SolvePositionConstraints_s_P=new P,i.SolvePositionConstraints_s_impulse=new D,i})(mi),Gi=(function(e){function i(){var i=e.call(this,t.b2JointType.e_wheelJoint)||this;return i.localAnchorA=new P(0,0),i.localAnchorB=new P(0,0),i.localAxisA=new P(1,0),i.enableMotor=!1,i.maxMotorTorque=0,i.motorSpeed=0,i.frequencyHz=2,i.dampingRatio=.7,i}return ti(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})(pi),ki=(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 P,n.m_localAnchorB=new P,n.m_localXAxisA=new P,n.m_localYAxisA=new P,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 P,n.m_localCenterB=new P,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_ax=new P,n.m_ay=new P,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 O,n.m_qB=new O,n.m_lalcA=new P,n.m_lalcB=new P,n.m_rA=new P,n.m_rB=new P,n.m_frequencyHz=e(i.frequencyHz,2),n.m_dampingRatio=e(i.dampingRatio,.7),n.m_localAnchorA.Copy(e(i.localAnchorA,P.ZERO)),n.m_localAnchorB.Copy(e(i.localAnchorB,P.ZERO)),n.m_localXAxisA.Copy(e(i.localAxisA,P.UNITX)),P.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 ti(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,c=t.positions[this.m_indexA].a,l=t.velocities[this.m_indexA].v,u=t.velocities[this.m_indexA].w,h=t.positions[this.m_indexB].c,_=t.positions[this.m_indexB].a,f=t.velocities[this.m_indexB].v,d=t.velocities[this.m_indexB].w,p=this.m_qA.SetAngle(c),m=this.m_qB.SetAngle(_);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var v=O.MulRV(p,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var y=O.MulRV(m,this.m_lalcB,this.m_rB),g=P.SubVV(P.AddVV(h,y,P.s_t0),P.AddVV(a,v,P.s_t1),i.InitVelocityConstraints_s_d);if(O.MulRV(p,this.m_localYAxisA,this.m_ay),this.m_sAy=P.CrossVV(P.AddVV(g,v,P.s_t0),this.m_ay),this.m_sBy=P.CrossVV(y,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){O.MulRV(p,this.m_localXAxisA,this.m_ax),this.m_sAx=P.CrossVV(P.AddVV(g,v,P.s_t0),this.m_ax),this.m_sBx=P.CrossVV(y,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=P.DotVV(g,this.m_ax),C=2*s*this.m_frequencyHz,S=2*this.m_springMass*this.m_dampingRatio*C,b=this.m_springMass*C*C,T=t.step.dt;this.m_gamma=T*(S+T*b),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=A*T*b*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=P.AddVV(P.MulSV(this.m_impulse,this.m_ay,P.s_t0),P.MulSV(this.m_springImpulse,this.m_ax,P.s_t1),i.InitVelocityConstraints_s_P),E=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,B=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;l.SelfMulSub(this.m_invMassA,w),u-=this.m_invIA*E,f.SelfMulAdd(this.m_invMassB,w),d+=this.m_invIB*B}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;t.velocities[this.m_indexA].w=u,t.velocities[this.m_indexB].w=d},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,c=t.velocities[this.m_indexB].v,l=t.velocities[this.m_indexB].w,u=P.DotVV(this.m_ax,P.SubVV(c,o,P.s_t0))+this.m_sBx*l-this.m_sAx*a,h=-this.m_springMass*(u+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=h;var _=P.MulSV(h,this.m_ax,i.SolveVelocityConstraints_s_P),f=h*this.m_sAx,d=h*this.m_sBx;o.SelfMulSub(e,_),a-=r*f,c.SelfMulAdd(n,_),u=(l+=s*d)-a-this.m_motorSpeed,h=-this.m_motorMass*u;var p=this.m_motorImpulse,m=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=g(this.m_motorImpulse+h,-m,m),a-=r*(h=this.m_motorImpulse-p),l+=s*h,u=P.DotVV(this.m_ay,P.SubVV(c,o,P.s_t0))+this.m_sBy*l-this.m_sAy*a,h=-this.m_mass*u,this.m_impulse+=h,_=P.MulSV(h,this.m_ay,i.SolveVelocityConstraints_s_P),f=h*this.m_sAy,d=h*this.m_sBy,o.SelfMulSub(e,_),a-=r*f,c.SelfMulAdd(n,_),l+=s*d,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);P.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=O.MulRV(o,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u,h=O.MulRV(a,this.m_lalcB,this.m_rB),_=P.AddVV(P.SubVV(r,e,P.s_t0),P.SubVV(h,l,P.s_t1),i.SolvePositionConstraints_s_d),f=O.MulRV(o,this.m_localYAxisA,this.m_ay),d=P.CrossVV(P.AddVV(_,l,P.s_t0),f),p=P.CrossVV(h,f),v=P.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;u=0!==y?-v/y:0;var g=P.MulSV(u,f,i.SolvePositionConstraints_s_P),x=u*d,A=u*p;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,m(v)<=c},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 P),n=e.GetWorldPoint(this.m_localAnchorB,new P),r=P.SubVV(n,i,new P),s=t.GetWorldVector(this.m_localXAxisA,new P);return P.DotVV(r,s)},i.prototype.GetPrismaticJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;P.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=O.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);P.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=O.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=P.AddVV(t.m_sweep.c,i,P.s_t0),s=P.AddVV(e.m_sweep.c,n,P.s_t1),o=P.SubVV(s,r,P.s_t2),a=t.GetWorldVector(this.m_localXAxisA,new P),c=t.m_linearVelocity,l=e.m_linearVelocity,u=t.m_angularVelocity,h=e.m_angularVelocity;return P.DotVV(o,P.CrossSV(u,a,P.s_t0))+P.DotVV(a,P.SubVV(P.AddVCrossSV(l,h,n,P.s_t0),P.AddVCrossSV(c,u,i,P.s_t1),P.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 P,i.InitVelocityConstraints_s_P=new P,i.SolveVelocityConstraints_s_P=new P,i.SolvePositionConstraints_s_d=new P,i.SolvePositionConstraints_s_P=new P,i})(mi);function zi(t,e){return b(t*e)}function Ui(t,e){return t>e?t:e}var Hi,Wi=function(t){this.prev=null,this.next=null,this.contact=t},ji=(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 gt,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new gt,this.m_nodeA=new Wi(this),this.m_nodeB=new Wi(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=zi(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=Ui(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=zi(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=Ui(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(),c=this.m_fixtureB.GetBody(),l=a.GetTransform(),u=c.GetTransform();if(o){var h=this.m_fixtureA.GetShape(),_=this.m_fixtureB.GetShape();i=Rt(h,this.m_indexA,_,this.m_indexB,l,u),this.m_manifold.pointCount=0}else{this.Evaluate(this.m_manifold,l,u),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})(),en=(function(){function t(){}return t.prototype.SayGoodbyeJoint=function(){},t.prototype.SayGoodbyeFixture=function(){},t.prototype.SayGoodbyeParticleGroup=function(){},t.prototype.SayGoodbyeParticle=function(){},t})(),nn=(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(){return!0},e.prototype.ShouldCollideParticleParticle=function(){return!0},e.b2_defaultFilter=new e,e})(),rn=function(){this.normalImpulses=p(o),this.tangentImpulses=p(o),this.count=0},sn=(function(){function t(){}return t.prototype.BeginContact=function(){},t.prototype.EndContact=function(){},t.prototype.BeginContactFixtureParticle=function(){},t.prototype.EndContactFixtureParticle=function(){},t.prototype.BeginContactParticleParticle=function(){},t.prototype.EndContactParticleParticle=function(){},t.prototype.PreSolve=function(){},t.prototype.PostSolve=function(){},t.b2_defaultListener=new t,t})(),on=(function(){function t(){}return t.prototype.ReportFixture=function(){return!0},t.prototype.ReportParticle=function(){return!1},t.prototype.ShouldQueryParticleSystem=function(){return!0},t})(),an=(function(){function t(){}return t.prototype.ReportFixture=function(t,e,i,n){return n},t.prototype.ReportParticle=function(){return 0},t.prototype.ShouldQueryParticleSystem=function(){return!0},t})(),cn=(function(){function e(){this.m_broadPhase=new Lt,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=nn.b2_defaultFilter,this.m_contactListener=sn.b2_defaultListener,this.m_allocator=null,this.m_contactFactory=new tn(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 c=a.GetContactList();c;){if(c.other===o){var l=c.contact.GetFixtureA(),u=c.contact.GetFixtureB(),h=c.contact.GetChildIndexA(),_=c.contact.GetChildIndexB();if(l===i&&u===n&&h===r&&_===s)return;if(l===n&&u===i&&h===s&&_===r)return}c=c.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=(u=e).m_next,this.Destroy(u);continue}e.m_filterFlag=!1}var c=o.IsAwake()&&o.m_type!==t.b2BodyType.b2_staticBody,l=a.IsAwake()&&a.m_type!==t.b2BodyType.b2_staticBody;if(c||l){var u,h=i.m_proxies[r].treeNode,_=n.m_proxies[s].treeNode;Tt(h.aabb,_.aabb)?(e.Update(this.m_contactListener),e=e.m_next):(e=(u=e).m_next,this.Destroy(u))}else e=e.m_next}},e})(),ln=(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})(),un=(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})(),hn=(function(){function t(){this.c=new P,this.a=0}return t.MakeArray=function(e){return d(e,(function(){return new t}))},t})(),_n=(function(){function t(){this.v=new P,this.w=0}return t.MakeArray=function(e){return d(e,(function(){return new t}))},t})(),fn=function(){this.step=new un},dn=(function(){function t(){this.rA=new P,this.rB=new P,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}return t.MakeArray=function(e){return d(e,(function(){return new t}))},t})(),pn=(function(){function t(){this.points=dn.MakeArray(o),this.normal=new P,this.tangent=new P,this.normalMass=new V,this.K=new V,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 d(e,(function(){return new t}))},t})(),mn=(function(){function e(){this.localPoints=P.MakeArray(o),this.localNormal=new P,this.localPoint=new P,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new P,this.localCenterB=new P,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 d(t,(function(){return new e}))},e})(),vn=function(){this.step=new un,this.count=0,this.allocator=null},yn=(function(){function e(){this.normal=new P,this.point=new P,this.separation=0}return e.prototype.Initialize=function(i,n,r,s){var o=e.Initialize_s_pointA,a=e.Initialize_s_pointB,c=e.Initialize_s_planePoint,l=e.Initialize_s_clipPoint;switch(i.type){case t.b2ManifoldType.e_circles:F.MulXV(n,i.localPoint,o),F.MulXV(r,i.localPoints[0],a),P.SubVV(a,o,this.normal).SelfNormalize(),P.MidVV(o,a,this.point),this.separation=P.DotVV(P.SubVV(a,o,P.s_t0),this.normal)-i.radiusA-i.radiusB;break;case t.b2ManifoldType.e_faceA:O.MulRV(n.q,i.localNormal,this.normal),F.MulXV(n,i.localPoint,c),F.MulXV(r,i.localPoints[s],l),this.separation=P.DotVV(P.SubVV(l,c,P.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(l);break;case t.b2ManifoldType.e_faceB:O.MulRV(r.q,i.localNormal,this.normal),F.MulXV(r,i.localPoint,c),F.MulXV(n,i.localPoints[s],l),this.separation=P.DotVV(P.SubVV(l,c,P.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(l),this.normal.SelfNeg()}},e.Initialize_s_pointA=new P,e.Initialize_s_pointB=new P,e.Initialize_s_planePoint=new P,e.Initialize_s_clipPoint=new P,e})(),gn=(function(){function t(){this.m_step=new un,this.m_allocator=null,this.m_positionConstraints=mn.MakeArray(1024),this.m_velocityConstraints=pn.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/I:0;var D=s.tangent,V=P.CrossVV(B.rA,D),L=P.CrossVV(B.rB,D),F=_+f+d*V*V+p*L*L;B.tangentMass=F>0?1/F:0,B.velocityBias=0;var N=P.DotVV(s.normal,P.SubVV(P.AddVCrossSV(b,T,B.rB,P.s_t0),P.AddVCrossSV(x,A,B.rA,P.s_t1),P.s_t0));N<-1&&(B.velocityBias+=-s.restitution*N)}s.pointCount}},t.prototype.WarmStart=function(){for(var e=t.WarmStart_s_P,i=0;i0?-R/V:0;P.MulSV(L,E,o),C.SelfMulSub(d,o),S-=p*P.CrossVV(r,o),b.SelfMulAdd(y,o),T+=x*P.CrossVV(s,o)}this.m_positions[h].a=S,this.m_positions[_].a=T}return a>-3*c},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,u=0,h=0;h0?-D/F:0;P.MulSV(N,M,l),b.SelfMulSub(x,l),T-=A*P.CrossVV(o,l),w.SelfMulAdd(C,l),E+=S*P.CrossVV(a,l)}this.m_positions[f].a=T,this.m_positions[d].a=E}return u>=-1.5*c},t.InitializeVelocityConstraints_s_xfA=new F,t.InitializeVelocityConstraints_s_xfB=new F,t.InitializeVelocityConstraints_s_worldManifold=new xt,t.WarmStart_s_P=new P,t.SolveVelocityConstraints_s_dv=new P,t.SolveVelocityConstraints_s_dv1=new P,t.SolveVelocityConstraints_s_dv2=new P,t.SolveVelocityConstraints_s_P=new P,t.SolveVelocityConstraints_s_a=new P,t.SolveVelocityConstraints_s_b=new P,t.SolveVelocityConstraints_s_x=new P,t.SolveVelocityConstraints_s_d=new P,t.SolveVelocityConstraints_s_P1=new P,t.SolveVelocityConstraints_s_P2=new P,t.SolveVelocityConstraints_s_P1P2=new P,t.SolvePositionConstraints_s_xfA=new F,t.SolvePositionConstraints_s_xfB=new F,t.SolvePositionConstraints_s_psm=new yn,t.SolvePositionConstraints_s_rA=new P,t.SolvePositionConstraints_s_rB=new P,t.SolvePositionConstraints_s_P=new P,t.SolveTOIPositionConstraints_s_xfA=new F,t.SolveTOIPositionConstraints_s_xfB=new F,t.SolveTOIPositionConstraints_s_psm=new yn,t.SolveTOIPositionConstraints_s_rA=new P,t.SolveTOIPositionConstraints_s_rB=new P,t.SolveTOIPositionConstraints_s_P=new P,t})(),xn=(function(){function e(){this.m_allocator=null,this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=hn.MakeArray(1024),this.m_velocities=_n.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 C=2/A.Length();_.SelfMul(C)}var S=c*f;S*S>2.4674011002726646&&(f*=C=1.570796326795/m(S)),x.x+=c*_.x,x.y+=c*_.y,h+=c*f,this.m_positions[l].a=h,this.m_velocities[l].w=f}a.Reset();var b=!1;for(l=0;l.0012184696791469947||P.DotVV(u.m_linearVelocity,u.m_linearVelocity)>1e-4?(u.m_sleepTime=0,M=0):(u.m_sleepTime+=c,M=v(M,u.m_sleepTime)));if(M>=.5&&b)for(l=0;l4){var d=2/f.Length();h.SelfMul(d)}var p=c*_;p*p>2.4674011002726646&&(_*=d=1.570796326795/m(p)),l.SelfMulAdd(c,h),u+=c*_,this.m_positions[r].a=u,this.m_velocities[r].w=_;var v=this.m_bodies[r];v.m_sweep.c.Copy(l),v.m_sweep.a=u,v.m_linearVelocity.Copy(h),v.m_angularVelocity=_,v.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)}for(this.m_inertia=0,this.m_angularVelocity=0,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 P,e})(),En=(function(){function t(t){this.m_front=0,this.m_back=0,this.m_capacity=0,this.m_buffer=d(t,(function(){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(d(this.m_capacity,(function(){return null}))),this.m_capacity*=2):(this.m_buffer.concat(d(1,(function(){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=d(e,(function(){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 P(+i,+i),o=new P(-i,-i),a=0,c=0;c=0&&h>=0&&u0&&l.Push(new t.Task(u-1,h,_-1,f)),h>0&&l.Push(new t.Task(u,h-1,_-this.m_countX,f)),ug*g+x*x&&(this.m_diagram[_]=m,u>0&&l.Push(new t.Task(u-1,h,_-1,m)),h>0&&l.Push(new t.Task(u,h-1,_-this.m_countX,m)),u=i)break;Mn(t,c,i)}}if(0===o)break;r=i,i=s[--o]}return t}function In(t,e,i,n){return void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===n&&(n=Rn),Pn(t,e,i,n)}function Dn(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 Ln(t,e,i,n,r){void 0===r&&(r=Rn);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 On(t,e,i,n){for(var r=i;e!==r;)Mn(t,e++,r++),r===n?r=i:e===i&&(i=r)}function Fn(t,e,i,n){if(e===i)return i;for(var r=e;++e!==i;)n(t[r],t[e])||Mn(t,++r,e);return++r}(function(t){t.Generator=function(){this.center=new P,this.tag=0,this.necessary=!1};t.Task=function(t,e,i,n){this.m_x=t,this.m_y=e,this.m_i=i,this.m_generator=n}})(Bn||(Bn={}));var Nn=(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(){return!1},e.prototype.ReportFixtureAndParticle=function(){},e})(on),kn=(function(){function t(){this.indexA=0,this.indexB=0,this.weight=0,this.normal=new P,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&&m(this.weight-t.weight)<.01&&P.DistanceSquaredVV(this.normal,t.normal)<1e-4},t})(),zn=function(){this.index=0,this.weight=0,this.normal=new P,this.mass=0},Un=function(){this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0},Hn=function(){this.indexA=0,this.indexB=0,this.indexC=0,this.flags=0,this.strength=0,this.pa=new P(0,0),this.pb=new P(0,0),this.pc=new P(0,0),this.ka=0,this.kb=0,this.kc=0,this.s=0},Wn=(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 Nn(function(){return 0}),this.m_proxyBuffer=new Nn(function(){return new n.Proxy}),this.m_contactBuffer=new Nn(function(){return new kn}),this.m_bodyContactBuffer=new Nn(function(){return new zn}),this.m_pairBuffer=new Nn(function(){return new Un}),this.m_triadBuffer=new Nn(function(){return new Hn}),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 Wn,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 h;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 P).Copy(e(t.position,P.ZERO)),this.m_velocityBuffer.data[n]=(this.m_velocityBuffer.data[n]||new P).Copy(e(t.velocity,P.ZERO)),this.m_weightBuffer[n]=0,this.m_forceBuffer[n]=(this.m_forceBuffer[n]||new P).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 c=e(t.group,null);return this.m_groupBuffer[n]=c,c&&(c.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,P.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 P).Copy(i).SelfMul(1/r),o=t;o=0;){var m=P.SubVV(e,l[h],s),y=P.DotVV(m,f),g=y*y-d*(P.DotVV(m,m)-this.m_squaredDiameter);if(g>=0){var x=b(g),A=(-y-x)/d;if(A>_)continue;if(A<0&&((A=(-y+x)/d)<0||A>_))continue;var C=P.AddVMulSV(m,A,f,a);C.Normalize();var S=t.ReportParticle(this,h,P.AddVMulSV(e,A,f,c),C,A);if((_=v(_,S))<=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,this.m_def.maxCount),t=e(t,this.m_flagsBuffer.userSuppliedCapacity),t=e(t,this.m_positionBuffer.userSuppliedCapacity),t=e(t,this.m_velocityBuffer.userSuppliedCapacity),t=e(t,this.m_colorBuffer.userSuppliedCapacity),t=e(t,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 An;r.flags=e(t.flags,0),F.MulXV(i,n,r.position),P.AddVV(e(t.linearVelocity,P.ZERO),P.CrossSV(e(t.angularVelocity,0),P.SubVV(r.position,e(t.position,P.ZERO),P.s_t0),P.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,c=n.CreateParticlesStrokeShapeForGroup_s_p,l=e(r.stride,0);0===l&&(l=this.GetParticleStride());for(var u=0,h=i.GetChildCount(),_=0;_=e&&f=e&&dg||P.DotVV(m,m)>g||P.DotVV(y,y)>g)return;var x=T.m_groupBuffer[t],A=T.m_groupBuffer[e],C=T.m_groupBuffer[i],S=T.m_triadBuffer.data[T.m_triadBuffer.Append()];S.indexA=t,S.indexB=e,S.indexC=i,S.flags=l|u|h,S.strength=v(v(x?x.m_strength:1,A?A.m_strength:1),C?C.m_strength:1);var b=(_.x+f.x+d.x)/3,w=(_.y+f.y+d.y)/3;S.pa.x=_.x-b,S.pa.y=_.y-w,S.pb.x=f.x-b,S.pb.y=f.y-w,S.pc.x=d.x-b,S.pc.y=d.y-w,S.ka=-P.DotVV(y,p),S.kb=-P.DotVV(p,m),S.kc=-P.DotVV(m,y),S.s=P.CrossVV(_,f)+P.CrossVV(f,d)+P.CrossVV(d,_)}})),In(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,m=0;mC&&(this.m_depthBuffer[s]=C,v=!0),A>S&&(this.m_depthBuffer[o]=S,v=!0)}if(!v)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(b(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=P.MulSV(t.dt*this.m_def.gravityScale,this.m_world.GetGravity(),e),s=0;s=0;){var F=p[O],N=this.m_groupBuffer[O];if(B!==N&&M!==N){var G=this.GetLinearVelocity(N,O,F,c),k=P.SubVV(F,T,l),z=P.SubVV(G,R,u),U=P.CrossVV(V,z),H=P.CrossVV(D,z)-P.CrossVV(k,V),W=P.CrossVV(D,k),j=void 0,X=void 0,q=h,Y=_;if(0===U){if(0===H)continue;if(!((X=-W/H)>=0&&X=0&&j<=1))continue}else{var J=H*H-4*W*U;if(J<0)continue;var Z=b(J),K=(-H-Z)/(2*U),Q=(-H+Z)/(2*U);if(K>Q){var $=K;K=Q,Q=$}if(X=K,P.AddVMulSV(D,X,V,q),P.AddVMulSV(k,X,z,Y),j=P.DotVV(q,Y)/P.DotVV(q,q),!(X>=0&&X=0&&j<=1)){if(!((X=Q)>=0&&X=0&&j<=1))continue}}var tt=f;tt.x=R.x+j*V.x-G.x,tt.y=R.y+j*V.y-G.y;var et=P.MulSV(g,tt,d);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+=P.CrossVV(P.SubVV(F,N.GetCenter(),P.s_t0),et)/nt)}else m[O].SelfAdd(tt);this.ParticleApplyForce(O,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 u=p.body,h=p.mass,_=r[l],f=p.normal,d=P.MulSV(o*h*(m-.25),f,i);s[l].SelfMulSub(a,d),u.ApplyLinearImpulse(d,_,!0)}}for(c=0;c.25&&(l=p.indexA,u=p.indexB,f=p.normal,d=P.MulSV(o*(m-.25),f,i),s[l].SelfSub(d),s[u].SelfAdd(d))}},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?(x=v(x,S),A=y(A,S+1)):C=!0}xr: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=P.AddVV(r.m_positionBuffer.data[n.index],a,e);if(!n.fixture.TestPoint(l)){for(var u=n.fixture.GetShape().GetChildCount(),h=0;hthis.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]=P.CrossVV(P.SubVV(o,s,P.s_t0),a)},n.prototype.InitDampingParameterWithRigidGroupOrParticle=function(e,i,n,r,s,o,a,c){if(s&&r)this.InitDampingParameter(e,i,n,s.GetMass(),s.GetInertia(),s.GetCenter(),a,c);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,c)}},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 h},t})();e.InsideBoundsEnumerator=r;e.ParticleListNode=function(){this.next=null,this.count=0,this.index=0};var s=(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.prototype.GetValidBuffer=function(){return[]},t.prototype.GetBuffer=function(){return[]},t.prototype.SetCount=function(){},t})();e.FixedSetAllocator=s;e.FixtureParticle=function(t,e){this.second=h,this.first=t,this.second=e};var o=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ti(e,t),e.prototype.Initialize=function(){},e.prototype.Find=function(){return h},e})(e.FixedSetAllocator);e.FixtureParticleSet=o;e.ParticlePair=function(t,e){this.first=h,this.second=h,this.first=t,this.second=e};var a=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ti(e,t),e.prototype.Initialize=function(){},e.prototype.Find=function(){return h},e})(e.FixedSetAllocator);e.b2ParticlePairSet=a;var l=(function(){function t(){}return t.prototype.IsNecessary=function(){return!0},t.prototype.ShouldCreatePair=function(){return!0},t.prototype.ShouldCreateTriad=function(){return!0},t})();e.ConnectionFilter=l;var u=(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 ti(e,t),e.prototype.ReportFixture=function(){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})(on);e.DestroyParticlesInShapeCallback=u;var _=(function(t){function e(e){var i=t.call(this)||this;return i.m_threshold=0,i.m_threshold=e,i}return ti(e,t),e.prototype.ShouldCreatePair=function(t,e){return t0?1/_:0,p=f>0?1/f:0,m=this.m_system.m_flagsBuffer.data[r]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),v=P.SubVV(a,h,o),y=P.CrossVV(v,c),g=m+d+p*y*y,x=this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];x.index=r,x.body=u,x.fixture=i,x.weight=1-l*this.m_system.m_inverseDiameter,x.normal.Copy(c.SelfNeg()),x.mass=g>0?1/g:0,this.m_system.DetectStuckParticle(r)}},n.ReportFixtureAndParticle_s_n=new P,n.ReportFixtureAndParticle_s_rp=new P,n})(Gn);e.UpdateBodyContactsCallback=p;var m=(function(i){function n(t,e){var n=i.call(this,t)||this;return n.m_step=e,n}return ti(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,u=e.SolveCollisionCallback.ReportFixtureAndParticle_s_v,h=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],d=this.m_system.m_velocityBuffer.data[r],p=o,m=a;if(0===this.m_system.m_iterationIndex){var v=F.MulTXV(_.m_xf0,f,s);i.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(v.SelfSub(_.GetLocalCenter()),O.MulRV(_.m_xf0.q,v,v),O.MulTRV(_.m_xf.q,v,v),v.SelfAdd(_.GetLocalCenter())),F.MulXV(_.m_xf,v,m.p1)}else m.p1.Copy(f);if(P.AddVMulSV(f,this.m_step.dt,d,m.p2),m.maxFraction=1,i.RayCast(p,m,n)){var y=p.normal,g=l;g.x=(1-p.fraction)*m.p1.x+p.fraction*m.p2.x+c*y.x,g.y=(1-p.fraction)*m.p1.y+p.fraction*m.p2.y+c*y.y;var x=u;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=h;A.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(d.x-x.x),A.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(d.y-x.y),this.m_system.ParticleApplyForce(r,A)}},n.prototype.ReportParticle=function(){return!1},n.ReportFixtureAndParticle_s_p1=new P,n.ReportFixtureAndParticle_s_output=new St,n.ReportFixtureAndParticle_s_input=new Ct,n.ReportFixtureAndParticle_s_p=new P,n.ReportFixtureAndParticle_s_v=new P,n.ReportFixtureAndParticle_s_f=new P,n})(Gn);e.SolveCollisionCallback=m})(t.b2ParticleSystem||(t.b2ParticleSystem={}));var jn=(function(){function e(t){this.m_newFixture=!1,this.m_locked=!1,this.m_clearForces=!0,this.m_contactManager=new cn,this.m_bodyList=null,this.m_jointList=null,this.m_particleSystemList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_gravity=new P,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 ln,this.m_island=new xn,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 _i(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 c=a;a=a.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(c),c.DestroyProxies(),c.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){switch(e.type){case t.b2JointType.e_distanceJoint:return new yi(e);case t.b2JointType.e_mouseJoint:return new Bi(e);case t.b2JointType.e_prismaticJoint:return new Ri(e);case t.b2JointType.e_revoluteJoint:return new Vi(e);case t.b2JointType.e_pulleyJoint:return new Ii(e);case t.b2JointType.e_gearJoint:return new bi(e);case t.b2JointType.e_wheelJoint:return new ki(e);case t.b2JointType.e_weldJoint:return new Ni(e);case t.b2JointType.e_frictionJoint:return new Ci(e);case t.b2JointType.e_ropeJoint:return new Oi(e);case t.b2JointType.e_motorJoint:return new wi(e);case t.b2JointType.e_areaJoint:return new xi(e)}throw new Error},e._Joint_Destroy=function(){},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){return null===this.m_particleSystemList?1:Cn(this.m_gravity.Length(),(function(t){for(var e=i,n=t.GetParticleSystemList();null!==n;n=n.m_next)e=v(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 c=e.Step_s_timer.Reset(),l=this.m_particleSystemList;l;l=l.m_next)l.Solve(o);this.Solve(o),this.m_profile.solve=c.GetMilliseconds()}if(this.m_continuousPhysics&&o.dt>0){var u=e.Step_s_timer.Reset();this.SolveTOI(o),this.m_profile.solveTOI=u.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 c=this.m_jointList;c;c=c.m_next)this.DrawJoint(c);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 u=0;u0;){if(!(i=a[--l]))throw new Error;if(r.AddBody(i),i.m_awakeFlag=!0,i.GetType()!==t.b2BodyType.b2_staticBody){for(var u=i.m_contactList;u;u=u.next){var h=u.contact;if(!h.m_islandFlag&&h.IsEnabled()&&h.IsTouching()){var _=h.m_fixtureA.m_isSensor,f=h.m_fixtureB.m_isSensor;if(!_&&!f){if(r.AddContact(h),h.m_islandFlag=!0,!(p=u.other))throw new Error;p.m_islandFlag||(a[l++]=p,p.m_islandFlag=!0)}}}for(var d=i.m_jointList;d;d=d.next){var p;d.joint.m_islandFlag||(p=d.other).IsActive()&&(r.AddJoint(d.joint),d.joint.m_islandFlag=!0,p.m_islandFlag||(a[l++]=p,p.m_islandFlag=!0))}}}var m=new ln;r.Solve(m,e,this.m_gravity,this.m_allowSleep),this.m_profile.solveInit+=m.solveInit,this.m_profile.solveVelocity+=m.solveVelocity,this.m_profile.solvePosition+=m.solvePosition;for(var v=0;v8)){var l=1;if(o.m_toiFlag)l=o.m_toi;else{var u=o.GetFixtureA(),h=o.GetFixtureB();if(u.IsSensor()||h.IsSensor())continue;var _=u.GetBody(),f=h.GetBody(),d=_.m_type,p=f.m_type,m=_.IsAwake()&&d!==t.b2BodyType.b2_staticBody,y=f.IsAwake()&&p!==t.b2BodyType.b2_staticBody;if(!m&&!y)continue;var g=_.IsBullet()||d!==t.b2BodyType.b2_dynamicBody,x=f.IsBullet()||p!==t.b2BodyType.b2_dynamicBody;if(!g&&!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(V.MulMV(this.T,s.GetLocalVector(s.GetLinearVelocity(),P.s_t0),P.s_t1),e.Step_s_damping);s.SetLinearVelocity(P.AddVV(s.GetLinearVelocity(),P.MulSV(i,o,P.s_t0),P.s_t1))}}}},e.prototype.Draw=function(){},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/y(t,e):0},e.Step_s_damping=new P,e})(qn),$n=(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 P,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=P.MakeArray(this.m_count),this.m_p0s=P.MakeArray(this.m_count),this.m_vs=P.MakeArray(this.m_count),this.m_ims=p(this.m_count);for(var e=0;e0?1/i:0}var n=this.m_count-1,r=this.m_count-2;for(this.m_Ls=p(n),this.m_as=p(r),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;)S=(m-=2*s)-this.m_as[i];for(;S<-s;)S=(m+=2*s)-this.m_as[i];var b=-this.m_k3*C*S;n.SelfMulAdd(a*b,g),r.SelfMulAdd(c*b,x),o.SelfMulAdd(l*b,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,1+((t|=t>>8&16777215)|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=P,t.b2Vec2_zero=I,t.b2Vec3=D,t.b2Mat22=V,t.b2Mat33=L,t.b2Rot=O,t.b2Transform=F,t.b2Sweep=N,t.b2Color=G,t.b2Draw=k,t.b2Timer=z,t.b2Counter=U,t.b2GrowableStack=H,t.b2BlockAllocator=function(){},t.b2StackAllocator=function(){},t.b2ContactFeature=pt,t.b2ContactID=mt,t.b2ManifoldPoint=vt,t.b2Manifold=gt,t.b2WorldManifold=xt,t.b2GetPointStates=function(e,i,n,r){var s;for(s=0;sC;){t.iterations+=1,d=i.GetSupport(O.MulTRV(s.q,P.NegV(x,P.s_t1),P.s_t0)),p=F.MulXV(s,i.GetVertex(d),ct),v=n.GetSupport(O.MulTRV(o.q,x,P.s_t0)),g=F.MulXV(o,n.GetVertex(v),lt);var b=P.SubVV(p,g,ht);x.Normalize();var T=P.DotVV(x,b),w=P.DotVV(x,a);if(T-A>h*w){if(w<=0)return!1;if((h=(T-A)/w)>1)return!1;l.Copy(x).SelfNeg(),_.m_count=0}var E=f[_.m_count];switch(E.indexA=v,E.wA.Copy(g).SelfMulAdd(h,a),E.indexB=d,E.wB.Copy(p),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(x),++S}var B=_t,M=ft;return _.GetWitnessPoints(B,M),x.LengthSquared()>0&&(l.Copy(x).SelfNeg(),l.Normalize()),t.normal.Copy(l),t.lambda=h,t.iterations=S,!0},t.b2Pair=Vt,t.b2BroadPhase=Lt,t.b2PairLessThan=Ot,t.b2TreeNode=It,t.b2DynamicTree=Dt,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=jt,t.b2TOIOutput=qt,t.b2SeparationFunction=Yt,t.b2TimeOfImpact=re,t.b2CollideCircles=ae,t.b2CollidePolygonAndCircle=he,t.b2CollidePolygons=Le,t.b2CollideEdgeAndCircle=We,t.b2CollideEdgeAndPolygon=Je,t.b2MassData=Ke,t.b2Shape=Qe,t.b2CircleShape=ii,t.b2PolygonShape=ni,t.b2EdgeShape=ri,t.b2ChainShape=si,t.b2Filter=oi,t.b2FixtureDef=ai,t.b2FixtureProxy=ci,t.b2Fixture=li,t.b2BodyDef=function(){this.type=t.b2BodyType.b2_staticBody,this.position=new P(0,0),this.angle=0,this.linearVelocity=new P(0,0),this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.active=!0,this.userData=null,this.gravityScale=1},t.b2Body=_i,t.b2World=jn,t.b2DestructionListener=en,t.b2ContactFilter=nn,t.b2ContactImpulse=rn,t.b2ContactListener=sn,t.b2QueryCallback=on,t.b2RayCastCallback=an,t.b2Island=xn,t.b2Profile=ln,t.b2TimeStep=un,t.b2Position=hn,t.b2Velocity=_n,t.b2SolverData=fn,t.b2ContactManager=cn,t.b2MixFriction=zi,t.b2MixRestitution=Ui,t.b2ContactEdge=Wi,t.b2Contact=ji,t.b2ContactRegister=$i,t.b2ContactFactory=tn,t.g_blockSolve=!1,t.b2VelocityConstraintPoint=dn,t.b2ContactVelocityConstraint=pn,t.b2ContactPositionConstraint=mn,t.b2ContactSolverDef=vn,t.b2PositionSolverManifold=yn,t.b2ContactSolver=gn,t.b2CircleContact=Xi,t.b2PolygonContact=qi,t.b2PolygonAndCircleContact=Yi,t.b2EdgeAndCircleContact=Ji,t.b2EdgeAndPolygonContact=Zi,t.b2ChainAndCircleContact=Ki,t.b2ChainAndPolygonContact=Qi,t.b2Jacobian=fi,t.b2JointEdge=di,t.b2JointDef=pi,t.b2Joint=mi,t.b2AreaJointDef=gi,t.b2AreaJoint=xi,t.b2DistanceJointDef=vi,t.b2DistanceJoint=yi,t.b2FrictionJointDef=Ai,t.b2FrictionJoint=Ci,t.b2GearJointDef=Si,t.b2GearJoint=bi,t.b2MotorJointDef=Ti,t.b2MotorJoint=wi,t.b2MouseJointDef=Ei,t.b2MouseJoint=Bi,t.b2PrismaticJointDef=Mi,t.b2PrismaticJoint=Ri,t.b2_minPulleyLength=2,t.b2PulleyJointDef=Pi,t.b2PulleyJoint=Ii,t.b2RevoluteJointDef=Di,t.b2RevoluteJoint=Vi,t.b2RopeJointDef=Li,t.b2RopeJoint=Oi,t.b2WeldJointDef=Fi,t.b2WeldJoint=Ni,t.b2WheelJointDef=Gi,t.b2WheelJoint=ki,t.b2ControllerEdge=Xn,t.b2Controller=qn,t.b2BuoyancyController=Yn,t.b2ConstantAccelController=Jn,t.b2ConstantForceController=Zn,t.b2GravityController=Kn,t.b2TensorDampingController=Qn,t.b2ParticleDef=An,t.b2CalculateParticleIterations=Cn,t.b2ParticleHandle=bn,t.b2ParticleGroupDef=Tn,t.b2ParticleGroup=wn,t.b2GrowableBuffer=Nn,t.b2FixtureParticleQueryCallback=Gn,t.b2ParticleContact=kn,t.b2ParticleBodyContact=zn,t.b2ParticlePair=Un,t.b2ParticleTriad=Hn,t.b2ParticleSystemDef=Wn,t.b2RopeDef=function(){this.vertices=[],this.count=0,this.masses=[],this.gravity=new P(0,0),this.damping=.1,this.k2=.9,this.k3=.1},t.b2Rope=$n,Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof i&&void 0!==e?n(i):"function"==typeof define&&define.amd?define(["exports"],n):n((void 0).box2d={})}),{}],321:[(function(t,e){"use strict";var i="undefined"==typeof window?global:window;i.cc=i.cc||{},cc.internal=cc.internal||{},t("./predefine"),t("./polyfill/string"),t("./polyfill/misc"),t("./polyfill/array"),t("./polyfill/object"),t("./polyfill/array-buffer"),t("./polyfill/number"),t("./polyfill/typescript"),t("./cocos2d/core/predefine"),t("./cocos2d"),t("./extends"),e.exports=i.cc}),{"./cocos2d":279,"./cocos2d/core/predefine":203,"./extends":318,"./package":void 0,"./polyfill/array":323,"./polyfill/array-buffer":322,"./polyfill/misc":324,"./polyfill/number":325,"./polyfill/object":326,"./polyfill/string":327,"./polyfill/typescript":328,"./predefine":329}],322:[(function(){"use strict";if(!ArrayBuffer.isView){var t=Object.getPrototypeOf(Int8Array);ArrayBuffer.isView="function"==typeof t?function(e){return e instanceof t}:function(t){if("object"!=typeof t)return!1;var e=t.constructor;return e===Float64Array||e===Float32Array||e===Uint8Array||e===Uint32Array||e===Int8Array}}}),{}],323:[(function(){"use strict";Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.find||(Array.prototype.find=function(t){for(var e=this.length,i=0;i0?1:-1}),Math.log2||(Math.log2=function(t){return Math.log(t)*Math.LOG2E}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),!console.time){var t=window.performance||Date,e=Object.create(null);console.time=function(i){e[i]=t.now()},console.timeEnd=function(i){var n=e[i],r=t.now()-n;console.log(i+": "+r+"ms")}}}),{}],325:[(function(){"use strict";Number.parseFloat=Number.parseFloat||parseFloat,Number.parseInt=Number.parseInt||parseInt}),{}],326:[(function(){"use strict";Object.assign||(Object.assign=function(t,e){return cc.js.mixin(t,e)}),Object.getOwnPropertyDescriptors||(Object.getOwnPropertyDescriptors=function(t){var e={},i=Object.getOwnPropertyNames(t);Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t)));for(var n=0;nthis.length)&&(e=this.length),e-=t.length;var i=this.indexOf(t,e);return-1!==i&&i===e}),String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/,"")})}),{}],328:[(function(){"use strict";var t=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(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)},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{c(n.next(t))}catch(e){s(e)}}function a(t){try{c(n.throw(t))}catch(e){s(e)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,a)}c((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(t){return function(e){return c([t,e])}}function c(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&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[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},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(a){r={error:a}}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{(i=r[t](e)).value instanceof __await?Promise.resolve(i.value.v).then(c,l):u(s[0][2],i)}catch(n){u(s[0][3],n)}var i}function c(t){a("next",t)}function l(t){a("throw",t)}function u(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){e[n]=t[n]?function(e){return(i=!i)?{value:__await(t[n](e)),done:"return"===n}:r?r(e):e}:r}},window.__asyncValues=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=t[Symbol.asyncIterator];return i?i.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(e){return new Promise(function(n,s){r(n,s,(e=t[i](e)).done,e.value)})}}function r(t,e,i,n){Promise.resolve(n).then((function(e){t({value:e,done:i})}),e)}},window.__makeTemplateObject=function(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t};var e=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};window.__importStar=function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&__createBinding(i,t,n);return e(i,t),i},window.__importDefault=function(t){return t&&t.__esModule?t:{default:t}},window.__classPrivateFieldGet=function(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)},window.__classPrivateFieldSet=function(t,e,i){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,i),i}}),{}],329:[(function(){"use strict";var t="undefined"==typeof window?global:window;function e(e,i){void 0===t[e]&&Object.defineProperty(t,e,{get:function(){var t;return"CC_WECHATGAMESUB"===e?t="cc.sys.platform === cc.sys.WECHAT_GAME_SUB":"CC_WECHATGAME"===e?t="cc.sys.platform === cc.sys.WECHAT_GAME":"CC_QQPLAY"===e&&(t="cc.sys.platform === cc.sys.QQ_PLAY"),cc.warnID(1400,e,t),i}})}function i(e){return"object"==typeof t[e]}(function(e,i){void 0===t[e]&&(t[e]=i)})("CC_BUILD",!1),t.CC_BUILD=!0,t.CC_DEV=!1,t.CC_DEBUG=!1,t.CC_JSB=!1,t.CC_NATIVERENDERER=!1,t.CC_SUPPORT_JIT=!1,t.CC_PHYSICS_BUILTIN=!1,t.CC_PHYSICS_CANNON=!1,t.CC_EDITOR=!1,t.CC_PREVIEW=!1,t.CC_TEST=!1,t.CC_RUNTIME=!1,t.CC_JSB=!1;var n=!(!i("wx")||!wx.getSharedCanvas),r=!(!i("wx")||!wx.getSystemInfoSync&&!wx.getSharedCanvas),s=i("bk");e("CC_WECHATGAMESUB",n),e("CC_WECHATGAME",r),e("CC_QQPLAY",s),t.CocosEngine=cc.ENGINE_VERSION="2.4.12"}),{}]},{},[321]);