text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See https://js.arcgis.com/4.3/esri/copyright.txt for details.
  //>>built
  define("require exports ../../../../core/tsSupport/extendsHelper dojo/_base/lang dojo/when ./Graphics3DSymbolLayer ./Graphics3DGraphicLayer ./Graphics3DDrapedGraphicLayer ./ElevationAligners ./Graphics3DSymbolCommonCode ./SignedDistanceFunctions ./FastSymbolUpdates ../../../../core/urlUtils ../../../../core/screenUtils ../../../../config ../../../../Color ../../../../geometry/Polygon ../../support/projectionUtils ../../lib/glMatrix ../../webgl-engine/Stage ../../webgl-engine/lib/Geometry ../../webgl-engine/lib/GeometryUtil ../../webgl-engine/lib/RenderGeometry ../../webgl-engine/lib/Texture ../../webgl-engine/materials/HUDMaterial".split(" "),
  function(A,aa,K,B,C,n,D,L,v,l,p,t,w,r,E,M,N,O,x,u,P,F,Q,R,G){function y(g){return"cross"===g||"x"===g}function S(g){var b;"primitive:"===g.substring(0,10)&&(g=g.substring(10));switch(g){case q.PRIM_CIRCLE:b=p.computeSignedDistancefieldCicle(128,64);break;case q.PRIM_SQUARE:b=p.computeSignedDistancefieldSquare(128,64,!1);break;case q.PRIM_KITE:b=p.computeSignedDistancefieldSquare(128,64,!0);break;case q.PRIM_CROSS:b=p.computeSignedDistancefieldCrossAndX(128,64,!1);break;case q.PRIM_X:b=p.computeSignedDistancefieldCrossAndX(128,
  64,!0)}return new R(b,"sdf_"+g,{mipmap:!1,wrapClamp:!0,width:128,height:128,components:4})}var T=x.vec3d;A=x.vec4d;var z=x.mat4d.identity(),H=[0,0,1],U=[0,0,0,0],V=[0,0,0],W=[1,1,1],I="center bottom top left right bottom-left bottom-right top-left top-right".split(" "),X=[.25,.25,.75,.75],q={PRIM_CIRCLE:"circle",PRIM_SQUARE:"square",PRIM_CROSS:"cross",PRIM_X:"x",PRIM_KITE:"kite"};n=function(g){function b(){return null!==g&&g.apply(this,arguments)||this}K(b,g);b.prototype._prepareResources=function(){var a=
  this.symbol,c=null!=a.size?r.pt2px(a.size):16;this._size=null;this._symbolTextureRatio=1;this._primitive=null;var f=this._getStageIdHint();this._isPropertyDriven("size")&&64>c&&(c=64);var e=a.resource||{primitive:"circle",href:void 0},d={anchorPos:this._getAnchorPos(a)};if(e.href)d.color=this._getFillColor(a,null),d.outlineColor=this._getOutlineColor(a),d.outlineSize=this._getOutlineSize(a,null),d.textureIsSignedDistanceField=!1,this._prepareImageResources(e.href,c,d,f);else{var e=e.primitive||"circle",
  b="primitive:"+e;this._primitive=e;d.color=this._getFillColor(a,e);d.outlineColor=this._getOutlineColor(a);d.outlineSize=this._getOutlineSize(a,e);y(e)&&0===d.outlineSize?this.reject():(this.texture=this._context.sharedResources.textures.acquire(b,S),this._textureURI=b,d.textureIsSignedDistanceField=!0,d.distanceFieldBoundingBox=X,d.textureId=this.texture.getId(),this._size=[c,c],this._symbolTextureRatio=2,this._createMaterialsAndAddToStage(d,this._context.stage,f),this.resolve())}};b.prototype._getOutlineDefaultSize=
  function(a){return y(a)?1.5:0};b.prototype._getOutlineSize=function(a,c){return a.outline?null!=a.outline.size?r.pt2px(a.outline.size):this._getOutlineDefaultSize(c):this._getOutlineDefaultSize(c)};b.prototype._getOutlineColor=function(a){var c=this._getLayerOpacity();if(a.outline&&null!=a.outline.color){var f=M.toUnitRGB(a.outline.color);return[f[0],f[1],f[2],a.outline.color.a*c]}return[0,0,0,c]};b.prototype._getFillColor=function(a,c){return y(c)?U:this._getMaterialOpacityAndColor()};b.prototype._getAnchorPos=
  function(a){return-1<I.indexOf(a.anchor)?a.anchor:"center"};b.prototype._prepareImageResources=function(a,c,f,e){var d=this,b=function(a){if(!d.isRejected()){var b=a.params,h=b.width/b.height;d._size=c?1<h?[c,c/h]:[c*h,c]:[b.width,b.height];f.textureId=a.getId();d._createMaterialsAndAddToStage(f,d._context.stage,e);d.resolve()}},k="data:image/svg"===a.substring(0,14),g=".svg"===a.substring(a.length-4,a.length);if(k||g){a=w.normalize(a);var h=new Image,g=!k&&w.hasSameOrigin(a,window.location.href);
  k||(g||w.canUseXhr(a)?g||(h.crossOrigin="anonymous"):E.request.proxyUrl&&(a=E.request.proxyUrl+"?"+a));h.src=a;h.onerror=function(){d.reject()};h.onload=function(){if(!d.isRejected()){var a=h.width,e=h.height,f=1;a&&e&&(f=a/e);null!=c&&(1<f?(a=c,e=Math.round(c/f)):(e=c,a=Math.round(c*f)));f=document.createElement("canvas");f.width=a;f.height=e;f.getContext("2d").drawImage(h,0,0,a,e);a=f.toDataURL();C(d._context.sharedResources.textures.acquire(a),b,function(){d.reject()});d._textureURI=a}};h.onerror=
  function(){console.warn("Failed to create Icon primitive");d.reject()}}else C(this._context.sharedResources.textures.acquire(a),b,function(){d.reject()}),this._textureURI=a};b.prototype._createMaterialsAndAddToStage=function(a,c,f){this._fastUpdates=t.initFastSymbolUpdatesState(this._context.renderer,this._supportsShaderVisualVariables(),this._fastVisualVariableConvertOptions());this._fastUpdates.enabled&&B.mixin(a,this._fastUpdates.materialParameters);var e=B.clone(a);e.occlusionTest=!1;e.shaderPolygonOffset=
  0;this._drapedMaterial=new G(e,f+"_iconDraped");c.add(u.ModelContentType.MATERIAL,this._drapedMaterial);a.occlusionTest=!0;this._material=new G(a,f+"_icon");c.add(u.ModelContentType.MATERIAL,this._material)};b.prototype.destroy=function(){this.isFulfilled()||this.reject();this._material&&(this._context.stage.remove(u.ModelContentType.MATERIAL,this._material.getId()),this._material=null);this._drapedMaterial&&(this._context.stage.remove(u.ModelContentType.MATERIAL,this._drapedMaterial.getId()),this._drapedMaterial=
  null);this._textureURI&&(this._context.sharedResources.textures.release(this._textureURI),this._textureURI=null)};b.prototype._getGeometry=function(a){a=a.geometry;if("extent"===a.type)return l.placePointOnPolygon(N.fromExtent(a));if("polyline"===a.type)return l.placePointOnPolyline(a);if("polygon"===a.type)return l.placePointOnPolygon(a);if("point"===a.type)return a;this._logWarning("unsupported geometry type for icon symbol: "+a.type);return null};b.prototype._getScaleFactor=function(a){if(this._isPropertyDriven("size")){if(a.size){for(var c=
  0;3>c;c++)a.size[c]&&"symbolValue"!==a.size[0]&&(a.size[c]=r.pt2px(a.size[c]));c=this._size[0]>this._size[1]?this._size[0]:this._size[1];if("symbolValue"===a.size[0])return 1;if(isFinite(a.size[0]))return a.size[0]/c;if(isFinite(a.size[2]))return a.size[2]/c}}else return 1};b.prototype.createGraphics3DGraphic=function(a,c){var f=this._getGeometry(a);if(null===f)return null;var e="graphic"+a.uid,d=this._getVertexOpacityAndColor(c),b=1;this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size||
  (b=this._getScaleFactor(c));b*=this._symbolTextureRatio;c=[this._size[0]*b,this._size[1]*b];b=this._getGraphicElevationInfo(a);return b.mode===l.ELEV_MODES.ON_THE_GROUND?this._createAsOverlay(a,f,d,c,b,e,a.uid):this._createAs3DShape(a,f,d,c,b,e,a.uid)};b.prototype.layerPropertyChanged=function(a,c,b){if("opacity"===a)return c=this._getFillColor(this.symbol,this._primitive),this._drapedMaterial.setParameterValues({color:c}),this._material.setParameterValues({color:c}),c=this._getOutlineColor(this.symbol),
  this._drapedMaterial.setParameterValues({outlineColor:c}),this._material.setParameterValues({outlineColor:c}),!0;if("elevationInfo"===a){var f=this._elevationInfo.mode;this._updateElevationInfo();a=this._elevationInfo.mode;var d=l.ELEV_MODES;if(f===d.ON_THE_GROUND&&a===d.ON_THE_GROUND)return!0;if(f!==a&&(f===d.ON_THE_GROUND||a===d.ON_THE_GROUND))return!1;var f=this._context.elevationProvider,g=this._context.renderCoordsHelper,k=v.perObjectElevationAligner,J;for(J in c){var h=c[J],m=h._graphics[b];
  m&&m instanceof D&&(h=this._getGraphicElevationInfo(h.graphic),m.elevationAligner=a===d.RELATIVE_TO_GROUND?k:null,m.elevationInfo.set(h),k(m,f,g))}return!0}return!1};b.prototype.applyRendererDiff=function(a,c,b,e){for(var d in a.diff)switch(d){case "visualVariables":if(t.updateFastSymbolUpdatesState(this._fastUpdates,c,this._fastVisualVariableConvertOptions()))this._material.setParameterValues(this._fastUpdates.materialParameters),this._drapedMaterial.setParameterValues(this._fastUpdates.materialParameters);
  else return!1;break;default:return!1}return!0};b.prototype.setDrawOrder=function(a,c,b){this._drapedMaterial&&(this._drapedMaterial.setRenderPriority(a),b[this._drapedMaterial.getId()]=!0)};b.prototype._defaultElevationInfoNoZ=function(){return Y};b.prototype._getGraphicElevationInfo=function(a){var c=g.prototype._getGraphicElevationInfo.call(this,a);c.mode!==l.ELEV_MODES.RELATIVE_TO_GROUND||0!==c.offset||a.geometry.get("hasZ")||(c.offset=1/this._context.renderCoordsHelper.unitInMeters);return c};
  b.prototype._createAs3DShape=function(a,c,b,e,d,g,k){var f=this,h=this._getFastUpdateAttrValues(a),m=h?function(a){return t.evaluateModelTransform(f._fastUpdates.materialParameters,h,a)}:null;a=F.createPointGeometry(H,null,b,e,Z,null,h);a=[new P(a,g)];g=l.createStageObjectForPoint.call(this,c,a,[[this._material]],null,null,d,g,this._context.layer.id,k,!0,m);if(null===g)return null;k=null;d.mode===l.ELEV_MODES.RELATIVE_TO_GROUND?k=v.perObjectElevationAligner:d.mode===l.ELEV_MODES.ABSOLUTE_HEIGHT&&
  (k=v.perObjectVerticalDistanceToGroundAligner);d=new D(this,g.object,a,null,null,k,d);d.alignedTerrainElevation=g.terrainElevation;if(this._fastUpdates.enabled){var n=e[0]/this._symbolTextureRatio,p=e[1]/this._symbolTextureRatio;d.getScreenSize=function(){var a=m(z);return[a[0]*n,a[5]*p]}}else{var q=e[0]/this._symbolTextureRatio,r=e[1]/this._symbolTextureRatio;d.getScreenSize=function(){return[q,r]}}l.extendPointGraphicElevationInfo(d,c,this._context.elevationProvider);return d};b.prototype._createAsOverlay=
  function(a,c,b,e,d,g,k){var f=this;this._drapedMaterial.setRenderPriority(this._symbolLayerOrder);k=T.create();O.pointToVector(c,k,this._context.overlaySR);k[2]=this._getDrapedZ();if((c=this._context.clippingExtent)&&!l.pointInBox2D(k,c))return null;var h=this._getFastUpdateAttrValues(a),m=h?function(a){return t.evaluateModelTransform(f._fastUpdates.materialParameters,h,a)}:null;a=F.createPointGeometry(H,k,b,e,null,null,h);b=new Q(a);b.material=this._drapedMaterial;b.center=k;b.bsRadius=0;b.transformation=
  z;b.name=g;b.uniqueName=g+"#"+a.id;d=new L(this,[b],null,null,null,d);if(this._fastUpdates.enabled){var n=e[0]/this._symbolTextureRatio,p=e[1]/this._symbolTextureRatio;d.getScreenSize=function(){var a=m(z);return[a[0]*n,a[5]*p]}}else{var q=e[0]/this._symbolTextureRatio,r=e[1]/this._symbolTextureRatio;d.getScreenSize=function(){return[q,r]}}return d};b.prototype._supportsShaderVisualVariables=function(){return!0};b.prototype._fastVisualVariableConvertOptions=function(){var a=this._size[0]>this._size[1]?
  this._size[0]:this._size[1],c=[a,a,a],b=r.px2pt(1),a=a*b;return{modelSize:c,symbolSize:[a,a,a],unitInMeters:b,transformation:{anchor:V,scale:W,rotation:0}}};return b}(n);n.PRIMITIVE_SIZE=[64,64];n.VALID_ANCHOR_STRINGS=I;var Y={mode:l.ELEV_MODES.RELATIVE_TO_GROUND,offset:0},Z=A.createFrom(0,0,0,1);return n});