UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.13 kB
import{isSome as t}from"../../../../../core/maybe.js";import{WGLGeometryType as e}from"../enums.js";import{createProgramDescriptor as o}from"../Utils.js";import a from"./WGLGeometryBrush.js";import{TextMaterialKey as r}from"../materialKey/MaterialKey.js";import{PrimitiveType as s,DataType as n}from"../../../../webgl/enums.js";const i=t=>o(t.data,{geometry:[{location:0,name:"a_pos",count:2,type:n.SHORT},{location:1,name:"a_id",count:4,type:n.UNSIGNED_BYTE},{location:2,name:"a_color",count:4,type:n.UNSIGNED_BYTE,normalized:!0},{location:3,name:"a_haloColor",count:4,type:n.UNSIGNED_BYTE,normalized:!0},{location:4,name:"a_texFontSize",count:4,type:n.UNSIGNED_BYTE},{location:5,name:"a_aux",count:4,type:n.BYTE},{location:6,name:"a_zoomRange",count:2,type:n.UNSIGNED_SHORT},{location:7,name:"a_vertexOffset",count:2,type:n.SHORT},{location:8,name:"a_texCoords",count:2,type:n.UNSIGNED_SHORT}]});class m extends a{dispose(){}getGeometryType(){return e.TEXT}supportsSymbology(t){return!0}drawGeometry(e,o,a,m){const{context:l,painter:u,rendererInfo:d,state:f,passOptions:_,requestRender:p,allowDelayedRender:c}=e,y=r.load(a.materialKey),E=t(_)&&"hittest"===_.type,{bufferLayouts:N,attributes:U}=i(y),S=u.materialManager.getMaterialProgram(e,y,"materials/text",U,m);if(c&&t(p)&&!S.compiled)return void p();l.useProgram(S);let T=s.TRIANGLES;E&&(T=s.POINTS),this._setSharedUniforms(S,e,o),u.textureManager.bindTextures(l,S,y),S.setUniformMatrix3fv("u_displayMat3",f.displayMat3),S.setUniformMatrix3fv("u_displayViewMat3",f.displayViewMat3),this._setSizeVVUniforms(y,S,d,o),this._setColorAndOpacityVVUniforms(y,S,d),this._setRotationVVUniforms(y,S,d);const x=a.target.getVAO(l,N,U),I=a.indexFrom*Uint32Array.BYTES_PER_ELEMENT;S.setUniform1f("u_isHaloPass",0),S.setUniform1f("u_isBackgroundPass",1),l.bindVAO(x),l.drawElements(T,a.indexCount,n.UNSIGNED_INT,I),S.setUniform1f("u_isHaloPass",1),S.setUniform1f("u_isBackgroundPass",0),l.drawElements(s.TRIANGLES,a.indexCount,n.UNSIGNED_INT,I),S.setUniform1f("u_isHaloPass",0),S.setUniform1f("u_isBackgroundPass",0),l.drawElements(T,a.indexCount,n.UNSIGNED_INT,I)}}export{m as default};