12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{Z as e}from"../../chunks/vec2f64.js";import{ContextType as t}from"./context-util.js";import{PixelType as n,TextureType as a,PixelFormat as r,SizedPixelFormat as i,TextureSamplingMode as o,TextureWrapMode as s,UniformType as u}from"./enums.js";import{Texture as f}from"./Texture.js";function m(e,u,m="nearest",c=!1){const l=!(c&&"u8"===u.pixelType),_=l?n.FLOAT:n.UNSIGNED_BYTE,p=null==u.pixels||0===u.pixels.length?null:l?u.getAsRGBAFloat():u.getAsRGBA(),g=e.capabilities.textureFloat?.textureFloatLinear,T={width:u.width,height:u.height,target:a.TEXTURE_2D,pixelFormat:r.RGBA,internalFormat:e.type===t.WEBGL2&&l?i.RGBA32F:r.RGBA,samplingMode:!g||"bilinear"!==m&&"cubic"!==m?o.NEAREST:o.LINEAR,dataType:_,wrapMode:s.CLAMP_TO_EDGE,flipped:!1};return new f(e,T,p)}function c(e,u){const{spacing:m,offsets:c,coefficients:l,size:[_,p]}=u,g=m[0]>1,T={width:g?4*_:_,height:p,target:a.TEXTURE_2D,pixelFormat:r.RGBA,internalFormat:e.type===t.WEBGL2?i.RGBA32F:r.RGBA,dataType:n.FLOAT,samplingMode:o.NEAREST,wrapMode:s.CLAMP_TO_EDGE,flipped:!1},E=new Float32Array(g?_*p*16:2*c.length);if(g)for(let t=0,n=0;t<l.length;t++)E[n++]=l[t],t%3==2&&(E[n++]=1);else for(let t=0;t<p;t++)for(let e=0;e<_;e++){const n=4*(t*_+e),a=2*(e*p+t);E[n]=c[a],E[n+1]=c[a+1],E[n+3]=-1===c[a]?0:1}return new f(e,T,E)}function l(e,t){const i={width:t.length/4,height:1,target:a.TEXTURE_2D,pixelFormat:r.RGBA,internalFormat:r.RGBA,dataType:n.UNSIGNED_BYTE,samplingMode:o.NEAREST,wrapMode:s.CLAMP_TO_EDGE,flipped:!1};return new f(e,i,t)}function _(t,n,a,r=1,i=!0){return{u_flipY:i,u_applyTransform:!!t,u_opacity:r,u_transformSpacing:t?t.spacing:e,u_transformGridSize:t?t.size:e,u_targetImageSize:n,u_srcImageSize:a}}function p(e,t){return{u_colormapOffset:t||0,u_colormapMaxIndex:e?e.length/4-1:0}}function g(e,t){return{u_scale:e,u_offset:t}}function T(e){return{u_bandCount:e.bandCount,u_minOutput:e.outMin,u_maxOutput:e.outMax,u_minCutOff:e.minCutOff,u_maxCutOff:e.maxCutOff,u_factor:e.factor,u_useGamma:e.useGamma,u_gamma:e.gamma,u_gammaCorrection:e.gammaCorrection}}function E(e){return{u_hillshadeType:e.hillshadeType,u_sinZcosAs:e.sinZcosAs,u_sinZsinAs:e.sinZsinAs,u_cosZs:e.cosZs,u_weights:e.weights,u_factor:e.factor,u_minValue:e.minValue,u_maxValue:e.maxValue}}function A(e,t){const n=e.gl,a=t.glName,r=n.getProgramParameter(a,n.ACTIVE_UNIFORMS),i=new Map;let o;for(let s=0;s<r;s++)o=n.getActiveUniform(a,s),o&&i.set(o.name,{location:n.getUniformLocation(a,o.name),info:o});return i}function h(e,t,n){Object.keys(n).forEach((a=>{const r=t.get(a)||t.get(a+"[0]");r&&d(e,a,n[a],r)}))}function O(e,t,n,a){n.length===a.length&&(a.some((e=>null==e))||n.some((e=>null==e))||n.forEach(((n,r)=>{t.setUniform1i(n,r),e.bindTexture(a[r],r)})))}function d(e,t,n,a){if(null===a||null==n)return!1;const{info:r}=a;switch(r.type){case u.FLOAT:r.size>1?e.setUniform1fv(t,n):e.setUniform1f(t,n);break;case u.FLOAT_VEC2:e.setUniform2fv(t,n);break;case u.FLOAT_VEC3:e.setUniform3fv(t,n);break;case u.FLOAT_VEC4:e.setUniform4fv(t,n);break;case u.FLOAT_MAT3:e.setUniformMatrix3fv(t,n);break;case u.FLOAT_MAT4:e.setUniformMatrix4fv(t,n);break;case u.INT:r.size>1?e.setUniform1iv(t,n):e.setUniform1i(t,n);break;case u.BOOL:e.setUniform1i(t,n?1:0);break;case u.INT_VEC2:case u.BOOL_VEC2:e.setUniform2iv(t,n);break;case u.INT_VEC3:case u.BOOL_VEC3:e.setUniform3iv(t,n);break;case u.INT_VEC4:case u.BOOL_VEC4:e.setUniform4iv(t,n);break;default:return!1}return!0}export{l as createColormapTexture,m as createRasterTexture,c as createTransformTexture,g as getBasicGridUniforms,p as getColormapUniforms,_ as getCommonUniforms,E as getShadedReliefUniforms,T as getStretchUniforms,A as getUniformLocationInfos,O as setTextures,h as setUniforms};
|