UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.94 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ 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 r}from"../Technique.js";import{TechniqueType as i}from"../TechniqueType.js";import{OverlayShader as o}from"../shaders/OverlayShader.js";import{StencilOperation as n,CompareFunction as a,PrimitiveType as h,DataType as p}from"../../../../../../webgl/enums.js";import{VertexElementDescriptor as u}from"../../../../../../webgl/VertexElementDescriptor.js";class m extends r{constructor(){super(...arguments),this.type=i.Overlay,this._mesh=null,this.shaders={overlay:new o}}render(e,t){const{context:r,painter:i}=e,o=this._getMesh(e,t);i.setPipelineState(s);const{isWrapAround:h,wrapAroundShift:p}=t.config,u={...t.config,wrapAroundShift:0},m={shader:this.shaders.overlay,uniforms:{transform:t.transform,config:u},defines:null,optionalAttributes:null,useComputeBuffer:!1};i.setPipelineState({...s,stencil:{write:!1,test:{compare:a.EQUAL,op:{fail:n.KEEP,zFail:n.KEEP,zPass:n.REPLACE},ref:0,mask:255}}}),i.submitDrawMeshUntyped(r,m,o),h&&(u.wrapAroundShift=p,i.submitDrawMeshUntyped(r,m,o))}shutdown(){e(this._mesh)}_getMesh(e,s){const{context:r}=e;if(this._mesh){const e=this._mesh.vertexBuffers.get("positions");if(!e)throw new Error("Buffer not found");e.buffer.setData(s.position)}else{const e=null!=s.index?s.index.length:s.position.length/2;this._mesh=new t(r,{vertex:{positions:{data:s.position,attributes:[new u("pos",2,p.FLOAT,0,8)]},uvs:{data:s.tex,attributes:[new u("uv",2,p.UNSIGNED_SHORT,0,4)]}},index:null!=s.index?{index:{data:s.index}}:void 0,groups:[{index:null!=s.index?"index":void 0,primitive:h.TRIANGLE_STRIP}],parts:[{group:0,start:0,count:e}]})}return this._mesh}}export{m as OverlayTechnique};