window.Laya=function(exports){"use strict";class Config{}Config.animationInterval=50,Config.isAntialias=!1,Config.isAlpha=!1,Config.premultipliedAlpha=!0,Config.isStencil=!0,Config.preserveDrawingBuffer=!1,Config.webGL2D_MeshAllocMaxMem=!0,Config.is2DPixelArtGame=!1,Config.useWebGL2=!0,Config.useRetinalCanvas=!1,window.Config=Config;class ILaya{static regClass(c){ILaya.__classMap[c.name]=c}}ILaya.Laya=null,ILaya.Timer=null,ILaya.WorkerLoader=null,ILaya.Dragging=null,ILaya.GraphicsBounds=null,ILaya.Sprite=null,ILaya.TextRender=null,ILaya.TextAtlas=null,ILaya.timer=null,ILaya.systemTimer=null,ILaya.startTimer=null,ILaya.updateTimer=null,ILaya.lateTimer=null,ILaya.physicsTimer=null,ILaya.stage=null,ILaya.Loader=null,ILaya.loader=null,ILaya.TTFLoader=null,ILaya.SoundManager=null,ILaya.WebAudioSound=null,ILaya.AudioSound=null,ILaya.ShaderCompile=null,ILaya.ClassUtils=null,ILaya.SceneUtils=null,ILaya.Context=null,ILaya.Render=null,ILaya.MouseManager=null,ILaya.Text=null,ILaya.Browser=null,ILaya.WebGL=null,ILaya.Pool=null,ILaya.Utils=null,ILaya.Graphics=null,ILaya.Submit=null,ILaya.Stage=null,ILaya.Resource=null,ILaya.__classMap={};class Pool{static getPoolBySign(sign){return Pool._poolDic[sign]||(Pool._poolDic[sign]=[])}static clearBySign(sign){Pool._poolDic[sign]&&(Pool._poolDic[sign].length=0)}static recover(sign,item){item[Pool.POOLSIGN]||(item[Pool.POOLSIGN]=!0,Pool.getPoolBySign(sign).push(item))}static recoverByClass(instance){if(instance){var className=instance.__className||instance.constructor._$gid;className&&Pool.recover(className,instance)}}static _getClassSign(cla){var className=cla.__className||cla._$gid;return className||(cla._$gid=className=Pool._CLSID+"",Pool._CLSID++),className}static createByClass(cls){return Pool.getItemByClass(Pool._getClassSign(cls),cls)}static getItemByClass(sign,cls){if(!Pool._poolDic[sign])return new cls;var pool=Pool.getPoolBySign(sign);if(pool.length){var rst=pool.pop();rst[Pool.POOLSIGN]=!1}else rst=new cls;return rst}static getItemByCreateFun(sign,createFun,caller=null){var pool=Pool.getPoolBySign(sign),rst=pool.length?pool.pop():createFun.call(caller);return rst[Pool.POOLSIGN]=!1,rst}static getItem(sign){var pool=Pool.getPoolBySign(sign),rst=pool.length?pool.pop():null;return rst&&(rst[Pool.POOLSIGN]=!1),rst}}Pool._CLSID=0,Pool.POOLSIGN="__InPool",Pool._poolDic={};class AlphaCmd{static create(alpha){var cmd=Pool.getItemByClass("AlphaCmd",AlphaCmd);return cmd.alpha=alpha,cmd}recover(){Pool.recover("AlphaCmd",this)}run(context,gx,gy){context.alpha(this.alpha)}get cmdID(){return AlphaCmd.ID}}AlphaCmd.ID="Alpha";class DrawCircleCmd{static create(x,y,radius,fillColor,lineColor,lineWidth,vid){var cmd=Pool.getItemByClass("DrawCircleCmd",DrawCircleCmd);return cmd.x=x,cmd.y=y,cmd.radius=radius,cmd.fillColor=fillColor,cmd.lineColor=lineColor,cmd.lineWidth=lineWidth,cmd.vid=vid,cmd}recover(){this.fillColor=null,this.lineColor=null,Pool.recover("DrawCircleCmd",this)}run(context,gx,gy){context._drawCircle(this.x+gx,this.y+gy,this.radius,this.fillColor,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return DrawCircleCmd.ID}}DrawCircleCmd.ID="DrawCircle";class DrawCurvesCmd{static create(x,y,points,lineColor,lineWidth){var cmd=Pool.getItemByClass("DrawCurvesCmd",DrawCurvesCmd);return cmd.x=x,cmd.y=y,cmd.points=points,cmd.lineColor=lineColor,cmd.lineWidth=lineWidth,cmd}recover(){this.points=null,this.lineColor=null,Pool.recover("DrawCurvesCmd",this)}run(context,gx,gy){context.drawCurves(this.x+gx,this.y+gy,this.points,this.lineColor,this.lineWidth)}get cmdID(){return DrawCurvesCmd.ID}}DrawCurvesCmd.ID="DrawCurves";class DrawImageCmd{static create(texture,x,y,width,height){var cmd=Pool.getItemByClass("DrawImageCmd",DrawImageCmd);return cmd.texture=texture,texture._addReference(),cmd.x=x,cmd.y=y,cmd.width=width,cmd.height=height,cmd}recover(){this.texture._removeReference(),this.texture=null,Pool.recover("DrawImageCmd",this)}run(context,gx,gy){context.drawTexture(this.texture,this.x+gx,this.y+gy,this.width,this.height)}get cmdID(){return DrawImageCmd.ID}}DrawImageCmd.ID="DrawImage";class DrawLineCmd{static create(fromX,fromY,toX,toY,lineColor,lineWidth,vid){var cmd=Pool.getItemByClass("DrawLineCmd",DrawLineCmd);return cmd.fromX=fromX,cmd.fromY=fromY,cmd.toX=toX,cmd.toY=toY,cmd.lineColor=lineColor,cmd.lineWidth=lineWidth,cmd.vid=vid,cmd}recover(){Pool.recover("DrawLineCmd",this)}run(context,gx,gy){context._drawLine(gx,gy,this.fromX,this.fromY,this.toX,this.toY,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return DrawLineCmd.ID}}DrawLineCmd.ID="DrawLine";class DrawLinesCmd{static create(x,y,points,lineColor,lineWidth,vid){var cmd=Pool.getItemByClass("DrawLinesCmd",DrawLinesCmd);return cmd.x=x,cmd.y=y,cmd.points=points,cmd.lineColor=lineColor,cmd.lineWidth=lineWidth,cmd.vid=vid,cmd}recover(){this.points=null,this.lineColor=null,Pool.recover("DrawLinesCmd",this)}run(context,gx,gy){context._drawLines(this.x+gx,this.y+gy,this.points,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return DrawLinesCmd.ID}}DrawLinesCmd.ID="DrawLines";class DrawPathCmd{static create(x,y,paths,brush,pen){var cmd=Pool.getItemByClass("DrawPathCmd",DrawPathCmd);return cmd.x=x,cmd.y=y,cmd.paths=paths,cmd.brush=brush,cmd.pen=pen,cmd}recover(){this.paths=null,this.brush=null,this.pen=null,Pool.recover("DrawPathCmd",this)}run(context,gx,gy){context._drawPath(this.x+gx,this.y+gy,this.paths,this.brush,this.pen)}get cmdID(){return DrawPathCmd.ID}}DrawPathCmd.ID="DrawPath";class DrawPieCmd{static create(x,y,radius,startAngle,endAngle,fillColor,lineColor,lineWidth,vid){var cmd=Pool.getItemByClass("DrawPieCmd",DrawPieCmd);return cmd.x=x,cmd.y=y,cmd.radius=radius,cmd._startAngle=startAngle,cmd._endAngle=endAngle,cmd.fillColor=fillColor,cmd.lineColor=lineColor,cmd.lineWidth=lineWidth,cmd.vid=vid,cmd}recover(){this.fillColor=null,this.lineColor=null,Pool.recover("DrawPieCmd",this)}run(context,gx,gy){context._drawPie(this.x+gx,this.y+gy,this.radius,this._startAngle,this._endAngle,this.fillColor,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return DrawPieCmd.ID}get startAngle(){return 180*this._startAngle/Math.PI}set startAngle(value){this._startAngle=value*Math.PI/180}get endAngle(){return 180*this._endAngle/Math.PI}set endAngle(value){this._endAngle=value*Math.PI/180}}DrawPieCmd.ID="DrawPie";class DrawPolyCmd{static create(x,y,points,fillColor,lineColor,lineWidth,isConvexPolygon,vid){var cmd=Pool.getItemByClass("DrawPolyCmd",DrawPolyCmd);return cmd.x=x,cmd.y=y,cmd.points=points,cmd.fillColor=fillColor,cmd.lineColor=lineColor,cmd.lineWidth=lineWidth,cmd.isConvexPolygon=isConvexPolygon,cmd.vid=vid,cmd}recover(){this.points=null,this.fillColor=null,this.lineColor=null,Pool.recover("DrawPolyCmd",this)}run(context,gx,gy){context._drawPoly(this.x+gx,this.y+gy,this.points,this.fillColor,this.lineColor,this.lineWidth,this.isConvexPolygon,this.vid)}get cmdID(){return DrawPolyCmd.ID}}DrawPolyCmd.ID="DrawPoly";class DrawRectCmd{static create(x,y,width,height,fillColor,lineColor,lineWidth){var cmd=Pool.getItemByClass("DrawRectCmd",DrawRectCmd);return cmd.x=x,cmd.y=y,cmd.width=width,cmd.height=height,cmd.fillColor=fillColor,cmd.lineColor=lineColor,cmd.lineWidth=lineWidth,cmd}recover(){this.fillColor=null,this.lineColor=null,Pool.recover("DrawRectCmd",this)}run(context,gx,gy){context.drawRect(this.x+gx,this.y+gy,this.width,this.height,this.fillColor,this.lineColor,this.lineWidth)}get cmdID(){return DrawRectCmd.ID}}DrawRectCmd.ID="DrawRect";class Matrix{constructor(a=1,b=0,c=0,d=1,tx=0,ty=0,nums=0){if(this._bTransform=!1,null!=Matrix._createFun)return Matrix._createFun(a,b,c,d,tx,ty,nums);this.a=a,this.b=b,this.c=c,this.d=d,this.tx=tx,this.ty=ty,this._checkTransform()}identity(){return this.a=this.d=1,this.b=this.tx=this.ty=this.c=0,this._bTransform=!1,this}_checkTransform(){return this._bTransform=1!==this.a||0!==this.b||0!==this.c||1!==this.d}setTranslate(x,y){return this.tx=x,this.ty=y,this}translate(x,y){return this.tx+=x,this.ty+=y,this}scale(x,y){return this.a*=x,this.d*=y,this.c*=x,this.b*=y,this.tx*=x,this.ty*=y,this._bTransform=!0,this}rotate(angle){var cos=Math.cos(angle),sin=Math.sin(angle),a1=this.a,c1=this.c,tx1=this.tx;return this.a=a1*cos-this.b*sin,this.b=a1*sin+this.b*cos,this.c=c1*cos-this.d*sin,this.d=c1*sin+this.d*cos,this.tx=tx1*cos-this.ty*sin,this.ty=tx1*sin+this.ty*cos,this._bTransform=!0,this}skew(x,y){var tanX=Math.tan(x),tanY=Math.tan(y),a1=this.a,b1=this.b;return this.a+=tanY*this.c,this.b+=tanY*this.d,this.c+=tanX*a1,this.d+=tanX*b1,this}invertTransformPoint(out){var a1=this.a,b1=this.b,c1=this.c,d1=this.d,tx1=this.tx,n=a1*d1-b1*c1,a2=d1/n,b2=-b1/n,c2=-c1/n,d2=a1/n,tx2=(c1*this.ty-d1*tx1)/n,ty2=-(a1*this.ty-b1*tx1)/n;return out.setTo(a2*out.x+c2*out.y+tx2,b2*out.x+d2*out.y+ty2)}transformPoint(out){return out.setTo(this.a*out.x+this.c*out.y+this.tx,this.b*out.x+this.d*out.y+this.ty)}transformPointN(out){return out.setTo(this.a*out.x+this.c*out.y,this.b*out.x+this.d*out.y)}getScaleX(){return 0===this.b?this.a:Math.sqrt(this.a*this.a+this.b*this.b)}getScaleY(){return 0===this.c?this.d:Math.sqrt(this.c*this.c+this.d*this.d)}invert(){var a1=this.a,b1=this.b,c1=this.c,d1=this.d,tx1=this.tx,n=a1*d1-b1*c1;return this.a=d1/n,this.b=-b1/n,this.c=-c1/n,this.d=a1/n,this.tx=(c1*this.ty-d1*tx1)/n,this.ty=-(a1*this.ty-b1*tx1)/n,this}setTo(a,b,c,d,tx,ty){return this.a=a,this.b=b,this.c=c,this.d=d,this.tx=tx,this.ty=ty,this}concat(matrix){var a=this.a,c=this.c,tx=this.tx;return this.a=a*matrix.a+this.b*matrix.c,this.b=a*matrix.b+this.b*matrix.d,this.c=c*matrix.a+this.d*matrix.c,this.d=c*matrix.b+this.d*matrix.d,this.tx=tx*matrix.a+this.ty*matrix.c+matrix.tx,this.ty=tx*matrix.b+this.ty*matrix.d+matrix.ty,this}static mul(m1,m2,out){var aa=m1.a,ab=m1.b,ac=m1.c,ad=m1.d,atx=m1.tx,aty=m1.ty,ba=m2.a,bb=m2.b,bc=m2.c,bd=m2.d,btx=m2.tx,bty=m2.ty;return 0!==bb||0!==bc?(out.a=aa*ba+ab*bc,out.b=aa*bb+ab*bd,out.c=ac*ba+ad*bc,out.d=ac*bb+ad*bd,out.tx=ba*atx+bc*aty+btx,out.ty=bb*atx+bd*aty+bty):(out.a=aa*ba,out.b=ab*bd,out.c=ac*ba,out.d=ad*bd,out.tx=ba*atx+btx,out.ty=bd*aty+bty),out}static mul16(m1,m2,out){var aa=m1.a,ab=m1.b,ac=m1.c,ad=m1.d,atx=m1.tx,aty=m1.ty,ba=m2.a,bb=m2.b,bc=m2.c,bd=m2.d,btx=m2.tx,bty=m2.ty;return 0!==bb||0!==bc?(out[0]=aa*ba+ab*bc,out[1]=aa*bb+ab*bd,out[4]=ac*ba+ad*bc,out[5]=ac*bb+ad*bd,out[12]=ba*atx+bc*aty+btx,out[13]=bb*atx+bd*aty+bty):(out[0]=aa*ba,out[1]=ab*bd,out[4]=ac*ba,out[5]=ad*bd,out[12]=ba*atx+btx,out[13]=bd*aty+bty),out}scaleEx(x,y){var ba=this.a,bb=this.b,bc=this.c,bd=this.d;0!==bb||0!==bc?(this.a=x*ba,this.b=x*bb,this.c=y*bc,this.d=y*bd):(this.a=x*ba,this.b=0*bd,this.c=0*ba,this.d=y*bd),this._bTransform=!0}rotateEx(angle){var cos=Math.cos(angle),sin=Math.sin(angle),ba=this.a,bb=this.b,bc=this.c,bd=this.d;0!==bb||0!==bc?(this.a=cos*ba+sin*bc,this.b=cos*bb+sin*bd,this.c=-sin*ba+cos*bc,this.d=-sin*bb+cos*bd):(this.a=cos*ba,this.b=sin*bd,this.c=-sin*ba,this.d=cos*bd),this._bTransform=!0}clone(){var dec=Matrix.create();return dec.a=this.a,dec.b=this.b,dec.c=this.c,dec.d=this.d,dec.tx=this.tx,dec.ty=this.ty,dec._bTransform=this._bTransform,dec}copyTo(dec){return dec.a=this.a,dec.b=this.b,dec.c=this.c,dec.d=this.d,dec.tx=this.tx,dec.ty=this.ty,dec._bTransform=this._bTransform,dec}toString(){return this.a+","+this.b+","+this.c+","+this.d+","+this.tx+","+this.ty}destroy(){this.recover()}recover(){Pool.recover("Matrix",this.identity())}static create(){return Pool.getItemByClass("Matrix",Matrix)}}Matrix.EMPTY=new Matrix,Matrix.TEMP=new Matrix,Matrix._createFun=null;class Point{constructor(x=0,y=0){this.x=x,this.y=y}static create(){return Pool.getItemByClass("Point",Point)}setTo(x,y){return this.x=x,this.y=y,this}reset(){return this.x=this.y=0,this}recover(){Pool.recover("Point",this.reset())}distance(x,y){return Math.sqrt((this.x-x)*(this.x-x)+(this.y-y)*(this.y-y))}toString(){return this.x+","+this.y}normalize(){var d=Math.sqrt(this.x*this.x+this.y*this.y);if(d>0){var id=1/d;this.x*=id,this.y*=id}}copy(point){return this.setTo(point.x,point.y)}}Point.TEMP=new Point,Point.EMPTY=new Point;class Rectangle{constructor(x=0,y=0,width=0,height=0){this.x=x,this.y=y,this.width=width,this.height=height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}setTo(x,y,width,height){return this.x=x,this.y=y,this.width=width,this.height=height,this}reset(){return this.x=this.y=this.width=this.height=0,this}recover(){this!=Rectangle.TEMP&&this!=Rectangle.EMPTY?Pool.recover("Rectangle",this.reset()):console.log("recover Temp or Empty:",this)}static create(){return Pool.getItemByClass("Rectangle",Rectangle)}copyFrom(source){return this.x=source.x,this.y=source.y,this.width=source.width,this.height=source.height,this}contains(x,y){return!(this.width<=0||this.height<=0)&&(x>=this.x&&x=this.y&&ythis.x+this.width||rect.x+rect.widththis.y+this.height||rect.y+rect.heightx&&(this.width+=this.x-x,this.x=x),this.y>y&&(this.height+=this.y-y,this.y=y),this.widthtPoint.x?maxX:tPoint.x,maxY=maxY>tPoint.y?maxY:tPoint.y;return rst.setTo(minX,minY,maxX-minX,maxY-minY)}isEmpty(){return this.width<=0||this.height<=0}}Rectangle.EMPTY=new Rectangle,Rectangle.TEMP=new Rectangle,Rectangle._temB=[],Rectangle._temA=[];class LayaGL{}LayaGL.ARRAY_BUFFER_TYPE_DATA=0,LayaGL.ARRAY_BUFFER_TYPE_CMD=1,LayaGL.ARRAY_BUFFER_REF_REFERENCE=0,LayaGL.ARRAY_BUFFER_REF_COPY=1,LayaGL.UPLOAD_SHADER_UNIFORM_TYPE_ID=0,LayaGL.UPLOAD_SHADER_UNIFORM_TYPE_DATA=1;class Handler{constructor(caller=null,method=null,args=null,once=!1){this.once=!1,this._id=0,this.setTo(caller,method,args,once)}setTo(caller,method,args,once){return this._id=Handler._gid++,this.caller=caller,this.method=method,this.args=args,this.once=once,this}run(){if(null==this.method)return null;var id=this._id,result=this.method.apply(this.caller,this.args);return this._id===id&&this.once&&this.recover(),result}runWith(data){if(null==this.method)return null;var id=this._id;if(null==data)var result=this.method.apply(this.caller,this.args);else result=this.args||data.unshift?this.args?this.method.apply(this.caller,this.args.concat(data)):this.method.apply(this.caller,data):this.method.call(this.caller,data);return this._id===id&&this.once&&this.recover(),result}clear(){return this.caller=null,this.method=null,this.args=null,this}recover(){this._id>0&&(this._id=0,Handler._pool.push(this.clear()))}static create(caller,method,args=null,once=!0){return Handler._pool.length?Handler._pool.pop().setTo(caller,method,args,once):new Handler(caller,method,args,once)}}Handler._pool=[],Handler._gid=1;class EventDispatcher{hasListener(type){return!!(this._events&&this._events[type])}event(type,data=null){if(!this._events||!this._events[type])return!1;var listeners=this._events[type];if(listeners.run)listeners.once&&delete this._events[type],null!=data?listeners.runWith(data):listeners.run();else{for(var i=0,n=listeners.length;i-1;i--)arr[i]&&(arr[i].recover(),arr[i]=null)}isMouseEvent(type){return EventDispatcher.MOUSE_EVENTS[type]||!1}}EventDispatcher.MOUSE_EVENTS={rightmousedown:!0,rightmouseup:!0,rightclick:!0,mousedown:!0,mouseup:!0,mousemove:!0,mouseover:!0,mouseout:!0,click:!0,doubleclick:!0};class EventHandler extends Handler{constructor(caller,method,args,once){super(caller,method,args,once)}recover(){this._id>0&&(this._id=0,EventHandler._pool.push(this.clear()))}static create(caller,method,args=null,once=!0){return EventHandler._pool.length?EventHandler._pool.pop().setTo(caller,method,args,once):new EventHandler(caller,method,args,once)}}EventHandler._pool=[];class URL{constructor(url){this._url=URL.formatURL(url),this._path=URL.getPath(url)}get url(){return this._url}get path(){return this._path}static set basePath(value){URL._basePath=ILaya.Laya._getUrlPath(),URL._basePath=URL.formatURL(value)}static get basePath(){return URL._basePath}static formatURL(url){if(!url)return"null path";if(url.indexOf(":")>0)return url;if(null!=URL.customFormat&&(url=URL.customFormat(url)),url.indexOf(":")>0)return url;var char1=url.charAt(0);if("."===char1)return URL._formatRelativePath(URL._basePath+url);if("~"===char1)return URL.rootPath+url.substring(1);if("d"===char1){if(0===url.indexOf("data:image"))return url}else if("/"===char1)return url;return URL._basePath+url}static _formatRelativePath(value){for(var parts=value.split("/"),i=0,len=parts.length;i0?url.substr(0,ofs+1):""}static getFileName(url){var ofs=url.lastIndexOf("/");return ofs>0?url.substr(ofs+1):url}static getAdptedFilePath(url){if(!URL.exportSceneToJson||!url)return url;var i,len,tArr;for(len=URL._adpteTypeList.length,i=0;i>i,1),Math.max(height>>i,1));this._setGPUMemory(width*height*4*(1+1/3))}else this._mipmapCount=1,this._setGPUMemory(width*height*4)}static __init__(){var pixels=new Uint8Array(3);pixels[0]=128,pixels[1]=128,pixels[2]=128,Texture2D.grayTexture=new Texture2D(1,1,BaseTexture.FORMAT_R8G8B8,!1,!1),Texture2D.grayTexture.setPixels(pixels),Texture2D.grayTexture.lock=!0,pixels[0]=255,pixels[1]=255,pixels[2]=255,Texture2D.whiteTexture=new Texture2D(1,1,BaseTexture.FORMAT_R8G8B8,!1,!1),Texture2D.whiteTexture.setPixels(pixels),Texture2D.whiteTexture.lock=!0,pixels[0]=0,pixels[1]=0,pixels[2]=0,Texture2D.blackTexture=new Texture2D(1,1,BaseTexture.FORMAT_R8G8B8,!1,!1),Texture2D.blackTexture.setPixels(pixels),Texture2D.blackTexture.lock=!0}static _parse(data,propertyParams=null,constructParams=null){var texture=constructParams?new Texture2D(constructParams[0],constructParams[1],constructParams[2],constructParams[3],constructParams[4]):new Texture2D(0,0);switch(propertyParams&&(texture.wrapModeU=propertyParams.wrapModeU,texture.wrapModeV=propertyParams.wrapModeV,texture.filterMode=propertyParams.filterMode,texture.anisoLevel=propertyParams.anisoLevel),texture._format){case BaseTexture.FORMAT_R8G8B8:case BaseTexture.FORMAT_R8G8B8A8:texture.loadImageSource(data);break;case BaseTexture.FORMAT_DXT1:case BaseTexture.FORMAT_DXT5:case BaseTexture.FORMAT_ETC1RGB:case BaseTexture.FORMAT_PVRTCRGB_2BPPV:case BaseTexture.FORMAT_PVRTCRGBA_2BPPV:case BaseTexture.FORMAT_PVRTCRGB_4BPPV:case BaseTexture.FORMAT_PVRTCRGBA_4BPPV:texture.setCompressData(data);break;default:throw"Texture2D:unkonwn format."}return texture}static load(url,complete){ILaya.loader.create(url,complete,null,ILaya.Loader.TEXTURE2D)}get defaulteTexture(){return Texture2D.grayTexture}_setPixels(pixels,miplevel,width,height){var gl=LayaGL.instance,textureType=this._glTextureType,glFormat=this._getGLFormat();WebGLContext.bindTexture(gl,textureType,this._glTexture),this.format===BaseTexture.FORMAT_R8G8B8?(gl.pixelStorei(gl.UNPACK_ALIGNMENT,1),gl.texImage2D(textureType,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels),gl.pixelStorei(gl.UNPACK_ALIGNMENT,4)):gl.texImage2D(textureType,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels)}_calcualatesCompressedDataSize(format,width,height){switch(format){case BaseTexture.FORMAT_DXT1:case BaseTexture.FORMAT_ETC1RGB:return(width+3>>2)*(height+3>>2)*8;case BaseTexture.FORMAT_DXT5:return(width+3>>2)*(height+3>>2)*16;case BaseTexture.FORMAT_PVRTCRGB_4BPPV:case BaseTexture.FORMAT_PVRTCRGBA_4BPPV:return Math.floor((Math.max(width,8)*Math.max(height,8)*4+7)/8);case BaseTexture.FORMAT_PVRTCRGB_2BPPV:case BaseTexture.FORMAT_PVRTCRGBA_2BPPV:return Math.floor((Math.max(width,16)*Math.max(height,8)*2+7)/8);default:return 0}}_pharseDDS(arrayBuffer){var header=new Int32Array(arrayBuffer,0,31);if(542327876!=header[0])throw"Invalid magic number in DDS header";if(!(4&header[20]))throw"Unsupported format, must contain a FourCC code";var compressedFormat=header[21];switch(this._format){case BaseTexture.FORMAT_DXT1:if(827611204!==compressedFormat)throw"the FourCC code is not same with texture format.";break;case BaseTexture.FORMAT_DXT5:if(894720068!==compressedFormat)throw"the FourCC code is not same with texture format.";break;default:throw"unknown texture format."}var mipLevels=1;if(131072&header[2]){if(mipLevels=Math.max(1,header[7]),!this._mipmap)throw"the mipmap is not same with Texture2D."}else if(this._mipmap)throw"the mipmap is not same with Texture2D.";var width=header[4],height=header[3];this._width=width,this._height=height;var dataOffset=header[1]+4;this._upLoadCompressedTexImage2D(arrayBuffer,width,height,mipLevels,dataOffset,0)}_pharseKTX(arrayBuffer){var id=new Uint8Array(arrayBuffer,0,12);if(171!=id[0]||75!=id[1]||84!=id[2]||88!=id[3]||32!=id[4]||49!=id[5]||49!=id[6]||187!=id[7]||13!=id[8]||10!=id[9]||26!=id[10]||10!=id[11])throw"Invalid fileIdentifier in KTX header";var header=new Int32Array(id.buffer,id.length,13);switch(header[4]){case LayaGL.layaGPUInstance._compressedTextureEtc1.COMPRESSED_RGB_ETC1_WEBGL:this._format=BaseTexture.FORMAT_ETC1RGB;break;default:throw"unknown texture format."}var mipLevels=header[11],width=header[6],height=header[7];this._width=width,this._height=height;var dataOffset=64+header[12];this._upLoadCompressedTexImage2D(arrayBuffer,width,height,mipLevels,dataOffset,4)}_pharsePVR(arrayBuffer){var header=new Int32Array(arrayBuffer,0,13);if(55727696!=header[0])throw"Invalid magic number in PVR header";switch(header[2]){case 0:this._format=BaseTexture.FORMAT_PVRTCRGB_2BPPV;break;case 2:this._format=BaseTexture.FORMAT_PVRTCRGB_4BPPV;break;case 1:this._format=BaseTexture.FORMAT_PVRTCRGBA_2BPPV;break;case 3:this._format=BaseTexture.FORMAT_PVRTCRGBA_4BPPV;break;default:throw"Texture2D:unknown PVR format."}var mipLevels=header[11],width=header[7],height=header[6];this._width=width,this._height=height;var dataOffset=header[12]+52;this._upLoadCompressedTexImage2D(arrayBuffer,width,height,mipLevels,dataOffset,0)}_upLoadCompressedTexImage2D(data,width,height,miplevelCount,dataOffset,imageSizeOffset){var gl=LayaGL.instance,textureType=this._glTextureType;WebGLContext.bindTexture(gl,textureType,this._glTexture);for(var glFormat=this._getGLFormat(),offset=dataOffset,i=0;i>1,1),height=Math.max(height>>1,1),offset+=mipDataSize}var memory=offset;this._setGPUMemory(memory),this._readyed=!0,this._activeResource()}loadImageSource(source,premultiplyAlpha=!1){var gl=LayaGL.instance,width=source.width,height=source.height;this._width=width,this._height=height,this._isPot(width)&&this._isPot(height)||(this._mipmap=!1),this._setWarpMode(gl.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(gl.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture);var glFormat=this._getGLFormat();ILaya.Render.isConchApp?(source.setPremultiplyAlpha&&source.setPremultiplyAlpha(premultiplyAlpha),gl.texImage2D(this._glTextureType,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,source)):(premultiplyAlpha&&gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),gl.texImage2D(this._glTextureType,0,glFormat,glFormat,gl.UNSIGNED_BYTE,source),premultiplyAlpha&&gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)),this._mipmap?(gl.generateMipmap(this._glTextureType),this._setGPUMemory(width*height*4*(1+1/3))):this._setGPUMemory(width*height*4),this._canRead&&(ILaya.Render.isConchApp?this._pixels=new Uint8Array(source._nativeObj.getImageData(0,0,width,height)):(ILaya.Browser.canvas.size(width,height),ILaya.Browser.canvas.clear(),ILaya.Browser.context.drawImage(source,0,0,width,height),this._pixels=new Uint8Array(ILaya.Browser.context.getImageData(0,0,width,height).data.buffer))),this._readyed=!0,this._activeResource()}setPixels(pixels,miplevel=0){if(!pixels)throw"Texture2D:pixels can't be null.";var width=Math.max(this._width>>miplevel,1),height=Math.max(this._height>>miplevel,1),pixelsCount=width*height*this._getFormatByteCount();if(pixels.length=1e4&&console.error("getRT error! w too big"),new RenderTexture2D(w,h,BaseTexture.FORMAT_R8G8B8A8,-1)}static releaseRT(rt){rt._disposeResource()}}WebGLRTMgr.dict={};class BlendMode{static _init_(gl){BlendMode.fns=[BlendMode.BlendNormal,BlendMode.BlendAdd,BlendMode.BlendMultiply,BlendMode.BlendScreen,BlendMode.BlendOverlay,BlendMode.BlendLight,BlendMode.BlendMask,BlendMode.BlendDestinationOut],BlendMode.targetFns=[BlendMode.BlendNormalTarget,BlendMode.BlendAddTarget,BlendMode.BlendMultiplyTarget,BlendMode.BlendScreenTarget,BlendMode.BlendOverlayTarget,BlendMode.BlendLightTarget,BlendMode.BlendMask,BlendMode.BlendDestinationOut]}static BlendNormal(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.ONE_MINUS_SRC_ALPHA)}static BlendAdd(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.DST_ALPHA)}static BlendMultiply(gl){WebGLContext.setBlendFunc(gl,gl.DST_COLOR,gl.ONE_MINUS_SRC_ALPHA)}static BlendScreen(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.ONE)}static BlendOverlay(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.ONE_MINUS_SRC_COLOR)}static BlendLight(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.ONE)}static BlendNormalTarget(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.ONE_MINUS_SRC_ALPHA)}static BlendAddTarget(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.DST_ALPHA)}static BlendMultiplyTarget(gl){WebGLContext.setBlendFunc(gl,gl.DST_COLOR,gl.ONE_MINUS_SRC_ALPHA)}static BlendScreenTarget(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.ONE)}static BlendOverlayTarget(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.ONE_MINUS_SRC_COLOR)}static BlendLightTarget(gl){WebGLContext.setBlendFunc(gl,gl.ONE,gl.ONE)}static BlendMask(gl){WebGLContext.setBlendFunc(gl,gl.ZERO,gl.SRC_ALPHA)}static BlendDestinationOut(gl){WebGLContext.setBlendFunc(gl,gl.ZERO,gl.ZERO)}}BlendMode.activeBlendFunction=null,BlendMode.NAMES=["normal","add","multiply","screen","overlay","light","mask","destination-out"],BlendMode.TOINT={normal:0,add:1,multiply:2,screen:3,overlay:4,light:5,mask:6,"destination-out":7,lighter:1},BlendMode.NORMAL="normal",BlendMode.ADD="add",BlendMode.MULTIPLY="multiply",BlendMode.SCREEN="screen",BlendMode.OVERLAY="overlay",BlendMode.LIGHT="light",BlendMode.MASK="mask",BlendMode.DESTINATIONOUT="destination-out",BlendMode.LIGHTER="lighter",BlendMode.fns=[],BlendMode.targetFns=[];class ShaderDefinesBase{constructor(name2int,int2name,int2nameMap){this._value=0,this._name2int=name2int,this._int2name=int2name,this._int2nameMap=int2nameMap}add(value){return this._value|="string"==typeof value?this._name2int[value]:value,this._value}addInt(value){return this._value|=value,this._value}remove(value){return this._value&="string"==typeof value?~this._name2int[value]:~value,this._value}isDefine(def){return(this._value&def)===def}getValue(){return this._value}setValue(value){this._value=value}toNameDic(){var r=this._int2nameMap[this._value];return r||ShaderDefinesBase._toText(this._value,this._int2name,this._int2nameMap)}static _reg(name,value,_name2int,_int2name){_name2int[name]=value,_int2name[value]=name}static _toText(value,_int2name,_int2nameMap){var r=_int2nameMap[value];if(r)return r;for(var o={},d=1,i=0;i<32&&!((d=1<value);i++)if(value&d){var name=_int2name[d];name&&(o[name]="")}return _int2nameMap[value]=o,o}static _toInt(names,_name2int){for(var words=names.split("."),num=0,i=0,n=words.length;i0&&(one.name=one.name.substr(0,one.name.length-3),one.isArray=!0,one.location=gl.getUniformLocation(this._program,one.name)),this._params.push(one)}for(i=0,n=this._params.length;i=0;i-=2)(one=this._paramsMap[shaderValue[i]])&&null!=(value=shaderValue[i+1])&&(_bufferUsage&&_bufferUsage[one.name]&&_bufferUsage[one.name].bind(),shaderCall+=one.fun.call(this,one,value));Stat.shaderCall+=shaderCall}getParams(){return this._params}setAttributesLocation(attribDesc){this._attribInfo=attribDesc}}Shader._count=0,Shader._preCompileShader={},Shader.SHADERNAME2ID=2e-4,Shader.nameKey=new StringKey,Shader.sharders=new Array(32);class Shader2X extends Shader{constructor(vs,ps,saveName=null,nameMap=null,bindAttrib=null){super(vs,ps,saveName,nameMap,bindAttrib),this._params2dQuick2=null,this._shaderValueWidth=0,this._shaderValueHeight=0}_disposeResource(){super._disposeResource(),this._params2dQuick2=null}upload2dQuick2(shaderValue){this.upload(shaderValue,this._params2dQuick2||this._make2dQuick2())}_make2dQuick2(){if(!this._params2dQuick2){this._params2dQuick2=[];for(var one,params=this._params,i=0,n=params.length;i0&&!this._inClassCache&&(this._inClassCache=Value2D._cache[this._cacheID]=[],this._inClassCache._length=0),this.clear()}static _initone(type,classT){Value2D._typeClass[type]=classT,Value2D._cache[type]=[],Value2D._cache[type]._length=0}static __init__(){}setValue(value){}_ShaderWithCompile(){return Shader.withCompile2D(0,this.mainID,this.defines.toNameDic(),this.mainID|this.defines._value,Shader2X.create,this._attribLocation)}upload(){var renderstate2d=RenderState2D;RenderState2D.worldMatrix4===RenderState2D.TEMPMAT4_ARRAY||this.defines.addInt(ShaderDefines2D.WORLDMAT),this.mmat=renderstate2d.worldMatrix4,RenderState2D.matWVP&&(this.defines.addInt(ShaderDefines2D.MVP3D),this.u_MvpMatrix=RenderState2D.matWVP.elements);var sd=Shader.sharders[this.mainID|this.defines._value]||this._ShaderWithCompile();sd._shaderValueWidth!==renderstate2d.width||sd._shaderValueHeight!==renderstate2d.height?(this.size[0]=renderstate2d.width,this.size[1]=renderstate2d.height,sd._shaderValueWidth=renderstate2d.width,sd._shaderValueHeight=renderstate2d.height,sd.upload(this,null)):sd.upload(this,sd._params2dQuick2||sd._make2dQuick2())}setFilters(value){if(this.filters=value,value)for(var f,n=value.length,i=0;i-1&&array[j]._zOrder>key;)array[j+1]=array[j];array[j+1]=c,i++}return!0}static transPointList(points,x,y){var i,len=points.length;for(i=0;i1?result[1].toLowerCase():null}static getTransformRelativeToWindow(coordinateSpace,x,y){var stage=Utils.gStage,globalTransform=Utils.getGlobalPosAndScale(coordinateSpace),canvasMatrix=stage._canvasTransform.clone(),canvasLeft=canvasMatrix.tx,canvasTop=canvasMatrix.ty;canvasMatrix.rotate(-Math.PI/180*stage.canvasDegree),canvasMatrix.scale(stage.clientScaleX,stage.clientScaleY);var tx,ty,domScaleX,domScaleY,perpendicular=stage.canvasDegree%180!=0;return perpendicular?(tx=y+globalTransform.y,ty=x+globalTransform.x,tx*=canvasMatrix.d,ty*=canvasMatrix.a,90==stage.canvasDegree?(tx=canvasLeft-tx,ty+=canvasTop):(tx+=canvasLeft,ty=canvasTop-ty)):(tx=x+globalTransform.x,ty=y+globalTransform.y,tx*=canvasMatrix.a,ty*=canvasMatrix.d,tx+=canvasLeft,ty+=canvasTop),ty+=stage._safariOffsetY,perpendicular?(domScaleX=canvasMatrix.d*globalTransform.height,domScaleY=canvasMatrix.a*globalTransform.width):(domScaleX=canvasMatrix.a*globalTransform.width,domScaleY=canvasMatrix.d*globalTransform.height),{x:tx,y:ty,scaleX:domScaleX,scaleY:domScaleY}}static fitDOMElementInArea(dom,coordinateSpace,x,y,width,height){dom._fitLayaAirInitialized||(dom._fitLayaAirInitialized=!0,dom.style.transformOrigin=dom.style.webKittransformOrigin="left top",dom.style.position="absolute");var transform=Utils.getTransformRelativeToWindow(coordinateSpace,x,y);dom.style.transform=dom.style.webkitTransform="scale("+transform.scaleX+","+transform.scaleY+") rotate("+Utils.gStage.canvasDegree+"deg)",dom.style.width=width+"px",dom.style.height=height+"px",dom.style.left=transform.x+"px",dom.style.top=transform.y+"px"}static isOkTextureList(textureList){if(!textureList)return!1;var i,tTexture,len=textureList.length;for(i=0;i\s+<"),(rst=(new DOMParser).parseFromString(value,"text/xml")).firstChild.textContent.indexOf("This page contains the following errors")>-1)throw new Error(rst.firstChild.firstChild.textContent);return rst};class ColorUtils{constructor(value){if(this.arrColor=[],null==value)return this.strColor="#00000000",this.numColor=0,void(this.arrColor=[0,0,0,0]);var i,len,color;if("string"==typeof value)if(value.indexOf("rgba(")>=0||value.indexOf("rgb(")>=0){var beginI,endI,tStr=value;for(beginI=tStr.indexOf("("),endI=tStr.indexOf(")"),tStr=tStr.substring(beginI+1,endI),this.arrColor=tStr.split(","),len=this.arrColor.length,i=0;i=0||9===this.strColor.length?(this.arrColor=[((4278190080&color)>>>24)/255,((16711680&color)>>16)/255,((65280&color)>>8)/255,(255&color)/255],this.numColor=(4278190080&color)>>>24|(16711680&color)>>8|(65280&color)<<8|(255&color)<<24):(this.arrColor=[((16711680&color)>>16)/255,((65280&color)>>8)/255,(255&color)/255,1],this.numColor=4278190080|(16711680&color)>>16|65280&color|(255&color)<<16),this.arrColor.__id=++ColorUtils._COLODID}static _initDefault(){for(var i in ColorUtils._DEFAULT={},ColorUtils._COLOR_MAP)ColorUtils._SAVE[i]=ColorUtils._DEFAULT[i]=new ColorUtils(ColorUtils._COLOR_MAP[i]);return ColorUtils._DEFAULT}static _initSaveMap(){for(var i in ColorUtils._SAVE_SIZE=0,ColorUtils._SAVE={},ColorUtils._DEFAULT)ColorUtils._SAVE[i]=ColorUtils._DEFAULT[i]}static create(value){var key=value+"",color=ColorUtils._SAVE[key];return null!=color?color:(ColorUtils._SAVE_SIZE<1e3&&ColorUtils._initSaveMap(),ColorUtils._SAVE[key]=new ColorUtils(value))}}ColorUtils._SAVE={},ColorUtils._SAVE_SIZE=0,ColorUtils._COLOR_MAP={purple:"#800080",orange:"#ffa500",white:"#FFFFFF",red:"#FF0000",green:"#00FF00",blue:"#0000FF",black:"#000000",yellow:"#FFFF00",gray:"#808080"},ColorUtils._DEFAULT=ColorUtils._initDefault(),ColorUtils._COLODID=1;class ColorFilter extends Filter{constructor(mat=null){super(),mat||(mat=this._copyMatrix(ColorFilter.IDENTITY_MATRIX)),this._mat=new Float32Array(16),this._alpha=new Float32Array(4),this.setByMatrix(mat)}gray(){return this.setByMatrix(ColorFilter.GRAY_MATRIX)}color(red=0,green=0,blue=0,alpha=1){return this.setByMatrix([1,0,0,0,red,0,1,0,0,green,0,0,1,0,blue,0,0,0,1,alpha])}setColor(color){var arr=ColorUtils.create(color).arrColor,mt=[0,0,0,0,256*arr[0],0,0,0,0,256*arr[1],0,0,0,0,256*arr[2],0,0,0,1,0];return this.setByMatrix(mt)}setByMatrix(matrix){this._matrix!=matrix&&this._copyMatrix(matrix);for(var j=0,z=0,i=0;i<20;i++)i%5!=4?this._mat[j++]=matrix[i]:this._alpha[z++]=matrix[i];return this}get type(){return Filter.COLOR}adjustColor(brightness,contrast,saturation,hue){return this.adjustHue(hue),this.adjustContrast(contrast),this.adjustBrightness(brightness),this.adjustSaturation(saturation),this}adjustBrightness(brightness){return 0==(brightness=this._clampValue(brightness,100))||isNaN(brightness)?this:this._multiplyMatrix([1,0,0,0,brightness,0,1,0,0,brightness,0,0,1,0,brightness,0,0,0,1,0,0,0,0,0,1])}adjustContrast(contrast){if(0==(contrast=this._clampValue(contrast,100))||isNaN(contrast))return this;var x,x1=(x=contrast<0?127+contrast/100*127:127*(x=0==(x=contrast%1)?ColorFilter.DELTA_INDEX[contrast]:ColorFilter.DELTA_INDEX[contrast<<0]*(1-x)+ColorFilter.DELTA_INDEX[1+(contrast<<0)]*x)+127)/127,x2=.5*(127-x);return this._multiplyMatrix([x1,0,0,0,x2,0,x1,0,0,x2,0,0,x1,0,x2,0,0,0,1,0,0,0,0,0,1])}adjustSaturation(saturation){if(0==(saturation=this._clampValue(saturation,100))||isNaN(saturation))return this;var x=1+(saturation>0?3*saturation/100:saturation/100),dx=1-x,r=.3086*dx,g=.6094*dx,b=.082*dx;return this._multiplyMatrix([r+x,g,b,0,0,r,g+x,b,0,0,r,g,b+x,0,0,0,0,0,1,0,0,0,0,0,1])}adjustHue(hue){if(0==(hue=this._clampValue(hue,180)/180*Math.PI)||isNaN(hue))return this;var cos=Math.cos(hue),sin=Math.sin(hue),r=.213,g=.715,b=.072;return this._multiplyMatrix([r+cos*(1-r)+sin*-r,g+cos*-g+sin*-g,b+cos*-b+sin*(1-b),0,0,r+cos*-r+.143*sin,g+cos*(1-g)+.14*sin,b+cos*-b+-.283*sin,0,0,r+cos*-r+-.787*sin,g+cos*-g+sin*g,b+cos*(1-b)+sin*b,0,0,0,0,0,1,0,0,0,0,0,1])}reset(){return this.setByMatrix(this._copyMatrix(ColorFilter.IDENTITY_MATRIX))}_multiplyMatrix(matrix){var col=[];this._matrix=this._fixMatrix(this._matrix);for(var i=0;i<5;i++){for(var j=0;j<5;j++)col[j]=this._matrix[j+5*i];for(j=0;j<5;j++){for(var val=0,k=0;k<5;k++)val+=matrix[j+5*k]*col[k];this._matrix[j+5*i]=val}}return this.setByMatrix(this._matrix)}_clampValue(val,limit){return Math.min(limit,Math.max(-limit,val))}_fixMatrix(matrix=null){return null==matrix?ColorFilter.IDENTITY_MATRIX:(matrix.lengthColorFilter.LENGTH&&(matrix=matrix.slice(0,ColorFilter.LENGTH)),matrix)}_copyMatrix(matrix){var len=ColorFilter.LENGTH;this._matrix||(this._matrix=[]);for(var i=0;i0?count:5),i=0;i<=1;i+=dLen)this._calFun(i,rst)}getBezierPoints(pList,inSertCount=5,count=2){var i,len;if((len=pList.length)<2*(count+1))return[];var rst=[];switch(count){case 2:this._calFun=this.getPoint2;break;case 3:this._calFun=this.getPoint3;break;default:return[]}for(;this._controlPoints.length<=count;)this._controlPoints.push(Point.create());for(i=0;i<2*count;i+=2)this._switchPoint(pList[i],pList[i+1]);for(i=2*count;i=0;i--)(key=(tmp=PointSet[i]).x+"_"+tmp.y)in _tmpDic||(_tmpDic[key]=!0,ch.push(tmp));for(n=ch.length,Utils.copyArray(PointSet,ch),i=1;i0||0==GrahamScan.multiply(PointSet[j],PointSet[k],PointSet[0])&&GrahamScan.dis(PointSet[0],PointSet[j])=2&&GrahamScan.multiply(PointSet[i],ch[ch.length-1],ch[ch.length-2])>=0;)ch.pop();PointSet[i]&&ch.push(PointSet[i])}return ch}}GrahamScan._tempPointList=[],GrahamScan._temPList=[],GrahamScan._temArr=[];class DrawStyle{constructor(value){this.setValue(value)}static create(value){if(value){var color=value instanceof ColorUtils?value:ColorUtils.create(value);return color._drawStyle||(color._drawStyle=new DrawStyle(value))}return DrawStyle.DEFAULT}setValue(value){this._color=value?value instanceof ColorUtils?value:ColorUtils.create(value):ColorUtils.create("#000000")}reset(){this._color=ColorUtils.create("#000000")}toInt(){return this._color.numColor}equal(value){return"string"==typeof value?this._color.strColor===value:value instanceof ColorUtils&&this._color.numColor===value.numColor}toColorStr(){return this._color.strColor}}DrawStyle.DEFAULT=new DrawStyle("#000000");class Path{constructor(){this._lastOriX=0,this._lastOriY=0,this.paths=[],this._curPath=null}beginPath(convex){this.paths.length=1,this._curPath=this.paths[0]=new renderPath,this._curPath.convex=convex}closePath(){this._curPath.loop=!0}newPath(){this._curPath=new renderPath,this.paths.push(this._curPath)}addPoint(pointX,pointY){this._curPath.path.push(pointX,pointY)}push(points,convex){this._curPath?this._curPath.path.length>0&&(this._curPath=new renderPath,this.paths.push(this._curPath)):(this._curPath=new renderPath,this.paths.push(this._curPath));var rp=this._curPath;rp.path=points.slice(),rp.convex=convex}reset(){this.paths.length=0}}class renderPath{constructor(){this.path=[],this.loop=!1,this.convex=!1}}class SubmitBase{constructor(renderType=SubmitBase.TYPE_2D){this.clipInfoID=-1,this._mesh=null,this._blendFn=null,this._id=0,this._renderType=0,this._parent=null,this._key=new SubmitKey,this._startIdx=0,this._numEle=0,this._ref=1,this.shaderValue=null,this._renderType=renderType,this._id=++SubmitBase.ID}static __init__(){var s=SubmitBase.RENDERBASE=new SubmitBase(-1);s.shaderValue=new Value2D(0,0),s.shaderValue.ALPHA=1,s._ref=4294967295}getID(){return this._id}getRenderType(){return this._renderType}toString(){return"ibindex:"+this._startIdx+" num:"+this._numEle+" key="+this._key}renderSubmit(){return 1}releaseRender(){}}SubmitBase.TYPE_2D=1e4,SubmitBase.TYPE_CANVAS=10003,SubmitBase.TYPE_CMDSETRT=10004,SubmitBase.TYPE_CUSTOM=10005,SubmitBase.TYPE_BLURRT=10006,SubmitBase.TYPE_CMDDESTORYPRERT=10007,SubmitBase.TYPE_DISABLESTENCIL=10008,SubmitBase.TYPE_OTHERIBVB=10009,SubmitBase.TYPE_PRIMITIVE=10010,SubmitBase.TYPE_RT=10011,SubmitBase.TYPE_BLUR_RT=10012,SubmitBase.TYPE_TARGET=10013,SubmitBase.TYPE_CHANGE_VALUE=10014,SubmitBase.TYPE_SHAPE=10015,SubmitBase.TYPE_TEXTURE=10016,SubmitBase.TYPE_FILLTEXTURE=10017,SubmitBase.KEY_ONCE=-1,SubmitBase.KEY_FILLRECT=1,SubmitBase.KEY_DRAWTEXTURE=2,SubmitBase.KEY_VG=3,SubmitBase.KEY_TRIANGLES=4,SubmitBase.ID=1,SubmitBase.preRender=null;class SaveBase{constructor(){}static _createArray(){var value=[];return value._length=0,value}static _init(){var namemap=SaveBase._namemap={};return namemap[SaveBase.TYPE_ALPHA]="ALPHA",namemap[SaveBase.TYPE_FILESTYLE]="fillStyle",namemap[SaveBase.TYPE_FONT]="font",namemap[SaveBase.TYPE_LINEWIDTH]="lineWidth",namemap[SaveBase.TYPE_STROKESTYLE]="strokeStyle",namemap[SaveBase.TYPE_ENABLEMERGE]="_mergeID",namemap[SaveBase.TYPE_MARK]=namemap[SaveBase.TYPE_TRANSFORM]=namemap[SaveBase.TYPE_TRANSLATE]=[],namemap[SaveBase.TYPE_TEXTBASELINE]="textBaseline",namemap[SaveBase.TYPE_TEXTALIGN]="textAlign",namemap[SaveBase.TYPE_GLOBALCOMPOSITEOPERATION]="_nBlendType",namemap[SaveBase.TYPE_SHADER]="shader",namemap[SaveBase.TYPE_FILTERS]="filters",namemap[SaveBase.TYPE_COLORFILTER]="_colorFiler",namemap}isSaveMark(){return!1}restore(context){this._dataObj[this._valueName]=this._value,SaveBase.POOL[SaveBase.POOL._length++]=this,this._newSubmit&&(context._curSubmit=SubmitBase.RENDERBASE)}static save(context,type,dataObj,newSubmit){if((context._saveMark._saveuse&type)!==type){context._saveMark._saveuse|=type;var cache=SaveBase.POOL,o=cache._length>0?cache[--cache._length]:new SaveBase;o._value=dataObj[o._valueName=SaveBase._namemap[type]],o._dataObj=dataObj,o._newSubmit=newSubmit;var _save=context._save;_save[_save._length++]=o}}}SaveBase.TYPE_ALPHA=1,SaveBase.TYPE_FILESTYLE=2,SaveBase.TYPE_FONT=8,SaveBase.TYPE_LINEWIDTH=256,SaveBase.TYPE_STROKESTYLE=512,SaveBase.TYPE_MARK=1024,SaveBase.TYPE_TRANSFORM=2048,SaveBase.TYPE_TRANSLATE=4096,SaveBase.TYPE_ENABLEMERGE=8192,SaveBase.TYPE_TEXTBASELINE=16384,SaveBase.TYPE_TEXTALIGN=32768,SaveBase.TYPE_GLOBALCOMPOSITEOPERATION=65536,SaveBase.TYPE_CLIPRECT=131072,SaveBase.TYPE_CLIPRECT_STENCIL=262144,SaveBase.TYPE_IBVB=524288,SaveBase.TYPE_SHADER=1048576,SaveBase.TYPE_FILTERS=2097152,SaveBase.TYPE_FILTERS_TYPE=4194304,SaveBase.TYPE_COLORFILTER=8388608,SaveBase.POOL=SaveBase._createArray(),SaveBase._namemap=SaveBase._init();class SaveClipRect{constructor(){this._globalClipMatrix=new Matrix,this._clipInfoID=-1,this._clipRect=new Rectangle,this.incache=!1}isSaveMark(){return!1}restore(context){this._globalClipMatrix.copyTo(context._globalClipMatrix),this._clipRect.clone(context._clipRect),context._clipInfoID=this._clipInfoID,SaveClipRect.POOL[SaveClipRect.POOL._length++]=this,context._clipInCache=this.incache}static save(context){if((context._saveMark._saveuse&SaveBase.TYPE_CLIPRECT)!=SaveBase.TYPE_CLIPRECT){context._saveMark._saveuse|=SaveBase.TYPE_CLIPRECT;var cache=SaveClipRect.POOL,o=cache._length>0?cache[--cache._length]:new SaveClipRect;context._globalClipMatrix.copyTo(o._globalClipMatrix),context._clipRect.clone(o._clipRect),o._clipInfoID=context._clipInfoID,o.incache=context._clipInCache;var _save=context._save;_save[_save._length++]=o}}}SaveClipRect.POOL=SaveBase._createArray();class SaveMark{constructor(){this._saveuse=0}isSaveMark(){return!0}restore(context){context._saveMark=this._preSaveMark,SaveMark.POOL[SaveMark.POOL._length++]=this}static Create(context){var no=SaveMark.POOL,o=no._length>0?no[--no._length]:new SaveMark;return o._saveuse=0,o._preSaveMark=context._saveMark,context._saveMark=o,o}}SaveMark.POOL=SaveBase._createArray();class SaveTransform{constructor(){this._matrix=new Matrix}isSaveMark(){return!1}restore(context){context._curMat=this._savematrix,SaveTransform.POOL[SaveTransform.POOL._length++]=this}static save(context){var _saveMark=context._saveMark;if((_saveMark._saveuse&SaveBase.TYPE_TRANSFORM)!==SaveBase.TYPE_TRANSFORM){_saveMark._saveuse|=SaveBase.TYPE_TRANSFORM;var no=SaveTransform.POOL,o=no._length>0?no[--no._length]:new SaveTransform;o._savematrix=context._curMat,context._curMat=context._curMat.copyTo(o._matrix);var _save=context._save;_save[_save._length++]=o}}}SaveTransform.POOL=SaveBase._createArray();class SaveTranslate{constructor(){this._mat=new Matrix}isSaveMark(){return!1}restore(context){this._mat.copyTo(context._curMat),SaveTranslate.POOL[SaveTranslate.POOL._length++]=this}static save(context){var no=SaveTranslate.POOL,o=no._length>0?no[--no._length]:new SaveTranslate;context._curMat.copyTo(o._mat);var _save=context._save;_save[_save._length++]=o}}SaveTranslate.POOL=SaveBase._createArray();class RenderInfo{}RenderInfo.loopStTm=0,RenderInfo.loopCount=0;class Buffer{constructor(){this._byteLength=0,this._glBuffer=LayaGL.instance.createBuffer()}get bufferUsage(){return this._bufferUsage}_bindForVAO(){}bind(){return!1}destroy(){this._glBuffer&&(LayaGL.instance.deleteBuffer(this._glBuffer),this._glBuffer=null)}}class Buffer2D extends Buffer{constructor(){super(),this._maxsize=0,this._upload=!0,this._uploadSize=0,this._bufferSize=0,this._u8Array=null}static __int__(gl){}get bufferLength(){return this._buffer.byteLength}set byteLength(value){this.setByteLength(value)}setByteLength(value){this._byteLength!==value&&(value<=this._bufferSize||this._resizeBuffer(2*value+256,!0),this._byteLength=value)}needSize(sz){var old=this._byteLength;if(sz){var needsz=this._byteLength+sz;needsz<=this._bufferSize||this._resizeBuffer(needsz<<1,!0),this._byteLength=needsz}return old}_bufferData(){this._maxsize=Math.max(this._maxsize,this._byteLength),RenderInfo.loopCount%30==0&&(this._buffer.byteLength>this._maxsize+64&&(this._buffer=this._buffer.slice(0,this._maxsize+64),this._bufferSize=this._buffer.byteLength,this._checkArrayUse()),this._maxsize=this._byteLength),this._uploadSizethis._maxsize+64&&(this._buffer=this._buffer.slice(0,this._maxsize+64),this._bufferSize=this._buffer.byteLength,this._checkArrayUse()),this._maxsize=this._byteLength),this._uploadSize0){var newbuffer=new ArrayBuffer(nsz),oldU8Arr=u8buf&&u8buf.buffer==buff?u8buf:new Uint8Array(buff);(u8buf=this._u8Array=new Uint8Array(newbuffer)).set(oldU8Arr,0),buff=this._buffer=newbuffer}else buff=this._buffer=new ArrayBuffer(nsz),this._u8Array=null;return this._checkArrayUse(),this._upload=!0,this._bufferSize=buff.byteLength,this}append(data){var byteLen,n;this._upload=!0,byteLen=data.byteLength,data instanceof Uint8Array?(this._resizeBuffer(this._byteLength+byteLen,!0),n=new Uint8Array(this._buffer,this._byteLength)):data instanceof Uint16Array?(this._resizeBuffer(this._byteLength+byteLen,!0),n=new Uint16Array(this._buffer,this._byteLength)):data instanceof Float32Array&&(this._resizeBuffer(this._byteLength+byteLen,!0),n=new Float32Array(this._buffer,this._byteLength)),n.set(data,0),this._byteLength+=byteLen,this._checkArrayUse()}appendU16Array(data,len){this._resizeBuffer(this._byteLength+2*len,!0);var u=new Uint16Array(this._buffer,this._byteLength,len);if(6==len)u[0]=data[0],u[1]=data[1],u[2]=data[2],u[3]=data[3],u[4]=data[4],u[5]=data[5];else if(len>=100)u.set(new Uint16Array(data.buffer,0,len));else for(var i=0;i>2;this.setByteLength(this._byteLength+4*data.length),this.getFloat32Array().set(data,oldoff),this._upload=!0}_checkArrayUse(){this._floatArray32&&(this._floatArray32=new Float32Array(this._buffer)),this._uint32Array&&(this._uint32Array=new Uint32Array(this._buffer))}deleteBuffer(){super._disposeResource()}_bindForVAO(){var gl=LayaGL.instance;gl.bindBuffer(gl.ARRAY_BUFFER,this._glBuffer)}bind(){if(Buffer._bindedVertexBuffer!==this._glBuffer){var gl=LayaGL.instance;return gl.bindBuffer(gl.ARRAY_BUFFER,this._glBuffer),Buffer._bindedVertexBuffer=this._glBuffer,!0}return!1}destroy(){super.destroy(),this._byteLength=0,this._upload=!0,this._buffer=null,this._floatArray32=null}}VertexBuffer2D.create=function(vertexStride,bufferUsage=35048){return new VertexBuffer2D(vertexStride,bufferUsage)};class IndexBuffer2D extends Buffer2D{constructor(bufferUsage=35044){super(),this._bufferUsage=bufferUsage,this._bufferType=LayaGL.instance.ELEMENT_ARRAY_BUFFER,this._buffer=new ArrayBuffer(8)}_checkArrayUse(){this._uint16Array&&(this._uint16Array=new Uint16Array(this._buffer))}getUint16Array(){return this._uint16Array||(this._uint16Array=new Uint16Array(this._buffer))}_bindForVAO(){var gl=LayaGL.instance;gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this._glBuffer)}bind(){if(Buffer._bindedIndexBuffer!==this._glBuffer){var gl=LayaGL.instance;return gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this._glBuffer),Buffer._bindedIndexBuffer=this._glBuffer,!0}return!1}destory(){this._uint16Array=null,this._buffer=null}disposeResource(){this._disposeResource()}}IndexBuffer2D.create=function(bufferUsage=35044){return new IndexBuffer2D(bufferUsage)};class BufferStateBase{constructor(){this._nativeVertexArrayObject=LayaGL.layaGPUInstance.createVertexArray()}bind(){BufferStateBase._curBindedBufferState!==this&&(LayaGL.layaGPUInstance.bindVertexArray(this._nativeVertexArrayObject),BufferStateBase._curBindedBufferState=this)}unBind(){if(BufferStateBase._curBindedBufferState!==this)throw"BufferState: must call bind() function first.";LayaGL.layaGPUInstance.bindVertexArray(null),BufferStateBase._curBindedBufferState=null}destroy(){LayaGL.layaGPUInstance.deleteVertexArray(this._nativeVertexArrayObject)}bindForNative(){LayaGL.instance.bindVertexArray(this._nativeVertexArrayObject),BufferStateBase._curBindedBufferState=this}unBindForNative(){LayaGL.instance.bindVertexArray(null),BufferStateBase._curBindedBufferState=null}}class BufferState2D extends BufferStateBase{constructor(){super()}}class Mesh2D{constructor(stride,vballoc,iballoc){this._stride=0,this.vertNum=0,this.indexNum=0,this._applied=!1,this._quadNum=0,this.canReuse=!1,this._stride=stride,this._vb=new VertexBuffer2D(stride,LayaGL.instance.DYNAMIC_DRAW),vballoc?this._vb._resizeBuffer(vballoc,!1):Config.webGL2D_MeshAllocMaxMem&&this._vb._resizeBuffer(65536*stride,!1),this._ib=new IndexBuffer2D,iballoc&&this._ib._resizeBuffer(iballoc,!1)}cloneWithNewVB(){var mesh=new Mesh2D(this._stride,0,0);return mesh._ib=this._ib,mesh._quadNum=this._quadNum,mesh._attribInfo=this._attribInfo,mesh}cloneWithNewVBIB(){var mesh=new Mesh2D(this._stride,0,0);return mesh._attribInfo=this._attribInfo,mesh}getVBW(){return this._vb.setNeedUpload(),this._vb}getVBR(){return this._vb}getIBR(){return this._ib}getIBW(){return this._ib.setNeedUpload(),this._ib}createQuadIB(QuadNum){this._quadNum=QuadNum,this._ib._resizeBuffer(6*QuadNum*2,!1),this._ib.byteLength=this._ib.bufferLength;for(var bd=this._ib.getUint16Array(),idx=0,curvert=0,i=0;i>2;vb.setByteLength(vpos+MeshQuadTexture.const_stride<<2);var vbdata=vb._floatArray32||vb.getFloat32Array(),vbu32Arr=vb._uint32Array,cpos=vpos,useTexVal=useTex?255:0;vbdata[cpos++]=pos[0],vbdata[cpos++]=pos[1],vbdata[cpos++]=uv[0],vbdata[cpos++]=uv[1],vbu32Arr[cpos++]=color,vbu32Arr[cpos++]=useTexVal,vbdata[cpos++]=pos[2],vbdata[cpos++]=pos[3],vbdata[cpos++]=uv[2],vbdata[cpos++]=uv[3],vbu32Arr[cpos++]=color,vbu32Arr[cpos++]=useTexVal,vbdata[cpos++]=pos[4],vbdata[cpos++]=pos[5],vbdata[cpos++]=uv[4],vbdata[cpos++]=uv[5],vbu32Arr[cpos++]=color,vbu32Arr[cpos++]=useTexVal,vbdata[cpos++]=pos[6],vbdata[cpos++]=pos[7],vbdata[cpos++]=uv[6],vbdata[cpos++]=uv[7],vbu32Arr[cpos++]=color,vbu32Arr[cpos++]=useTexVal,vb._upload=!0}}MeshQuadTexture.const_stride=24,MeshQuadTexture._maxIB=16384,MeshQuadTexture._POOL=[];class MeshTexture extends Mesh2D{constructor(){super(MeshTexture.const_stride,4,4),this.canReuse=!0,this.setAttributes(MeshTexture._fixattriInfo)}static __init__(){MeshTexture._fixattriInfo=[5126,4,0,5121,4,16,5121,4,20]}static getAMesh(mainctx){var ret;return ret=MeshTexture._POOL.length?MeshTexture._POOL.pop():new MeshTexture,mainctx&&ret._vb._resizeBuffer(65536*MeshTexture.const_stride,!1),ret}addData(vertices,uvs,idx,matrix,rgba){var vb=this._vb,ib=this._ib,vertsz=vertices.length>>1,f32pos=vb.needSize(vertsz*MeshTexture.const_stride)>>2,vbdata=vb._floatArray32||vb.getFloat32Array(),vbu32Arr=vb._uint32Array,ci=0,m00=matrix.a,m01=matrix.b,m10=matrix.c,m11=matrix.d,tx=matrix.tx,ty=matrix.ty,i=0;for(i=0;i>1;if(vertN>0){var end=stibid+sz,si=0;for(i=stibid;i>2,vbdata=this._vb._floatArray32||this._vb.getFloat32Array(),vbu32Arr=this._vb._uint32Array,ci=0,sz=points.length/2,i=0;ip.length+2?BasePoly.tempData:new Array(p.length+2);points[0]=p[0],points[1]=p[1];var newlen=2,i=0,length=p.length;for(i=2;i.01&&(points[newlen++]=p[i],points[newlen++]=p[i+1]);loop&&Math.abs(p[0]-points[newlen-2])+Math.abs(p[1]-points[newlen-1])>.01&&(points[newlen++]=p[0],points[newlen++]=p[1]);var result=outVertex;length=newlen/2;var px,py,p1x,p1y,p2x,p2y,p3x,p3y,perpx,perpy,perp2x,perp2y,a1,b1,c1,a2,b2,c2,denom,dist,w=lineWidth/2;for(p1x=points[0],p1y=points[1],perpy=p1x-(p2x=points[2]),perpx=(perpx=-(p1y-(p2y=points[3])))/(dist=Math.sqrt(perpx*perpx+perpy*perpy))*w,perpy=perpy/dist*w,result.push(p1x-perpx,p1y-perpy,p1x+perpx,p1y+perpy),i=1;i.001&&(tmpData[rp=4*realPtNum]=p1x,tmpData[rp+1]=p1y,tmpData[rp+2]=dx/len,tmpData[rp+3]=dy/len,realPtNum++);for(loop?(p1x=points[ptlen-2],p1y=points[ptlen-1],p2x=points[0],dy=points[1]-p1y,0!=(dx=p2x-p1x)&&0!=dy&&(len=Math.sqrt(dx*dx+dy*dy))>.001&&(tmpData[rp=4*realPtNum]=p1x,tmpData[rp+1]=p1y,tmpData[rp+2]=dx/len,tmpData[rp+3]=dy/len,realPtNum++)):(tmpData[rp=4*realPtNum]=p1x,tmpData[rp+1]=p1y,tmpData[rp+2]=dx/len,tmpData[rp+3]=dy/len,realPtNum++),ci=0,i=0;i80*dim){minX=maxX=data[0],minY=maxY=data[1];for(var i=dim;imaxX&&(maxX=x),y>maxY&&(maxY=y);invSize=0!==(invSize=Math.max(maxX-minX,maxY-minY))?1/invSize:0}return Earcut.earcutLinked(outerNode,triangles,dim,minX,minY,invSize),triangles}static linkedList(data,start,end,dim,clockwise){var i,last;if(clockwise===Earcut.signedArea(data,start,end,dim)>0)for(i=start;i=start;i-=dim)last=Earcut.insertNode(i,data[i],data[i+1],last);return last&&Earcut.equals(last,last.next)&&(Earcut.removeNode(last),last=last.next),last}static filterPoints(start,end){if(!start)return start;end||(end=start);var again,p=start;do{if(again=!1,p.steiner||!Earcut.equals(p,p.next)&&0!==Earcut.area(p.prev,p,p.next))p=p.next;else{if(Earcut.removeNode(p),(p=end=p.prev)===p.next)break;again=!0}}while(again||p!==end);return end}static earcutLinked(ear,triangles,dim,minX,minY,invSize,pass=null){if(ear){!pass&&invSize&&Earcut.indexCurve(ear,minX,minY,invSize);for(var prev,next,stop=ear;ear.prev!==ear.next;)if(prev=ear.prev,next=ear.next,invSize?Earcut.isEarHashed(ear,minX,minY,invSize):Earcut.isEar(ear))triangles.push(prev.i/dim),triangles.push(ear.i/dim),triangles.push(next.i/dim),Earcut.removeNode(ear),ear=next.next,stop=next.next;else if((ear=next)===stop){pass?1===pass?(ear=Earcut.cureLocalIntersections(ear,triangles,dim),Earcut.earcutLinked(ear,triangles,dim,minX,minY,invSize,2)):2===pass&&Earcut.splitEarcut(ear,triangles,dim,minX,minY,invSize):Earcut.earcutLinked(Earcut.filterPoints(ear,null),triangles,dim,minX,minY,invSize,1);break}}}static isEar(ear){var a=ear.prev,b=ear,c=ear.next;if(Earcut.area(a,b,c)>=0)return!1;for(var p=ear.next.next;p!==ear.prev;){if(Earcut.pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&Earcut.area(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}static isEarHashed(ear,minX,minY,invSize){var a=ear.prev,b=ear,c=ear.next;if(Earcut.area(a,b,c)>=0)return!1;for(var minTX=a.xb.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x,maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y,minZ=Earcut.zOrder(minTX,minTY,minX,minY,invSize),maxZ=Earcut.zOrder(maxTX,maxTY,minX,minY,invSize),p=ear.nextZ;p&&p.z<=maxZ;){if(p!==ear.prev&&p!==ear.next&&Earcut.pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&Earcut.area(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=ear.prevZ;p&&p.z>=minZ;){if(p!==ear.prev&&p!==ear.next&&Earcut.pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&Earcut.area(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}static cureLocalIntersections(start,triangles,dim){var p=start;do{var a=p.prev,b=p.next.next;!Earcut.equals(a,b)&&Earcut.intersects(a,p,p.next,b)&&Earcut.locallyInside(a,b)&&Earcut.locallyInside(b,a)&&(triangles.push(a.i/dim),triangles.push(p.i/dim),triangles.push(b.i/dim),Earcut.removeNode(p),Earcut.removeNode(p.next),p=start=b),p=p.next}while(p!==start);return p}static splitEarcut(start,triangles,dim,minX,minY,invSize){var a=start;do{for(var b=a.next.next;b!==a.prev;){if(a.i!==b.i&&Earcut.isValidDiagonal(a,b)){var c=Earcut.splitPolygon(a,b);return a=Earcut.filterPoints(a,a.next),c=Earcut.filterPoints(c,c.next),Earcut.earcutLinked(a,triangles,dim,minX,minY,invSize),void Earcut.earcutLinked(c,triangles,dim,minX,minY,invSize)}b=b.next}a=a.next}while(a!==start)}static eliminateHoles(data,holeIndices,outerNode,dim){var i,len,start,end,list,queue=[];for(i=0,len=holeIndices.length;i=p.next.y&&p.next.y!==p.y){var x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){if(qx=x,x===hx){if(hy===p.y)return p;if(hy===p.next.y)return p.next}m=p.x=p.x&&p.x>=mx&&hx!==p.x&&Earcut.pointInTriangle(hym.x)&&Earcut.locallyInside(p,hole)&&(m=p,tanMin=tan),p=p.next;return m}static indexCurve(start,minX,minY,invSize){var p=start;do{null===p.z&&(p.z=Earcut.zOrder(p.x,p.y,minX,minY,invSize)),p.prevZ=p.prev,p.nextZ=p.next,p=p.next}while(p!==start);p.prevZ.nextZ=null,p.prevZ=null,Earcut.sortLinked(p)}static sortLinked(list){var i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{for(p=list,list=null,tail=null,numMerges=0;p;){for(numMerges++,q=p,pSize=0,i=0;i0||qSize>0&&q;)0!==pSize&&(0===qSize||!q||p.z<=q.z)?(e=p,p=p.nextZ,pSize--):(e=q,q=q.nextZ,qSize--),tail?tail.nextZ=e:list=e,e.prevZ=tail,tail=e;p=q}tail.nextZ=null,inSize*=2}while(numMerges>1);return list}static zOrder(x,y,minX,minY,invSize){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=32767*(x-minX)*invSize)|x<<8))|x<<4))|x<<2))|x<<1))|(y=1431655765&((y=858993459&((y=252645135&((y=16711935&((y=32767*(y-minY)*invSize)|y<<8))|y<<4))|y<<2))|y<<1))<<1}static getLeftmost(start){var p=start,leftmost=start;do{p.x=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}static isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!Earcut.intersectsPolygon(a,b)&&Earcut.locallyInside(a,b)&&Earcut.locallyInside(b,a)&&Earcut.middleInside(a,b)}static area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}static equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}static intersects(p1,q1,p2,q2){return!!(Earcut.equals(p1,q1)&&Earcut.equals(p2,q2)||Earcut.equals(p1,q2)&&Earcut.equals(p2,q1))||Earcut.area(p1,q1,p2)>0!=Earcut.area(p1,q1,q2)>0&&Earcut.area(p2,q2,p1)>0!=Earcut.area(p2,q2,q1)>0}static intersectsPolygon(a,b){var p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&Earcut.intersects(p,p.next,a,b))return!0;p=p.next}while(p!==a);return!1}static locallyInside(a,b){return Earcut.area(a.prev,a,a.next)<0?Earcut.area(a,b,a.next)>=0&&Earcut.area(a,a.prev,b)>=0:Earcut.area(a,b,a.prev)<0||Earcut.area(a,a.next,b)<0}static middleInside(a,b){var p=a,inside=!1,px=(a.x+b.x)/2,py=(a.y+b.y)/2;do{p.y>py!=p.next.y>py&&p.next.y!==p.y&&px<(p.next.x-p.x)*(py-p.y)/(p.next.y-p.y)+p.x&&(inside=!inside),p=p.next}while(p!==a);return inside}static splitPolygon(a,b){var a2=new EarcutNode(a.i,a.x,a.y),b2=new EarcutNode(b.i,b.x,b.y),an=a.next,bp=b.prev;return a.next=b,b.prev=a,a2.next=an,an.prev=a2,b2.next=a2,a2.prev=b2,bp.next=b2,b2.prev=bp,b2}static insertNode(i,x,y,last){var p=new EarcutNode(i,x,y);return last?(p.next=last.next,p.prev=last,last.next.prev=p,last.next=p):(p.prev=p,p.next=p),p}static removeNode(p){p.next.prev=p.prev,p.prev.next=p.next,p.prevZ&&(p.prevZ.nextZ=p.nextZ),p.nextZ&&(p.nextZ.prevZ=p.prevZ)}static signedArea(data,start,end,dim){for(var sum=0,i=start,j=end-dim;i0&&(this._tex!=tex||this._imgId!=imgid||this._clipid>=0&&this._clipid!=ctx._clipInfoID)&&this.submit(ctx),this._clipid=ctx._clipInfoID,ctx._globalClipMatrix.copyTo(this._clipMatrix),this._tex=tex,this._imgId=imgid,this._colorFiler=ctx._colorFiler,this._data[this._ndata]=pos,this._data[this._ndata+1]=uv,this._data[this._ndata+2]=color,this._ndata+=3}getPos(){return 0==CharSubmitCache.__nPosPool?new Array(8):CharSubmitCache.__posPool[--CharSubmitCache.__nPosPool]}enable(value,ctx){value!==this._enbale&&(this._enbale=value,this._enbale||this.submit(ctx))}submit(ctx){var n=this._ndata;if(n){var _mesh=ctx._mesh,colorFiler=ctx._colorFiler;ctx._colorFiler=this._colorFiler;var submit=SubmitTexture.create(ctx,_mesh,Value2D.create(ShaderDefines2D.TEXTURE2D,0));ctx._submits[ctx._submits._length++]=ctx._curSubmit=submit,submit.shaderValue.textureHost=this._tex,submit._key.other=this._imgId,ctx._colorFiler=colorFiler,ctx._copyClipInfo(submit,this._clipMatrix),submit.clipInfoID=this._clipid;for(var i=0;ithis._width||height>this._height)return!1;for(var rx=-1,ry=-1,nWidth=this._width,nHeight=this._height,pCellBox=this._cells,y=0;y=w),this._rowInfo[yy]-=w;for(var xx=0;xx0)for(yy=0;yy=0&&0==this._cells[3*((y+yy)*nWidth+xx)];--xx,++s);for(xx=s;xx>0;--xx)this._cells[3*((y+yy)*nWidth+x-xx)+1]=xx,this._check(xx>0)}if(y>0)for(xx=x;xx=0&&0==this._cells[3*(xx+yy*nWidth)];--yy,s++);for(yy=s;yy>0;--yy)this._cells[3*(xx+(y-yy)*nWidth)+2]=yy,this._check(yy>0)}this._used+=w*h/(this._width*this._height)}_check(ret){0==ret&&console.log("xtexMerger 错误啦")}_clear(){this._texCount=0;for(var y=0;y=TextTexture.pool.length&&(TextTexture.pool=TextTexture.pool.concat(new Array(10))),this._discardTm=RenderInfo.loopStTm,TextTexture.pool[TextTexture.poolLen++]=this):this.destroy()}static getTextTexture(w,h){if(w!=TextTexture.gTextRender.atlasWidth||w!=TextTexture.gTextRender.atlasWidth)return new TextTexture(w,h);if(TextTexture.poolLen>0){var ret=TextTexture.pool[--TextTexture.poolLen];return TextTexture.poolLen>0&&TextTexture.clean(),ret}return new TextTexture(w,h)}destroy(){this.__destroyed=!0;var gl=LayaGL.instance;this._source&&gl.deleteTexture(this._source),this._source=null}static clean(){var curtm=RenderInfo.loopStTm;if(0===TextTexture.cleanTm&&(TextTexture.cleanTm=curtm),curtm-TextTexture.cleanTm>=TextTexture.gTextRender.checkCleanTextureDt){for(var i=0;i=TextTexture.gTextRender.destroyUnusedTextureDt&&(p.destroy(),TextTexture.pool[i]=TextTexture.pool[TextTexture.poolLen-1],TextTexture.poolLen--,i--)}TextTexture.cleanTm=curtm}}touchRect(ri,curloop){this.lastTouchTm!=curloop&&(this.curUsedCovRate=0,this.curUsedCovRateAtlas=0,this.lastTouchTm=curloop);var texw2=TextTexture.gTextRender.atlasWidth*TextTexture.gTextRender.atlasWidth,gridw2=ILaya.TextAtlas.atlasGridW*ILaya.TextAtlas.atlasGridW;this.curUsedCovRate+=ri.bmpWidth*ri.bmpHeight/texw2,this.curUsedCovRateAtlas+=Math.ceil(ri.bmpWidth/ILaya.TextAtlas.atlasGridW)*Math.ceil(ri.bmpHeight/ILaya.TextAtlas.atlasGridW)/(texw2/gridw2)}get texture(){return this}_getSource(){return this._source}drawOnScreen(x,y){}}TextTexture.gTextRender=null,TextTexture.pool=new Array(10),TextTexture.poolLen=0,TextTexture.cleanTm=0;class TextAtlas{constructor(){this.texWidth=1024,this.texHeight=1024,this.protectDist=1,this.texture=null,this.charMaps={},this.texHeight=this.texWidth=ILaya.TextRender.atlasWidth,this.texture=TextTexture.getTextTexture(this.texWidth,this.texHeight),this.texWidth/TextAtlas.atlasGridW>256&&(TextAtlas.atlasGridW=Math.ceil(this.texWidth/256)),this.atlasgrid=new AtlasGrid(this.texWidth/TextAtlas.atlasGridW,this.texHeight/TextAtlas.atlasGridW,this.texture.id)}setProtecteDist(d){this.protectDist=d}getAEmpty(w,h,pt){var find=this.atlasgrid.addRect(1,Math.ceil(w/TextAtlas.atlasGridW),Math.ceil(h/TextAtlas.atlasGridW),pt);return find&&(pt.x*=TextAtlas.atlasGridW,pt.y*=TextAtlas.atlasGridW),find}get usedRate(){return this.atlasgrid._used}destroy(){for(var k in this.charMaps){this.charMaps[k].deleted=!0}this.texture.discard()}printDebugInfo(){}}TextAtlas.atlasGridW=16;class Event{setTo(type,currentTarget,target){return this.type=type,this.currentTarget=currentTarget,this.target=target,this}stopPropagation(){this._stoped=!0}get touches(){if(!this.nativeEvent)return null;var arr=this.nativeEvent.touches;if(arr)for(var stage=ILaya.stage,i=0,n=arr.length;ibitmap.width&&(width=bitmap.width-x),bitmap.height&&y+height>bitmap.height&&(height=bitmap.height-y),outTexture?(tex=outTexture).setTo(bitmap,null,sourceWidth||width,sourceHeight||height):tex=new Texture(bitmap,null,sourceWidth||width,sourceHeight||height),tex.width=width,tex.height=height,tex.offsetX=offsetX,tex.offsetY=offsetY;var dwidth=1/bitmap.width,dheight=1/bitmap.height;x*=dwidth,y*=dheight,width*=dwidth,height*=dheight;var u1=tex.uv[0],v1=tex.uv[1],u2=tex.uv[4],v2=tex.uv[5],inAltasUVWidth=u2-u1,inAltasUVHeight=v2-v1,oriUV=Texture.moveUV(uv[0],uv[1],[x,y,x+width,y,x+width,y+height,x,y+height]);tex.uv=new Float32Array([u1+oriUV[0]*inAltasUVWidth,v1+oriUV[1]*inAltasUVHeight,u2-(1-oriUV[2])*inAltasUVWidth,v1+oriUV[3]*inAltasUVHeight,u2-(1-oriUV[4])*inAltasUVWidth,v2-(1-oriUV[5])*inAltasUVHeight,u1+oriUV[6]*inAltasUVWidth,v2-(1-oriUV[7])*inAltasUVHeight]);var bitmapScale=bitmap.scaleRate;return bitmapScale&&1!=bitmapScale?(tex.sourceWidth/=bitmapScale,tex.sourceHeight/=bitmapScale,tex.width/=bitmapScale,tex.height/=bitmapScale,tex.scaleRate=bitmapScale):tex.scaleRate=1,tex}static createFromTexture(texture,x,y,width,height){var texScaleRate=texture.scaleRate;1!=texScaleRate&&(x*=texScaleRate,y*=texScaleRate,width*=texScaleRate,height*=texScaleRate);var rect=Rectangle.TEMP.setTo(x-texture.offsetX,y-texture.offsetY,width,height),result=rect.intersection(Texture._rect1.setTo(0,0,texture.width,texture.height),Texture._rect2);return result?Texture.create(texture,result.x,result.y,result.width,result.height,result.x-rect.x,result.y-rect.y,width,height):null}get uv(){return this._uv}set uv(value){this.uvrect[0]=Math.min(value[0],value[2],value[4],value[6]),this.uvrect[1]=Math.min(value[1],value[3],value[5],value[7]),this.uvrect[2]=Math.max(value[0],value[2],value[4],value[6])-this.uvrect[0],this.uvrect[3]=Math.max(value[1],value[3],value[5],value[7])-this.uvrect[1],this._uv=value}get width(){return this._w?this._w:this.bitmap?this.uv&&this.uv!==Texture.DEF_UV?(this.uv[2]-this.uv[0])*this.bitmap.width:this.bitmap.width:0}set width(value){this._w=value,this.sourceWidth||(this.sourceWidth=value)}get height(){return this._h?this._h:this.bitmap?this.uv&&this.uv!==Texture.DEF_UV?(this.uv[5]-this.uv[1])*this.bitmap.height:this.bitmap.height:0}set height(value){this._h=value,this.sourceHeight||(this.sourceHeight=value)}get bitmap(){return this._bitmap}set bitmap(value){this._bitmap&&this._bitmap._removeReference(this._referenceCount),this._bitmap=value,value&&value._addReference(this._referenceCount)}get destroyed(){return this._destroyed}_addReference(){this._bitmap&&this._bitmap._addReference(),this._referenceCount++}_removeReference(){this._bitmap&&this._bitmap._removeReference(),this._referenceCount--}_getSource(cb=null){return this._destroyed||!this._bitmap?null:(this.recoverBitmap(cb),this._bitmap.destroyed?null:this.bitmap._getSource())}_onLoaded(complete,context){if(context)if(context==this);else if(context instanceof Texture){var tex=context;Texture._create(context,0,0,tex.width,tex.height,0,0,tex.sourceWidth,tex.sourceHeight,this)}else this.bitmap=context,this.sourceWidth=this._w=context.width,this.sourceHeight=this._h=context.height;else;complete&&complete.run(),this.event(Event.READY,this)}getIsReady(){return!this._destroyed&&!!this._bitmap}setTo(bitmap=null,uv=null,sourceWidth=0,sourceHeight=0){this.bitmap=bitmap,this.sourceWidth=sourceWidth,this.sourceHeight=sourceHeight,bitmap&&(this._w=bitmap.width,this._h=bitmap.height,this.sourceWidth=this.sourceWidth||bitmap.width,this.sourceHeight=this.sourceHeight||bitmap.height),this.uv=uv||Texture.DEF_UV}load(url,complete=null){this._destroyed||ILaya.loader.load(url,Handler.create(this,this._onLoaded,[complete]),null,"htmlimage",1,!1,null,!0)}getTexturePixels(x,y,width,height){var st,dst,i,tex2d=this.bitmap,texw=tex2d.width,texh=tex2d.height;if(x+width>texw&&(width-=x+width-texw),y+height>texh&&(height-=y+height-texh),width<=0||height<=0)return null;var wstride=4*width,pix=null;try{pix=tex2d.getPixels()}catch(e){}if(pix){if(0==x&&0==y&&width==texw&&height==texh)return pix;var ret=new Uint8Array(width*height*4);for(st=4*x,dst=(y+height-1)*(wstride=4*texw)+4*x,i=height-1;i>=0;i--)ret.set(dt.slice(dst,dst+4*width),st),st+=wstride,dst-=wstride;return ret}var ctx=new ILaya.Context;ctx.size(width,height),ctx.asBitmap=!0;var uv=null;if(0!=x||0!=y||width!=texw||height!=texh){var stu=(uv=this._uv.slice())[0],stv=uv[1],uk=(uv[2]-stu)/texw,vk=(uv[7]-stv)/texh;uv=[stu+x*uk,stv+y*vk,stu+(x+width)*uk,stv+y*vk,stu+(x+width)*uk,stv+(y+height)*vk,stu+x*uk,stv+(y+height)*vk]}ctx._drawTextureM(this,0,0,width,height,null,1,uv),ctx._targets.start(),ctx.flush(),ctx._targets.end(),ctx._targets.restore();var dt=ctx._targets.getData(0,0,width,height);for(ctx.destroy(),ret=new Uint8Array(width*height*4),st=0,dst=(height-1)*wstride,i=height-1;i>=0;i--)ret.set(dt.slice(dst,dst+wstride),st),st+=wstride,dst-=wstride;return ret}getPixels(x,y,width,height){return window.conch?this._nativeObj.getImageData(x,y,width,height):this.getTexturePixels(x,y,width,height)}recoverBitmap(onok=null){var url=this._bitmap.url;this._destroyed||this._bitmap&&!this._bitmap.destroyed||!url||ILaya.loader.load(url,Handler.create(this,function(bit){this.bitmap=bit,onok&&onok()}),null,"htmlimage",1,!1,null,!0)}disposeBitmap(){!this._destroyed&&this._bitmap&&this._bitmap.destroy()}destroy(force=!1){if(!this._destroyed){this._destroyed=!0;var bit=this._bitmap;bit&&(bit._removeReference(this._referenceCount),(0===bit.referenceCount||force)&&bit.destroy(),bit=null),this.url&&this===ILaya.loader.getRes(this.url)&&ILaya.loader.clearRes(this.url)}}}Texture.DEF_UV=new Float32Array([0,0,1,0,1,1,0,1]),Texture.NO_UV=new Float32Array([0,0,0,0,0,0,0,0]),Texture.INV_UV=new Float32Array([0,1,1,1,1,0,0,0]),Texture._rect1=new Rectangle,Texture._rect2=new Rectangle;class FontInfo{constructor(font){this._font="14px Arial",this._family="Arial",this._size=14,this._italic=!1,this._bold=!1,this._id=FontInfo._gfontID++,this.setFont(font||this._font)}static Parse(font){if(font===FontInfo._lastFont)return FontInfo._lastFontInfo;var r=FontInfo._cache[font];return r||(r=FontInfo._cache[font]=new FontInfo(font)),FontInfo._lastFont=font,FontInfo._lastFontInfo=r,r}setFont(value){this._font=value;var _words=value.split(" "),l=_words.length;if(l<2)1==l&&_words[0].indexOf("px")>0&&(this._size=parseInt(_words[0]));else{for(var szpos=-1,i=0;i0||_words[i].indexOf("pt")>0){szpos=i,this._size=parseInt(_words[i]),this._size<=0&&(console.error("font parse error:"+value),this._size=14);break}var fpos=szpos+1,familys=_words[fpos];for(fpos++;fpos=0,this._bold=_words.indexOf("bold")>=0}}}FontInfo.EMPTY=new FontInfo(null),FontInfo._cache={},FontInfo._gfontID=0,FontInfo._lastFont="";class WordText{constructor(){this.save=[],this.toUpperCase=null,this.width=-1,this.pageChars=[],this.startID=0,this.startIDStroke=0,this.lastGCCnt=0,this.splitRender=!1}setText(txt){this.changed=!0,this._text=txt,this.width=-1,this.cleanCache()}toString(){return this._text}get length(){return this._text?this._text.length:0}charCodeAt(i){return this._text?this._text.charCodeAt(i):NaN}charAt(i){return this._text?this._text.charAt(i):null}cleanCache(){this.pageChars.forEach(function(p){var tex=p.tex;p.words;1==p.words.length&&tex&&tex.ri&&tex.destroy()}),this.pageChars=[],this.startID=0}}class CharRenderInfo{constructor(){this.char="",this.deleted=!1,this.uv=new Array(8),this.pos=0,this.orix=0,this.oriy=0,this.touchTick=0,this.isSpace=!1}touch(){var curLoop=RenderInfo.loopCount;this.touchTick!=curLoop&&this.tex.touchRect(this,curLoop),this.touchTick=curLoop}}class ICharRender{constructor(){this.fontsz=16}getWidth(font,str){return 0}scale(sx,sy){}get canvasWidth(){return 0}set canvasWidth(w){}getCharBmp(char,font,lineWidth,colStr,strokeColStr,size,margin_left,margin_top,margin_right,margin_bottom,rect=null){return null}}class Browser{static __init__(){var Laya=window.Laya||ILaya.Laya;if(Browser._window)return Browser._window;var win=Browser._window=window,doc=Browser._document=win.document,u=Browser.userAgent=win.navigator.userAgent;u.indexOf("AlipayMiniGame")>-1&&"my"in Browser.window&&(window.aliMiniGame(Laya,Laya),window.aliPayMiniGame(Laya,Laya),Laya.ALIMiniAdapter?Laya.ALIMiniAdapter.enable():console.error("请先添加阿里小游戏适配库")),-1==u.indexOf("OPPO")&&u.indexOf("MiniGame")>-1&&"wx"in Browser.window&&("qq"in Browser.window?(window.qqMiniGame(Laya,Laya),Laya.QQMiniAdapter?Laya.QQMiniAdapter.enable():console.error("请引入手机QQ小游戏的适配库:https://ldc2.layabox.com/doc/?nav=zh-ts-5-0-0")):(window.wxMiniGame(Laya,Laya),Laya.MiniAdpter?Laya.MiniAdpter.enable():console.error("请先添加小游戏适配库,详细教程:https://ldc2.layabox.com/doc/?nav=zh-ts-5-0-0"))),u.indexOf("SwanGame")>-1&&(window.bdMiniGame(Laya,Laya),Laya.BMiniAdapter?Laya.BMiniAdapter.enable():console.error("请先添加百度小游戏适配库,详细教程:https://ldc2.layabox.com/doc/?nav=zh-ts-5-0-0")),u.indexOf("QuickGame")>-1&&(window.miMiniGame(Laya,Laya),Laya.KGMiniAdapter?Laya.KGMiniAdapter.enable():console.error("请先添加小米小游戏适配库,详细教程:https://ldc2.layabox.com/doc/?nav=zh-ts-5-0-0")),u.indexOf("OPPO")>-1&&u.indexOf("MiniGame")>-1&&(window.qgMiniGame(Laya,Laya),Laya.QGMiniAdapter?Laya.QGMiniAdapter.enable():console.error("请先添加OPPO小游戏适配库")),u.indexOf("VVGame")>-1&&(window.vvMiniGame(Laya,Laya),Laya.VVMiniAdapter?Laya.VVMiniAdapter.enable():console.error("请先添加VIVO小游戏适配库")),win.trace=console.log,win.requestAnimationFrame=win.requestAnimationFrame||win.webkitRequestAnimationFrame||win.mozRequestAnimationFrame||win.oRequestAnimationFrame||win.msRequestAnimationFrame||function(fun){return win.setTimeout(fun,1e3/60)};var bodyStyle=doc.body.style;bodyStyle.margin=0,bodyStyle.overflow="hidden",bodyStyle["-webkit-user-select"]="none",bodyStyle["-webkit-tap-highlight-color"]="rgba(200,200,200,0)";for(var metas=doc.getElementsByTagName("meta"),i=0,flag=!1,content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no";i-1,Browser.onIOS=!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),Browser.onIPhone=u.indexOf("iPhone")>-1,Browser.onMac=u.indexOf("Mac OS X")>-1,Browser.onIPad=u.indexOf("iPad")>-1,Browser.onAndroid=u.indexOf("Android")>-1||u.indexOf("Adr")>-1,Browser.onWP=u.indexOf("Windows Phone")>-1,Browser.onQQBrowser=u.indexOf("QQBrowser")>-1,Browser.onMQQBrowser=u.indexOf("MQQBrowser")>-1||u.indexOf("Mobile")>-1&&u.indexOf("QQ")>-1,Browser.onIE=!!win.ActiveXObject||"ActiveXObject"in win,Browser.onWeiXin=u.indexOf("MicroMessenger")>-1,Browser.onSafari=u.indexOf("Safari")>-1,Browser.onPC=!Browser.onMobile,Browser.onMiniGame=u.indexOf("MiniGame")>-1,Browser.onBDMiniGame=u.indexOf("SwanGame")>-1,Browser.onLayaRuntime=!!Browser.window.conch,u.indexOf("OPPO")>-1&&u.indexOf("MiniGame")>-1?(Browser.onQGMiniGame=!0,Browser.onMiniGame=!1):"qq"in Browser.window&&u.indexOf("MiniGame")>-1&&(Browser.onQQMiniGame=!0,Browser.onMiniGame=!1),Browser.onVVMiniGame=u.indexOf("VVGame")>-1,Browser.onKGMiniGame=u.indexOf("QuickGame")>-1,u.indexOf("AlipayMiniGame")>-1&&(Browser.onAlipayMiniGame=!0,Browser.onMiniGame=!1),win}static createElement(type){return Browser.__init__(),Browser._document.createElement(type)}static getElementById(type){return Browser.__init__(),Browser._document.getElementById(type)}static removeElement(ele){ele&&ele.parentNode&&ele.parentNode.removeChild(ele)}static now(){return Date.now()}static get clientWidth(){return Browser.__init__(),Browser._window.innerWidth||Browser._document.body.clientWidth}static get clientHeight(){return Browser.__init__(),Browser._window.innerHeight||Browser._document.body.clientHeight||Browser._document.documentElement.clientHeight}static get width(){return Browser.__init__(),(ILaya.stage&&ILaya.stage.canvasRotation?Browser.clientHeight:Browser.clientWidth)*Browser.pixelRatio}static get height(){return Browser.__init__(),(ILaya.stage&&ILaya.stage.canvasRotation?Browser.clientWidth:Browser.clientHeight)*Browser.pixelRatio}static get pixelRatio(){return Browser._pixelRatio<0&&(Browser.__init__(),Browser.userAgent.indexOf("Mozilla/6.0(Linux; Android 6.0; HUAWEI NXT-AL10 Build/HUAWEINXT-AL10)")>-1?Browser._pixelRatio=2:(Browser._pixelRatio=Browser._window.devicePixelRatio||1,Browser._pixelRatio<1&&(Browser._pixelRatio=1))),Browser._pixelRatio}static get container(){return Browser._container||(Browser.__init__(),Browser._container=Browser.createElement("div"),Browser._container.id="layaContainer",Browser._document.body.appendChild(Browser._container)),Browser._container}static set container(value){Browser._container=value}static get window(){return Browser._window||Browser.__init__()}static get document(){return Browser.__init__(),Browser._document}}Browser._pixelRatio=-1,Browser.mainCanvas=null,Browser.hanzi=new RegExp("^[一-龥]$"),Browser.fontMap=[],Browser.measureText=function(txt,font){var isChinese=Browser.hanzi.test(txt);if(isChinese&&Browser.fontMap[font])return Browser.fontMap[font];var ctx=Browser.context;ctx.font=font;var r=ctx.measureText(txt);return isChinese&&(Browser.fontMap[font]=r),r};class CharRender_Canvas extends ICharRender{constructor(maxw,maxh,scalefont=!0,useImageData=!0,showdbg=!1){super(),this.ctx=null,this.lastScaleX=1,this.lastScaleY=1,this.needResetScale=!1,this.maxTexW=0,this.maxTexH=0,this.scaleFontSize=!0,this.showDbgInfo=!1,this.supportImageData=!0,this.maxTexW=maxw,this.maxTexH=maxh,this.scaleFontSize=scalefont,this.supportImageData=useImageData,this.showDbgInfo=showdbg,CharRender_Canvas.canvas||(CharRender_Canvas.canvas=Browser.createElement("canvas"),CharRender_Canvas.canvas.width=1024,CharRender_Canvas.canvas.height=512,CharRender_Canvas.canvas.style.left="-10000px",CharRender_Canvas.canvas.style.position="absolute",document.body.appendChild(CharRender_Canvas.canvas),this.ctx=CharRender_Canvas.canvas.getContext("2d"))}get canvasWidth(){return CharRender_Canvas.canvas.width}set canvasWidth(w){CharRender_Canvas.canvas.width!=w&&(CharRender_Canvas.canvas.width=w,w>2048&&console.warn("画文字设置的宽度太大,超过2048了"),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(this.lastScaleX,this.lastScaleY))}getWidth(font,str){return this.ctx?(this.ctx._lastFont!=font&&(this.ctx.font=font,this.ctx._lastFont=font),this.ctx.measureText(str).width):0}scale(sx,sy){if(!this.supportImageData)return this.lastScaleX=sx,void(this.lastScaleY=sy);this.lastScaleX==sx&&this.lastScaleY==sy||(this.ctx.setTransform(sx,0,0,sy,0,0),this.lastScaleX=sx,this.lastScaleY=sy)}getCharBmp(char,font,lineWidth,colStr,strokeColStr,cri,margin_left,margin_top,margin_right,margin_bottom,rect=null){if(!this.supportImageData)return this.getCharCanvas(char,font,lineWidth,colStr,strokeColStr,cri,margin_left,margin_top,margin_right,margin_bottom);var ctx=this.ctx,sz=this.fontsz;ctx.font!=font&&(ctx.font=font,ctx._lastFont=font),cri.width=ctx.measureText(char).width;var w=cri.width*this.lastScaleX,h=cri.height*this.lastScaleY;w+=(margin_left+margin_right)*this.lastScaleX,h+=(margin_top+margin_bottom)*this.lastScaleY,w=Math.ceil(w),h=Math.ceil(h);var clearW=(w=Math.min(w,CharRender_Canvas.canvas.width))+2*lineWidth+1,clearH=(h=Math.min(h,CharRender_Canvas.canvas.height))+2*lineWidth+1;rect&&(clearW=Math.max(clearW,rect[0]+rect[2]+1),clearH=Math.max(clearH,rect[1]+rect[3]+1)),ctx.clearRect(0,0,clearW,clearH),ctx.save(),ctx.textBaseline="middle",lineWidth>0&&(ctx.strokeStyle=strokeColStr,ctx.lineWidth=lineWidth,ctx.strokeText(char,margin_left,margin_top+sz/2)),colStr&&(ctx.fillStyle=colStr,ctx.fillText(char,margin_left,margin_top+sz/2)),this.showDbgInfo&&(ctx.strokeStyle="#ff0000",ctx.strokeRect(1,1,w-2,h-2),ctx.strokeStyle="#00ff00",ctx.strokeRect(margin_left,margin_top,cri.width,cri.height)),rect&&-1==rect[2]&&(rect[2]=Math.ceil((cri.width+2*lineWidth)*this.lastScaleX));var imgdt=rect?ctx.getImageData(rect[0],rect[1],rect[2],rect[3]):ctx.getImageData(0,0,w,h);return ctx.restore(),cri.bmpWidth=imgdt.width,cri.bmpHeight=imgdt.height,imgdt}getCharCanvas(char,font,lineWidth,colStr,strokeColStr,cri,margin_left,margin_top,margin_right,margin_bottom){var ctx=this.ctx;ctx.font!=font&&(ctx.font=font,ctx._lastFont=font),cri.width=ctx.measureText(char).width;var w=cri.width*this.lastScaleX,h=cri.height*this.lastScaleY;w+=(margin_left+margin_right)*this.lastScaleX,h+=(margin_top+margin_bottom)*this.lastScaleY+1,w=Math.min(w,this.maxTexW),h=Math.min(h,this.maxTexH),CharRender_Canvas.canvas.width=Math.min(w+1,this.maxTexW),CharRender_Canvas.canvas.height=Math.min(h+1,this.maxTexH),ctx.font=font,ctx.clearRect(0,0,w+1+lineWidth,h+1+lineWidth),ctx.setTransform(1,0,0,1,0,0),ctx.save(),this.scaleFontSize&&ctx.scale(this.lastScaleX,this.lastScaleY),ctx.translate(margin_left,margin_top),ctx.textAlign="left";var sz=this.fontsz;return ctx.textBaseline="middle",lineWidth>0?(ctx.strokeStyle=strokeColStr,ctx.fillStyle=colStr,ctx.lineWidth=lineWidth,ctx.fillAndStrokeText?ctx.fillAndStrokeText(char,0,sz/2):(ctx.strokeText(char,0,sz/2),ctx.fillText(char,0,sz/2))):colStr&&(ctx.fillStyle=colStr,ctx.fillText(char,0,sz/2)),this.showDbgInfo&&(ctx.strokeStyle="#ff0000",ctx.strokeRect(0,0,w,h),ctx.strokeStyle="#00ff00",ctx.strokeRect(0,0,cri.width,cri.height)),ctx.restore(),cri.bmpWidth=CharRender_Canvas.canvas.width,cri.bmpHeight=CharRender_Canvas.canvas.height,CharRender_Canvas.canvas}}CharRender_Canvas.canvas=null;class CharRender_Native extends ICharRender{constructor(){super(),this.lastFont=""}getWidth(font,str){return window.conchTextCanvas?(window.conchTextCanvas.font=font,this.lastFont=font,window.conchTextCanvas.measureText(str).width):0}scale(sx,sy){}getCharBmp(char,font,lineWidth,colStr,strokeColStr,size,margin_left,margin_top,margin_right,margin_bottom,rect=null){if(!window.conchTextCanvas)return null;window.conchTextCanvas.font=font,this.lastFont=font;size.width=window.conchTextCanvas.measureText(char).width,size.height;var nStrokeColor=ColorUtils.create(strokeColStr).numColor,nTextColor=ColorUtils.create(colStr).numColor,textInfo=window.conchTextCanvas.getTextBitmapData(char,nTextColor,lineWidth>2?2:lineWidth,nStrokeColor);return size.bmpWidth=textInfo.width,size.bmpHeight=textInfo.height,textInfo}}class TextRender{constructor(){this.fontSizeInfo={},this.charRender=null,this.mapFont={},this.fontID=0,this.mapColor=[],this.colorID=0,this.fontScaleX=1,this.fontScaleY=1,this._curStrPos=0,this.textAtlases=[],this.isoTextures=[],this.lastFont=null,this.fontSizeW=0,this.fontSizeH=0,this.fontSizeOffX=0,this.fontSizeOffY=0,this.renderPerChar=!0,this.tmpAtlasPos=new Point,this.textureMem=0,ILaya.TextAtlas=TextAtlas;var bugIOS=!1,miniadp=ILaya.Laya.MiniAdpter;miniadp&&miniadp.systemInfo&&miniadp.systemInfo.system&&(bugIOS="ios 10.1.1"===miniadp.systemInfo.system.toLowerCase()),ILaya.Browser.onMiniGame&&!bugIOS&&(TextRender.isWan1Wan=!0),this.charRender=ILaya.Render.isConchApp?new CharRender_Native:new CharRender_Canvas(TextRender.atlasWidth,TextRender.atlasWidth,TextRender.scaleFontWithCtx,!TextRender.isWan1Wan,!1),TextRender.textRenderInst=this,ILaya.Laya.textRender=this,TextRender.atlasWidth2=TextRender.atlasWidth*TextRender.atlasWidth}setFont(font){if(this.lastFont!=font){this.lastFont=font;var fontsz=this.getFontSizeInfo(font._family),offx=fontsz>>24,offy=fontsz>>16&255,fw=fontsz>>8&255,fh=255&fontsz,k=font._size/TextRender.standardFontSize;this.fontSizeOffX=Math.ceil(offx*k),this.fontSizeOffY=Math.ceil(offy*k),this.fontSizeW=Math.ceil(fw*k),this.fontSizeH=Math.ceil(fh*k),font._font.indexOf("italic")>=0?this.fontStr=font._font.replace("italic",""):this.fontStr=font._font}}getNextChar(str){var len=str.length,start=this._curStrPos;if(start>=len)return null;for(var i=start,state=0;i>>11==27){if(1==state)break;state=1,i++}else if(65038===c||65039===c);else if(8205==c)state=2;else if(0==state)state=1;else if(1==state)break}return this._curStrPos=i,str.substring(start,i)}filltext(ctx,data,x,y,fontStr,color,strokeColor,lineWidth,textAlign,underLine=0){if(!(data.length<=0)){var font=FontInfo.Parse(fontStr),nTextAlign=0;switch(textAlign){case"center":nTextAlign=ILaya.Context.ENUM_TEXTALIGN_CENTER;break;case"right":nTextAlign=ILaya.Context.ENUM_TEXTALIGN_RIGHT}this._fast_filltext(ctx,data,null,x,y,font,color,strokeColor,lineWidth,nTextAlign,underLine)}}fillWords(ctx,data,x,y,fontStr,color,strokeColor,lineWidth){if(data&&!(data.length<=0)){var font=FontInfo.Parse(fontStr);this._fast_filltext(ctx,null,data,x,y,font,color,strokeColor,lineWidth,0,0)}}_fast_filltext(ctx,data,htmlchars,x,y,font,color,strokeColor,lineWidth,textAlign,underLine=0){if(!(data&&data.length<1||htmlchars&&htmlchars.length<1)){if(lineWidth<0&&(lineWidth=0),this.setFont(font),this.fontScaleX=this.fontScaleY=1,!ILaya.Render.isConchApp&&TextRender.scaleFontWithCtx){var sx=1,sy=1;if(ILaya.Render.isConchApp?(sx=ctx._curMat.getScaleX(),sy=ctx._curMat.getScaleY()):(sx=ctx.getMatScaleX(),sy=ctx.getMatScaleY()),sx<1e-4||sy<.1)return;sx>1&&(this.fontScaleX=sx),sy>1&&(this.fontScaleY=sy)}font._italic&&(ctx._italicDeg=13);var wt=data,isWT=!htmlchars&&data instanceof WordText,str=data,isHtmlChar=!!htmlchars,sameTexData=isWT?wt.pageChars:[],strWidth=0;switch(isWT?(str=wt._text,(strWidth=wt.width)<0&&(strWidth=wt.width=this.charRender.getWidth(this.fontStr,str))):strWidth=str?this.charRender.getWidth(this.fontStr,str):0,textAlign){case ILaya.Context.ENUM_TEXTALIGN_CENTER:x-=strWidth/2;break;case ILaya.Context.ENUM_TEXTALIGN_RIGHT:x-=strWidth}wt&&sameTexData&&this.hasFreedText(sameTexData)&&(sameTexData=wt.pageChars=[]);var ri=null,splitTex=this.renderPerChar=!isWT||TextRender.forceSplitRender||isHtmlChar||isWT&&wt.splitRender;if(!sameTexData||sameTexData.length<1)if(splitTex){var curstr,stx=0,sty=0;for(this._curStrPos=0;;){if(isHtmlChar){var chc=htmlchars[this._curStrPos++];chc?(curstr=chc.char,stx=chc.x,sty=chc.y):curstr=null}else curstr=this.getNextChar(str);if(!curstr)break;if(!(ri=this.getCharRenderInfo(curstr,font,color,strokeColor,lineWidth,!1)))break;if(ri.isSpace);else{var add=sameTexData[ri.tex.id];if(add)add=add.words;else{var o1={texgen:ri.tex.genID,tex:ri.tex,words:[]};sameTexData[ri.tex.id]=o1,add=o1.words}ILaya.Render.isConchApp?add.push({ri:ri,x:stx,y:sty,w:ri.bmpWidth/this.fontScaleX,h:ri.bmpHeight/this.fontScaleY}):add.push({ri:ri,x:stx+1/this.fontScaleX,y:sty,w:(ri.bmpWidth-2)/this.fontScaleX,h:(ri.bmpHeight-1)/this.fontScaleY}),stx+=ri.width}}}else{var isotex=TextRender.noAtlas||strWidth*this.fontScaleX>TextRender.atlasWidth;ri=this.getCharRenderInfo(str,font,color,strokeColor,lineWidth,isotex),ILaya.Render.isConchApp?sameTexData[0]={texgen:ri.tex.genID,tex:ri.tex,words:[{ri:ri,x:0,y:0,w:ri.bmpWidth/this.fontScaleX,h:ri.bmpHeight/this.fontScaleY}]}:sameTexData[0]={texgen:ri.tex.genID,tex:ri.tex,words:[{ri:ri,x:1/this.fontScaleX,y:0/this.fontScaleY,w:(ri.bmpWidth-2)/this.fontScaleX,h:(ri.bmpHeight-1)/this.fontScaleY}]}}this._drawResortedWords(ctx,x,y,sameTexData),ctx._italicDeg=0}}_drawResortedWords(ctx,startx,starty,samePagesData){for(var isLastRender=ctx._charSubmitCache&&ctx._charSubmitCache._enbale,mat=ctx._curMat,slen=samePagesData.length,id=0;id0&&(key+="_"+strokeColor+lineWidth),font._bold&&(key+="P"),1==this.fontScaleX&&1==this.fontScaleY||(key+=(20*this.fontScaleX|0)+"_"+(20*this.fontScaleY|0));var i=0,sz=this.textAtlases.length,ri=null,atlas=null;if(!isoTexture)for(i=0;ithis.charRender.canvasWidth&&(this.charRender.canvasWidth=Math.min(2048,w1+2*margin)),isoTexture){this.charRender.fontsz=font._size,imgdt=this.charRender.getCharBmp(str,this.fontStr,lineWidth,color,strokeColor,ri,margin,margin,margin,margin,null);var tex=TextTexture.getTextTexture(imgdt.width,imgdt.height);tex.addChar(imgdt,0,0,ri.uv),ri.tex=tex,ri.orix=margin,ri.oriy=margin,tex.ri=ri,this.isoTextures.push(tex)}else{var len=str.length,lineExt=1*lineWidth,fw=Math.ceil((this.fontSizeW+2*lineExt)*this.fontScaleX),fh=Math.ceil((this.fontSizeH+2*lineExt)*this.fontScaleY);TextRender.imgdtRect[0]=(margin-this.fontSizeOffX-lineExt)*this.fontScaleX|0,TextRender.imgdtRect[1]=(margin-this.fontSizeOffY-lineExt)*this.fontScaleY|0,this.renderPerChar||1==len?(TextRender.imgdtRect[2]=Math.max(w1,fw),TextRender.imgdtRect[3]=Math.max(w1,fh)):(TextRender.imgdtRect[2]=-1,TextRender.imgdtRect[3]=fh),this.charRender.fontsz=font._size,imgdt=this.charRender.getCharBmp(str,this.fontStr,lineWidth,color,strokeColor,ri,margin,margin,margin,margin,TextRender.imgdtRect),atlas=this.addBmpData(imgdt,ri),TextRender.isWan1Wan?(ri.orix=margin,ri.oriy=margin):(ri.orix=this.fontSizeOffX+lineExt,ri.oriy=this.fontSizeOffY+lineExt),atlas.charMaps[key]=ri}return ri}addBmpData(data,ri){for(var w=data.width,h=data.height,sz=this.textAtlases.length,atlas=null,find=!1,i=0;idestroyDt&&(TextRender.showLog&&console.log(curatlas.texture.id),curatlas.destroy(),this.textAtlases[i]=this.textAtlases[sz-1],sz--,i--,maxWasteRateID=-1)}for(this.textAtlases.length=sz,sz=this.isoTextures.length,i=0;iTextRender.destroyUnusedTextureDt&&(tex.ri.deleted=!0,tex.ri.tex=null,tex.destroy(),this.isoTextures[i]=this.isoTextures[sz-1],sz--,i--);this.isoTextures.length=sz;var needGC=this.textAtlases.length>1&&this.textAtlases.length-totalUsedRateAtlas>=2;(TextRender.atlasWidth*TextRender.atlasWidth*4*this.textAtlases.length>TextRender.cleanMem||needGC||TextRender.simClean)&&(TextRender.simClean=!1,TextRender.showLog&&console.log("清理使用率低的贴图。总使用率:",totalUsedRateAtlas,":",this.textAtlases.length,"最差贴图:"+maxWasteRateID),maxWasteRateID>=0&&((curatlas=this.textAtlases[maxWasteRateID]).destroy(),this.textAtlases[maxWasteRateID]=this.textAtlases[this.textAtlases.length-1],this.textAtlases.length=this.textAtlases.length-1)),TextTexture.clean()}cleanAtlases(){}getCharBmp(c){}checkBmpLine(data,l,sx,ex){this.bmpData32.buffer!=data.data.buffer&&(this.bmpData32=new Uint32Array(data.data.buffer));for(var stpos=data.width*l+sx,x=sx;x=sy){curbbx[1]=y;break}this.checkBmpLine(data,y,0,w)?sy=y:ey=y}if(curbbx[3]>h)curbbx[3]=h;else if(y=sy=curbbx[3],ey=h,this.checkBmpLine(data,sy,0,w))for(;;){if((y=(sy+ey)/2|0)-1<=sy){curbbx[3]=y;break}this.checkBmpLine(data,y,0,w)?sy=y:ey=y}if(!onlyH){var minx=curbbx[0],stpos=w*curbbx[1];for(y=curbbx[1];y>24,offy=fontsz>>16&255,fw=fontsz>>8&255,fh=255&fontsz;console.log(" "+f," off:",offx,offy," size:",fw,fh)}var num=0;console.log("缓存数据:");var totalUsedRate=0,totalUsedRateAtlas=0;this.textAtlases.forEach(function(a){var id=a.texture.id,dt=RenderInfo.loopCount-a.texture.lastTouchTm,dtstr=dt>0?dt+"帧以前":"当前帧";for(var k in totalUsedRate+=a.texture.curUsedCovRate,totalUsedRateAtlas+=a.texture.curUsedCovRateAtlas,console.log("--图集(id:"+id+",当前使用率:"+(1e3*a.texture.curUsedCovRate|0)+"‰","当前图集使用率:",(100*a.texture.curUsedCovRateAtlas|0)+"%","图集使用率:",100*a.usedRate|0,"%, 使用于:"+dtstr+")--:"),a.charMaps){var ri=a.charMaps[k];console.log(" off:",ri.orix,ri.oriy," bmp宽高:",ri.bmpWidth,ri.bmpHeight,"无效:",ri.deleted,"touchdt:",RenderInfo.loopCount-ri.touchTick,"位置:",ri.uv[0]*TextRender.atlasWidth|0,ri.uv[1]*TextRender.atlasWidth|0,"字符:",ri.char,"key:",k),num++}}),console.log("独立贴图文字("+this.isoTextures.length+"个):"),this.isoTextures.forEach(function(tex){console.log(" size:",tex._texW,tex._texH,"touch间隔:",RenderInfo.loopCount-tex.lastTouchTm,"char:",tex.ri.char)}),console.log("总缓存:",num,"总使用率:",totalUsedRate,"总当前图集使用率:",totalUsedRateAtlas)}showAtlas(n,bgcolor,x,y,w,h){if(!this.textAtlases[n])return console.log("没有这个图集"),null;var sp=new ILaya.Sprite,texttex=this.textAtlases[n].texture,texture={width:TextRender.atlasWidth,height:TextRender.atlasWidth,sourceWidth:TextRender.atlasWidth,sourceHeight:TextRender.atlasWidth,offsetX:0,offsetY:0,getIsReady:function(){return!0},_addReference:function(){},_removeReference:function(){},_getSource:function(){return texttex._getSource()},bitmap:{id:texttex.id},_uv:Texture.DEF_UV};return sp.size=function(w,h){return this.width=w,this.height=h,sp.graphics.clear(),sp.graphics.drawRect(0,0,sp.width,sp.height,bgcolor),sp.graphics.drawTexture(texture,0,0,sp.width,sp.height),this},sp.graphics.drawRect(0,0,w,h,bgcolor),sp.graphics.drawTexture(texture,0,0,w,h),sp.pos(x,y),ILaya.stage.addChild(sp),sp}filltext_native(ctx,data,htmlchars,x,y,fontStr,color,strokeColor,lineWidth,textAlign,underLine=0){if(!(data&&data.length<=0||htmlchars&&htmlchars.length<1)){var font=FontInfo.Parse(fontStr),nTextAlign=0;switch(textAlign){case"center":nTextAlign=ILaya.Context.ENUM_TEXTALIGN_CENTER;break;case"right":nTextAlign=ILaya.Context.ENUM_TEXTALIGN_RIGHT}return this._fast_filltext(ctx,data,htmlchars,x,y,font,color,strokeColor,lineWidth,nTextAlign,underLine)}}}TextRender.useOldCharBook=!1,TextRender.atlasWidth=2048,TextRender.noAtlas=!1,TextRender.forceSplitRender=!1,TextRender.forceWholeRender=!1,TextRender.scaleFontWithCtx=!0,TextRender.standardFontSize=32,TextRender.destroyAtlasDt=10,TextRender.checkCleanTextureDt=2e3,TextRender.destroyUnusedTextureDt=3e3,TextRender.cleanMem=104857600,TextRender.isWan1Wan=!1,TextRender.showLog=!1,TextRender.debugUV=!1,TextRender.atlasWidth2=4194304,TextRender.tmpRI=new CharRenderInfo,TextRender.pixelBBX=[0,0,0,0],TextRender.textRenderInst=null,TextRender.imgdtRect=[0,0,0,0],TextRender.simClean=!1,TextTexture.gTextRender=TextRender;class Context{constructor(){if(this._tmpMatrix=new Matrix,this._drawTexToDrawTri_Vert=new Float32Array(8),this._drawTexToDrawTri_Index=new Uint16Array([0,1,2,0,2,3]),this._tempUV=new Float32Array(8),this._drawTriUseAbsMatrix=!1,this._id=++Context._COUNT,this._other=null,this._renderNextSubmitIndex=0,this._path=null,this._drawCount=1,this._width=Context._MAXSIZE,this._height=Context._MAXSIZE,this._renderCount=0,this._isConvexCmd=!0,this._submits=null,this._curSubmit=null,this._submitKey=new SubmitKey,this._mesh=null,this._pathMesh=null,this._triangleMesh=null,this.meshlist=[],this._transedPoints=new Array(8),this._temp4Points=new Array(8),this._clipRect=Context.MAXCLIPRECT,this._globalClipMatrix=new Matrix(Context._MAXSIZE,0,0,Context._MAXSIZE,0,0),this._clipInCache=!1,this._clipInfoID=0,this._clipID_Gen=0,this._curMat=null,this._lastMatScaleX=1,this._lastMatScaleY=1,this._lastMat_a=1,this._lastMat_b=0,this._lastMat_c=0,this._lastMat_d=1,this._nBlendType=0,this._save=null,this._targets=null,this._charSubmitCache=null,this._saveMark=null,this._shader2D=new Shader2D,this.sprite=null,this._italicDeg=0,this._lastTex=null,this._fillColor=0,this._flushCnt=0,this.defTexture=null,this._colorFiler=null,this.drawTexAlign=!1,this._incache=!1,this.isMain=!1,Context._contextcount++,Context._textRender=Context._textRender||new TextRender,!this.defTexture){var defTex2d=new Texture2D(2,2);defTex2d.setPixels(new Uint8Array(16)),defTex2d.lock=!0,this.defTexture=new Texture(defTex2d)}this._lastTex=this.defTexture,this.clear()}static __init__(){Context.MAXCLIPRECT=new Rectangle(0,0,Context._MAXSIZE,Context._MAXSIZE),ContextParams.DEFAULT=new ContextParams}drawImage(...args){}getImageData(...args){}measureText(text){return null}setTransform(...args){}$transform(a,b,c,d,tx,ty){}get lineJoin(){return null}set lineJoin(value){}get lineCap(){return null}set lineCap(value){}get miterLimit(){return null}set miterLimit(value){}clearRect(x,y,width,height){}_drawRect(x,y,width,height,style){Stat.renderBatches++,style&&(this.fillStyle=style),this.fillRect(x,y,width,height,null)}drawTexture2(x,y,pivotX,pivotY,m,args2){}transformByMatrix(matrix,tx,ty){this.transform(matrix.a,matrix.b,matrix.c,matrix.d,matrix.tx+tx,matrix.ty+ty)}saveTransform(matrix){this.save()}restoreTransform(matrix){this.restore()}drawRect(x,y,width,height,fillColor,lineColor,lineWidth){null!=fillColor&&(this.fillStyle=fillColor,this.fillRect(x,y,width,height)),null!=lineColor&&(this.strokeStyle=lineColor,this.lineWidth=lineWidth,this.strokeRect(x,y,width,height))}alpha(value){this.globalAlpha*=value}_transform(mat,pivotX,pivotY){this.translate(pivotX,pivotY),this.transform(mat.a,mat.b,mat.c,mat.d,mat.tx,mat.ty),this.translate(-pivotX,-pivotY)}_rotate(angle,pivotX,pivotY){this.translate(pivotX,pivotY),this.rotate(angle),this.translate(-pivotX,-pivotY)}_scale(scaleX,scaleY,pivotX,pivotY){this.translate(pivotX,pivotY),this.scale(scaleX,scaleY),this.translate(-pivotX,-pivotY)}_drawLine(x,y,fromX,fromY,toX,toY,lineColor,lineWidth,vid){this.beginPath(),this.strokeStyle=lineColor,this.lineWidth=lineWidth,this.moveTo(x+fromX,y+fromY),this.lineTo(x+toX,y+toY),this.stroke()}_drawLines(x,y,points,lineColor,lineWidth,vid){this.beginPath(),this.strokeStyle=lineColor,this.lineWidth=lineWidth;points.length;this.addPath(points.slice(),!1,!1,x,y),this.stroke()}drawCurves(x,y,points,lineColor,lineWidth){this.beginPath(),this.strokeStyle=lineColor,this.lineWidth=lineWidth,this.moveTo(x+points[0],y+points[1]);for(var i=2,n=points.length;i0&&(this.strokeStyle=strokeColor,this.lineWidth=lineWidth,this.stroke())}_drawCircle(x,y,radius,fillColor,lineColor,lineWidth,vid){Stat.renderBatches++,this.beginPath(!0),this.arc(x,y,radius,0,Context.PI2),this.closePath(),this._fillAndStroke(fillColor,lineColor,lineWidth)}_drawPie(x,y,radius,startAngle,endAngle,fillColor,lineColor,lineWidth,vid){this.beginPath(),this.moveTo(x,y),this.arc(x,y,radius,startAngle,endAngle),this.closePath(),this._fillAndStroke(fillColor,lineColor,lineWidth)}_drawPoly(x,y,points,fillColor,lineColor,lineWidth,isConvexPolygon,vid){points.length;this.beginPath(),this.addPath(points.slice(),!0,isConvexPolygon,x,y),this.closePath(),this._fillAndStroke(fillColor,lineColor,lineWidth,isConvexPolygon)}_drawPath(x,y,paths,brush,pen){this.beginPath();for(var i=0,n=paths.length;i=0;i--){var o=this._save[i];if(o.restore(this),o.isSaveMark())return void(this._save._length=i)}lastBlend!=this._nBlendType&&(this._curSubmit=SubmitBase.RENDERBASE)}}set font(str){this._other=this._other.make(),SaveBase.save(this,SaveBase.TYPE_FONT,this._other,!1)}fillText(txt,x,y,fontStr,color,align){this._fillText(txt,null,x,y,fontStr,color,null,0,null)}_fillText(txt,words,x,y,fontStr,color,strokeColor,lineWidth,textAlign,underLine=0){txt?Context._textRender.filltext(this,txt,x,y,fontStr,color,strokeColor,lineWidth,textAlign,underLine):words&&Context._textRender.fillWords(this,words,x,y,fontStr,color,strokeColor,lineWidth)}_fast_filltext(data,x,y,fontObj,color,strokeColor,lineWidth,textAlign,underLine=0){Context._textRender._fast_filltext(this,data,null,x,y,fontObj,color,strokeColor,lineWidth,textAlign,underLine)}fillWords(words,x,y,fontStr,color){this._fillText(null,words,x,y,fontStr,color,null,-1,null,0)}fillBorderWords(words,x,y,font,color,borderColor,lineWidth){this._fillBorderText(null,words,x,y,font,color,borderColor,lineWidth,null)}drawText(text,x,y,font,color,textAlign){this._fillText(text,null,x,y,font,ColorUtils.create(color).strColor,null,-1,textAlign)}strokeWord(text,x,y,font,color,lineWidth,textAlign){this._fillText(text,null,x,y,font,null,ColorUtils.create(color).strColor,lineWidth||1,textAlign)}fillBorderText(txt,x,y,fontStr,fillColor,borderColor,lineWidth,textAlign){this._fillBorderText(txt,null,x,y,fontStr,ColorUtils.create(fillColor).strColor,ColorUtils.create(borderColor).strColor,lineWidth,textAlign)}_fillBorderText(txt,words,x,y,fontStr,fillColor,borderColor,lineWidth,textAlign){this._fillText(txt,words,x,y,fontStr,fillColor,borderColor,lineWidth||1,textAlign)}_fillRect(x,y,width,height,rgba){var submit=this._curSubmit,sameKey=submit&&submit._key.submitType===SubmitBase.KEY_DRAWTEXTURE&&submit._key.blendShader===this._nBlendType;this._mesh.vertNum+4>Context._MAXVERTNUM&&(this._mesh=MeshQuadTexture.getAMesh(this.isMain),this.meshlist.push(this._mesh),sameKey=!1),sameKey&&(sameKey=sameKey&&this.isSameClipInfo(submit)),this.transformQuad(x,y,width,height,0,this._curMat,this._transedPoints),this.clipedOff(this._transedPoints)||(this._mesh.addQuad(this._transedPoints,Texture.NO_UV,rgba,!1),sameKey||(submit=this._curSubmit=SubmitTexture.create(this,this._mesh,Value2D.create(ShaderDefines2D.TEXTURE2D,0)),this._submits[this._submits._length++]=submit,this._copyClipInfo(submit,this._globalClipMatrix),submit.shaderValue.textureHost=this._lastTex,submit._key.other=this._lastTex&&this._lastTex.bitmap?this._lastTex.bitmap.id:-1,submit._renderType=SubmitBase.TYPE_TEXTURE),this._curSubmit._numEle+=6,this._mesh.indexNum+=6,this._mesh.vertNum+=4)}fillRect(x,y,width,height,fillStyle){var drawstyle=fillStyle?DrawStyle.create(fillStyle):this._shader2D.fillStyle,rgba=this.mixRGBandAlpha(drawstyle.toInt());this._fillRect(x,y,width,height,rgba)}fillTexture(texture,x,y,width,height,type,offset,other){texture._getSource()?this._fillTexture(texture,texture.width,texture.height,texture.uvrect,x,y,width,height,type,offset.x,offset.y):this.sprite&&ILaya.systemTimer.callLater(this,this._repaintSprite)}_fillTexture(texture,texw,texh,texuvRect,x,y,width,height,type,offsetx,offsety){var submit=this._curSubmit;this._mesh.vertNum+4>Context._MAXVERTNUM&&(this._mesh=MeshQuadTexture.getAMesh(this.isMain),this.meshlist.push(this._mesh));var repeatx=!0,repeaty=!0;switch(type){case"repeat":break;case"repeat-x":repeaty=!1;break;case"repeat-y":repeatx=!1;break;case"no-repeat":repeatx=repeaty=!1}var uv=this._temp4Points,stu=0,stv=0,stx=0,sty=0,edx=0,edy=0;if(offsetx<0?(stx=x,stu=-offsetx%texw/texw):stx=x+offsetx,offsety<0?(sty=y,stv=-offsety%texh/texh):sty=y+offsety,edx=x+width,edy=y+height,!repeatx&&(edx=Math.min(edx,x+offsetx+texw)),!repeaty&&(edy=Math.min(edy,y+offsety+texh)),!(edxedx||sty>edy)){var edu=(edx-x-offsetx)/texw,edv=(edy-y-offsety)/texh;if(this.transformQuad(stx,sty,edx-stx,edy-sty,0,this._curMat,this._transedPoints),uv[0]=stu,uv[1]=stv,uv[2]=edu,uv[3]=stv,uv[4]=edu,uv[5]=edv,uv[6]=stu,uv[7]=edv,!this.clipedOff(this._transedPoints)){var rgba=this._mixRGBandAlpha(4294967295,this._shader2D.ALPHA);this._mesh.addQuad(this._transedPoints,uv,rgba,!0);var sv=Value2D.create(ShaderDefines2D.TEXTURE2D,0);sv.defines.add(ShaderDefines2D.FILLTEXTURE),sv.u_TexRange=texuvRect,submit=this._curSubmit=SubmitTexture.create(this,this._mesh,sv),this._submits[this._submits._length++]=submit,this._copyClipInfo(submit,this._globalClipMatrix),submit.shaderValue.textureHost=texture,submit._renderType=SubmitBase.TYPE_TEXTURE,this._curSubmit._numEle+=6,this._mesh.indexNum+=6,this._mesh.vertNum+=4}this.breakNextMerge()}}setColorFilter(filter){SaveBase.save(this,SaveBase.TYPE_COLORFILTER,this,!0),this._colorFiler=filter,this._curSubmit=SubmitBase.RENDERBASE}drawTexture(tex,x,y,width,height){this._drawTextureM(tex,x,y,width,height,null,1,null)}drawTextures(tex,pos,tx,ty){if(tex._getSource())for(var n=pos.length/2,ipos=0,bmpid=tex.bitmap.id,i=0;iContext._MAXVERTNUM&&(this._mesh=MeshQuadTexture.getAMesh(this.isMain),this.meshlist.push(this._mesh));var submit=SubmitTexture.create(this,this._mesh,Value2D.create(ShaderDefines2D.TEXTURE2D,0));this._submits[this._submits._length++]=this._curSubmit=submit,submit.shaderValue.textureHost=tex,this._copyClipInfo(submit,this._globalClipMatrix)}_drawTexRect(x,y,w,h,uv){this.transformQuad(x,y,w,h,this._italicDeg,this._curMat,this._transedPoints);var ops=this._transedPoints;ops[0]=ops[0]+.5|0,ops[1]=ops[1]+.5|0,ops[2]=ops[2]+.5|0,ops[3]=ops[3]+.5|0,ops[4]=ops[4]+.5|0,ops[5]=ops[5]+.5|0,ops[6]=ops[6]+.5|0,ops[7]=ops[7]+.5|0,this.clipedOff(this._transedPoints)||(this._mesh.addQuad(this._transedPoints,uv,this._fillColor,!0),this._curSubmit._numEle+=6,this._mesh.indexNum+=6,this._mesh.vertNum+=4)}drawCallOptimize(enbale){return this._charSubmitCache.enable(enbale,this),enbale}_inner_drawTexture(tex,imgid,x,y,width,height,m,uv,alpha,lastRender){var preKey=this._curSubmit._key;if(uv=uv||tex._uv,preKey.submitType===SubmitBase.KEY_TRIANGLES&&preKey.other===imgid){var tv=this._drawTexToDrawTri_Vert;tv[0]=x,tv[1]=y,tv[2]=x+width,tv[3]=y,tv[4]=x+width,tv[5]=y+height,tv[6]=x,tv[7]=y+height,this._drawTriUseAbsMatrix=!0;var tuv=this._tempUV;return tuv[0]=uv[0],tuv[1]=uv[1],tuv[2]=uv[2],tuv[3]=uv[3],tuv[4]=uv[4],tuv[5]=uv[5],tuv[6]=uv[6],tuv[7]=uv[7],this.drawTriangles(tex,0,0,tv,tuv,this._drawTexToDrawTri_Index,m,alpha,null,null),this._drawTriUseAbsMatrix=!1,!0}var mesh=this._mesh,submit=this._curSubmit,ops=lastRender?this._charSubmitCache.getPos():this._transedPoints;if(this.transformQuad(x,y,width||tex.width,height||tex.height,this._italicDeg,m||this._curMat,ops),this.drawTexAlign){var round=Math.round;ops[0]=round(ops[0]),ops[1]=round(ops[1]),ops[2]=round(ops[2]),ops[3]=round(ops[3]),ops[4]=round(ops[4]),ops[5]=round(ops[5]),ops[6]=round(ops[6]),ops[7]=round(ops[7]),this.drawTexAlign=!1}var rgba=this._mixRGBandAlpha(4294967295,this._shader2D.ALPHA*alpha);if(lastRender)return this._charSubmitCache.add(this,tex,imgid,ops,uv,rgba),!0;this._drawCount++;var sameKey=imgid>=0&&preKey.submitType===SubmitBase.KEY_DRAWTEXTURE&&preKey.other===imgid;return sameKey&&(sameKey=sameKey&&this.isSameClipInfo(submit)),this._lastTex=tex,mesh.vertNum+4>Context._MAXVERTNUM&&(mesh=this._mesh=MeshQuadTexture.getAMesh(this.isMain),this.meshlist.push(mesh),sameKey=!1),mesh.addQuad(ops,uv,rgba,!0),sameKey||(this._submits[this._submits._length++]=this._curSubmit=submit=SubmitTexture.create(this,mesh,Value2D.create(ShaderDefines2D.TEXTURE2D,0)),submit.shaderValue.textureHost=tex,submit._key.other=imgid,this._copyClipInfo(submit,this._globalClipMatrix)),submit._numEle+=6,mesh.indexNum+=6,mesh.vertNum+=4,!0}transform4Points(a,m,out){var tx=m.tx,ty=m.ty,ma=m.a,mb=m.b,mc=m.c,md=m.d,a0=a[0],a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],a6=a[6],a7=a[7];m._bTransform?(out[0]=a0*ma+a1*mc+tx,out[1]=a0*mb+a1*md+ty,out[2]=a2*ma+a3*mc+tx,out[3]=a2*mb+a3*md+ty,out[4]=a4*ma+a5*mc+tx,out[5]=a4*mb+a5*md+ty,out[6]=a6*ma+a7*mc+tx,out[7]=a6*mb+a7*md+ty):(out[0]=a0+tx,out[1]=a1+ty,out[2]=a2+tx,out[3]=a3+ty,out[4]=a4+tx,out[5]=a5+ty,out[6]=a6+tx,out[7]=a7+ty)}clipedOff(pt){return this._clipRect.width<=0||this._clipRect.height<=0}transformQuad(x,y,w,h,italicDeg,m,out){var xoff=0;0!=italicDeg&&(xoff=Math.tan(italicDeg*Math.PI/180)*h);var maxx=x+w,maxy=y+h,tx=m.tx,ty=m.ty,ma=m.a,mb=m.b,mc=m.c,md=m.d,a0=x+xoff,a1=y,a2=maxx+xoff,a3=y,a4=maxx,a5=maxy,a6=x,a7=maxy;m._bTransform?(out[0]=a0*ma+a1*mc+tx,out[1]=a0*mb+a1*md+ty,out[2]=a2*ma+a3*mc+tx,out[3]=a2*mb+a3*md+ty,out[4]=a4*ma+a5*mc+tx,out[5]=a4*mb+a5*md+ty,out[6]=a6*ma+a7*mc+tx,out[7]=a6*mb+a7*md+ty):(out[0]=a0+tx,out[1]=a1+ty,out[2]=a2+tx,out[3]=a3+ty,out[4]=a4+tx,out[5]=a5+ty,out[6]=a6+tx,out[7]=a7+ty)}pushRT(){this.addRenderObject(SubmitCMD.create(null,RenderTexture2D.pushRT,this))}popRT(){this.addRenderObject(SubmitCMD.create(null,RenderTexture2D.popRT,this)),this.breakNextMerge()}useRT(rt){this.addRenderObject(SubmitCMD.create([rt],function(rt){if(!rt)throw"error useRT";rt.start(),rt.clear(0,0,0,0)},this)),this.breakNextMerge()}RTRestore(rt){this.addRenderObject(SubmitCMD.create([rt],function(rt){rt.restore()},this)),this.breakNextMerge()}breakNextMerge(){this._curSubmit=SubmitBase.RENDERBASE}_repaintSprite(){this.sprite&&this.sprite.repaint()}drawTextureWithTransform(tex,x,y,width,height,transform,tx,ty,alpha,blendMode,colorfilter=null,uv){var oldcomp=null,curMat=this._curMat;blendMode&&(oldcomp=this.globalCompositeOperation,this.globalCompositeOperation=blendMode);var oldColorFilter=this._colorFiler;if(colorfilter&&this.setColorFilter(colorfilter),!transform)return this._drawTextureM(tex,x+tx,y+ty,width,height,curMat,alpha,uv),blendMode&&(this.globalCompositeOperation=oldcomp),void(colorfilter&&this.setColorFilter(oldColorFilter));var tmpMat=this._tmpMatrix;tmpMat.a=transform.a,tmpMat.b=transform.b,tmpMat.c=transform.c,tmpMat.d=transform.d,tmpMat.tx=transform.tx+tx,tmpMat.ty=transform.ty+ty,tmpMat._bTransform=transform._bTransform,transform&&curMat._bTransform?(Matrix.mul(tmpMat,curMat,tmpMat),(transform=tmpMat)._bTransform=!0):(tmpMat.tx+=curMat.tx,tmpMat.ty+=curMat.ty,transform=tmpMat),this._drawTextureM(tex,x,y,width,height,transform,alpha,uv),blendMode&&(this.globalCompositeOperation=oldcomp),colorfilter&&this.setColorFilter(oldColorFilter)}_flushToTarget(context,target){RenderState2D.worldScissorTest=!1;var gl=LayaGL.instance;gl.disable(gl.SCISSOR_TEST);var preAlpha=RenderState2D.worldAlpha,preMatrix4=RenderState2D.worldMatrix4,preMatrix=RenderState2D.worldMatrix;RenderState2D.worldMatrix=Matrix.EMPTY,RenderState2D.restoreTempArray(),RenderState2D.worldMatrix4=RenderState2D.TEMPMAT4_ARRAY,RenderState2D.worldAlpha=1,BaseShader.activeShader=null,target.start(),context._submits._length>0&&target.clear(0,0,0,0),context._curSubmit=SubmitBase.RENDERBASE,context.flush(),context.clear(),target.restore(),context._curSubmit=SubmitBase.RENDERBASE,BaseShader.activeShader=null,RenderState2D.worldAlpha=preAlpha,RenderState2D.worldMatrix4=preMatrix4,RenderState2D.worldMatrix=preMatrix}drawCanvas(canvas,x,y,width,height){if(canvas){var submit,src=canvas.context;if(src._targets)src._submits._length>0&&(submit=SubmitCMD.create([src,src._targets],this._flushToTarget,this),this._submits[this._submits._length++]=submit),this._drawRenderTexture(src._targets,x,y,width,height,null,1,RenderTexture2D.flipyuv),this._curSubmit=SubmitBase.RENDERBASE;else{var canv=canvas;canv.touches&&canv.touches.forEach(function(v){v.touch()}),submit=SubmitCanvas.create(canvas,this._shader2D.ALPHA,this._shader2D.filters),this._submits[this._submits._length++]=submit,submit._key.clear();var mat=submit._matrix;this._curMat.copyTo(mat);var tx=mat.tx,ty=mat.ty;mat.tx=mat.ty=0,mat.transformPoint(Point.TEMP.setTo(x,y)),mat.translate(Point.TEMP.x+tx,Point.TEMP.y+ty),Matrix.mul(canv.invMat,mat,mat),this._curSubmit=SubmitBase.RENDERBASE}}}drawTarget(rt,x,y,width,height,m,shaderValue,uv=null,blend=-1){if(this._drawCount++,this._mesh.vertNum+4>Context._MAXVERTNUM&&(this._mesh=MeshQuadTexture.getAMesh(this.isMain),this.meshlist.push(this._mesh)),this.transformQuad(x,y,width,height,0,m||this._curMat,this._transedPoints),!this.clipedOff(this._transedPoints)){this._mesh.addQuad(this._transedPoints,uv||Texture.DEF_UV,4294967295,!0);var submit=this._curSubmit=SubmitTarget.create(this,this._mesh,shaderValue,rt);return submit.blendType=-1==blend?this._nBlendType:blend,this._copyClipInfo(submit,this._globalClipMatrix),submit._numEle=6,this._mesh.indexNum+=6,this._mesh.vertNum+=4,this._submits[this._submits._length++]=submit,this._curSubmit=SubmitBase.RENDERBASE,!0}return this._curSubmit=SubmitBase.RENDERBASE,!1}drawTriangles(tex,x,y,vertices,uvs,indices,matrix,alpha,color,blendMode){if(tex._getSource()){this._drawCount++;var tmpMat=this._tmpMatrix,triMesh=this._triangleMesh,oldColorFilter=null,needRestorFilter=!1;color&&(oldColorFilter=this._colorFiler,this._colorFiler=color,this._curSubmit=SubmitBase.RENDERBASE,needRestorFilter=oldColorFilter!=color);var webGLImg=tex.bitmap,preKey=this._curSubmit._key,sameKey=preKey.submitType===SubmitBase.KEY_TRIANGLES&&preKey.other===webGLImg.id&&preKey.blendShader==this._nBlendType;if(triMesh.vertNum+vertices.length/2>Context._MAXVERTNUM&&(triMesh=this._triangleMesh=MeshTexture.getAMesh(this.isMain),this.meshlist.push(triMesh),sameKey=!1),!sameKey){var submit=this._curSubmit=SubmitTexture.create(this,triMesh,Value2D.create(ShaderDefines2D.TEXTURE2D,0));submit.shaderValue.textureHost=tex,submit._renderType=SubmitBase.TYPE_TEXTURE,submit._key.submitType=SubmitBase.KEY_TRIANGLES,submit._key.other=webGLImg.id,this._copyClipInfo(submit,this._globalClipMatrix),this._submits[this._submits._length++]=submit}var rgba=this._mixRGBandAlpha(4294967295,this._shader2D.ALPHA*alpha);this._drawTriUseAbsMatrix?triMesh.addData(vertices,uvs,indices,matrix,rgba):(matrix?(tmpMat.a=matrix.a,tmpMat.b=matrix.b,tmpMat.c=matrix.c,tmpMat.d=matrix.d,tmpMat.tx=matrix.tx+x,tmpMat.ty=matrix.ty+y):(tmpMat.a=1,tmpMat.b=0,tmpMat.c=0,tmpMat.d=1,tmpMat.tx=x,tmpMat.ty=y),Matrix.mul(tmpMat,this._curMat,tmpMat),triMesh.addData(vertices,uvs,indices,tmpMat,rgba)),this._curSubmit._numEle+=indices.length,needRestorFilter&&(this._colorFiler=oldColorFilter,this._curSubmit=SubmitBase.RENDERBASE)}else this.sprite&&ILaya.systemTimer.callLater(this,this._repaintSprite)}transform(a,b,c,d,tx,ty){SaveTransform.save(this),Matrix.mul(Matrix.TEMP.setTo(a,b,c,d,tx,ty),this._curMat,this._curMat),this._curMat._checkTransform()}_transformByMatrix(matrix,tx,ty){matrix.setTranslate(tx,ty),Matrix.mul(matrix,this._curMat,this._curMat),matrix.setTranslate(0,0),this._curMat._bTransform=!0}setTransformByMatrix(value){value.copyTo(this._curMat)}rotate(angle){SaveTransform.save(this),this._curMat.rotateEx(angle)}scale(scaleX,scaleY){SaveTransform.save(this),this._curMat.scaleEx(scaleX,scaleY)}clipRect(x,y,width,height){SaveClipRect.save(this),this._clipRect==Context.MAXCLIPRECT?this._clipRect=new Rectangle(x,y,width,height):(this._clipRect.width=width,this._clipRect.height=height,this._clipRect.x=x,this._clipRect.y=y),this._clipID_Gen++,this._clipID_Gen%=1e4,this._clipInfoID=this._clipID_Gen;var cm=this._globalClipMatrix,minx=cm.tx,miny=cm.ty,maxx=minx+cm.a,maxy=miny+cm.d;if(this._clipRect.width>=Context._MAXSIZE?(cm.a=cm.d=Context._MAXSIZE,cm.b=cm.c=cm.tx=cm.ty=0):(this._curMat._bTransform?(cm.tx=this._clipRect.x*this._curMat.a+this._clipRect.y*this._curMat.c+this._curMat.tx,cm.ty=this._clipRect.x*this._curMat.b+this._clipRect.y*this._curMat.d+this._curMat.ty,cm.a=this._clipRect.width*this._curMat.a,cm.b=this._clipRect.width*this._curMat.b,cm.c=this._clipRect.height*this._curMat.c,cm.d=this._clipRect.height*this._curMat.d):(cm.tx=this._clipRect.x+this._curMat.tx,cm.ty=this._clipRect.y+this._curMat.ty,cm.a=this._clipRect.width,cm.b=cm.c=0,cm.d=this._clipRect.height),this._incache&&(this._clipInCache=!0)),cm.a>0&&cm.d>0){var cmaxx=cm.tx+cm.a,cmaxy=cm.ty+cm.d;cmaxx<=minx||cmaxy<=miny||cm.tx>=maxx||cm.ty>=maxy?(cm.a=-.1,cm.d=-.1):(cm.txmaxx&&(cm.a-=cmaxx-maxx),cm.tymaxy&&(cm.d-=cmaxy-maxy),cm.a<=0&&(cm.a=-.1),cm.d<=0&&(cm.d=-.1))}}drawMesh(x,y,ib,vb,numElement,mat,shader,shaderValues,startIndex=0){}addRenderObject(o){this._submits[this._submits._length++]=o}submitElement(start,end){this.isMain;var renderList=this._submits,ret=renderList._length;end<0&&(end=renderList._length);for(var submit=SubmitBase.RENDERBASE;startContext._MAXVERTNUM&&(this._curSubmit._numEle+=curEleNum,curEleNum=0,this._pathMesh=MeshVG.getAMesh(this.isMain),this._curSubmit=this.addVGSubmit(this._pathMesh));var curvert=this._pathMesh.vertNum;if(p.convex){var faceNum=vertNum-2;idx=new Array(3*faceNum);for(var idxpos=0,fi=0;fi0)for(var ii=0;ii0){var rgba=this.mixRGBandAlpha(this.strokeStyle._color.numColor),tPath=this._getPath(),submit=this._curSubmit,sameKey=submit._key.submitType===SubmitBase.KEY_VG&&submit._key.blendShader===this._nBlendType;sameKey&&(sameKey=sameKey&&this.isSameClipInfo(submit)),sameKey||(this._curSubmit=this.addVGSubmit(this._pathMesh));for(var curEleNum=0,i=0,sz=tPath.paths.length;iContext._MAXVERTNUM&&(this._curSubmit._numEle+=curEleNum,curEleNum=0,this._pathMesh=MeshVG.getAMesh(this.isMain),this.meshlist.push(this._pathMesh),this._curSubmit=this.addVGSubmit(this._pathMesh)),BasePoly.createLine2(p.path,idx,this.lineWidth,this._pathMesh.vertNum,vertex,p.loop);var xp,yp,_x,_y,ptnum=vertex.length/2,m=this._curMat,pi=0;if(m._bTransform)for(pi=0;pi=0){var fda=2*halfAng/Context.SEGNUM;sinx=Math.sin(fda),cosx=Math.cos(fda)}else fda=2*-halfAng/Context.SEGNUM,sinx=Math.sin(fda),cosx=Math.cos(fda);var lastx=this._path._lastOriX,lasty=this._path._lastOriY,_x1=ptx1,_y1=pty1;(Math.abs(_x1-this._path._lastOriX)>.1||Math.abs(_y1-this._path._lastOriY)>.1)&&(x=_x1,y=_y1,lastx=_x1,lasty=_y1,this._path.addPoint(x,y));var cvx=ptx1-orix,cvy=pty1-oriy;for(i=0;i.1||Math.abs(lasty-y)>.1)&&(this._path.addPoint(x,y),lastx=x,lasty=y),cvx=cx,cvy=cy}}}}}arc(cx,cy,r,startAngle,endAngle,counterclockwise=!1,b=!0){var i,ndivs,a=0,da=0,dx=0,x=0,y=0;if(da=endAngle-startAngle,counterclockwise)if(Math.abs(da)>=2*Math.PI)da=2*-Math.PI;else for(;da>0;)da-=2*Math.PI;else if(Math.abs(da)>=2*Math.PI)da=2*Math.PI;else for(;da<0;)da+=2*Math.PI;var sx=this.getMatScaleX(),sy=this.getMatScaleY(),sr=r*(sx>sy?sx:sy),cl=2*Math.PI*sr;ndivs=0|Math.max(cl/10,10);var tPath=this._getPath();for(i=0;i<=ndivs;i++)a=startAngle+da*(i/ndivs),dx=Math.cos(a),y=cy+Math.sin(a)*r,(x=cx+dx*r)==this._path._lastOriX&&y==this._path._lastOriY||tPath.addPoint(x,y);dx=Math.cos(endAngle),y=cy+Math.sin(endAngle)*r,(x=cx+dx*r)==this._path._lastOriX&&y==this._path._lastOriY||tPath.addPoint(x,y)}quadraticCurveTo(cpx,cpy,x,y){for(var tArray=Bezier.I.getBezierPoints([this._path._lastOriX,this._path._lastOriY,cpx,cpy,x,y],30,2),i=0,n=tArray.length/2;i=1)return color;var a=(4278190080&color)>>>24;return 0!=a?a*=alpha:a=255*alpha,16777215&color|a<<24}strokeRect(x,y,width,height,parameterLineWidth){if(this.lineWidth>0){var rgba=this.mixRGBandAlpha(this.strokeStyle._color.numColor),hw=this.lineWidth/2;this._fillRect(x-hw,y-hw,width+this.lineWidth,this.lineWidth,rgba),this._fillRect(x-hw,y-hw+height,width+this.lineWidth,this.lineWidth,rgba),this._fillRect(x-hw,y+hw,this.lineWidth,height-this.lineWidth,rgba),this._fillRect(x-hw+width,y+hw,this.lineWidth,height-this.lineWidth,rgba)}}clip(){}drawParticle(x,y,pt){pt.x=x,pt.y=y,this._submits[this._submits._length++]=pt}_getPath(){return this._path||(this._path=new Path)}get canvas(){return this._canvas}_fillTexture_h(tex,imgid,uv,oriw,orih,x,y,w){for(var stx=x,num=Math.floor(w/oriw),left=w%oriw,i=0;i0){var du=uv[2]-uv[0],uvr=uv[0]+du*(left/oriw),tuv=Context.tmpuv1;tuv[0]=uv[0],tuv[1]=uv[1],tuv[2]=uvr,tuv[3]=uv[3],tuv[4]=uvr,tuv[5]=uv[5],tuv[6]=uv[6],tuv[7]=uv[7],this._inner_drawTexture(tex,imgid,stx,y,left,orih,this._curMat,tuv,1,!1)}}_fillTexture_v(tex,imgid,uv,oriw,orih,x,y,h){for(var sty=y,num=Math.floor(h/orih),left=h%orih,i=0;i0){var dv=uv[7]-uv[1],uvb=uv[1]+dv*(left/orih),tuv=Context.tmpuv1;tuv[0]=uv[0],tuv[1]=uv[1],tuv[2]=uv[2],tuv[3]=uv[3],tuv[4]=uv[4],tuv[5]=uvb,tuv[6]=uv[6],tuv[7]=uvb,this._inner_drawTexture(tex,imgid,x,sty,oriw,left,this._curMat,tuv,1,!1)}}drawTextureWithSizeGrid(tex,tx,ty,width,height,sizeGrid,gx,gy){if(tex._getSource()){tx+=gx,ty+=gy;var uv=tex.uv,w=tex.bitmap.width,h=tex.bitmap.height,top=sizeGrid[0],left=sizeGrid[3],d_top=top/h,d_left=left/w,right=sizeGrid[1],bottom=sizeGrid[2],d_right=right/w,d_bottom=bottom/h,repeat=sizeGrid[4],needClip=!1;if(width==w&&(left=right=0),height==h&&(top=bottom=0),left+right>width){var clipWidth=width;needClip=!0,width=left+right,this.save(),this.clipRect(0+tx,0+ty,clipWidth,height)}var imgid=tex.bitmap.id,mat=this._curMat,tuv=this._tempUV,uvl=uv[0],uvt=uv[1],uvr=uv[4],uvb=uv[5],uvl_=uvl,uvt_=uvt,uvr_=uvr,uvb_=uvb;if(left&&top&&(uvr_=uvl+d_left,uvb_=uvt+d_top,tuv[0]=uvl,tuv[1]=uvt,tuv[2]=uvr_,tuv[3]=uvt,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl,tuv[7]=uvb_,this._inner_drawTexture(tex,imgid,tx,ty,left,top,mat,tuv,1,!1)),right&&top&&(uvl_=uvr-d_right,uvt_=uvt,uvr_=uvr,uvb_=uvt+d_top,tuv[0]=uvl_,tuv[1]=uvt_,tuv[2]=uvr_,tuv[3]=uvt_,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl_,tuv[7]=uvb_,this._inner_drawTexture(tex,imgid,width-right+tx,0+ty,right,top,mat,tuv,1,!1)),left&&bottom&&(uvl_=uvl,uvt_=uvb-d_bottom,uvr_=uvl+d_left,uvb_=uvb,tuv[0]=uvl_,tuv[1]=uvt_,tuv[2]=uvr_,tuv[3]=uvt_,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl_,tuv[7]=uvb_,this._inner_drawTexture(tex,imgid,0+tx,height-bottom+ty,left,bottom,mat,tuv,1,!1)),right&&bottom&&(uvl_=uvr-d_right,uvt_=uvb-d_bottom,uvr_=uvr,uvb_=uvb,tuv[0]=uvl_,tuv[1]=uvt_,tuv[2]=uvr_,tuv[3]=uvt_,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl_,tuv[7]=uvb_,this._inner_drawTexture(tex,imgid,width-right+tx,height-bottom+ty,right,bottom,mat,tuv,1,!1)),top&&(uvl_=uvl+d_left,uvt_=uvt,uvr_=uvr-d_right,uvb_=uvt+d_top,tuv[0]=uvl_,tuv[1]=uvt_,tuv[2]=uvr_,tuv[3]=uvt_,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl_,tuv[7]=uvb_,repeat?this._fillTexture_h(tex,imgid,tuv,tex.width-left-right,top,left+tx,ty,width-left-right):this._inner_drawTexture(tex,imgid,left+tx,ty,width-left-right,top,mat,tuv,1,!1)),bottom&&(uvl_=uvl+d_left,uvt_=uvb-d_bottom,uvr_=uvr-d_right,uvb_=uvb,tuv[0]=uvl_,tuv[1]=uvt_,tuv[2]=uvr_,tuv[3]=uvt_,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl_,tuv[7]=uvb_,repeat?this._fillTexture_h(tex,imgid,tuv,tex.width-left-right,bottom,left+tx,height-bottom+ty,width-left-right):this._inner_drawTexture(tex,imgid,left+tx,height-bottom+ty,width-left-right,bottom,mat,tuv,1,!1)),left&&(uvl_=uvl,uvt_=uvt+d_top,uvr_=uvl+d_left,uvb_=uvb-d_bottom,tuv[0]=uvl_,tuv[1]=uvt_,tuv[2]=uvr_,tuv[3]=uvt_,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl_,tuv[7]=uvb_,repeat?this._fillTexture_v(tex,imgid,tuv,left,tex.height-top-bottom,tx,top+ty,height-top-bottom):this._inner_drawTexture(tex,imgid,tx,top+ty,left,height-top-bottom,mat,tuv,1,!1)),right&&(uvl_=uvr-d_right,uvt_=uvt+d_top,uvr_=uvr,uvb_=uvb-d_bottom,tuv[0]=uvl_,tuv[1]=uvt_,tuv[2]=uvr_,tuv[3]=uvt_,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl_,tuv[7]=uvb_,repeat?this._fillTexture_v(tex,imgid,tuv,right,tex.height-top-bottom,width-right+tx,top+ty,height-top-bottom):this._inner_drawTexture(tex,imgid,width-right+tx,top+ty,right,height-top-bottom,mat,tuv,1,!1)),uvl_=uvl+d_left,uvt_=uvt+d_top,uvr_=uvr-d_right,uvb_=uvb-d_bottom,tuv[0]=uvl_,tuv[1]=uvt_,tuv[2]=uvr_,tuv[3]=uvt_,tuv[4]=uvr_,tuv[5]=uvb_,tuv[6]=uvl_,tuv[7]=uvb_,repeat){var tuvr=Context.tmpUVRect;tuvr[0]=uvl_,tuvr[1]=uvt_,tuvr[2]=uvr_-uvl_,tuvr[3]=uvb_-uvt_,this._fillTexture(tex,tex.width-left-right,tex.height-top-bottom,tuvr,left+tx,top+ty,width-left-right,height-top-bottom,"repeat",0,0)}else this._inner_drawTexture(tex,imgid,left+tx,top+ty,width-left-right,height-top-bottom,mat,tuv,1,!1);needClip&&this.restore()}}}Context.ENUM_TEXTALIGN_DEFAULT=0,Context.ENUM_TEXTALIGN_CENTER=1,Context.ENUM_TEXTALIGN_RIGHT=2,Context._SUBMITVBSIZE=32e3,Context._MAXSIZE=99999999,Context._MAXVERTNUM=65535,Context.MAXCLIPRECT=null,Context._COUNT=0,Context.SEGNUM=32,Context._contextcount=0,Context.PI2=2*Math.PI,Context._textRender=null,Context.tmpuv1=[0,0,0,0,0,0,0,0],Context.tmpUV=[0,0,0,0,0,0,0,0],Context.tmpUVRect=[0,0,0,0];class ContextParams{constructor(){this.lineWidth=1}clear(){this.lineWidth=1,this.textAlign=this.textBaseline=null}make(){return this===ContextParams.DEFAULT?new ContextParams:this}}class WebGL{static _uint8ArraySlice(){for(var sz=this.length,dec=new Uint8Array(this.length),i=0;istart)for(sz=end-start,dec=new Uint16Array(sz),i=start;i0?tex.offsetX:0,offY=tex.offsetY>0?tex.offsetY:0;offX*=wRate,offY*=hRate,GraphicsBounds._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd.x-offX,cmd.y-offY,oWidth,oHeight),tMatrix)}break;case FillTextureCmd.ID:cmd.width&&cmd.height?GraphicsBounds._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd.x,cmd.y,cmd.width,cmd.height),tMatrix):(tex=cmd.texture,GraphicsBounds._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd.x,cmd.y,tex.width,tex.height),tMatrix));break;case DrawTextureCmd.ID:var drawMatrix;cmd.matrix?(tMatrix.copyTo(tempMatrix),tempMatrix.concat(cmd.matrix),drawMatrix=tempMatrix):drawMatrix=tMatrix,realSize?cmd.width&&cmd.height?GraphicsBounds._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd.x,cmd.y,cmd.width,cmd.height),drawMatrix):(tex=cmd.texture,GraphicsBounds._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd.x,cmd.y,tex.width,tex.height),drawMatrix)):(tex=cmd.texture,wRate=(cmd.width||tex.sourceWidth)/tex.width,hRate=(cmd.height||tex.sourceHeight)/tex.height,oWidth=wRate*tex.sourceWidth,oHeight=hRate*tex.sourceHeight,offX=tex.offsetX>0?tex.offsetX:0,offY=tex.offsetY>0?tex.offsetY:0,offX*=wRate,offY*=hRate,GraphicsBounds._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd.x-offX,cmd.y-offY,oWidth,oHeight),drawMatrix));break;case DrawRectCmd.ID:GraphicsBounds._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd.x,cmd.y,cmd.width,cmd.height),tMatrix);break;case DrawCircleCmd.ID:GraphicsBounds._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd.x-cmd.radius,cmd.y-cmd.radius,cmd.radius+cmd.radius,cmd.radius+cmd.radius),tMatrix);break;case DrawLineCmd.ID:var lineWidth;GraphicsBounds._tempPoints.length=0,lineWidth=.5*cmd.lineWidth,cmd.fromX==cmd.toX?GraphicsBounds._tempPoints.push(cmd.fromX+lineWidth,cmd.fromY,cmd.toX+lineWidth,cmd.toY,cmd.fromX-lineWidth,cmd.fromY,cmd.toX-lineWidth,cmd.toY):cmd.fromY==cmd.toY?GraphicsBounds._tempPoints.push(cmd.fromX,cmd.fromY+lineWidth,cmd.toX,cmd.toY+lineWidth,cmd.fromX,cmd.fromY-lineWidth,cmd.toX,cmd.toY-lineWidth):GraphicsBounds._tempPoints.push(cmd.fromX,cmd.fromY,cmd.toX,cmd.toY),GraphicsBounds._addPointArrToRst(rst,GraphicsBounds._tempPoints,tMatrix);break;case DrawCurvesCmd.ID:GraphicsBounds._addPointArrToRst(rst,Bezier.I.getBezierPoints(cmd.points),tMatrix,cmd.x,cmd.y);break;case DrawLinesCmd.ID:case DrawPolyCmd.ID:GraphicsBounds._addPointArrToRst(rst,cmd.points,tMatrix,cmd.x,cmd.y);break;case DrawPathCmd.ID:GraphicsBounds._addPointArrToRst(rst,this._getPathPoints(cmd.paths),tMatrix,cmd.x,cmd.y);break;case DrawPieCmd.ID:GraphicsBounds._addPointArrToRst(rst,this._getPiePoints(cmd.x,cmd.y,cmd.radius,cmd.startAngle,cmd.endAngle),tMatrix);break;case DrawTrianglesCmd.ID:GraphicsBounds._addPointArrToRst(rst,this._getTriAngBBXPoints(cmd.vertices),tMatrix);break;case Draw9GridTexture.ID:GraphicsBounds._addPointArrToRst(rst,this._getDraw9GridBBXPoints(cmd),tMatrix)}return rst.length>200?rst=Utils.copyArray(rst,Rectangle._getWrapRec(rst)._getBoundPoints()):rst.length>8&&(rst=GrahamScan.scanPList(rst)),rst}_switchMatrix(tMatix,tempMatrix){tempMatrix.concat(tMatix),tempMatrix.copyTo(tMatix)}static _addPointArrToRst(rst,points,matrix,dx=0,dy=0){var i,len;for(len=points.length,i=0;i=360||d1<=-360)return rst.push(x-radius,y-radius),rst.push(x+radius,y-radius),rst.push(x+radius,y+radius),rst.push(x-radius,y+radius),rst;rst.push(x,y);var delta=d1%360;delta<0&&(delta+=360);var end1=startAngle+delta,st=startAngle*k,ed=end1*k;rst.push(x+radius*Math.cos(st),y+radius*Math.sin(st)),rst.push(x+radius*Math.cos(ed),y+radius*Math.sin(ed));for(var s1=90*Math.ceil(startAngle/90),s2=90*Math.floor(end1/90),cs=s1;cs<=s2;cs+=90){var csr=cs*k;rst.push(x+radius*Math.cos(csr),y+radius*Math.sin(csr))}return rst}_getTriAngBBXPoints(vert){var vnum=vert.length;if(vnum<2)return[];for(var minx=vert[0],miny=vert[1],maxx=minx,maxy=miny,i=2;icx&&(minx=cx),miny>cy&&(miny=cy),maxx1&&(rst.push(tCMD[1],tCMD[2]),tCMD.length>3&&rst.push(tCMD[3],tCMD[4]));return rst}}GraphicsBounds._tempMatrix=new Matrix,GraphicsBounds._initMatrix=new Matrix,GraphicsBounds._tempPoints=[],GraphicsBounds._tempMatrixArrays=[],GraphicsBounds._tempCmds=[];class SpriteConst{}SpriteConst.ALPHA=1,SpriteConst.TRANSFORM=2,SpriteConst.BLEND=4,SpriteConst.CANVAS=8,SpriteConst.FILTERS=16,SpriteConst.MASK=32,SpriteConst.CLIP=64,SpriteConst.STYLE=128,SpriteConst.TEXTURE=256,SpriteConst.GRAPHICS=512,SpriteConst.LAYAGL3D=1024,SpriteConst.CUSTOM=2048,SpriteConst.ONECHILD=4096,SpriteConst.CHILDS=8192,SpriteConst.REPAINT_NONE=0,SpriteConst.REPAINT_NODE=1,SpriteConst.REPAINT_CACHE=2,SpriteConst.REPAINT_ALL=3;class ClipRectCmd{static create(x,y,width,height){var cmd=Pool.getItemByClass("ClipRectCmd",ClipRectCmd);return cmd.x=x,cmd.y=y,cmd.width=width,cmd.height=height,cmd}recover(){Pool.recover("ClipRectCmd",this)}run(context,gx,gy){context.clipRect(this.x+gx,this.y+gy,this.width,this.height)}get cmdID(){return ClipRectCmd.ID}}ClipRectCmd.ID="ClipRect";class DrawTexturesCmd{static create(texture,pos){var cmd=Pool.getItemByClass("DrawTexturesCmd",DrawTexturesCmd);return cmd.texture=texture,texture._addReference(),cmd.pos=pos,cmd}recover(){this.texture._removeReference(),this.texture=null,this.pos=null,Pool.recover("DrawTexturesCmd",this)}run(context,gx,gy){context.drawTextures(this.texture,this.pos,gx,gy)}get cmdID(){return DrawTexturesCmd.ID}}DrawTexturesCmd.ID="DrawTextures";class FillBorderTextCmd{static create(text,x,y,font,fillColor,borderColor,lineWidth,textAlign){var cmd=Pool.getItemByClass("FillBorderTextCmd",FillBorderTextCmd);return cmd.text=text,cmd.x=x,cmd.y=y,cmd.font=font,cmd.fillColor=fillColor,cmd.borderColor=borderColor,cmd.lineWidth=lineWidth,cmd.textAlign=textAlign,cmd}recover(){Pool.recover("FillBorderTextCmd",this)}run(context,gx,gy){context.fillBorderText(this.text,this.x+gx,this.y+gy,this.font,this.fillColor,this.borderColor,this.lineWidth,this.textAlign)}get cmdID(){return FillBorderTextCmd.ID}}FillBorderTextCmd.ID="FillBorderText";class FillBorderWordsCmd{static create(words,x,y,font,fillColor,borderColor,lineWidth){var cmd=Pool.getItemByClass("FillBorderWordsCmd",FillBorderWordsCmd);return cmd.words=words,cmd.x=x,cmd.y=y,cmd.font=font,cmd.fillColor=fillColor,cmd.borderColor=borderColor,cmd.lineWidth=lineWidth,cmd}recover(){this.words=null,Pool.recover("FillBorderWordsCmd",this)}run(context,gx,gy){context.fillBorderWords(this.words,this.x+gx,this.y+gy,this.font,this.fillColor,this.borderColor,this.lineWidth)}get cmdID(){return FillBorderWordsCmd.ID}}FillBorderWordsCmd.ID="FillBorderWords";class FillTextCmd{constructor(){this._textIsWorldText=!1,this._fontColor=4294967295,this._strokeColor=0,this._fontObj=FillTextCmd._defFontObj,this._nTexAlign=0}static create(text,x,y,font,color,textAlign){var cmd=Pool.getItemByClass("FillTextCmd",FillTextCmd);return cmd.text=text,cmd._textIsWorldText=text instanceof WordText,cmd.x=x,cmd.y=y,cmd.font=font,cmd.color=color,cmd.textAlign=textAlign,cmd}recover(){Pool.recover("FillTextCmd",this)}run(context,gx,gy){ILaya.stage.isGlobalRepaint()&&this._textIsWorldText&&this._text.cleanCache(),this._textIsWorldText?context._fast_filltext(this._text,this.x+gx,this.y+gy,this._fontObj,this._color,null,0,this._nTexAlign,0):context.drawText(this._text,this.x+gx,this.y+gy,this._font,this._color,this._textAlign)}get cmdID(){return FillTextCmd.ID}get text(){return this._text}set text(value){this._text=value,this._textIsWorldText=value instanceof WordText,this._textIsWorldText&&this._text.cleanCache()}get font(){return this._font}set font(value){this._font=value,this._fontObj=FontInfo.Parse(value),this._textIsWorldText&&this._text.cleanCache()}get color(){return this._color}set color(value){this._color=value,this._fontColor=ColorUtils.create(value).numColor,this._textIsWorldText&&this._text.cleanCache()}get textAlign(){return this._textAlign}set textAlign(value){switch(this._textAlign=value,value){case"center":this._nTexAlign=ILaya.Context.ENUM_TEXTALIGN_CENTER;break;case"right":this._nTexAlign=ILaya.Context.ENUM_TEXTALIGN_RIGHT;break;default:this._nTexAlign=ILaya.Context.ENUM_TEXTALIGN_DEFAULT}this._textIsWorldText&&this._text.cleanCache()}}FillTextCmd.ID="FillText",FillTextCmd._defFontObj=new FontInfo(null);class FillWordsCmd{static create(words,x,y,font,color){var cmd=Pool.getItemByClass("FillWordsCmd",FillWordsCmd);return cmd.words=words,cmd.x=x,cmd.y=y,cmd.font=font,cmd.color=color,cmd}recover(){this.words=null,Pool.recover("FillWordsCmd",this)}run(context,gx,gy){context.fillWords(this.words,this.x+gx,this.y+gy,this.font,this.color)}get cmdID(){return FillWordsCmd.ID}}FillWordsCmd.ID="FillWords";class SaveCmd{static create(){return Pool.getItemByClass("SaveCmd",SaveCmd)}recover(){Pool.recover("SaveCmd",this)}run(context,gx,gy){context.save()}get cmdID(){return SaveCmd.ID}}SaveCmd.ID="Save";class StrokeTextCmd{static create(text,x,y,font,color,lineWidth,textAlign){var cmd=Pool.getItemByClass("StrokeTextCmd",StrokeTextCmd);return cmd.text=text,cmd.x=x,cmd.y=y,cmd.font=font,cmd.color=color,cmd.lineWidth=lineWidth,cmd.textAlign=textAlign,cmd}recover(){Pool.recover("StrokeTextCmd",this)}run(context,gx,gy){context.strokeWord(this.text,this.x+gx,this.y+gy,this.font,this.color,this.lineWidth,this.textAlign)}get cmdID(){return StrokeTextCmd.ID}}StrokeTextCmd.ID="StrokeText";class CacheManger{constructor(){}static regCacheByFunction(disposeFunction,getCacheListFunction){var cache;CacheManger.unRegCacheByFunction(disposeFunction,getCacheListFunction),cache={tryDispose:disposeFunction,getCacheList:getCacheListFunction},CacheManger._cacheList.push(cache)}static unRegCacheByFunction(disposeFunction,getCacheListFunction){var i,len;for(len=CacheManger._cacheList.length,i=0;i0&&(CacheManger._index++,CacheManger._index=CacheManger._index%len,cacheList[CacheManger._index].tryDispose(!1),!(ILaya.Browser.now()-tTime>CacheManger.loopTimeLimit));)count--}}}CacheManger.loopTimeLimit=2,CacheManger._cacheList=[],CacheManger._index=0;class VectorGraphManager{constructor(){this.useDic={},this.shapeDic={},this.shapeLineDic={},this._id=0,this._checkKey=!1,this._freeIdArray=[],CacheManger.regCacheByFunction(this.startDispose.bind(this),this.getCacheList.bind(this))}static getInstance(){return VectorGraphManager.instance=VectorGraphManager.instance||new VectorGraphManager}getId(){return this._id++}addShape(id,shape){this.shapeDic[id]=shape,this.useDic[id]||(this.useDic[id]=!0)}addLine(id,Line){this.shapeLineDic[id]=Line,this.shapeLineDic[id]||(this.shapeLineDic[id]=!0)}getShape(id){this._checkKey&&null!=this.useDic[id]&&(this.useDic[id]=!0)}deleteShape(id){this.shapeDic[id]&&(this.shapeDic[id]=null,delete this.shapeDic[id]),this.shapeLineDic[id]&&(this.shapeLineDic[id]=null,delete this.shapeLineDic[id]),null!=this.useDic[id]&&delete this.useDic[id]}getCacheList(){var str,list=[];for(str in this.shapeDic)list.push(this.shapeDic[str]);for(str in this.shapeLineDic)list.push(this.shapeLineDic[str]);return list}startDispose(key){var str;for(str in this.useDic)this.useDic[str]=!1;this._checkKey=!0}endDispose(){if(this._checkKey){var str;for(str in this.useDic)this.useDic[str]||this.deleteShape(str);this._checkKey=!1}}}class Graphics{constructor(){this._sp=null,this._one=null,this._render=this._renderEmpty,this._cmds=null,this._vectorgraphArray=null,this._graphicBounds=null,this.autoDestroy=!1,this._createData()}_createData(){}_clearData(){}_destroyData(){}destroy(){this.clear(!0),this._graphicBounds&&this._graphicBounds.destroy(),this._graphicBounds=null,this._vectorgraphArray=null,this._sp&&(this._sp._renderType=0,this._sp._setRenderType(0),this._sp=null),this._destroyData()}clear(recoverCmds=!0){if(recoverCmds){var tCmd=this._one;if(this._cmds){var i,len=this._cmds.length;for(i=0;i-1;i--)if(this._isTextCmd(cmds[i]))return cmds[i].text=text,!0}else if(this._one&&this._isTextCmd(this._one))return this._one.text=text,!0;return!1}_isTextCmd(cmd){var cmdID=cmd.cmdID;return cmdID==FillTextCmd.ID||cmdID==StrokeTextCmd.ID||cmdID==FillBorderTextCmd.ID}replaceTextColor(color){this._repaint();var cmds=this._cmds;if(cmds)for(var i=cmds.length-1;i>-1;i--)this._isTextCmd(cmds[i])&&this._setTextCmdColor(cmds[i],color);else this._one&&this._isTextCmd(this._one)&&this._setTextCmdColor(this._one,color)}_setTextCmdColor(cmdO,color){switch(cmdO.cmdID){case FillTextCmd.ID:case StrokeTextCmd.ID:cmdO.color=color;break;case FillBorderTextCmd.ID:case FillBorderWordsCmd.ID:case FillBorderTextCmd.ID:cmdO.fillColor=color}}loadImage(url,x=0,y=0,width=0,height=0,complete=null){var tex=ILaya.Loader.getRes(url);tex?tex.getIsReady()?this.drawImage(tex,x,y,width,height):tex.once(Event.READY,this,this.drawImage,[tex,x,y,width,height]):((tex=new Texture).load(url),ILaya.Loader.cacheRes(url,tex),tex.once(Event.READY,this,this.drawImage,[tex,x,y,width,height])),null!=complete&&(tex.getIsReady()?complete.call(this._sp):tex.on(Event.READY,this._sp,complete))}_renderEmpty(sprite,context,x,y){}_renderAll(sprite,context,x,y){for(var cmds=this._cmds,i=0,n=cmds.length;i=1&&lineColor?lineWidth/2:0,lineOffset=lineColor?lineWidth:0;return this._saveToCmd(Render._context.drawRect,DrawRectCmd.create.call(this,x+offset,y+offset,width-lineOffset,height-lineOffset,fillColor,lineColor,lineWidth))}drawCircle(x,y,radius,fillColor,lineColor=null,lineWidth=1){var offset=lineWidth>=1&&lineColor?lineWidth/2:0;return this._saveToCmd(Render._context._drawCircle,DrawCircleCmd.create.call(this,x,y,radius-offset,fillColor,lineColor,lineWidth,0))}drawPie(x,y,radius,startAngle,endAngle,fillColor,lineColor=null,lineWidth=1){var offset=lineWidth>=1&&lineColor?lineWidth/2:0,lineOffset=lineColor?lineWidth:0;return this._saveToCmd(Render._context._drawPie,DrawPieCmd.create.call(this,x+offset,y+offset,radius-lineOffset,Utils.toRadian(startAngle),Utils.toRadian(endAngle),fillColor,lineColor,lineWidth,0))}drawPoly(x,y,points,fillColor,lineColor=null,lineWidth=1){var tIsConvexPolygon=!1;tIsConvexPolygon=!(points.length>6);var offset=lineWidth>=1&&lineColor?lineWidth%2==0?0:.5:0;return this._saveToCmd(Render._context._drawPoly,DrawPolyCmd.create.call(this,x+offset,y+offset,points,fillColor,lineColor,lineWidth,tIsConvexPolygon,0))}drawPath(x,y,paths,brush=null,pen=null){return this._saveToCmd(Render._context._drawPath,DrawPathCmd.create.call(this,x,y,paths,brush,pen))}draw9Grid(texture,x=0,y=0,width=0,height=0,sizeGrid=null){this._saveToCmd(null,Draw9GridTexture.create(texture,x,y,width,height,sizeGrid))}}class Const{}Const.NOT_ACTIVE=1,Const.ACTIVE_INHIERARCHY=2,Const.AWAKED=4,Const.NOT_READY=8,Const.DISPLAY=16,Const.HAS_ZORDER=32,Const.HAS_MOUSE=64,Const.DISPLAYED_INSTAGE=128,Const.DRAWCALL_OPTIMIZE=256;class HitArea{contains(x,y){return!!HitArea._isHitGraphic(x,y,this.hit)&&!HitArea._isHitGraphic(x,y,this.unHit)}static _isHitGraphic(x,y,graphic){if(!graphic)return!1;var i,len,cmd,cmds=graphic.cmds;if(!cmds&&graphic._one&&((cmds=HitArea._cmds).length=1,cmds[0]=graphic._one),!cmds)return!1;for(len=cmds.length,i=0;i=Math.max(p1y,p2y)))(p.y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x>p.x&&nCross++}return nCross%2==1}get hit(){return this._hit||(this._hit=new ILaya.Graphics),this._hit}set hit(value){this._hit=value}get unHit(){return this._unHit||(this._unHit=new ILaya.Graphics),this._unHit}set unHit(value){this._unHit=value}}HitArea._cmds=[],HitArea._rect=new Rectangle,HitArea._ptPoint=new Point;class ClassUtils{static regClass(className,classDef){ClassUtils._classMap[className]=classDef}static regShortClassName(classes){for(var i=0;i=0)return null;this._extUIChild.push(node)}return null}removeInputChild(node){var idx=this._extUIChild.indexOf(node);idx>=0&&this._extUIChild.splice(idx,1)}addChildren(...args){for(var i=0,n=args.length;i=0&&index<=this._children.length){if(node._parent===this){var oldIndex=this.getChildIndex(node);this._children.splice(oldIndex,1),this._children.splice(index,0,node),this._childChanged()}else node._parent&&node._parent.removeChild(node),this._children===Node.ARRAY_EMPTY&&(this._children=[]),this._children.splice(index,0,node),node._setParent(this);return node}throw new Error("appendChildAt:The index is out of bounds")}getChildIndex(node){return this._children.indexOf(node)}getChildByName(name){var nodes=this._children;if(nodes)for(var i=0,n=nodes.length;i=childs.length)throw new Error("setChildIndex:The index is out of bounds.");var oldIndex=this.getChildIndex(node);if(oldIndex<0)throw new Error("setChildIndex:node is must child of this object.");return childs.splice(oldIndex,1),childs.splice(index,0,node),this._childChanged(),node}_childChanged(child=null){}removeChild(node){if(!this._children)return node;var index=this._children.indexOf(node);return this.removeChildAt(index)}removeSelf(){return this._parent&&this._parent.removeChild(this),this}removeChildByName(name){var node=this.getChildByName(name);return node&&this.removeChild(node),node}removeChildAt(index){var node=this.getChildAt(index);return node&&(this._children.splice(index,1),node._setParent(null)),node}removeChildren(beginIndex=0,endIndex=2147483647){if(this._children&&this._children.length>0){var childs=this._children;if(0===beginIndex&&endIndex>=childs.length-1){var arr=childs;this._children=Node.ARRAY_EMPTY}else arr=childs.splice(beginIndex,endIndex-beginIndex);for(var i=0,n=arr.length;i-1?(this._children.splice(index,1,newNode),oldNode._setParent(null),newNode._setParent(this),newNode):null}get numChildren(){return this._children.length}get parent(){return this._parent}_setParent(value){this._parent!==value&&(value?(this._parent=value,this._onAdded(),this.event(Event.ADDED),this._getBit(Const.DISPLAY)&&(this._setUpNoticeChain(),value.displayedInStage&&this._displayChild(this,!0)),value._childChanged(this)):(this._onRemoved(),this.event(Event.REMOVED),this._parent._childChanged(),this._getBit(Const.DISPLAY)&&this._displayChild(this,!1),this._parent=value))}get displayedInStage(){return this._getBit(Const.DISPLAY)?this._getBit(Const.DISPLAYED_INSTAGE):(this._setBitUp(Const.DISPLAY),this._getBit(Const.DISPLAYED_INSTAGE))}_updateDisplayedInstage(){var ele;ele=this;for(var stage=ILaya.stage,displayedInStage=!1;ele;){if(ele._getBit(Const.DISPLAY)){displayedInStage=ele._getBit(Const.DISPLAYED_INSTAGE);break}if(ele===stage||ele._getBit(Const.DISPLAYED_INSTAGE)){displayedInStage=!0;break}ele=ele._parent}this._setBit(Const.DISPLAYED_INSTAGE,displayedInStage)}_setDisplay(value){this._getBit(Const.DISPLAYED_INSTAGE)!==value&&(this._setBit(Const.DISPLAYED_INSTAGE,value),value?this.event(Event.DISPLAY):this.event(Event.UNDISPLAY))}_displayChild(node,display){var childs=node._children;if(childs)for(var i=0,n=childs.length;i0?this._displayChild(child,display):child._setDisplay(display))}node._setDisplay(display)}contains(node){if(node===this)return!0;for(;node;){if(node._parent===this)return!0;node=node._parent}return!1}timerLoop(delay,caller,method,args=null,coverBefore=!0,jumpFrame=!1){(this.scene?this.scene.timer:ILaya.timer).loop(delay,caller,method,args,coverBefore,jumpFrame)}timerOnce(delay,caller,method,args=null,coverBefore=!0){(this.scene?this.scene.timer:ILaya.timer)._create(!1,!1,delay,caller,method,args,coverBefore)}frameLoop(delay,caller,method,args=null,coverBefore=!0){(this.scene?this.scene.timer:ILaya.timer)._create(!0,!0,delay,caller,method,args,coverBefore)}frameOnce(delay,caller,method,args=null,coverBefore=!0){(this.scene?this.scene.timer:ILaya.timer)._create(!0,!1,delay,caller,method,args,coverBefore)}clearTimer(caller,method){(this.scene?this.scene.timer:ILaya.timer).clear(caller,method)}callLater(method,args=null){(this.scene?this.scene.timer:ILaya.timer).callLater(this,method,args)}runCallLater(method){(this.scene?this.scene.timer:ILaya.timer).runCallLater(this,method)}get scene(){return this._scene}get active(){return!this._getBit(Const.NOT_READY)&&!this._getBit(Const.NOT_ACTIVE)}set active(value){if(value=!!value,!this._getBit(Const.NOT_ACTIVE)!==value){if(this._activeChangeScripts&&0!==this._activeChangeScripts.length)throw value?"Node: can't set the main inActive node active in hierarchy,if the operate is in main inActive node or it's children script's onDisable Event.":"Node: can't set the main active node inActive in hierarchy,if the operate is in main active node or it's children script's onEnable Event.";this._setBit(Const.NOT_ACTIVE,!value),this._parent&&this._parent.activeInHierarchy&&(value?this._processActive():this._processInActive())}}get activeInHierarchy(){return this._getBit(Const.ACTIVE_INHIERARCHY)}_onActive(){Stat.spriteCount++}_onInActive(){Stat.spriteCount--}_onActiveInScene(){}_onInActiveInScene(){}_parse(data,spriteMap){}_setBelongScene(scene){if(!this._scene){this._scene=scene,this._onActiveInScene();for(var i=0,n=this._children.length;i.01||sprite._needRepaint()){var temp=context.globalAlpha;context.globalAlpha*=alpha,context.drawTexture(tex,x-style.pivotX+tex.offsetX,y-style.pivotY+tex.offsetY,sprite._width||tex.width,sprite._height||tex.height),context.globalAlpha=temp}}static alpha_transform_drawTexture(sprite,context,x,y){var alpha,style=sprite._style,tex=sprite.texture;if((alpha=style.alpha)>.01||sprite._needRepaint()){var temp=context.globalAlpha;context.globalAlpha*=alpha,context.saveTransform(LayaGLQuickRunner.curMat),context.transformByMatrix(sprite.transform,x,y),context.drawTexture(tex,-style.pivotX+tex.offsetX,-style.pivotY+tex.offsetY,sprite._width||tex.width,sprite._height||tex.height),context.restoreTransform(LayaGLQuickRunner.curMat),context.globalAlpha=temp}}static alpha_transform_drawLayaGL(sprite,context,x,y){var alpha,style=sprite._style;if((alpha=style.alpha)>.01||sprite._needRepaint()){var temp=context.globalAlpha;context.globalAlpha*=alpha,context.saveTransform(LayaGLQuickRunner.curMat),context.transformByMatrix(sprite.transform,x,y),sprite._graphics&&sprite._graphics._render(sprite,context,-style.pivotX,-style.pivotY),context.restoreTransform(LayaGLQuickRunner.curMat),context.globalAlpha=temp}}static alpha_drawLayaGL(sprite,context,x,y){var alpha,style=sprite._style;if((alpha=style.alpha)>.01||sprite._needRepaint()){var temp=context.globalAlpha;context.globalAlpha*=alpha,sprite._graphics&&sprite._graphics._render(sprite,context,x-style.pivotX,y-style.pivotY),context.globalAlpha=temp}}static transform_drawLayaGL(sprite,context,x,y){var style=sprite._style;context.saveTransform(LayaGLQuickRunner.curMat),context.transformByMatrix(sprite.transform,x,y),sprite._graphics&&sprite._graphics._render(sprite,context,-style.pivotX,-style.pivotY),context.restoreTransform(LayaGLQuickRunner.curMat)}static transform_drawNodes(sprite,context,x,y){var textLastRender=sprite._getBit(Const.DRAWCALL_OPTIMIZE)&&context.drawCallOptimize(!0),style=sprite._style;context.saveTransform(LayaGLQuickRunner.curMat),context.transformByMatrix(sprite.transform,x,y),x=-style.pivotX,y=-style.pivotY;var ele,childs=sprite._children,n=childs.length;if(style.viewport){var _x,_y,rect=style.viewport,left=rect.x,top=rect.y,right=rect.right,bottom=rect.bottom;for(i=0;ileft&&(_y=ele._y)top&&ele.render(context,x,y)}else for(var i=0;ileft&&(_y=ele._y)top&&ele.render(context,x,y)}else for(var i=0;i0;)tType&type&&(rst=new RenderSprite(tType,rst)),tType>>=1;return rst}onCreate(type){}_style(sprite,context,x,y){var style=sprite._style;null!=style.render&&style.render(sprite,context,x,y);var next=this._next;next._fun.call(next,sprite,context,x,y)}_no(sprite,context,x,y){}_custom(sprite,context,x,y){sprite.customRender(context,x,y),this._next._fun.call(this._next,sprite,context,x-sprite.pivotX,y-sprite.pivotY)}_clip(sprite,context,x,y){var next=this._next;if(next!=RenderSprite.NORENDER){var r=sprite._style.scrollRect;context.save(),context.clipRect(x,y,r.width,r.height),next._fun.call(next,sprite,context,x-r.x,y-r.y),context.restore()}}_texture(sprite,context,x,y){var tex=sprite.texture;tex._getSource()&&context.drawTexture(tex,x-sprite.pivotX+tex.offsetX,y-sprite.pivotY+tex.offsetY,sprite._width||tex.width,sprite._height||tex.height);var next=this._next;next!=RenderSprite.NORENDER&&next._fun.call(next,sprite,context,x,y)}_graphics(sprite,context,x,y){var style=sprite._style,g=sprite._graphics;g&&g._render(sprite,context,x-style.pivotX,y-style.pivotY);var next=this._next;next!=RenderSprite.NORENDER&&next._fun.call(next,sprite,context,x,y)}_image(sprite,context,x,y){var style=sprite._style;context.drawTexture2(x,y,style.pivotX,style.pivotY,sprite.transform,sprite._graphics._one)}_image2(sprite,context,x,y){var style=sprite._style;context.drawTexture2(x,y,style.pivotX,style.pivotY,sprite.transform,sprite._graphics._one)}_alpha(sprite,context,x,y){var alpha;if((alpha=sprite._style.alpha)>.01||sprite._needRepaint()){var temp=context.globalAlpha;context.globalAlpha*=alpha;var next=this._next;next._fun.call(next,sprite,context,x,y),context.globalAlpha=temp}}_transform(sprite,context,x,y){var transform=sprite.transform,_next=this._next;sprite._style;transform&&_next!=RenderSprite.NORENDER?(context.save(),context.transform(transform.a,transform.b,transform.c,transform.d,transform.tx+x,transform.ty+y),_next._fun.call(_next,sprite,context,0,0),context.restore()):_next!=RenderSprite.NORENDER&&_next._fun.call(_next,sprite,context,x,y)}_children(sprite,context,x,y){var ele,style=sprite._style,childs=sprite._children,n=childs.length;x-=sprite.pivotX,y-=sprite.pivotY;var textLastRender=sprite._getBit(Const.DRAWCALL_OPTIMIZE)&&context.drawCallOptimize(!0);if(style.viewport){var _x,_y,rect=style.viewport,left=rect.x,top=rect.y,right=rect.right,bottom=rect.bottom;for(i=0;ileft&&(_y=ele._y)top&&ele.render(context,x,y)}else for(var i=0;i2048||h>2048))return console.warn("cache bitmap size larger than 2048,cache ignored"),_cacheStyle.releaseContext(),void _next._fun.call(_next,sprite,context,x,y);if(canvas||(_cacheStyle.createContext(),canvas=_cacheStyle.canvas),(tx=canvas.context).sprite=sprite,(canvas.width!=w||canvas.height!=h)&&canvas.size(w,h),"bitmap"===tCacheType?tx.asBitmap=!0:"normal"===tCacheType&&(tx.asBitmap=!1),tx.clear(),1!=scaleX||1!=scaleY){var ctx=tx;ctx.save(),ctx.scale(scaleX,scaleY),_next._fun.call(_next,sprite,tx,-left,-top),ctx.restore(),sprite._applyFilters()}else ctx=tx,_next._fun.call(_next,sprite,tx,-left,-top),sprite._applyFilters();_cacheStyle.staticCache&&(_cacheStyle.reCache=!1),Stat.canvasReCache++}_canvas_webgl_normal_repaint(sprite,context){var _cacheStyle=sprite._cacheStyle,_next=this._next,canvas=_cacheStyle.canvas,tCacheType=_cacheStyle.cacheAs;_cacheStyle._calculateCacheRect(sprite,tCacheType,0,0);canvas||(canvas=_cacheStyle.canvas=new WebGLCacheAsNormalCanvas(context,sprite));var tx=canvas.context;canvas.startRec(),_next._fun.call(_next,sprite,tx,sprite.pivotX,sprite.pivotY),sprite._applyFilters(),Stat.canvasReCache++,canvas.endRec()}_blend(sprite,context,x,y){var style=sprite._style,next=this._next;style.blendMode?(context.save(),context.globalCompositeOperation=style.blendMode,next._fun.call(next,sprite,context,x,y),context.restore()):next._fun.call(next,sprite,context,x,y)}_mask(sprite,context,x,y){var next=this._next,mask=sprite.mask,ctx=context;if(mask){ctx.save();var preBlendMode=ctx.globalCompositeOperation,tRect=new Rectangle;if(tRect.copyFrom(mask.getBounds()),tRect.width=Math.round(tRect.width),tRect.height=Math.round(tRect.height),tRect.x=Math.round(tRect.x),tRect.y=Math.round(tRect.y),tRect.width>0&&tRect.height>0){var w=tRect.width,h=tRect.height,tmpRT=WebGLRTMgr.getRT(w,h);ctx.breakNextMerge(),ctx.pushRT(),ctx.addRenderObject(SubmitCMD.create([ctx,tmpRT,w,h],RenderSprite.tmpTarget,this)),mask.render(ctx,-tRect.x,-tRect.y),ctx.breakNextMerge(),ctx.popRT(),ctx.save(),ctx.clipRect(x+tRect.x-sprite.getStyle().pivotX,y+tRect.y-sprite.getStyle().pivotY,w,h),next._fun.call(next,sprite,ctx,x,y),ctx.restore(),preBlendMode=ctx.globalCompositeOperation,ctx.addRenderObject(SubmitCMD.create(["mask"],RenderSprite.setBlendMode,this));var shaderValue=Value2D.create(ShaderDefines2D.TEXTURE2D,0),uv=Texture.INV_UV;ctx.drawTarget(tmpRT,x+tRect.x-sprite.getStyle().pivotX,y+tRect.y-sprite.getStyle().pivotY,w,h,Matrix.TEMP.identity(),shaderValue,uv,6),ctx.addRenderObject(SubmitCMD.create([tmpRT],RenderSprite.recycleTarget,this)),ctx.addRenderObject(SubmitCMD.create([preBlendMode],RenderSprite.setBlendMode,this))}ctx.restore()}else next._fun.call(next,sprite,context,x,y)}static tmpTarget(ctx,rt,w,h){rt.start(),rt.clear(0,0,0,0)}static recycleTarget(rt){WebGLRTMgr.releaseRT(rt)}static setBlendMode(blendMode){var gl=WebGLContext.mainContext;BlendMode.targetFns[BlendMode.TOINT[blendMode]](gl)}}RenderSprite.INIT=69905,RenderSprite.renders=[],RenderSprite.NORENDER=new RenderSprite(0,null),RenderSprite.tempUV=new Array(8);class Sprite extends Node{constructor(){super(),this._x=0,this._y=0,this._width=0,this._height=0,this._visible=!0,this._mouseState=0,this._zOrder=0,this._renderType=0,this._transform=null,this._tfChanged=!1,this._repaint=SpriteConst.REPAINT_NONE,this._texture=null,this._style=SpriteStyle.EMPTY,this._cacheStyle=CacheStyle.EMPTY,this._boundStyle=null,this._graphics=null,this.mouseThrough=!1,this.autoSize=!1,this.hitTestPrior=!1}destroy(destroyChild=!0){super.destroy(destroyChild),this._style&&this._style.recover(),this._cacheStyle&&this._cacheStyle.recover(),this._boundStyle&&this._boundStyle.recover(),this._style=null,this._cacheStyle=null,this._boundStyle=null,this._transform=null,this._graphics&&this._graphics.autoDestroy&&this._graphics.destroy(),this._graphics=null,this.texture=null}updateZOrder(){Utils.updateOrder(this._children)&&this.repaint()}_getBoundsStyle(){return this._boundStyle||(this._boundStyle=BoundsStyle.create()),this._boundStyle}_setCustomRender(){}set customRenderEnable(b){b&&(this._renderType|=SpriteConst.CUSTOM,this._setRenderType(this._renderType),this._setCustomRender())}get cacheAs(){return this._cacheStyle.cacheAs}_setCacheAs(value){}set cacheAs(value){value!==this._cacheStyle.userSetCache&&(this.mask&&"normal"===value||(this._setCacheAs(value),this._getCacheStyle().userSetCache=value,this._checkCanvasEnable(),this.repaint()))}_checkCanvasEnable(){var tEnable=this._cacheStyle.needEnableCanvasRender();this._getCacheStyle().enableCanvasRender=tEnable,tEnable?(this._cacheStyle.needBitmapCache()?this._cacheStyle.cacheAs="bitmap":this._cacheStyle.cacheAs=this._cacheStyle.userSetCache,this._cacheStyle.reCache=!0,this._renderType|=SpriteConst.CANVAS):(this._cacheStyle.cacheAs="none",this._cacheStyle.releaseContext(),this._renderType&=~SpriteConst.CANVAS),this._setCacheAs(this._cacheStyle.cacheAs),this._setRenderType(this._renderType)}get staticCache(){return this._cacheStyle.staticCache}set staticCache(value){this._getCacheStyle().staticCache=value,value||this.reCache()}reCache(){this._cacheStyle.reCache=!0,this._repaint|=SpriteConst.REPAINT_CACHE}getRepaint(){return this._repaint}_setX(value){this._x=value}_setY(value){this._y=value}_setWidth(texture,value){}_setHeight(texture,value){}get x(){return this._x}set x(value){if(!this.destroyed&&this._x!==value){this._setX(value),this.parentRepaint(SpriteConst.REPAINT_CACHE);var p=this._cacheStyle.maskParent;p&&p.repaint(SpriteConst.REPAINT_CACHE)}}get y(){return this._y}set y(value){if(!this.destroyed&&this._y!==value){this._setY(value),this.parentRepaint(SpriteConst.REPAINT_CACHE);var p=this._cacheStyle.maskParent;p&&p.repaint(SpriteConst.REPAINT_CACHE)}}get width(){return this.get_width()}set width(value){this.set_width(value)}set_width(value){this._width!==value&&(this._width=value,this._setWidth(this.texture,value),this._setTranformChange())}get_width(){return this.autoSize?this.texture?this.texture.width:this._graphics||0!==this._children.length?this.getSelfBounds().width:0:this._width||(this.texture?this.texture.width:0)}get height(){return this.get_height()}set height(value){this.set_height(value)}set_height(value){this._height!==value&&(this._height=value,this._setHeight(this.texture,value),this._setTranformChange())}get_height(){return this.autoSize?this.texture?this.texture.height:this._graphics||0!==this._children.length?this.getSelfBounds().height:0:this._height||(this.texture?this.texture.height:0)}get displayWidth(){return this.width*this.scaleX}get displayHeight(){return this.height*this.scaleY}setSelfBounds(bound){this._getBoundsStyle().userBounds=bound}getBounds(){return this._getBoundsStyle().bounds=Rectangle._getWrapRec(this._boundPointsToParent())}getSelfBounds(){return this._boundStyle&&this._boundStyle.userBounds?this._boundStyle.userBounds:this._graphics||0!==this._children.length||this._texture?this._getBoundsStyle().bounds=Rectangle._getWrapRec(this._getBoundPointsM(!1)):Rectangle.TEMP.setTo(0,0,this.width,this.height)}_boundPointsToParent(ifRotate=!1){var pX=0,pY=0;this._style&&(pX=this.pivotX,pY=this.pivotY,ifRotate=ifRotate||0!==this._style.rotation,this._style.scrollRect&&(pX+=this._style.scrollRect.x,pY+=this._style.scrollRect.y));var pList=this._getBoundPointsM(ifRotate);if(!pList||pList.length<1)return pList;if(8!=pList.length&&(pList=ifRotate?GrahamScan.scanPList(pList):Rectangle._getWrapRec(pList,Rectangle.TEMP)._getBoundPoints()),!this.transform)return Utils.transPointList(pList,this._x-pX,this._y-pY),pList;var i,tPoint=Point.TEMP,len=pList.length;for(i=0;i1?1:value,this._setAlpha(value)}get visible(){return this.get_visible()}set visible(value){this.set_visible(value)}get_visible(){return this._visible}set_visible(value){this._visible!==value&&(this._visible=value,this.parentRepaint(SpriteConst.REPAINT_ALL))}_setBlendMode(value){}get blendMode(){return this._style.blendMode}set blendMode(value){this._setBlendMode(value),this.getStyle().blendMode=value,value&&"source-over"!=value?this._renderType|=SpriteConst.BLEND:this._renderType&=~SpriteConst.BLEND,this._setRenderType(this._renderType),this.parentRepaint()}get graphics(){return this._graphics||(this.graphics=new Graphics,this._graphics.autoDestroy=!0),this._graphics}_setGraphics(value){}_setGraphicsCallBack(){}set graphics(value){this._graphics&&(this._graphics._sp=null),this._graphics=value,value?(this._setGraphics(value),this._renderType|=SpriteConst.GRAPHICS,value._sp=this):this._renderType&=~SpriteConst.GRAPHICS,this._setRenderType(this._renderType),this.repaint()}get scrollRect(){return this._style.scrollRect}_setScrollRect(value){}set scrollRect(value){this.getStyle().scrollRect=value,this._setScrollRect(value),this.repaint(),value?this._renderType|=SpriteConst.CLIP:this._renderType&=~SpriteConst.CLIP,this._setRenderType(this._renderType)}pos(x,y,speedMode=!1){if(this._x!==x||this._y!==y){if(this.destroyed)return this;if(speedMode){this._setX(x),this._setY(y),this.parentRepaint(SpriteConst.REPAINT_CACHE);var p=this._cacheStyle.maskParent;p&&p.repaint(SpriteConst.REPAINT_CACHE)}else this.x=x,this.y=y}return this}pivot(x,y){return this.pivotX=x,this.pivotY=y,this}size(width,height){return this.width=width,this.height=height,this}scale(scaleX,scaleY,speedMode=!1){var style=this.getStyle();if(style.scaleX!=scaleX||style.scaleY!=scaleY){if(this.destroyed)return this;speedMode?(this._setScaleX(scaleX),this._setScaleY(scaleY),this._setTranformChange()):(this.scaleX=scaleX,this.scaleY=scaleY)}return this}skew(skewX,skewY){return this.skewX=skewX,this.skewY=skewY,this}render(ctx,x,y){RenderSprite.renders[this._renderType]._fun(this,ctx,x+this._x,y+this._y),this._repaint=0}drawToCanvas(canvasWidth,canvasHeight,offsetX,offsetY){return Sprite.drawToCanvas(this,this._renderType,canvasWidth,canvasHeight,offsetX,offsetY)}drawToTexture(canvasWidth,canvasHeight,offsetX,offsetY){return Sprite.drawToTexture(this,this._renderType,canvasWidth,canvasHeight,offsetX,offsetY)}drawToTexture3D(offx,offy,tex){throw"not implement"}customRender(context,x,y){this._repaint=SpriteConst.REPAINT_ALL}_applyFilters(){}get filters(){return this._cacheStyle.filters}_setColorFilter(value){}set filters(value){value&&0===value.length&&(value=null),this._cacheStyle.filters!=value&&(this._getCacheStyle().filters=value?value.slice():null,value&&value.length?(this._setColorFilter(value[0]),this._renderType|=SpriteConst.FILTERS):(this._setColorFilter(null),this._renderType&=~SpriteConst.FILTERS),this._setRenderType(this._renderType),value&&value.length>0?(this._getBit(Const.DISPLAY)||this._setBitUp(Const.DISPLAY),1==value.length&&value[0]instanceof ColorFilter||(this._getCacheStyle().cacheForFilters=!0,this._checkCanvasEnable())):this._cacheStyle.cacheForFilters&&(this._cacheStyle.cacheForFilters=!1,this._checkCanvasEnable()),this._getCacheStyle().hasGlowFilter=this._isHaveGlowFilter(),this.repaint())}_isHaveGlowFilter(){var i,len;if(this.filters)for(i=0;i=0;)point=(ele=list[i]).fromParentPoint(point),i--;return point}toParentPoint(point){if(!point)return point;point.x-=this.pivotX,point.y-=this.pivotY,this.transform&&this._transform.transformPoint(point),point.x+=this._x,point.y+=this._y;var scroll=this._style.scrollRect;return scroll&&(point.x-=scroll.x,point.y-=scroll.y),point}fromParentPoint(point){if(!point)return point;point.x-=this._x,point.y-=this._y;var scroll=this._style.scrollRect;return scroll&&(point.x+=scroll.x,point.y+=scroll.y),this.transform&&this._transform.invertTransformPoint(point),point.x+=this.pivotX,point.y+=this.pivotY,point}fromStagePoint(point){return point}on(type,caller,listener,args=null){return 1!==this._mouseState&&this.isMouseEvent(type)?(this.mouseEnabled=!0,this._setBit(Const.HAS_MOUSE,!0),this._parent&&this._onDisplay(),this._createListener(type,caller,listener,args,!1)):super.on(type,caller,listener,args)}once(type,caller,listener,args=null){return 1!==this._mouseState&&this.isMouseEvent(type)?(this.mouseEnabled=!0,this._setBit(Const.HAS_MOUSE,!0),this._parent&&this._onDisplay(),this._createListener(type,caller,listener,args,!0)):super.once(type,caller,listener,args)}_onDisplay(v){if(1!==this._mouseState){var ele=this;for(ele=ele.parent;ele&&1!==ele._mouseState&&!ele._getBit(Const.HAS_MOUSE);)ele.mouseEnabled=!0,ele._setBit(Const.HAS_MOUSE,!0),ele=ele.parent}}_setParent(value){super._setParent(value),value&&this._getBit(Const.HAS_MOUSE)&&this._onDisplay()}loadImage(url,complete=null){if(url){var tex=ILaya.Loader.getRes(url);tex||((tex=new Texture).load(url),ILaya.Loader.cacheRes(url,tex)),this.texture=tex,tex.getIsReady()?loaded.call(this):tex.once(Event.READY,this,loaded)}else this.texture=null,loaded.call(this);function loaded(){this.repaint(SpriteConst.REPAINT_ALL),complete&&complete.run()}return this}static fromImage(url){return(new Sprite).loadImage(url)}repaint(type=SpriteConst.REPAINT_CACHE){this._repaint&type||(this._repaint|=type,this.parentRepaint(type)),this._cacheStyle&&this._cacheStyle.maskParent&&this._cacheStyle.maskParent.repaint(type)}_needRepaint(){return this._repaint&SpriteConst.REPAINT_CACHE&&this._cacheStyle.enableCanvasRender&&this._cacheStyle.reCache}_childChanged(child=null){this._children.length?this._renderType|=SpriteConst.CHILDS:this._renderType&=~SpriteConst.CHILDS,this._setRenderType(this._renderType),child&&this._getBit(Const.HAS_ZORDER)&&ILaya.systemTimer.callLater(this,this.updateZOrder),this.repaint(SpriteConst.REPAINT_ALL)}parentRepaint(type=SpriteConst.REPAINT_CACHE){var p=this._parent;!p||p._repaint&type||(p._repaint|=type,p.parentRepaint(type))}get stage(){return ILaya.stage}get hitArea(){return this._style.hitArea}set hitArea(value){this.getStyle().hitArea=value}_setMask(value){}get mask(){return this._cacheStyle.mask}set mask(value){value&&this.mask&&this.mask._cacheStyle.maskParent||(this._getCacheStyle().mask=value,this._setMask(value),this._checkCanvasEnable(),value?value._getCacheStyle().maskParent=this:this.mask&&(this.mask._getCacheStyle().maskParent=null),this._renderType|=SpriteConst.MASK,this._setRenderType(this._renderType),this.parentRepaint(SpriteConst.REPAINT_ALL))}get mouseEnabled(){return this._mouseState>1}set mouseEnabled(value){this._mouseState=value?2:1}startDrag(area=null,hasInertia=!1,elasticDistance=0,elasticBackTime=300,data=null,disableMouseEvent=!1,ratio=.92){this._style.dragging||(this.getStyle().dragging=new ILaya.Dragging),this._style.dragging.start(this,area,hasInertia,elasticDistance,elasticBackTime,data,disableMouseEvent,ratio)}stopDrag(){this._style.dragging&&this._style.dragging.stop()}_setDisplay(value){value||this._cacheStyle&&(this._cacheStyle.releaseContext(),this._cacheStyle.releaseFilterCache(),this._cacheStyle.hasGlowFilter&&(this._cacheStyle.hasGlowFilter=!1)),super._setDisplay(value)}hitTestPoint(x,y){var point=this.globalToLocal(Point.TEMP.setTo(x,y));return x=point.x,y=point.y,(this._style.hitArea?this._style.hitArea:this._width>0&&this._height>0?Rectangle.TEMP.setTo(0,0,this._width,this._height):this.getSelfBounds()).contains(x,y)}getMousePoint(){return this.globalToLocal(Point.TEMP.setTo(ILaya.stage.mouseX,ILaya.stage.mouseY))}get globalScaleX(){for(var scale=1,ele=this;ele&&ele!==ILaya.stage;)scale*=ele.scaleX,ele=ele.parent;return scale}get globalRotation(){for(var angle=0,ele=this;ele&&ele!==ILaya.stage;)angle+=ele.rotation,ele=ele.parent;return angle}get globalScaleY(){for(var scale=1,ele=this;ele&&ele!==ILaya.stage;)scale*=ele.scaleY,ele=ele.parent;return scale}get mouseX(){return this.getMousePoint().x}get mouseY(){return this.getMousePoint().y}get zOrder(){return this._zOrder}set zOrder(value){this._zOrder!=value&&(this._zOrder=value,this._parent&&(value&&this._parent._setBit(Const.HAS_ZORDER,!0),ILaya.systemTimer.callLater(this._parent,this.updateZOrder)))}get texture(){return this._texture}_setTexture(value){}set texture(value){"string"==typeof value?this.loadImage(value):this._texture!=value&&(this._texture&&this._texture._removeReference(),this._texture=value,value&&value._addReference(),this._setTexture(value),this._setWidth(this._texture,this.width),this._setHeight(this._texture,this.height),value?this._renderType|=SpriteConst.TEXTURE:this._renderType&=~SpriteConst.TEXTURE,this._setRenderType(this._renderType),this.repaint())}get viewport(){return this._style.viewport}set viewport(value){var recArr;"string"==typeof value&&((recArr=value.split(",")).length>3&&(value=new Rectangle(parseFloat(recArr[0]),parseFloat(recArr[1]),parseFloat(recArr[2]),parseFloat(recArr[3]))));this.getStyle().viewport=value}_setRenderType(type){}_setTranformChange(){this._tfChanged=!0,this._renderType|=SpriteConst.TRANSFORM,this.parentRepaint(SpriteConst.REPAINT_CACHE)}_setBgStyleColor(x,y,width,height,fillColor){}_setBorderStyleColor(x,y,width,height,fillColor,borderWidth){}captureMouseEvent(exclusive){ILaya.MouseManager.instance.setCapture(this,exclusive)}releaseMouseEvent(){ILaya.MouseManager.instance.releaseCapture()}set drawCallOptimize(value){this._setBit(Const.DRAWCALL_OPTIMIZE,value)}get drawCallOptimize(){return this._getBit(Const.DRAWCALL_OPTIMIZE)}}Sprite.drawToCanvas=function(sprite,_renderType,canvasWidth,canvasHeight,offsetX,offsetY){offsetX-=sprite.x,offsetY-=sprite.y,offsetX|=0,offsetY|=0,canvasWidth|=0,canvasHeight|=0;var ctx=new Context;ctx.size(canvasWidth,canvasHeight),ctx.asBitmap=!0,ctx._targets.start(),RenderSprite.renders[_renderType]._fun(sprite,ctx,offsetX,offsetY),ctx.flush(),ctx._targets.end(),ctx._targets.restore();var dt=ctx._targets.getData(0,0,canvasWidth,canvasHeight);ctx.destroy();for(var imgdata=new ImageData(canvasWidth,canvasHeight),lineLen=4*canvasWidth,dst=imgdata.data,y=canvasHeight-1,off=y*lineLen,srcoff=0;y>=0;y--)dst.set(dt.subarray(srcoff,srcoff+lineLen),off),off-=lineLen,srcoff+=lineLen;var canv=new HTMLCanvas(!0);return canv.size(canvasWidth,canvasHeight),canv.getContext("2d").putImageData(imgdata,0,0),canv},Sprite.drawToTexture=function(sprite,_renderType,canvasWidth,canvasHeight,offsetX,offsetY){offsetX-=sprite.x,offsetY-=sprite.y,offsetX|=0,offsetY|=0,canvasWidth|=0,canvasHeight|=0;var ctx=new Context;ctx.size(canvasWidth,canvasHeight),ctx.asBitmap=!0,ctx._targets.start(),RenderSprite.renders[_renderType]._fun(sprite,ctx,offsetX,offsetY),ctx.flush(),ctx._targets.end(),ctx._targets.restore();var rtex=new Texture(ctx._targets,Texture.INV_UV);return ctx.destroy(!0),rtex},ClassUtils.regClass("laya.display.Sprite",Sprite),ClassUtils.regClass("Laya.Sprite",Sprite);class TextStyle extends SpriteStyle{constructor(){super(...arguments),this.italic=!1}reset(){return super.reset(),this.italic=!1,this.align="left",this.wordWrap=!1,this.leading=0,this.padding=[0,0,0,0],this.bgColor=null,this.borderColor=null,this.asPassword=!1,this.stroke=0,this.strokeColor="#000000",this.bold=!1,this.underline=!1,this.underlineColor=null,this.currBitmapFont=null,this}recover(){this!==TextStyle.EMPTY&&Pool.recover("TextStyle",this.reset())}static create(){return Pool.getItemByClass("TextStyle",TextStyle)}render(sprite,context,x,y){(this.bgColor||this.borderColor)&&context.drawRect(x,y,sprite.width,sprite.height,this.bgColor,this.borderColor,1)}}TextStyle.EMPTY=new TextStyle;class Text extends Sprite{constructor(){super(),this._textWidth=0,this._textHeight=0,this._lines=[],this._lineWidths=[],this._startX=0,this._startY=0,this._charSize={},this._valign="top",this._fontSize=Text.defaultFontSize,this._font=Text.defaultFont,this._color="#000000",this._singleCharRender=!1,this.overflow=Text.VISIBLE,this._style=TextStyle.EMPTY}static defaultFontStr(){return Text.defaultFontSize+"px "+Text.defaultFont}getStyle(){return this._style===TextStyle.EMPTY&&(this._style=TextStyle.create()),this._style}_getTextStyle(){return this._style===TextStyle.EMPTY&&(this._style=TextStyle.create()),this._style}static registerBitmapFont(name,bitmapFont){Text._bitmapFonts||(Text._bitmapFonts={}),Text._bitmapFonts[name]=bitmapFont}static unregisterBitmapFont(name,destroy=!0){if(Text._bitmapFonts&&Text._bitmapFonts[name]){var tBitmapFont=Text._bitmapFonts[name];destroy&&tBitmapFont.destroy(),delete Text._bitmapFonts[name]}}destroy(destroyChild=!0){super.destroy(destroyChild),this._clipPoint=null,this._lines=null,this._lineWidths=null,this._words&&this._words.forEach(function(w){w.cleanCache()}),this._words=null,this._charSize=null}_getBoundPointsM(ifRotate=!1){var rec=Rectangle.TEMP;return rec.setTo(0,0,this.width,this.height),rec._getBoundPoints()}getGraphicBounds(realSize=!1){var rec=Rectangle.TEMP;return rec.setTo(0,0,this.width,this.height),rec}get width(){return this._width?this._width:this.textWidth+this.padding[1]+this.padding[3]}set width(value){value!=this._width&&(super.set_width(value),this.isChanged=!0,this.borderColor&&this._setBorderStyleColor(0,0,this.width,this.height,this.borderColor,1))}_getCSSStyle(){return this._style}get height(){return this._height?this._height:this.textHeight}set height(value){value!=this._height&&(super.set_height(value),this.isChanged=!0,this.borderColor&&this._setBorderStyleColor(0,0,this.width,this.height,this.borderColor,1))}get textWidth(){return this._isChanged&&ILaya.systemTimer.runCallLater(this,this.typeset),this._textWidth}get textHeight(){return this._isChanged&&ILaya.systemTimer.runCallLater(this,this.typeset),this._textHeight}get text(){return this._text||""}get_text(){return this._text||""}set_text(value){this._text!==value&&(this.lang(value+""),this.isChanged=!0,this.event(Event.CHANGE),this.borderColor&&this._setBorderStyleColor(0,0,this.width,this.height,this.borderColor,1))}set text(value){this.set_text(value)}lang(text,arg1=null,arg2=null,arg3=null,arg4=null,arg5=null,arg6=null,arg7=null,arg8=null,arg9=null,arg10=null){if(text=Text.langPacks&&Text.langPacks[text]?Text.langPacks[text]:text,arguments.length<2)this._text=text;else{for(var i=0,n=arguments.length;i0;j--)word+="●";return word}_renderText(){var padding=this.padding,visibleLineCount=this._lines.length;this.overflow!=Text.VISIBLE&&(visibleLineCount=Math.min(visibleLineCount,Math.floor((this.height-padding[0]-padding[2])/(this.leading+this._charSize.height))+1));var beginLine=this.scrollY/(this._charSize.height+this.leading)|0,graphics=this.graphics;graphics.clear(!0);var ctxFont=this._getContextFont();ILaya.Browser.context.font=ctxFont;var startX=padding[3],textAlgin="left",lines=this._lines,lineHeight=this.leading+this._charSize.height,tCurrBitmapFont=this._style.currBitmapFont;tCurrBitmapFont&&(lineHeight=this.leading+tCurrBitmapFont.getMaxHeight());var startY=padding[0];if(!tCurrBitmapFont&&this._width>0&&this._textWidth<=this._width&&("right"==this.align?(textAlgin="right",startX=this._width-padding[1]):"center"==this.align&&(textAlgin="center",startX=.5*this._width+padding[3]-padding[1])),this._height>0){var tempVAlign=this._textHeight>this._height?"top":this.valign;"middle"===tempVAlign?startY=.5*(this._height-visibleLineCount*lineHeight)+padding[0]-padding[2]:"bottom"===tempVAlign&&(startY=this._height-visibleLineCount*lineHeight-padding[2])}var style=this._style;if(tCurrBitmapFont&&tCurrBitmapFont.autoScaleSize)var bitmapScale=tCurrBitmapFont.fontSize/this.fontSize;if(this._clipPoint){var tClipWidth,tClipHeight;if(graphics.save(),tCurrBitmapFont&&tCurrBitmapFont.autoScaleSize)tClipWidth=this._width?this._width-padding[3]-padding[1]:this._textWidth,tClipHeight=this._height?this._height-padding[0]-padding[2]:this._textHeight,tClipWidth*=bitmapScale,tClipHeight*=bitmapScale,graphics.clipRect(padding[3],padding[0],tClipWidth,tClipHeight);else graphics.clipRect(padding[3],padding[0],this._width?this._width-padding[3]-padding[1]:this._textWidth,this._height?this._height-padding[0]-padding[2]:this._textHeight);this.repaint()}var password=style.asPassword;"prompt"in this&&this.prompt==this._text&&(password=!1);for(var x=0,y=0,end=Math.min(this._lines.length,visibleLineCount+beginLine)||1,i=beginLine;i0;j--)word+="●"}if(null==word&&(word=""),x=startX-(this._clipPoint?this._clipPoint.x:0),y=startY+lineHeight*i-(this._clipPoint?this._clipPoint.y:0),this.underline&&this._drawUnderline(textAlgin,x,y,i),tCurrBitmapFont){var tWidth=this.width;tCurrBitmapFont.autoScaleSize&&(tWidth=this.width*bitmapScale),tCurrBitmapFont._drawText(word,this,x,y,this.align,tWidth)}else this._words||(this._words=[]),this._words.length>i-beginLine?_word=this._words[i-beginLine]:(_word=new WordText,this._words.push(_word)),_word.setText(word),_word.splitRender=this._singleCharRender,style.stroke?graphics.fillBorderText(_word,x,y,ctxFont,this.color,style.strokeColor,style.stroke,textAlgin):graphics.fillText(_word,x,y,ctxFont,this.color,textAlgin)}if(tCurrBitmapFont&&tCurrBitmapFont.autoScaleSize){var tScale=1/bitmapScale;this.scale(tScale,tScale)}this._clipPoint&&graphics.restore(),this._startX=startX,this._startY=startY}_drawUnderline(align,x,y,lineIndex){var lineWidth=this._lineWidths[lineIndex];switch(align){case"center":x-=lineWidth/2;break;case"right":x-=lineWidth}y+=this._charSize.height,this._graphics.drawLine(x,y,x+lineWidth,y,this.underlineColor||this.color,1)}typeset(){if(this._isChanged=!1,!this._text)return this._clipPoint=null,this._textWidth=this._textHeight=0,void this.graphics.clear(!0);ILaya.Render.isConchApp?window.conchTextCanvas.font=this._getContextFont():ILaya.Browser.context.font=this._getContextFont(),this._lines.length=0,this._lineWidths.length=0,this._isPassWordMode()?this._parseLines(this._getPassWordTxt(this._text)):this._parseLines(this._text),this._evalTextSize(),this._checkEnabledViewportOrNot()?this._clipPoint||(this._clipPoint=new Point(0,0)):this._clipPoint=null,this._renderText()}_evalTextSize(){var nw,nh;nw=Math.max.apply(this,this._lineWidths),nh=this._style.currBitmapFont?this._lines.length*(this._style.currBitmapFont.getMaxHeight()+this.leading)+this.padding[0]+this.padding[2]:this._lines.length*(this._charSize.height+this.leading)+this.padding[0]+this.padding[2],nw==this._textWidth&&nh==this._textHeight||(this._textWidth=nw,this._textHeight=nh)}_checkEnabledViewportOrNot(){return this.overflow==Text.SCROLL&&(this._width>0&&this._textWidth>this._width||this._height>0&&this._textHeight>this._height)}changeText(text){this._text!==text&&(this.lang(text+""),this._graphics&&this._graphics.replaceText(this._text)||this.typeset())}_parseLines(text){var needWordWrapOrTruncate=this.wordWrap||this.overflow==Text.HIDDEN;if(needWordWrapOrTruncate)var wordWrapWidth=this._getWordWrapWidth();var bitmapFont=this._style.currBitmapFont;if(bitmapFont)this._charSize.width=bitmapFont.getMaxWidth(),this._charSize.height=bitmapFont.getMaxHeight();else{var measureResult=null;(measureResult=ILaya.Render.isConchApp?window.conchTextCanvas.measureText(Text._testWord):ILaya.Browser.context.measureText(Text._testWord))||(measureResult={width:100}),this._charSize.width=measureResult.width,this._charSize.height=measureResult.height||this.fontSize}for(var lines=text.replace(/\r\n/g,"\n").split("\n"),i=0,n=lines.length;iwordWrapWidth)if(this.wordWrap){var newLine=line.substring(startIndex,j);if(newLine.charCodeAt(newLine.length-1)<255){var execResult=/(?:\w|-)+$/.exec(newLine);execResult&&(j=execResult.index+startIndex,0==execResult.index?j+=newLine.length:newLine=line.substring(startIndex,j))}if(lines.push(newLine),this._lineWidths.push(wordWidth-charsWidth),startIndex=j,!(j+maybeIndexmaxScrollX?maxScrollX:value,this._clipPoint.x=value,this._renderText()}}get scrollX(){return this._clipPoint?this._clipPoint.x:0}set scrollY(value){if(!(this.overflow!=Text.SCROLL||this.textHeightmaxScrollY?maxScrollY:value,this._clipPoint.y=value,this._renderText()}}get scrollY(){return this._clipPoint?this._clipPoint.y:0}get maxScrollX(){return this.textWidth-1&&(pattern=pattern.replace("^^","")),this._restrictPattern=new RegExp(pattern,"g")):this._restrictPattern=null}set editable(value){this._editable=value,ILaya.Render.isConchApp&&Input.input.setForbidEdit(!value)}get editable(){return this._editable}get maxChars(){return this._maxChars}set maxChars(value){value<=0&&(value=1e5),this._maxChars=value}get prompt(){return this._prompt}set prompt(value){!this._text&&value&&super.set_color(this._promptColor),this.promptColor=this._promptColor,this._text?super.set_text(this._text==this._prompt?value:this._text):super.set_text(value),this._prompt=Text.langPacks&&Text.langPacks[value]?Text.langPacks[value]:value}get promptColor(){return this._promptColor}set promptColor(value){this._promptColor=value,this._content||super.set_color(value)}get type(){return this._type}set type(value){this._getTextStyle().asPassword="password"===value,this._type=value}}Input.TYPE_TEXT="text",Input.TYPE_PASSWORD="password",Input.TYPE_EMAIL="email",Input.TYPE_URL="url",Input.TYPE_NUMBER="number",Input.TYPE_RANGE="range",Input.TYPE_DATE="date",Input.TYPE_MONTH="month",Input.TYPE_WEEK="week",Input.TYPE_TIME="time",Input.TYPE_DATE_TIME="datetime",Input.TYPE_DATE_TIME_LOCAL="datetime-local",Input.TYPE_SEARCH="search",Input.IOS_IFRAME=!1,Input.inputHeight=45,Input.isInputting=!1,ClassUtils.regClass("laya.display.Input",Input),ClassUtils.regClass("Laya.Input",Input);class TouchManager{constructor(){this.preOvers=[],this.preDowns=[],this.preRightDowns=[],this.enable=!0,this._event=new Event,this._lastClickTime=0}_clearTempArrs(){TouchManager._oldArr.length=0,TouchManager._newArr.length=0,TouchManager._tEleArr.length=0}getTouchFromArr(touchID,arr){var i,len,tTouchO;for(len=arr.length,i=0;i=0;i--)arr[i].id==touchID&&arr.splice(i,1)}createTouchO(ele,touchID){var rst;return(rst=Pool.getItem("TouchData")||{}).id=touchID,rst.tar=ele,rst}onMouseDown(ele,touchID,isLeft=!1){var preO,tO,arrs,preDowns;this.enable&&(preO=this.getTouchFromArr(touchID,this.preOvers),arrs=this.getEles(ele,null,TouchManager._tEleArr),preO?preO.tar=ele:(tO=this.createTouchO(ele,touchID),this.preOvers.push(tO)),Browser.onMobile&&this.sendEvents(arrs,Event.MOUSE_OVER),preDowns=isLeft?this.preDowns:this.preRightDowns,(preO=this.getTouchFromArr(touchID,preDowns))?preO.tar=ele:(tO=this.createTouchO(ele,touchID),preDowns.push(tO)),this.sendEvents(arrs,isLeft?Event.MOUSE_DOWN:Event.RIGHT_MOUSE_DOWN),this._clearTempArrs())}sendEvents(eles,type){var i,len,_target;for(len=eles.length,this._event._stoped=!1,_target=eles[0],i=0;i=0){newArr.splice(tIndex,newArr.length-tIndex);break}arrs.push(tar)}arrs.length>0&&this.sendEvents(arrs,Event.MOUSE_OUT),newArr.length>0&&this.sendEvents(newArr,Event.MOUSE_OVER)}}onMouseMove(ele,touchID){var preO,arrs;this.enable&&((preO=this.getTouchFromArr(touchID,this.preOvers))?(this.checkMouseOutAndOverOfMove(ele,preO.tar),preO.tar=ele,arrs=this.getEles(ele,null,TouchManager._tEleArr)):(arrs=this.getEles(ele,null,TouchManager._tEleArr),this.sendEvents(arrs,Event.MOUSE_OVER),this.preOvers.push(this.createTouchO(ele,touchID))),this.sendEvents(arrs,Event.MOUSE_MOVE),this._clearTempArrs())}getLastOvers(){return TouchManager._tEleArr.length=0,this.preOvers.length>0&&this.preOvers[0].tar?this.getEles(this.preOvers[0].tar,null,TouchManager._tEleArr):(TouchManager._tEleArr.push(ILaya.stage),TouchManager._tEleArr)}stageMouseOut(){var lastOvers;lastOvers=this.getLastOvers(),this.preOvers.length=0,this.sendEvents(lastOvers,Event.MOUSE_OUT)}onMouseUp(ele,touchID,isLeft=!1){if(this.enable){var preO,arrs,oldArr,i,len,tar,sendArr,preDowns,onMobile=Browser.onMobile;if(arrs=this.getEles(ele,null,TouchManager._tEleArr),this.sendEvents(arrs,isLeft?Event.MOUSE_UP:Event.RIGHT_MOUSE_UP),preDowns=isLeft?this.preDowns:this.preRightDowns,preO=this.getTouchFromArr(touchID,preDowns)){var isDouble,now=Browser.now();if(isDouble=now-this._lastClickTime<300,this._lastClickTime=now,ele==preO.tar)sendArr=arrs;else for(oldArr=this.getEles(preO.tar,null,TouchManager._oldArr),(sendArr=TouchManager._newArr).length=0,len=oldArr.length,i=0;i=0&&sendArr.push(tar);sendArr.length>0&&this.sendEvents(sendArr,isLeft?Event.CLICK:Event.RIGHT_CLICK),isLeft&&isDouble&&this.sendEvents(sendArr,Event.DOUBLE_CLICK),this.removeTouchFromArr(touchID,preDowns),preO.tar=null,Pool.recover("TouchData",preO)}else;(preO=this.getTouchFromArr(touchID,this.preOvers))&&onMobile&&((sendArr=this.getEles(preO.tar,null,sendArr))&&sendArr.length>0&&this.sendEvents(sendArr,Event.MOUSE_OUT),this.removeTouchFromArr(touchID,this.preOvers),preO.tar=null,Pool.recover("TouchData",preO)),this._clearTempArrs()}}}TouchManager.I=new TouchManager,TouchManager._oldArr=[],TouchManager._newArr=[],TouchManager._tEleArr=[];class MouseManager{constructor(){this.mouseX=0,this.mouseY=0,this.disableMouseEvent=!1,this.mouseDownTime=0,this.mouseMoveAccuracy=2,this._event=new Event,this._captureSp=null,this._captureChain=[],this._captureExlusiveMode=!1,this._hitCaputreSp=!1,this._point=new Point,this._rect=new Rectangle,this._lastMoveTimer=0,this._prePoint=new Point,this._touchIDs={},this._curTouchID=NaN,this._id=1}__init__(stage,canvas){this._stage=stage;var _this=this;canvas.oncontextmenu=function(e){if(MouseManager.enabled)return!1},canvas.addEventListener("mousedown",function(e){MouseManager.enabled&&(Browser.onIE||e.preventDefault(),_this.mouseDownTime=Browser.now(),_this.runEvent(e))}),canvas.addEventListener("mouseup",function(e){MouseManager.enabled&&(e.preventDefault(),_this.mouseDownTime=-Browser.now(),_this.runEvent(e))},!0),canvas.addEventListener("mousemove",function(e){if(MouseManager.enabled){e.preventDefault();var now=Browser.now();if(now-_this._lastMoveTimer<10)return;_this._lastMoveTimer=now,_this.runEvent(e)}},!0),canvas.addEventListener("mouseout",function(e){MouseManager.enabled&&_this.runEvent(e)}),canvas.addEventListener("mouseover",function(e){MouseManager.enabled&&_this.runEvent(e)}),canvas.addEventListener("touchstart",function(e){MouseManager.enabled&&(MouseManager._isFirstTouch||Input.isInputting||e.preventDefault(),_this.mouseDownTime=Browser.now(),_this.runEvent(e))}),canvas.addEventListener("touchend",function(e){MouseManager.enabled?(MouseManager._isFirstTouch||Input.isInputting||e.preventDefault(),MouseManager._isFirstTouch=!1,_this.mouseDownTime=-Browser.now(),_this.runEvent(e)):_this._curTouchID=NaN},!0),canvas.addEventListener("touchmove",function(e){MouseManager.enabled&&(e.preventDefault(),_this.runEvent(e))},!0),canvas.addEventListener("touchcancel",function(e){MouseManager.enabled?(e.preventDefault(),_this.runEvent(e)):_this._curTouchID=NaN},!0),canvas.addEventListener("mousewheel",function(e){MouseManager.enabled&&_this.runEvent(e)}),canvas.addEventListener("DOMMouseScroll",function(e){MouseManager.enabled&&_this.runEvent(e)})}initEvent(e,nativeEvent=null){var evt;this._event._stoped=!1,this._event.nativeEvent=nativeEvent||e,this._target=null,this._point.setTo(e.pageX||e.clientX,e.pageY||e.clientY),this._stage._canvasTransform&&(this._stage._canvasTransform.invertTransformPoint(this._point),this.mouseX=this._point.x,this.mouseY=this._point.y),this._event.touchId=e.identifier||0,this._tTouchID=this._event.touchId,(evt=TouchManager.I._event)._stoped=!1,evt.nativeEvent=this._event.nativeEvent,evt.touchId=this._event.touchId}checkMouseWheel(e){this._event.delta=e.wheelDelta?.025*e.wheelDelta:-e.detail;for(var _lastOvers=TouchManager.I.getLastOvers(),i=0,n=_lastOvers.length;i-1;i--){var child=sp._children[i];if(!child.destroyed&&child._mouseState>1&&child._visible&&this.check(child,mouseX,mouseY,callBack))return!0}for(i=sp._extUIChild.length-1;i>=0;i--){var c=sp._extUIChild[i];if(!c.destroyed&&c._mouseState>1&&c._visible&&this.check(c,mouseX,mouseY,callBack))return!0}}var isHit=!(!sp.hitTestPrior||sp.mouseThrough||this.disableMouseEvent)||this.hitTest(sp,mouseX,mouseY);return isHit?(this._target=sp,callBack.call(this,sp),this._target==this._hitCaputreSp&&(this._hitCaputreSp=!0)):callBack===this.onMouseUp&&sp===this._stage&&(this._target=this._stage,callBack.call(this,this._target)),isHit}hitTest(sp,mouseX,mouseY){var isHit=!1;sp.scrollRect&&(mouseX-=sp._style.scrollRect.x,mouseY-=sp._style.scrollRect.y);var hitArea=sp._style.hitArea;return hitArea&&hitArea._hit?hitArea.contains(mouseX,mouseY):((sp.width>0&&sp.height>0||sp.mouseThrough||hitArea)&&(isHit=sp.mouseThrough?sp.getGraphicBounds().contains(mouseX,mouseY):(hitArea||this._rect.setTo(0,0,sp.width,sp.height)).contains(mouseX,mouseY)),isHit)}_checkAllBaseUI(mousex,mousey,callback){var ret=this.handleExclusiveCapture(this.mouseX,this.mouseY,callback);return!!ret||(ret=this.check(this._stage,this.mouseX,this.mouseY,callback),this.handleCapture(this.mouseX,this.mouseY,callback)||ret)}check3DUI(mousex,mousey,callback){for(var uis=this._stage._3dUI,i=0,ret=!1;i1&&curui._visible&&(ret=ret||this.check(curui,this.mouseX,this.mouseY,callback))}return this._stage._curUIBase=this._stage,ret}handleExclusiveCapture(mousex,mousey,callback){if(this._captureExlusiveMode&&this._captureSp&&this._captureChain.length>0){var cursp;this._point.setTo(mousex,mousey);for(var i=0;i0){var cursp;this._point.setTo(mousex,mousey);for(var i=0;i=this.mouseMoveAccuracy&&(this._prePoint.x=evt.clientX,this._prePoint.y=evt.clientY,this.initEvent(evt),this._checkAllBaseUI(this.mouseX,this.mouseY,this.onMouseMove));break;case"touchstart":MouseManager._isTouchRespond=!0,this._isLeftMouse=!0;var touches=evt.changedTouches;for(i=0,n=touches.length;i0){for(var i=0,n=len-1;i<=n;i++){var handler=laters[i];this._map[handler.key]=null,null!==handler.method&&(handler.run(),handler.clear()),this._pool.push(handler),i===n&&(n=laters.length-1)}laters.length=0}}_getHandler(caller,method){var cid=caller?caller.$_GID||(caller.$_GID=ILaya.Utils.getGID()):0,mid=method.$_TID||(method.$_TID=1e5*ILaya.Timer._mid++);return this._map[cid+mid]}callLater(caller,method,args=null){if(null==this._getHandler(caller,method)){if(this._pool.length)var handler=this._pool.pop();else handler=new LaterHandler;handler.caller=caller,handler.method=method,handler.args=args;var cid=caller?caller.$_GID:0,mid=method.$_TID;handler.key=cid+mid,this._map[handler.key]=handler,this._laters.push(handler)}}runCallLater(caller,method){var handler=this._getHandler(caller,method);handler&&null!=handler.method&&(this._map[handler.key]=null,handler.run(),handler.clear())}}CallLater.I=new CallLater;class LaterHandler{clear(){this.caller=null,this.method=null,this.args=null}run(){var caller=this.caller;if(caller&&caller.destroyed)return this.clear();var method=this.method,args=this.args;null!=method&&(args?method.apply(caller,args):method.call(caller))}}class RunDriver{}RunDriver.createShaderCondition=function(conditionScript){var fn="(function() {return "+conditionScript+";})";return window.Laya._runScript(fn)},RunDriver.changeWebGLSize=function(w,h){WebGL.onStageResize(w,h)};class Stage extends Sprite{constructor(){super(),this.offset=new Point,this._frameRate="fast",this.designWidth=0,this.designHeight=0,this.canvasRotation=!1,this.canvasDegree=0,this.renderingEnabled=!0,this.screenAdaptationEnabled=!0,this._canvasTransform=new Matrix,this._screenMode="none",this._scaleMode="noscale",this._alignV="top",this._alignH="left",this._bgColor="black",this._mouseMoveTime=0,this._renderCount=0,this._safariOffsetY=0,this._frameStartTime=0,this._previousOrientation=Browser.window.orientation,this._wgColor=[0,0,0,1],this._scene3Ds=[],this._globalRepaintSet=!1,this._globalRepaintGet=!1,this._3dUI=[],this._curUIBase=null,this.useRetinalCanvas=!1,super.set_transform(this._createTransform()),this.mouseEnabled=!0,this.hitTestPrior=!0,this.autoSize=!1,this._setBit(Const.DISPLAYED_INSTAGE,!0),this._setBit(Const.ACTIVE_INHIERARCHY,!0),this._isFocused=!0,this._isVisibility=!0,this.useRetinalCanvas=Config.useRetinalCanvas;var window=Browser.window,_me=this;window.addEventListener("focus",function(){this._isFocused=!0,_me.event(Event.FOCUS),_me.event(Event.FOCUS_CHANGE)}),window.addEventListener("blur",function(){this._isFocused=!1,_me.event(Event.BLUR),_me.event(Event.FOCUS_CHANGE),_me._isInputting()&&(Input.inputElement.target.focus=!1)});var state="visibilityState",visibilityChange="visibilitychange",document=window.document;void 0!==document.hidden?(visibilityChange="visibilitychange",state="visibilityState"):void 0!==document.mozHidden?(visibilityChange="mozvisibilitychange",state="mozVisibilityState"):void 0!==document.msHidden?(visibilityChange="msvisibilitychange",state="msVisibilityState"):void 0!==document.webkitHidden&&(visibilityChange="webkitvisibilitychange",state="webkitVisibilityState"),window.document.addEventListener(visibilityChange,function(){"hidden"==Browser.document[state]?(this._isVisibility=!1,_me._isInputting()&&(Input.inputElement.target.focus=!1)):this._isVisibility=!0;this.renderingEnabled=this._isVisibility,_me.event(Event.VISIBILITY_CHANGE)}),window.addEventListener("resize",function(){var orientation=Browser.window.orientation;null!=orientation&&orientation!=this._previousOrientation&&_me._isInputting()&&(Input.inputElement.target.focus=!1),this._previousOrientation=orientation,_me._isInputting()||(Browser.onSafari&&(_me._safariOffsetY=(Browser.window.__innerHeight||Browser.document.body.clientHeight||Browser.document.documentElement.clientHeight)-Browser.window.innerHeight),_me._resetCanvas())}),window.addEventListener("orientationchange",function(e){_me._resetCanvas()}),this.on(Event.MOUSE_MOVE,this,this._onmouseMove),Browser.onMobile&&this.on(Event.MOUSE_DOWN,this,this._onmouseMove)}_isInputting(){return Browser.onMobile&&Input.isInputting}set width(value){this.designWidth=value,super.set_width(value),ILaya.systemTimer.callLater(this,this._changeCanvasSize)}get width(){return super.get_width()}set height(value){this.designHeight=value,super.set_height(value),ILaya.systemTimer.callLater(this,this._changeCanvasSize)}get height(){return super.get_height()}set transform(value){super.set_transform(value)}get transform(){return this._tfChanged&&this._adjustTransform(),this._transform=this._transform||this._createTransform()}get isFocused(){return this._isFocused}get isVisibility(){return this._isVisibility}_changeCanvasSize(){this.setScreenSize(Browser.clientWidth*Browser.pixelRatio,Browser.clientHeight*Browser.pixelRatio)}_resetCanvas(){this.screenAdaptationEnabled&&this._changeCanvasSize()}setScreenSize(screenWidth,screenHeight){var rotation=!1;if(this._screenMode!==Stage.SCREEN_NONE&&(rotation=(screenWidth/screenHeight<1?Stage.SCREEN_VERTICAL:Stage.SCREEN_HORIZONTAL)!==this._screenMode)){var temp=screenHeight;screenHeight=screenWidth,screenWidth=temp}this.canvasRotation=rotation;var canvas=Render._mainCanvas,canvasStyle=canvas.source.style,mat=this._canvasTransform.identity(),scaleMode=this._scaleMode,scaleX=screenWidth/this.designWidth,scaleY=screenHeight/this.designHeight,canvasWidth=this.useRetinalCanvas?screenWidth:this.designWidth,canvasHeight=this.useRetinalCanvas?screenHeight:this.designHeight,realWidth=screenWidth,realHeight=screenHeight,pixelRatio=Browser.pixelRatio;switch(this._width=this.designWidth,this._height=this.designHeight,scaleMode){case Stage.SCALE_NOSCALE:scaleX=scaleY=1,realWidth=this.designWidth,realHeight=this.designHeight;break;case Stage.SCALE_SHOWALL:scaleX=scaleY=Math.min(scaleX,scaleY),canvasWidth=realWidth=Math.round(this.designWidth*scaleX),canvasHeight=realHeight=Math.round(this.designHeight*scaleY);break;case Stage.SCALE_NOBORDER:scaleX=scaleY=Math.max(scaleX,scaleY),realWidth=Math.round(this.designWidth*scaleX),realHeight=Math.round(this.designHeight*scaleY);break;case Stage.SCALE_FULL:scaleX=scaleY=1,this._width=canvasWidth=screenWidth,this._height=canvasHeight=screenHeight;break;case Stage.SCALE_FIXED_WIDTH:scaleY=scaleX,this._height=canvasHeight=Math.round(screenHeight/scaleX);break;case Stage.SCALE_FIXED_HEIGHT:scaleX=scaleY,this._width=canvasWidth=Math.round(screenWidth/scaleY);break;case Stage.SCALE_FIXED_AUTO:screenWidth/screenHeight0?1:-1:value}get scaleMode(){return this._scaleMode}set scaleMode(value){this._scaleMode=value,ILaya.systemTimer.callLater(this,this._changeCanvasSize)}get alignH(){return this._alignH}set alignH(value){this._alignH=value,ILaya.systemTimer.callLater(this,this._changeCanvasSize)}get alignV(){return this._alignV}set alignV(value){this._alignV=value,ILaya.systemTimer.callLater(this,this._changeCanvasSize)}get bgColor(){return this._bgColor}set bgColor(value){this._bgColor=value,this._wgColor=value?ColorUtils.create(value).arrColor:null,Render.canvas.style.background=value||"none"}get mouseX(){return Math.round(MouseManager.instance.mouseX/this.clientScaleX)}get mouseY(){return Math.round(MouseManager.instance.mouseY/this.clientScaleY)}getMousePoint(){return Point.TEMP.setTo(this.mouseX,this.mouseY)}get clientScaleX(){return this._transform?this._transform.getScaleX():1}get clientScaleY(){return this._transform?this._transform.getScaleY():1}get screenMode(){return this._screenMode}set screenMode(value){this._screenMode=value}repaint(type=SpriteConst.REPAINT_CACHE){this._repaint|=type}parentRepaint(type=SpriteConst.REPAINT_CACHE){}_loop(){return this._globalRepaintGet=this._globalRepaintSet,this._globalRepaintSet=!1,this.render(Render._context,0,0),!0}getFrameTm(){return this._frameStartTime}_onmouseMove(e){this._mouseMoveTime=Browser.now()}getTimeFromFrameStart(){return Browser.now()-this._frameStartTime}set visible(value){this.visible!==value&&(super.set_visible(value),Render._mainCanvas.source.style.visibility=value?"visible":"hidden")}get visible(){return super.visible}render(context,x,y){if(window.conch)this.renderToNative(context,x,y);else{if(Stage._dbgSprite.graphics.clear(),this._frameRate===Stage.FRAME_SLEEP){var now=Browser.now();if(!(now-this._frameStartTime>=1e3))return;this._frameStartTime=now}else{if(!this._visible)return this._renderCount++,void(this._renderCount%5==0&&(CallLater.I._update(),Stat.loopCount++,RenderInfo.loopCount=Stat.loopCount,this._updateTimers()));this._frameStartTime=Browser.now(),RenderInfo.loopStTm=this._frameStartTime}this._renderCount++;var isFastMode=(this._frameRate===Stage.FRAME_MOUSE?this._frameStartTime-this._mouseMoveTime<2e3?Stage.FRAME_FAST:Stage.FRAME_SLOW:this._frameRate)!==Stage.FRAME_SLOW,isDoubleLoop=this._renderCount%2==0;if(Stat.renderSlow=!isFastMode,isFastMode||isDoubleLoop){if(CallLater.I._update(),Stat.loopCount++,RenderInfo.loopCount=Stat.loopCount,this.renderingEnabled){for(var i=0,n=this._scene3Ds.length;i=0||this._3dUI.push(uiroot)}remove3DUI(uibase){var uiroot=uibase.rootView,p=this._3dUI.indexOf(uiroot);return p>=0&&(this._3dUI.splice(p,1),!0)}}Stage.SCALE_NOSCALE="noscale",Stage.SCALE_EXACTFIT="exactfit",Stage.SCALE_SHOWALL="showall",Stage.SCALE_NOBORDER="noborder",Stage.SCALE_FULL="full",Stage.SCALE_FIXED_WIDTH="fixedwidth",Stage.SCALE_FIXED_HEIGHT="fixedheight",Stage.SCALE_FIXED_AUTO="fixedauto",Stage.ALIGN_LEFT="left",Stage.ALIGN_RIGHT="right",Stage.ALIGN_CENTER="center",Stage.ALIGN_TOP="top",Stage.ALIGN_MIDDLE="middle",Stage.ALIGN_BOTTOM="bottom",Stage.SCREEN_NONE="none",Stage.SCREEN_HORIZONTAL="horizontal",Stage.SCREEN_VERTICAL="vertical",Stage.FRAME_FAST="fast",Stage.FRAME_SLOW="slow",Stage.FRAME_MOUSE="mouse",Stage.FRAME_SLEEP="sleep",Stage._dbgSprite=new Sprite,Stage.clear=function(value){Context.set2DRenderConfig();var gl=LayaGL.instance;RenderState2D.worldScissorTest&&gl.disable(gl.SCISSOR_TEST);var ctx=Render.context,c=0==ctx._submits._length||Config.preserveDrawingBuffer?ColorUtils.create(value).arrColor:window.Laya.stage._wgColor;c?ctx.clearBG(c[0],c[1],c[2],c[3]):ctx.clearBG(0,0,0,0),RenderState2D.clear()},ClassUtils.regClass("laya.display.Stage",Stage),ClassUtils.regClass("Laya.Stage",Stage);class KeyBoardManager{static __init__(){KeyBoardManager._addEvent("keydown"),KeyBoardManager._addEvent("keypress"),KeyBoardManager._addEvent("keyup")}static _addEvent(type){ILaya.Browser.document.addEventListener(type,function(e){KeyBoardManager._dispatch(e,type)},!0)}static _dispatch(e,type){if(KeyBoardManager.enabled){KeyBoardManager._event._stoped=!1,KeyBoardManager._event.nativeEvent=e,KeyBoardManager._event.keyCode=e.keyCode||e.which||e.charCode,"keydown"===type?KeyBoardManager._pressKeys[KeyBoardManager._event.keyCode]=!0:"keyup"===type&&(KeyBoardManager._pressKeys[KeyBoardManager._event.keyCode]=null);for(var target=ILaya.stage.focus&&null!=ILaya.stage.focus.event&&ILaya.stage.focus.displayedInStage?ILaya.stage.focus:ILaya.stage,ct=target;ct;)ct.event(type,KeyBoardManager._event.setTo(type,ct,target)),ct=ct.parent}}static hasKeyDown(key){return KeyBoardManager._pressKeys[key]}}KeyBoardManager._pressKeys={},KeyBoardManager.enabled=!0,KeyBoardManager._event=new Event;class SoundChannel extends EventDispatcher{constructor(){super(...arguments),this.isStopped=!1}set volume(v){}get volume(){return 1}get position(){return 0}get duration(){return 0}play(){}stop(){this.completeHandler&&this.completeHandler.run()}pause(){}resume(){}__runComplete(handler){handler&&handler.run()}}class AudioSoundChannel extends SoundChannel{constructor(audio){super(),this._audio=null,this._onEnd=this.__onEnd.bind(this),this._resumePlay=this.__resumePlay.bind(this),audio.addEventListener("ended",this._onEnd),this._audio=audio}__onEnd(evt){if(1==this.loops)return this.completeHandler&&(ILaya.systemTimer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),void this.event(Event.COMPLETE);this.loops>0&&this.loops--,this.startTime=0,this.play()}__resumePlay(){if(this._audio&&this._audio.removeEventListener("canplay",this._resumePlay),!this.isStopped)try{this._audio.currentTime=this.startTime,Browser.container.appendChild(this._audio),this._audio.play()}catch(e){this.event(Event.ERROR)}}play(){this.isStopped=!1;try{this._audio.playbackRate=ILaya.SoundManager.playbackRate,this._audio.currentTime=this.startTime}catch(e){return void this._audio.addEventListener("canplay",this._resumePlay)}ILaya.SoundManager.addChannel(this),Browser.container.appendChild(this._audio),"play"in this._audio&&this._audio.play()}get position(){return this._audio?this._audio.currentTime:0}get duration(){return this._audio?this._audio.duration:0}stop(){super.stop(),this.isStopped=!0,ILaya.SoundManager.removeChannel(this),this.completeHandler=null,this._audio&&("pause"in this._audio&&ILaya.Render.isConchApp&&this._audio.stop(),this._audio.pause(),this._audio.removeEventListener("ended",this._onEnd),this._audio.removeEventListener("canplay",this._resumePlay),ILaya.Browser.onIE||this._audio!=ILaya.AudioSound._musicAudio&&ILaya.Pool.recover("audio:"+this.url,this._audio),Browser.removeElement(this._audio),this._audio=null,ILaya.SoundManager.autoReleaseSound&&ILaya.SoundManager.disposeSoundLater(this.url))}pause(){this.isStopped=!0,ILaya.SoundManager.removeChannel(this),"pause"in this._audio&&this._audio.pause(),ILaya.SoundManager.autoReleaseSound&&ILaya.SoundManager.disposeSoundLater(this.url)}resume(){this._audio&&(this.isStopped=!1,ILaya.SoundManager.addChannel(this),"play"in this._audio&&this._audio.play())}set volume(v){this._audio&&(this._audio.volume=v)}get volume(){return this._audio?this._audio.volume:1}}class AudioSound extends EventDispatcher{constructor(){super(...arguments),this.loaded=!1}dispose(){var ad=AudioSound._audioCache[this.url];Pool.clearBySign("audio:"+this.url),ad&&(Render.isConchApp||(ad.src=""),delete AudioSound._audioCache[this.url])}static _initMusicAudio(){AudioSound._musicAudio||(AudioSound._musicAudio||(AudioSound._musicAudio=Browser.createElement("audio")),Render.isConchApp||Browser.document.addEventListener("mousedown",AudioSound._makeMusicOK))}static _makeMusicOK(){Browser.document.removeEventListener("mousedown",AudioSound._makeMusicOK),AudioSound._musicAudio.src?AudioSound._musicAudio.play():(AudioSound._musicAudio.src="",AudioSound._musicAudio.load())}load(url){var ad;if(url=URL.formatURL(url),this.url=url,url==ILaya.SoundManager._bgMusic?(AudioSound._initMusicAudio(),(ad=AudioSound._musicAudio).src!=url&&(AudioSound._audioCache[ad.src]=null,ad=null)):ad=AudioSound._audioCache[url],ad&&ad.readyState>=2)this.event(Event.COMPLETE);else{ad||(url==ILaya.SoundManager._bgMusic?(AudioSound._initMusicAudio(),ad=AudioSound._musicAudio):ad=Browser.createElement("audio"),AudioSound._audioCache[url]=ad,ad.src=url),ad.addEventListener("canplaythrough",onLoaded),ad.addEventListener("error",onErr);var me=this;this.audio=ad,ad.load?ad.load():onErr()}function onLoaded(){offs(),me.loaded=!0,me.event(Event.COMPLETE)}function onErr(){ad.load=null,offs(),me.event(Event.ERROR)}function offs(){ad.removeEventListener("canplaythrough",onLoaded),ad.removeEventListener("error",onErr)}}play(startTime=0,loops=0){if(!this.url)return null;var ad,tAd;if(!(ad=this.url==ILaya.SoundManager._bgMusic?AudioSound._musicAudio:AudioSound._audioCache[this.url]))return null;tAd=Pool.getItem("audio:"+this.url),Render.isConchApp?tAd||((tAd=Browser.createElement("audio")).src=this.url):this.url==ILaya.SoundManager._bgMusic?(AudioSound._initMusicAudio(),(tAd=AudioSound._musicAudio).src=this.url):tAd=tAd||ad.cloneNode(!0);var channel=new AudioSoundChannel(tAd);return channel.url=this.url,channel.loops=loops,channel.startTime=startTime,channel.play(),ILaya.SoundManager.addChannel(channel),channel}get duration(){var ad;return(ad=AudioSound._audioCache[this.url])?ad.duration:0}}AudioSound._audioCache={};class WebAudioSoundChannel extends SoundChannel{constructor(){super(),this.bufferSource=null,this._currentTime=0,this._volume=1,this._startTime=0,this._pauseTime=0,this.context=ILaya.WebAudioSound.ctx,this._onPlayEnd=Utils.bind(this.__onPlayEnd,this),this.context.createGain?this.gain=this.context.createGain():this.gain=this.context.createGainNode()}play(){if(ILaya.SoundManager.addChannel(this),this.isStopped=!1,this._clearBufferSource(),this.audioBuffer){if(this.startTime>=this.duration)return stop();var context=this.context,gain=this.gain,bufferSource=context.createBufferSource();this.bufferSource=bufferSource,bufferSource.buffer=this.audioBuffer,bufferSource.connect(gain),gain&&gain.disconnect(),gain.connect(context.destination),bufferSource.onended=this._onPlayEnd,this._startTime=Browser.now(),this.gain.gain.setTargetAtTime?this.gain.gain.setTargetAtTime(this._volume,this.context.currentTime,WebAudioSoundChannel.SetTargetDelay):this.gain.gain.value=this._volume,0==this.loops&&(bufferSource.loop=!0),bufferSource.playbackRate.setTargetAtTime?bufferSource.playbackRate.setTargetAtTime(ILaya.SoundManager.playbackRate,this.context.currentTime,WebAudioSoundChannel.SetTargetDelay):bufferSource.playbackRate.value=ILaya.SoundManager.playbackRate,bufferSource.start(0,this.startTime),this._currentTime=0}}__onPlayEnd(){if(1==this.loops)return this.completeHandler&&(ILaya.timer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),void this.event(Event.COMPLETE);this.loops>0&&this.loops--,this.startTime=0,this.play()}get position(){return this.bufferSource?(Browser.now()-this._startTime)/1e3+this.startTime:0}get duration(){return this.audioBuffer?this.audioBuffer.duration:0}_clearBufferSource(){if(this.bufferSource){var sourceNode=this.bufferSource;sourceNode.stop?sourceNode.stop(0):sourceNode.noteOff(0),sourceNode.disconnect(0),sourceNode.onended=null,WebAudioSoundChannel._tryCleanFailed||this._tryClearBuffer(sourceNode),this.bufferSource=null}}_tryClearBuffer(sourceNode){if(Browser.onMac)try{sourceNode.buffer=ILaya.WebAudioSound._miniBuffer}catch(e){WebAudioSoundChannel._tryCleanFailed=!0}else try{sourceNode.buffer=null}catch(e){WebAudioSoundChannel._tryCleanFailed=!0}}stop(){super.stop(),this._clearBufferSource(),this.audioBuffer=null,this.gain&&this.gain.disconnect(),this.isStopped=!0,ILaya.SoundManager.removeChannel(this),this.completeHandler=null,ILaya.SoundManager.autoReleaseSound&&ILaya.SoundManager.disposeSoundLater(this.url)}pause(){this.isStopped||(this._pauseTime=this.position),this._clearBufferSource(),this.gain&&this.gain.disconnect(),this.isStopped=!0,ILaya.SoundManager.removeChannel(this),ILaya.SoundManager.autoReleaseSound&&ILaya.SoundManager.disposeSoundLater(this.url)}resume(){this.startTime=this._pauseTime,this.play()}set volume(v){this._volume=v,this.isStopped||(this.gain.gain.setTargetAtTime?this.gain.gain.setTargetAtTime(v,this.context.currentTime,WebAudioSoundChannel.SetTargetDelay):this.gain.gain.value=v)}get volume(){return this._volume}}WebAudioSoundChannel._tryCleanFailed=!1,WebAudioSoundChannel.SetTargetDelay=.001;class WebAudioSound extends EventDispatcher{constructor(){super(...arguments),this.loaded=!1,this._disposed=!1}static decode(){WebAudioSound.buffs.length<=0||WebAudioSound.isDecoding||(WebAudioSound.isDecoding=!0,WebAudioSound.tInfo=WebAudioSound.buffs.shift(),WebAudioSound.ctx.decodeAudioData(WebAudioSound.tInfo.buffer,WebAudioSound._done,WebAudioSound._fail))}static _done(audioBuffer){WebAudioSound.e.event("loaded:"+WebAudioSound.tInfo.url,audioBuffer),WebAudioSound.isDecoding=!1,WebAudioSound.decode()}static _fail(){WebAudioSound.e.event("err:"+WebAudioSound.tInfo.url,null),WebAudioSound.isDecoding=!1,WebAudioSound.decode()}static _playEmptySound(){if(null!=WebAudioSound.ctx){var source=WebAudioSound.ctx.createBufferSource();source.buffer=WebAudioSound._miniBuffer,source.connect(WebAudioSound.ctx.destination),source.start(0,0,0)}}static _unlock(){WebAudioSound._unlocked||(WebAudioSound._playEmptySound(),"running"==WebAudioSound.ctx.state&&(window.document.removeEventListener("mousedown",WebAudioSound._unlock,!0),window.document.removeEventListener("touchend",WebAudioSound._unlock,!0),window.document.removeEventListener("touchstart",WebAudioSound._unlock,!0),WebAudioSound._unlocked=!0))}static initWebAudio(){"running"!=WebAudioSound.ctx.state&&(WebAudioSound._unlock(),window.document.addEventListener("mousedown",WebAudioSound._unlock,!0),window.document.addEventListener("touchend",WebAudioSound._unlock,!0),window.document.addEventListener("touchstart",WebAudioSound._unlock,!0))}load(url){var me=this;if(url=URL.formatURL(url),this.url=url,this.audioBuffer=WebAudioSound._dataCache[url],this.audioBuffer)this._loaded(this.audioBuffer);else if(WebAudioSound.e.on("loaded:"+url,this,this._loaded),WebAudioSound.e.on("err:"+url,this,this._err),!WebAudioSound.__loadingSound[url]){WebAudioSound.__loadingSound[url]=!0;var request=new XMLHttpRequest;request.open("GET",url,!0),request.responseType="arraybuffer",request.onload=function(){me._disposed?me._removeLoadEvents():(me.data=request.response,WebAudioSound.buffs.push({buffer:me.data,url:me.url}),WebAudioSound.decode())},request.onerror=function(e){me._err()},request.send()}}_err(){this._removeLoadEvents(),WebAudioSound.__loadingSound[this.url]=!1,this.event(Event.ERROR)}_loaded(audioBuffer){this._removeLoadEvents(),this._disposed||(this.audioBuffer=audioBuffer,WebAudioSound._dataCache[this.url]=this.audioBuffer,this.loaded=!0,this.event(Event.COMPLETE))}_removeLoadEvents(){WebAudioSound.e.off("loaded:"+this.url,this,this._loaded),WebAudioSound.e.off("err:"+this.url,this,this._err)}__playAfterLoaded(){if(this.__toPlays){var i,len,toPlays,tParams;for(len=(toPlays=this.__toPlays).length,i=0;i=0||SoundManager._channels.push(channel)}static removeChannel(channel){var i;for(i=SoundManager._channels.length-1;i>=0;i--)SoundManager._channels[i]==channel&&SoundManager._channels.splice(i,1)}static disposeSoundLater(url){SoundManager._lastSoundUsedTimeDic[url]=ILaya.Browser.now(),SoundManager._isCheckingDispose||(SoundManager._isCheckingDispose=!0,ILaya.timer.loop(5e3,null,SoundManager._checkDisposeSound))}static _checkDisposeSound(){var key,tTime=ILaya.Browser.now(),hasCheck=!1;for(key in SoundManager._lastSoundUsedTimeDic)tTime-SoundManager._lastSoundUsedTimeDic[key]>3e4?(delete SoundManager._lastSoundUsedTimeDic[key],SoundManager.disposeSoundIfNotUsed(key)):hasCheck=!0;hasCheck||(SoundManager._isCheckingDispose=!1,ILaya.timer.clear(null,SoundManager._checkDisposeSound))}static disposeSoundIfNotUsed(url){var i;for(i=SoundManager._channels.length-1;i>=0;i--)if(SoundManager._channels[i].url==url)return;SoundManager.destroySound(url)}static set autoStopMusic(v){ILaya.stage.off(Event.BLUR,null,SoundManager._stageOnBlur),ILaya.stage.off(Event.FOCUS,null,SoundManager._stageOnFocus),ILaya.stage.off(Event.VISIBILITY_CHANGE,null,SoundManager._visibilityChange),SoundManager._autoStopMusic=v,v&&(ILaya.stage.on(Event.BLUR,null,SoundManager._stageOnBlur),ILaya.stage.on(Event.FOCUS,null,SoundManager._stageOnFocus),ILaya.stage.on(Event.VISIBILITY_CHANGE,null,SoundManager._visibilityChange))}static get autoStopMusic(){return SoundManager._autoStopMusic}static _visibilityChange(){ILaya.stage.isVisibility?SoundManager._stageOnFocus():SoundManager._stageOnBlur()}static _stageOnBlur(){SoundManager._isActive=!1,SoundManager._musicChannel&&(SoundManager._musicChannel.isStopped||(SoundManager._blurPaused=!0,SoundManager._musicChannel.pause())),SoundManager.stopAllSound(),ILaya.stage.once(Event.MOUSE_DOWN,null,SoundManager._stageOnFocus)}static _recoverWebAudio(){WebAudioSound.ctx&&"running"!=WebAudioSound.ctx.state&&WebAudioSound.ctx.resume&&WebAudioSound.ctx.resume()}static _stageOnFocus(){SoundManager._isActive=!0,SoundManager._recoverWebAudio(),ILaya.stage.off(Event.MOUSE_DOWN,null,SoundManager._stageOnFocus),SoundManager._blurPaused&&SoundManager._musicChannel&&SoundManager._musicChannel.isStopped&&(SoundManager._blurPaused=!1,SoundManager._musicChannel.resume())}static set muted(value){value!=SoundManager._muted&&(value&&SoundManager.stopAllSound(),SoundManager.musicMuted=value,SoundManager._muted=value)}static get muted(){return SoundManager._muted}static set soundMuted(value){SoundManager._soundMuted=value}static get soundMuted(){return SoundManager._soundMuted}static set musicMuted(value){value!=SoundManager._musicMuted&&(value?(SoundManager._bgMusic&&SoundManager._musicChannel&&!SoundManager._musicChannel.isStopped?ILaya.Render.isConchApp?SoundManager._musicChannel._audio&&(SoundManager._musicChannel._audio.muted=!0):SoundManager._musicChannel.pause():SoundManager._musicChannel=null,SoundManager._musicMuted=value):(SoundManager._musicMuted=value,SoundManager._bgMusic&&SoundManager._musicChannel&&(ILaya.Render.isConchApp?SoundManager._musicChannel._audio&&(SoundManager._musicChannel._audio.muted=!1):SoundManager._musicChannel.resume())))}static get musicMuted(){return SoundManager._musicMuted}static get useAudioMusic(){return SoundManager._useAudioMusic}static set useAudioMusic(value){SoundManager._useAudioMusic=value,SoundManager._musicClass=value?AudioSound:null}static playSound(url,loops=1,complete=null,soundClass=null,startTime=0){if(!SoundManager._isActive||!url)return null;if(SoundManager._muted)return null;if(SoundManager._recoverWebAudio(),(url=URL.formatURL(url))==SoundManager._bgMusic){if(SoundManager._musicMuted)return null}else{if(ILaya.Render.isConchApp){var ext=Utils.getFileExtension(url);if("wav"!=ext&&"ogg"!=ext)return alert("The sound only supports wav or ogg format,for optimal performance reason,please refer to the official website document."),null}if(SoundManager._soundMuted)return null}var tSound,channel;return ILaya.Browser.onBDMiniGame||ILaya.Browser.onMiniGame||ILaya.Browser.onKGMiniGame||ILaya.Browser.onQGMiniGame||ILaya.Browser.onVVMiniGame||ILaya.Browser.onAlipayMiniGame||ILaya.Browser.onQQMiniGame||(tSound=ILaya.loader.getRes(url)),soundClass||(soundClass=SoundManager._soundClass),tSound||((tSound=new soundClass).load(url),ILaya.Browser.onBDMiniGame||ILaya.Browser.onMiniGame||ILaya.Browser.onKGMiniGame||ILaya.Browser.onQGMiniGame||ILaya.Browser.onVVMiniGame||ILaya.Browser.onAlipayMiniGame||ILaya.Browser.onQQMiniGame||ILaya.Loader.cacheRes(url,tSound)),(channel=tSound.play(startTime,loops))?(channel.url=url,channel.volume=url==SoundManager._bgMusic?SoundManager.musicVolume:SoundManager.soundVolume,channel.completeHandler=complete,channel):null}static destroySound(url){var tSound=ILaya.loader.getRes(url);tSound&&(ILaya.Loader.clearRes(url),tSound.dispose())}static playMusic(url,loops=0,complete=null,startTime=0){return url=URL.formatURL(url),SoundManager._bgMusic=url,SoundManager._musicChannel&&SoundManager._musicChannel.stop(),SoundManager._musicChannel=SoundManager.playSound(url,loops,complete,SoundManager._musicClass,startTime)}static stopSound(url){var i,channel;for(url=URL.formatURL(url),i=SoundManager._channels.length-1;i>=0;i--)(channel=SoundManager._channels[i]).url==url&&channel.stop()}static stopAll(){var i;for(SoundManager._bgMusic=null,i=SoundManager._channels.length-1;i>=0;i--)SoundManager._channels[i].stop()}static stopAllSound(){var i,channel;for(i=SoundManager._channels.length-1;i>=0;i--)(channel=SoundManager._channels[i]).url!=SoundManager._bgMusic&&channel.stop()}static stopMusic(){SoundManager._musicChannel&&SoundManager._musicChannel.stop(),SoundManager._bgMusic=null}static setSoundVolume(volume,url=null){var i,channel;if(url)url=URL.formatURL(url),SoundManager._setVolume(url,volume);else for(SoundManager.soundVolume=volume,i=SoundManager._channels.length-1;i>=0;i--)(channel=SoundManager._channels[i]).url!=SoundManager._bgMusic&&(channel.volume=volume)}static setMusicVolume(volume){SoundManager.musicVolume=volume,SoundManager._setVolume(SoundManager._bgMusic,volume)}static _setVolume(url,volume){var i,channel;for(url=URL.formatURL(url),i=SoundManager._channels.length-1;i>=0;i--)(channel=SoundManager._channels[i]).url==url&&(channel.volume=volume)}}SoundManager.musicVolume=1,SoundManager.soundVolume=1,SoundManager.playbackRate=1,SoundManager._useAudioMusic=!0,SoundManager._muted=!1,SoundManager._soundMuted=!1,SoundManager._musicMuted=!1,SoundManager._bgMusic=null,SoundManager._musicChannel=null,SoundManager._channels=[],SoundManager._blurPaused=!1,SoundManager._isActive=!0,SoundManager._lastSoundUsedTimeDic={},SoundManager._isCheckingDispose=!1,SoundManager.autoReleaseSound=!0;class HttpRequest extends EventDispatcher{constructor(){super(...arguments),this._http=new XMLHttpRequest}send(url,data=null,method="get",responseType="text",headers=null){this._responseType=responseType,this._data=null,(Browser.onVVMiniGame||Browser.onQGMiniGame||Browser.onQQMiniGame)&&(url=encodeURI(url)),this._url=url;var _this=this,http=this._http;if(url=URL.getAdptedFilePath(url),http.open(method,url,!0),headers)for(var i=0;ivalue&&this._resizeBuffer(this._allocated_=value),this._length=value}get length(){return this._length}_resizeBuffer(len){try{var newByteView=new Uint8Array(len);null!=this._u8d_&&(this._u8d_.length<=len?newByteView.set(this._u8d_):newByteView.set(this._u8d_.subarray(0,len))),this._u8d_=newByteView,this._d_=new DataView(newByteView.buffer)}catch(err){throw"Invalid typed array length:"+len}}getString(){return this.readString()}readString(){return this._rUTF(this.getUint16())}getFloat32Array(start,len){return this.readFloat32Array(start,len)}readFloat32Array(start,len){var end=start+len;end=end>this._length?this._length:end;var v=new Float32Array(this._d_.buffer.slice(start,end));return this._pos_=end,v}getUint8Array(start,len){return this.readUint8Array(start,len)}readUint8Array(start,len){var end=start+len;end=end>this._length?this._length:end;var v=new Uint8Array(this._d_.buffer.slice(start,end));return this._pos_=end,v}getInt16Array(start,len){return this.readInt16Array(start,len)}readInt16Array(start,len){var end=start+len;end=end>this._length?this._length:end;var v=new Int16Array(this._d_.buffer.slice(start,end));return this._pos_=end,v}getFloat32(){return this.readFloat32()}readFloat32(){if(this._pos_+4>this._length)throw"getFloat32 error - Out of bounds";var v=this._d_.getFloat32(this._pos_,this._xd_);return this._pos_+=4,v}getFloat64(){return this.readFloat64()}readFloat64(){if(this._pos_+8>this._length)throw"getFloat64 error - Out of bounds";var v=this._d_.getFloat64(this._pos_,this._xd_);return this._pos_+=8,v}writeFloat32(value){this._ensureWrite(this._pos_+4),this._d_.setFloat32(this._pos_,value,this._xd_),this._pos_+=4}writeFloat64(value){this._ensureWrite(this._pos_+8),this._d_.setFloat64(this._pos_,value,this._xd_),this._pos_+=8}getInt32(){return this.readInt32()}readInt32(){if(this._pos_+4>this._length)throw"getInt32 error - Out of bounds";var float=this._d_.getInt32(this._pos_,this._xd_);return this._pos_+=4,float}getUint32(){return this.readUint32()}readUint32(){if(this._pos_+4>this._length)throw"getUint32 error - Out of bounds";var v=this._d_.getUint32(this._pos_,this._xd_);return this._pos_+=4,v}writeInt32(value){this._ensureWrite(this._pos_+4),this._d_.setInt32(this._pos_,value,this._xd_),this._pos_+=4}writeUint32(value){this._ensureWrite(this._pos_+4),this._d_.setUint32(this._pos_,value,this._xd_),this._pos_+=4}getInt16(){return this.readInt16()}readInt16(){if(this._pos_+2>this._length)throw"getInt16 error - Out of bounds";var us=this._d_.getInt16(this._pos_,this._xd_);return this._pos_+=2,us}getUint16(){return this.readUint16()}readUint16(){if(this._pos_+2>this._length)throw"getUint16 error - Out of bounds";var us=this._d_.getUint16(this._pos_,this._xd_);return this._pos_+=2,us}writeUint16(value){this._ensureWrite(this._pos_+2),this._d_.setUint16(this._pos_,value,this._xd_),this._pos_+=2}writeInt16(value){this._ensureWrite(this._pos_+2),this._d_.setInt16(this._pos_,value,this._xd_),this._pos_+=2}getUint8(){return this.readUint8()}readUint8(){if(this._pos_+1>this._length)throw"getUint8 error - Out of bounds";return this._u8d_[this._pos_++]}writeUint8(value){this._ensureWrite(this._pos_+1),this._d_.setUint8(this._pos_,value),this._pos_++}_getUInt8(pos){return this._readUInt8(pos)}_readUInt8(pos){return this._d_.getUint8(pos)}_getUint16(pos){return this._readUint16(pos)}_readUint16(pos){return this._d_.getUint16(pos,this._xd_)}_getMatrix(){return this._readMatrix()}_readMatrix(){return new Matrix(this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32())}_rUTF(len){var c,c2,c3,max=this._pos_+len,f=String.fromCharCode,u=this._u8d_,strs=[],n=0;for(strs.length=1e3;this._pos_0;)if((c=u[this._pos_])<128)v+=f(c),this._pos_++,len--;else for(ulen=c-128,this._pos_++,len-=ulen;ulen>0;)c=u[this._pos_++],v+=f(u[this._pos_++]<<8|c),ulen--;return v}get pos(){return this._pos_}set pos(value){this._pos_=value}get bytesAvailable(){return this._length-this._pos_}clear(){this._pos_=0,this.length=0}__getBuffer(){return this._d_.buffer}writeUTFBytes(value){for(var i=0,sz=(value+="").length;i>6,128|63&c],this._pos_),this._pos_+=2):c<=65535?(this._ensureWrite(this._pos_+3),this._u8d_.set([224|c>>12,128|c>>6&63,128|63&c],this._pos_),this._pos_+=3):(this._ensureWrite(this._pos_+4),this._u8d_.set([240|c>>18,128|c>>12&63,128|c>>6&63,128|63&c],this._pos_),this._pos_+=4)}}writeUTFString(value){var tPos=this.pos;this.writeUint16(1),this.writeUTFBytes(value);var dPos=this.pos-tPos-2;this._d_.setUint16(tPos,dPos,this._xd_)}readUTFString(){return this.readUTFBytes(this.getUint16())}getUTFString(){return this.readUTFString()}readUTFBytes(len=-1){if(0===len)return"";var lastBytes=this.bytesAvailable;if(len>lastBytes)throw"readUTFBytes error - Out of bounds";return len=len>0?len:lastBytes,this._rUTF(len)}getUTFBytes(len=-1){return this.readUTFBytes(len)}writeByte(value){this._ensureWrite(this._pos_+1),this._d_.setInt8(this._pos_,value),this._pos_+=1}readByte(){if(this._pos_+1>this._length)throw"readByte error - Out of bounds";return this._d_.getInt8(this._pos_++)}getByte(){return this.readByte()}_ensureWrite(lengthToEnsure){this._length=0?"/":"\\",idx=this._url.lastIndexOf(split),folderPath=idx>=0?this._url.substr(0,idx+1):"";Browser.onAndroid&&data.meta.compressTextureAndroid&&(changeType=".ktx"),Browser.onIOS&&data.meta.compressTextureIOS&&(changeType=".pvr");for(var i=0,len=toloadPics.length;i0)return this.event(Event.PROGRESS,.3+1/this._data.toLoads.length*.6),this._loadResourceFilter(Loader.IMAGE,this._data.toLoads.pop());var frames=this._data.frames,cleanUrl=this._url.split("?")[0],directory=this._data.meta&&this._data.meta.prefix?this._data.meta.prefix:cleanUrl.substring(0,cleanUrl.lastIndexOf("."))+"/",pics=this._data.pics,atlasURL=URL.formatURL(this._url),map=Loader.atlasMap[atlasURL]||(Loader.atlasMap[atlasURL]=[]);map.dir=directory;var scaleRate=1;if(this._data.meta&&this._data.meta.scale&&1!=this._data.meta.scale)for(var name in scaleRate=parseFloat(this._data.meta.scale),frames){var tTexture,obj=frames[name],tPic=pics[obj.frame.idx?obj.frame.idx:0],url=URL.formatURL(directory+name);tPic.scaleRate=scaleRate,tTexture=Texture._create(tPic,obj.frame.x,obj.frame.y,obj.frame.w,obj.frame.h,obj.spriteSourceSize.x,obj.spriteSourceSize.y,obj.sourceSize.w,obj.sourceSize.h,Loader.getRes(url)),Loader.cacheRes(url,tTexture),tTexture.url=url,map.push(url)}else for(name in frames)tPic=pics[(obj=frames[name]).frame.idx?obj.frame.idx:0],url=URL.formatURL(directory+name),tTexture=Texture._create(tPic,obj.frame.x,obj.frame.y,obj.frame.w,obj.frame.h,obj.spriteSourceSize.x,obj.spriteSourceSize.y,obj.sourceSize.w,obj.sourceSize.h,Loader.getRes(url)),Loader.cacheRes(url,tTexture),tTexture.url=url,map.push(url);delete this._data.pics,this.complete(this._data)}else if(type===Loader.FONT){if(!data._source)return this._data=data,this.event(Event.PROGRESS,.5),this._loadImage(this._url.replace(".fnt",".png"));var bFont=new BitmapFont;bFont.parseFont(this._data,new Texture(data));var tArr=this._url.split(".fnt")[0].split("/"),fontName=tArr[tArr.length-1];Text.registerBitmapFont(fontName,bFont),this._data=bFont,this.complete(this._data)}else if(type===Loader.PREFAB){var prefab=new Prefab;prefab.json=data,this.complete(prefab)}else this.complete(data)}parsePLFData(plfData){var type,filePath,fileDic;for(type in plfData)switch(fileDic=plfData[type],type){case"json":case"text":for(filePath in fileDic)Loader.preLoadedMap[URL.formatURL(filePath)]=fileDic[filePath];break;default:for(filePath in fileDic)Loader.preLoadedMap[URL.formatURL(filePath)]=fileDic[filePath]}}parsePLFBData(plfData){var byte,i,len;for(len=(byte=new Byte(plfData)).getInt32(),i=0;iLoader.maxTimeOut)return console.warn("loader callback cost a long time:"+(Browser.now()-startTimer)+" url="+Loader._loaders[Loader._startIndex-1].url),void ILaya.systemTimer.frameOnce(1,null,Loader.checkNext);Loader._loaders.length=0,Loader._startIndex=0,Loader._isWorking=!1}endLoad(content=null){content&&(this._data=content),this._cache&&Loader.cacheRes(this._url,this._data),this.event(Event.PROGRESS,1),this.event(Event.COMPLETE,this.data instanceof Array?[this.data]:this.data)}get url(){return this._url}get type(){return this._type}get cache(){return this._cache}get data(){return this._data}static clearRes(url){url=URL.formatURL(url);var arr=Loader.getAtlas(url);if(arr){for(var i=0,n=arr.length;i0)arr.forEach(function(t){var tex=Loader.getRes(t);tex instanceof Texture&&tex.disposeBitmap()});else{var t=Loader.getRes(url);t instanceof Texture&&t.disposeBitmap()}}static getRes(url){return Loader.loadedMap[URL.formatURL(url)]}static getAtlas(url){return Loader.atlasMap[URL.formatURL(url)]}static cacheRes(url,data){url=URL.formatURL(url),null!=Loader.loadedMap[url]||(Loader.loadedMap[url]=data)}static setGroup(url,group){Loader.groupMap[group]||(Loader.groupMap[group]=[]),Loader.groupMap[group].push(url)}static clearResByGroup(group){if(Loader.groupMap[group]){var i,arr=Loader.groupMap[group],len=arr.length;for(i=0;i=this.maxLoader)){for(var i=0;i0;){var info=infos.shift();if(info)return this._doLoad(info)}this._loaderCount||this.event(Event.COMPLETE)}}_doLoad(resInfo){this._loaderCount++;var loader=this._loaders.length?this._loaders.pop():new Loader;loader.on(Event.COMPLETE,null,onLoaded),loader.on(Event.PROGRESS,null,function(num){resInfo.event(Event.PROGRESS,num)}),loader.on(Event.ERROR,null,function(msg){onLoaded(null)});var _me=this;function onLoaded(data=null){loader.offAll(),loader._data=null,loader._customParse=!1,_me._loaders.push(loader),_me._endLoad(resInfo,data instanceof Array?[data]:data),_me._loaderCount--,_me._next()}loader._constructParams=resInfo.createConstructParams,loader._propertyParams=resInfo.createPropertyParams,loader._createCache=resInfo.createCache,loader.load(resInfo.url,resInfo.type,resInfo.cache,resInfo.group,resInfo.ignoreCache,resInfo.useWorkerLoader)}_endLoad(resInfo,content){var url=resInfo.url;if(null==content){var errorCount=this._failRes[url]||0;if(errorCount-1;j--){var info=infos[j];info&&(info.offAll(),this._infoPool.push(info))}infos.length=0}this._loaderCount=0,LoaderManager._resMap={}}cancelLoadByUrls(urls){if(urls)for(var i=0,n=urls.length;i-1;j--){var info=infos[j];info&&info.url===url&&(infos[j]=null,info.offAll(),this._infoPool.push(info))}LoaderManager._resMap[url]&&delete LoaderManager._resMap[url]}_loadAssets(arr,complete=null,progress=null,type=null,priority=1,cache=!0,group=null){for(var itemCount=arr.length,loadedCount=0,totalSize=0,items=[],success=!0,i=0;i0&&a0&&a0&&a=this._duration)return this.complete();for(var ratio=usedTimer>0?this._ease(usedTimer,0,1,this._duration):0,props=this._props,i=0,n=props.length;i=this.repeat?(this.clear(),handler&&handler.run()):this.restart()}}pause(){var dTime;ILaya.timer.clear(this,this._beginLoop),ILaya.timer.clear(this,this._doEase),ILaya.timer.clear(this,this.firstStart),(dTime=Browser.now()-this._startTimer-this._delay)<0&&(this._usedTimer=dTime)}setStartTime(startTime){this._startTimer=startTime}static clearAll(target){if(target&&target.$_GID){var tweens=Tween.tweenMap[target.$_GID];if(tweens){for(var i=0,n=tweens.length;i=this._duration||(this._startTimer=Browser.now()-this._usedTimer-this._delay,this._delayParam?this._usedTimer<0?ILaya.timer.once(-this._usedTimer,this,this.firstStart,this._delayParam):this.firstStart.apply(this,this._delayParam):this._beginLoop())}static easeNone(t,b,c,d){return c*t/d+b}}Tween.tweenMap=[];class Dragging{constructor(){this.ratio=.92,this.maxOffset=60,this._dragging=!1,this._clickOnly=!0}start(target,area,hasInertia,elasticDistance,elasticBackTime,data,disableMouseEvent,ratio=.92){this.clearTimer(),this.target=target,this.area=area,this.hasInertia=hasInertia,this.elasticDistance=area?elasticDistance:0,this.elasticBackTime=elasticBackTime,this.data=data,this._disableMouseEvent=disableMouseEvent,this.ratio=ratio,this._parent=target.parent,this._clickOnly=!0,this._dragging=!0,this._elasticRateX=this._elasticRateY=1,this._lastX=this._parent.mouseX,this._lastY=this._parent.mouseY,ILaya.stage.on(Event.MOUSE_UP,this,this.onStageMouseUp),ILaya.stage.on(Event.MOUSE_OUT,this,this.onStageMouseUp),ILaya.systemTimer.frameLoop(1,this,this.loop)}clearTimer(){ILaya.systemTimer.clear(this,this.loop),ILaya.systemTimer.clear(this,this.tweenMove),this._tween&&(this._tween.recover(),this._tween=null)}stop(){this._dragging&&(MouseManager.instance.disableMouseEvent=!1,ILaya.stage.off(Event.MOUSE_UP,this,this.onStageMouseUp),ILaya.stage.off(Event.MOUSE_OUT,this,this.onStageMouseUp),this._dragging=!1,this.target&&this.area&&this.backToArea(),this.clear())}loop(){var point=this._parent.getMousePoint(),mouseX=point.x,mouseY=point.y,offsetX=mouseX-this._lastX,offsetY=mouseY-this._lastY;if(this._clickOnly){if(!(Math.abs(offsetX*ILaya.stage._canvasTransform.getScaleX())>1||Math.abs(offsetY*ILaya.stage._canvasTransform.getScaleY())>1))return;this._clickOnly=!1,this._offsets||(this._offsets=[]),this._offsets.length=0,this.target.event(Event.DRAG_START,this.data),MouseManager.instance.disableMouseEvent=this._disableMouseEvent}else this._offsets.push(offsetX,offsetY);0===offsetX&&0===offsetY||(this._lastX=mouseX,this._lastY=mouseY,this.target.x+=offsetX*this._elasticRateX,this.target.y+=offsetY*this._elasticRateY,this.area&&this.checkArea(),this.target.event(Event.DRAG_MOVE,this.data))}checkArea(){if(this.elasticDistance<=0)this.backToArea();else{if(this.target._xthis.area.x+this.area.width?this.target._x-this.area.x-this.area.width:0;if(this._elasticRateX=Math.max(0,1-offsetX/this.elasticDistance),this.target._ythis.area.y+this.area.height?this.target._y-this.area.y-this.area.height:0;this._elasticRateY=Math.max(0,1-offsetY/this.elasticDistance)}}backToArea(){this.target.x=Math.min(Math.max(this.target._x,this.area.x),this.area.x+this.area.width),this.target.y=Math.min(Math.max(this.target._y,this.area.y),this.area.y+this.area.height)}onStageMouseUp(e){if(MouseManager.instance.disableMouseEvent=!1,ILaya.stage.off(Event.MOUSE_UP,this,this.onStageMouseUp),ILaya.stage.off(Event.MOUSE_OUT,this,this.onStageMouseUp),ILaya.systemTimer.clear(this,this.loop),!this._clickOnly&&this.target)if(this.hasInertia){this._offsets.length<1&&this._offsets.push(this._parent.mouseX-this._lastX,this._parent.mouseY-this._lastY),this._offsetX=this._offsetY=0;for(var len=this._offsets.length,n=Math.min(len,6),m=this._offsets.length-n,i=len-1;i>m;i--)this._offsetY+=this._offsets[i--],this._offsetX+=this._offsets[i];this._offsetX=this._offsetX/n*2,this._offsetY=this._offsetY/n*2,Math.abs(this._offsetX)>this.maxOffset&&(this._offsetX=this._offsetX>0?this.maxOffset:-this.maxOffset),Math.abs(this._offsetY)>this.maxOffset&&(this._offsetY=this._offsetY>0?this.maxOffset:-this.maxOffset),ILaya.systemTimer.frameLoop(1,this,this.tweenMove)}else this.elasticDistance>0?this.checkElastic():this.clear()}checkElastic(){var tx=NaN,ty=NaN;if(this.target.xthis.area.x+this.area.width&&(tx=this.area.x+this.area.width),this.target.ythis.area.y+this.area.height&&(ty=this.area.y+this.area.height),isNaN(tx)&&isNaN(ty))this.clear();else{var obj={};isNaN(tx)||(obj.x=tx),isNaN(ty)||(obj.y=ty),this._tween=Tween.to(this.target,obj,this.elasticBackTime,Ease.sineOut,Handler.create(this,this.clear),0,!1,!1)}}tweenMove(){this._offsetX*=this.ratio*this._elasticRateX,this._offsetY*=this.ratio*this._elasticRateY,this.target.x+=this._offsetX,this.target.y+=this._offsetY,this.area&&this.checkArea(),this.target.event(Event.DRAG_MOVE,this.data),(Math.abs(this._offsetX)<1&&Math.abs(this._offsetY)<1||this._elasticRateX<.5||this._elasticRateY<.5)&&(ILaya.systemTimer.clear(this,this.tweenMove),this.elasticDistance>0?this.checkElastic():this.clear())}clear(){if(this.target){this.clearTimer();var sp=this.target;this.target=null,this._parent=null,sp.event(Event.DRAG_END,this.data)}}}class Component{constructor(){this._id=Utils.getGID(),this._resetComp()}get id(){return this._id}get enabled(){return this._enabled}set enabled(value){this._enabled!=value&&(this._enabled=value,this.owner&&(value?this.owner.activeInHierarchy&&this._onEnable():this.owner.activeInHierarchy&&this._onDisable()))}get isSingleton(){return!0}get destroyed(){return this._destroyed}_isScript(){return!1}_resetComp(){this._indexInList=-1,this._enabled=!0,this._awaked=!1,this.owner=null}_getIndexInList(){return this._indexInList}_setIndexInList(index){this._indexInList=index}_onAdded(){}_onAwake(){}_onEnable(){}_onDisable(){}_onDestroy(){}onReset(){}_parse(data){}_cloneTo(dest){}_setActive(value){value?(this._awaked||(this._awaked=!0,this._onAwake()),this._enabled&&this._onEnable()):this._enabled&&this._onDisable()}destroy(){this.owner&&this.owner._destroyComponent(this)}_destroy(){this.owner.activeInHierarchy&&this._enabled&&(this._setActive(!1),this._isScript()&&this.onDisable()),this._onDestroy(),this._destroyed=!0,this.onReset!==Component.prototype.onReset?(this.onReset(),this._resetComp(),Pool.recoverByClass(this)):this._resetComp()}}class AnimationBase extends Sprite{constructor(){super(),this.wrapMode=0,this._interval=Config.animationInterval,this._isReverse=!1,this._frameRateChanged=!1,this._setBitUp(Const.DISPLAY)}play(start=0,loop=!0,name=""){this._isPlaying=!0,this._actionName=name,this.index="string"==typeof start?this._getFrameByLabel(start):start,this.loop=loop,this._isReverse=this.wrapMode===AnimationBase.WRAP_REVERSE,0==this.index&&this._isReverse&&(this.index=this.count-1),this.interval>0&&this.timerLoop(this.interval,this,this._frameLoop,null,!0,!0)}get interval(){return this._interval}set interval(value){this._interval!=value&&(this._frameRateChanged=!0,this._interval=value,this._isPlaying&&value>0&&this.timerLoop(value,this,this._frameLoop,null,!0,!0))}_getFrameByLabel(label){for(var i=0;i-1)return i}return 0}_frameLoop(){if(this._isReverse){if(this._index--,this._index<0){if(!this.loop)return this._index=0,this.stop(),void this.event(Event.COMPLETE);this.wrapMode==AnimationBase.WRAP_PINGPONG?(this._index=this._count>0?1:0,this._isReverse=!1):this._index=this._count-1,this.event(Event.COMPLETE)}}else if(this._index++,this._index>=this._count){if(!this.loop)return this._index--,this.stop(),void this.event(Event.COMPLETE);this.wrapMode==AnimationBase.WRAP_PINGPONG?(this._index=this._count-2>=0?this._count-2:0,this._isReverse=!0):this._index=0,this.event(Event.COMPLETE)}this.index=this._index}_setControlNode(node){this._controlNode&&(this._controlNode.off(Event.DISPLAY,this,this._resumePlay),this._controlNode.off(Event.UNDISPLAY,this,this._resumePlay)),this._controlNode=node,node&&node!=this&&(node.on(Event.DISPLAY,this,this._resumePlay),node.on(Event.UNDISPLAY,this,this._resumePlay))}_setDisplay(value){super._setDisplay(value),this._resumePlay()}_resumePlay(){this._isPlaying&&(this._controlNode.displayedInStage?this.play(this._index,this.loop,this._actionName):this.clearTimer(this,this._frameLoop))}stop(){this._isPlaying=!1,this.clearTimer(this,this._frameLoop)}get isPlaying(){return this._isPlaying}addLabel(label,index){this._labels||(this._labels={}),this._labels[index]||(this._labels[index]=[]),this._labels[index].push(label)}removeLabel(label){if(label){if(this._labels)for(var name in this._labels)this._removeLabelFromList(this._labels[name],label)}else this._labels=null}_removeLabelFromList(list,label){if(list)for(var i=list.length-1;i>=0;i--)list[i]==label&&list.splice(i,1)}gotoAndStop(position){this.index="string"==typeof position?this._getFrameByLabel(position):position,this.stop()}get index(){return this._index}set index(value){if(this._index=value,this._displayToIndex(value),this._labels&&this._labels[value])for(var tArr=this._labels[value],i=0,len=tArr.length;i1e-6?(omega=Math.acos(cosom),sinom=Math.sin(omega),scale0=Math.sin((1-t)*omega)/sinom,scale1=Math.sin(t*omega)/sinom):(scale0=1-t,scale1=t),out[Offset3+0]=scale0*ax+scale1*bx,out[Offset3+1]=scale0*ay+scale1*by,out[Offset3+2]=scale0*az+scale1*bz,out[Offset3+3]=scale0*aw+scale1*bw,out}static getRotation(x0,y0,x1,y1){return Math.atan2(y1-y0,x1-x0)/Math.PI*180}static sortBigFirst(a,b){return a==b?0:b>a?1:-1}static sortSmallFirst(a,b){return a==b?0:b>a?-1:1}static sortNumBigFirst(a,b){return parseFloat(b)-parseFloat(a)}static sortNumSmallFirst(a,b){return parseFloat(a)-parseFloat(b)}static sortByKey(key,bigFirst=!1,forceNum=!0){var _sortFun;return _sortFun=bigFirst?forceNum?MathUtil.sortNumBigFirst:MathUtil.sortBigFirst:forceNum?MathUtil.sortNumSmallFirst:MathUtil.sortSmallFirst,function(a,b){return _sortFun(a[key],b[key])}}}class FrameAnimation extends AnimationBase{constructor(){super(),null===FrameAnimation._sortIndexFun&&(FrameAnimation._sortIndexFun=MathUtil.sortByKey("index",!1,!0))}_setUp(targetDic,animationData){this._targetDic=targetDic,this._animationData=animationData,this.interval=1e3/animationData.frameRate,animationData.parsed?(this._count=animationData.count,this._labels=animationData.labels,this._usedFrames=animationData.animationNewFrames):(this._usedFrames=[],this._calculateDatas(),animationData.parsed=!0,animationData.labels=this._labels,animationData.count=this._count,animationData.animationNewFrames=this._usedFrames)}clear(){return super.clear(),this._targetDic=null,this._animationData=null,this}_displayToIndex(value){if(this._animationData){value<0&&(value=0),value>this._count&&(value=this._count);var i,nodes=this._animationData.nodes,len=nodes.length;for(i=0;iframe?propFrames[frame]:propFrames[propFrames.length-1],target[key]=value;var funFrames,funkeys=node.funkeys;if(0!=(len=funkeys.length))for(i=0;ithis._count&&(this._count=temp.index)}}else this._targetDic&&this._targetDic[target]&&(node.initValues[key]=this._targetDic[target][key]),tKeyFrames.sort(FrameAnimation._sortIndexFun),node.keys.push(key),this._calculateNodePropFrames(tKeyFrames,node.frames[key],key,target)}}resetNodes(){if(this._targetDic&&this._animationData){var i,tNode,initValues,nodes=this._animationData.nodes,len=nodes.length;for(i=0;ithis._count&&(this._count=end),startFrame.tween)for(null==(easeFun=Ease[startFrame.tweenMethod])&&(easeFun=Ease.linearNone),i=start;i0&&null==uiView.props.hitTestPrior&&!root.mouseThrough&&(root.hitTestPrior=!0),tInitTool.beginLoad(root),root}static createInitTool(){return InitTool.create()}static createComp(uiView,comp=null,view=null,dataMap=null,initTool=null){if("Scene3D"==uiView.type||"Sprite3D"==uiView.type){var outBatchSprits=[],scene3D=ILaya.Laya.Utils3D._createSceneByJsonForMaker(uiView,outBatchSprits,initTool);return"Sprite3D"==uiView.type?ILaya.Laya.StaticBatchManager.combine(scene3D,outBatchSprits):ILaya.Laya.StaticBatchManager.combine(null,outBatchSprits),scene3D}if(!(comp=comp||SceneUtils.getCompInstance(uiView)))return uiView.props&&uiView.props.runtime?console.warn("runtime not found:"+uiView.props.runtime):console.warn("can not create:"+uiView.type),null;var child=uiView.child;if(child)for(var isList="List"==comp._$componentType,i=0,n=child.length;i=0||value.indexOf("@Prefab:")>=0)?initTool&&initTool.addNodeRef(comp,prop,value):SceneUtils.setCompValue(comp,prop,value,view,dataMap)}return comp._afterInited&&comp._afterInited(),uiView.compId&&initTool&&initTool._idMap&&(initTool._idMap[uiView.compId]=comp),comp}static setCompValue(comp,prop,value,view=null,dataMap=null){if("string"==typeof value&&value.indexOf("${")>-1){if(SceneUtils._sheet||(SceneUtils._sheet=ILaya.ClassUtils.getClass("laya.data.Table")),!SceneUtils._sheet)return void console.warn("Can not find class Sheet");if(dataMap)dataMap.push(comp,prop,value);else if(view){-1==value.indexOf("].")&&(value=value.replace(".","[0]."));var one,temp,watcher=new DataWatcher(comp,prop,value);watcher.exe(view);for(var str=value.replace(/\[.*?\]\./g,".");null!=(one=SceneUtils._parseWatchData.exec(str));){for(var key1=one[1];null!=(temp=SceneUtils._parseKeyWord.exec(key1));){var key2=temp[0],arr=view._watchMap[key2]||(view._watchMap[key2]=[]);arr.push(watcher),SceneUtils._sheet.I.notifer.on(key2,view,view.changeData,[key2])}(arr=view._watchMap[key1]||(view._watchMap[key1]=[])).push(watcher),SceneUtils._sheet.I.notifer.on(key1,view,view.changeData,[key1])}}}else"var"===prop&&view?view[value]=comp:comp[prop]="true"===value||"false"!==value&&value}static getCompInstance(json){if("UIView"==json.type&&json.props&&json.props.pageData)return SceneUtils.createByData(null,json.props.pageData);var runtime=json.props&&json.props.runtime||json.type,compClass=ILaya.ClassUtils.getClass(runtime);if(!compClass)throw"Can not find class "+runtime;if("Script"===json.type&&compClass.prototype._doAwake){var comp=Pool.createByClass(compClass);return comp._destroyed=!1,comp}return json.props&&"renderType"in json.props&&"instance"==json.props.renderType?(compClass.instance||(compClass.instance=new compClass),compClass.instance):new compClass}}SceneUtils._parseWatchData=/\${(.*?)}/g,SceneUtils._parseKeyWord=/[a-zA-Z_][a-zA-Z0-9_]*(?:(?:\.[a-zA-Z_][a-zA-Z0-9_]*)+)/g;class DataWatcher{constructor(comp,prop,value){this.comp=comp,this.prop=prop,this.value=value}exe(view){var fun=SceneUtils.getBindFun(this.value);this.comp[this.prop]=fun.call(this,view)}}class InitTool{reset(){this._nodeRefList=null,this._initList=null,this._idMap=null,this._loadList=null,this._scene=null}recover(){this.reset(),Pool.recover("InitTool",this)}static create(){var tool=Pool.getItemByClass("InitTool",InitTool);return tool._idMap=[],tool}addLoadRes(url,type=null){this._loadList||(this._loadList=[]),type?this._loadList.push({url:url,type:type}):this._loadList.push(url)}addNodeRef(node,prop,referStr){this._nodeRefList||(this._nodeRefList=[]),this._nodeRefList.push([node,prop,referStr]),referStr.indexOf("@Prefab:")>=0&&this.addLoadRes(referStr.replace("@Prefab:",""),Loader.PREFAB)}setNodeRef(){if(this._nodeRefList)if(this._idMap){var i,len,tRefInfo;for(len=this._nodeRefList.length,i=0;i=0)return Loader.getRes(referStr.replace("@Prefab:",""));if(referStr.indexOf("@arr:")>=0){var list,i,len,tStr;for(len=(list=(referStr=referStr.replace("@arr:","")).split(",")).length,i=0;i0?Math.floor(1e3/Stat.FPS).toString():" ";Stat._fpsStr=Stat.FPS+(Stat.renderSlow?" slow":"")+" "+delay,Stat._spriteStr=Stat.spriteCount+(Stat.spriteRenderUseCacheCount?"/"+Stat.spriteRenderUseCacheCount:""),Stat._canvasStr=Stat.canvasReCache+"/"+Stat.canvasNormal+"/"+Stat.canvasBitmap,Stat.cpuMemory=Resource.cpuMemory,Stat.gpuMemory=Resource.gpuMemory,this._useCanvas?this.renderInfoPre():this.renderInfo(),Stat.clear()}Stat._count=0,Stat._timer=timer}}renderInfoPre(){var one,value,i=0;if(this._canvas){var ctx=this._ctx;for(ctx.clearRect(this._first?0:this._vx,0,this._width,this._height),i=0;i3e4;this._delta=(now-this._lastTimer)*this.scale;var timer=this.currTimer=this.currTimer+this._delta;this._lastTimer=now;var handlers=this._handlers;this._count=0;for(var i=0,n=handlers.length;i=handler.exeTime)if(handler.repeat)if(!handler.jumpFrame||awake)handler.exeTime+=handler.delay,handler.run(!1),t>handler.exeTime&&(handler.exeTime+=Math.ceil((t-handler.exeTime)/handler.delay)*handler.delay);else for(;t>=handler.exeTime;)handler.exeTime+=handler.delay,handler.run(!1);else handler.run(!0)}else this._count++}(this._count>30||frame%200==0)&&this._clearHandlers()}_clearHandlers(){for(var handlers=this._handlers,i=0,n=handlers.length;i0?Timer._pool.pop():new TimerHandler).repeat=repeat,handler.userFrame=useFrame,handler.delay=delay,handler.caller=caller,handler.method=method,handler.args=args,handler.exeTime=delay+(useFrame?this.currFrame:this.currTimer+Date.now()-this._lastTimer),this._indexHandler(handler),this._handlers.push(handler),handler}_indexHandler(handler){var caller=handler.caller,method=handler.method,cid=caller?caller.$_GID||(caller.$_GID=ILaya.Utils.getGID()):0,mid=method.$_TID||(method.$_TID=1e5*Timer._mid++);handler.key=cid+mid,this._map[handler.key]=handler}once(delay,caller,method,args=null,coverBefore=!0){this._create(!1,!1,delay,caller,method,args,coverBefore)}loop(delay,caller,method,args=null,coverBefore=!0,jumpFrame=!1){var handler=this._create(!1,!0,delay,caller,method,args,coverBefore);handler&&(handler.jumpFrame=jumpFrame)}frameOnce(delay,caller,method,args=null,coverBefore=!0){this._create(!0,!1,delay,caller,method,args,coverBefore)}frameLoop(delay,caller,method,args=null,coverBefore=!0){this._create(!0,!0,delay,caller,method,args,coverBefore)}toString(){return" handlers:"+this._handlers.length+" pool:"+Timer._pool.length}clear(caller,method){var handler=this._getHandler(caller,method);handler&&(this._map[handler.key]=null,handler.key=0,handler.clear())}clearAll(caller){if(caller)for(var i=0,n=this._handlers.length;i=0&&(r+=this.funs[i]);return r}}class ShaderNode{constructor(includefiles){this.childs=[],this.text="",this.useFuns="",this.z=0,this.includefiles=includefiles}setParent(parent){parent.childs.push(this),this.z=parent.z+1,this.parent=parent}setCondition(condition,type){condition&&(this.conditionType=type,condition=condition.replace(/(\s*$)/g,""),this.condition=function(){return this[condition]},this.condition.__condition=condition)}toscript(def,out){return this._toscript(def,out,++ShaderNode.__id)}_toscript(def,out,id){if(this.childs.length<1&&!this.text)return out;out.length;if(this.condition){var ifdef=!!this.condition.call(def);if(this.conditionType===ILaya.ShaderCompile.IFDEF_ELSE&&(ifdef=!ifdef),!ifdef)return out}if(this.text&&out.push(this.text),this.childs.length>0&&this.childs.forEach(function(o,index,arr){o._toscript(def,out,id)}),this.includefiles.length>0&&this.useFuns.length>0)for(var funsCode,i=0,n=this.includefiles.length;i0&&(this.includefiles[i].curUseID=id,out[0]=funsCode+out[0]);return out}}ShaderNode.__id=1;class ShaderCompile{constructor(vs,ps,nameMap){this.defs={};let _this=this;function _compile(script){script=script.replace(ShaderCompile._clearCR,"");var includefiles=[],top=new ShaderNode(includefiles);return _this._compileToTree(top,script.split("\n"),0,includefiles,_this.defs),top}var startTime=Date.now();this._VS=_compile(vs),this._PS=_compile(ps),this._nameMap=nameMap,Date.now()-startTime>2&&console.log("ShaderCompile use time:"+(Date.now()-startTime)+" size:"+vs.length+"/"+ps.length)}static __init__(){var gl=LayaGL.instance;ShaderCompile.shaderParamsMap={float:gl.FLOAT,int:gl.INT,bool:gl.BOOL,vec2:gl.FLOAT_VEC2,vec3:gl.FLOAT_VEC3,vec4:gl.FLOAT_VEC4,ivec2:gl.INT_VEC2,ivec3:gl.INT_VEC3,ivec4:gl.INT_VEC4,bvec2:gl.BOOL_VEC2,bvec3:gl.BOOL_VEC3,bvec4:gl.BOOL_VEC4,mat2:gl.FLOAT_MAT2,mat3:gl.FLOAT_MAT3,mat4:gl.FLOAT_MAT4,sampler2D:gl.SAMPLER_2D,samplerCube:gl.SAMPLER_CUBE}}static _parseOne(attributes,uniforms,words,i,word,b){var one={type:ShaderCompile.shaderParamsMap[words[i+1]],name:words[i+2],size:isNaN(parseInt(words[i+3]))?1:parseInt(words[i+3])};return b&&("attribute"==word?attributes.push(one):uniforms.push(one)),":"==words[i+3]&&(one.type=words[i+4],i+=2),i+=2}static addInclude(fileName,txt){if(!txt||0===txt.length)throw new Error("add shader include file err:"+fileName);if(ShaderCompile.includes[fileName])throw new Error("add shader include file err, has add:"+fileName);ShaderCompile.includes[fileName]=new InlcudeFile(txt)}static preGetParams(vs,ps){var i,n,text=[vs,ps],result={},attributes=[],uniforms=[],definesInfo={},definesName=[];result.attributes=attributes,result.uniforms=uniforms,result.defines=definesInfo;for(var s=0;s<2;s++){text[s]=text[s].replace(ShaderCompile._removeAnnotation,"");var tempelse,words=text[s].match(ShaderCompile._reg);for(i=0,n=words.length;i()'\",;".indexOf(c)>=0){if(ofs>=0&&i-ofs>1&&(word=str.substr(ofs,i-ofs),out.push(word)),'"'==c||"'"==c){var ofs2=str.indexOf(c,i+1);if(ofs2<0)throw"Sharder err:"+str;out.push(str.substr(i+1,ofs2-i-1)),i=ofs2,ofs=-1;continue}"("==c&&block&&out.length>0&&(word=out[out.length-1]+";","vec4;main;".indexOf(word)<0&&(block.useFuns+=word)),ofs=-1}else ofs<0&&(ofs=i);return ofs1&&(word=str.substr(ofs,n-ofs),out.push(word)),out}_compileToTree(parent,lines,start,includefiles,defs){var node,preNode,text,name,fname,ofs,words,noUseNode,i,n,j;for(i=start;i=0&&(text=text.substr(0,ofs)),node=noUseNode||new ShaderNode(includefiles),noUseNode=null,node.text=text,node.noCompile=!0,(ofs=text.indexOf("#"))>=0){for(name="#",j=ofs+1,n=text.length;j]/),node.noCompile?console.log("function():Boolean{return "+text.substr(ofs+node.name.length)+"}"):(words=text.replace(/^\s*/,"").split(/\s+/),node.setCondition(words[1],"#ifdef"===name?ShaderCompile.IFDEF_YES:ShaderCompile.IFDEF_ELSE),node.text="//"+node.text),node.setParent(parent),parent=node,defs)for(words=text.substr(j).split(ShaderCompile._splitToWordExps3),j=0;j0&&ShaderCompile.splitToWords(text,preNode),noUseNode=node,preNode.text+="\n"+text;continue}includefiles.length>0&&ShaderCompile.splitToWords(text,node)}node.setParent(parent)}}createShader(define,shaderName,createShader,bindAttrib){var defMap={},defineStr="";if(define)for(var i in define)defineStr+="#define "+i+"\n",defMap[i]=!0;var vs=this._VS.toscript(defMap,[]),ps=this._PS.toscript(defMap,[]);return(createShader||Shader.create)(defineStr+vs.join("\n"),defineStr+ps.join("\n"),shaderName,this._nameMap,bindAttrib)}}ShaderCompile.IFDEF_NO=0,ShaderCompile.IFDEF_YES=1,ShaderCompile.IFDEF_ELSE=2,ShaderCompile.IFDEF_PARENT=3,ShaderCompile._removeAnnotation=new RegExp("(/\\*([^*]|[\\r\\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/)|(//.*)","g"),ShaderCompile._reg=new RegExp("(\".*\")|('.*')|([#\\w\\*-\\.+/()=<>{}\\\\]+)|([,;:\\\\])","g"),ShaderCompile._splitToWordExps=new RegExp("[(\".*\")]+|[('.*')]+|([ \\t=\\+\\-*/&%!<>!%(),;])","g"),ShaderCompile.includes={},ShaderCompile._clearCR=new RegExp("\r","g"),ShaderCompile._splitToWordExps3=new RegExp("[ \\t=\\+\\-*/&%!<>!%(),;\\|]","g");class WorkerLoader extends EventDispatcher{constructor(){super(),this.worker=new Worker(WorkerLoader.workerPath);let me=this;this.worker.onmessage=function(evt){me.workerMessage(evt.data)}}static __init__(){return null==WorkerLoader._preLoadFun&&(!!Worker&&(WorkerLoader._preLoadFun=Loader.prototype._loadImage,Loader.prototype._loadImage=WorkerLoader.prototype._loadImage,WorkerLoader.I||(WorkerLoader.I=new WorkerLoader),!0))}static workerSupported(){return!!Worker}static enableWorkerLoader(){WorkerLoader._tryEnabled||(WorkerLoader.enable=!0,WorkerLoader._tryEnabled=!0)}static set enable(value){WorkerLoader._enable!=value&&(WorkerLoader._enable=value,value&&null==WorkerLoader._preLoadFun&&(WorkerLoader._enable=WorkerLoader.__init__()))}static get enable(){return WorkerLoader._enable}workerMessage(data){if(data)switch(data.type){case"Image":this.imageLoaded(data);break;case"Disable":WorkerLoader.enable=!1}}imageLoaded(data){if(data.dataType&&"imageBitmap"==data.dataType){var imageData=data.imageBitmap,tex=new Texture2D;tex.loadImageSource(imageData),console.log("load:",data.url),this.event(data.url,tex)}else this.event(data.url,null)}loadImage(url){this.worker.postMessage(url)}_loadImage(url){var _this=this;if(this._useWorkerLoader&&WorkerLoader._enable){url=URL.formatURL(url);var onload=function(image){WorkerLoader.I.off(url,_this,onload),image?_this.onLoaded(image):WorkerLoader._preLoadFun.call(_this,url)};WorkerLoader.I.on(url,_this,onload),WorkerLoader.I.loadImage(url)}else WorkerLoader._preLoadFun.call(_this,url)}}WorkerLoader.workerPath="libs/workerloader.js",WorkerLoader._enable=!1,WorkerLoader._tryEnabled=!1;class Mouse{static set cursor(cursorStr){Mouse._style.cursor=cursorStr}static get cursor(){return Mouse._style.cursor}static __init__(){}static hide(){"none"!=Mouse.cursor&&(Mouse._preCursor=Mouse.cursor,Mouse.cursor="none")}static show(){"none"==Mouse.cursor&&(Mouse._preCursor?Mouse.cursor=Mouse._preCursor:Mouse.cursor="auto")}}class MeshParticle2D extends Mesh2D{constructor(maxNum){super(MeshParticle2D.const_stride,4*maxNum*MeshParticle2D.const_stride,4),this.canReuse=!0,this.setAttributes(MeshParticle2D._fixattriInfo),this.createQuadIB(maxNum),this._quadNum=maxNum}static __init__(){var gl=LayaGL.instance;MeshParticle2D._fixattriInfo=[gl.FLOAT,4,0,gl.FLOAT,3,16,gl.FLOAT,3,28,gl.FLOAT,4,40,gl.FLOAT,4,56,gl.FLOAT,3,72,gl.FLOAT,2,84,gl.FLOAT,4,92,gl.FLOAT,1,108,gl.FLOAT,1,112]}setMaxParticleNum(maxNum){this._vb._resizeBuffer(4*maxNum*MeshParticle2D.const_stride,!1),this.createQuadIB(maxNum)}static getAMesh(maxNum){if(MeshParticle2D._POOL.length){var ret=MeshParticle2D._POOL.pop();return ret.setMaxParticleNum(maxNum),ret}return new MeshParticle2D(maxNum)}releaseMesh(){this._vb.setByteLength(0),this.vertNum=0,this.indexNum=0,MeshParticle2D._POOL.push(this)}destroy(){this._ib.destroy(),this._vb.destroy(),this._vb.deleteBuffer()}}MeshParticle2D.const_stride=116,MeshParticle2D._POOL=[];class HTMLImage extends Bitmap{}HTMLImage.create=function(width,height,format){var tex=new Texture2D(width,height,format,!1,!1);return tex.wrapModeU=BaseTexture.WARPMODE_CLAMP,tex.wrapModeV=BaseTexture.WARPMODE_CLAMP,tex};class Laya{static __init(_classs){_classs.forEach(function(o){o.__init$&&o.__init$()})}static init(width,height,...plugins){if(!Laya._isinit){Laya._isinit=!0,ArrayBuffer.prototype.slice||(ArrayBuffer.prototype.slice=Laya._arrayBufferSlice),Browser.__init__();var mainCanv=Browser.mainCanvas=new HTMLCanvas(!0),style=mainCanv.source.style;style.position="absolute",style.top=style.left="0px",style.background="#000000",Browser.onKGMiniGame||Browser.onAlipayMiniGame||Browser.container.appendChild(mainCanv.source),Browser.canvas=new HTMLCanvas(!0),Browser.context=Browser.canvas.getContext("2d"),Browser.supportWebAudio=SoundManager.__init__(),Browser.supportLocalStorage=LocalStorage.__init__(),Laya.systemTimer=new Timer(!1),exports.systemTimer=Timer.gSysTimer=Laya.systemTimer,Laya.startTimer=new Timer(!1),Laya.physicsTimer=new Timer(!1),Laya.updateTimer=new Timer(!1),Laya.lateTimer=new Timer(!1),Laya.timer=new Timer(!1),exports.startTimer=ILaya.startTimer=Laya.startTimer,exports.lateTimer=ILaya.lateTimer=Laya.lateTimer,exports.updateTimer=ILaya.updateTimer=Laya.updateTimer,ILaya.systemTimer=Laya.systemTimer,exports.timer=ILaya.timer=Laya.timer,exports.physicsTimer=ILaya.physicsTimer=Laya.physicsTimer,Laya.loader=new LoaderManager,ILaya.Laya=Laya,exports.loader=ILaya.loader=Laya.loader,WeakObject.__init__(),SceneUtils.__init(),Mouse.__init__(),WebGL.inner_enable();for(var i=0,n=plugins.length;i=vArr.length&&(frame=vArr.length-1),obj[key][frame]}return key in obj2?obj2[key]:noValue}_getNodeGraphicData(nodeID,frame,rst){rst||(rst=new GraphicNode),rst.transform?rst.transform.identity():rst.transform=new Matrix;var node=this.getNodeDataByID(nodeID);if(!node)return rst;var width,height,tex,frameData=node.frames,params=this._getParams(frameData,GraphicAnimation._drawTextureCmd,frame,this._nodeDefaultProps[nodeID]),url=params[0],px=params[5],py=params[6],aX=params[13],aY=params[14],sx=params[7],sy=params[8],rotate=params[9],skewX=params[11],skewY=params[12];width=params[3],height=params[4],0!=width&&0!=height||(url=null),-1==width&&(width=0),-1==height&&(height=0),rst.skin=url,rst.width=width,rst.height=height,url&&((tex=this._getTextureByUrl(url))?(width||(width=tex.sourceWidth),height||(height=tex.sourceHeight)):console.warn("lost skin:",url,",you may load pics first")),rst.alpha=params[10];var m=rst.transform;0!=aX&&(px=aX*width),0!=aY&&(py=aY*height),0==px&&0==py||m.translate(-px,-py);var tm=null;if(rotate||1!==sx||1!==sy||skewX||skewY){(tm=GraphicAnimation._tempMt).identity(),tm._bTransform=!0;var skx=.0174532922222222*(rotate-skewX),sky=.0174532922222222*(rotate+skewY),cx=Math.cos(sky),ssx=Math.sin(sky),cy=Math.sin(skx),ssy=Math.cos(skx);tm.a=sx*cx,tm.b=sx*ssx,tm.c=-sy*cy,tm.d=sy*ssy,tm.tx=tm.ty=0}return tm&&(m=Matrix.mul(m,tm,m)),m.translate(params[1],params[2]),rst}_getTextureByUrl(url){return Loader.getRes(url)}setAniData(uiView,aniName=null){if(uiView.animations){this._nodeDefaultProps={},this._nodeGDic={},this._nodeList&&(this._nodeList.length=0),this._rootNode=uiView,this._parseNodeList(uiView);var i,tAniO,aniDic={},anilist=[],animations=uiView.animations,len=animations.length;for(i=0;i.01&&this._frames&&super._frameLoop()}_displayToIndex(value){this._frames&&(this.graphics=this._frames[value])}get frames(){return this._frames}set frames(value){this._frames=value,value&&(this._count=value.length,this._actionName&&this._setFramesFromCache(this._actionName,!0),this.index=this._index)}set source(value){value.indexOf(".ani")>-1?this.loadAnimation(value):value.indexOf(".json")>-1||value.indexOf("als")>-1||value.indexOf("atlas")>-1?this.loadAtlas(value):this.loadImages(value.split(","))}set autoAnimation(value){this.play(0,!0,value)}set autoPlay(value){value?this.play():this.stop()}clear(){return super.clear(),this.stop(),this.graphics=null,this._frames=null,this._labels=null,this}loadImages(urls,cacheName=""){return this._url="",this._setFramesFromCache(cacheName)||(this.frames=Animation.framesMap[cacheName]?Animation.framesMap[cacheName]:Animation.createFrames(urls,cacheName)),this}loadAtlas(url,loaded=null,cacheName=""){this._url="";var _this=this;if(!_this._setFramesFromCache(cacheName)){function onLoaded(loadUrl){url===loadUrl&&(_this.frames=Animation.framesMap[cacheName]?Animation.framesMap[cacheName]:Animation.createFrames(url,cacheName),loaded&&loaded.run())}Loader.getAtlas(url)?onLoaded(url):ILaya.loader.load(url,Handler.create(null,onLoaded,[url]),null,Loader.ATLAS)}return this}loadAnimation(url,loaded=null,atlas=null){this._url=url;return this._actionName||(this._actionName=""),this._setFramesFromCache(this._actionName)?(this._setFramesFromCache(this._actionName,!0),this.index=0,loaded&&loaded.run()):!atlas||Loader.getAtlas(atlas)?this._loadAnimationData(url,loaded,atlas):ILaya.loader.load(atlas,Handler.create(this,this._loadAnimationData,[url,loaded,atlas]),null,Loader.ATLAS),this}_loadAnimationData(url,loaded=null,atlas=null){if(!atlas||Loader.getAtlas(atlas)){var _this=this;Loader.getRes(url)?onLoaded(url):ILaya.loader.load(url,Handler.create(null,onLoaded,[url]),null,Loader.JSON)}else console.warn("atlas load fail:"+atlas);function onLoaded(loadUrl){if(Loader.getRes(loadUrl)){if(url===loadUrl){var tAniO;if(Animation.framesMap[url+"#"])_this._setFramesFromCache(_this._actionName,!0),_this.index=0,_this._resumePlay();else{var aniData=GraphicAnimation.parseAnimationData(Loader.getRes(url));if(!aniData)return;var i,defaultO,aniList=aniData.animationList,len=aniList.length;for(i=0;ithis._count&&(value=this._count);var i,nodes=this._animationData.nodes,len=nodes.length;for(len=len>1?1:len,i=0;iframe?propFrames[frame]:propFrames[propFrames.length-1],target[key]=value}}_calculateKeyFrames(node){super._calculateKeyFrames(node);var key,tKeyFrames,keyFrames=node.keyframes,secondFrames=(node.target,{});for(key in node.secondFrames=secondFrames,keyFrames)(tKeyFrames=keyFrames[key]).length<=1?secondFrames[key]=-1:secondFrames[key]=tKeyFrames[1].index}}EffectAnimation.EFFECT_BEGIN="effectbegin",ClassUtils.regClass("laya.display.EffectAnimation",EffectAnimation),ClassUtils.regClass("Laya.EffectAnimation",EffectAnimation);class SceneLoader extends EventDispatcher{constructor(){super(),this._completeHandler=new Handler(this,this.onOneLoadComplete),this.reset()}reset(){this._toLoadList=[],this._isLoading=!1,this.totalCount=0}get leftCount(){return this._isLoading?this._toLoadList.length+1:this._toLoadList.length}get loadedCount(){return this.totalCount-this.leftCount}load(url,is3D=!1,ifCheck=!0){var i,len;if(url instanceof Array)for(len=url.length,i=0;i=0||Loader.getRes(url)||(is3D?this._toLoadList.push({url:url}):this._toLoadList.push(url),this.totalCount++)}_checkNext(){if(!this._isLoading){if(0==this._toLoadList.length)return void this.event(Event.COMPLETE);var tItem;"string"==typeof(tItem=this._toLoadList.pop())?this.loadOne(tItem):this.loadOne(tItem.url,!0)}}loadOne(url,is3D=!1){this._curUrl=url;var type=Utils.getFileExtension(this._curUrl);is3D?ILaya.loader.create(url,this._completeHandler):SceneLoader.LoadableExtensions[type]?ILaya.loader.load(url,this._completeHandler,null,SceneLoader.LoadableExtensions[type]):url!=AtlasInfoManager.getFileLoadPath(url)||SceneLoader.No3dLoadTypes[type]||!LoaderManager.createMap[type]?ILaya.loader.load(url,this._completeHandler):ILaya.loader.create(url,this._completeHandler)}onOneLoadComplete(){this._isLoading=!1,Loader.getRes(this._curUrl)||console.log("Fail to load:",this._curUrl);var dataO,type=Utils.getFileExtension(this._curUrl);SceneLoader.LoadableExtensions[type]&&((dataO=Loader.getRes(this._curUrl))&&dataO instanceof Prefab&&(dataO=dataO.json),dataO&&(dataO.loadList&&this.load(dataO.loadList,!1,!1),dataO.loadList3D&&this.load(dataO.loadList3D,!0,!1)));"sk"==type&&this.load(this._curUrl.replace(".sk",".png"),!1,!1),this.event(Event.PROGRESS,this.getProgress()),this._checkNext()}getProgress(){return this.loadedCount/this.totalCount}}SceneLoader.LoadableExtensions={scene:Loader.JSON,scene3d:Loader.JSON,ani:Loader.JSON,ui:Loader.JSON,prefab:Loader.PREFAB},SceneLoader.No3dLoadTypes={png:!0,jpg:!0,txt:!0};class Scene extends Sprite{constructor(createChildren=!0){super(),this.autoDestroyAtClosed=!1,this.url=null,this._viewCreated=!1,this._$componentType="Scene",this._setBit(Const.NOT_READY,!0),Scene.unDestroyedScenes.push(this),this._scene=this,createChildren&&this.createChildren()}createChildren(){}loadScene(path){var url=path.indexOf(".")>-1?path:path+".scene",view=ILaya.loader.getRes(url);if(view)this.createView(view);else{ILaya.loader.resetProgress();var loader=new SceneLoader;loader.on(Event.COMPLETE,this,this._onSceneLoaded,[url]),loader.load(url)}}_onSceneLoaded(url){this.createView(ILaya.Loader.getRes(url))}createView(view){view&&!this._viewCreated&&(this._viewCreated=!0,SceneUtils.createByData(this,view))}getNodeByID(id){return this._idMap?this._idMap[id]:null}open(closeOther=!0,param=null){closeOther&&Scene.closeAll(),Scene.root.addChild(this),this.onOpened(param)}onOpened(param){}close(type=null){this.onClosed(type),this.autoDestroyAtClosed?this.destroy():this.removeSelf()}onClosed(type=null){}destroy(destroyChild=!0){this._idMap=null,super.destroy(destroyChild);for(var list=Scene.unDestroyedScenes,i=list.length-1;i>-1;i--)if(list[i]===this)return void list.splice(i,1)}set scaleX(value){super.get_scaleX()!=value&&(super.set_scaleX(value),this.event(Event.RESIZE))}get scaleX(){return super.scaleX}set scaleY(value){super.get_scaleY()!=value&&(super.set_scaleY(value),this.event(Event.RESIZE))}get scaleY(){return super.scaleY}get width(){if(this._width)return this._width;for(var max=0,i=this.numChildren-1;i>-1;i--){var comp=this.getChildAt(i);comp._visible&&(max=Math.max(comp._x+comp.width*comp.scaleX,max))}return max}set width(value){super.get_width()!=value&&(super.set_width(value),this.callLater(this._sizeChanged))}get height(){if(this._height)return this._height;for(var max=0,i=this.numChildren-1;i>-1;i--){var comp=this.getChildAt(i);comp._visible&&(max=Math.max(comp._y+comp.height*comp.scaleY,max))}return max}set height(value){super.get_height()!=value&&(super.set_height(value),this.callLater(this._sizeChanged))}_sizeChanged(){this.event(Event.RESIZE)}static get root(){return Scene._root||(Scene._root=ILaya.stage.addChild(new Sprite),Scene._root.name="root",ILaya.stage.on("resize",null,()=>{Scene._root.size(ILaya.stage.width,ILaya.stage.height),Scene._root.event(Event.RESIZE)}),Scene._root.size(ILaya.stage.width,ILaya.stage.height),Scene._root.event(Event.RESIZE)),Scene._root}get timer(){return this._timer||ILaya.timer}set timer(value){this._timer=value}static load(url,complete=null,progress=null){ILaya.loader.resetProgress();var loader=new SceneLoader;function onProgress(value){Scene._loadPage&&Scene._loadPage.event("progress",value),progress&&progress.runWith(value)}loader.on(Event.PROGRESS,null,onProgress),loader.once(Event.COMPLETE,null,function(){loader.off(Event.PROGRESS,null,onProgress);var obj=ILaya.Loader.getRes(url);if(!obj)throw"Can not find scene:"+url;if(!obj.props)throw"Scene data is error:"+url;var runtime=obj.props.runtime?obj.props.runtime:obj.type,clas=ILaya.ClassUtils.getClass(runtime);if("instance"==obj.props.renderType)var scene=clas.instance||(clas.instance=new clas);else scene=new clas;if(!(scene&&scene instanceof Node))throw"Can not find scene:"+runtime;scene.url=url,scene._getBit(Const.NOT_READY)?(scene.on("onViewCreated",null,function(){complete&&complete.runWith(scene)}),scene.createView(obj)):complete&&complete.runWith(scene),Scene.hideLoadingPage()}),loader.load(url)}static open(url,closeOther=!0,param=null,complete=null,progress=null){if(param instanceof Handler){var temp=complete;complete=param,param=temp}Scene.showLoadingPage(),Scene.load(url,Handler.create(null,this._onSceneLoaded,[closeOther,complete,param]),progress)}static _onSceneLoaded(closeOther,complete,param,scene){scene.open(closeOther,param),complete&&complete.runWith(scene)}static close(url,name=""){for(var flag=!1,list=Scene.unDestroyedScenes,i=0,n=list.length;i60&&(QuickTestTool.showCountInfo(),QuickTestTool._i=0)}static _addType(type){QuickTestTool._countDic[type]?QuickTestTool._countDic[type]+=1:QuickTestTool._countDic[type]=1}static showCountInfo(){var key;for(key in console.log("==================="),QuickTestTool._countDic)console.log("count:"+QuickTestTool._countDic[key]),QuickTestTool.showRenderTypeInfo(key,!0)}static enableQuickTest(){QuickTestTool.__init__(),Sprite.prototype.render=QuickTestTool.prototype.render,QuickTestTool._PreStageRender=Stage.prototype.render,Stage.prototype.render=QuickTestTool.prototype._stageRender}}QuickTestTool.showedDic={},QuickTestTool._rendertypeToStrDic={},QuickTestTool._typeToNameDic={},QuickTestTool._countDic={},QuickTestTool._i=0;class ResourceVersion{static enable(manifestFile,callback,type=2){ResourceVersion.type=type,ILaya.loader.load(manifestFile,Handler.create(null,ResourceVersion.onManifestLoaded,[callback]),null,Loader.JSON)}static onManifestLoaded(callback,data){ResourceVersion.manifest=data,URL.customFormat=ResourceVersion.addVersionPrefix,callback.run(),data||console.warn("资源版本清单文件不存在,不使用资源版本管理。忽略ERR_FILE_NOT_FOUND错误。")}static addVersionPrefix(originURL){return originURL=URL.getAdptedFilePath(originURL),ResourceVersion.manifest&&ResourceVersion.manifest[originURL]?ResourceVersion.type==ResourceVersion.FILENAME_VERSION?ResourceVersion.manifest[originURL]:ResourceVersion.manifest[originURL]+"/"+originURL:originURL}}ResourceVersion.FOLDER_VERSION=1,ResourceVersion.FILENAME_VERSION=2,ResourceVersion.type=ResourceVersion.FOLDER_VERSION;class Socket extends EventDispatcher{constructor(host=null,port=0,byteClass=null,protocols=null){super(),this.disableInput=!1,this.protocols=[],this._byteClass=byteClass||Byte,this.protocols=protocols,this.endian=Socket.BIG_ENDIAN,host&&port>0&&port<65535&&this.connect(host,port)}get input(){return this._input}get output(){return this._output}get connected(){return this._connected}get endian(){return this._endian}set endian(value){this._endian=value,null!=this._input&&(this._input.endian=value),null!=this._output&&(this._output.endian=value)}connect(host,port){var url="ws://"+host+":"+port;this.connectByUrl(url)}connectByUrl(url){null!=this._socket&&this.close(),this._socket&&this.cleanSocket(),this.protocols&&0!=this.protocols.length?this._socket=new Browser.window.WebSocket(url,this.protocols):this._socket=new Browser.window.WebSocket(url),this._socket.binaryType="arraybuffer",this._output=new this._byteClass,this._output.endian=this.endian,this._input=new this._byteClass,this._input.endian=this.endian,this._addInputPosition=0,this._socket.onopen=(e=>{this._onOpen(e)}),this._socket.onmessage=(msg=>{this._onMessage(msg)}),this._socket.onclose=(e=>{this._onClose(e)}),this._socket.onerror=(e=>{this._onError(e)})}cleanSocket(){this.close(),this._connected=!1,this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null,this._socket=null}close(){if(null!=this._socket)try{this._socket.close()}catch(e){}}_onOpen(e){this._connected=!0,this.event(Event.OPEN,e)}_onMessage(msg){if(msg&&msg.data){var data=msg.data;if(this.disableInput&&data)this.event(Event.MESSAGE,data);else{this._input.length>0&&this._input.bytesAvailable<1&&(this._input.clear(),this._addInputPosition=0);var pre=this._input.pos;!this._addInputPosition&&(this._addInputPosition=0),this._input.pos=this._addInputPosition,data&&("string"==typeof data?this._input.writeUTFBytes(data):this._input.writeArrayBuffer(data),this._addInputPosition=this._input.pos,this._input.pos=pre),this.event(Event.MESSAGE,data)}}}_onClose(e){this._connected=!1,this.event(Event.CLOSE,e)}_onError(e){this.event(Event.ERROR,e)}send(data){this._socket.send(data)}flush(){if(this._output&&this._output.length>0){var evt;try{this._socket&&this._socket.send(this._output.__getBuffer().slice(0,this._output.length))}catch(e){evt=e}this._output.endian=this.endian,this._output.clear(),evt&&this.event(Event.ERROR,evt)}}}Socket.LITTLE_ENDIAN="littleEndian",Socket.BIG_ENDIAN="bigEndian";class HTMLChar{constructor(){this.reset()}setData(char,w,h,style){return this.char=char,this.charNum=char.charCodeAt(0),this.x=this.y=0,this.width=w,this.height=h,this.style=style,this.isWord=!HTMLChar._isWordRegExp.test(char),this}reset(){return this.x=this.y=this.width=this.height=0,this.isWord=!1,this.char=null,this.charNum=0,this.style=null,this}recover(){Pool.recover("HTMLChar",this.reset())}static create(){return Pool.getItemByClass("HTMLChar",HTMLChar)}_isChar(){return!0}_getCSSStyle(){return this.style}}HTMLChar._isWordRegExp=new RegExp("[\\w.]","");class Log{static enable(){Log._logdiv||(Log._logdiv=Browser.createElement("div"),Log._logdiv.style.cssText="border:white;padding:4px;overflow-y:auto;z-index:1000000;background:rgba(100,100,100,0.6);color:white;position: absolute;left:0px;top:0px;width:50%;height:50%;",Browser.document.body.appendChild(Log._logdiv),Log._btn=Browser.createElement("button"),Log._btn.innerText="Hide",Log._btn.style.cssText="z-index:1000001;position: absolute;left:10px;top:10px;",Log._btn.onclick=Log.toggle,Browser.document.body.appendChild(Log._btn))}static toggle(){var style=Log._logdiv.style;""===style.display?(Log._btn.innerText="Show",style.display="none"):(Log._btn.innerText="Hide",style.display="")}static print(value){Log._logdiv&&(Log._count>=Log.maxCount&&Log.clear(),Log._count++,Log._logdiv.innerText+=value+"\n",Log.autoScrollToBottom&&Log._logdiv.scrollHeight-Log._logdiv.scrollTop-Log._logdiv.clientHeight<50&&(Log._logdiv.scrollTop=Log._logdiv.scrollHeight))}static clear(){Log._logdiv.innerText="",Log._count=0}}Log._count=0,Log.maxCount=50,Log.autoScrollToBottom=!0;let DATANUM=300;class PerfData{constructor(id,color,name,scale){this.scale=1,this.datas=new Array(DATANUM),this.datapos=0,this.id=id,this.color=color,this.name=name,this.scale=scale}addData(v){this.datas[this.datapos]=v,this.datapos++,this.datapos%=DATANUM}}class PerfHUD extends Sprite{constructor(){super(),this.datas=[],this.xdata=new Array(PerfHUD.DATANUM),this.ydata=new Array(PerfHUD.DATANUM),this.hud_width=800,this.hud_height=200,this.gMinV=0,this.gMaxV=100,this.textSpace=40,this.sttm=0,PerfHUD.inst=this,this._renderType|=SpriteConst.CUSTOM,this._setRenderType(this._renderType),this._setCustomRender(),this.addDataDef(0,16777215,"frame",1),this.addDataDef(1,65280,"update",1),this.addDataDef(2,16711680,"flush",1),PerfHUD._now=performance?performance.now.bind(performance):Date.now}now(){return PerfHUD._now()}start(){this.sttm=PerfHUD._now()}end(i){var dt=PerfHUD._now()-this.sttm;this.updateValue(i,dt)}config(w,h){this.hud_width=w,this.hud_height=h}addDataDef(id,color,name,scale){this.datas[id]=new PerfData(id,color,name,scale)}updateValue(id,v){this.datas[id].addData(v)}v2y(v){this._y,this.hud_height,this.gMinV,this.gMaxV;return this._y+this.hud_height*(1-(v-this.gMinV)/this.gMaxV)}drawHLine(ctx,v,color,text){var sx=this._x,sy=(this._x,this.hud_width,this.v2y(v));ctx.fillText(text,sx,sy-6,null,"green",null),sx+=this.textSpace,ctx.fillStyle=color,ctx.fillRect(sx,sy,this._x+this.hud_width,1,null)}customRender(ctx,x,y){var now=performance.now();PerfHUD._lastTm<=0&&(PerfHUD._lastTm=now),this.updateValue(0,now-PerfHUD._lastTm),PerfHUD._lastTm=now,ctx.save(),ctx.fillRect(this._x,this._y,this.hud_width,this.hud_height+4,"#000000cc"),ctx.globalAlpha=.9,this.drawHLine(ctx,0,"green"," 0"),this.drawHLine(ctx,10,"green"," 10"),this.drawHLine(ctx,16.667,"red"," "),this.drawHLine(ctx,20,"green","50|20"),this.drawHLine(ctx,33.334,"yellow",""),this.drawHLine(ctx,16.667*3,"yellow",""),this.drawHLine(ctx,66.668,"yellow",""),this.drawHLine(ctx,50,"green","20|50"),this.drawHLine(ctx,100,"green","10|100");for(var di=0,sz=this.datas.length;dithis.maxCount&&list.splice(this.maxCount,list.length-this.maxCount)}static addPoolCacheManager(sign,maxCount=100){var cache;(cache=new PoolCache).sign=sign,cache.maxCount=maxCount,CacheManger.regCacheByFunction(Utils.bind(cache.tryDispose,cache),Utils.bind(cache.getCacheList,cache))}}class TimeLine extends EventDispatcher{constructor(){super(...arguments),this._tweenDic={},this._tweenDataList=[],this._currTime=0,this._lastTime=0,this._startTime=0,this._index=0,this._gidIndex=0,this._firstTweenDic={},this._startTimeSort=!1,this._endTimeSort=!1,this._loopKey=!1,this.scale=1,this._frameRate=60,this._frameIndex=0,this._total=0}static to(target,props,duration,ease=null,offset=0){return(new TimeLine).to(target,props,duration,ease,offset)}static from(target,props,duration,ease=null,offset=0){return(new TimeLine).from(target,props,duration,ease,offset)}to(target,props,duration,ease=null,offset=0){return this._create(target,props,duration,ease,offset,!0)}from(target,props,duration,ease=null,offset=0){return this._create(target,props,duration,ease,offset,!1)}_create(target,props,duration,ease,offset,isTo){var tTweenData=Pool.getItemByClass("tweenData",tweenData);return tTweenData.isTo=isTo,tTweenData.type=0,tTweenData.target=target,tTweenData.duration=duration,tTweenData.data=props,tTweenData.startTime=this._startTime+offset,tTweenData.endTime=tTweenData.startTime+tTweenData.duration,tTweenData.ease=ease,this._startTime=Math.max(tTweenData.endTime,this._startTime),this._tweenDataList.push(tTweenData),this._startTimeSort=!0,this._endTimeSort=!0,this}addLabel(label,offset){var tTweenData=Pool.getItemByClass("tweenData",tweenData);return tTweenData.type=1,tTweenData.data=label,tTweenData.endTime=tTweenData.startTime=this._startTime+offset,this._labelDic||(this._labelDic={}),this._labelDic[label]=tTweenData,this._tweenDataList.push(tTweenData),this}removeLabel(label){if(this._labelDic&&this._labelDic[label]){var tTweenData=this._labelDic[label];if(tTweenData){var tIndex=this._tweenDataList.indexOf(tTweenData);tIndex>-1&&this._tweenDataList.splice(tIndex,1)}delete this._labelDic[label]}}gotoTime(time){if(null!=this._tweenDataList&&0!=this._tweenDataList.length){var tTween,tObject,tTweenDataCopyList,tTweenData;for(var p in this._firstTweenDic)if(tObject=this._firstTweenDic[p])for(var tDataP in tObject)tDataP in tObject.diyTarget&&(tObject.diyTarget[tDataP]=tObject[tDataP]);for(p in this._tweenDic)(tTween=this._tweenDic[p]).clear(),delete this._tweenDic[p];if(this._index=0,this._gidIndex=0,this._currTime=time,this._lastTime=Browser.now(),null==this._endTweenDataList||this._endTimeSort){this._endTimeSort=!1,this._endTweenDataList=tTweenDataCopyList=this._tweenDataList.concat(),tTweenDataCopyList.sort(function(paraA,paraB){return paraA.endTime>paraB.endTime?1:paraA.endTime=tTweenData.endTime))break;this._index=Math.max(this._index,i+1);var props=tTweenData.data;if(tTweenData.isTo)for(var tP in props)tTweenData.target[tP]=props[tP]}for(i=0,n=this._tweenDataList.length;i=tTweenData.startTime&&timeparaB.startTime?1:paraA.startTime=this._startTime){if(!this._loopKey){for(var p in this._tweenDic)(tTween=this._tweenDic[p]).complete();return this._complete(),void this.pause()}if(this._complete(),!this._tweenDataList)return;this.gotoTime(0)}var tTween,tNow=Browser.now(),tFrameTime=tNow-this._lastTime,tCurrTime=this._currTime+=tFrameTime*this.scale;for(p in this._lastTime=tNow,this._tweenDic)(tTween=this._tweenDic[p])._updateEase(tCurrTime);if(0!=this._tweenDataList.length&&this._index=tTweenData.startTime&&(this._index++,0==tTweenData.type?(this._gidIndex++,(tTween=Pool.getItemByClass("tween",Tween))._create(tTweenData.target,tTweenData.data,tTweenData.duration,tTweenData.ease,Handler.create(this,this._animComplete,[this._gidIndex]),0,!1,tTweenData.isTo,!0,!1),tTween.setStartTime(tCurrTime),tTween.gid=this._gidIndex,this._tweenDic[this._gidIndex]=tTween,tTween._updateEase(tCurrTime)):this.event(Event.LABEL,tTweenData.data))}}_animComplete(index){this._tweenDic[index]&&delete this._tweenDic[index]}_complete(){this.event(Event.COMPLETE)}get index(){return this._frameIndex}set index(value){this._frameIndex=value,this.gotoTime(this._frameIndex/this._frameRate*1e3)}get total(){return this._total=Math.floor(this._startTime/1e3*this._frameRate),this._total}reset(){var p,i,len;if(this._labelDic)for(p in this._labelDic)delete this._labelDic[p];for(p in this._tweenDic)this._tweenDic[p].clear(),delete this._tweenDic[p];for(p in this._firstTweenDic)delete this._firstTweenDic[p];if(this._endTweenDataList=null,this._tweenDataList&&this._tweenDataList.length)for(len=this._tweenDataList.length,i=0;i-1)return String.fromCharCode(ArabicReshaper.charsMap[j][0]);for(j=0;j-1)return String.fromCharCode(ArabicReshaper.combCharsMap[j][0][0])+String.fromCharCode(ArabicReshaper.combCharsMap[j][0][1]);return String.fromCharCode(code)}convertArabic(normal){for(var crep,combcrep,shaped="",i=0;i=0&&this.isTransparent(normal.charCodeAt(prevID));--prevID);for((!(crep=!!(prev=prevID>=0?normal.charCodeAt(prevID):null)&&this.getCharRep(prev))||null==crep[2]&&null==crep[3])&&(prev=null);nextID0?LayaGL.UPLOAD_SHADER_UNIFORM_TYPE_DATA:LayaGL.UPLOAD_SHADER_UNIFORM_TYPE_ID)}},exports.LayaGPU=LayaGPU,exports.Loader=Loader,exports.LoaderManager=LoaderManager,exports.LocalStorage=LocalStorage,exports.Log=Log,exports.MathUtil=MathUtil,exports.MatirxArray=MatirxArray,exports.Matrix=Matrix,exports.Mesh2D=Mesh2D,exports.MeshParticle2D=MeshParticle2D,exports.MeshQuadTexture=MeshQuadTexture,exports.MeshTexture=MeshTexture,exports.MeshVG=MeshVG,exports.Mouse=Mouse,exports.MouseManager=MouseManager,exports.Node=Node,exports.Path=Path,exports.PerfData=PerfData,exports.PerfHUD=PerfHUD,exports.Point=Point,exports.Pool=Pool,exports.PoolCache=PoolCache,exports.Prefab=Prefab,exports.PrimitiveSV=PrimitiveSV,exports.QuickTestTool=QuickTestTool,exports.Rectangle=Rectangle,exports.Render=Render,exports.RenderInfo=RenderInfo,exports.RenderSprite=RenderSprite,exports.RenderState2D=RenderState2D,exports.RenderTexture2D=RenderTexture2D,exports.Resource=Resource,exports.ResourceVersion=ResourceVersion,exports.RestoreCmd=RestoreCmd,exports.RotateCmd=RotateCmd,exports.RunDriver=RunDriver,exports.SaveBase=SaveBase,exports.SaveClipRect=SaveClipRect,exports.SaveCmd=SaveCmd,exports.SaveMark=SaveMark,exports.SaveTransform=SaveTransform,exports.SaveTranslate=SaveTranslate,exports.ScaleCmd=ScaleCmd,exports.Scene=Scene,exports.SceneLoader=SceneLoader,exports.SceneUtils=SceneUtils,exports.Script=Script,exports.Shader=Shader,exports.Shader2D=Shader2D,exports.Shader2X=Shader2X,exports.ShaderCompile=ShaderCompile,exports.ShaderDefines2D=ShaderDefines2D,exports.ShaderDefinesBase=ShaderDefinesBase,exports.ShaderNode=ShaderNode,exports.ShaderValue=class{constructor(){}},exports.SkinMeshBuffer=SkinMeshBuffer,exports.SkinSV=SkinSV,exports.Socket=Socket,exports.Sound=class extends EventDispatcher{load(url){}play(startTime=0,loops=0){return null}get duration(){return 0}dispose(){}},exports.SoundChannel=SoundChannel,exports.SoundManager=SoundManager,exports.SoundNode=class extends Sprite{constructor(){super(),this.visible=!1,this.on(Event.ADDED,this,this._onParentChange),this.on(Event.REMOVED,this,this._onParentChange)}_onParentChange(){this.target=this.parent}play(loops=1,complete=null){isNaN(loops)&&(loops=1),this.url&&(this.stop(),this._channel=SoundManager.playSound(this.url,loops,complete))}stop(){this._channel&&!this._channel.isStopped&&this._channel.stop(),this._channel=null}_setPlayAction(tar,event,action,add=!0){this[action]&&tar&&(add?tar.on(event,this,this[action]):tar.off(event,this,this[action]))}_setPlayActions(tar,events,action,add=!0){if(tar&&events){var i,len,eventArr=events.split(",");for(len=eventArr.length,i=0;i