UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 1.75 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{destroyMaybe as e}from"../../../../../../../core/maybe.js";import{Mesh as t}from"../../../meshing/Mesh.js";import{simplePipelineState as s}from"../../utils.js";import{Technique as i}from"../Technique.js";import{OverlayShader as r}from"../shaders/OverlayShader.js";import{PrimitiveType as n,DataType as o}from"../../../../../../webgl/enums.js";import{VertexElementDescriptor as a}from"../../../../../../webgl/VertexElementDescriptor.js";class h extends i{constructor(){super(...arguments),this.type=26,this._mesh=null,this.shaders={overlay:new r}}render(e,t){const{context:i,painter:r}=e,n=this._getMesh(e,t);r.setPipelineState(s);const{isWrapAround:o,wrapAroundShift:a}=t.config,h={...t.config,wrapAroundShift:0},p={shader:this.shaders.overlay,uniforms:{transform:t.transform,config:h},defines:null,optionalAttributes:null,useComputeBuffer:!1};r.setPipelineState({...s,stencil:{write:!1,test:{compare:514,op:{fail:7680,zFail:7680,zPass:7681},mask:255}}}),r.submitDrawMeshUntyped(i,p,n,{stencilRef:0}),o&&(h.wrapAroundShift=a,r.submitDrawMeshUntyped(i,p,n,{stencilRef:0}))}shutdown(){e(this._mesh)}_getMesh(e,s){const{context:i}=e;if(this._mesh){const e=this._mesh.vertexBuffers.get("positions");if(!e)throw new Error("Buffer not found");e.setData(s.position)}else{const e=null!=s.index?s.index.length:s.position.length/2;this._mesh=new t(i,{vertex:{positions:{data:s.position,layout:[new a("pos",2,o.FLOAT,0,8)]},uvs:{data:s.tex,layout:[new a("uv",2,o.UNSIGNED_SHORT,0,4)]}},index:null!=s.index?{index:{data:s.index}}:void 0,groups:[{index:null!=s.index?"index":void 0,primitive:n.TRIANGLE_STRIP}],parts:[{group:0,start:0,count:e}]})}return this._mesh}}export{h as OverlayTechnique};