@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.54 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{fromValues as r}from"../../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{createProgramDescriptor as e}from"../Utils.js";import t from"./WGLBrush.js";import{background as s}from"../shaders/BackgroundPrograms.js";import{StencilOperation as o,CompareFunction as i,PrimitiveType as a,DataType as n}from"../../../../webgl/enums.js";import{createProgram as l}from"../../../../webgl/ProgramTemplate.js";const m=()=>e("clip",{geometry:[{location:0,name:"a_pos",count:2,type:n.SHORT}]});class p extends t{constructor(){super(...arguments),this._color=r(0,1,0,1)}dispose(){this._program&&this._program.dispose()}prepareState({context:r}){r.setStencilTestEnabled(!0),r.setBlendingEnabled(!1),r.setFaceCullingEnabled(!1),r.setColorMask(!1,!1,!1,!1),r.setStencilOp(o.KEEP,o.KEEP,o.REPLACE),r.setStencilWriteMask(255),r.setStencilFunction(i.ALWAYS,0,255)}draw(r,e){const{context:t,state:o,requestRender:i,allowDelayedRender:p}=r,c=m(),d=e.getVAO(t,o,c.attributes,c.bufferLayouts);null!=d.indexBuffer&&(this._program||(this._program=l(t,s)),!p||null==i||this._program.compiled?(t.useProgram(this._program),this._program.setUniform2fv("u_coord_range",[1,1]),this._program.setUniform4fv("u_color",this._color),this._program.setUniformMatrix3fv("u_dvsMat3",o.displayMat3),t.bindVAO(d),t.drawElements(a.TRIANGLES,d.indexBuffer.size,n.UNSIGNED_INT,0),t.bindVAO()):i())}}export{p as default};