10 lines
21 KiB
JavaScript
10 lines
21 KiB
JavaScript
import{ax as A,M as V,iI as ae,z as se,iJ as le,eA as ce}from"./index-b5c8f851.js";import{H as p,V as y}from"./enums-bdecffa2.js";import{c as E,i as fe,o as ue}from"./Texture-507d5ea8.js";const he=["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"];var O,H={exports:{}};(O=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"])!==void 0&&(H.exports=O);const de=A(H.exports);var j,P={exports:{}};P.exports,j=P,function(i){var e=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"];e!==void 0&&(j.exports=e)}();const B=A(P.exports);var q={exports:{}};(function(i){(function(e){var t=function(){return["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT","textureSize","texelFetch"]}();t!==void 0&&(i.exports=t)})()})(q);const ge=A(q.exports);var _=999,F=9999,w=0,D=1,R=2,N=3,$=4,M=5,me=6,_e=7,pe=8,I=9,xe=10,G=11,ye=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function ve(){var i,e,t,r=0,a=0,o=_,n=[],l=[],s=1,c=0,f=0,h=!1,m=!1,g="";return function(u){return l=[],u!==null?K(u.replace?u.replace(/\r\n/g,`
|
|
`):u):Q()};function d(u){u.length&&l.push({type:ye[o],data:u,position:f,line:s,column:c})}function K(u){var v;for(r=0,t=(g+=u).length;i=g[r],r<t;){switch(v=r,o){case w:r=ee();break;case D:r=Z();break;case R:r=C();break;case N:r=te();break;case $:r=ie();break;case G:r=re();break;case M:r=ne();break;case F:r=oe();break;case I:r=Y();break;case _:r=J()}v!==r&&(g[v]===`
|
|
`?(c=0,++s):++c)}return a+=r,g=g.slice(r),l}function Q(u){return n.length&&d(n.join("")),o=xe,d("(eof)"),l}function J(){return n=n.length?[]:n,e==="/"&&i==="*"?(f=a+r-1,o=w,e=i,r+1):e==="/"&&i==="/"?(f=a+r-1,o=D,e=i,r+1):i==="#"?(o=R,f=a+r,r):/\s/.test(i)?(o=I,f=a+r,r):(h=/\d/.test(i),m=/[^\w_]/.test(i),f=a+r,o=h?$:m?N:F,r)}function Y(){return/[^\s]/g.test(i)?(d(n.join("")),o=_,r):(n.push(i),e=i,r+1)}function C(){return i!=="\r"&&i!==`
|
|
`||e==="\\"?(n.push(i),e=i,r+1):(d(n.join("")),o=_,r)}function Z(){return C()}function ee(){return i==="/"&&e==="*"?(n.push(i),d(n.join("")),o=_,r+1):(n.push(i),e=i,r+1)}function te(){if(e==="."&&/\d/.test(i))return o=M,r;if(e==="/"&&i==="*")return o=w,r;if(e==="/"&&i==="/")return o=D,r;if(i==="."&&n.length){for(;U(n););return o=M,r}if(i===";"||i===")"||i==="("){if(n.length)for(;U(n););return d(i),o=_,r+1}var u=n.length===2&&i!=="=";if(/[\w_\d\s]/.test(i)||u){for(;U(n););return o=_,r}return n.push(i),e=i,r+1}function U(u){for(var v,b,k=0;;){if(v=B.indexOf(u.slice(0,u.length+k).join("")),b=B[v],v===-1){if(k--+u.length>0)continue;b=u.slice(0,1).join("")}return d(b),f+=b.length,(n=n.slice(b.length)).length}}function re(){return/[^a-fA-F0-9]/.test(i)?(d(n.join("")),o=_,r):(n.push(i),e=i,r+1)}function ie(){return i==="."||/[eE]/.test(i)?(n.push(i),o=M,e=i,r+1):i==="x"&&n.length===1&&n[0]==="0"?(o=G,n.push(i),e=i,r+1):/[^\d]/.test(i)?(d(n.join("")),o=_,r):(n.push(i),e=i,r+1)}function ne(){return i==="f"&&(n.push(i),e=i,r+=1),/[eE]/.test(i)||i==="-"&&/[eE]/.test(e)?(n.push(i),e=i,r+1):/[^\d]/.test(i)?(d(n.join("")),o=_,r):(n.push(i),e=i,r+1)}function oe(){if(/[^\d\w_]/.test(i)){var u=n.join("");return o=de.indexOf(u)>-1?pe:ge.indexOf(u)>-1?_e:me,d(n.join("")),o=_,r}return n.push(i),e=i,r+1}}function Te(i){var e=ve(),t=[];return t=(t=t.concat(e(i))).concat(e(null))}function be(i){return Te(i)}function Se(i){return i.map(e=>e.type!=="eof"?e.data:"").join("")}const L=new Set(["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"]);function Me(i,e="100",t="300 es"){const r=/^\s*\#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const a of i)if(a.type==="preprocessor"){const o=r.exec(a.data);if(o){const n=o[1].replaceAll(/\s\s+/g," ");if(n===t)return n;if(n===e)return a.data="#version "+t,e;throw new Error("unknown glsl version: "+n)}}return i.splice(0,0,{type:"preprocessor",data:"#version "+t},{type:"whitespace",data:`
|
|
`}),null}function Ue(i,e){for(let t=e-1;t>=0;t--){const r=i[t];if(r.type!=="whitespace"&&r.type!=="block-comment"){if(r.type!=="keyword")break;if(r.data==="attribute"||r.data==="in")return!0}}return!1}function S(i,e,t,r){r=r||t;for(const a of i)if(a.type==="ident"&&a.data===t)return r in e?e[r]++:e[r]=0,S(i,e,r+"_"+e[r],r);return t}function W(i,e,t="afterVersion"){function r(s,c){for(let f=c;f<s.length;f++){const h=s[f];if(h.type==="operator"&&h.data===";")return f}return null}function a(s){let c=-1,f=0,h=-1;for(let m=0;m<s.length;m++){const g=s[m];if(g.type==="preprocessor"&&(/\#(if|ifdef|ifndef)\s+.+/.test(g.data)?++f:/\#endif\s*.*/.test(g.data)&&--f),t!=="afterVersion"&&t!=="afterPrecision"||g.type==="preprocessor"&&g.data.startsWith("#version")&&(h=Math.max(h,m)),t==="afterPrecision"&&g.type==="keyword"&&g.data==="precision"){const d=r(s,m);if(d===null)throw new Error("precision statement not followed by any semicolons!");h=Math.max(h,d)}c<h&&f===0&&(c=m)}return c+1}const o={data:`
|
|
`,type:"whitespace"},n=s=>s<i.length&&/[^\r\n]$/.test(i[s].data);let l=a(i);n(l-1)&&i.splice(l++,0,o);for(const s of e)i.splice(l++,0,s);n(l-1)&&n(l)&&i.splice(l,0,o)}function we(i,e,t,r="lowp"){W(i,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"keyword",data:t},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function De(i,e,t,r,a="lowp"){W(i,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:r.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:a},{type:"whitespace",data:" "},{type:"keyword",data:t},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function Le(i,e){let t,r,a=-1;for(let o=e;o<i.length;o++){const n=i[o];if(n.type==="operator"&&(n.data==="["&&(t=o),n.data==="]")){r=o;break}n.type==="integer"&&(a=parseInt(n.data,10))}return t&&r&&i.splice(t,r-t+1),a}function X(i,e){if(i.startsWith("#version 300"))return i;const t=be(i);if(Me(t,"100","300 es")==="300 es")return i;let r=null,a=null;const o={},n={};for(let l=0;l<t.length;++l){const s=t[l];switch(s.type){case"keyword":e===p.VERTEX_SHADER&&s.data==="attribute"?s.data="in":s.data==="varying"&&(s.data=e===p.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(s.data.trim())&&(s.data=s.data.replaceAll(/(2D|Cube|EXT)/g,"")),e===p.FRAGMENT_SHADER&&s.data==="gl_FragColor"&&(r||(r=S(t,o,"fragColor"),we(t,r,"vec4")),s.data=r),e===p.FRAGMENT_SHADER&&s.data==="gl_FragData"){const c=Le(t,l+1),f=S(t,o,"fragData");De(t,f,"vec4",c,"mediump"),s.data=f}else e===p.FRAGMENT_SHADER&&s.data==="gl_FragDepthEXT"&&(a||(a=S(t,o,"gl_FragDepth")),s.data=a);break;case"ident":if(he.includes(s.data)){if(e===p.VERTEX_SHADER&&Ue(t,l))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");s.data in n||(n[s.data]=S(t,o,s.data)),s.data=n[s.data]}}}for(let l=t.length-1;l>=0;--l){const s=t[l];if(s.type==="preprocessor"){const c=s.data.match(/\#extension\s+(.*)\:/);if(c&&c[1]&&L.has(c[1].trim())){const m=t[l+1];t.splice(l,m&&m.type==="whitespace"?2:1)}const f=s.data.match(/\#ifdef\s+(.*)/);f&&f[1]&&L.has(f[1].trim())&&(s.data="#if 1");const h=s.data.match(/\#ifndef\s+(.*)/);h&&h[1]&&L.has(h[1].trim())&&(s.data="#if 0")}}return Ee(i,Se(t))}function Ee(i,e){return e}const Pe=4294967295;class Ae{constructor(e,t,r,a,o=new Map){this._context=e,this._locations=a,this._uniformBlockBindings=o,this._refCount=1,this._compiled=!1,this._linesOfCode=0,this._nameToUniformLocation=new Map,this._nameToUniform1=new Map,this._nameToUniform1v=new Map,this._nameToUniform2=new Map,this._nameToUniform3=new Map,this._nameToUniform4=new Map,this._nameToUniformMatrix3=new Map,this._nameToUniformMatrix4=new Map,e||console.error("RenderingContext isn't initialized!"),t.length===0&&console.error("Shaders source should not be empty!"),this._context.type===V.WEBGL2&&(t=X(t,p.VERTEX_SHADER),r=X(r,p.FRAGMENT_SHADER)),this._vShader=z(this._context,p.VERTEX_SHADER,t),this._fShader=z(this._context,p.FRAGMENT_SHADER,r),Ve.enabled&&(this._linesOfCode=t.match(/\n/g).length+r.match(/\n/g).length+2,this._context.instanceCounter.increment(y.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(y.Shader,this),E()&&(this.vertexShader=t,this.fragmentShader=r);const n=this._context.gl,l=n.createProgram();if(n.attachShader(l,this._vShader),n.attachShader(l,this._fShader),this._locations.forEach((s,c)=>n.bindAttribLocation(l,s,c)),n.linkProgram(l),E()&&!n.getProgramParameter(l,n.LINK_STATUS)&&console.error(`Could not link shader
|
|
validated: ${n.getProgramParameter(l,n.VALIDATE_STATUS)}, gl error ${n.getError()}, vertex: ${n.getShaderParameter(this._vShader,n.COMPILE_STATUS)}, fragment: ${n.getShaderParameter(this._fShader,n.COMPILE_STATUS)}, info log: ${n.getProgramInfoLog(l)}, vertex source: ${this.vertexShader}, fragment source: ${this.fragmentShader}`),this._context.type===V.WEBGL2){const s=n;for(const[c,f]of this._uniformBlockBindings){const h=s.getUniformBlockIndex(l,c);h<Pe&&s.uniformBlockBinding(l,h,f)}}this._glName=l,this._context.instanceCounter.increment(y.Program,this)}get glName(){return this._glName}get hasGLName(){return this._glName!=null}get compiled(){if(this._compiled)return!0;const e=this._context.gl.getExtension("KHR_parallel_shader_compile");return e==null||this.glName==null?(this._compiled=!0,!0):(this._compiled=!!this._context.gl.getProgramParameter(this.glName,e.COMPLETION_STATUS_KHR),this._compiled)}dispose(){if(--this._refCount>0)return;const e=this._context.gl,t=this._context.instanceCounter;this._nameToUniformLocation.forEach(r=>r&&t.decrement(y.Uniform,r)),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(t.decrement(y.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),e.deleteShader(this._vShader),this._vShader=null,t.decrement(y.Shader,this)),this._fShader&&(e.deleteShader(this._fShader),this._fShader=null),this._glName&&(e.deleteProgram(this._glName),this._glName=null,t.decrement(y.Program,this))}ref(){++this._refCount}_getUniformLocation(e){const t=this._nameToUniformLocation.get(e);if(t!==void 0)return t;if(this.glName){const r=this._context.gl.getUniformLocation(this.glName,e);return this._nameToUniformLocation.set(e,r),r&&this._context.instanceCounter.increment(y.Uniform,r),r}return null}hasUniform(e){return this._getUniformLocation(e)!=null}setUniform1i(e,t){const r=this._nameToUniform1.get(e);r!==void 0&&t===r||(this._context.gl.uniform1i(this._getUniformLocation(e),t),this._nameToUniform1.set(e,t))}setUniform1iv(e,t){x(this._nameToUniform1v,e,t)&&this._context.gl.uniform1iv(this._getUniformLocation(e),t)}setUniform2iv(e,t){x(this._nameToUniform2,e,t)&&this._context.gl.uniform2iv(this._getUniformLocation(e),t)}setUniform3iv(e,t){x(this._nameToUniform3,e,t)&&this._context.gl.uniform3iv(this._getUniformLocation(e),t)}setUniform4iv(e,t){x(this._nameToUniform4,e,t)&&this._context.gl.uniform4iv(this._getUniformLocation(e),t)}setUniform1f(e,t){const r=this._nameToUniform1.get(e);r!==void 0&&t===r||(this._context.gl.uniform1f(this._getUniformLocation(e),t),this._nameToUniform1.set(e,t))}setUniform1fv(e,t){x(this._nameToUniform1v,e,t)&&this._context.gl.uniform1fv(this._getUniformLocation(e),t)}setUniform2f(e,t,r){const a=this._nameToUniform2.get(e);a===void 0?(this._context.gl.uniform2f(this._getUniformLocation(e),t,r),this._nameToUniform2.set(e,[t,r])):t===a[0]&&r===a[1]||(this._context.gl.uniform2f(this._getUniformLocation(e),t,r),a[0]=t,a[1]=r)}setUniform2fv(e,t){x(this._nameToUniform2,e,t)&&this._context.gl.uniform2fv(this._getUniformLocation(e),t)}setUniform3f(e,t,r,a){const o=this._nameToUniform3.get(e);o===void 0?(this._context.gl.uniform3f(this._getUniformLocation(e),t,r,a),this._nameToUniform3.set(e,[t,r,a])):t===o[0]&&r===o[1]&&a===o[2]||(this._context.gl.uniform3f(this._getUniformLocation(e),t,r,a),o[0]=t,o[1]=r,o[2]=a)}setUniform3fv(e,t){x(this._nameToUniform3,e,t)&&this._context.gl.uniform3fv(this._getUniformLocation(e),t)}setUniform4f(e,t,r,a,o){const n=this._nameToUniform4.get(e);n===void 0?(this._context.gl.uniform4f(this._getUniformLocation(e),t,r,a,o),this._nameToUniform4.set(e,[t,r,a,o])):n!==void 0&&t===n[0]&&r===n[1]&&a===n[2]&&o===n[3]||(this._context.gl.uniform4f(this._getUniformLocation(e),t,r,a,o),n[0]=t,n[1]=r,n[2]=a,n[3]=o)}setUniform4fv(e,t){x(this._nameToUniform4,e,t)&&this._context.gl.uniform4fv(this._getUniformLocation(e),t)}setUniformMatrix3fv(e,t,r=!1){x(this._nameToUniformMatrix3,e,t)&&this._context.gl.uniformMatrix3fv(this._getUniformLocation(e),r,t)}setUniformMatrix4fv(e,t,r=!1){x(this._nameToUniformMatrix4,e,t)&&this._context.gl.uniformMatrix4fv(this._getUniformLocation(e),r,t)}stop(){}}function z(i,e,t){const r=i.gl,a=r.createShader(e);return r.shaderSource(a,t),r.compileShader(a),E()&&!r.getShaderParameter(a,r.COMPILE_STATUS)&&(console.error("Compile error in ".concat(e===p.VERTEX_SHADER?"vertex":"fragment"," shader")),console.error(r.getShaderInfoLog(a)),console.error(Ce(t))),a}function Ce(i){let e=2;return i.replaceAll(`
|
|
`,()=>`
|
|
`+ke(e++)+":")}function ke(i){return i>=1e3?i.toString():(" "+i).slice(-3)}function x(i,e,t){const r=i.get(e);return r?ae(r,t):(i.set(e,Array.from(t)),!0)}const Ve={enabled:!1};let Fe=class{constructor(e){this._readFile=e}resolveIncludes(e){return this._resolve(e)}_resolve(e,t=new Map){if(t.has(e))return t.get(e);const r=this._read(e);if(!r)throw new Error(`cannot find shader file ${e}`);const a=/^[^\S\n]*#include\s+<(\S+)>[^\S\n]?/gm;let o=a.exec(r);const n=[];for(;o!=null;)n.push({path:o[1],start:o.index,length:o[0].length}),o=a.exec(r);let l=0,s="";return n.forEach(c=>{s+=r.slice(l,c.start),s+=t.has(c.path)?"":this._resolve(c.path,t),l=c.start+c.length}),s+=r.slice(l),t.set(e,s),s}_read(e){return this._readFile(e)}};const T=se.getLogger("esri.views.webgl.VertexArrayObject");let Ne=class{constructor(e,t,r,a,o=null){this._context=e,this._locations=t,this._layout=r,this._buffers=a,this._indexBuffer=o,this._glName=null,this._initialized=!1}get glName(){return this._glName}get context(){return this._context}get vertexBuffers(){return this._buffers}get indexBuffer(){return this._indexBuffer}get byteSize(){return Object.keys(this._buffers).reduce((e,t)=>e+this._buffers[t].byteLength,this._indexBuffer!=null?this._indexBuffer.byteLength:0)}get layout(){return this._layout}get locations(){return this._locations}get usedMemory(){return this.byteSize+(Object.keys(this._buffers).length+(this._indexBuffer?1:0))*le}dispose(){var e;if(this._context){this._context.getBoundVAO()===this&&this._context.bindVAO(null);for(const t in this._buffers)(e=this._buffers[t])==null||e.dispose(),delete this._buffers[t];this._indexBuffer=ce(this._indexBuffer),this.disposeVAOOnly()}else(this._glName||Object.getOwnPropertyNames(this._buffers).length>0)&&T.warn("Leaked WebGL VAO")}disposeVAOOnly(){var e,t;this._glName&&(((t=(e=this._context)==null?void 0:e.capabilities)==null?void 0:t.vao).deleteVertexArray(this._glName),this._glName=null,this._context.instanceCounter.decrement(y.VertexArrayObject,this)),this._context=null}initialize(){if(this._initialized)return;const e=this._context.capabilities.vao;if(e){const t=e.createVertexArray();e.bindVertexArray(t),this._bindLayout(),e.bindVertexArray(null),this._glName=t,this._context.instanceCounter.increment(y.VertexArrayObject,this)}this._initialized=!0}bind(){this.initialize();const e=this._context.capabilities.vao;e?e.bindVertexArray(this.glName):(this._context.bindVAO(null),this._bindLayout())}_bindLayout(){const{_buffers:e,_layout:t,_indexBuffer:r}=this;e||T.error("Vertex buffer dictionary is empty!");const a=this._context.gl;for(const o in e){const n=e[o];n||T.error("Vertex buffer is uninitialized!");const l=t[o];l||T.error("Vertex element descriptor is empty!"),fe(this._context,this._locations,n,l)}r!=null&&(this._context.capabilities.vao?a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,r.glName):this._context.bindBuffer(r))}unbind(){this.initialize();const e=this._context.capabilities.vao;e?e.bindVertexArray(null):this._unbindLayout()}_unbindLayout(){const{_buffers:e,_layout:t}=this;e||T.error("Vertex buffer dictionary is empty!");for(const r in e){const a=e[r];a||T.error("Vertex buffer is uninitialized!");const o=t[r];ue(this._context,this._locations,a,o)}this._indexBuffer!=null&&this._context.unbindBuffer(this._indexBuffer.bufferType)}};function Ie(i,e,t=""){return new Ae(i,t+e.shaders.vertexShader,t+e.shaders.fragmentShader,e.attributes)}export{Ie as a,Fe as e,Ne as f,Ae as m};
|