live2d-widget-model
Version:
1 lines • 144 kB
JavaScript
!function(i){function r(t){var e;return(o[t]||(e=o[t]={i:t,l:!1,exports:{}},i[t].call(e.exports,e,e.exports,r),e.l=!0,e)).exports}var o={};r.m=i,r.c=o,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=4)}([function(t,e,i){"use strict";function r(){this.live2DModel=null,this.modelMatrix=null,this.eyeBlink=null,this.physics=null,this.pose=null,this.debugMode=!1,this.initialized=!1,this.updating=!1,this.alpha=1,this.accAlpha=0,this.lipSync=!1,this.lipSyncValue=0,this.accelX=0,this.accelY=0,this.accelZ=0,this.dragX=0,this.dragY=0,this.startTimeMSec=null,this.mainMotionManager=new _,this.expressionManager=new _,this.motions={},this.expressions={},this.isTexLoaded=!1}function l(){AMotion.prototype.constructor.call(this),this.paramList=new Array}function $(){this.id="",this.type=-1,this.value=null}function o(){this.nextBlinkTime=null,this.stateStartTime=null,this.blinkIntervalMsec=null,this.eyeState=p.STATE_FIRST,this.blinkIntervalMsec=4e3,this.closingMotionMsec=100,this.closedMotionMsec=50,this.openingMotionMsec=150,this.closeIfZero=!0,this.eyeID_L="PARAM_EYE_L_OPEN",this.eyeID_R="PARAM_EYE_R_OPEN"}function n(){this.tr=new Float32Array(16),this.identity()}function s(t,e){n.prototype.constructor.call(this),this.width=t,this.height=e}function _(){MotionQueueManager.prototype.constructor.call(this),this.currentPriority=null,this.reservePriority=null,this.super=MotionQueueManager.prototype}function P(){this.physicsList=new Array,this.startTimeMSec=UtSystem.getUserTimeMSec()}function f(){this.lastTime=0,this.lastModel=null,this.partsGroups=new Array}function d(t){this.paramIndex=-1,this.partsIndex=-1,this.link=null,this.id=t}function a(){this.EPSILON=.01,this.faceTargetX=0,this.faceTargetY=0,this.faceX=0,this.faceY=0,this.faceVX=0,this.faceVY=0,this.lastTimeSec=0}function h(){n.prototype.constructor.call(this),this.screenLeft=null,this.screenRight=null,this.screenTop=null,this.screenBottom=null,this.maxLeft=null,this.maxRight=null,this.maxTop=null,this.maxBottom=null,this.max=Number.MAX_VALUE,this.min=0}function L(){}var u=0,p=(r.prototype.getModelMatrix=function(){return this.modelMatrix},r.prototype.setAlpha=function(t){this.alpha=t=(t=.999<t?1:t)<.001?0:t},r.prototype.getAlpha=function(){return this.alpha},r.prototype.isInitialized=function(){return this.initialized},r.prototype.setInitialized=function(t){this.initialized=t},r.prototype.isUpdating=function(){return this.updating},r.prototype.setUpdating=function(t){this.updating=t},r.prototype.getLive2DModel=function(){return this.live2DModel},r.prototype.setLipSync=function(t){this.lipSync=t},r.prototype.setLipSyncValue=function(t){this.lipSyncValue=t},r.prototype.setAccel=function(t,e,i){this.accelX=t,this.accelY=e,this.accelZ=i},r.prototype.setDrag=function(t,e){this.dragX=t,this.dragY=e},r.prototype.getMainMotionManager=function(){return this.mainMotionManager},r.prototype.getExpressionManager=function(){return this.expressionManager},r.prototype.loadModelData=function(t,e){var i=L.getPlatformManager(),r=(this.debugMode&&i.log("Load model : "+t),this);i.loadLive2DModel(t,function(t){r.live2DModel=t,r.live2DModel.saveParam(),0!=Live2D.getError()?console.error("Error : Failed to loadModelData()."):(r.modelMatrix=new s(r.live2DModel.getCanvasWidth(),r.live2DModel.getCanvasHeight()),r.modelMatrix.setWidth(2),r.modelMatrix.setCenterPosition(0,0),e(r.live2DModel))})},r.prototype.loadTexture=function(t,e,i){u++;var r=L.getPlatformManager(),o=(this.debugMode&&r.log("Load Texture : "+e),this);r.loadTexture(this.live2DModel,t,e,function(){0==--u&&(o.isTexLoaded=!0),"function"==typeof i&&i()})},r.prototype.loadMotion=function(e,t,i){var r,o=L.getPlatformManager(),n=(this.debugMode&&o.log("Load Motion : "+t),this);o.loadBytes(t,function(t){r=Live2DMotion.loadMotion(t),null!=e&&(n.motions[e]=r),i(r)})},r.prototype.loadExpression=function(e,t,i){var r=L.getPlatformManager(),o=(this.debugMode&&r.log("Load Expression : "+t),this);r.loadBytes(t,function(t){null!=e&&(o.expressions[e]=l.loadJson(t)),"function"==typeof i&&i()})},r.prototype.loadPose=function(t,e){var i=L.getPlatformManager(),r=(this.debugMode&&i.log("Load Pose : "+t),this);try{i.loadBytes(t,function(t){r.pose=f.load(t),"function"==typeof e&&e()})}catch(t){console.warn(t)}},r.prototype.loadPhysics=function(t){var e=L.getPlatformManager(),i=(this.debugMode&&e.log("Load Physics : "+t),this);try{e.loadBytes(t,function(t){i.physics=P.load(t)})}catch(t){console.warn(t)}},r.prototype.hitTestSimple=function(t,e,i){if(null===this.live2DModel)return!1;t=this.live2DModel.getDrawDataIndex(t);if(t<0)return!1;for(var r=this.live2DModel.getTransformedPoints(t),o=this.live2DModel.getCanvasWidth(),n=0,s=this.live2DModel.getCanvasHeight(),_=0,a=0;a<r.length;a+=2){var h=r[a],l=r[a+1];h<o&&(o=h),n<h&&(n=h),l<s&&(s=l),_<l&&(_=l)}t=this.modelMatrix.invertTransformX(e),e=this.modelMatrix.invertTransformY(i);return o<=t&&t<=n&&s<=e&&e<=_},r.prototype.hitTestSimpleCustom=function(t,e,i,r){return null!==this.live2DModel&&i>=t[0]&&i<=e[0]&&r<=t[1]&&r>=e[1]},l.prototype=new AMotion,l.EXPRESSION_DEFAULT="DEFAULT",l.TYPE_SET=0,l.TYPE_ADD=1,l.TYPE_MULT=2,l.loadJson=function(t){var e=new l,t=L.getPlatformManager().jsonParseFromBytes(t);if(e.setFadeIn(0<parseInt(t.fade_in)?parseInt(t.fade_in):1e3),e.setFadeOut(0<parseInt(t.fade_out)?parseInt(t.fade_out):1e3),null!=t.params){var i=t.params,r=i.length;e.paramList=[];for(var o=0;o<r;o++){var n,s=i[o],_=s.id.toString(),a=parseFloat(s.val),h=null!=s.calc?s.calc.toString():"add",s=((h="add"===h?l.TYPE_ADD:"mult"===h?l.TYPE_MULT:"set"===h?l.TYPE_SET:l.TYPE_ADD)==l.TYPE_ADD?a-=n=null==s.def?0:parseFloat(s.def):h==l.TYPE_MULT&&(a/=n=0==(n=null==s.def?1:parseFloat(s.def))?1:n),new $);s.id=_,s.type=h,s.value=a,e.paramList.push(s)}}return e},l.prototype.updateParamExe=function(t,e,i,r){for(var o=this.paramList.length-1;0<=o;--o){var n=this.paramList[o];n.type==l.TYPE_ADD?t.addToParamFloat(n.id,n.value,i):n.type==l.TYPE_MULT?t.multParamFloat(n.id,n.value,i):n.type==l.TYPE_SET&&t.setParamFloat(n.id,n.value,i)}},o.prototype.calcNextBlink=function(){return UtSystem.getUserTimeMSec()+Math.random()*(2*this.blinkIntervalMsec-1)},o.prototype.setInterval=function(t){this.blinkIntervalMsec=t},o.prototype.setEyeMotion=function(t,e,i){this.closingMotionMsec=t,this.closedMotionMsec=e,this.openingMotionMsec=i},o.prototype.updateParam=function(t){var e,i=UtSystem.getUserTimeMSec(),r=0;switch(this.eyeState){case p.STATE_CLOSING:1<=(r=(i-this.stateStartTime)/this.closingMotionMsec)&&(r=1,this.eyeState=p.STATE_CLOSED,this.stateStartTime=i),e=1-r;break;case p.STATE_CLOSED:1<=(r=(i-this.stateStartTime)/this.closedMotionMsec)&&(this.eyeState=p.STATE_OPENING,this.stateStartTime=i),e=0;break;case p.STATE_OPENING:1<=(r=(i-this.stateStartTime)/this.openingMotionMsec)&&(r=1,this.eyeState=p.STATE_INTERVAL,this.nextBlinkTime=this.calcNextBlink()),e=r;break;case p.STATE_INTERVAL:this.nextBlinkTime<i&&(this.eyeState=p.STATE_CLOSING,this.stateStartTime=i),e=1;break;default:p.STATE_FIRST;this.eyeState=p.STATE_INTERVAL,this.nextBlinkTime=this.calcNextBlink(),e=1}this.closeIfZero||(e=-e),t.setParamFloat(this.eyeID_L,e),t.setParamFloat(this.eyeID_R,e)},function(){});p.STATE_FIRST="STATE_FIRST",p.STATE_INTERVAL="STATE_INTERVAL",p.STATE_CLOSING="STATE_CLOSING",p.STATE_CLOSED="STATE_CLOSED",p.STATE_OPENING="STATE_OPENING",n.mul=function(t,e,i){for(var r,o,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s=0;s<4;s++)for(r=0;r<4;r++)for(o=0;o<4;o++)n[s+4*r]+=t[s+4*o]*e[o+4*r];for(s=0;s<16;s++)i[s]=n[s]},n.prototype.identity=function(){for(var t=0;t<16;t++)this.tr[t]=t%5==0?1:0},n.prototype.getArray=function(){return this.tr},n.prototype.getCopyMatrix=function(){return new Float32Array(this.tr)},n.prototype.setMatrix=function(t){if(null!=this.tr&&this.tr.length==this.tr.length)for(var e=0;e<16;e++)this.tr[e]=t[e]},n.prototype.getScaleX=function(){return this.tr[0]},n.prototype.getScaleY=function(){return this.tr[5]},n.prototype.transformX=function(t){return this.tr[0]*t+this.tr[12]},n.prototype.transformY=function(t){return this.tr[5]*t+this.tr[13]},n.prototype.invertTransformX=function(t){return(t-this.tr[12])/this.tr[0]},n.prototype.invertTransformY=function(t){return(t-this.tr[13])/this.tr[5]},n.prototype.multTranslate=function(t,e){n.mul([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1],this.tr,this.tr)},n.prototype.translate=function(t,e){this.tr[12]=t,this.tr[13]=e},n.prototype.translateX=function(t){this.tr[12]=t},n.prototype.translateY=function(t){this.tr[13]=t},n.prototype.multScale=function(t,e){n.mul([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1],this.tr,this.tr)},n.prototype.scale=function(t,e){this.tr[0]=t,this.tr[5]=e},(s.prototype=new n).setPosition=function(t,e){this.translate(t,e)},s.prototype.setCenterPosition=function(t,e){var i=this.width*this.getScaleX(),r=this.height*this.getScaleY();this.translate(t-i/2,e-r/2)},s.prototype.top=function(t){this.setY(t)},s.prototype.bottom=function(t){var e=this.height*this.getScaleY();this.translateY(t-e)},s.prototype.left=function(t){this.setX(t)},s.prototype.right=function(t){var e=this.width*this.getScaleX();this.translateX(t-e)},s.prototype.centerX=function(t){var e=this.width*this.getScaleX();this.translateX(t-e/2)},s.prototype.centerY=function(t){var e=this.height*this.getScaleY();this.translateY(t-e/2)},s.prototype.setX=function(t){this.translateX(t)},s.prototype.setY=function(t){this.translateY(t)},s.prototype.setHeight=function(t){t/=this.height;this.scale(t,-t)},s.prototype.setWidth=function(t){t/=this.width;this.scale(t,-t)},(_.prototype=new MotionQueueManager).getCurrentPriority=function(){return this.currentPriority},_.prototype.getReservePriority=function(){return this.reservePriority},_.prototype.reserveMotion=function(t){return!(this.reservePriority>=t||this.currentPriority>=t||(this.reservePriority=t,0))},_.prototype.setReservePriority=function(t){this.reservePriority=t},_.prototype.updateParam=function(t){t=MotionQueueManager.prototype.updateParam.call(this,t);return this.isFinished()&&(this.currentPriority=0),t},_.prototype.startMotionPrio=function(t,e){return e==this.reservePriority&&(this.reservePriority=0),this.currentPriority=e,this.startMotion(t,!1)},P.load=function(t){for(var e=new P,i=L.getPlatformManager().jsonParseFromBytes(t).physics_hair,r=i.length,o=0;o<r;o++){var n=i[o],s=new PhysicsHair,_=n.setup,a=parseFloat(_.length),h=parseFloat(_.regist),_=parseFloat(_.mass);s.setup(a,h,_);for(var l=n.src,$=l.length,u=0;u<$;u++){var p=l[u],c=p.id,f=PhysicsHair.Src.SRC_TO_X,d=("x"===(T=p.ptype)?f=PhysicsHair.Src.SRC_TO_X:"y"===T?f=PhysicsHair.Src.SRC_TO_Y:"angle"===T?f=PhysicsHair.Src.SRC_TO_G_ANGLE:UtDebug.error("live2d","Invalid parameter:PhysicsHair.Src"),parseFloat(p.scale)),g=parseFloat(p.weight);s.addSrcParam(f,c,d,g)}for(var y=n.targets,m=y.length,u=0;u<m;u++){var T,S=y[u],c=S.id,f=PhysicsHair.Target.TARGET_FROM_ANGLE,d=("angle"===(T=S.ptype)?f=PhysicsHair.Target.TARGET_FROM_ANGLE:"angle_v"===T?f=PhysicsHair.Target.TARGET_FROM_ANGLE_V:UtDebug.error("live2d","Invalid parameter:PhysicsHair.Target"),parseFloat(S.scale)),g=parseFloat(S.weight);s.addTargetParam(f,c,d,g)}e.physicsList.push(s)}return e},P.prototype.updateParam=function(t){for(var e=UtSystem.getUserTimeMSec()-this.startTimeMSec,i=0;i<this.physicsList.length;i++)this.physicsList[i].update(t,e)},f.load=function(t){for(var e=new f,i=L.getPlatformManager().jsonParseFromBytes(t).parts_visible,r=i.length,o=0;o<r;o++){for(var n=i[o].group,s=n.length,_=new Array,a=0;a<s;a++){var h=n[a],l=new d(h.id);if(_[a]=l,null!=h.link){var $=h.link,u=$.length;l.link=new Array;for(var p=0;p<u;p++){var c=new d($[p]);l.link.push(c)}}}e.partsGroups.push(_)}return e},f.prototype.updateParam=function(t){if(null!=t){t!=this.lastModel&&this.initParam(t),this.lastModel=t;var e=UtSystem.getUserTimeMSec(),i=0==this.lastTime?0:(e-this.lastTime)/1e3;this.lastTime=e,i<0&&(i=0);for(var r=0;r<this.partsGroups.length;r++)this.normalizePartsOpacityGroup(t,this.partsGroups[r],i),this.copyOpacityOtherParts(t,this.partsGroups[r])}},f.prototype.initParam=function(t){if(null!=t)for(var e=0;e<this.partsGroups.length;e++)for(var i=this.partsGroups[e],r=0;r<i.length;r++){i[r].initIndex(t);var o=i[r].partsIndex,n=i[r].paramIndex;if(!(o<0)){var s=0!=t.getParamFloat(n);if(t.setPartsOpacity(o,s?1:0),t.setParamFloat(n,s?1:0),null!=i[r].link)for(var _=0;_<i[r].link.length;_++)i[r].link[_].initIndex(t)}}},f.prototype.normalizePartsOpacityGroup=function(t,e,i){for(var r=-1,o=1,n=0;n<e.length;n++){var s=e[n].partsIndex,_=e[n].paramIndex;if(!(s<0)&&0!=t.getParamFloat(_)){if(0<=r)break;r=n,o=t.getPartsOpacity(s),1<(o+=i/.5)&&(o=1)}}r<0&&(r=0,o=1);for(var a,h,n=0;n<e.length;n++)(s=e[n].partsIndex)<0||(r==n?t.setPartsOpacity(s,o):((h=.15<(1-(h=o<.5?-.5*o/.5+1:.5*(1-o)/.5))*(1-o)?1-.15/(1-o):h)<(a=t.getPartsOpacity(s))&&(a=h),t.setPartsOpacity(s,a)))},f.prototype.copyOpacityOtherParts=function(t,e){for(var i=0;i<e.length;i++){var r=e[i];if(null!=r.link&&!(r.partsIndex<0))for(var o=t.getPartsOpacity(r.partsIndex),n=0;n<r.link.length;n++){var s=r.link[n];s.partsIndex<0||t.setPartsOpacity(s.partsIndex,o)}}},d.prototype.initIndex=function(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)},a.FRAME_RATE=30,a.prototype.setPoint=function(t,e){this.faceTargetX=t,this.faceTargetY=e},a.prototype.getX=function(){return this.faceX},a.prototype.getY=function(){return this.faceY},a.prototype.update=function(){var t,e,i,r,o=40/7.5/a.FRAME_RATE;0==this.lastTimeSec?this.lastTimeSec=UtSystem.getUserTimeMSec():(e=((t=UtSystem.getUserTimeMSec())-this.lastTimeSec)*a.FRAME_RATE/1e3,this.lastTimeSec=t,t=e*o/(.15*a.FRAME_RATE),e=this.faceTargetX-this.faceX,i=this.faceTargetY-this.faceY,Math.abs(e)<=this.EPSILON&&Math.abs(i)<=this.EPSILON||(r=o*e/(e=Math.sqrt(e*e+i*i))-this.faceVX,o=o*i/e-this.faceVY,((i=Math.sqrt(r*r+o*o))<-t||t<i)&&(r*=t/i,o*=t/i,i=t),this.faceVX+=r,this.faceVY+=o,(i=.5*(Math.sqrt(t*t+16*t*e-8*t*e)-t))<(r=Math.sqrt(this.faceVX*this.faceVX+this.faceVY*this.faceVY))&&(this.faceVX*=i/r,this.faceVY*=i/r),this.faceX+=this.faceVX,this.faceY+=this.faceVY))},(h.prototype=new n).getMaxScale=function(){return this.max},h.prototype.getMinScale=function(){return this.min},h.prototype.setMaxScale=function(t){this.max=t},h.prototype.setMinScale=function(t){this.min=t},h.prototype.isMaxScale=function(){return this.getScaleX()==this.max},h.prototype.isMinScale=function(){return this.getScaleX()==this.min},h.prototype.adjustTranslate=function(t,e){this.tr[0]*this.maxLeft+(this.tr[12]+t)>this.screenLeft&&(t=this.screenLeft-this.tr[0]*this.maxLeft-this.tr[12]),this.tr[0]*this.maxRight+(this.tr[12]+t)<this.screenRight&&(t=this.screenRight-this.tr[0]*this.maxRight-this.tr[12]),this.tr[5]*this.maxTop+(this.tr[13]+e)<this.screenTop&&(e=this.screenTop-this.tr[5]*this.maxTop-this.tr[13]),this.tr[5]*this.maxBottom+(this.tr[13]+e)>this.screenBottom&&(e=this.screenBottom-this.tr[5]*this.maxBottom-this.tr[13]),n.mul([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1],this.tr,this.tr)},h.prototype.adjustScale=function(t,e,i){var r=i*this.tr[0],r=(r<this.min?0<this.tr[0]&&(i=this.min/this.tr[0]):r>this.max&&0<this.tr[0]&&(i=this.max/this.tr[0]),[1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]),i=[i,0,0,0,0,i,0,0,0,0,1,0,0,0,0,1];n.mul([1,0,0,0,0,1,0,0,0,0,1,0,-t,-e,0,1],this.tr,this.tr),n.mul(i,this.tr,this.tr),n.mul(r,this.tr,this.tr)},h.prototype.setScreenRect=function(t,e,i,r){this.screenLeft=t,this.screenRight=e,this.screenTop=r,this.screenBottom=i},h.prototype.setMaxScreenRect=function(t,e,i,r){this.maxLeft=t,this.maxRight=e,this.maxTop=r,this.maxBottom=i},h.prototype.getScreenLeft=function(){return this.screenLeft},h.prototype.getScreenRight=function(){return this.screenRight},h.prototype.getScreenBottom=function(){return this.screenBottom},h.prototype.getScreenTop=function(){return this.screenTop},h.prototype.getMaxLeft=function(){return this.maxLeft},h.prototype.getMaxRight=function(){return this.maxRight},h.prototype.getMaxBottom=function(){return this.maxBottom},h.prototype.getMaxTop=function(){return this.maxTop},L.platformManager=null,L.getPlatformManager=function(){return L.platformManager},L.setPlatformManager=function(t){L.platformManager=t},t.exports={L2DTargetPoint:a,Live2DFramework:L,L2DViewMatrix:h,L2DPose:f,L2DPartsParam:d,L2DPhysics:P,L2DMotionManager:_,L2DModelMatrix:s,L2DMatrix44:n,EYE_STATE:p,L2DEyeBlink:o,L2DExpressionParam:$,L2DExpressionMotion:l,L2DBaseModel:r}},function(t,e,i){"use strict";t.exports={DEBUG_LOG:!1,DEBUG_MOUSE_LOG:!1,DEBUG_DRAW_HIT_AREA:!1,DEBUG_DRAW_ALPHA_MODEL:!1,VIEW_MAX_SCALE:2,VIEW_MIN_SCALE:.8,VIEW_LOGICAL_LEFT:-1,VIEW_LOGICAL_RIGHT:1,VIEW_LOGICAL_MAX_LEFT:-2,VIEW_LOGICAL_MAX_RIGHT:2,VIEW_LOGICAL_MAX_BOTTOM:-2,VIEW_LOGICAL_MAX_TOP:2,PRIORITY_NONE:0,PRIORITY_IDLE:1,PRIORITY_SLEEPY:2,PRIORITY_NORMAL:3,PRIORITY_FORCE:4,MOTION_GROUP_IDLE:"idle",MOTION_GROUP_SLEEPY:"sleepy",MOTION_GROUP_TAP_BODY:"tap_body",MOTION_GROUP_FLICK_HEAD:"flick_head",MOTION_GROUP_PINCH_IN:"pinch_in",MOTION_GROUP_PINCH_OUT:"pinch_out",MOTION_GROUP_SHAKE:"shake",HIT_AREA_HEAD:"head",HIT_AREA_BODY:"body"}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setContext=function(t){r=t},e.getContext=function(){return r};var r=void 0},function(t,e,i){"use strict";function r(){}r.matrixStack=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.depth=0,r.currentMatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.tmp=new Array(16),r.reset=function(){this.depth=0},r.loadIdentity=function(){for(var t=0;t<16;t++)this.currentMatrix[t]=t%5==0?1:0},r.push=function(){this.depth;var t=16*(this.depth+1);this.matrixStack.length<16+t&&(this.matrixStack.length=16+t);for(var e=0;e<16;e++)this.matrixStack[t+e]=this.currentMatrix[e];this.depth++},r.pop=function(){--this.depth<0&&(myError("Invalid matrix stack."),this.depth=0);for(var t=16*this.depth,e=0;e<16;e++)this.currentMatrix[e]=this.matrixStack[t+e]},r.getMatrix=function(){return this.currentMatrix},r.multMatrix=function(t){for(var e,i,r=0;r<16;r++)this.tmp[r]=0;for(r=0;r<4;r++)for(e=0;e<4;e++)for(i=0;i<4;i++)this.tmp[r+4*e]+=this.currentMatrix[r+4*i]*t[i+4*e];for(r=0;r<16;r++)this.currentMatrix[r]=this.tmp[r]},t.exports=r},function(t,e,i){t.exports=i(5)},function(t,e,i){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(t){var e=L.width,i=L.height,r=(M=new f.L2DTargetPoint,i/e),o=g.default.VIEW_LOGICAL_LEFT,n=g.default.VIEW_LOGICAL_RIGHT,s=-r;if(window.Live2D.captureFrame=!1,(E=new f.L2DViewMatrix).setScreenRect(o,n,s,r),E.setMaxScreenRect(g.default.VIEW_LOGICAL_MAX_LEFT,g.default.VIEW_LOGICAL_MAX_RIGHT,g.default.VIEW_LOGICAL_MAX_BOTTOM,g.default.VIEW_LOGICAL_MAX_TOP),E.setMaxScale(g.default.VIEW_MAX_SCALE),E.setMinScale(g.default.VIEW_MIN_SCALE),(v=new f.L2DMatrix44).multScale(1,e/i),(A=new f.L2DMatrix44).multTranslate(-e/2,-i/2),A.multScale(2/e,-2/e),P=function(){for(var t=["webgl","experimental-webgl","webkit-3d","moz-webgl"],e=0;e<t.length;e++)try{var i=L.getContext(t[e],{premultipliedAlpha:!0});if(i)return i}catch(t){}return null}(),(0,m.setContext)(P),!P)return console.error("Failed to create WebGL context."),window.WebGLRenderingContext&&console.error("Your browser don't support WebGL, check https://get.webgl.org/ for futher information.");window.Live2D.setGL(P),P.clearColor(0,0,0,0),o=t,T.reloadFlg=!0,T.count++,T.changeModel(P,o),S||(S=!0,function t(){!function(){y.default.reset(),y.default.loadIdentity(),M.update(),T.setDrag(M.getX(),M.getY()),P.clear(P.COLOR_BUFFER_BIT),y.default.multMatrix(v.getArray()),y.default.multMatrix(E.getArray()),y.default.push();for(var t=0;t<T.numModels();t++){var e=T.getModel(t);if(null==e)return;e.initialized&&!e.updating&&(e.update(),e.draw(P))}y.default.pop()}();var e,i=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;window.Live2D.captureFrame&&(window.Live2D.captureFrame=!1,e=document.createElement("a"),document.body.appendChild(e),e.setAttribute("type","hidden"),e.href=L.toDataURL(),e.download=window.Live2D.captureName||"live2d.png",e.click()),i(t,L)}())}function _(t,e,i){function r(t,e){return 180*Math.acos((i={x:0,y:1},t=t,e=e,r=Math.sqrt(t*t+e*e),t={x:t/r,y:e/r},i.x*t.x+i.y*t.y))/Math.PI;var i,r}var o,n,s,_,a,h;return e.x<i.left+i.width&&e.y<i.top+i.height&&e.x>i.left&&e.y>i.top?e:(o=r(_=t.x-e.x,s=t.y-e.y),e.x<t.x&&(o=360-o),e=360-r(i.left-t.x,-1*(i.top-t.y)),n=360-r(i.left-t.x,-1*(i.top+i.height-t.y)),h=r(i.left+i.width-t.x,-1*(i.top-t.y)),a=r(i.left+i.width-t.x,-1*(i.top+i.height-t.y)),s=s/_,o<h?(_=i.top-t.y,{y:t.y+_,x:t.x+_/s}):o<a?(h=i.left+i.width-t.x,{y:t.y+h*s,x:t.x+h}):o<n?(_=i.top+i.height-t.y,{y:t.y+_,x:t.x+_/s}):o<e?(a=t.x-i.left,{y:t.y-a*s,x:t.x-a}):(h=i.top-t.y,{y:t.y+h,x:t.x+h/s}))}function a(t){x=!0;var e=L.getBoundingClientRect(),i=p(t.clientX-e.left),r=c(t.clientY-e.top),o=_({x:e.left+e.width/2,y:e.top+e.height*I},{x:t.clientX,y:t.clientY},e),n=$(o.x-e.left),o=u(o.y-e.top);g.default.DEBUG_MOUSE_LOG&&console.log("onMouseMove device( x:"+t.clientX+" y:"+t.clientY+" ) view( x:"+n+" y:"+o+")"),M.setPoint(n,o)}function h(){x=x&&!1,M.setPoint(0,0)}function l(){g.default.DEBUG_LOG&&console.log("Set Session Storage."),sessionStorage.setItem("Sleepy","1")}function n(t){var e,i,r,o,n,s;"mousewheel"!=t.type&&("mousedown"==t.type?(e=t,x=!0,i=L.getBoundingClientRect(),r=p(e.clientX-i.left),o=c(e.clientY-i.top),n=$((s=_({x:i.left+i.width/2,y:i.top+i.height*I},{x:e.clientX,y:e.clientY},i)).x-i.left),s=u(s.y-i.top),g.default.DEBUG_MOUSE_LOG&&console.log("onMouseDown device( x:"+e.clientX+" y:"+e.clientY+" ) view( x:"+n+" y:"+s+")"),T.tapEvent(n,s)):"mousemove"==t.type?("1"===sessionStorage.getItem("Sleepy")&&sessionStorage.setItem("Sleepy","0"),a(t)):"mouseup"==t.type?"button"in t&&t.button:"mouseout"==t.type&&(g.default.DEBUG_LOG&&console.log("Mouse out Window."),h(),i=sessionStorage.getItem("SleepyTimer"),window.clearTimeout(i),i=window.setTimeout(l,5e4),sessionStorage.setItem("SleepyTimer",i)))}function s(t){var e,i,r,o,n,s=t.touches[0];"touchstart"==t.type?1==t.touches.length&&a(s):"touchmove"==t.type?(s=s,e=L.getBoundingClientRect(),i=p(s.clientX-e.left),r=c(s.clientY-e.top),o=$((n=_({x:e.left+e.width/2,y:e.top+e.height*I},{x:s.clientX,y:s.clientY},e)).x-e.left),n=u(n.y-e.top),g.default.DEBUG_MOUSE_LOG&&console.log("onMouseMove device( x:"+s.clientX+" y:"+s.clientY+" ) view( x:"+o+" y:"+n+")"),x&&M.setPoint(o,n)):"touchend"==t.type&&h()}function $(t){t=A.transformX(t);return E.invertTransformX(t)}function u(t){t=A.transformY(t);return E.invertTransformY(t)}function p(t){return A.transformX(t)}function c(t){return A.transformY(t)}i(6);var f=i(0),d=r(i(8)),g=r(i(1)),y=r(i(3)),m=i(2),T=(window.navigator.platform.toLowerCase(),new d.default),S=!1,P=null,L=null,M=null,E=null,v=null,A=null,x=!1,I=.5;window.loadlive2d=function(t,e,i){I=void 0===i?.5:i,(L=document.getElementById(t)).addEventListener&&(window.addEventListener("click",n),window.addEventListener("mousedown",n),window.addEventListener("mousemove",n),window.addEventListener("mouseup",n),document.addEventListener("mouseout",n),window.addEventListener("touchstart",s),window.addEventListener("touchend",s),window.addEventListener("touchmove",s)),o(e)}},function(t,e,i){"use strict";!function(Y){function $(){O||(this._$MT=null,this._$5S=null,this._$NP=0,$._$42++,this._$5S=new d(this))}function L(t){if(!O){this.clipContextList=new Array,this.glcontext=t.gl,this.dp_webgl=t,this.curFrameNo=0,this.firstError_clipInNotUpdate=!0,this.colorBuffer=0,this.isInitGLFBFunc=!1,this.tmpBoundsOnModel=new H,ot.glContext.length>ot.frameBuffers.length&&(this.curFrameNo=this.getMaskRenderTexture()),this.tmpModelToViewMatrix=new i,this.tmpMatrix2=new i,this.tmpMatrixForMask=new i,this.tmpMatrixForDraw=new i,this.CHANNEL_COLORS=new Array;t=new j;(t=new j).r=0,t.g=0,t.b=0,t.a=1,this.CHANNEL_COLORS.push(t),(t=new j).r=1,t.g=0,t.b=0,t.a=0,this.CHANNEL_COLORS.push(t),(t=new j).r=0,t.g=1,t.b=0,t.a=0,this.CHANNEL_COLORS.push(t),(t=new j).r=0,t.g=0,t.b=1,t.a=0,this.CHANNEL_COLORS.push(t);for(var e=0;e<this.CHANNEL_COLORS.length;e++)this.dp_webgl.setChannelFlagAsColor(e,this.CHANNEL_COLORS[e])}}function D(t,e,i){this.clipIDList=new Array,this.clipIDList=i,this.clippingMaskDrawIndexList=new Array;for(var r=0;r<i.length;r++)this.clippingMaskDrawIndexList.push(e.getDrawDataIndex(i[r]));this.clippedDrawContextList=new Array,this.isUsing=!0,this.layoutChannelNo=0,this.layoutBounds=new H,this.allClippedDrawRect=new H,this.matrixForMask=new Float32Array(16),this.matrixForDraw=new Float32Array(16),this.owner=t}function R(t,e){this._$gP=t,this.drawDataIndex=e}function b(){O||(this.color=null)}function t(){O||(this._$dP=null,this._$eo=null,this._$V0=null,this._$dP=1e3,this._$eo=1e3,this._$V0=1,this._$a0())}function it(){}function F(){this._$r=null,this._$0S=null}function C(){O||(this.x=null,this.y=null,this.width=null,this.height=null)}function n(t){O||at.prototype.constructor.call(this,t)}function s(t){O||at.prototype.constructor.call(this,t)}function N(){O||(this._$vo=null,this._$F2=null,this._$ao=400,this._$1S=400,N._$42++)}function _(){O||(this.p1=new B,this.p2=new B,this._$Fo=0,this._$Db=0,this._$L2=0,this._$M2=0,this._$ks=0,this._$9b=0,this._$iP=0,this._$iT=0,this._$lL=new Array,this._$qP=new Array,this.setup(.3,.5,.1))}function B(){this._$p=1,this.x=0,this.y=0,this.vx=0,this.vy=0,this.ax=0,this.ay=0,this.fx=0,this.fy=0,this._$s0=0,this._$70=0,this._$7L=0,this._$HL=0}function U(t,e,i){this._$wL=null,this.scale=null,this._$V0=null,this._$wL=t,this.scale=e,this._$V0=i}function G(t,e,i,r){U.prototype.constructor.call(this,e,i,r),this._$tL=null,this._$tL=t}function k(t,e,i){this._$wL=null,this.scale=null,this._$V0=null,this._$wL=t,this.scale=e,this._$V0=i}function V(t,e,i,r){k.prototype.constructor.call(this,e,i,r),this._$YP=null,this._$YP=t}function X(){O||(this._$fL=0,this._$gL=0,this._$B0=1,this._$z0=1,this._$qT=0,this.reflectX=!1,this.reflectY=!1)}function H(){O||(this.x=null,this.y=null,this.width=null,this.height=null)}function W(){}function q(){O||(this.x=null,this.y=null)}function r(){O||(this._$gP=null,this._$dr=null,this._$GS=null,this._$qb=null,this._$Lb=null,this._$mS=null,this.clipID=null,this.clipIDList=new Array)}function e(){O||(this._$Eb=e._$ps,this._$lT=1,this._$C0=1,this._$tT=1,this._$WL=1,this.culling=!1,this.matrix4x4=new Float32Array(16),this.premultipliedAlpha=!1,this.anisotropy=0,this.clippingProcess=e.CLIPPING_PROCESS_NONE,this.clipBufPre_clipContextMask=null,this.clipBufPre_clipContextDraw=null,this.CHANNEL_COLORS=new Array)}function j(){O||(this.a=1,this.r=1,this.g=1,this.b=1,this.scale=1,this._$ho=1,this.blendMode=ot.L2D_COLOR_BLEND_MODE_MULT)}function a(){O||(this._$kP=null,this._$dr=null,this._$Ai=!0,this._$mS=null)}function Rt(){}function g(){O||(this._$VP=0,this._$wL=null,this._$GP=null,this._$8o=g._$ds,this._$2r=-1,this._$O2=0,this._$ri=0)}function c(){}function J(){O||(this._$Ob=null)}function i(){this.m=new Float32Array(16),this.identity()}function Q(t){O||at.prototype.constructor.call(this,t)}function p(){O||(this._$7=1,this._$f=0,this._$H=0,this._$g=1,this._$k=0,this._$w=0,this._$hi=STATE_IDENTITY,this._$Z=_$pS)}function f(){this._$4P=null,this._$I0=null,this._$RP=null}function T(){}function u(){}function d(t){O||(this._$QT=!0,this._$co=-1,this._$qo=0,this._$pb=new Array(d._$is),this._$_2=new Float32Array(d._$is),this._$vr=new Float32Array(d._$is),this._$Rr=new Float32Array(d._$is),this._$Or=new Float32Array(d._$is),this._$fs=new Float32Array(d._$is),this._$Js=new Array(d._$is),this._$3S=new Array,this._$aS=new Array,this._$Bo=null,this._$F2=new Array,this._$db=new Array,this._$8b=new Array,this._$Hr=new Array,this._$Ws=null,this._$Vs=null,this._$Er=null,this._$Es=new Int16Array(T._$Qb),this._$ZP=new Float32Array(2*T._$1r),this._$Ri=t,this._$b0=d._$HP++,this.clipManager=null,this.dp_webgl=null)}function Z(){}function o(){O||(e.prototype.constructor.call(this),this._$sb=new Int32Array(o._$As),this._$U2=new Array,this.transform=null,(this.gl=null)==o._$NT&&(o._$NT=o._$9r(256),o._$vS=o._$9r(256),o._$no=o._$vb(256)))}function z(){O||(a.prototype.constructor.call(this),this._$GS=null,this._$Y0=null)}function K(t){P.prototype.constructor.call(this,t),this._$8r=a._$ur,this._$Yr=null,this._$Wr=null}function y(){O||(r.prototype.constructor.call(this),this._$gP=null,this._$dr=null,this._$GS=null,this._$qb=null,this._$Lb=null,this._$mS=null)}function tt(){O||(this._$NL=null,this._$3S=null,this._$aS=null,tt._$42++)}function h(){O||($.prototype.constructor.call(this),this._$zo=new o)}function S(){O||(t.prototype.constructor.call(this),this.motions=new Array,this._$o2=null,this._$7r=S._$Co++,this._$D0=30,this._$yT=0,this._$E=!1,this.loopFadeIn=!0,this._$rr=-1,this._$eP=0)}function et(t,e){return String.fromCharCode(t.getUint8(e))}function f(){this._$4P=null,this._$I0=null,this._$RP=null}function nt(){O||(a.prototype.constructor.call(this),this._$o=0,this._$A=0,this._$GS=null,this._$Eo=null)}function st(t){P.prototype.constructor.call(this,t),this._$8r=a._$ur,this._$Cr=null,this._$hr=null}function l(){O||(this.visible=!0,this._$g0=!1,this._$NL=null,this._$3S=null,this._$aS=null,l._$42++)}function _t(t){this._$VS=null,this._$e0=null,this._$e0=t}function at(t){O||(this.id=t)}function ht(){O||(this._$4S=null)}function rt(t,e){this.canvas=t,this.context=e,this.viewport=new Array(0,0,t.width,t.height),this._$6r=1,this._$xP=0,this._$3r=1,this._$uP=0,this._$Qo=-1,this.cacheImages={}}function lt(){O||(this._$TT=null,this._$LT=null,this._$FS=null,this._$wL=null)}function P(t){O||(this._$e0=null,this._$IP=null,this._$JS=!1,this._$AT=!0,this._$e0=t,this.totalScale=1,this._$7s=1,this.totalOpacity=1)}function ot(){}function $t(){}function ut(t){O||(this._$ib=t)}function M(){O||(y.prototype.constructor.call(this),this._$LP=-1,this._$d0=0,this._$Yo=0,this._$JP=null,this._$5P=null,this._$BP=null,this._$Eo=null,this._$Qi=null,this._$6s=M._$ms,this.culling=!0,this.gl_cacheImage=null,this.instanceNo=M._$42++)}function pt(t){Tt.prototype.constructor.call(this,t),this._$8r=y._$ur,this._$Cr=null,this._$hr=null}function ct(){O||(this.x=null,this.y=null)}function E(t){O||($.prototype.constructor.call(this),this.drawParamWebGL=new A(t),this.drawParamWebGL.setGL(ot.getGL(t)))}function ft(){O||(this.motions=null,this._$eb=!1,this.motions=new Array)}function dt(){this._$w0=null,this._$AT=!0,this._$9L=!1,this._$z2=-1,this._$bs=-1,this._$Do=-1,this._$sr=null,this._$sr=dt._$Gs++}function gt(){this.m=new Array(1,0,0,0,1,0,0,0,1)}function v(t){O||at.prototype.constructor.call(this,t)}function A(t){O||(e.prototype.constructor.call(this),this.textures=new Array,this.transform=null,this.gl=null,this.glno=t,this.firstDraw=!0,this.anisotropyExt=null,this.maxAnisotropy=0,this._$As=32,this._$Gr=!1,this._$NT=null,this._$vS=null,this._$no=null,this.vertShader=null,this.fragShader=null,this.vertShaderOff=null,this.fragShaderOff=null)}function yt(t,e,i){return null==e&&(e=t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,i,t.DYNAMIC_DRAW),e}function mt(t,e,i){return null==e&&(e=t.createBuffer()),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),t.bufferData(t.ELEMENT_ARRAY_BUFFER,i,t.DYNAMIC_DRAW),e}function x(t){O||(this._$P=new Int8Array(8),this._$R0=new DataView(this._$P.buffer),this._$3i=new Int8Array(1e3),this._$hL=0,this._$v0=0,this._$S2=0,this._$Ko=new Array,this._$T=t,this._$F=0)}function I(){}function Tt(t){O||(this._$e0=null,this._$IP=null,this._$Us=null,this._$7s=null,this._$IS=[!1],this._$VS=null,this._$AT=!0,this.baseOpacity=1,this.clipBufPre_clipContext=null,this._$e0=t)}function w(){}function St(){}var O,Pt,Lt;O=!0,$._$0s=1,$._$4s=2,$._$42=0,$._$62=function(t,e){try{if(!((e=e instanceof ArrayBuffer?new DataView(e):e)instanceof DataView))throw new ut("_$SS#loadModel(b) / b _$x be DataView or ArrayBuffer");var i,r=new x(e),o=r._$ST(),n=r._$ST(),s=r._$ST();if(109!=o||111!=n||99!=s)throw new ut("_$gi _$C _$li , _$Q0 _$P0.");if(i=r._$ST(),r._$gr(i),u._$T7<i)throw t._$NP|=$._$4s,new ut("_$gi _$C _$li , _$n0 _$_ version _$li ( SDK : "+u._$T7+" < _$f0 : "+i+" )@_$SS#loadModel()\n");var _=r._$nP();if(u._$s7<=i){var a=r._$9T(),h=r._$9T();if(-30584!=a||-30584!=h)throw t._$NP|=$._$0s,new ut("_$gi _$C _$li , _$0 _$6 _$Ui.")}t._$KS(_);var l=t.getModelContext();l.setDrawParam(t.getDrawParam()),l.init()}catch(t){it._$Rb(t)}},$.prototype._$KS=function(t){this._$MT=t},$.prototype.getModelImpl=function(){return null==this._$MT&&(this._$MT=new N,this._$MT._$zP()),this._$MT},$.prototype.getCanvasWidth=function(){return null==this._$MT?0:this._$MT.getCanvasWidth()},$.prototype.getCanvasHeight=function(){return null==this._$MT?0:this._$MT.getCanvasHeight()},$.prototype.getParamFloat=function(t){return"number"!=typeof t&&(t=this._$5S.getParamIndex(s.getID(t))),this._$5S.getParamFloat(t)},$.prototype.setParamFloat=function(t,e,i){"number"!=typeof t&&(t=this._$5S.getParamIndex(s.getID(t))),arguments.length<3&&(i=1),this._$5S.setParamFloat(t,this._$5S.getParamFloat(t)*(1-i)+e*i)},$.prototype.addToParamFloat=function(t,e,i){"number"!=typeof t&&(t=this._$5S.getParamIndex(s.getID(t))),arguments.length<3&&(i=1),this._$5S.setParamFloat(t,this._$5S.getParamFloat(t)+e*i)},$.prototype.multParamFloat=function(t,e,i){"number"!=typeof t&&(t=this._$5S.getParamIndex(s.getID(t))),arguments.length<3&&(i=1),this._$5S.setParamFloat(t,this._$5S.getParamFloat(t)*(1+(e-1)*i))},$.prototype.getParamIndex=function(t){return this._$5S.getParamIndex(s.getID(t))},$.prototype.loadParam=function(){this._$5S.loadParam()},$.prototype.saveParam=function(){this._$5S.saveParam()},$.prototype.init=function(){this._$5S.init()},$.prototype.update=function(){this._$5S.update()},$.prototype._$Rs=function(){return it._$li("_$60 _$PT _$Rs()"),-1},$.prototype._$Ds=function(t){it._$li("_$60 _$PT _$SS#_$Ds() \n")},$.prototype._$K2=function(){},$.prototype.draw=function(){},$.prototype.getModelContext=function(){return this._$5S},$.prototype._$s2=function(){return this._$NP},$.prototype._$P7=function(t,e,i,r){var o=-1,n=0,s=this;if(0!=i)if(1==t.length){var _=t[0],a=0!=s.getParamFloat(_),h=e[0],l=s.getPartsOpacity(h),$=i/r;a?1<(l+=$)&&(l=1):(l-=$)<0&&(l=0),s.setPartsOpacity(h,l)}else{for(var u=0;u<t.length;u++){_=t[u];if(f=0!=s.getParamFloat(_)){if(0<=o)break;o=u,h=e[u],n=s.getPartsOpacity(h);1<(n+=i/r)&&(n=1)}}o<0&&(console.log("No _$wi _$q0/ _$U default[%s]",t[0]),o=0,n=1,s.loadParam(),s.setParamFloat(t[o],n),s.saveParam());for(u=0;u<t.length;u++){var p,c,h=e[u];o==u?s.setPartsOpacity(h,n):((c=.15<(1-(c=n<.5?-.5*n/.5+1:.5*(1-n)/.5))*(1-n)?1-.15/(1-n):c)<(p=s.getPartsOpacity(h))&&(p=c),s.setPartsOpacity(h,p))}}else for(u=0;u<t.length;u++){var _=t[u],h=e[u],f=0!=s.getParamFloat(_);s.setPartsOpacity(h,f?1:0)}},$.prototype.setPartsOpacity=function(t,e){"number"!=typeof t&&(t=this._$5S.getPartsDataIndex(n.getID(t))),this._$5S.setPartsOpacity(t,e)},$.prototype.getPartsDataIndex=function(t){return t instanceof n||(t=n.getID(t)),this._$5S.getPartsDataIndex(t)},$.prototype.getPartsOpacity=function(t){return(t="number"!=typeof t?this._$5S.getPartsDataIndex(n.getID(t)):t)<0?0:this._$5S.getPartsOpacity(t)},$.prototype.getDrawParam=function(){},$.prototype.getDrawDataIndex=function(t){return this._$5S.getDrawDataIndex(Q.getID(t))},$.prototype.getDrawData=function(t){return this._$5S.getDrawData(t)},$.prototype.getTransformedPoints=function(t){t=this._$5S._$C2(t);return t instanceof pt?t.getTransformedPoints():null},$.prototype.getIndexArray=function(t){return!(t<0||t>=this._$5S._$aS.length)&&null!=(t=this._$5S._$aS[t])&&t.getType()==y._$wb&&t instanceof M?t.getIndexArray():null},L.CHANNEL_COUNT=4,L.RENDER_TEXTURE_USE_MIPMAP=!1,L.NOT_USED_FRAME=-100,L.prototype._$L7=function(){if(this.tmpModelToViewMatrix&&(this.tmpModelToViewMatrix=null),this.tmpMatrix2&&(this.tmpMatrix2=null),this.tmpMatrixForMask&&(this.tmpMatrixForMask=null),this.tmpMatrixForDraw&&(this.tmpMatrixForDraw=null),this.tmpBoundsOnModel&&(this.tmpBoundsOnModel=null),this.CHANNEL_COLORS){for(var t=this.CHANNEL_COLORS.length-1;0<=t;--t)this.CHANNEL_COLORS.splice(t,1);this.CHANNEL_COLORS=[]}this.releaseShader()},L.prototype.releaseShader=function(){for(var t=ot.frameBuffers.length,e=0;e<t;e++)this.gl.deleteFramebuffer(ot.frameBuffers[e].framebuffer);ot.frameBuffers=[],ot.glContext=[]},L.prototype.init=function(t,e,i){for(var r=0;r<e.length;r++){var o,n,s=e[r].getClipIDList();null!=s&&(null==(o=this.findSameClip(s))&&(o=new D(this,t,s),this.clipContextList.push(o)),s=e[r].getDrawDataID(),n=t.getDrawDataIndex(s),o.addClippedDrawData(s,n),i[r].clipBufPre_clipContext=o)}},L.prototype.getMaskRenderTexture=function(){var t=this.dp_webgl.createFramebuffer();return ot.frameBuffers[this.dp_webgl.glno]=t,this.dp_webgl.glno},L.prototype.setupClip=function(t,e){for(var i=0,r=0;r<this.clipContextList.length;r++){var o=this.clipContextList[r];this.calcClippedDrawTotalBounds(t,o),o.isUsing&&i++}if(0<i){var n=e.gl.getParameter(e.gl.FRAMEBUFFER_BINDING),s=new Array(4);s[0]=0,s[1]=0,s[2]=e.gl.canvas.width,s[3]=e.gl.canvas.height,e.gl.viewport(0,0,ot.clippingMaskBufferSize,ot.clippingMaskBufferSize),this.setupLayoutBounds(i),e.gl.bindFramebuffer(e.gl.FRAMEBUFFER,ot.frameBuffers[this.curFrameNo].framebuffer),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT);for(r=0;r<this.clipContextList.length;r++){var _=(o=this.clipContextList[r]).allClippedDrawRect,a=(o.layoutChannelNo,o.layoutBounds),_=(this.tmpBoundsOnModel._$jL(_),this.tmpBoundsOnModel.expand(.05*_.width,.05*_.height),a.width/this.tmpBoundsOnModel.width),h=a.height/this.tmpBoundsOnModel.height;this.tmpMatrix2.identity(),this.tmpMatrix2.translate(-1,-1,0),this.tmpMatrix2.scale(2,2,1),this.tmpMatrix2.translate(a.x,a.y,0),this.tmpMatrix2.scale(_,h,1),this.tmpMatrix2.translate(-this.tmpBoundsOnModel.x,-this.tmpBoundsOnModel.y,0),this.tmpMatrixForMask.setMatrix(this.tmpMatrix2.m),this.tmpMatrix2.identity(),this.tmpMatrix2.translate(a.x,a.y,0),this.tmpMatrix2.scale(_,h,1),this.tmpMatrix2.translate(-this.tmpBoundsOnModel.x,-this.tmpBoundsOnModel.y,0),this.tmpMatrixForDraw.setMatrix(this.tmpMatrix2.m);for(var l=this.tmpMatrixForMask.getArray(),$=0;$<16;$++)o.matrixForMask[$]=l[$];for(var u=this.tmpMatrixForDraw.getArray(),$=0;$<16;$++)o.matrixForDraw[$]=u[$];for(var p=o.clippingMaskDrawIndexList.length,c=0;c<p;c++){var f=o.clippingMaskDrawIndexList[c],d=t.getDrawData(f),f=t._$C2(f);e.setClipBufPre_clipContextForMask(o),d.draw(e,t,f)}}e.gl.bindFramebuffer(e.gl.FRAMEBUFFER,n),e.setClipBufPre_clipContextForMask(null),e.gl.viewport(s[0],s[1],s[2],s[3])}},L.prototype.getColorBuffer=function(){return this.colorBuffer},L.prototype.findSameClip=function(t){for(var e=0;e<this.clipContextList.length;e++){var i=this.clipContextList[e],r=i.clipIDList.length;if(r==t.length){for(var o=0,n=0;n<r;n++)for(var s=i.clipIDList[n],_=0;_<r;_++)if(t[_]==s){o++;break}if(o==r)return i}}return null},L.prototype.calcClippedDrawTotalBounds=function(t,e){for(var i=t._$Ri.getModelImpl().getCanvasWidth(),r=t._$Ri.getModelImpl().getCanvasHeight(),i=r<i?i:r,o=i,n=i,s=0,_=0,a=e.clippedDrawContextList.length,h=0;h<a;h++){var l=e.clippedDrawContextList[h].drawDataIndex,l=t._$C2(l);if(l._$yo()){for(var $=l.getTransformedPoints(),u=$.length,p=[],c=[],f=0,d=T._$i2;d<u;d+=T._$No)p[f]=$[d],c[f]=$[d+1],f++;var l=Math.min.apply(null,p),g=Math.min.apply(null,c),y=Math.max.apply(null,p),m=Math.max.apply(null,c);l<o&&(o=l),g<n&&(n=g),s<y&&(s=y),_<m&&(_=m)}}o==i?(e.allClippedDrawRect.x=0,e.allClippedDrawRect.y=0,e.allClippedDrawRect.width=0,e.allClippedDrawRect.height=0,e.isUsing=!1):(r=s-o,i=_-n,e.allClippedDrawRect.x=o,e.allClippedDrawRect.y=n,e.allClippedDrawRect.width=r,e.allClippedDrawRect.height=i,e.isUsing=!0)},L.prototype.setupLayoutBounds=function(t){for(var e=~~(t/L.CHANNEL_COUNT),i=~~(t%L.CHANNEL_COUNT),r=0,o=0;o<L.CHANNEL_COUNT;o++){var n=e+(o<i?1:0);if(0!=n)if(1==n)(a=this.clipContextList[r++]).layoutChannelNo=o,a.layoutBounds.x=0,a.layoutBounds.y=0,a.layoutBounds.width=1,a.layoutBounds.height=1;else if(2==n)for(var s=0;s<n;s++){var _,a,h=0;_=~~(_=s%2),(a=this.clipContextList[r++]).layoutChannelNo=o,a.layoutBounds.x=.5*_,a.layoutBounds.y=0,a.layoutBounds.width=.5,a.layoutBounds.height=1}else if(n<=4)for(s=0;s<n;s++)_=~~(_=s%2),h=~~(h=s/2),(a=this.clipContextList[r++]).layoutChannelNo=o,a.layoutBounds.x=.5*_,a.layoutBounds.y=.5*h,a.layoutBounds.width=.5,a.layoutBounds.height=.5;else if(n<=9)for(s=0;s<n;s++)_=~~(_=s%3),h=~~(h=s/3),(a=this.clipContextList[r++]).layoutChannelNo=o,a.layoutBounds.x=_/3,a.layoutBounds.y=h/3,a.layoutBounds.width=1/3,a.layoutBounds.height=1/3;else it._$li("_$6 _$0P mask count : %d",n)}},D.prototype.addClippedDrawData=function(t,e){t=new R(t,e);this.clippedDrawContextList.push(t)},t._$JT=function(t,e,i){var t=t/e,i=i/e,e=1-(1-i)*(1-i),r=1-(1-i)*(1-i),e=1/3*(1-i)*e+(2/3*i+1/3*(1-i))*(1-e),i=(i+2/3*(1-i))*r+(1/3*i+2/3*(1-i))*(1-r);return t<=0?0:1<=t?1:t*(r=t*t)*(1-3*i+3*e)+(3*i-6*e+0)*r+3*e*t},t.prototype._$a0=function(){},t.prototype.setFadeIn=function(t){this._$dP=t},t.prototype.setFadeOut=function(t){this._$eo=t},t.prototype._$pT=function(t){this._$V0=t},t.prototype.getFadeOut=function(){return this._$eo},t.prototype._$4T=function(){return this._$eo},t.prototype._$mT=function(){return this._$V0},t.prototype.getDurationMSec=function(){return-1},t.prototype.getLoopDurationMSec=function(){return-1},t.prototype.updateParam=function(t,e){var i,r;e._$AT&&!e._$9L&&(i=Rt.getUserTimeMSec(),e._$z2<0&&(e._$z2=i,e._$bs=i,r=this.getDurationMSec(),e._$Do<0)&&(e._$Do=r<=0?-1:e._$z2+r),0<=(r=this._$V0*(0==this._$dP?1:$t._$r2((i-e._$bs)/this._$dP))*(0==this._$eo||e._$Do<0?1:$t._$r2((e._$Do-i)/this._$eo)))&&r<=1||console.log("### assert!! ### "),this.updateParamExe(t,i,r,e),0<e._$Do)&&e._$Do<i&&(e._$9L=!0)},t.prototype.updateParamExe=function(t,e,i,r){},it._$8s=0,it._$fT=new Object,it.start=function(t){var e=it._$fT[t];null==e&&((e=new F)._$r=t,it._$fT[t]=e),e._$0S=Rt.getSystemTimeMSec()},it.dump=function(t){var e=it._$fT[t];return null!=e?(e=Rt.getSystemTimeMSec()-e._$0S,console.log(t+" : "+e+"ms"),e):-1},it.end=function(t){t=it._$fT[t];return null!=t?Rt.getSystemTimeMSec()-t._$0S:-1},it._$li=function(t,e){console.log("_$li : "+t+"\n",e)},it._$Ji=function(t,e){console.log(t,e)},it._$dL=function(t,e){console.log(t,e),console.log("\n")},it._$KL=function(t,e){for(var i=0;i<e;i++)i%16==0&&0<i?console.log("\n"):i%8==0&&0<i&&console.log(" "),console.log("%02X ",255&t[i]);console.log("\n")},it._$nr=function(t,e,i){console.log("%s\n",t);for(var r=e.length,o=0;o<r;++o)console.log("%5d",e[o]),console.log("%s\n",i),console.log(",");console.log("\n")},it._$Rb=function(t){console.log("dump exception : "+t),console.log("stack :: "+t.stack)},C.prototype._$8P=function(){return.5*(this.x+this.x+this.width)},C.prototype._$6P=function(){return.5*(this.y+this.y+this.height)},C.prototype._$EL=function(){return this.x+this.width},C.prototype._$5T=function(){return this.y+this.height},C.prototype._$jL=function(t,e,i,r){this.x=t,this.y=e,this.width=i,this.height=r},C.prototype._$jL=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},n.prototype=new at,n._$tP=new Object,n._$27=function(){n._$tP.clear()},n.getID=function(t){var e=n._$tP[t];return null==e&&(e=new n(t),n._$tP[t]=e),e},n.prototype._$3s=function(){return new n},s.prototype=new at,s._$tP=new Object,s._$27=function(){s._$tP.clear()},s.getID=function(t){var e=s._$tP[t];return null==e&&(e=new s(t),s._$tP[t]=e),e},s.prototype._$3s=function(){return new s},N._$42=0,N.prototype._$zP=function(){null==this._$vo&&(this._$vo=new ht),null==this._$F2&&(this._$F2=new Array)},N.prototype.getCanvasWidth=function(){return this._$ao},N.prototype.getCanvasHeight=function(){return this._$1S},N.prototype._$F0=function(t){this._$vo=t._$nP(),this._$F2=t._$nP(),this._$ao=t._$6L(),this._$1S=t._$6L()},N.prototype._$6S=function(t){this._$F2.push(t)},N.prototype._$Xr=function(){return this._$F2},N.prototype._$E2=function(){return this._$vo},_.prototype.setup=function(t,e,i){this._$ks=this._$Yb(),this.p2._$xT(),3==arguments.length&&(this._$Fo=t,this._$L2=e,this.p1._$p=i,this.p2._$p=i,this.p2.y=t,this.setup())},_.prototype.getPhysicsPoint1=function(){return this.p1},_.prototype.getPhysicsPoint2=function(){return this.p2},_.prototype._$qr=function(){return this._$Db},_.prototype._$pr=function(t){this._$Db=t},_.prototype._$5r=function(){return this._$M2},_.prototype._$Cs=function(){return this._$9b},_.prototype._$Yb=function(){return-180*Math.atan2(this.p1.x-this.p2.x,-(this.p1.y-this.p2.y))/Math.PI},_.prototype.addSrcParam=function(t,e,i,r){t=new G(t,e,i,r);this._$lL.push(t)},_.prototype.addTargetParam=function(t,e,i,r){t=new V(t,e,i,r);this._$qP.push(t)},_.prototype.update=function(t,e){if(0==this._$iP)this._$iP=this._$iT=e,this._$Fo=Math.sqrt((this.p1.x-this.p2.x)*(this.p1.x-this.p2.x)+(this.p1.y-this.p2.y)*(this.p1.y-this.p2.y));else{var i=(e-this._$iT)/1e3;if(0!=i){for(var r=this._$lL.length-1;0<=r;--r)this._$lL[r]._$oP(t,this);this._$oo(t,i),this._$M2=this._$Yb(),this._$9b=(this._$M2-this._$ks)/i,this._$ks=this._$M2}for(r=this._$qP.length-1;0<=r;--r)this._$qP[r]._$YS(t,this);this._$iT=e}},_.prototype._$oo=function(t,e){var i=1/(e=e<.033?.033:e);this.p1.vx=(this.p1.x-this.p1._$s0)*i,this.p1.vy=(this.p1.y-this.p1._$70)*i,this.p1.ax=(this.p1.vx-this.p1._$7L)*i,this.p1.ay=(this.p1.vy-this.p1._$HL)*i,this.p1.fx=this.p1.ax*this.p1._$p,this.p1.fy=this.p1.ay*this.p1._$p,this.p1._$xT();var r=-Math.atan2(this.p1.y-this.p2.y,this.p1.x-this.p2.x),o=Math.cos(r),n=Math.sin(r),s=9.8*this.p2._$p,_=this._$Db*I._$bS,s=s*Math.cos(r-_),r=s*o,_=-this.p1.fx*n*n,o=-this.p1.fy*n*o,a=-this.p2.vx*this._$L2,h=-this.p2.vy*this._$L2,s=(this.p2.fx=s*n+_+a,this.p2.fy=r+o+h,this.p2.ax=this.p2.fx/this.p2._$p,this.p2.ay=this.p2.fy/this.p2._$p,this.p2.vx+=this.p2.ax*e,this.p2.vy+=this.p2.ay*e,this.p2.x+=this.p2.vx*e,this.p2.y+=this.p2.vy*e,Math.sqrt((this.p1.x-this.p2.x)*(this.p1.x-this.p2.x)+(this.p1.y-this.p2.y)*(this.p1.y-this.p2.y)));this.p2.x=this.p1.x+this._$Fo*(this.p2.x-this.p1.x)/s,this.p2.y=this.p1.y+this._$Fo*(this.p2.y-this.p1.y)/s,this.p2.vx=(this.p2.x-this.p2._$s0)*i,this.p2.vy=(this.p2.y-this.p2._$70)*i,this.p2._$xT()},B.prototype._$xT=function(){this._$s0=this.x,this._$70=this.y,this._$7L=this.vx,this._$HL=this.vy},U.prototype._$oP=function(t,e){},(G.prototype=new U)._$oP=function(t,e){var i=this.scale*t.getParamFloat(this._$wL),r=e.getPhysicsPoint1();switch(this._$tL){default:case _.Src.SRC_TO_X:r.x=r.x+(i-r.x)*this._$V0;break;case _.Src.SRC_TO_Y:r.y=r.y+(i-r.y)*this._$V0;break;case _.Src.SRC_TO_G_ANGLE:var o=e._$qr();o+=(i-o)*this._$V0,e._$pr(o)}},k.prototype._$YS=function(t,e){},(V.prototype=new k)._$YS=function(t,e){switch(this._$YP){default:case _.Target.TARGET_FROM_ANGLE:t.setParamFloat(this._$wL,this.scale*e._$5r(),this._$V0);break;case _.Target.TARGET_FROM_ANGLE_V:t.setParamFloat(this._$wL,this.scale*e._$Cs(),this._$V0)}},(_.Src=function(){}).SRC_TO_X="SRC_TO_X",_.Src.SRC_TO_Y="SRC_TO_Y",_.Src.SRC_TO_G_ANGLE="SRC_TO_G_ANGLE",(_.Target=function(){}).TARGET_FROM_ANGLE="TARGET_FROM_ANGLE",_.Target.TARGET_FROM_ANGLE_V="TARGET_FROM_ANGLE_V",X.prototype.init=function(t){this._$fL=t._$fL,this._$gL=t._$gL,this._$B0=t._$B0,this._$z0=t._$z0,this._$qT=t._$qT,this.reflectX=t.reflectX,this.reflectY=t.reflectY},X.prototype._$F0=function(t){this._$fL=t._$_T(),this._$gL=t._$_T(),this._$B0=t._$_T(),this._$z0=t._$_T(),this._$qT=t._$_T(),t.getFormatVersion()>=u.LIVE2D_FORMAT_VERSION_V2_10_SDK2&&(this.reflectX=t._$po(),this.reflectY=t._$po())},X.prototype._$e=function(){},St._$ni=function(t,e,i,r,o,n,s,_,a){var h,l=s*n-_*o;return 0==l?null:(l=((t-i)*n-(e-r)*o)/l,h=0!=o?(t-i-l*s)/o:(e-r-l*_)/n,isNaN(h)&&(h=(t-i-l*s)/o,isNaN(h)&&(h=(e-r-l*_)/n),isNaN(h))&&(console.log("a is NaN @UtVector#_$ni() "),console.log("v1x : "+o),console.log("v1x != 0 ? "+(0!=o))),null==a?new Array(h,l):(a[0]=h,a[1]=l,a))},H.prototype._$8P=function(){return this.x+.5*this.width},H.prototype._$6P=function(){return this.y+.5*this.height},H.prototype._$EL=function(){return this.x+this.width},H.prototype._$5T=function(){return this.y+this.height},H.prototype._$jL=function(t,e,i,r){this.x=t,this.y=e,this.width=i,this.height=r},H.prototype._$jL=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},H.prototype.contains=function(t,e){return this.x<=this.x&&this.y<=this.y&&this.x<=this.x+this.width&&this.y<=this.y+this.height},H.prototype.expand=function(t,e){this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e},W._$Z2=function(t,e,i,r){var o,n,s,_,a,h,C,l,N,$,B,u,U,p,c,f,d,g,y,m,T,S,P,L,M,E,v,A,x,I=e._$Q2(t,i),w=t._$vs(),O=t._$Tr();if(e._$zr(w,O,I),I<=0)return r[w[0]];if(1==I)return(M=r[w[0]])+((E=r[w[1]])-M)*(p=O[0])|0;if(2==I)return M=r[w[0]],E=r[w[1]],v=r[w[2]],A=r[w[3]],(x=M+(E-M)*(p=O[0])|0)+((v+(A-v)*p|0)-x)*(c=O[1])|0;if(3==I)return d=r[w[0]],g=r[w[1]],y=r[w[2]],m=r[w[3]],T=r[w[4]],S=r[w[5]],P=r[w[6]],L=r[w[7]],(x=(M=d+(g-d)*(p=O[0])|0)+((E=y+(m-y)*p|0)-M)*(c=O[1])|0)+(((v=T+(S-T)*p|0)+((A=P+(L-P)*p|0)-v)*c|0)-x)*(f=O[2])|0;if(4==I)return i=r[w[0]],t=r[w[1]],e=r[w[2]],o=r[w[3]],n=r[w[4]],s=r[w[5]],_=r[w[6]],a=r[w[7]],h=r[w[8]],C=r[w[9]],l=r[w[10]],N=r[w[11]],$=r[w[12]],B=r[w[13]],u=r[w[14]],U=r[w[15]],(x=(M=(d=i+(t-i)*(p=O[0])|0)+((g=e+(o-e)*p|0)-d)*(c=O[1])|0)+((E=(y=n+(s-n)*p|0)+((m=_+(a-_)*p|0)-y)*c|0)-M)*(f=O[2])|0)+(((v=(T=h+(C-h)*p|0)+((S=l+(N-l)*p|0)-T)*c|0)+((A=(P=$+(B-$)*p|0)+((L=u+(U-u)*p|0)-P)*c|0)-v)*f|0)-x)*O[3]|0;for(var D=1<<I,G=new Float32Array(D),R=0;R<D;R++){for(var Y=R,k=1,b=0;b<I;b++)k*=Y%2==0?1-O[b]:O[b],Y/=2;G[R]=k}for(var V=new Float32Array(D),F=0;F<D;F++)V[F]=r[w[F]];for(var X=0,F=0;F<D;F++)X+=G[F]*V[F];return X+.5|0},W._$br=function(t,e,i,r){var o,n,s,_,a,h,l,$,u,p,c,f,d,g,y,m,T,S=e._$Q2(t,i),P=t._$vs(),L=t._$Tr();if(e._$zr(P,L,S),S<=0)return r[P[0]];if(1==S)return(n=r[P[0]])+((o=r[P[1]])-n)*(g=L[0]);if(2==S)return n=r