UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.41 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import e from"../../../../../core/Logger.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{Default3D as t}from"../../lib/DefaultVertexAttributeLocations.js";import{Program as r}from"../../lib/Program.js";import{PrimitiveType as o}from"../../../../webgl/enums.js";import{makePipelineState as s,blendWithPremultipliedAlpha as n,defaultColorWrite as a}from"../../../../webgl/renderState.js";const p=()=>e.getLogger("esri.views.3d.webgl.ShaderTechnique");class l{constructor(e,s,n,a=t){this.locations=a,this.primitiveType=o.TRIANGLES,this.key=s.key,this._program=new r(e.rctx,n.get().build(s),a),this._pipeline=this.initializePipeline(s),this.reload=async t=>{t&&await n.reload(),this.key.equals(s.key)||p().warn("Configuration was changed after construction, cannot reload shader.",n),i(this._program),this._program=new r(e.rctx,n.get().build(s),a),this._pipeline=this.initializePipeline(s)}}destroy(){this._program=i(this._program),this._pipeline=null}get program(){return this._program}get compiled(){return this.program.compiled}ensureAttributeLocations(e){this.program.assertCompatibleVertexAttributeLocations(e)}getPipeline(e,i){return this._pipeline}initializePipeline(e){return s({blending:n,colorWrite:a})}}export{l as ShaderTechnique};