UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.96 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{TypedShaderProgram as t}from"./typed/TypedShaderProgram.js";class e{constructor(){this.computeAttributes={}}get locationsMap(){const t=new Map;for(const e in this.locations)t.set(e,this.locations[e].index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set(Object.keys(this.options));this._optionPropertyKeys=t}return this._optionPropertyKeys}get _transformFeedbackBindings(){return[]}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map(([t,e])=>`${t}.${e}`).join(".");this._locationInfo={stringHash:e,locations:t,computeAttributeMap:this.computeAttributes}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const[e,o]of this.locationsMap.entries())t.set("a_"+e,o);return t}getShaderKey(t,e,o){return`${Object.keys(t).map(e=>`${e}.${t[e]}`).join(".")}.${Object.keys(o).filter(t=>o[t]).map(t=>`${t}_${o[t].toString()}`).join(".")}.${Object.keys(e).filter(t=>this.optionPropertyKeys.has(t)).join(".")}`}getProgram(e,o,n,r){let i="",s="";for(const t in n)if(n[t]){const e="boolean"==typeof n[t]?`#define ${t}\n`:`#define ${t} ${n[t]}\n`;i+=e,s+=e}return i+=this.vertexShader,s+=this.fragmentShader,new t("glslShaderModule",i,s,this.renamedLocationsMap,this._getUniformBindings(o),this._transformFeedbackBindings)}_getUniformBindings(t){const e=[];for(const r in this.required){const t=this.required[r];e.push({uniformHydrated:null,shaderModulePath:r,uniformName:r,uniformType:t.type,uniformArrayElementType:o(t),uniformArrayLength:n(t)})}for(const r in t){const i=this.options[r];if(t[r])for(const t in i){const s=i[t];e.push({uniformHydrated:null,shaderModulePath:`${r}.${t}`,uniformName:t,uniformType:s.type,uniformArrayElementType:o(s),uniformArrayLength:n(s)})}}return e}}const o=t=>"array"===t.type?t.elementType?.type:void 0,n=t=>"array"===t.type?t.size:void 0;export{e as GLSLShaderModule};