UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.31 kB
import{isSome as e,unwrapOr as t}from"../../../../../core/maybe.js";import{WGLGeometryType as o,WGLSymbologyType as r}from"../enums.js";import{createProgramDescriptor as a}from"../Utils.js";import i from"./WGLGeometryBrush.js";import{FillMaterialKey as n}from"../materialKey/MaterialKey.js";import{getTechniqueFromMaterialKey as s}from"../techniques/utils.js";import{PrimitiveType as m,DataType as l}from"../../../../webgl/enums.js";function u(e){const t={geometry:[{location:0,name:"a_pos",count:2,type:l.SHORT},{location:1,name:"a_id",count:3,type:l.UNSIGNED_BYTE},{location:2,name:"a_bitset",count:1,type:l.UNSIGNED_BYTE},{location:3,name:"a_color",count:4,type:l.UNSIGNED_BYTE,normalized:!0},{location:4,name:"a_aux1",count:4,type:l.UNSIGNED_SHORT},{location:5,name:"a_aux2",count:4,type:l.SHORT},{location:6,name:"a_aux3",count:4,type:l.UNSIGNED_BYTE},{location:7,name:"a_zoomRange",count:2,type:l.UNSIGNED_SHORT}]};switch(e.symbologyType){case r.SIMPLE:case r.OUTLINE_FILL_SIMPLE:t.geometry.splice(7,1),t.geometry.splice(4,1)}return{shader:"materials/fill",vertexLayout:t}}class c extends i{dispose(){}getGeometryType(){return o.FILL}supportsSymbology(e){return e!==r.DOT_DENSITY}drawGeometry(o,r,i,l){const{context:c,painter:y,rendererInfo:p,requiredLevel:_,passOptions:d,requestRender:f,allowDelayedRender:E}=o,S=n.load(i.materialKey),g=s(S.data),N=e(d)&&"hittest"===d.type,T=y.materialManager,{shader:I,vertexLayout:U,hittestAttributes:x}=t(g.programSpec,u(S));let L=m.TRIANGLES,h=a(S.data,U);N&&(h=this._getTriangleDesc(i.materialKey,h,x),L=m.POINTS);const{attributes:G,bufferLayouts:O}=h,b=T.getMaterialProgram(o,S,I,G,l);if(E&&e(f)&&!b.compiled)return void f();if(c.useProgram(b),this._setSharedUniforms(b,o,r),b.setUniform2f("u_tileOffset",512*r.key.col,512*r.key.row),S.textureBinding){y.textureManager.bindTextures(c,b,S);const e=1/2**(_-r.key.level);b.setUniform1f("u_zoomFactor",e)}const D=1/o.pixelRatio;b.setUniform1f("u_blur",D),b.setUniform1f("u_antialiasing",D),this._setSizeVVUniforms(S,b,p,r),this._setColorAndOpacityVVUniforms(S,b,p);const R=i.target.getVAO(c,O,G,N);let w=i.indexCount,j=i.indexFrom*Uint32Array.BYTES_PER_ELEMENT;N&&(w/=3,j/=3),c.bindVAO(R),this._drawFills(o,r,b,L,w,j)}_drawFills(e,t,o,r,a,i){e.context.drawElements(r,a,l.UNSIGNED_INT,i)}}export{c as default};