UNPKG

laya-coreui-es

Version:

laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改

1 lines 519 kB
!function(t){"use strict";class e{static regClass(t){e.__classMap[t.name]=t}}e.Laya=null,e.Timer=null,e.Dragging=null,e.Sprite=null,e.TextRender=null,e.Loader=null,e.ShaderCompile=null,e.ClassUtils=null,e.SceneUtils=null,e.Context=null,e.Render=null,e.MouseManager=null,e.Text=null,e.Browser=null,e.Pool=null,e.Utils=null,e.Graphics=null,e.WorkerLoader=null,e.TextAtlas=null,e.timer=null,e.systemTimer=null,e.startTimer=null,e.updateTimer=null,e.lateTimer=null,e.physicsTimer=null,e.stage=null,e.loader=null,e.__classMap={};class s{static getPoolBySign(t){return s._poolDic[t]||(s._poolDic[t]=[])}static clearBySign(t){s._poolDic[t]&&(s._poolDic[t].length=0)}static recover(t,e){e[s.POOLSIGN]||(e[s.POOLSIGN]=!0,s.getPoolBySign(t).push(e))}static recoverByClass(t){if(t){var e=t.__className||t.constructor._$gid;e&&s.recover(e,t)}}static _getClassSign(t){var e=t.__className||t._$gid;return e||(t._$gid=e=s._CLSID+"",s._CLSID++),e}static createByClass(t){return s.getItemByClass(s._getClassSign(t),t)}static getItemByClass(t,e){if(!s._poolDic[t])return new e;var i=s.getPoolBySign(t);if(i.length){var r=i.pop();r[s.POOLSIGN]=!1}else r=new e;return r}static getItemByCreateFun(t,e,i=null){var r=s.getPoolBySign(t),a=r.length?r.pop():e.call(i);return a[s.POOLSIGN]=!1,a}static getItem(t){var e=s.getPoolBySign(t),i=e.length?e.pop():null;return i&&(i[s.POOLSIGN]=!1),i}}s._CLSID=0,s.POOLSIGN="__InPool",s._poolDic={};class i{static create(t){var e=s.getItemByClass("AlphaCmd",i);return e.alpha=t,e}recover(){s.recover("AlphaCmd",this)}run(t,e,s){t.alpha(this.alpha)}get cmdID(){return i.ID}}i.ID="Alpha";class r{static create(t,e,i,a,h,n,l){var o=s.getItemByClass("DrawCircleCmd",r);return o.x=t,o.y=e,o.radius=i,o.fillColor=a,o.lineColor=h,o.lineWidth=n,o.vid=l,o}recover(){this.fillColor=null,this.lineColor=null,s.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 r.ID}}r.ID="DrawCircle";class a{static create(t,e,i,r,h){var n=s.getItemByClass("DrawCurvesCmd",a);return n.x=t,n.y=e,n.points=i,n.lineColor=r,n.lineWidth=h,n}recover(){this.points=null,this.lineColor=null,s.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 a.ID}}a.ID="DrawCurves";class h{static create(t,e,i,r,a){var n=s.getItemByClass("DrawImageCmd",h);return n.texture=t,t._addReference(),n.x=e,n.y=i,n.width=r,n.height=a,n}recover(){this.texture&&this.texture._removeReference(),this.texture=null,s.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 h.ID}}h.ID="DrawImage";class n{static create(t,e,i,r,a,h,l){var o=s.getItemByClass("DrawLineCmd",n);return o.fromX=t,o.fromY=e,o.toX=i,o.toY=r,o.lineColor=a,o.lineWidth=h,o.vid=l,o}recover(){s.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 n.ID}}n.ID="DrawLine";class l{static create(t,e,i,r,a,h){var n=s.getItemByClass("DrawLinesCmd",l);return n.x=t,n.y=e,n.points=i,n.lineColor=r,n.lineWidth=a,n.vid=h,n}recover(){this.points=null,this.lineColor=null,s.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 l.ID}}l.ID="DrawLines";class o{static create(t,e,i,r,a){var h=s.getItemByClass("DrawPathCmd",o);return h.x=t,h.y=e,h.paths=i,h.brush=r,h.pen=a,h}recover(){this.paths=null,this.brush=null,this.pen=null,s.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 o.ID}}o.ID="DrawPath";class _{static create(t,e,i,r,a,h,n,l,o){var c=s.getItemByClass("DrawPieCmd",_);return c.x=t,c.y=e,c.radius=i,c._startAngle=r,c._endAngle=a,c.fillColor=h,c.lineColor=n,c.lineWidth=l,c.vid=o,c}recover(){this.fillColor=null,this.lineColor=null,s.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 _.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}}_.ID="DrawPie";class c{static create(t,e,i,r,a,h,n,l){var o=s.getItemByClass("DrawPolyCmd",c);return o.x=t,o.y=e,o.points=i,o.fillColor=r,o.lineColor=a,o.lineWidth=h,o.isConvexPolygon=n,o.vid=l,o}recover(){this.points=null,this.fillColor=null,this.lineColor=null,s.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 c.ID}}c.ID="DrawPoly";class u{static create(t,e,i,r,a,h,n){var l=s.getItemByClass("DrawRectCmd",u);return l.x=t,l.y=e,l.width=i,l.height=r,l.fillColor=a,l.lineColor=h,l.lineWidth=n,l}recover(){this.fillColor=null,this.lineColor=null,s.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 u.ID}}u.ID="DrawRect";class d{constructor(t=1,e=0,s=0,i=1,r=0,a=0,h=0){if(this._bTransform=!1,null!=d._createFun)return d._createFun(t,e,s,i,r,a,h);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,h=e*r-s*i,n=r/h,l=-s/h,o=-i/h,_=e/h,c=(i*this.ty-r*a)/h,u=-(e*this.ty-s*a)/h;return t.setTo(n*t.x+o*t.y+c,l*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,h=t.d,n=t.tx,l=t.ty,o=e.a,_=e.b,c=e.c,u=e.d,d=e.tx,p=e.ty;return 0!==_||0!==c?(s.a=i*o+r*c,s.b=i*_+r*u,s.c=a*o+h*c,s.d=a*_+h*u,s.tx=o*n+c*l+d,s.ty=_*n+u*l+p):(s.a=i*o,s.b=r*u,s.c=a*o,s.d=h*u,s.tx=o*n+d,s.ty=u*l+p),s}static mul16(t,e,s){var i=t.a,r=t.b,a=t.c,h=t.d,n=t.tx,l=t.ty,o=e.a,_=e.b,c=e.c,u=e.d,d=e.tx,p=e.ty;return 0!==_||0!==c?(s[0]=i*o+r*c,s[1]=i*_+r*u,s[4]=a*o+h*c,s[5]=a*_+h*u,s[12]=o*n+c*l+d,s[13]=_*n+u*l+p):(s[0]=i*o,s[1]=r*u,s[4]=a*o,s[5]=h*u,s[12]=o*n+d,s[13]=u*l+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,h=this.d;0!==r||0!==a?(this.a=e*i+s*a,this.b=e*r+s*h,this.c=-s*i+e*a,this.d=-s*r+e*h):(this.a=e*i,this.b=s*h,this.c=-s*i,this.d=e*h),this._bTransform=!0}clone(){var t=d.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(){s.recover("Matrix",this.identity())}static create(){return s.getItemByClass("Matrix",d)}}d.EMPTY=new d,d.TEMP=new d,d._createFun=null;class p{constructor(t=0,e=0){this.x=t,this.y=e}static create(){return s.getItemByClass("Point",p)}setTo(t,e){return this.x=t,this.y=e,this}reset(){return this.x=this.y=0,this}recover(){s.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)}}p.TEMP=new p,p.EMPTY=new p;class g{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!=g.TEMP&&this!=g.EMPTY?s.recover("Rectangle",this.reset()):console.log("recover Temp or Empty:",this)}static create(){return s.getItemByClass("Rectangle",g)}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 g),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 g),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 g),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=g._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=g._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):g.TEMP.setTo(0,0,0,0);e=e||g.create();var s,i,r,a,h,n=t.length,l=p.TEMP;for(r=h=-(i=a=99999),s=0;s<n;s+=2)l.x=t[s],l.y=t[s+1],i=i<l.x?i:l.x,a=a<l.y?a:l.y,r=r>l.x?r:l.x,h=h>l.y?h:l.y;return e.setTo(i,a,r-i,h-a)}isEmpty(){return this.width<=0||this.height<=0}}g.EMPTY=new g,g.TEMP=new g,g._temB=[],g._temA=[];class f{}f.ARRAY_BUFFER_TYPE_DATA=0,f.ARRAY_BUFFER_TYPE_CMD=1,f.ARRAY_BUFFER_REF_REFERENCE=0,f.ARRAY_BUFFER_REF_COPY=1,f.UPLOAD_SHADER_UNIFORM_TYPE_ID=0,f.UPLOAD_SHADER_UNIFORM_TYPE_DATA=1;var m,v,x,T,y,C=1,E=0;class b{static __init__(){var t=f.instance;b._depthFunc=t.LESS,b._blendEquation=t.FUNC_ADD,b._blendEquationRGB=t.FUNC_ADD,b._blendEquationAlpha=t.FUNC_ADD,C=t.ONE,E=t.ZERO,b._sFactorAlpha=t.ONE,b._dFactorAlpha=t.ZERO,b._activedTextureID=t.TEXTURE0;var e=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);b._activeTextures=new Array(e),b._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);b._maxUniformFragmentVectors=Math.min(s,i)}static useProgram(t,e){return b._useProgram!==e&&(t.useProgram(e),b._useProgram=e,!0)}static setDepthTest(t,e){e!==b._depthTest&&(b._depthTest=e,e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST))}static setDepthMask(t,e){e!==b._depthMask&&(b._depthMask=e,t.depthMask(e))}static setDepthFunc(t,e){e!==b._depthFunc&&(b._depthFunc=e,t.depthFunc(e))}static setBlend(t,e){e!==b._blend&&(b._blend=e,e?t.enable(t.BLEND):t.disable(t.BLEND))}static setBlendEquation(t,e){e!==b._blendEquation&&(b._blendEquation=e,b._blendEquationRGB=b._blendEquationAlpha=null,t.blendEquation(e))}static setBlendEquationSeparate(t,e,s){e===b._blendEquationRGB&&s===b._blendEquationAlpha||(b._blendEquationRGB=e,b._blendEquationAlpha=s,b._blendEquation=null,t.blendEquationSeparate(e,s))}static setBlendFunc(t,e,s,i=!1){(i||e!==C||s!==E)&&(C=e,E=s,b._sFactorRGB=null,b._dFactorRGB=null,b._sFactorAlpha=null,b._dFactorAlpha=null,t.blendFunc(e,s))}static setBlendFuncSeperate(t,e,s,i,r){e===b._sFactorRGB&&s===b._dFactorRGB&&i===b._sFactorAlpha&&r===b._dFactorAlpha||(b._sFactorRGB=e,b._dFactorRGB=s,b._sFactorAlpha=i,b._dFactorAlpha=r,C=null,E=null,t.blendFuncSeparate(e,s,i,r))}static setCullFace(t,e){e!==b._cullFace&&(b._cullFace=e,e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE))}static setFrontFace(t,e){e!==b._frontFace&&(b._frontFace=e,t.frontFace(e))}static activeTexture(t,e){b._activedTextureID!==e&&(t.activeTexture(e),b._activedTextureID=e)}static bindTexture(t,e,s){b._activeTextures[b._activedTextureID-t.TEXTURE0]!==s&&(t.bindTexture(e,s),b._activeTextures[b._activedTextureID-t.TEXTURE0]=s)}static __init_native(){if(e.Render.supportWebGLPlusRendering){var t=b;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 b._maxUniformFragmentVectors}}b._activeTextures=new Array(1),b._useProgram=null,b._depthTest=!0,b._depthMask=!0,b._blend=!1,b._cullFace=!1,b.mainContext=null;class S{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=S._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,S._pool.push(this.clear()))}static create(t,e,s=null,i=!0){return S._pool.length?S._pool.pop().setTo(t,e,s,i):new S(t,e,s,i)}}S._pool=[],S._gid=1;class w{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 h=R.create(e||this,s,i,r);this._events||(this._events={});var n=this._events;return n[t]?n[t].run?n[t]=[n[t],h]:n[t].push(h):n[t]=h,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,h=0,n=r.length;h<n;h++){var l=r[h];l?!l||e&&l.caller!==e||null!=s&&l.method!==s||i&&!l.once||(a++,r[h]=null,l.recover()):a++}a===n&&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 w.MOUSE_EVENTS[t]||!1}}w.MOUSE_EVENTS={rightmousedown:!0,rightmouseup:!0,rightclick:!0,mousedown:!0,mouseup:!0,mousemove:!0,mouseover:!0,mouseout:!0,click:!0,doubleclick:!0};class R extends S{constructor(t,e,s,i){super(t,e,s,i)}recover(){this._id>0&&(this._id=0,R._pool.push(this.clear()))}static create(t,e,s=null,i=!0){return R._pool.length?R._pool.pop().setTo(t,e,s,i):new R(t,e,s,i)}}R._pool=[];class A{constructor(t){this._url=A.formatURL(t),this._path=A.getPath(t)}get url(){return this._url}get path(){return this._path}static set basePath(t){A._basePath=e.Laya._getUrlPath(),A._basePath=A.formatURL(t)}static get basePath(){return A._basePath}static formatURL(t){if(!t)return"null path";if(t.indexOf(":")>0)return t;if(A.exportSceneToJson&&(t=A.getAdptedFilePath(t)),null!=A.customFormat&&(t=A.customFormat(t)),t.indexOf(":")>0)return t;var e=t.charAt(0);if("."===e)return A._formatRelativePath(A._basePath+t);if("~"===e)return A.rootPath+t.substring(1);if("d"===e){if(0===t.indexOf("data:image"))return t}else if("/"===e)return t;return A._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(!A.exportSceneToJson||!t)return t;var e,s,i;for(s=A._adpteTypeList.length,e=0;e<s;e++)i=A._adpteTypeList[e],t=t.replace(i[0],i[1]);return t}}A.version={},A.exportSceneToJson=!1,A._basePath="",A.rootPath="",A.customFormat=function(t){var e=A.version[t];return!window.conch&&e&&(t+="?v="+e),t},A._adpteTypeList=[[".scene3d",".json"],[".scene",".json"],[".taa",".json"],[".prefab",".json"]];class M extends w{static get cpuMemory(){return M._cpuMemory}static get gpuMemory(){return M._gpuMemory}static _addCPUMemory(t){M._cpuMemory+=t}static _addGPUMemory(t){M._gpuMemory+=t}static _addMemory(t,e){M._cpuMemory+=t,M._gpuMemory+=e}static getResourceByID(t){return M._idResourcesMap[t]}static getResourceByURL(t,e=0){return M._urlResourcesMap[t][e]}static destroyUnusedResources(){for(var t in M._idResourcesMap){var e=M._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=++M._uniqueIDCounter,this._destroyed=!1,this._referenceCount=0,M._idResourcesMap[this.id]=this,this.lock=!1}_setCPUMemory(t){var e=t-this._cpuMemory;this._cpuMemory=t,M._addCPUMemory(e)}_setGPUMemory(t){var e=t-this._gpuMemory;this._gpuMemory=t,M._addGPUMemory(e)}_setCreateURL(t){var e;(t=A.formatURL(t),this._url!==t)&&(this._url&&((e=M._urlResourcesMap[this._url]).splice(e.indexOf(this),1),0===e.length&&delete M._urlResourcesMap[this._url]),t&&((e=M._urlResourcesMap[t])||(M._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 M._idResourcesMap[this.id],this._url&&((t=M._urlResourcesMap[this._url])&&(t.splice(t.indexOf(this),1),0===t.length&&delete M._urlResourcesMap[this._url]),e.Loader.loadedMap[this._url]==this&&delete e.Loader.loadedMap[this._url]))}}M._uniqueIDCounter=0,M._idResourcesMap={},M._urlResourcesMap={},M._cpuMemory=0,M._gpuMemory=0;class I extends M{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"}(m||(m={})),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"}(v||(v={})),function(t){t[t.Repeat=0]="Repeat",t[t.Clamp=1]="Clamp"}(x||(x={}));class P extends I{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(f.instance.TEXTURE_WRAP_S,t))}get wrapModeV(){return this._wrapModeV}set wrapModeV(t){this._wrapModeV!==t&&(this._wrapModeV=t,-1!==this._height&&this._setWarpMode(f.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=x.Repeat,this._wrapModeV=x.Repeat,this._filterMode=m.Bilinear,this._readyed=!1,this._width=-1,this._height=-1,this._format=t,this._mipmap=e,this._anisoLevel=1,this._glTexture=f.instance.createTexture()}_getFormatByteCount(){switch(this._format){case v.R8G8B8:return 3;case v.R8G8B8A8:return 4;case v.R5G6B5:case v.Alpha8:return 1;case v.R16G16B16A16:return 2;case v.R32G32B32A32:return 4;default:throw"Texture2D: unknown format."}}_isPot(t){return 0==(t&t-1)}_getGLFormat(){var t,e=f.instance,s=f.layaGPUInstance;switch(this._format){case v.R8G8B8:case v.R5G6B5:t=e.RGB;break;case v.R8G8B8A8:t=e.RGBA;break;case v.Alpha8:t=e.ALPHA;break;case v.R32G32B32A32:case v.R16G16B16A16:t=e.RGBA;break;case v.DXT1:if(!s._compressedTextureS3tc)throw"BaseTexture: not support DXT1 format.";t=s._compressedTextureS3tc.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case v.DXT5:if(!s._compressedTextureS3tc)throw"BaseTexture: not support DXT5 format.";t=s._compressedTextureS3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;case v.ETC1RGB:if(!s._compressedTextureEtc1)throw"BaseTexture: not support ETC1RGB format.";t=s._compressedTextureEtc1.COMPRESSED_RGB_ETC1_WEBGL;break;case v.ETC2RGB:if(!s._compressedTextureETC)throw"BaseTexture: not support ETC2RGB format.";t=s._compressedTextureETC.COMPRESSED_RGB8_ETC2;break;case v.ETC2RGBA:if(!s._compressedTextureETC)throw"BaseTexture: not support ETC2RGBA format.";t=s._compressedTextureETC.COMPRESSED_RGBA8_ETC2_EAC;break;case v.ETC2RGB_Alpha8:if(!s._compressedTextureETC)throw"BaseTexture: not support ETC2SRGB_Alpha8 format.";t=s._compressedTextureETC.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;break;case v.ETC2SRGB:if(!s._compressedTextureETC)throw"BaseTexture: not support ETC2SRGB format.";t=s._compressedTextureETC.COMPRESSED_SRGB8_ETC2;break;case v.PVRTCRGB_2BPPV:if(!s._compressedTexturePvrtc)throw"BaseTexture: not support PVRTCRGB_2BPPV format.";t=s._compressedTexturePvrtc.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;break;case v.PVRTCRGBA_2BPPV:if(!s._compressedTexturePvrtc)throw"BaseTexture: not support PVRTCRGBA_2BPPV format.";t=s._compressedTexturePvrtc.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;break;case v.PVRTCRGB_4BPPV:if(!s._compressedTexturePvrtc)throw"BaseTexture: not support PVRTCRGB_4BPPV format.";t=s._compressedTexturePvrtc.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;break;case v.PVRTCRGBA_4BPPV:if(!s._compressedTexturePvrtc)throw"BaseTexture: not support PVRTCRGBA_4BPPV format.";t=s._compressedTexturePvrtc.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;break;case v.ASTC4x4:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC4x4 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_4x4_KHR;break;case v.ASTC4x4SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC4x4_KHR format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case v.ASTC6x6:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC6x6 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_6x6_KHR;break;case v.ASTC6x6SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC6x6_KHR format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;break;case v.ASTC8x8:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC8x8 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_8x8_KHR;break;case v.ASTC8x8SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC8x8 format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;break;case v.ASTC10x10:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC10x10 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_10x10_KHR;break;case v.ASTC10x10SRGB:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC10x10 format.";t=s._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;break;case v.ASTC12x12:if(!s._compressedTextureASTC)throw"BaseTexture: not support ASTC12x12 format.";t=s._compressedTextureASTC.COMPRESSED_RGBA_ASTC_12x12_KHR;break;case v.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=f.instance;switch(b.bindTexture(e,this._glTextureType,this._glTexture),t){case m.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 m.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 m.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=f.instance;if(b.bindTexture(s,this._glTextureType,this._glTexture),this._isPot(this._width)&&this._isPot(this._height))switch(e){case x.Repeat:s.texParameteri(this._glTextureType,t,s.REPEAT);break;case x.Clamp:s.texParameteri(this._glTextureType,t,s.CLAMP_TO_EDGE)}else s.texParameteri(this._glTextureType,t,s.CLAMP_TO_EDGE)}_setAnisotropy(t){var e=f.layaGPUInstance._extTextureFilterAnisotropic;if(e){t=Math.max(t,1);var s=f.instance;b.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&&(f.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)&&f.instance.generateMipmap(this._glTextureType)}}P._rgbmRange=5,P.FORMAT_R8G8B8=0,P.FORMAT_R8G8B8A8=1,P.FORMAT_ALPHA8=2,P.FORMAT_DXT1=3,P.FORMAT_DXT5=4,P.FORMAT_ETC1RGB=5,P.FORMAT_PVRTCRGB_2BPPV=9,P.FORMAT_PVRTCRGBA_2BPPV=10,P.FORMAT_PVRTCRGB_4BPPV=11,P.FORMAT_PVRTCRGBA_4BPPV=12,P.RENDERTEXTURE_FORMAT_RGBA_HALF_FLOAT=14,P.FORMAT_R32G32B32A32=15,P.FORMAT_DEPTH_16=0,P.FORMAT_STENCIL_8=1,P.FORMAT_DEPTHSTENCIL_16_8=2,P.FORMAT_DEPTHSTENCIL_NONE=3,P.FILTERMODE_POINT=0,P.FILTERMODE_BILINEAR=1,P.FILTERMODE_TRILINEAR=2,P.WARPMODE_REPEAT=0,P.WARPMODE_CLAMP=1;class L{static getSystemEndian(){if(!L._sysEndian){var t=new ArrayBuffer(2);new DataView(t).setInt16(0,256,!0),L._sysEndian=256===new Int16Array(t)[0]?L.LITTLE_ENDIAN:L.BIG_ENDIAN}return L._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_?L.LITTLE_ENDIAN:L.BIG_ENDIAN}set endian(t){this._xd_=t===L.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 d(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_,h=[],n=0;for(h.length=1e3;this._pos_<i;)if((e=a[this._pos_++])<128)0!=e&&(h[n++]=r(e));else if(e<224)h[n++]=r((63&e)<<6|127&a[this._pos_++]);else if(e<240)s=a[this._pos_++],h[n++]=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;h[n++]=r(s),h[n++]=r(i)}else h[n++]=r(t)}return h.length=n,h.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,h=128|(3&t)<<4|e>>6&15,n=128|63&e;this._ensureWrite(this._pos_+4),this._u8d_.set([r,a,h,n],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}}L.BIG_ENDIAN="bigEndian",L.LITTLE_ENDIAN="littleEndian",L._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"}(T||(T={})),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"}(y||(y={}));class B{static get maxTextureCount(){return this._maxTextureCount}static get maxTextureSize(){return this._maxTextureSize}static get shaderCapailityLevel(){return this._shaderCapailityLevel}static supportTextureFormat(t){switch(t){case v.R32G32B32A32:return!(!f.layaGPUInstance._isWebGL2&&!f.layaGPUInstance._oesTextureFloat);case v.R16G16B16A16:return!(!f.layaGPUInstance._isWebGL2&&!f.layaGPUInstance._oesTextureHalfFloat);default:return!0}}static supportRenderTextureFormat(t){switch(t){case T.R16G16B16A16:return!!(f.layaGPUInstance._isWebGL2&&f.layaGPUInstance._extColorBufferFloat||f.layaGPUInstance._oesTextureHalfFloat&&f.layaGPUInstance._oesTextureHalfFloatLinear);case T.Depth:return!(!f.layaGPUInstance._isWebGL2&&!f.layaGPUInstance._webgl_depth_texture);case T.ShadowMap:return!!f.layaGPUInstance._isWebGL2;default:return!0}}}class D{static __init__(){for(var t=0;t<256;++t){var e=t-127;e<-27?(D._baseTable[0|t]=0,D._baseTable[256|t]=32768,D._shiftTable[0|t]=24,D._shiftTable[256|t]=24):e<-14?(D._baseTable[0|t]=1024>>-e-14,D._baseTable[256|t]=1024>>-e-14|32768,D._shiftTable[0|t]=-e-1,D._shiftTable[256|t]=-e-1):e<=15?(D._baseTable[0|t]=e+15<<10,D._baseTable[256|t]=e+15<<10|32768,D._shiftTable[0|t]=13,D._shiftTable[256|t]=13):e<128?(D._baseTable[0|t]=31744,D._baseTable[256|t]=64512,D._shiftTable[0|t]=24,D._shiftTable[256|t]=24):(D._baseTable[0|t]=31744,D._baseTable[256|t]=64512,D._shiftTable[0|t]=13,D._shiftTable[256|t]=13)}for(D._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,D._mantissaTable[t]=s|e}for(t=1024;t<2048;++t)D._mantissaTable[t]=939524096+(t-1024<<13);for(D._exponentTable[0]=0,t=1;t<31;++t)D._exponentTable[t]=t<<23;for(D._exponentTable[31]=1199570944,D._exponentTable[32]=2147483648,t=33;t<63;++t)D._exponentTable[t]=2147483648+(t-32<<23);for(D._exponentTable[63]=3347054592,D._offsetTable[0]=0,t=1;t<64;++t)D._offsetTable[t]=32===t?0:1024}static roundToFloat16Bits(t){D._floatView[0]=t;var e=D._uint32View[0],s=e>>23&511;return D._baseTable[s]+((8388607&e)>>D._shiftTable[s])}static convertToNumber(t){var e=t>>10;return D._uint32View[0]=D._mantissaTable[D._offsetTable[e]+(1023&t)]+D._exponentTable[e],D._floatView[0]}}D._buffer=new ArrayBuffer(4),D._floatView=new Float32Array(D._buffer),D._uint32View=new Uint32Array(D._buffer),D._baseTable=new Uint32Array(512),D._shiftTable=new Uint32Array(512),D._mantissaTable=new Uint32Array(2048),D._exponentTable=new Uint32Array(64),D._offsetTable=new Uint32Array(64);class O extends P{static __init__(){var t=new Uint8Array(3);t[0]=128,t[1]=128,t[2]=128,O.grayTexture=new O(1,1,v.R8G8B8,!1,!1),O.grayTexture.setPixels(t),O.grayTexture.lock=!0,t[0]=255,t[1]=255,t[2]=255,O.whiteTexture=new O(1,1,v.R8G8B8,!1,!1),O.whiteTexture.setPixels(t),O.whiteTexture.lock=!0,t[0]=0,t[1]=0,t[2]=0,O.blackTexture=new O(1,1,v.R8G8B8,!1,!1),O.blackTexture.setPixels(t),O.blackTexture.lock=!0,O.erroTextur=O.whiteTexture}static _parse(t,e=null,s=null){var i=s?new O(s[0],s[1],s[2],s[3],s[4]):new O(0,0);switch(e&&(i.wrapModeU=e.wrapModeU,i.wrapModeV=e.wrapModeV,i.filterMode=e.filterMode,i.anisoLevel=e.anisoLevel),i._format){case v.R8G8B8:case v.R8G8B8A8:i.loadImageSource(t);break;case v.DXT1:case v.DXT5:case v.ETC1RGB:case v.PVRTCRGB_2BPPV:case v.PVRTCRGBA_2BPPV:case v.PVRTCRGB_4BPPV:case v.PVRTCRGBA_4BPPV:case v.ETC2RGB:case v.ETC2RGBA:case v.ETC2SRGB:case v.ASTC4x4:case v.ASTC6x6:case v.ASTC8x8:case v.ASTC10x10:case v.ASTC12x12:case v.KTXTEXTURE:case v.PVRTEXTURE:i.setCompressData(t);break;default:throw"Texture2D:unkonwn format."}return i}static _SimpleAnimatorTextureParse(t,e=null,s=null){var i,r,a=new L(t);switch(a.readUTFString()){case"LAYAANIMATORTEXTURE:0000":var h,n=a.readInt32(),l=a.readInt32();i=new Float32Array(n*n*4),r=new Float32Array(a.readArrayBuffer(4*l)),i.set(r,0),(h=new O(n,n,v.R32G32B32A32,!1,!1)).setPixels(i,0),h.filterMode=m.Point;break;case"LAYACOMPRESSANIMATORTEXTURE:0000":n=a.readInt32(),l=a.readInt32();if(i=new Uint16Array(a.readArrayBuffer(2*l)),B.supportTextureFormat(v.R16G16B16A16))(r=new Uint16Array(n*n*4)).set(i,0),(h=new O(n,n,v.R16G16B16A16,!1,!1)).setPixels(r,0),h.filterMode=m.Point;else{console.log("The platform does not support 16-bit floating-point textures"),B.supportTextureFormat(v.R32G32B32A32)||console.error("The platform does not support 32-bit floating-point textures"),r=new Float32Array(n*n*4);for(var o=0,_=i.length;o<_;o++)r[o]=D.convertToNumber(i[o]);(h=new O(n,n,v.R32G32B32A32,!1,!1)).setPixels(r,0),h.filterMode=m.Point}break;default:throw"Laya3D:unknow version."}return h}static load(t,s){e.loader.create(t,s,null,e.Loader.TEXTURE2D)}get defaulteTexture(){return O.grayTexture}constructor(t=0,e=0,s=v.R8G8B8A8,i=!0,r=!1){super(s,i);var a=f.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 h=this._gpuCompressFormat();if(i){var n=Math.max(Math.ceil(Math.log2(t))+1,Math.ceil(Math.log2(e))+1);if(!h)for(var l=0;l<n;l++)this._setPixels(null,l,Math.max(t>>l,1),Math.max(e>>l,1));this._mipmapCount=n,this._setGPUMemory(t*e*4*(1+1/3))}else h||this._setPixels(null,0,t,e),this._mipmapCount=1,this._setGPUMemory(t*e*4)}_gpuCompressFormat(){return this._format!=v.R8G8B8A8&&this._format!=v.R8G8B8&&this._format!=v.R16G16B16A16&&this._format!=v.R32G32B32A32&&this._format!=v.R5G6B5&&this._format!=v.Alpha8}_setPixels(t,e,s,i){var r=f.instance,a=this._glTextureType,h=this._getGLFormat();switch(b.bindTexture(r,a,this._glTexture),this.format){case v.R8G8B8:r.pixelStorei(r.UNPACK_ALIGNMENT,1),r.texImage2D(a,e,h,s,i,0,h,r.UNSIGNED_BYTE,t),r.pixelStorei(r.UNPACK_ALIGNMENT,4);break;case v.R5G6B5:r.pixelStorei(r.UNPACK_ALIGNMENT,2),r.texImage2D(a,e,h,s,i,0,h,r.UNSIGNED_SHORT_5_6_5,t),r.pixelStorei(r.UNPACK_ALIGNMENT,4);break;case v.R32G32B32A32:f.layaGPUInstance._isWebGL2?r.texImage2D(a,e,r.RGBA32F,s,i,0,h,r.FLOAT,t):r.texImage2D(a,e,r.RGBA,s,i,0,h,r.FLOAT,t);break;case v.R16G16B16A16:f.layaGPUInstance._isWebGL2?r.texImage2D(a,e,r.RGBA16F,s,i,0,h,r.HALF_FLOAT,t):r.texImage2D(a,e,r.RGBA,s,i,0,h,f.layaGPUInstance._oesTextureHalfFloat.HALF_FLOAT_OES,t);break;default:r.texImage2D(a,e,h,s,i,0,h,r.UNSIGNED_BYTE,t)}}_calcualatesCompressedDataSize(t,e,s){switch(t){case v.DXT1:return(e+3>>2)*(s+3>>2)*8;case v.DXT5:return(e+3>>2)*(s+3>>2)*16;case v.PVRTCRGB_4BPPV:case v.PVRTCRGBA_4BPPV:return Math.floor((Math.max(e,8)*Math.max(s,8)*4+7)/8);case v.PVRTCRGB_2BPPV:case v.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 v.DXT1:if(827611204!==s)throw"the FourCC code is not same with texture format.";break;case v.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 h=e[1]+4;this._upLoadCompressedTexImage2D(t,r,a,i,h,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,f.layaGPUInstance._compressedTextureASTC)switch(i){case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_4x4_KHR:this._format=v.ASTC4x4;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:this._format=v.ASTC4x4SRGB;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:this._format=v.ASTC6x6SRGB;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:this._format=v.ASTC8x8SRGB;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:this._format=v.ASTC10x10SRGB;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:this._format=v.ASTC12x12SRGB;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_6x6_KHR:this._format=v.ASTC6x6;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_8x8_KHR:this._format=v.ASTC8x8;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_10x10_KHR:this._format=v.ASTC10x10;break;case f.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_12x12_KHR:this._format=v.ASTC12x12}if(f.layaGPUInstance._compressedTextureEtc1&&i===f.layaGPUInstance._compressedTextureEtc1.COMPRESSED_RGB_ETC1_WEBGL)this._format=v.ETC1RGB;if(f.layaGPUInstance._compressedTextureETC)switch(i){case f.layaGPUInstance._compressedTextureETC.COMPRESSED_RGBA8_ETC2_EAC:this._format=v.ETC2RGBA;break;case f.layaGPUInstance._compressedTextureETC.COMPRESSED_RGB8_ETC2:this._format=v.ETC2RGB;break;case f.layaGPUInstance._compressedTextureETC.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:this._format=v.ETC2RGB_Alpha8;break;case f.layaGPUInstance._compressedTextureETC.COMPRESSED_SRGB8_ETC2:this._format=v.ETC2SRGB}if(-1==this._format)throw"unknown texture format.";var r=s[11],a=s[6],h=s[7];this._width=a,this._height=h;var n=64+s[12];this._upLoadKTXCompressedTexImage2D(t,a,h,r,n,4)}_pharsePVR(t){var e=new Int32Array(t,0,13);if(55727696!=e[0])throw"Invalid magic number in PVR header";switch(e[2]){case 0:this._format=v.PVRTCRGB_2BPPV;break;case 2:this._format=v.PVRTCRGB_4BPPV;break;case 1:this._format=v.PVRTCRGBA_2BPPV;break;case 3:this._format=v.PVRTCRGBA_4BPPV;break;default:throw"Texture2D:unknown PVR format."}var s=e[11],i=e[7],r=e[6];this._width=i,this._height=r;var a=e[12]+52;this._upLoadCompressedTexImage2D(t,i,r,s,a,0)}_upLoadCompressedTexImage2D(t,e,s,i,r,a){var h=f.instance,n=this._glTextureType;b.bindTexture(h,n,this._glTexture);for(var l=this._getGLFormat(),o=r,_=0;_<i;_++){o+=a;var c=this._calcualatesCompressedDataSize(this._format,e,s),u=new Uint8Array(t,o,c);h.compressedTexImage2D(n,_,l,e,s,0,u),e=Math.max(e>>1,1),s=Math.max(s>>1,1),o+=c}var d=o;this._setGPUMemory(d),this._readyed=!0,this._activeResource()}_upLoadKTXCompressedTexImage2D(t,e,s,i,r,a){var h=f.instance,n=this._glTextureType;b.bindTexture(h,n,this._glTexture);for(var l=this._getGLFormat(),o=r,_=0;_<i;_++){var c=new Int32Array(t,o,1)[0];o+=a;var u=new Uint8Array(t,o,c);h.compressedTexImage2D(n,_,l,e,s,0,u),e=Math.max(e>>1,1),s=Math.max(s>>1,1),o+=c,o+=3-(c+3)%4}var d=o;this._setGPUMemory(d),this._readyed=!0,this._activeResource()}loadImageSource(t,s=!1){var i=f.instance,r=t.width,a=t.height;this._width=r,this._height=a,this._isPot(r)&&this._isPot(a)||(this._mipmap=!1),this._setWarpMode(i.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(i.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),b.bindTexture(i,this._glTextureType,this._glTexture);var h=this._getGLFormat();e.Render.isConchApp?(t.setPremultiplyAlpha&&t.setPremultiplyAlpha(s),i.texImage2D(this._glTextureType,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t)):(s&&i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.format==v.R5G6B5?i.texImage2D(this._glTextureType,0,i.RGB,i.RGB,i.UNSIGNED_SHORT_5_6_5,t):i.texImage2D(this._glTextureType,0,h,h,i.UNSIGNED_BYTE,t),s&&i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)),this._mipmap?(i.generateMipmap(this._glTextureType),this._setGPUMemory(r*a*4*(1+1/3))):this._setGPUMemory(r*a*4),this._canRead&&(e.Render.isConchApp?this._pixels=new Uint8Array(t._nativeObj.getImageData(0,0,r,a)):(e.Browser.canvas.size(r,a),e.Browser.canvas.clear(),e.Browser.context.drawImage(t,0,0,r,a),this._pixels=new Uint8Array(e.Browser.context.getImageData(0,0,r,a).data.buffer))),this._readyed=!0,this._activeResource()}setPixels(t,e=0){if(this._gpuCompressFormat())throw"Texture2D:the format is GPU compression format.";if(!t)throw"Texture2D:pixels can't be null.";var s=Math.max(this._width>>e,1),i=Math.max(this._height>>e,1),r=s*i*this._getFormatByteCount();if(t.length<r)throw"Texture2D:pixels length should at least "+r+".";this._setPixels(t,e,s,i),this._canRead&&(this._pixels=t),this._readyed=!0,this._activeResource()}setSubPixels(t,e,s,i,r,a=0){if(this._gpuCompressFormat())throw"Texture2D:the format is GPU compression format.";if