12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/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,TargetType as u,DepthStencilTargetType as f,UniformType as m}from"./enums.js";import{FramebufferObject as c}from"./FramebufferObject.js";import{Texture as l}from"./Texture.js";function _(e,u,f="nearest",m=!1){const c=!(m&&"u8"===u.pixelType),_=c?n.FLOAT:n.UNSIGNED_BYTE,p=null==u.pixels||0===u.pixels.length?null:c?u.getAsRGBAFloat():u.getAsRGBA(),E=e.capabilities.textureFloat?.textureFloatLinear,T={width:u.width,height:u.height,target:a.TEXTURE_2D,pixelFormat:r.RGBA,internalFormat:e.type===t.WEBGL2&&c?i.RGBA32F:r.RGBA,samplingMode:!E||"bilinear"!==f&&"cubic"!==f?o.NEAREST:o.LINEAR,dataType:_,wrapMode:s.CLAMP_TO_EDGE,flipped:!1};return new l(e,T,p)}function p(e,t,i,m){const _=m?n.UNSIGNED_BYTE:n.FLOAT,p={width:t,height:i,target:a.TEXTURE_2D,pixelFormat:r.RGBA,internalFormat:r.RGBA,samplingMode:o.NEAREST,dataType:_,wrapMode:s.CLAMP_TO_EDGE,flipped:!1},E=new l(e,p);return new c(e,{colorTarget:u.TEXTURE,depthStencilTarget:f.DEPTH_STENCIL_RENDER_BUFFER,width:t,height:i},E)}function E(e,u){const{spacing:f,offsets:m,coefficients:c,size:[_,p]}=u,E=f[0]>1,T={width:E?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},g=new Float32Array(E?_*p*16:2*m.length);if(E)for(let t=0,n=0;t<c.length;t++)g[n++]=c[t],t%3==2&&(g[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);g[n]=m[a],g[n+1]=m[a+1],g[n+3]=-1===m[a]?0:1}return new l(e,T,g)}function T(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 l(e,i,t)}function g(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 A(e,t){return{u_colormapOffset:t||0,u_colormapMaxIndex:e?e.length/4-1:0}}function h(e,t){return{u_scale:e,u_offset:t}}function d(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 O(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 F(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 R(e,t,n){Object.keys(n).forEach((a=>{const r=t.get(a)||t.get(a+"[0]");r&&G(e,a,n[a],r)}))}function U(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 G(e,t,n,a){if(null===a||null==n)return!1;const{info:r}=a;switch(r.type){case m.FLOAT:r.size>1?e.setUniform1fv(t,n):e.setUniform1f(t,n);break;case m.FLOAT_VEC2:e.setUniform2fv(t,n);break;case m.FLOAT_VEC3:e.setUniform3fv(t,n);break;case m.FLOAT_VEC4:e.setUniform4fv(t,n);break;case m.FLOAT_MAT3:e.setUniformMatrix3fv(t,n);break;case m.FLOAT_MAT4:e.setUniformMatrix4fv(t,n);break;case m.INT:r.size>1?e.setUniform1iv(t,n):e.setUniform1i(t,n);break;case m.BOOL:e.setUniform1i(t,n?1:0);break;case m.INT_VEC2:case m.BOOL_VEC2:e.setUniform2iv(t,n);break;case m.INT_VEC3:case m.BOOL_VEC3:e.setUniform3iv(t,n);break;case m.INT_VEC4:case m.BOOL_VEC4:e.setUniform4iv(t,n);break;default:return!1}return!0}export{T as createColormapTexture,p as createFrameBuffer,_ as createRasterTexture,E as createTransformTexture,h as getBasicGridUniforms,A as getColormapUniforms,g as getCommonUniforms,O as getShadedReliefUniforms,d as getStretchUniforms,F as getUniformLocationInfos,U as setTextures,R as setUniforms};
|