text: // COPYRIGHT © 2017 Esri
  //
  // All rights reserved under the copyright laws of the United States
  // and applicable international laws, treaties, and conventions.
  //
  // This material is licensed for use under the Esri Master License
  // Agreement (MLA), and is bound by the terms of that agreement.
  // You may redistribute and use this code without modification,
  // provided you adhere to the terms of the MLA and include this
  // copyright notice.
  //
  // See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
  //
  // For additional information, contact:
  // Environmental Systems Research Institute, Inc.
  // Attn: Contracts and Legal Services Department
  // 380 New York Street
  // Redlands, California, USA 92373
  // USA
  //
  // email: contracts@esri.com
  //
  // See http://js.arcgis.com/4.6/esri/copyright.txt for details.
  
  define(["require","exports","../../../../webgl/VertexArrayObject","../../../../webgl/Texture","../Utils"],function(e,t,i,o,r){function n(e,t){if(t.intensityKernel&&!t.refreshIntensityKernel)return t.intensityKernel;t.intensityKernel&&(t.intensityKernel.dispose(),t.intensityKernel=null);for(var i=t.radius,r=t.kernelSize,n=t.blurRadius,a=i*i,s=[],v=-1;++v<r;)s[v]=Math.exp(-Math.pow(v-n,2)/(2*a))/(Math.sqrt(2*Math.PI)*(i/2));for(var d,l,u,f=[],m=0;r>m;m++)for(l=s[m],v=0;r>v;v++)u=m*r+v,d=s[v],f[4*u+0]=l*d,f[4*u+1]=0,f[4*u+2]=0,f[4*u+3]=1;var _=new o(e,{target:3553,pixelFormat:6408,internalFormat:34836,dataType:5126,samplingMode:e.extensions.textureFloatLinear?9729:9728,wrapMode:33071,width:r,height:r},new Float32Array(f));return t.intensityKernel=_,t.refreshIntensityKernel=!1,_}var a=function(){function e(){this._iconAttributeLocations={a_pos:0,a_vertexOffsetAndTex:1,a_id:2,a_color:3,a_outlineColor:4,a_sizeAndOutlineWidth:5},this._iconAttributeLocationsVV={a_pos:0,a_vertexOffsetAndTex:1,a_id:2,a_color:3,a_outlineColor:4,a_sizeAndOutlineWidth:5,a_vv:6},this._iconAttributeLocationsHeatmap={a_pos:0,a_vertexOffsetAndTex:1,a_id:2,a_color:3,a_outlineColor:4,a_sizeAndOutlineWidth:5,a_weight:6},this._iconVertexAttributes={geometry:[{name:"a_pos",count:2,type:5122,offset:0,stride:24,normalized:!1,divisor:0},{name:"a_vertexOffsetAndTex",count:4,type:5120,offset:4,stride:24,normalized:!1,divisor:0},{name:"a_id",count:4,type:5121,offset:8,stride:24,normalized:!0,divisor:0},{name:"a_color",count:4,type:5121,offset:12,stride:24,normalized:!0,divisor:0},{name:"a_outlineColor",count:4,type:5121,offset:16,stride:24,normalized:!0,divisor:0},{name:"a_sizeAndOutlineWidth",count:4,type:5121,offset:20,stride:24,normalized:!1,divisor:0}]},this._iconVertexAttributesWithVV={geometry:[{name:"a_pos",count:2,type:5122,offset:0,stride:40,normalized:!1,divisor:0},{name:"a_vertexOffsetAndTex",count:4,type:5120,offset:4,stride:40,normalized:!1,divisor:0},{name:"a_id",count:4,type:5121,offset:8,stride:40,normalized:!0,divisor:0},{name:"a_color",count:4,type:5121,offset:12,stride:40,normalized:!0,divisor:0},{name:"a_outlineColor",count:4,type:5121,offset:16,stride:40,normalized:!0,divisor:0},{name:"a_sizeAndOutlineWidth",count:4,type:5121,offset:20,stride:40,normalized:!1,divisor:0},{name:"a_vv",count:4,type:5126,offset:24,stride:40,normalized:!1,divisor:0}]},this._iconVertexAttributesWithHeatmap={geometry:[{name:"a_pos",count:2,type:5122,offset:0,stride:28,normalized:!1,divisor:0},{name:"a_vertexOffsetAndTex",count:4,type:5120,offset:4,stride:28,normalized:!1,divisor:0},{name:"a_id",count:4,type:5121,offset:8,stride:28,normalized:!0,divisor:0},{name:"a_color",count:4,type:5121,offset:12,stride:28,normalized:!0,divisor:0},{name:"a_outlineColor",count:4,type:5121,offset:16,stride:28,normalized:!0,divisor:0},{name:"a_sizeAndOutlineWidth",count:4,type:5121,offset:20,stride:28,normalized:!1,divisor:0},{name:"a_weight",count:1,type:5126,offset:24,stride:28,normalized:!1,divisor:0}]},this._spritesTextureSize=new Float32Array(2)}return e.prototype.draw=function(e,t,i,o,r,a,s,v,d,l,u){if(i.canDisplay){var f=t.materialKeyInfo,m=f.heatmap,_=f.vvSizeMinMaxValue||f.vvSizeScaleStops||f.vvSizeFieldStops||f.vvSizeUnitValue||f.vvColor||f.vvRotation||f.vvOpacity,c=_?this._iconAttributeLocationsVV:this._iconAttributeLocations,p=v.getProgram(t.materialKey,r,c);if(p){e.bindProgram(p);var y=this._getVAO(e,i,_,m);if(e.bindVAO(y),m){var z=n(e,o.heatmapParameters);e.bindTexture(z,1),p.setUniform1i("u_texture",1),this._spritesTextureSize[0]=Math.round(o.heatmapParameters.radius),this._spritesTextureSize[1]=Math.round(o.heatmapParameters.radius)}else{var h=t.texBindingInfo[0],x=h.pageId;d.bindSpritePage(e,x,h.unit),p.setUniform1i(h.semantic,h.unit);var S=d.sprites;this._spritesTextureSize[0]=S.getWidth(x)/4,this._spritesTextureSize[1]=S.getHeight(x)/4}var V=o.vvMaterialParameters.vvRotationEnabled&&"geographic"===o.vvMaterialParameters.vvRotationType?l:u;p.setUniformMatrix4fv("u_transformMatrix",i.tileTransform.transform),p.setUniformMatrix4fv("u_extrudeMatrix",V),p.setUniform2fv("u_normalized_origin",i.tileTransform.displayCoord),p.setUniform2fv("u_mosaicSize",this._spritesTextureSize),p.setUniform1f("u_opacity",1),f.vvSizeMinMaxValue&&p.setUniform4fv("u_vvSizeMinMaxValue",o.vvSizeMinMaxValue),f.vvSizeScaleStops&&p.setUniform1f("u_vvSizeScaleStopsValue",o.vvSizeScaleStopsValue),f.vvSizeFieldStops&&(p.setUniform1fv("u_vvSizeFieldStopsValues",o.vvSizeFieldStopsValues),p.setUniform1fv("u_vvSizeFieldStopsSizes",o.vvSizeFieldStopsSizes)),f.vvSizeUnitValue&&p.setUniform1f("u_vvSizeUnitValueWorldToPixelsRatio",o.vvSizeUnitValueToPixelsRatio),f.vvColor&&(p.setUniform1fv("u_vvColorValues",o.vvColorValues),p.setUniform4fv("u_vvColors",o.vvColors)),f.vvOpacity&&(p.setUniform1fv("u_vvOpacityValues",o.vvOpacityValues),p.setUniform1fv("u_vvOpacities",o.vvOpacities)),e.drawElements(4,s,5125,4*a),e.bindVAO(null)}}},e.prototype._getVAO=function(e,t,o,n){if(t.iconGeometry.vao)return t.iconGeometry.vao;var a=t.iconGeometry.vertexBufferMap[r.C_VBO_GEOMETRY],s=t.iconGeometry.indexBuffer;return a&&s?(o?t.iconGeometry.vao=new i(e,this._iconAttributeLocationsVV,this._iconVertexAttributesWithVV,{geometry:a},s):n?t.iconGeometry.vao=new i(e,this._iconAttributeLocationsHeatmap,this._iconVertexAttributesWithHeatmap,{geometry:a},s):t.iconGeometry.vao=new i(e,this._iconAttributeLocations,this._iconVertexAttributes,{geometry:a},s),t.iconGeometry.vao):null},e}();return a});