laya-coreui-es
Version:
laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改
1 lines • 557 kB
JavaScript
"use strict";class ILaya{static regClass(t){ILaya.__classMap[t.name]=t}}ILaya.Laya=null,ILaya.Timer=null,ILaya.Dragging=null,ILaya.Sprite=null,ILaya.TextRender=null,ILaya.Loader=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.Pool=null,ILaya.Utils=null,ILaya.Graphics=null,ILaya.WorkerLoader=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.__classMap={};class Pool{static getPoolBySign(t){return Pool._poolDic[t]||(Pool._poolDic[t]=[])}static clearBySign(t){Pool._poolDic[t]&&(Pool._poolDic[t].length=0)}static recover(t,e){e[Pool.POOLSIGN]||(e[Pool.POOLSIGN]=!0,Pool.getPoolBySign(t).push(e))}static recoverByClass(t){if(t){var e=t.__className||t.constructor._$gid;e&&Pool.recover(e,t)}}static _getClassSign(t){var e=t.__className||t._$gid;return e||(t._$gid=e=Pool._CLSID+"",Pool._CLSID++),e}static createByClass(t){return Pool.getItemByClass(Pool._getClassSign(t),t)}static getItemByClass(t,e){if(!Pool._poolDic[t])return new e;var s=Pool.getPoolBySign(t);if(s.length){var i=s.pop();i[Pool.POOLSIGN]=!1}else i=new e;return i}static getItemByCreateFun(t,e,s=null){var i=Pool.getPoolBySign(t),r=i.length?i.pop():e.call(s);return r[Pool.POOLSIGN]=!1,r}static getItem(t){var e=Pool.getPoolBySign(t),s=e.length?e.pop():null;return s&&(s[Pool.POOLSIGN]=!1),s}}Pool._CLSID=0,Pool.POOLSIGN="__InPool",Pool._poolDic={};class AlphaCmd{static create(t){var e=Pool.getItemByClass("AlphaCmd",AlphaCmd);return e.alpha=t,e}recover(){Pool.recover("AlphaCmd",this)}run(t,e,s){t.alpha(this.alpha)}get cmdID(){return AlphaCmd.ID}}AlphaCmd.ID="Alpha";class DrawCircleCmd{static create(t,e,s,i,r,a,n){var h=Pool.getItemByClass("DrawCircleCmd",DrawCircleCmd);return h.x=t,h.y=e,h.radius=s,h.fillColor=i,h.lineColor=r,h.lineWidth=a,h.vid=n,h}recover(){this.fillColor=null,this.lineColor=null,Pool.recover("DrawCircleCmd",this)}run(t,e,s){t._drawCircle(this.x+e,this.y+s,this.radius,this.fillColor,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return DrawCircleCmd.ID}}DrawCircleCmd.ID="DrawCircle";class DrawCurvesCmd{static create(t,e,s,i,r){var a=Pool.getItemByClass("DrawCurvesCmd",DrawCurvesCmd);return a.x=t,a.y=e,a.points=s,a.lineColor=i,a.lineWidth=r,a}recover(){this.points=null,this.lineColor=null,Pool.recover("DrawCurvesCmd",this)}run(t,e,s){this.points&&t.drawCurves(this.x+e,this.y+s,this.points,this.lineColor,this.lineWidth)}get cmdID(){return DrawCurvesCmd.ID}}DrawCurvesCmd.ID="DrawCurves";class DrawImageCmd{static create(t,e,s,i,r){var a=Pool.getItemByClass("DrawImageCmd",DrawImageCmd);return a.texture=t,t._addReference(),a.x=e,a.y=s,a.width=i,a.height=r,a}recover(){this.texture&&this.texture._removeReference(),this.texture=null,Pool.recover("DrawImageCmd",this)}run(t,e,s){this.texture&&t.drawTexture(this.texture,this.x+e,this.y+s,this.width,this.height)}get cmdID(){return DrawImageCmd.ID}}DrawImageCmd.ID="DrawImage";class DrawLineCmd{static create(t,e,s,i,r,a,n){var h=Pool.getItemByClass("DrawLineCmd",DrawLineCmd);return h.fromX=t,h.fromY=e,h.toX=s,h.toY=i,h.lineColor=r,h.lineWidth=a,h.vid=n,h}recover(){Pool.recover("DrawLineCmd",this)}run(t,e,s){t._drawLine(e,s,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(t,e,s,i,r,a){var n=Pool.getItemByClass("DrawLinesCmd",DrawLinesCmd);return n.x=t,n.y=e,n.points=s,n.lineColor=i,n.lineWidth=r,n.vid=a,n}recover(){this.points=null,this.lineColor=null,Pool.recover("DrawLinesCmd",this)}run(t,e,s){this.points&&t._drawLines(this.x+e,this.y+s,this.points,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return DrawLinesCmd.ID}}DrawLinesCmd.ID="DrawLines";class DrawPathCmd{static create(t,e,s,i,r){var a=Pool.getItemByClass("DrawPathCmd",DrawPathCmd);return a.x=t,a.y=e,a.paths=s,a.brush=i,a.pen=r,a}recover(){this.paths=null,this.brush=null,this.pen=null,Pool.recover("DrawPathCmd",this)}run(t,e,s){this.paths&&t._drawPath(this.x+e,this.y+s,this.paths,this.brush,this.pen)}get cmdID(){return DrawPathCmd.ID}}DrawPathCmd.ID="DrawPath";class DrawPieCmd{static create(t,e,s,i,r,a,n,h,o){var l=Pool.getItemByClass("DrawPieCmd",DrawPieCmd);return l.x=t,l.y=e,l.radius=s,l._startAngle=i,l._endAngle=r,l.fillColor=a,l.lineColor=n,l.lineWidth=h,l.vid=o,l}recover(){this.fillColor=null,this.lineColor=null,Pool.recover("DrawPieCmd",this)}run(t,e,s){t._drawPie(this.x+e,this.y+s,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(t){this._startAngle=t*Math.PI/180}get endAngle(){return 180*this._endAngle/Math.PI}set endAngle(t){this._endAngle=t*Math.PI/180}}DrawPieCmd.ID="DrawPie";class DrawPolyCmd{static create(t,e,s,i,r,a,n,h){var o=Pool.getItemByClass("DrawPolyCmd",DrawPolyCmd);return o.x=t,o.y=e,o.points=s,o.fillColor=i,o.lineColor=r,o.lineWidth=a,o.isConvexPolygon=n,o.vid=h,o}recover(){this.points=null,this.fillColor=null,this.lineColor=null,Pool.recover("DrawPolyCmd",this)}run(t,e,s){this.points&&t._drawPoly(this.x+e,this.y+s,this.points,this.fillColor,this.lineColor,this.lineWidth,this.isConvexPolygon,this.vid)}get cmdID(){return DrawPolyCmd.ID}}DrawPolyCmd.ID="DrawPoly";class DrawRectCmd{static create(t,e,s,i,r,a,n){var h=Pool.getItemByClass("DrawRectCmd",DrawRectCmd);return h.x=t,h.y=e,h.width=s,h.height=i,h.fillColor=r,h.lineColor=a,h.lineWidth=n,h}recover(){this.fillColor=null,this.lineColor=null,Pool.recover("DrawRectCmd",this)}run(t,e,s){t.drawRect(this.x+e,this.y+s,this.width,this.height,this.fillColor,this.lineColor,this.lineWidth)}get cmdID(){return DrawRectCmd.ID}}DrawRectCmd.ID="DrawRect";class Matrix{constructor(t=1,e=0,s=0,i=1,r=0,a=0,n=0){if(this._bTransform=!1,null!=Matrix._createFun)return Matrix._createFun(t,e,s,i,r,a,n);this.a=t,this.b=e,this.c=s,this.d=i,this.tx=r,this.ty=a,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(t,e){return this.tx=t,this.ty=e,this}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this._bTransform=!0,this}rotate(t){var e=Math.cos(t),s=Math.sin(t),i=this.a,r=this.c,a=this.tx;return this.a=i*e-this.b*s,this.b=i*s+this.b*e,this.c=r*e-this.d*s,this.d=r*s+this.d*e,this.tx=a*e-this.ty*s,this.ty=a*s+this.ty*e,this._bTransform=!0,this}skew(t,e){var s=Math.tan(t),i=Math.tan(e),r=this.a,a=this.b;return this.a+=i*this.c,this.b+=i*this.d,this.c+=s*r,this.d+=s*a,this}invertTransformPoint(t){var e=this.a,s=this.b,i=this.c,r=this.d,a=this.tx,n=e*r-s*i,h=r/n,o=-s/n,l=-i/n,_=e/n,c=(i*this.ty-r*a)/n,u=-(e*this.ty-s*a)/n;return t.setTo(h*t.x+l*t.y+c,o*t.x+_*t.y+u)}transformPoint(t){return t.setTo(this.a*t.x+this.c*t.y+this.tx,this.b*t.x+this.d*t.y+this.ty)}transformPointN(t){return t.setTo(this.a*t.x+this.c*t.y,this.b*t.x+this.d*t.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 t=this.a,e=this.b,s=this.c,i=this.d,r=this.tx,a=t*i-e*s;return this.a=i/a,this.b=-e/a,this.c=-s/a,this.d=t/a,this.tx=(s*this.ty-i*r)/a,this.ty=-(t*this.ty-e*r)/a,this}setTo(t,e,s,i,r,a){return this.a=t,this.b=e,this.c=s,this.d=i,this.tx=r,this.ty=a,this}concat(t){var e=this.a,s=this.c,i=this.tx;return this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d,this.tx=i*t.a+this.ty*t.c+t.tx,this.ty=i*t.b+this.ty*t.d+t.ty,this}static mul(t,e,s){var i=t.a,r=t.b,a=t.c,n=t.d,h=t.tx,o=t.ty,l=e.a,_=e.b,c=e.c,u=e.d,d=e.tx,p=e.ty;return 0!==_||0!==c?(s.a=i*l+r*c,s.b=i*_+r*u,s.c=a*l+n*c,s.d=a*_+n*u,s.tx=l*h+c*o+d,s.ty=_*h+u*o+p):(s.a=i*l,s.b=r*u,s.c=a*l,s.d=n*u,s.tx=l*h+d,s.ty=u*o+p),s}static mul16(t,e,s){var i=t.a,r=t.b,a=t.c,n=t.d,h=t.tx,o=t.ty,l=e.a,_=e.b,c=e.c,u=e.d,d=e.tx,p=e.ty;return 0!==_||0!==c?(s[0]=i*l+r*c,s[1]=i*_+r*u,s[4]=a*l+n*c,s[5]=a*_+n*u,s[12]=l*h+c*o+d,s[13]=_*h+u*o+p):(s[0]=i*l,s[1]=r*u,s[4]=a*l,s[5]=n*u,s[12]=l*h+d,s[13]=u*o+p),s}scaleEx(t,e){var s=this.a,i=this.b,r=this.c,a=this.d;0!==i||0!==r?(this.a=t*s,this.b=t*i,this.c=e*r,this.d=e*a):(this.a=t*s,this.b=0*a,this.c=0*s,this.d=e*a),this._bTransform=!0}rotateEx(t){var e=Math.cos(t),s=Math.sin(t),i=this.a,r=this.b,a=this.c,n=this.d;0!==r||0!==a?(this.a=e*i+s*a,this.b=e*r+s*n,this.c=-s*i+e*a,this.d=-s*r+e*n):(this.a=e*i,this.b=s*n,this.c=-s*i,this.d=e*n),this._bTransform=!0}clone(){var t=Matrix.create();return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t._bTransform=this._bTransform,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t._bTransform=this._bTransform,t}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(t=0,e=0){this.x=t,this.y=e}static create(){return Pool.getItemByClass("Point",Point)}setTo(t,e){return this.x=t,this.y=e,this}reset(){return this.x=this.y=0,this}recover(){Pool.recover("Point",this.reset())}distance(t,e){return Math.sqrt((this.x-t)*(this.x-t)+(this.y-e)*(this.y-e))}toString(){return this.x+","+this.y}normalize(){var t=Math.sqrt(this.x*this.x+this.y*this.y);if(t>0){var e=1/t;this.x*=e,this.y*=e}}copy(t){return this.setTo(t.x,t.y)}}Point.TEMP=new Point,Point.EMPTY=new Point;class Rectangle{constructor(t=0,e=0,s=0,i=0){this.x=t,this.y=e,this.width=s,this.height=i}get right(){return this.x+this.width}get bottom(){return this.y+this.height}setTo(t,e,s,i){return this.x=t,this.y=e,this.width=s,this.height=i,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(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}contains(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<this.right&&e>=this.y&&e<this.bottom)}intersects(t){return!(t.x>this.x+this.width||t.x+t.width<this.x||t.y>this.y+this.height||t.y+t.height<this.y)}intersection(t,e=null){return this.intersects(t)?(e||(e=new Rectangle),e.x=Math.max(this.x,t.x),e.y=Math.max(this.y,t.y),e.width=Math.min(this.right,t.right)-e.x,e.height=Math.min(this.bottom,t.bottom)-e.y,e):null}union(t,e=null){return e||(e=new Rectangle),this.clone(e),t.width<=0||t.height<=0?e:(e.addPoint(t.x,t.y),e.addPoint(t.right,t.bottom),this)}clone(t=null){return t||(t=new Rectangle),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}toString(){return this.x+","+this.y+","+this.width+","+this.height}equals(t){return!(!t||t.x!==this.x||t.y!==this.y||t.width!==this.width||t.height!==this.height)}addPoint(t,e){return this.x>t&&(this.width+=this.x-t,this.x=t),this.y>e&&(this.height+=this.y-e,this.y=e),this.width<t-this.x&&(this.width=t-this.x),this.height<e-this.y&&(this.height=e-this.y),this}_getBoundPoints(){var t=Rectangle._temB;return t.length=0,0==this.width||0==this.height||t.push(this.x,this.y,this.x+this.width,this.y,this.x,this.y+this.height,this.x+this.width,this.y+this.height),t}static _getBoundPointS(t,e,s,i){var r=Rectangle._temA;return r.length=0,0==s||0==i||r.push(t,e,t+s,e,t,e+i,t+s,e+i),r}static _getWrapRec(t,e=null){if(!t||t.length<1)return e?e.setTo(0,0,0,0):Rectangle.TEMP.setTo(0,0,0,0);e=e||Rectangle.create();var s,i,r,a,n,h=t.length,o=Point.TEMP;for(r=n=-(i=a=99999),s=0;s<h;s+=2)o.x=t[s],o.y=t[s+1],i=i<o.x?i:o.x,a=a<o.y?a:o.y,r=r>o.x?r:o.x,n=n>o.y?n:o.y;return e.setTo(i,a,r-i,n-a)}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;var FilterMode,TextureFormat,WarpMode,RenderTextureFormat,RenderTextureDepthFormat,_sFactor=1,_dFactor=0;class WebGLContext{static __init__(){var t=LayaGL.instance;WebGLContext._depthFunc=t.LESS,WebGLContext._blendEquation=t.FUNC_ADD,WebGLContext._blendEquationRGB=t.FUNC_ADD,WebGLContext._blendEquationAlpha=t.FUNC_ADD,_sFactor=t.ONE,_dFactor=t.ZERO,WebGLContext._sFactorAlpha=t.ONE,WebGLContext._dFactorAlpha=t.ZERO,WebGLContext._activedTextureID=t.TEXTURE0;var e=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);WebGLContext._activeTextures=new Array(e),WebGLContext._glTextureIDs=[t.TEXTURE0,t.TEXTURE1,t.TEXTURE2,t.TEXTURE3,t.TEXTURE4,t.TEXTURE5,t.TEXTURE6,t.TEXTURE7,t.TEXTURE8,t.TEXTURE9,t.TEXTURE10,t.TEXTURE11,t.TEXTURE12,t.TEXTURE13,t.TEXTURE14,t.TEXTURE15,t.TEXTURE16,t.TEXTURE17,t.TEXTURE18,t.TEXTURE19,t.TEXTURE20,t.TEXTURE21,t.TEXTURE22,t.TEXTURE23,t.TEXTURE24,t.TEXTURE25,t.TEXTURE26,t.TEXTURE27,t.TEXTURE28,t.TEXTURE29,t.TEXTURE30,t.TEXTURE31];var s=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),i=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS);WebGLContext._maxUniformFragmentVectors=Math.min(s,i)}static useProgram(t,e){return WebGLContext._useProgram!==e&&(t.useProgram(e),WebGLContext._useProgram=e,!0)}static setDepthTest(t,e){e!==WebGLContext._depthTest&&(WebGLContext._depthTest=e,e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST))}static setDepthMask(t,e){e!==WebGLContext._depthMask&&(WebGLContext._depthMask=e,t.depthMask(e))}static setDepthFunc(t,e){e!==WebGLContext._depthFunc&&(WebGLContext._depthFunc=e,t.depthFunc(e))}static setBlend(t,e){e!==WebGLContext._blend&&(WebGLContext._blend=e,e?t.enable(t.BLEND):t.disable(t.BLEND))}static setBlendEquation(t,e){e!==WebGLContext._blendEquation&&(WebGLContext._blendEquation=e,WebGLContext._blendEquationRGB=WebGLContext._blendEquationAlpha=null,t.blendEquation(e))}static setBlendEquationSeparate(t,e,s){e===WebGLContext._blendEquationRGB&&s===WebGLContext._blendEquationAlpha||(WebGLContext._blendEquationRGB=e,WebGLContext._blendEquationAlpha=s,WebGLContext._blendEquation=null,t.blendEquationSeparate(e,s))}static setBlendFunc(t,e,s,i=!1){(i||e!==_sFactor||s!==_dFactor)&&(_sFactor=e,_dFactor=s,WebGLContext._sFactorRGB=null,WebGLContext._dFactorRGB=null,WebGLContext._sFactorAlpha=null,WebGLContext._dFactorAlpha=null,t.blendFunc(e,s))}static setBlendFuncSeperate(t,e,s,i,r){e===WebGLContext._sFactorRGB&&s===WebGLContext._dFactorRGB&&i===WebGLContext._sFactorAlpha&&r===WebGLContext._dFactorAlpha||(WebGLContext._sFactorRGB=e,WebGLContext._dFactorRGB=s,WebGLContext._sFactorAlpha=i,WebGLContext._dFactorAlpha=r,_sFactor=null,_dFactor=null,t.blendFuncSeparate(e,s,i,r))}static setCullFace(t,e){e!==WebGLContext._cullFace&&(WebGLContext._cullFace=e,e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE))}static setFrontFace(t,e){e!==WebGLContext._frontFace&&(WebGLContext._frontFace=e,t.frontFace(e))}static activeTexture(t,e){WebGLContext._activedTextureID!==e&&(t.activeTexture(e),WebGLContext._activedTextureID=e)}static bindTexture(t,e,s){WebGLContext._activeTextures[WebGLContext._activedTextureID-t.TEXTURE0]!==s&&(t.bindTexture(e,s),WebGLContext._activeTextures[WebGLContext._activedTextureID-t.TEXTURE0]=s)}static __init_native(){if(ILaya.Render.supportWebGLPlusRendering){var t=WebGLContext;t.activeTexture=t.activeTextureForNative,t.bindTexture=t.bindTextureForNative}}static useProgramForNative(t,e){return t.useProgram(e),!0}static setDepthTestForNative(t,e){e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST)}static setDepthMaskForNative(t,e){t.depthMask(e)}static setDepthFuncForNative(t,e){t.depthFunc(e)}static setBlendForNative(t,e){e?t.enable(t.BLEND):t.disable(t.BLEND)}static setBlendFuncForNative(t,e,s){t.blendFunc(e,s)}static setCullFaceForNative(t,e){e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE)}static setFrontFaceForNative(t,e){t.frontFace(e)}static activeTextureForNative(t,e){t.activeTexture(e)}static bindTextureForNative(t,e,s){t.bindTexture(e,s)}static bindVertexArrayForNative(t,e){t.bindVertexArray(e)}static getUniformMaxVector(){return WebGLContext._maxUniformFragmentVectors}}WebGLContext._activeTextures=new Array(1),WebGLContext._useProgram=null,WebGLContext._depthTest=!0,WebGLContext._depthMask=!0,WebGLContext._blend=!1,WebGLContext._cullFace=!1,WebGLContext.mainContext=null;class Handler{constructor(t=null,e=null,s=null,i=!1){this.once=!1,this._id=0,this.setTo(t,e,s,i)}setTo(t,e,s,i=!1){return this._id=Handler._gid++,this.caller=t,this.method=e,this.args=s,this.once=i,this}run(){if(null==this.method)return null;var t=this._id,e=this.method.apply(this.caller,this.args);return this._id===t&&this.once&&this.recover(),e}runWith(t){if(null==this.method)return null;var e=this._id;if(null==t)var s=this.method.apply(this.caller,this.args);else s=this.args||t.unshift?this.args?this.method.apply(this.caller,this.args.concat(t)):this.method.apply(this.caller,t):this.method.call(this.caller,t);return this._id===e&&this.once&&this.recover(),s}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(t,e,s=null,i=!0){return Handler._pool.length?Handler._pool.pop().setTo(t,e,s,i):new Handler(t,e,s,i)}}Handler._pool=[],Handler._gid=1;class EventDispatcher{hasListener(t){return!!(this._events&&this._events[t])}event(t,e=null){if(!this._events||!this._events[t])return!1;var s=this._events[t];if(s.run)s.once&&delete this._events[t],null!=e?s.runWith(e):s.run();else{for(var i=0,r=s.length;i<r;i++){var a=s[i];a&&(null!=e?a.runWith(e):a.run()),a&&!a.once||(s.splice(i,1),i--,r--)}0===s.length&&this._events&&delete this._events[t]}return!0}on(t,e,s,i=null){return this._createListener(t,e,s,i,!1)}once(t,e,s,i=null){return this._createListener(t,e,s,i,!0)}_createListener(t,e,s,i,r,a=!0){a&&this.off(t,e,s,r);var n=EventHandler.create(e||this,s,i,r);this._events||(this._events={});var h=this._events;return h[t]?h[t].run?h[t]=[h[t],n]:h[t].push(n):h[t]=n,this}off(t,e,s,i=!1){if(!this._events||!this._events[t])return this;var r=this._events[t];if(null!=r)if(r.run)e&&r.caller!==e||null!=s&&r.method!==s||i&&!r.once||(delete this._events[t],r.recover());else{for(var a=0,n=0,h=r.length;n<h;n++){var o=r[n];o?!o||e&&o.caller!==e||null!=s&&o.method!==s||i&&!o.once||(a++,r[n]=null,o.recover()):a++}a===h&&delete this._events[t]}return this}offAll(t=null){var e=this._events;if(!e)return this;if(t)this._recoverHandlers(e[t]),delete e[t];else{for(var s in e)this._recoverHandlers(e[s]);this._events=null}return this}offAllCaller(t){if(t&&this._events)for(var e in this._events)this.off(e,t,null);return this}_recoverHandlers(t){if(t)if(t.run)t.recover();else for(var e=t.length-1;e>-1;e--)t[e]&&(t[e].recover(),t[e]=null)}isMouseEvent(t){return EventDispatcher.MOUSE_EVENTS[t]||!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(t,e,s,i){super(t,e,s,i)}recover(){this._id>0&&(this._id=0,EventHandler._pool.push(this.clear()))}static create(t,e,s=null,i=!0){return EventHandler._pool.length?EventHandler._pool.pop().setTo(t,e,s,i):new EventHandler(t,e,s,i)}}EventHandler._pool=[];class URL{constructor(t){this._url=URL.formatURL(t),this._path=URL.getPath(t)}get url(){return this._url}get path(){return this._path}static set basePath(t){URL._basePath=ILaya.Laya._getUrlPath(),URL._basePath=URL.formatURL(t)}static get basePath(){return URL._basePath}static formatURL(t){if(!t)return"null path";if(t.indexOf(":")>0)return t;if(URL.exportSceneToJson&&(t=URL.getAdptedFilePath(t)),null!=URL.customFormat&&(t=URL.customFormat(t)),t.indexOf(":")>0)return t;var e=t.charAt(0);if("."===e)return URL._formatRelativePath(URL._basePath+t);if("~"===e)return URL.rootPath+t.substring(1);if("d"===e){if(0===t.indexOf("data:image"))return t}else if("/"===e)return t;return URL._basePath+t}static _formatRelativePath(t){for(var e=t.split("/"),s=0,i=e.length;s<i;s++)".."==e[s]&&(e.splice(s-1,2),s-=2);return e.join("/")}static getPath(t){var e=t.lastIndexOf("/");return e>0?t.substr(0,e+1):""}static getFileName(t){var e=t.lastIndexOf("/");return e>0?t.substr(e+1):t}static getAdptedFilePath(t){if(!URL.exportSceneToJson||!t)return t;var e,s,i;for(s=URL._adpteTypeList.length,e=0;e<s;e++)i=URL._adpteTypeList[e],t=t.replace(i[0],i[1]);return t}}URL.version={},URL.exportSceneToJson=!1,URL._basePath="",URL.rootPath="",URL.customFormat=function(t){var e=URL.version[t];return!window.conch&&e&&(t+="?v="+e),t},URL._adpteTypeList=[[".scene3d",".json"],[".scene",".json"],[".taa",".json"],[".prefab",".json"]];class Resource extends EventDispatcher{static get cpuMemory(){return Resource._cpuMemory}static get gpuMemory(){return Resource._gpuMemory}static _addCPUMemory(t){Resource._cpuMemory+=t}static _addGPUMemory(t){Resource._gpuMemory+=t}static _addMemory(t,e){Resource._cpuMemory+=t,Resource._gpuMemory+=e}static getResourceByID(t){return Resource._idResourcesMap[t]}static getResourceByURL(t,e=0){return Resource._urlResourcesMap[t][e]}static destroyUnusedResources(){for(var t in Resource._idResourcesMap){var e=Resource._idResourcesMap[t];e.lock||0!==e._referenceCount||e.destroy()}}get id(){return this._id}get url(){return this._url}get cpuMemory(){return this._cpuMemory}get gpuMemory(){return this._gpuMemory}get destroyed(){return this._destroyed}get referenceCount(){return this._referenceCount}constructor(){super(),this._id=0,this._url=null,this._cpuMemory=0,this._gpuMemory=0,this._destroyed=!1,this._referenceCount=0,this.lock=!1,this.name=null,this._id=++Resource._uniqueIDCounter,this._destroyed=!1,this._referenceCount=0,Resource._idResourcesMap[this.id]=this,this.lock=!1}_setCPUMemory(t){var e=t-this._cpuMemory;this._cpuMemory=t,Resource._addCPUMemory(e)}_setGPUMemory(t){var e=t-this._gpuMemory;this._gpuMemory=t,Resource._addGPUMemory(e)}_setCreateURL(t){var e;(t=URL.formatURL(t),this._url!==t)&&(this._url&&((e=Resource._urlResourcesMap[this._url]).splice(e.indexOf(this),1),0===e.length&&delete Resource._urlResourcesMap[this._url]),t&&((e=Resource._urlResourcesMap[t])||(Resource._urlResourcesMap[t]=e=[]),e.push(this)),this._url=t)}_addReference(t=1){this._referenceCount+=t}_removeReference(t=1){this._referenceCount-=t}_clearReference(){this._referenceCount=0}_recoverResource(){}_disposeResource(){}_activeResource(){}destroy(){var t;this._destroyed||(this._destroyed=!0,this.lock=!1,this._disposeResource(),delete Resource._idResourcesMap[this.id],this._url&&((t=Resource._urlResourcesMap[this._url])&&(t.splice(t.indexOf(this),1),0===t.length&&delete Resource._urlResourcesMap[this._url]),ILaya.Loader.loadedMap[this._url]==this&&delete ILaya.Loader.loadedMap[this._url]))}}Resource._uniqueIDCounter=0,Resource._idResourcesMap={},Resource._urlResourcesMap={},Resource._cpuMemory=0,Resource._gpuMemory=0;class Bitmap extends Resource{get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}constructor(){super(),this._width=-1,this._height=-1}_getSource(){throw"Bitmap: must override it."}}!function(t){t[t.Point=0]="Point",t[t.Bilinear=1]="Bilinear",t[t.Trilinear=2]="Trilinear"}(FilterMode||(FilterMode={})),function(t){t[t.R8G8B8=0]="R8G8B8",t[t.R8G8B8A8=1]="R8G8B8A8",t[t.R5G6B5=16]="R5G6B5",t[t.Alpha8=2]="Alpha8",t[t.DXT1=3]="DXT1",t[t.DXT5=4]="DXT5",t[t.ETC1RGB=5]="ETC1RGB",t[t.ETC2RGB=6]="ETC2RGB",t[t.ETC2RGBA=7]="ETC2RGBA",t[t.ETC2RGB_Alpha8=8]="ETC2RGB_Alpha8",t[t.ETC2SRGB=28]="ETC2SRGB",t[t.PVRTCRGB_2BPPV=9]="PVRTCRGB_2BPPV",t[t.PVRTCRGBA_2BPPV=10]="PVRTCRGBA_2BPPV",t[t.PVRTCRGB_4BPPV=11]="PVRTCRGB_4BPPV",t[t.PVRTCRGBA_4BPPV=12]="PVRTCRGBA_4BPPV",t[t.R32G32B32A32=15]="R32G32B32A32",t[t.R16G16B16A16=17]="R16G16B16A16",t[t.ASTC4x4=18]="ASTC4x4",t[t.ASTC4x4SRGB=23]="ASTC4x4SRGB",t[t.ASTC6x6=19]="ASTC6x6",t[t.ASTC6x6SRGB=24]="ASTC6x6SRGB",t[t.ASTC8x8=20]="ASTC8x8",t[t.ASTC8x8SRGB=25]="ASTC8x8SRGB",t[t.ASTC10x10=21]="ASTC10x10",t[t.ASTC10x10SRGB=26]="ASTC10x10SRGB",t[t.ASTC12x12=22]="ASTC12x12",t[t.ASTC12x12SRGB=27]="ASTC12x12SRGB",t[t.KTXTEXTURE=-1]="KTXTEXTURE",t[t.PVRTEXTURE=-2]="PVRTEXTURE"}(TextureFormat||(TextureFormat={})),function(t){t[t.Repeat=0]="Repeat",t[t.Clamp=1]="Clamp"}(WarpMode||(WarpMode={}));class BaseTexture extends Bitmap{get mipmap(){return this._mipmap}get format(){return this._format}get wrapModeU(){return this._wrapModeU}set wrapModeU(t){this._wrapModeU!==t&&(this._wrapModeU=t,-1!==this._width&&this._setWarpMode(LayaGL.instance.TEXTURE_WRAP_S,t))}get wrapModeV(){return this._wrapModeV}set wrapModeV(t){this._wrapModeV!==t&&(this._wrapModeV=t,-1!==this._height&&this._setWarpMode(LayaGL.instance.TEXTURE_WRAP_T,t))}get filterMode(){return this._filterMode}set filterMode(t){t!==this._filterMode&&(this._filterMode=t,-1!==this._width&&-1!==this._height&&this._setFilterMode(t))}get anisoLevel(){return this._anisoLevel}set anisoLevel(t){t!==this._anisoLevel&&(this._anisoLevel=Math.max(1,Math.min(16,t)),-1!==this._width&&-1!==this._height&&this._setAnisotropy(t))}get mipmapCount(){return this._mipmapCount}get defaulteTexture(){throw"BaseTexture:must override it."}constructor(t,e){super(),this._wrapModeU=WarpMode.Repeat,this._wrapModeV=WarpMode.Repeat,this._filterMode=FilterMode.Bilinear,this._readyed=!1,this._width=-1,this._height=-1,this._format=t,this._mipmap=e,this._anisoLevel=1,this._glTexture=LayaGL.instance.createTexture()}_getFormatByteCount(){switch(this._format){case TextureFormat.R8G8B8:return 3;case TextureFormat.R8G8B8A8:return 4;case TextureFormat.R5G6B5:case TextureFormat.Alpha8:return 1;case TextureFormat.R16G16B16A16:return 2;case TextureFormat.R32G32B32A32:return 4;default:throw"Texture2D: unknown format."}}_isPot(t){return 0==(t&t-1)}_getGLFormat(){var t,e=LayaGL.instance,s=LayaGL.layaGPUInstance;switch(this._format){case TextureFormat.R8G8B8:case TextureFormat.R5G6B5:t=e.RGB;break;case TextureFormat.R8G8B8A8:t=e.RGBA;break;case TextureFormat.Alpha8:t=e.ALPHA;break;case TextureFormat.R32G32B32A32:case TextureFormat.R16G16B16A16:t=e.RGBA;break;case TextureFormat.DXT1:if(!s._compressedTextureS3tc)throw"BaseTexture: not support DXT1 format.";t=s._compressedTextureS3tc.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case TextureFormat.DXT5:if(!s._compressedTextureS3tc)throw"BaseTexture: not support DXT5 format.";t=s._compressedTextureS3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;case TextureFormat.ETC1RGB:if(!s._compressedTextureEtc1)throw"BaseTexture: not support ETC1RGB format.";t=s._compressedTextureEtc1.COMPRESSED_RGB_ETC1_WEBGL;break;case TextureFormat.ETC2RGB:if(!s._compressedTextureETC)throw"BaseTexture: not support ETC2RGB format.";t=s._compressedTextureETC.COMPRESSED_RGB8_ETC2;break;case TextureFormat.ETC2RGBA:if(!s._compressedTextureETC)throw"BaseTexture: not support ETC2RGBA format.";t=s._compressedTextureETC.COMPRESSED_RGBA8_ETC2_EAC;break;case TextureFormat.ETC2RGB_Alpha8:if(!s._compressedTextureETC)throw"BaseTexture: not support ETC2SRGB_Alpha8 format.";t=s._compressedTextureETC.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;break;case TextureFormat.ETC2SRGB:if(!s._compressedTextureETC)throw"BaseTexture: not support ETC2SRGB format.";t=s._compressedTextureETC.COMPRESSED_SRGB8_ETC2;break;case TextureFormat.PVRTCRGB_2BPPV:if(!s._compressedTexturePvrtc)throw"BaseTexture: not support PVRTCRGB_2BPPV format.";t=s._compressedTexturePvrtc.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;break;case TextureFormat.PVRTCRGBA_2BPPV:if(!s._compressedTexturePvrtc)throw"BaseTexture: not support PVRTCRGBA_2BPPV format.";t=s._compressedTexturePvrtc.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;break;case TextureFormat.PVRTCRGB_4BPPV:if(!s._compressedTexturePvrtc)throw"BaseTexture: not support PVRTCRGB_4BPPV format.";t=s._compressedTexturePvrtc.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;break;case TextureFormat.PVRTCRGBA_4BPPV:if(!s._compressedTexturePvrtc)throw"BaseTexture: not support PVRTCRGBA_4BPPV format.";t=s._compressedTexturePvrtc.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;break;case TextureFormat.ASTC4x4:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC4x4 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_4x4_KHR;break;case TextureFormat.ASTC4x4SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC4x4_KHR format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case TextureFormat.ASTC6x6:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC6x6 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_6x6_KHR;break;case TextureFormat.ASTC6x6SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC6x6_KHR format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;break;case TextureFormat.ASTC8x8:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC8x8 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_8x8_KHR;break;case TextureFormat.ASTC8x8SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC8x8 format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;break;case TextureFormat.ASTC10x10:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC10x10 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_10x10_KHR;break;case TextureFormat.ASTC10x10SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC10x10 format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;break;case TextureFormat.ASTC12x12:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC12x12 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_12x12_KHR;break;case TextureFormat.ASTC12x12SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC12x12 format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;break;default:throw"BaseTexture: unknown texture format."}return t}_setFilterMode(t){var e=LayaGL.instance;switch(WebGLContext.bindTexture(e,this._glTextureType,this._glTexture),t){case FilterMode.Point:this._mipmap?e.texParameteri(this._glTextureType,e.TEXTURE_MIN_FILTER,e.NEAREST_MIPMAP_NEAREST):e.texParameteri(this._glTextureType,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(this._glTextureType,e.TEXTURE_MAG_FILTER,e.NEAREST);break;case FilterMode.Bilinear:this._mipmap?e.texParameteri(this._glTextureType,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST):e.texParameteri(this._glTextureType,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(this._glTextureType,e.TEXTURE_MAG_FILTER,e.LINEAR);break;case FilterMode.Trilinear:this._mipmap?e.texParameteri(this._glTextureType,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR):e.texParameteri(this._glTextureType,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(this._glTextureType,e.TEXTURE_MAG_FILTER,e.LINEAR);break;default:throw new Error("BaseTexture:unknown filterMode value.")}}_setWarpMode(t,e){var s=LayaGL.instance;if(WebGLContext.bindTexture(s,this._glTextureType,this._glTexture),this._isPot(this._width)&&this._isPot(this._height))switch(e){case WarpMode.Repeat:s.texParameteri(this._glTextureType,t,s.REPEAT);break;case WarpMode.Clamp:s.texParameteri(this._glTextureType,t,s.CLAMP_TO_EDGE)}else s.texParameteri(this._glTextureType,t,s.CLAMP_TO_EDGE)}_setAnisotropy(t){var e=LayaGL.layaGPUInstance._extTextureFilterAnisotropic;if(e){t=Math.max(t,1);var s=LayaGL.instance;WebGLContext.bindTexture(s,this._glTextureType,this._glTexture),t=Math.min(s.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT),t),s.texParameterf(this._glTextureType,e.TEXTURE_MAX_ANISOTROPY_EXT,t)}}_disposeResource(){this._glTexture&&(LayaGL.instance.deleteTexture(this._glTexture),this._glTexture=null,this._setGPUMemory(0))}_getSource(){return this._readyed?this._glTexture:null}generateMipmap(){this._isPot(this.width)&&this._isPot(this.height)&&LayaGL.instance.generateMipmap(this._glTextureType)}}BaseTexture._rgbmRange=5,BaseTexture.FORMAT_R8G8B8=0,BaseTexture.FORMAT_R8G8B8A8=1,BaseTexture.FORMAT_ALPHA8=2,BaseTexture.FORMAT_DXT1=3,BaseTexture.FORMAT_DXT5=4,BaseTexture.FORMAT_ETC1RGB=5,BaseTexture.FORMAT_PVRTCRGB_2BPPV=9,BaseTexture.FORMAT_PVRTCRGBA_2BPPV=10,BaseTexture.FORMAT_PVRTCRGB_4BPPV=11,BaseTexture.FORMAT_PVRTCRGBA_4BPPV=12,BaseTexture.RENDERTEXTURE_FORMAT_RGBA_HALF_FLOAT=14,BaseTexture.FORMAT_R32G32B32A32=15,BaseTexture.FORMAT_DEPTH_16=0,BaseTexture.FORMAT_STENCIL_8=1,BaseTexture.FORMAT_DEPTHSTENCIL_16_8=2,BaseTexture.FORMAT_DEPTHSTENCIL_NONE=3,BaseTexture.FILTERMODE_POINT=0,BaseTexture.FILTERMODE_BILINEAR=1,BaseTexture.FILTERMODE_TRILINEAR=2,BaseTexture.WARPMODE_REPEAT=0,BaseTexture.WARPMODE_CLAMP=1;class Byte{static getSystemEndian(){if(!Byte._sysEndian){var t=new ArrayBuffer(2);new DataView(t).setInt16(0,256,!0),Byte._sysEndian=256===new Int16Array(t)[0]?Byte.LITTLE_ENDIAN:Byte.BIG_ENDIAN}return Byte._sysEndian}constructor(t=null){this._xd_=!0,this._allocated_=8,this._pos_=0,this._length=0,t?(this._u8d_=new Uint8Array(t),this._d_=new DataView(this._u8d_.buffer),this._length=this._d_.byteLength):this._resizeBuffer(this._allocated_)}get buffer(){var t=this._d_.buffer;return t.byteLength===this._length?t:t.slice(0,this._length)}get endian(){return this._xd_?Byte.LITTLE_ENDIAN:Byte.BIG_ENDIAN}set endian(t){this._xd_=t===Byte.LITTLE_ENDIAN}set length(t){this._allocated_<t?this._resizeBuffer(this._allocated_=Math.floor(Math.max(t,2*this._allocated_))):this._allocated_>t&&this._resizeBuffer(this._allocated_=t),this._length=t}get length(){return this._length}_resizeBuffer(t){try{var e=new Uint8Array(t);null!=this._u8d_&&(this._u8d_.length<=t?e.set(this._u8d_):e.set(this._u8d_.subarray(0,t))),this._u8d_=e,this._d_=new DataView(e.buffer)}catch(e){throw"Invalid typed array length:"+t}}getString(){return this.readString()}readString(){return this._rUTF(this.getUint16())}getFloat32Array(t,e){return this.readFloat32Array(t,e)}readFloat32Array(t,e){var s=t+e;s=s>this._length?this._length:s;var i=new Float32Array(this._d_.buffer.slice(t,s));return this._pos_=s,i}getUint8Array(t,e){return this.readUint8Array(t,e)}readUint8Array(t,e){var s=t+e;s=s>this._length?this._length:s;var i=new Uint8Array(this._d_.buffer.slice(t,s));return this._pos_=s,i}getInt16Array(t,e){return this.readInt16Array(t,e)}readInt16Array(t,e){var s=t+e;s=s>this._length?this._length:s;var i=new Int16Array(this._d_.buffer.slice(t,s));return this._pos_=s,i}getFloat32(){return this.readFloat32()}readFloat32(){if(this._pos_+4>this._length)throw"getFloat32 error - Out of bounds";var t=this._d_.getFloat32(this._pos_,this._xd_);return this._pos_+=4,t}getFloat64(){return this.readFloat64()}readFloat64(){if(this._pos_+8>this._length)throw"getFloat64 error - Out of bounds";var t=this._d_.getFloat64(this._pos_,this._xd_);return this._pos_+=8,t}writeFloat32(t){this._ensureWrite(this._pos_+4),this._d_.setFloat32(this._pos_,t,this._xd_),this._pos_+=4}writeFloat64(t){this._ensureWrite(this._pos_+8),this._d_.setFloat64(this._pos_,t,this._xd_),this._pos_+=8}getInt32(){return this.readInt32()}readInt32(){if(this._pos_+4>this._length)throw"getInt32 error - Out of bounds";var t=this._d_.getInt32(this._pos_,this._xd_);return this._pos_+=4,t}getUint32(){return this.readUint32()}readUint32(){if(this._pos_+4>this._length)throw"getUint32 error - Out of bounds";var t=this._d_.getUint32(this._pos_,this._xd_);return this._pos_+=4,t}writeInt32(t){this._ensureWrite(this._pos_+4),this._d_.setInt32(this._pos_,t,this._xd_),this._pos_+=4}writeUint32(t){this._ensureWrite(this._pos_+4),this._d_.setUint32(this._pos_,t,this._xd_),this._pos_+=4}getInt16(){return this.readInt16()}readInt16(){if(this._pos_+2>this._length)throw"getInt16 error - Out of bounds";var t=this._d_.getInt16(this._pos_,this._xd_);return this._pos_+=2,t}getUint16(){return this.readUint16()}readUint16(){if(this._pos_+2>this._length)throw"getUint16 error - Out of bounds";var t=this._d_.getUint16(this._pos_,this._xd_);return this._pos_+=2,t}writeUint16(t){this._ensureWrite(this._pos_+2),this._d_.setUint16(this._pos_,t,this._xd_),this._pos_+=2}writeInt16(t){this._ensureWrite(this._pos_+2),this._d_.setInt16(this._pos_,t,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(t){this._ensureWrite(this._pos_+1),this._d_.setUint8(this._pos_,t),this._pos_++}_getUInt8(t){return this._readUInt8(t)}_readUInt8(t){return this._d_.getUint8(t)}_getUint16(t){return this._readUint16(t)}_readUint16(t){return this._d_.getUint16(t,this._xd_)}_getMatrix(){return this._readMatrix()}_readMatrix(){return new Matrix(this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32())}_rUTF(t){var e,s,i=this._pos_+t,r=String.fromCharCode,a=this._u8d_,n=[],h=0;for(n.length=1e3;this._pos_<i;)if((e=a[this._pos_++])<128)0!=e&&(n[h++]=r(e));else if(e<224)n[h++]=r((63&e)<<6|127&a[this._pos_++]);else if(e<240)s=a[this._pos_++],n[h++]=r((31&e)<<12|(127&s)<<6|127&a[this._pos_++]);else{const t=(15&e)<<18|(127&(s=a[this._pos_++]))<<12|(127&a[this._pos_++])<<6|127&a[this._pos_++];if(t>=65536){const e=t-65536,s=55296|e>>10,i=56320|1023&e;n[h++]=r(s),n[h++]=r(i)}else n[h++]=r(t)}return n.length=h,n.join("")}getCustomString(t){return this.readCustomString(t)}readCustomString(t){for(var e,s="",i=0,r=String.fromCharCode,a=this._u8d_;t>0;)if((e=a[this._pos_])<128)s+=r(e),this._pos_++,t--;else for(i=e-128,this._pos_++,t-=i;i>0;)e=a[this._pos_++],s+=r(a[this._pos_++]<<8|e),i--;return s}get pos(){return this._pos_}set pos(t){this._pos_=t}get bytesAvailable(){return this._length-this._pos_}clear(){this._pos_=0,this.length=0}__getBuffer(){return this._d_.buffer}writeUTFBytes(t){for(var e=0,s=(t+="").length;e<s;e++){var i=t.charCodeAt(e);if(i<=127)this.writeByte(i);else if(i<=2047)this._ensureWrite(this._pos_+2),this._u8d_.set([192|i>>6,128|63&i],this._pos_),this._pos_+=2;else if(i>=55296&&i<=56319){e++;const s=t.charCodeAt(e);if(!Number.isNaN(s)&&s>=56320&&s<=57343){const t=64+(1023&i),e=1023&s,r=240|t>>8&63,a=128|t>>2&63,n=128|(3&t)<<4|e>>6&15,h=128|63&e;this._ensureWrite(this._pos_+4),this._u8d_.set([r,a,n,h],this._pos_),this._pos_+=4}}else i<=65535?(this._ensureWrite(this._pos_+3),this._u8d_.set([224|i>>12,128|i>>6&63,128|63&i],this._pos_),this._pos_+=3):(this._ensureWrite(this._pos_+4),this._u8d_.set([240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i],this._pos_),this._pos_+=4)}}writeUTFString(t){var e=this.pos;this.writeUint16(1),this.writeUTFBytes(t);var s=this.pos-e-2;this._d_.setUint16(e,s,this._xd_)}writeUTFString32(t){var e=this.pos;this.writeUint32(1),this.writeUTFBytes(t);var s=this.pos-e-4;this._d_.setUint32(e,s,this._xd_)}readUTFString(){return this.readUTFBytes(this.getUint16())}readUTFString32(){return this.readUTFBytes(this.getUint32())}getUTFString(){return this.readUTFString()}readUTFBytes(t=-1){if(0===t)return"";var e=this.bytesAvailable;if(t>e)throw"readUTFBytes error - Out of bounds";return t=t>0?t:e,this._rUTF(t)}getUTFBytes(t=-1){return this.readUTFBytes(t)}writeByte(t){this._ensureWrite(this._pos_+1),this._d_.setInt8(this._pos_,t),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(t){this._length<t&&(this._length=t),this._allocated_<t&&(this.length=t)}writeArrayBuffer(t,e=0,s=0){if(e<0||s<0)throw"writeArrayBuffer error - Out of bounds";0==s&&(s=t.byteLength-e),this._ensureWrite(this._pos_+s);var i=new Uint8Array(t);this._u8d_.set(i.subarray(e,e+s),this._pos_),this._pos_+=s}readArrayBuffer(t){var e;return e=this._u8d_.buffer.slice(this._pos_,this._pos_+t),this._pos_=this._pos_+t,e}}Byte.BIG_ENDIAN="bigEndian",Byte.LITTLE_ENDIAN="littleEndian",Byte._sysEndian=null,function(t){t[t.R8G8B8=0]="R8G8B8",t[t.R8G8B8A8=1]="R8G8B8A8",t[t.Alpha8=2]="Alpha8",t[t.R16G16B16A16=14]="R16G16B16A16",t[t.Depth=15]="Depth",t[t.ShadowMap=16]="ShadowMap"}(RenderTextureFormat||(RenderTextureFormat={})),function(t){t[t.DEPTH_16=0]="DEPTH_16",t[t.STENCIL_8=1]="STENCIL_8",t[t.DEPTHSTENCIL_24_8=2]="DEPTHSTENCIL_24_8",t[t.DEPTHSTENCIL_NONE=3]="DEPTHSTENCIL_NONE",t[t.DEPTHSTENCIL_16_8=2]="DEPTHSTENCIL_16_8"}(RenderTextureDepthFormat||(RenderTextureDepthFormat={}));class SystemUtils{static get maxTextureCount(){return this._maxTextureCount}static get maxTextureSize(){return this._maxTextureSize}static get shaderCapailityLevel(){return this._shaderCapailityLevel}static supportTextureFormat(t){switch(t){case TextureFormat.R32G32B32A32:return!(!LayaGL.layaGPUInstance._isWebGL2&&!LayaGL.layaGPUInstance._oesTextureFloat);case TextureFormat.R16G16B16A16:return!(!LayaGL.layaGPUInstance._isWebGL2&&!LayaGL.layaGPUInstance._oesTextureHalfFloat);default:return!0}}static supportRenderTextureFormat(t){switch(t){case RenderTextureFormat.R16G16B16A16:return!!(LayaGL.layaGPUInstance._isWebGL2&&LayaGL.layaGPUInstance._extColorBufferFloat||LayaGL.layaGPUInstance._oesTextureHalfFloat&&LayaGL.layaGPUInstance._oesTextureHalfFloatLinear);case RenderTextureFormat.Depth:return!(!LayaGL.layaGPUInstance._isWebGL2&&!LayaGL.layaGPUInstance._webgl_depth_texture);case RenderTextureFormat.ShadowMap:return!!LayaGL.layaGPUInstance._isWebGL2;default:return!0}}}class HalfFloatUtils{static __init__(){for(var t=0;t<256;++t){var e=t-127;e<-27?(HalfFloatUtils._baseTable[0|t]=0,HalfFloatUtils._baseTable[256|t]=32768,HalfFloatUtils._shiftTable[0|t]=24,HalfFloatUtils._shiftTable[256|t]=24):e<-14?(HalfFloatUtils._baseTable[0|t]=1024>>-e-14,HalfFloatUtils._baseTable[256|t]=1024>>-e-14|32768,HalfFloatUtils._shiftTable[0|t]=-e-1,HalfFloatUtils._shiftTable[256|t]=-e-1):e<=15?(HalfFloatUtils._baseTable[0|t]=e+15<<10,HalfFloatUtils._baseTable[256|t]=e+15<<10|32768,HalfFloatUtils._shiftTable[0|t]=13,HalfFloatUtils._shiftTable[256|t]=13):e<128?(HalfFloatUtils._baseTable[0|t]=31744,HalfFloatUtils._baseTable[256|t]=64512,HalfFloatUtils._shiftTable[0|t]=24,HalfFloatUtils._shiftTable[256|t]=24):(HalfFloatUtils._baseTable[0|t]=31744,HalfFloatUtils._baseTable[256|t]=64512,HalfFloatUtils._shiftTable[0|t]=13,HalfFloatUtils._shiftTable[256|t]=13)}for(HalfFloatUtils._mantissaTable[0]=0,t=1;t<1024;++t){var s=t<<13;for(e=0;0==(8388608&s);)e-=8388608,s<<=1;s&=-8388609,e+=947912704,HalfFloatUtils._mantissaTable[t]=s|e}for(t=1024;t<2048;++t)HalfFloatUtils._mantissaTable[t]=939524096+(t-1024<<13);for(HalfFloatUtils._exponentTable[0]=0,t=1;t<31;++t)HalfFloatUtils._exponentTable[t]=t<<23;for(HalfFloatUtils._exponentTable[31]=1199570944,HalfFloatUtils._exponentTable[32]=2147483648,t=33;t<63;++t)HalfFloatUtils._exponentTable[t]=2147483648+(t-32<<23);for(HalfFloatUtils._exponentTable[63]=3347054592,HalfFloatUtils._offsetTable[0]=0,t=1;t<64;++t)HalfFloatUtils._offsetTable[t]=32===t?0:1024}static roundToFloat16Bits(t){HalfFloatUtils._floatView[0]=t;var e=HalfFloatUtils._uint32View[0],s=e>>23&511;return HalfFloatUtils._baseTable[s]+((8388607&e)>>HalfFloatUtils._shiftTable[s])}static convertToNumber(t){var e=t>>10;return HalfFloatUtils._uint32View[0]=HalfFloatUtils._mantissaTable[HalfFloatUtils._offsetTable[e]+(1023&t)]+HalfFloatUtils._exponentTable[e],HalfFloatUtils._floatView[0]}}HalfFloatUtils._buffer=new ArrayBuffer(4),HalfFloatUtils._floatView=new Float32Array(HalfFloatUtils._buffer),HalfFloatUtils._uint32View=new Uint32Array(HalfFloatUtils._buffer),HalfFloatUtils._baseTable=new Uint32Array(512),HalfFloatUtils._shiftTable=new Uint32Array(512),HalfFloatUtils._mantissaTable=new Uint32Array(2048),HalfFloatUtils._exponentTable=new Uint32Array(64),HalfFloatUtils._offsetTable=new Uint32Array(64);class Texture2D extends BaseTexture{static __init__(){var t=new Uint8Array(3);t[0]=128,t[1]=128,t[2]=128,Texture2D.grayTexture=new Texture2D(1,1,TextureFormat.R8G8B8,!1,!1),Texture2D.grayTexture.setPixels(t),Texture2D.grayTexture.lock=!0,t[0]=255,t[1]=255,t[2]=255,Texture2D.whiteTexture=new Texture2D(1,1,TextureFormat.R8G8B8,!1,!1),Texture2D.whiteTexture.setPixels(t),Texture2D.whiteTexture.lock=!0,t[0]=0,t[1]=0,t[2]=0,Texture2D.blackTexture=new Texture2D(1,1,TextureFormat.R8G8B8,!1,!1),Texture2D.blackTexture.setPixels(t),Texture2D.blackTexture.lock=!0,Texture2D.erroTextur=Texture2D.whiteTexture}static _parse(t,e=null,s=null){var i=s?new Texture2D(s[0],s[1],s[2],s[3],s[4]):new Texture2D(0,0);switch(e&&(i.wrapModeU=e.wrapModeU,i.wrapModeV=e.wrapModeV,i.filterMode=e.filterMode,i.anisoLevel=e.anisoLevel),i._format){case TextureFormat.R8G8B8:case TextureFormat.R8G8B8A8:i.loadImageSource(t);break;case TextureFormat.DXT1:case TextureFormat.DXT5:case TextureFormat.ETC1RGB:case TextureFormat.PVRTCRGB_2BPPV:case TextureFormat.PVRTCRGBA_2BPPV:case TextureFormat.PVRTCRGB_4BPPV:case TextureFormat.PVRTCRGBA_4BPPV:case TextureFormat.ETC2RGB:case TextureFormat.ETC2RGBA:case TextureFormat.ETC2SRGB:case TextureFormat.ASTC4x4:case TextureFormat.ASTC6x6:case TextureFormat.ASTC8x8:case TextureFormat.ASTC10x10:case TextureFormat.ASTC12x12:case TextureFormat.KTXTEXTURE:case TextureFormat.PVRTEXTURE:i.setCompressData(t);break;default:throw"Texture2D:unkonwn format."}return i}static _SimpleAnimatorTextureParse(t,e=null,s=null){var i,r,a=new Byte(t);switch(a.readUTFString()){case"LAYAANIMATORTEXTURE:0000":var n,h=a.readInt32(),o=a.readInt32();i=new Float32Array(h*h*4),r=new Float32Array(a.readArrayBuffer(4*o)),i.set(r,0),(n=new Texture2D(h,h,TextureFormat.R32G32B32A32,!1,!1)).setPixels(i,0),n.filterMode=FilterMode.Point;break;case"LAYACOMPRESSANIMATORTEXTURE:0000":h=a.readInt32(),o=a.readInt32();if(i=new Uint16Array(a.readArrayBuffer(2*o)),SystemUtils.supportTextureFormat(TextureFormat.R16G16B16A16))(r=new Uint16Array(h*h*4)).set(i,0),(n=new Texture2D(h,h,TextureFormat.R16G16B16A16,!1,!1)).setPixels(r,0),n.filterMode=FilterMode.Point;else{console.log("The platform does not support 16-bit floating-point textures"),SystemUtils.supportTextureFormat(TextureFormat.R32G32B32A32)||console.error("The platform does not support 32-bit floating-point textures"),r=new Float32Array(h*h*4);for(var l=0,_=i.length;l<_;l++)r[l]=HalfFloatUtils.convertToNumber(i[l]);(n=new Texture2D(h,h,TextureFormat.R32G32B32A32,!1,!1)).setPixels(r,0),n.filterMode=FilterMode.Point}break;default:throw"Laya3D:unknow version."}return n}static load(t,e){ILaya.loader.create(t,e,null,ILaya.Loader.TEXTURE2D)}get defaulteTexture(){return Texture2D.grayTexture}constructor(t=0,e=0,s=TextureFormat.R8G8B8A8,i=!0,r=!1){super(s,i);var a=LayaGL.instance;this._glTextureType=a.TEXTURE_2D,this._width=t,this._height=e,this._canRead=r,this._setWarpMode(a.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(a.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),this._setAnisotropy(this._anisoLevel);var n=this._gpuCompressFormat();if(i){var h=Math.max(Math.ceil(Math.log2(t))+1,Math.ceil(Math.log2(e))+1);if(!n)for(var o=0;o<h;o++)this._setPixels(null,o,Math.max(t>>o,1),Math.max(e>>o,1));this._mipmapCount=h,this._setGPUMemory(t*e*4*(1+1/3))}else n||this._setPixels(null,0,t,e),this._mipmapCount=1,this._setGPUMemory(t*e*4)}_gpuCompressFormat(){return this._format!=TextureFormat.R8G8B8A8&&this._format!=TextureFormat.R8G8B8&&this._format!=TextureFormat.R16G16B16A16&&this._format!=TextureFormat.R32G32B32A32&&this._format!=TextureFormat.R5G6B5&&this._format!=TextureFormat.Alpha8}_setPixels(t,e,s,i){var r=LayaGL.instance,a=this._glTextureType,n=this._getGLFormat();switch(WebGLContext.bindTexture(r,a,this._glTexture),this.format){case TextureFormat.R8G8B8:r.pixelStorei(r.UNPACK_ALIGNMENT,1),r.texImage2D(a,e,n,s,i,0,n,r.UNSIGNED_BYTE,t),r.pixelStorei(r.UNPACK_ALIGNMENT,4);break;case TextureFormat.R5G6B5:r.pixelStorei(r.UNPACK_ALIGNMENT,2),r.texImage2D(a,e,n,s,i,0,n,r.UNSIGNED_SHORT_5_6_5,t),r.pixelStorei(r.UNPACK_ALIGNMENT,4);break;case TextureFormat.R32G32B32A32:LayaGL.layaGPUInstance._isWebGL2?r.texImage2D(a,e,r.RGBA32F,s,i,0,n,r.FLOAT,t):r.texImage2D(a,e,r.RGBA,s,i,0,n,r.FLOAT,t);break;case TextureFormat.R16G16B16A16:LayaGL.layaGPUInstance._isWebGL2?r.texImage2D(a,e,r.RGBA16F,s,i,0,n,r.HALF_FLOAT,t):r.texImage2D(a,e,r.RGBA,s,i,0,n,LayaGL.layaGPUInstance._oesTextureHalfFloat.HALF_FLOAT_OES,t);break;default:r.texImage2D(a,e,n,s,i,0,n,r.UNSIGNED_BYTE,t)}}_calcualatesCompressedDataSize(t,e,s){switch(t){case TextureFormat.DXT1:return(e+3>>2)*(s+3>>2)*8;case TextureFormat.DXT5:return(e+3>>2)*(s+3>>2)*16;case TextureFormat.PVRTCRGB_4BPPV:case TextureFormat.PVRTCRGBA_4BPPV:return Math.floor((Math.max(e,8)*Math.max(s,8)*4+7)/8);case TextureFormat.PVRTCRGB_2BPPV:case TextureFormat.PVRTCRGBA_2BPPV:return Math.floor((Math.max(e,16)*Math.max(s,8)*2+7)/8);default:return 0}}_pharseDDS(t){var e=new Int32Array(t,0,31);if(542327876!=e[0])throw"Invalid magic number in DDS header";if(!(4&e[20]))throw"Unsupported format, must contain a FourCC code";var s=e[21];switch(this._format){case TextureFormat.DXT1:if(827611204!==s)throw"the FourCC code is not same with texture format.";break;case TextureFormat.DXT5:if(894720068!==s)throw"the FourCC code is not same with texture format.";break;default:throw"unknown texture format."}var i=1;if(131072&e[2]){if(i=Math.max(1,e[7]),!this._mipmap)throw"the mipmap is not same with Texture2D."}else if(this._mipmap)throw"the mipmap is not same with Texture2D.";var r=e[4],a=e[3];this._width=r,this._height=a;var n=e[1]+4;this._upLoadCompressedTexImage2D(t,r,a,i,n,0)}_pharseKTX(t){var e=new Uint8Array(t,0,12);if(171!=e[0]||75!=e[1]||84!=e[2]||88!=e[3]||32!=e[4]||49!=e[5]||49!=e[6]||187!=e[7]||13!=e[8]||10!=e[9]||26!=e[10]||10!=e[11])throw"Invalid fileIdentifier in KTX header";var s=new Int32Array(e.buffer,e.length,13),i=s[4];if(this._format=-1,LayaGL.layaGPUInstance._compressedTextureASTC)switch(i){case LayaGL.layaGPUInstance._compressed