import{M as L,N as C}from"./index-b5c8f851.js";import{P as d,G as T,U as A,L as _,D as h,o}from"./enums-bdecffa2.js";import{e as E,T as O}from"./Texture-507d5ea8.js";function x(e,n,t="nearest",i=!1){var c;const a=!(i&&n.pixelType==="u8"),s=a?A.FLOAT:A.UNSIGNED_BYTE,u=n.pixels==null||n.pixels.length===0?null:a?n.getAsRGBAFloat():n.getAsRGBA(),f=(c=e.capabilities.textureFloat)==null?void 0:c.textureFloatLinear,r=new E;return r.width=n.width,r.height=n.height,r.internalFormat=e.type===L.WEBGL2&&a?d.RGBA32F:T.RGBA,r.samplingMode=!f||t!=="bilinear"&&t!=="cubic"?_.NEAREST:_.LINEAR,r.dataType=s,r.wrapMode=h.CLAMP_TO_EDGE,new O(e,r,u)}function F(e,n){const{spacing:t,offsets:i,coefficients:a,size:[s,u]}=n,f=t[0]>1,r=new E;r.width=f?4*s:s,r.height=u,r.internalFormat=e.type===L.WEBGL2?d.RGBA32F:T.RGBA,r.dataType=A.FLOAT,r.samplingMode=_.NEAREST,r.wrapMode=h.CLAMP_TO_EDGE;const c=new Float32Array(f?s*u*16:2*i.length);if(f&&a!=null)for(let m=0,l=0;m{const a=n.get(i)||n.get(i+"[0]");a&&M(e,i,t[i],a)})}function I(e,n,t,i){t.length===i.length&&(i.some(a=>a==null)||t.some(a=>a==null)||t.forEach((a,s)=>{n.setUniform1i(a,s),e.bindTexture(i[s],s)}))}function M(e,n,t,i){if(i===null||t==null)return!1;const{info:a}=i;switch(a.type){case o.FLOAT:a.size>1?e.setUniform1fv(n,t):e.setUniform1f(n,t);break;case o.FLOAT_VEC2:e.setUniform2fv(n,t);break;case o.FLOAT_VEC3:e.setUniform3fv(n,t);break;case o.FLOAT_VEC4:e.setUniform4fv(n,t);break;case o.FLOAT_MAT3:e.setUniformMatrix3fv(n,t);break;case o.FLOAT_MAT4:e.setUniformMatrix4fv(n,t);break;case o.INT:a.size>1?e.setUniform1iv(n,t):e.setUniform1i(n,t);break;case o.BOOL:e.setUniform1i(n,t?1:0);break;case o.INT_VEC2:case o.BOOL_VEC2:e.setUniform2iv(n,t);break;case o.INT_VEC3:case o.BOOL_VEC3:e.setUniform3iv(n,t);break;case o.INT_VEC4:case o.BOOL_VEC4:e.setUniform4iv(n,t);break;default:return!1}return!0}export{k as A,v as E,I as O,y as T,B as _,x as c,N as g,R as h,G as l,F as m,V as p};