123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- import{n as Tt,m as Wt}from"./WGLContainer.bbd0fcb8.js";import{n as $t,s as Vt}from"./programUtils.7e7bf03b.js";import{ab as Rt,r as rt,s as Yt,t as U,b4 as Ht,a as it,b5 as Bt,b6 as jt,n as Kt}from"./index.6c049565.js";import{n as S,E as dt,a as H}from"./Texture.8e8dfb11.js";import{R as q,T as ct,N as K,S as Nt,I as st,O as Q,t as et,Y as nt,V as at,M as G,D as Z,P as k,G as W,L as z,F as lt,C as Et,E as X,U as zt,_ as tt,A as u,X as ft,n as y,W as qt,r as At,f as Qt}from"./enums.2d9e6f64.js";import{t as mt,W as Zt,s as Jt,M as te}from"./OrderIndependentTransparency.4d1575c0.js";import{x as ot,E as ut,a as ht,i as xt}from"./VertexArrayObject.729879be.js";import{r as ee}from"./floatRGBA.c5518572.js";import{t as gt}from"./VertexElementDescriptor.1fdca6da.js";const ie=r=>{let t="";t+=r[0].toUpperCase();for(let e=1;e<r.length;e++){const i=r[e];i===i.toUpperCase()?(t+="_",t+=i):t+=i.toUpperCase()}return t},re=r=>{const t={};for(const e in r)t[ie(e)]=r[e];return $t(t)},ye=(r,t,e,i)=>{const s=r+r.substring(r.lastIndexOf("/")),a=t+t.substring(t.lastIndexOf("/")),o=re(i);return{attributes:e,shaders:{vertexShader:o+Tt(`${s}.vert`),fragmentShader:o+Tt(`${a}.frag`)}}};class St{constructor(t,e,i,s,a,o,_,f,T){this.createQuery=t,this.deleteQuery=e,this.resultAvailable=i,this.getResult=s,this.disjoint=a,this.beginTimeElapsed=o,this.endTimeElapsed=_,this.createTimestamp=f,this.timestampBits=T}}let j=!1;function se(r,t){if(t.disjointTimerQuery)return null;let e=r.getExtension("EXT_disjoint_timer_query_webgl2");return e&&S(r)?new St(()=>r.createQuery(),i=>{r.deleteQuery(i),j=!1},i=>r.getQueryParameter(i,r.QUERY_RESULT_AVAILABLE),i=>r.getQueryParameter(i,r.QUERY_RESULT),()=>r.getParameter(e.GPU_DISJOINT_EXT),i=>{j||(j=!0,r.beginQuery(e.TIME_ELAPSED_EXT,i))},()=>{r.endQuery(e.TIME_ELAPSED_EXT),j=!1},i=>e.queryCounterEXT(i,e.TIMESTAMP_EXT),()=>r.getQuery(e.TIMESTAMP_EXT,e.QUERY_COUNTER_BITS_EXT)):(e=r.getExtension("EXT_disjoint_timer_query"),e?new St(()=>e.createQueryEXT(),i=>{e.deleteQueryEXT(i),j=!1},i=>e.getQueryObjectEXT(i,e.QUERY_RESULT_AVAILABLE_EXT),i=>e.getQueryObjectEXT(i,e.QUERY_RESULT_EXT),()=>r.getParameter(e.GPU_DISJOINT_EXT),i=>{j||(j=!0,e.beginQueryEXT(e.TIME_ELAPSED_EXT,i))},()=>{e.endQueryEXT(e.TIME_ELAPSED_EXT),j=!1},i=>e.queryCounterEXT(i,e.TIMESTAMP_EXT),()=>e.getQueryEXT(e.TIMESTAMP_EXT,e.QUERY_COUNTER_BITS_EXT)):null)}class Ot{constructor(){this.blend=!1,this.blendColor={r:0,g:0,b:0,a:0},this.blendFunction={srcRGB:q.ONE,dstRGB:q.ZERO,srcAlpha:q.ONE,dstAlpha:q.ZERO},this.blendEquation={mode:ct.ADD,modeAlpha:ct.ADD},this.colorMask={r:!0,g:!0,b:!0,a:!0},this.faceCulling=!1,this.cullFace=K.BACK,this.frontFace=Nt.CCW,this.scissorTest=!1,this.scissorRect={x:0,y:0,width:0,height:0},this.depthTest=!1,this.depthFunction=st.LESS,this.clearDepth=1,this.depthWrite=!0,this.depthRange={zNear:0,zFar:1},this.viewport=null,this.stencilTest=!1,this.polygonOffsetFill=!1,this.polygonOffset=[0,0],this.stencilFunction={face:K.FRONT_AND_BACK,func:st.ALWAYS,ref:0,mask:1},this.clearStencil=0,this.stencilWriteMask=1,this.stencilOperation={face:K.FRONT_AND_BACK,fail:Q.KEEP,zFail:Q.KEEP,zPass:Q.KEEP},this.clearColor={r:0,g:0,b:0,a:0},this.program=null,this.vertexBuffer=null,this.indexBuffer=null,this.uniformBuffer=null,this.pixelPackBuffer=null,this.pixelUnpackBuffer=null,this.copyReadBuffer=null,this.copyWriteBuffer=null,this.uniformBufferBindingPoints=new Array,this.readFramebuffer=null,this.drawFramebuffer=null,this.renderbuffer=null,this.activeTexture=0,this.textureUnitMap=new Array,this.vertexArrayObject=null}}class ne{constructor(t){this._allocations=new Map,t?Error.stackTraceLimit=1/0:(this.add=()=>{},this.remove=()=>{})}add(t){this._allocations.set(t,new Error().stack)}remove(t){this._allocations.delete(t)}print(){if(this._allocations.size>0){console.log(`${this._allocations.size} live object allocations:`);const t=new Map;this._allocations.forEach(e=>{var i;t.set(e,((i=t.get(e))!=null?i:0)+1)}),t.forEach((e,i)=>{const s=i.split(`
- `);s.shift(),s.shift(),console.log(`${e}: ${s.shift()}`),s.forEach(a=>console.log(" ",a))})}}}const ae={RECORD_ALLOCATIONS:!1};class le{constructor(){for(this._current=new Array,this._max=new Array,this._allocations=new ne(ae.RECORD_ALLOCATIONS);this._current.length<et.COUNT;)this._current.push(0),this._max.push(0)}resetMax(){for(this._max.length=0;this._max.length<this._current.length;)this._max.push(0)}increment(t,e){const i=++this._current[t];this._max[t]=Math.max(i,this._max[t]),this._allocations.add(e)}decrement(t,e){--this._current[t],this._allocations.remove(e)}get max(){return this._max}get current(){return this._current}get total(){return this.current.reduce((t,e)=>t+e,0)}printResourceCount(){if(this.total>0){console.log("Live objects:");for(let t=0;t<et.COUNT;++t){const e=this._current[t];e>0&&console.log(`${et[t]}: ${e}`)}}this._allocations.print()}}function Ct(r,t){r.resetState();const e=new ot(r,{colorTarget:nt.TEXTURE,depthStencilTarget:at.NONE},{target:G.TEXTURE_2D,wrapMode:Z.CLAMP_TO_EDGE,pixelFormat:k.RGBA,dataType:W.UNSIGNED_BYTE,samplingMode:z.NEAREST,width:1,height:1}),i=ut.createVertex(r,lt.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),s=new ht(r,new Map([["position",0]]),{geometry:[new gt("position",2,Et.UNSIGNED_SHORT,0,4)]},{geometry:i}),a=Rt(5633261287538229e-9,2626832878767164e-9,1.4349880495278358e6),o=Rt(563327146742708e-8,2.6268736381334523e6,1434963231608387e-9),_=oe(r,a,o,t);r.bindFramebuffer(e),r.setViewport(0,0,1,1),r.bindVAO(s),r.drawArrays(X.TRIANGLE_STRIP,0,4);const f=new Uint8Array(4);e.readPixels(0,0,1,1,k.RGBA,W.UNSIGNED_BYTE,f),_.dispose(),s.dispose(!1),i.dispose(),e.dispose();const T=(a[2]-o[2])/25,d=ee(f);return Math.abs(T-d)}function oe(r,t,e,i){const s=`
- precision highp float;
- attribute vec2 position;
- uniform vec3 u_highA;
- uniform vec3 u_lowA;
- uniform vec3 u_highB;
- uniform vec3 u_lowB;
- varying vec4 v_color;
- ${i?"#define DOUBLE_PRECISION_REQUIRES_OBFUSCATION":""}
- #ifdef DOUBLE_PRECISION_REQUIRES_OBFUSCATION
- vec3 dpPlusFrc(vec3 a, vec3 b) {
- return mix(a, a + b, vec3(notEqual(b, vec3(0))));
- }
- vec3 dpMinusFrc(vec3 a, vec3 b) {
- return mix(vec3(0), a - b, vec3(notEqual(a, b)));
- }
- vec3 dpAdd(vec3 hiA, vec3 loA, vec3 hiB, vec3 loB) {
- vec3 t1 = dpPlusFrc(hiA, hiB);
- vec3 e = dpMinusFrc(t1, hiA);
- vec3 t2 = dpMinusFrc(hiB, e) + dpMinusFrc(hiA, dpMinusFrc(t1, e)) + loA + loB;
- return t1 + t2;
- }
- #else
- vec3 dpAdd(vec3 hiA, vec3 loA, vec3 hiB, vec3 loB) {
- vec3 t1 = hiA + hiB;
- vec3 e = t1 - hiA;
- vec3 t2 = ((hiB - e) + (hiA - (t1 - e))) + loA + loB;
- return t1 + t2;
- }
- #endif
- const float MAX_RGBA_FLOAT =
- 255.0 / 256.0 +
- 255.0 / 256.0 / 256.0 +
- 255.0 / 256.0 / 256.0 / 256.0 +
- 255.0 / 256.0 / 256.0 / 256.0 / 256.0;
- const vec4 FIXED_POINT_FACTORS = vec4(1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0);
- vec4 float2rgba(const float value) {
- // Make sure value is in the domain we can represent
- float valueInValidDomain = clamp(value, 0.0, MAX_RGBA_FLOAT);
- // Decompose value in 32bit fixed point parts represented as
- // uint8 rgba components. Decomposition uses the fractional part after multiplying
- // by a power of 256 (this removes the bits that are represented in the previous
- // component) and then converts the fractional part to 8bits.
- vec4 fixedPointU8 = floor(fract(valueInValidDomain * FIXED_POINT_FACTORS) * 256.0);
- // Convert uint8 values (from 0 to 255) to floating point representation for
- // the shader
- const float toU8AsFloat = 1.0 / 255.0;
- return fixedPointU8 * toU8AsFloat;
- }
- void main() {
- vec3 val = dpAdd(u_highA, u_lowA, -u_highB, -u_lowB);
- v_color = float2rgba(val.z / 25.0);
- gl_Position = vec4(position * 2.0 - 1.0, 0.0, 1.0);
- }
- `,a=`
- precision highp float;
- varying vec4 v_color;
- void main() {
- gl_FragColor = v_color;
- }
- `,o=r.programCache.acquire(s,a,new Map([["position",0]])),_=new Float32Array(6);mt(t,_,3);const f=new Float32Array(6);return mt(e,f,3),r.useProgram(o),o.setUniform3f("u_highA",_[0],_[2],_[4]),o.setUniform3f("u_lowA",_[1],_[3],_[5]),o.setUniform3f("u_highB",f[0],f[2],f[4]),o.setUniform3f("u_lowB",f[1],f[3],f[5]),o}var vt,Pt,Ut,yt={exports:{}};function ue(r){var x,n,h,b,c;if(!r.gl)return!1;if(r.type===rt.WEBGL1)return!(!((x=r.capabilities.textureFloat)!=null&&x.textureFloat)||!((n=r.capabilities.colorBufferFloat)!=null&&n.textureFloat));if(!(((h=r.capabilities.textureFloat)==null?void 0:h.textureFloat)&&((b=r.capabilities.colorBufferFloat)==null?void 0:b.textureFloat)&&((c=r.capabilities.colorBufferFloat)==null?void 0:c.floatBlend)))return!1;const t=new ot(r,{colorTarget:nt.TEXTURE,depthStencilTarget:at.NONE},{target:G.TEXTURE_2D,wrapMode:Z.CLAMP_TO_EDGE,pixelFormat:k.RGBA,dataType:W.FLOAT,internalFormat:zt.RGBA32F,samplingMode:z.NEAREST,width:1,height:1}),e=ut.createVertex(r,lt.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),i=new ht(r,new Map([["a_pos",0]]),{geometry:[new gt("a_pos",2,Et.UNSIGNED_SHORT,0,4)]},{geometry:e}),s=`
- precision highp float;
- attribute vec2 a_pos;
- void main() {
- gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);
- }
- `,a=`
- precision highp float;
- void main() {
- gl_FragColor = vec4(0.5, 0.5, 0.5, 0.5);
- }
- `,o=r.programCache.acquire(s,a,new Map([["a_pos",0]]));r.useProgram(o);const _=r.getBoundFramebufferObject(),{x:f,y:T,width:d,height:R}=r.getViewport();r.bindFramebuffer(t),r.setViewport(0,0,1,1),r.bindVAO(i),r.drawArrays(X.TRIANGLE_STRIP,0,4);const B=Zt({blending:Jt});r.setPipelineState(B),r.drawArrays(X.TRIANGLE_STRIP,0,4),yt.exports.init(r);const O=r.gl.getError();return r.setViewport(f,T,d,R),r.bindFramebuffer(_),o.dispose(),i.dispose(!1),e.dispose(),t.dispose(),O!==1282||(console.warn("Device claims support for WebGL extension EXT_float_blend but does not support it. Using fall back."),!1)}vt=yt,Pt=function(){var r=function(n){window.console&&window.console.log&&window.console.log(n)},t=function(n){window.console&&window.console.error?window.console.error(n):r(n)},e={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0}},bindBuffer:{2:{0:!0}},bufferData:{3:{0:!0,2:!0}},bufferSubData:{3:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},readPixels:{7:{4:!0,5:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}}},i=null,s=null;function a(n){if(i==null)for(var h in i={},s={},n)typeof n[h]=="number"&&(i[n[h]]=h,s[h]=n[h])}function o(){if(i==null)throw"WebGLDebugUtils.init(ctx) not called"}function _(n){return o(),i[n]!==void 0}function f(n){o();var h=i[n];return h!==void 0?"gl."+h:"/*UNKNOWN WebGL ENUM*/ 0x"+n.toString(16)}function T(n,h,b,c){var F;if((F=e[n])!==void 0&&(F=F[h])!==void 0&&F[b]){if(typeof F[b]=="object"&&F[b].enumBitwiseOr!==void 0){for(var g=F[b].enumBitwiseOr,N=0,p=[],w=0;w<g.length;++w){var A=s[g[w]];(c&A)!=0&&(N|=A,p.push(f(A)))}return N===c?p.join(" | "):f(c)}return f(c)}return c===null?"null":c===void 0?"undefined":c.toString()}function d(n,h){for(var b="",c=h.length,F=0;F<c;++F)b+=(F==0?"":", ")+T(n,c,F,h[F]);return b}function R(n,h,b){n.__defineGetter__(b,function(){return h[b]}),n.__defineSetter__(b,function(c){h[b]=c})}function B(n,h,b,c){c=c||n,a(n),h=h||function(A,M,$){for(var D="",L=$.length,V=0;V<L;++V)D+=(V==0?"":", ")+T(M,L,V,$[V]);t("WebGL error "+f(A)+" in "+M+"("+D+")")};var F={};function g(A,M){return function(){b&&b(M,arguments);var $=A[M].apply(A,arguments),D=c.getError();return D!=0&&(F[D]=!0,h(D,M,arguments)),$}}var N={};for(var p in n)if(typeof n[p]=="function")if(p!="getExtension")N[p]=g(n,p);else{var w=g(n,p);N[p]=function(){return B(w.apply(n,arguments),h,b,c)}}else R(N,n,p);return N.getError=function(){for(var A in F)if(F.hasOwnProperty(A)&&F[A])return F[A]=!1,A;return n.NO_ERROR},N}function O(n){var h=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,b);for(var c=0;c<h;++c)n.disableVertexAttribArray(c),n.vertexAttribPointer(c,4,n.FLOAT,!1,0,0),n.vertexAttrib1f(c,0);n.deleteBuffer(b);var F=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS);for(c=0;c<F;++c)n.activeTexture(n.TEXTURE0+c),n.bindTexture(n.TEXTURE_CUBE_MAP,null),n.bindTexture(n.TEXTURE_2D,null);for(n.activeTexture(n.TEXTURE0),n.useProgram(null),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindRenderbuffer(n.RENDERBUFFER,null),n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.DITHER),n.disable(n.SCISSOR_TEST),n.blendColor(0,0,0,0),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.clearColor(0,0,0,0),n.clearDepth(1),n.clearStencil(-1),n.colorMask(!0,!0,!0,!0),n.cullFace(n.BACK),n.depthFunc(n.LESS),n.depthMask(!0),n.depthRange(0,1),n.frontFace(n.CCW),n.hint(n.GENERATE_MIPMAP_HINT,n.DONT_CARE),n.lineWidth(1),n.pixelStorei(n.PACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.UNPACK_COLORSPACE_CONVERSION_WEBGL&&n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.BROWSER_DEFAULT_WEBGL),n.polygonOffset(0,0),n.sampleCoverage(1,!1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilMask(4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.viewport(0,0,n.canvas.width,n.canvas.height),n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT|n.STENCIL_BUFFER_BIT);n.getError(););}function x(n){var h,b,c=[],F=[],g={},N=1,p=!1,w=[],A=0,M=0,$=!1,D=0,L={};function V(l){return typeof l=="function"?l:function(E){l.handleEvent(E)}}n.getContext=(b=n.getContext,function(){var l=b.apply(n,arguments);if(l instanceof WebGLRenderingContext){if(l!=h){if(h)throw"got different context";g=kt(h=l)}return g}return l});var Dt=function(l){c.push(V(l))},Lt=function(l){F.push(V(l))};function wt(l){var E=l.addEventListener;l.addEventListener=function(C,v,I){switch(C){case"webglcontextlost":Dt(v);break;case"webglcontextrestored":Lt(v);break;default:E.apply(l,arguments)}}}function It(){for(var l=Object.keys(L),E=0;E<l.length;++E)delete L[l]}function Y(){++M,p||A==M&&n.loseContext()}function Gt(l,E){var C=l[E];return function(){if(Y(),!p)return C.apply(l,arguments)}}function Xt(){for(var l=0;l<w.length;++l){var E=w[l];E instanceof WebGLBuffer?h.deleteBuffer(E):E instanceof WebGLFramebuffer?h.deleteFramebuffer(E):E instanceof WebGLProgram?h.deleteProgram(E):E instanceof WebGLRenderbuffer?h.deleteRenderbuffer(E):E instanceof WebGLShader?h.deleteShader(E):E instanceof WebGLTexture&&h.deleteTexture(E)}}function pt(l){return{statusMessage:l,preventDefault:function(){$=!0}}}return wt(n),n.loseContext=function(){if(!p){for(p=!0,A=0,++N;h.getError(););It(),L[h.CONTEXT_LOST_WEBGL]=!0;var l=pt("context lost"),E=c.slice();setTimeout(function(){for(var C=0;C<E.length;++C)E[C](l);D>=0&&setTimeout(function(){n.restoreContext()},D)},0)}},n.restoreContext=function(){p&&F.length&&setTimeout(function(){if(!$)throw"can not restore. webglcontestlost listener did not call event.preventDefault";Xt(),O(h),p=!1,M=0,$=!1;for(var l=F.slice(),E=pt("context restored"),C=0;C<l.length;++C)l[C](E)},0)},n.loseContextInNCalls=function(l){if(p)throw"You can not ask a lost contet to be lost";A=M+l},n.getNumCalls=function(){return M},n.setRestoreTimeout=function(l){D=l},n;function kt(l){for(var E in l)typeof l[E]=="function"?g[E]=Gt(l,E):R(g,l,E);g.getError=function(){if(Y(),!p)for(;m=h.getError();)L[m]=!0;for(var m in L)if(L[m])return delete L[m],m;return g.NO_ERROR};for(var C=["createBuffer","createFramebuffer","createProgram","createRenderbuffer","createShader","createTexture"],v=0;v<C.length;++v){var I=C[v];g[I]=function(m){return function(){if(Y(),p)return null;var _t=m.apply(l,arguments);return _t.__webglDebugContextLostId__=N,w.push(_t),_t}}(l[I])}var bt=["getActiveAttrib","getActiveUniform","getBufferParameter","getContextAttributes","getAttachedShaders","getFramebufferAttachmentParameter","getParameter","getProgramParameter","getProgramInfoLog","getRenderbufferParameter","getShaderParameter","getShaderInfoLog","getShaderSource","getTexParameter","getUniform","getUniformLocation","getVertexAttrib"];for(v=0;v<bt.length;++v)I=bt[v],g[I]=function(m){return function(){return Y(),p?null:m.apply(l,arguments)}}(g[I]);var Ft=["isBuffer","isEnabled","isFramebuffer","isProgram","isRenderbuffer","isShader","isTexture"];for(v=0;v<Ft.length;++v)I=Ft[v],g[I]=function(m){return function(){return Y(),!p&&m.apply(l,arguments)}}(g[I]);return g.checkFramebufferStatus=function(m){return function(){return Y(),p?g.FRAMEBUFFER_UNSUPPORTED:m.apply(l,arguments)}}(g.checkFramebufferStatus),g.getAttribLocation=function(m){return function(){return Y(),p?-1:m.apply(l,arguments)}}(g.getAttribLocation),g.getVertexAttribOffset=function(m){return function(){return Y(),p?0:m.apply(l,arguments)}}(g.getVertexAttribOffset),g.isContextLost=function(){return p},g}}return{init:a,mightBeEnum:_,glEnumToString:f,glFunctionArgToString:T,glFunctionArgsToString:d,makeDebugContext:B,makeLostContextSimulatingCanvas:x,resetToInitialState:O}},(Ut=Pt())!==void 0&&(vt.exports=Ut);function he(r){const t=new ot(r,{colorTarget:nt.TEXTURE,depthStencilTarget:at.NONE},{target:G.TEXTURE_2D,wrapMode:Z.CLAMP_TO_EDGE,pixelFormat:k.RGBA,dataType:W.UNSIGNED_BYTE,samplingMode:z.NEAREST,width:1,height:1}),e=`
- precision highp float;
- attribute vec2 a_pos;
- uniform highp sampler2D u_texture;
- varying vec4 v_color;
- float getBit(in float bitset, in int bitIndex) {
- float offset = pow(2.0, float(bitIndex));
- return mod(floor(bitset / offset), 2.0);
- }
- void main() {
- vec4 value = texture2D(u_texture, vec2(0.0));
- float bit = getBit(value.x * 255.0, 1);
- v_color = bit * vec4(1.0);
- gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);
- }
- `,i=`
- precision highp float;
- varying vec4 v_color;
- void main() {
- gl_FragColor = v_color;
- }
- `,s=new Uint8Array(4),a=ut.createVertex(r,lt.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),o=new ht(r,new Map([["a_position",0]]),{geometry:[new gt("a_position",2,Et.SHORT,0,4)]},{geometry:a}),_=r.programCache.acquire(e,i,new Map([["a_pos",0]]));r.useProgram(_);const f=new dt(r,{target:G.TEXTURE_2D,wrapMode:Z.CLAMP_TO_EDGE,pixelFormat:k.RGBA,dataType:W.UNSIGNED_BYTE,samplingMode:z.NEAREST,width:1,height:1},new Uint8Array([2,255,0,0]));_.setUniform1i("u_texture",0),r.bindTexture(f,0);const T=r.getBoundFramebufferObject();r.bindFramebuffer(t),r.useProgram(_);const{x:d,y:R,width:B,height:O}=r.getViewport();r.setViewport(0,0,1,1),r.bindVAO(o),r.drawArrays(X.TRIANGLE_STRIP,0,4),r.setViewport(d,R,B,O),t.readPixels(0,0,1,1,k.RGBA,W.UNSIGNED_BYTE,s),_.dispose(),o.dispose(!1),a.dispose(),t.dispose();const x=s[0]!==255||s[1]!==255||s[2]!==255||s[3]!==255;return x&&Yt.getLogger("esri.views.webgl.testSamplerPrecision").warn(`A problem was detected with your graphics driver. Your driver does not appear to honor sampler precision specifiers, which may result in rendering issues due to numerical instability. We recommend ensuring that your drivers have been updated to the latest version. Applying lowp sampler workaround. [${s[0]}.${s[1]}.${s[2]}.${s[3]}]`),r.bindFramebuffer(T),x}async function _e(r){const t=new Image;if(t.src="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='5' height='5' version='1.1' viewBox='0 0 5 5' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='5' height='5' fill='%23f00' fill-opacity='.5'/%3E%3C/svg%3E%0A",t.width=5,t.height=5,await t.decode(),!r.gl)return!0;const e=new ot(r,{colorTarget:nt.TEXTURE,depthStencilTarget:at.NONE},{target:G.TEXTURE_2D,wrapMode:Z.CLAMP_TO_EDGE,pixelFormat:k.RGBA,dataType:W.UNSIGNED_BYTE,samplingMode:z.NEAREST,width:1,height:1}),i=ut.createVertex(r,lt.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),s=new ht(r,new Map([["a_pos",0]]),Wt,{geometry:i}),a=`
- precision highp float;
- attribute vec2 a_pos;
- varying vec2 v_uv;
- void main() {
- v_uv = a_pos;
- gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);
- }
- `,o=`
- precision highp float;
- varying vec2 v_uv;
- uniform sampler2D u_texture;
- void main() {
- gl_FragColor = texture2D(u_texture, v_uv);
- }
- `,_=r.programCache.acquire(a,o,new Map([["a_pos",0]]));r.useProgram(_);const f=new dt(r,{dataType:W.UNSIGNED_BYTE,pixelFormat:k.RGBA,preMultiplyAlpha:!1,wrapMode:Z.CLAMP_TO_EDGE,samplingMode:z.LINEAR},t);r.bindTexture(f,0),_.setUniform1i("u_texture",0);const T=r.getBoundFramebufferObject(),{x:d,y:R,width:B,height:O}=r.getViewport();r.bindFramebuffer(e),r.setViewport(0,0,1,1),r.setClearColor(0,0,0,0),r.setBlendingEnabled(!1),r.clearSafe(tt.COLOR_BUFFER_BIT),r.bindVAO(s),r.drawArrays(X.TRIANGLE_STRIP,0,4);const x=new Uint8Array(4);return e.readPixels(0,0,1,1,k.RGBA,W.UNSIGNED_BYTE,x),_.dispose(),s.dispose(!1),i.dispose(),e.dispose(),f.dispose(),r.setViewport(d,R,B,O),r.bindFramebuffer(T),t.src="",x[0]===255}class fe{constructor(t){this.context=t,this._floatBufferBlendWorking=ue(t),_e(t).then(e=>this._svgAlwaysPremultipliesAlpha=!e)}get floatBufferBlendWorking(){if(U(this._floatBufferBlendWorking))throw new Error("floatBufferBlendWorking test not yet available");return this._floatBufferBlendWorking}get svgAlwaysPremultipliesAlpha(){if(U(this._svgAlwaysPremultipliesAlpha))throw new Error("svgAlwaysPremultipliesAlpha test not yet available");return this._svgAlwaysPremultipliesAlpha}get doublePrecisionRequiresObfuscation(){if(U(this._doublePrecisionRequiresObfuscation)){const t=Ct(this.context,!1),e=Ct(this.context,!0);this._doublePrecisionRequiresObfuscation=t!==0&&(e===0||t/e>5)}return this._doublePrecisionRequiresObfuscation}get ignoresSamplerPrecision(){return U(this._ignoresSamplerPrecision)&&(this._ignoresSamplerPrecision=he(this.context)),this._ignoresSamplerPrecision}}function ce(r,t){if(t.disjointTimerQuery)return null;if(S(r))return{drawBuffers:r.drawBuffers.bind(r),MAX_DRAW_BUFFERS:r.MAX_DRAW_BUFFERS,MAX_COLOR_ATTACHMENTS:r.MAX_COLOR_ATTACHMENTS};if(t.drawBuffers)return null;const e=r.getExtension("WEBGL_draw_buffers");return e?{drawBuffers:e.drawBuffersWEBGL.bind(e),MAX_DRAW_BUFFERS:e.MAX_DRAW_BUFFERS_WEBGL,MAX_COLOR_ATTACHMENTS:e.MAX_COLOR_ATTACHMENTS_WEBGL}:null}function de(r){if(S(r))return r;const t=r.getExtension("ANGLE_instanced_arrays");return t?{drawArraysInstanced:t.drawArraysInstancedANGLE.bind(t),drawElementsInstanced:t.drawElementsInstancedANGLE.bind(t),vertexAttribDivisor:t.vertexAttribDivisorANGLE.bind(t)}:null}function Ee(r,t){if(t.compressedTextureETC)return null;const e=r.getExtension("WEBGL_compressed_texture_etc");return e?{COMPRESSED_R11_EAC:e.COMPRESSED_R11_EAC,COMPRESSED_SIGNED_R11_EAC:e.COMPRESSED_SIGNED_R11_EAC,COMPRESSED_RG11_EAC:e.COMPRESSED_RG11_EAC,COMPRESSED_SIGNED_RG11_EAC:e.COMPRESSED_SIGNED_RG11_EAC,COMPRESSED_RGB8_ETC2:e.COMPRESSED_RGB8_ETC2,COMPRESSED_SRGB8_ETC2:e.COMPRESSED_SRGB8_ETC2,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,COMPRESSED_RGBA8_ETC2_EAC:e.COMPRESSED_RGBA8_ETC2_EAC,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC}:null}function ge(r,t){if(t.compressedTextureS3TC)return null;const e=r.getExtension("WEBGL_compressed_texture_s3tc");return e?{COMPRESSED_RGB_S3TC_DXT1:e.COMPRESSED_RGB_S3TC_DXT1_EXT,COMPRESSED_RGBA_S3TC_DXT1:e.COMPRESSED_RGBA_S3TC_DXT1_EXT,COMPRESSED_RGBA_S3TC_DXT3:e.COMPRESSED_RGBA_S3TC_DXT3_EXT,COMPRESSED_RGBA_S3TC_DXT5:e.COMPRESSED_RGBA_S3TC_DXT5_EXT}:null}function pe(r,t){if(S(r))return{MIN:r.MIN,MAX:r.MAX};if(t.blendMinMax)return null;{const e=r.getExtension("EXT_blend_minmax");return e?{MIN:e.MIN_EXT,MAX:e.MAX_EXT}:null}}function be(r,t){if(t.textureFilterAnisotropic)return null;const e=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");return e?{MAX_TEXTURE_MAX_ANISOTROPY:e.MAX_TEXTURE_MAX_ANISOTROPY_EXT,TEXTURE_MAX_ANISOTROPY:e.TEXTURE_MAX_ANISOTROPY_EXT}:null}function Fe(r,t){if(S(r))return{textureFloat:!0,textureFloatLinear:!t.textureFloatLinear&&!!r.getExtension("OES_texture_float_linear"),textureHalfFloat:!0,textureHalfFloatLinear:!0,HALF_FLOAT:r.HALF_FLOAT,R16F:r.R16F,RG16F:r.RG16F,RGBA16F:r.RGBA16F,R32F:r.R32F,RG32F:r.RG32F,RGBA32F:r.RGBA32F,R11F_G11F_B10F:r.R11F_G11F_B10F,RGB16F:r.RGB16F};if(r instanceof WebGLRenderingContext){const e=!t.textureHalfFloat&&r.getExtension("OES_texture_half_float");return{textureFloat:!t.textureFloat&&!!r.getExtension("OES_texture_float"),textureFloatLinear:!t.textureFloatLinear&&!!r.getExtension("OES_texture_float_linear"),textureHalfFloat:!!e,textureHalfFloatLinear:!t.textureHalfFloatLinear&&!!r.getExtension("OES_texture_half_float_linear"),HALF_FLOAT:e?e.HALF_FLOAT_OES:void 0}}return null}function Te(r,t){if(S(r)){const e=!t.colorBufferHalfFloat&&r.getExtension("EXT_color_buffer_half_float")||!t.colorBufferFloat&&r.getExtension("EXT_color_buffer_float"),i=!t.colorBufferFloat&&r.getExtension("EXT_color_buffer_float"),s=!t.floatBlend&&!t.colorBufferFloat&&r.getExtension("EXT_float_blend");return e||i||s?{textureFloat:!!i,textureHalfFloat:!!e,floatBlend:!!s,R16F:r.R16F,RG16F:r.RG16F,RGBA16F:r.RGBA16F,R32F:r.R32F,RG32F:r.RG32F,RGBA32F:r.RGBA32F,R11F_G11F_B10F:r.R11F_G11F_B10F,RGB16F:r.RGB16F}:null}if(r instanceof WebGLRenderingContext){const e=!t.colorBufferHalfFloat&&r.getExtension("EXT_color_buffer_half_float"),i=!t.colorBufferFloat&&r.getExtension("WEBGL_color_buffer_float"),s=!t.floatBlend&&!t.colorBufferFloat&&r.getExtension("EXT_float_blend");return e||i||s?{textureFloat:!!i,textureHalfFloat:!!e,floatBlend:!!s,RGBA16F:e?e.RGBA16F_EXT:void 0,RGB16F:e?e.RGB16F_EXT:void 0,RGBA32F:i?i.RGBA32F_EXT:void 0}:null}return null}function J(r,t,e,i,s){if(i&&S(r))return!0;if(t[e])return!1;for(const a of s)if(r.getExtension(a))return!0;return!1}function Re(r,t){if(!S(r)||t.textureNorm16)return null;const e=r.getExtension("EXT_texture_norm16");return e?{R16:e.R16_EXT,RG16:e.RG16_EXT,RGB16:e.RGB16_EXT,RGBA16:e.RGBA16_EXT,R16_SNORM:e.R16_SNORM_EXT,RG16_SNORM:e.RG16_SNORM_EXT,RGB16_SNORM:e.RGB16_SNORM_EXT,RGBA16_SNORM:e.RGBA16_SNORM_EXT}:null}function Be(r,t){const e=t.loseContext&&r.getExtension("WEBGL_lose_context");return e?{loseRenderingContext:()=>e.loseContext()}:null}function Ae(r,t){if(S(r))return{createVertexArray:r.createVertexArray.bind(r),deleteVertexArray:r.deleteVertexArray.bind(r),bindVertexArray:r.bindVertexArray.bind(r)};if(t.vao)return null;const e=r.getExtension("OES_vertex_array_object")||r.getExtension("MOZ_OES_vertex_array_object")||r.getExtension("WEBKIT_OES_vertex_array_object");return e?{createVertexArray:e.createVertexArrayOES.bind(e),deleteVertexArray:e.deleteVertexArrayOES.bind(e),bindVertexArray:e.bindVertexArrayOES.bind(e)}:null}class me{constructor(t,e){this._gl=t,this._instancing=null,this._vertexArrayObject=null,this._compressedTextureETC=null,this._compressedTextureS3TC=null,this._textureFilterAnisotropic=null,this._textureFloat=null,this._colorBufferFloat=null,this._minMaxBlending=null,this._loseContext=null,this._drawBuffers=null,this._textureNorm16=null,this._depthTexture=null,this._standardDerivatives=null,this._shaderTextureLOD=null,this._fragDepth=null,this._textureFloatLinear=null,this._disabledExtensions=e.disabledExtensions||{},this._debugWebGLExtensions=e.debugWebGLExtensions||{}}get drawBuffers(){return this._drawBuffers||(this._drawBuffers=ce(this._gl,this._disabledExtensions)),this._drawBuffers}get instancing(){return this._instancing||(this._instancing=de(this._gl)),this._instancing}get vao(){return this._vertexArrayObject||(this._vertexArrayObject=Ae(this._gl,this._disabledExtensions)),this._vertexArrayObject}get compressedTextureETC(){return this._compressedTextureETC||(this._compressedTextureETC=Ee(this._gl,this._disabledExtensions)),this._compressedTextureETC}get compressedTextureS3TC(){return this._compressedTextureS3TC||(this._compressedTextureS3TC=ge(this._gl,this._disabledExtensions)),this._compressedTextureS3TC}get textureFilterAnisotropic(){return this._textureFilterAnisotropic||(this._textureFilterAnisotropic=be(this._gl,this._disabledExtensions)),this._textureFilterAnisotropic}get disjointTimerQuery(){return this._disjointTimerQuery||(this._disjointTimerQuery=se(this._gl,this._disabledExtensions)),this._disjointTimerQuery}get textureFloat(){return this._textureFloat||(this._textureFloat=Fe(this._gl,this._disabledExtensions)),this._textureFloat}get colorBufferFloat(){return this._colorBufferFloat||(this._colorBufferFloat=Te(this._gl,this._disabledExtensions)),this._colorBufferFloat}get blendMinMax(){return this._minMaxBlending||(this._minMaxBlending=pe(this._gl,this._disabledExtensions)),this._minMaxBlending}get depthTexture(){return this._depthTexture===null&&(this._depthTexture=J(this._gl,this._disabledExtensions,"depthTexture",!0,["WEBGL_depth_texture","MOZ_WEBGL_depth_texture","WEBKIT_WEBGL_depth_texture"])),this._depthTexture}get standardDerivatives(){return this._standardDerivatives===null&&(this._standardDerivatives=J(this._gl,this._disabledExtensions,"standardDerivatives",!0,["OES_standard_derivatives"])),this._standardDerivatives}get shaderTextureLOD(){return this._shaderTextureLOD===null&&(this._shaderTextureLOD=J(this._gl,this._disabledExtensions,"shaderTextureLOD",!0,["EXT_shader_texture_lod"])),this._shaderTextureLOD}get fragDepth(){return this._fragDepth===null&&(this._fragDepth=J(this._gl,this._disabledExtensions,"fragDepth",!0,["EXT_frag_depth"])),this._fragDepth}get loseContext(){return this._loseContext||(this._loseContext=Be(this._gl,this._debugWebGLExtensions)),this._loseContext}get textureNorm16(){return this._textureNorm16||(this._textureNorm16=Re(this._gl,this._disabledExtensions)),this._textureNorm16}get textureFloatLinear(){return this._textureFloatLinear===null&&(this._textureFloatLinear=J(this._gl,this._disabledExtensions,"textureFloatLinear",!1,["OES_texture_float_linear"])),this._textureFloatLinear}enable(t){return this[t]}}class De{constructor(t,e){this.gl=t,this.instanceCounter=new le,this.programCache=new Vt(this),this._state=new Ot,this._numOfDrawCalls=0,this._numOfTriangles=0,this.type=S(t)?rt.WEBGL2:rt.WEBGL1,this._loadExtensions(),this.configure(e)}configure(t){this._capabilities=new me(this.gl,t),this._parameters=this._loadParameters(t);const e=this.gl.getParameter(this.gl.VIEWPORT);this._state=new Ot,this._state.viewport={x:e[0],y:e[1],width:e[2],height:e[3]},this._stateTracker=new te({setBlending:i=>{if(i){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(i.opRgb,i.opAlpha),this.setBlendFunctionSeparate(i.srcRgb,i.dstRgb,i.srcAlpha,i.dstAlpha);const s=i.color;this.setBlendColor(s.r,s.g,s.b,s.a)}else this.setBlendingEnabled(!1)},setCulling:i=>{i?(this.setFaceCullingEnabled(!0),this.setCullFace(i.face),this.setFrontFace(i.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:i=>{i?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(i.factor,i.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:i=>{i?(this.setDepthTestEnabled(!0),this.setDepthFunction(i.func)):this.setDepthTestEnabled(!1)},setStencilTest:i=>{if(i){this.setStencilTestEnabled(!0);const s=i.function;this.setStencilFunction(s.func,s.ref,s.mask);const a=i.operation;this.setStencilOp(a.fail,a.zFail,a.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:i=>{i?(this.setDepthWriteEnabled(!0),this.setDepthRange(i.zNear,i.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:i=>{i?this.setColorMask(i.r,i.g,i.b,i.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:i=>{i?this.setStencilWriteMask(i.mask):this.setStencilWriteMask(0)}}),this.enforceState(),this._driverTest=new fe(this)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}dispose(){this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(u.ARRAY_BUFFER),this.unbindBuffer(u.ELEMENT_ARRAY_BUFFER),S(this.gl)&&(this.unbindBuffer(u.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(u.PIXEL_PACK_BUFFER),this.unbindBuffer(u.PIXEL_UNPACK_BUFFER),this.unbindBuffer(u.COPY_READ_BUFFER),this.unbindBuffer(u.COPY_WRITE_BUFFER)),this._state.textureUnitMap.length=0,H()&&this.instanceCounter.printResourceCount()}setPipelineState(t){this._stateTracker.setPipeline(t)}setBlendingEnabled(t){this._state.blend!==t&&(t===!0?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){var t;(t=this._state.program)==null||t.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let i=0;i<t.length;++i)this._state.textureUnitMap[t[i]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){const t=this.capabilities.vao;t&&(t.bindVertexArray(null),this._state.vertexArrayObject=null),this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,i,s){t===this._state.blendColor.r&&e===this._state.blendColor.g&&i===this._state.blendColor.b&&s===this._state.blendColor.a||(this.gl.blendColor(t,e,i,s),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=i,this._state.blendColor.a=s,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,i,s){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===i&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===s||(this.gl.blendFuncSeparate(t,e,i,s),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=i,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=s,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,i,s){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===i&&this._state.colorMask.a===s||(this.gl.colorMask(t,e,i,s),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=i,this._state.colorMask.a=s,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,i,s){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===i&&this._state.clearColor.a===s||(this.gl.clearColor(t,e,i,s),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=i,this._state.clearColor.a=s)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(t===!0?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(t===!0?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(t===!0?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,i,s){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===i&&this._state.scissorRect.height===s||(this.gl.scissor(t,e,i,s),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=i,this._state.scissorRect.height=s)}setDepthTestEnabled(t){this._state.depthTest!==t&&(t===!0?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(t===!0?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,i){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===i||(this.gl.stencilFunc(t,e,i),this._state.stencilFunction.face=K.FRONT_AND_BACK,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,i,s){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===i&&this._state.stencilFunction.mask===s||(this.gl.stencilFuncSeparate(t,e,i,s),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=i,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,i){this._state.stencilOperation.face===K.FRONT_AND_BACK&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===i||(this.gl.stencilOp(t,e,i),this._state.stencilOperation.face=K.FRONT_AND_BACK,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,i,s){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===i&&this._state.stencilOperation.zPass===s||(this.gl.stencilOpSeparate(t,e,i,s),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=i,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const i=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(ft+t),this._state.activeTexture=t),i}clear(t){t&&this.gl.clear(t)}clearSafe(t,e=255){t&&(t&tt.COLOR_BUFFER_BIT&&this.setColorMask(!0,!0,!0,!0),t&tt.DEPTH_BUFFER_BIT&&this.setDepthWriteEnabled(!0),t&tt.STENCIL_BUFFER_BIT&&this.setStencilWriteMask(e),this.gl.clear(t))}drawArrays(t,e,i){if(H()&&(this._numOfDrawCalls++,this._numOfTriangles+=Mt(t,i)),this.gl.drawArrays(t,e,i),H()){const s=xt(this);s&&console.error("drawArrays:",s)}}drawElements(t,e,i,s){var a;if(H()&&(this._numOfDrawCalls++,this._numOfTriangles+=Mt(t,e)),this.gl.drawElements(t,e,i,s),H()){const o=xt(this);if(o){const _=this.getBoundVAO(),f=_==null?void 0:_.indexBuffer,T=_==null?void 0:_.vertexBuffers,d={indexBuffer:f,vertexBuffers:T},R={mode:t,count:e,type:i,offset:s},B=(a=Ht(f,n=>n.size))!=null?a:0,O=s+e,x=B<O?`. Buffer is too small. Attempted to draw index ${O} of ${B}`:"";console.error(`drawElements: ${o}${x}`,{args:R,vao:d})}}}logInfo(){H()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){H()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,i,s){i=Math.max(Math.round(i),1),s=Math.max(Math.round(s),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===i&&a.height===s||(a.x=t,a.y=e,a.width=i,a.height=s,this.gl.viewport(t,e,i,s))}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){var e,i;this._state.program!==t&&((e=this._state.program)==null||e.stop(),this._state.program=t,this.gl.useProgram((i=t==null?void 0:t.glName)!=null?i:null))}bindTexture(t,e,i=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const s=this._state.textureUnitMap[e];return U(t)||t.glName==null?(it(s)&&(this.setActiveTexture(e,i),this.gl.bindTexture(s.descriptor.target,null)),this._state.textureUnitMap[e]=null,s):i||s!==t?(this.setActiveTexture(e,i),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,s):(t.isDirty&&(this.setActiveTexture(e,i),t.applyChanges()),s)}unbindTexture(t){if(!U(t))for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(U(t))return this.gl.bindFramebuffer(y.FRAMEBUFFER,null),this._state.readFramebuffer=null,void(this._state.drawFramebuffer=null);t.initializeAndBind(y.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,i=!1){const s=e===y.READ_FRAMEBUFFER,a=s?this._state.readFramebuffer:this._state.drawFramebuffer;(i||a!==t)&&(U(t)?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),s?this._state.readFramebuffer=Bt(t,null):this._state.drawFramebuffer=Bt(t,null))}blitFramebuffer(t,e,i=0,s=0,a=t.width,o=t.height,_=0,f=0,T=e.width,d=e.height,R=tt.COLOR_BUFFER_BIT,B=z.NEAREST){this.bindFramebufferSeparate(t,y.READ_FRAMEBUFFER),this.bindFramebufferSeparate(e,y.DRAW_FRAMEBUFFER),this.gl.blitFramebuffer(i,s,a,o,_,f,T,d,R,B)}bindBuffer(t,e){if(t)switch(e!=null||(e=t.bufferType),e){case u.ARRAY_BUFFER:this._state.vertexBuffer=P(this.gl,t,e,this._state.vertexBuffer);break;case u.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=P(this.gl,t,e,this._state.indexBuffer);break;case u.UNIFORM_BUFFER:this._state.uniformBuffer=P(this.gl,t,e,this._state.uniformBuffer);break;case u.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=P(this.gl,t,e,this._state.pixelPackBuffer);break;case u.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=P(this.gl,t,e,this._state.pixelUnpackBuffer);break;case u.COPY_READ_BUFFER:this._state.copyReadBuffer=P(this.gl,t,e,this._state.copyReadBuffer);break;case u.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=P(this.gl,t,e,this._state.copyWriteBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const i=this._state.uniformBufferBindingPoints;let s=i[e];return U(s)&&(s={buffer:null,offset:0,size:0},i[e]=s),s}bindBufferBase(t,e,i){const s=this._getBufferBinding(t,e);U(s)||s.buffer===i&&s.offset===0&&s.size===0||(this.gl.bindBufferBase(t,e,i?i.glName:null),s.buffer=i,s.offset=0,s.size=0)}bindBufferRange(t,e,i,s,a){const o=this._getBufferBinding(t,e);if(!U(o)&&!(o.buffer===i&&o.offset===s&&o.size===a)){if(s%this._parameters.uniformBufferOffsetAlignment!=0)return void console.error("Uniform buffer binding offset is not a multiple of the context offset alignment");this.gl.bindBufferRange(t,e,i.glName,s,a),o.buffer=i,o.offset=s,o.size=a}}bindUBO(t,e,i,s){U(e)?this.bindBufferBase(u.UNIFORM_BUFFER,t,null):(H()&&(s!=null?s:e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),i!==void 0&&s!==void 0?this.bindBufferRange(u.UNIFORM_BUFFER,t,e.buffer,i,s):this.bindBufferBase(u.UNIFORM_BUFFER,t,e.buffer))}unbindUBO(t){for(let e=0,i=this._state.uniformBufferBindingPoints.length;e<i;e++){const s=this._state.uniformBufferBindingPoints[e];it(s)&&s.buffer===t.buffer&&this.bindBufferBase(u.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case u.ARRAY_BUFFER:this._state.vertexBuffer=P(this.gl,null,t,this._state.vertexBuffer);break;case u.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=P(this.gl,null,t,this._state.indexBuffer);break;case u.UNIFORM_BUFFER:this._state.uniformBuffer=P(this.gl,null,t,this._state.uniformBuffer);break;case u.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=P(this.gl,null,t,this._state.pixelPackBuffer);break;case u.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=P(this.gl,null,t,this._state.pixelUnpackBuffer);break;case u.COPY_READ_BUFFER:this._state.copyReadBuffer=P(this.gl,null,t,this._state.copyReadBuffer);break;case u.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=P(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){U(t)?this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null):this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t)}async clientWaitAsync(t=Kt(10)){const e=this.gl,i=e.fenceSync(qt.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Client wait failed, could not create sync object");let s;this.instanceCounter.increment(et.Sync,i),e.flush();do await jt(t),s=e.clientWaitSync(i,0,0);while(s===At.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(et.Sync,i),e.deleteSync(i),s===At.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=y.FRAMEBUFFER){return t===y.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(u.ARRAY_BUFFER),this.unbindBuffer(u.ELEMENT_ARRAY_BUFFER),S(this.gl)&&(this.unbindBuffer(u.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(u.PIXEL_PACK_BUFFER),this.unbindBuffer(u.PIXEL_UNPACK_BUFFER),this.unbindBuffer(u.COPY_READ_BUFFER),this.unbindBuffer(u.COPY_WRITE_BUFFER));for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(q.ONE,q.ZERO),this.setBlendEquation(ct.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(K.BACK),this.setFrontFace(Nt.CCW),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(st.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(st.ALWAYS,0,0),this.setStencilOp(Q.KEEP,Q.KEEP,Q.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){var s,a,o,_,f,T;const t=this.gl,e=this.capabilities.vao;e&&e.bindVertexArray(null);for(let d=0;d<this.parameters.maxVertexAttributes;d++)t.disableVertexAttribArray(d);if(this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(u.ARRAY_BUFFER,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(u.ELEMENT_ARRAY_BUFFER,null),S(t)){this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(u.UNIFORM_BUFFER,null);for(let d=0;d<this._parameters.maxUniformBufferBindings;d++){const R=this._state.uniformBufferBindingPoints[d];if(it(R)){const{buffer:B,offset:O,size:x}=R;B!==null?O===0&&x===0?t.bindBufferBase(u.UNIFORM_BUFFER,d,B.glName):t.bindBufferRange(u.UNIFORM_BUFFER,d,B.glName,O,x):t.bindBufferBase(u.UNIFORM_BUFFER,d,null)}}this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(u.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(u.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(u.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(u.COPY_WRITE_BUFFER,null),t.bindFramebuffer(y.READ_FRAMEBUFFER,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(y.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),t.readBuffer(Qt.COLOR_ATTACHMENT0)),t.bindFramebuffer(y.DRAW_FRAMEBUFFER,(a=(s=this._state.drawFramebuffer)==null?void 0:s.glName)!=null?a:null)}else this._state.readFramebuffer=this._state.drawFramebuffer,t.bindFramebuffer(y.FRAMEBUFFER,(_=(o=this._state.drawFramebuffer)==null?void 0:o.glName)!=null?_:null);if(e&&this._state.vertexArrayObject){const d=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(d)}t.useProgram((T=(f=this._state.program)==null?void 0:f.glName)!=null?T:null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?this._state.renderbuffer.glName:null),this._state.blend===!0?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),this._state.depthTest===!0?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),this._state.faceCulling===!0?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),this._state.polygonOffsetFill===!0?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),this._state.scissorTest===!0?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),this._state.stencilTest===!0?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let d=0;d<this.parameters.maxTextureImageUnits;d++){t.activeTexture(ft+d),t.bindTexture(G.TEXTURE_2D,null),t.bindTexture(G.TEXTURE_CUBE_MAP,null),S(t)&&(t.bindTexture(G.TEXTURE_3D,null),t.bindTexture(G.TEXTURE_2D_ARRAY,null));const R=this._state.textureUnitMap[d];it(R)&&t.bindTexture(R.descriptor.target,R.glName)}t.activeTexture(ft+this._state.activeTexture);const i=this._state.viewport;t.viewport(i.x,i.y,i.width,i.height),this.resetInfo()}_loadExtensions(){this.type===rt.WEBGL1&&this.gl.getExtension("OES_element_index_uint"),this.gl.getExtension("KHR_parallel_shader_compile")}_loadParameters(t){var _;const e=this.capabilities.textureFilterAnisotropic,i=(_=t.maxAnisotropy)!=null?_:1/0,s=S(this.gl),a=this.gl,o={versionString:this.gl.getParameter(this.gl.VERSION),maxVertexTextureImageUnits:this.gl.getParameter(this.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxVertexAttributes:this.gl.getParameter(this.gl.MAX_VERTEX_ATTRIBS),maxMaxAnisotropy:e?Math.min(this.gl.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY),i):1,maxTextureImageUnits:this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),maxTextureSize:this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE),maxUniformBufferBindings:s?a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS):0,maxVertexUniformBlocks:s?a.getParameter(a.MAX_VERTEX_UNIFORM_BLOCKS):0,maxFragmentUniformBlocks:s?a.getParameter(a.MAX_FRAGMENT_UNIFORM_BLOCKS):0,maxUniformBlockSize:s?a.getParameter(a.MAX_UNIFORM_BLOCK_SIZE):0,uniformBufferOffsetAlignment:s?a.getParameter(a.UNIFORM_BUFFER_OFFSET_ALIGNMENT):1,maxArrayTextureLayers:s?a.getParameter(a.MAX_ARRAY_TEXTURE_LAYERS):1,maxSamples:s?a.getParameter(a.MAX_SAMPLES):1};return dt.TEXTURE_UNIT_FOR_UPDATES=o.maxTextureImageUnits-1,o}}function P(r,t,e,i){return t?i!==t&&r.bindBuffer(e,t.glName):r.bindBuffer(e,null),t}function Mt(r,t){switch(r){case X.POINTS:return 2*t;case X.TRIANGLES:return t/3;case X.TRIANGLE_STRIP:case X.TRIANGLE_FAN:return t-2;default:return 0}}export{se as T,ye as o,De as y};
|