// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/layers/vectorTiles/views/vectorTiles/renderers/IconRenderer","require exports ../../../core/libs/gl-matrix/mat4 ../../../core/libs/gl-matrix/vec3 ../../webgl/VertexArrayObject ../GeometryUtils ./rendererUtils ../../webgl/ShaderVariations ./vtShaderSnippets".split(" "),function(G,H,l,x,r,C,E,y,F){return function(){function d(){this._attributeLocations={a_pos:0,a_vertexOffset:1,a_tex:2,a_levelInfo:3};this._attributeLocationsDD={a_pos:0,a_vertexOffset:1,a_tex:2,a_levelInfo:3,a_color:4,a_size:5};
this._spritesTextureSize=new Float32Array(2);this._initialized=!1;this._viewProjMat=l.create();this._offsetVector=x.create();this._extrudeMat=l.create()}d.prototype.dispose=function(){};d.prototype.render=function(e,b,a,u,d,v,m,f,z,g,n,r){var A=this;this._initialized||this._initialize(e);var x=f.getLayoutValue("icon-size",a);r*=f.getPaintValue("icon-opacity",a);var t=f.getLayoutValue("icon-rotation-alignment",a);2===t&&(t=1===f.getLayoutValue("symbol-placement",a)?0:1);var y=0===t,w=b.isSDF,B=f.hasDataDrivenIcon;
u=3===u;var t=C.degToByte(d),p=m.tileTransform.transform,h=f.getPaintValue("icon-translate",a);if(0!==h[0]||0!==h[1]){l.copy(this._viewProjMat,m.tileTransform.transform);var p=h[0],h=h[1],q=0,k=0,k=(1<<m.key.level)/Math.pow(2,a)*(m.coordRange/512);if(1===f.getPaintValue("icon-translate-anchor",a)){q=-C.C_DEG_TO_RAD*d;d=Math.sin(q);var D=Math.cos(q),q=k*(p*D-h*d),k=k*(p*d+h*D)}else q=k*p,k*=h;this._offsetVector[0]=q;this._offsetVector[1]=k;this._offsetVector[2]=0;l.translate(this._viewProjMat,this._viewProjMat,
this._offsetVector);p=this._viewProjMat}y?l.copy(this._extrudeMat,g):l.copy(this._extrudeMat,n);if(g=this._getIconVAO(e,m,B)){e.bindVAO(g);var c=this._shaderVariations.getProgram([w,B,u],void 0,void 0,B?this._attributeLocationsDD:this._attributeLocations);e.bindProgram(c);w&&(g=f.getPaintValue("icon-color",a),n=f.getPaintValue("icon-halo-color",a),w=f.getPaintValue("icon-halo-width",a),c.setUniform4f("u_color",g[0],g[1],g[2],g[3]),c.setUniform4f("u_outlineColor",n[0],n[1],n[2],n[3]),c.setUniform1f("u_outlineSize",
w));c.setUniformMatrix4fv("u_transformMatrix",p);c.setUniformMatrix4fv("u_extrudeMatrix",this._extrudeMat);c.setUniform2fv("u_normalized_origin",m.tileTransform.displayCoord);c.setUniform1f("u_depth",f.z);c.setUniform1f("u_mapRotation",t);c.setUniform1f("u_keepUpright",0);c.setUniform1f("u_level",10*a);c.setUniform1f("u_fadeSpeed",10*v.fadeSpeed);c.setUniform1f("u_minfadeLevel",10*v.minfadeLevel);c.setUniform1f("u_maxfadeLevel",10*v.maxfadeLevel);c.setUniform1f("u_fadeChange",10*(a+v.fadeChange));
c.setUniform1i("u_texture",1);c.setUniform1f("u_size",x);c.setUniform1f("u_opacity",r);u&&(a=E.int32To4Bytes(b.layerID),c.setUniform4f("u_id",a[0],a[1],a[2],a[3]));b.markerPerPageElementsMap.forEach(function(a,b){A._spritesTextureSize[0]=z.getWidth(b)/4;A._spritesTextureSize[1]=z.getHeight(b)/4;c.setUniform2fv("u_mosaicSize",A._spritesTextureSize);z.bind(e,9729,b,1);e.drawElements(4,a[1],5125,12*a[0])});e.bindVAO()}};d.prototype._initialize=function(e){if(this._initialized)return!0;e=new y("icon",
["iconVS","iconFS"],[],F,e);e.addDefine("SDF","SDF",[!0,!0],"SDF");e.addDefine("DD","DD",[!0,!1],"DD");e.addDefine("ID","ID",[!0,!0],"ID");this._shaderVariations=e;this._vertexAttributes={geometry:[{name:"a_pos",count:2,type:5122,offset:0,stride:16,normalized:!1,divisor:0},{name:"a_vertexOffset",count:2,type:5122,offset:4,stride:16,normalized:!1,divisor:0},{name:"a_tex",count:4,type:5121,offset:8,stride:16,normalized:!1,divisor:0},{name:"a_levelInfo",count:4,type:5121,offset:12,stride:16,normalized:!1,
divisor:0}]};this._vertexAttributesDD={geometry:[{name:"a_pos",count:2,type:5122,offset:0,stride:24,normalized:!1,divisor:0},{name:"a_vertexOffset",count:2,type:5122,offset:4,stride:24,normalized:!1,divisor:0},{name:"a_tex",count:4,type:5121,offset:8,stride:24,normalized:!1,divisor:0},{name:"a_levelInfo",count:4,type:5121,offset:12,stride:24,normalized:!1,divisor:0},{name:"a_color",count:4,type:5121,offset:16,stride:24,normalized:!0,divisor:0},{name:"a_size",count:1,type:5126,offset:20,stride:24,
normalized:!1,divisor:0}]};return this._initialized=!0};d.prototype._getIconVAO=function(e,b,a){if(a){if(b.iconDDVertexArrayObject)return b.iconDDVertexArrayObject;a=b.iconDDVertexBuffer;var d=b.iconIndexBuffer;if(!a||!d)return null;b.iconDDVertexArrayObject=new r(e,this._attributeLocationsDD,this._vertexAttributesDD,{geometry:a},d);return b.iconDDVertexArrayObject}if(b.iconVertexArrayObject)return b.iconVertexArrayObject;a=b.iconVertexBuffer;d=b.iconIndexBuffer;if(!a||!d)return null;b.iconVertexArrayObject=
new r(e,this._attributeLocations,this._vertexAttributes,{geometry:a},d);return b.iconVertexArrayObject};return d}()});