text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See https://js.arcgis.com/4.10/esri/copyright.txt for details.
  //>>built
  define("require exports ../../../../core/tsSupport/extendsHelper ../../../../core/compilerUtils ../../../../core/libs/earcut/earcut ../../../../core/libs/gl-matrix-2/gl-matrix ../../../../geometry/Polygon ../../../../layers/graphics/dehydratedFeatures ./Graphics3DObject3DGraphicLayer ./Graphics3DSymbolCommonCode ./Graphics3DSymbolLayer ./graphicUtils ../support/edgeUtils ../../support/projectionUtils ../../webgl-engine/Stage ../../webgl-engine/lib/Geometry ../../webgl-engine/lib/GeometryData ../../webgl-engine/lib/Object3D ../../webgl-engine/lib/Util ../../webgl-engine/materials/DefaultMaterial".split(" "),
  function(L,oa,aa,P,ba,q,ca,da,ea,x,fa,ga,ha,ia,Q,ja,ka,la,B,ma){function na(e,d,a,b,c,h,k,p,v,l,t,r,n,x){var y=a.length/3,C=0;t+=2*b.count;var g=b.index,G=b.count,m=v,u=t;q.vec3.copy(f,n);var w=0<r?1:-1,g=3*g,z=m;n=3*z;for(var A=m+G,m=3*A,D=0;D<G;++D)x&&(f[0]=e[g+0],f[1]=e[g+1],f[2]=e[g+2],q.vec3.normalize(f,f)),c[n+0]=e[g+0],c[n+1]=e[g+1],c[n+2]=e[g+2],h[n+0]=d[g+0],h[n+1]=d[g+1],h[n+2]=d[g+2],k[n+0]=-w*f[0],k[n+1]=-w*f[1],k[n+2]=-w*f[2],p[z]=0,c[m+0]=e[g+0]+r*f[0],c[m+1]=e[g+1]+r*f[1],c[m+2]=e[g+
  2]+r*f[2],h[m+0]=d[g+0],h[m+1]=d[g+1],h[m+2]=d[g+2],k[m+0]=w*f[0],k[m+1]=w*f[1],k[m+2]=w*f[2],p[A]=r,n+=3,m+=3,g+=3,z+=1,A+=1;g=0;n=3*u;m=3*(u+y);n=3*(u+y);m=3*u;e=R;d=S;0>r&&(e=S,d=R);for(D=0;D<y;++D)l[n+0]=a[g+e[0]],l[n+1]=a[g+e[1]],l[n+2]=a[g+e[2]],l[m+0]=a[g+d[0]]+G,l[m+1]=a[g+d[1]]+G,l[m+2]=a[g+d[2]]+G,n+=3,m+=3,g+=3;v+=2*b.count;t=t+2*y-(2*b.count+2*y);T(c,h,p,k,C,b.pathLengths[0],b.count,v,l,t,r);v+=4*b.pathLengths[0];t+=2*b.pathLengths[0];C+=b.pathLengths[0];for(a=1;a<b.pathLengths.length;++a)T(c,
  h,p,k,C,b.pathLengths[a],b.count,v,l,t,r),v+=4*b.pathLengths[a],t+=2*b.pathLengths[a],C+=b.pathLengths[a]}function H(e,d,a,b,c,h,k){b[h]=b[k];k*=3;h*=3;e[h+0]=e[k+0];e[h+1]=e[k+1];e[h+2]=e[k+2];d[h+0]=d[k+0];d[h+1]=d[k+1];d[h+2]=d[k+2];a[h+0]=c[0];a[h+1]=c[1];a[h+2]=c[2]}function T(e,d,a,b,c,h,k,p,v,l,t){var r=c,n=c+1,f=c+k,y=c+k+1,C=p,g=p+1,x=p+2*h;p=p+2*h+1;0>t&&(r=c+k+1,y=c);l*=3;for(var m=0;m<h;++m){m===h-1&&(0<t?(n=c,y=c+k):(n=c,r=c+k));var u=e,w=r,z=n,A=f,D=F,w=3*w,z=3*z,A=3*A;q.vec3.set(I,
  u[w++],u[w++],u[w++]);q.vec3.set(U,u[z++],u[z++],u[z++]);q.vec3.set(V,u[A++],u[A++],u[A++]);q.vec3.subtract(W,U,I);q.vec3.subtract(X,V,I);q.vec3.cross(D,X,W);q.vec3.normalize(D,D);H(e,d,b,a,F,C,r);H(e,d,b,a,F,g,n);H(e,d,b,a,F,x,f);H(e,d,b,a,F,p,y);v[l++]=C;v[l++]=x;v[l++]=p;v[l++]=C;v[l++]=p;v[l++]=g;r++;n++;f++;y++;C+=2;g+=2;x+=2;p+=2}}var J=q.vec3f64.create(),f=q.vec3f64.create(),R=[0,2,1],S=[0,1,2],M=da.makeDehydratedPoint(0,0,0,null),Y={verticalDistanceToGround:0,terrainElevation:0};L=function(e){function d(){var a=
  null!==e&&e.apply(this,arguments)||this;a._edgeStageObjects=new Set;return a}aa(d,e);d.prototype._prepareResources=function(){if(!this._isPropertyDriven("size")){var a=ga.validateSymbolLayerSize(this._getSymbolSize());if(a){this._logWarning(a);this.reject();return}}var a=this._getStageIdHint(),b=this._getMaterialOpacityAndColor(),c=q.vec3f64.fromArray(b),b=b[3],c={diffuse:c,ambient:c,opacity:b,transparent:1>b||this._isPropertyDriven("opacity"),vertexColors:!0,slicePlaneEnabled:this._context.slicePlaneEnabled};
  this._material=new ma(c,a+"_3dlinemat");this._context.stage.add(Q.ModelContentType.MATERIAL,this._material);this.resolve()};d.prototype.destroy=function(){e.prototype.destroy.call(this);this.isFulfilled()||this.reject();this._material&&this._context.stage.remove(Q.ModelContentType.MATERIAL,this._material.id)};d.prototype.createGraphics3DGraphic=function(a){var b=a.renderingInfo;a=a.graphic;var c=a.geometry;if("polygon"!==c.type&&"extent"!==c.type)return this._logWarning("unsupported geometry type for extrude symbol: "+
  c.type),null;if(!this._validateGeometry(c))return null;var c="polygon"===c.type||"extent"===c.type?"rings":"paths",h="graphic"+a.uid,d=this._getVertexOpacityAndColor(b,Float32Array,255),e=this.getGraphicElevationContext(a);return this._createAs3DShape(a,c,b,d,e,h,a.uid)};d.prototype.layerOpacityChanged=function(){var a=this._getMaterialOpacity(),b=1>a||this._isPropertyDriven("opacity");this._material.setParameterValues({opacity:a,transparent:b});if(0<this._edgeStageObjects.size){var c=this._context.stage.view.getEdgeView(),
  h=this._getLayerOpacity();this._edgeStageObjects.forEach(function(a){c.updateAllComponentOpacities(a,[h])})}return!0};d.prototype.layerElevationInfoChanged=function(a,b){return this.updateGraphics3DGraphicElevationInfo(a,b,x.needsElevationUpdates3D)};d.prototype.slicePlaneEnabledChanged=function(a,b){var c=this;this._material.setParameterValues({slicePlaneEnabled:this._context.slicePlaneEnabled});if(0<this._edgeStageObjects.size){var h=this._context.stage.view.getEdgeView();a=this._createEdgeMaterial(h);
  if(P.isSome(a)){var d=[a];this._edgeStageObjects.forEach(function(a){h.updateAllComponentMaterials(a,d,{slicePlaneEnabled:c._context.slicePlaneEnabled},!1)})}}return!0};d.prototype._getExtrusionSize=function(a){a=a.size&&this._isPropertyDriven("size")?x.getSingleSizeDriver(a.size,2):this._getSymbolSize();return a/=this._context.renderCoordsHelper.unitInMeters};d.prototype._getSymbolSize=function(){return this.symbol.size||1};d.prototype._createAs3DShape=function(a,b,c,h,d,e,f){var k=this,p=a.geometry;
  "extent"===p.type&&(p=ca.fromExtent(p));a=p[b];var r=[],n=[],v=[],y=q.vec3f64.create(),C=Array(6),g=this._context.renderSpatialReference===ia.SphericalECEFSpatialReference,G=this._getExtrusionSize(c),m=q.vec3f64.create();g||this._context.renderCoordsHelper.worldUpAtPosition(null,m);c=x.getGeometryVertexData3D(a,p.hasZ,p.spatialReference,this._context.renderSpatialReference,this._context.elevationProvider,this._context.renderCoordsHelper,d);this._logGeometryCreationWarnings(c,a,b,"ExtrudeSymbol3DLayer");
  if(0<a.length){var u=c.geometryData.polygons,w=c.eleVertexData,z=c.vertexData;b=z.length/3;var A=new Float64Array(18*b),D=new Float64Array(18*b),F=new Float64Array(18*b),H=new Float64Array(6*b),N=0;b=function(a){var b=u[a],c=b.count,d=b.index;if(O._context.clippingExtent&&(x.computeBoundingBox(w,d,c,C),x.boundingBoxClipped(C,O._context.clippingExtent)))return"continue";var k=new Float64Array(w.buffer,3*d*A.BYTES_PER_ELEMENT,3*c),p=b.holeIndices.map(function(a){return a-d}),k=ba(k,p,3);if(0<k.length){x.chooseOrigin(z,
  d,c,y);var p=new Uint32Array(6*c+2*k.length),f=6*c,l=new Float64Array(A.buffer,3*N*A.BYTES_PER_ELEMENT,3*f),t=new Float64Array(D.buffer,3*N*D.BYTES_PER_ELEMENT,3*f),Z=new Float64Array(F.buffer,3*N*F.BYTES_PER_ELEMENT,3*f),B=new Float64Array(H.buffer,1*N*H.BYTES_PER_ELEMENT,1*f);na(z,w,k,b,l,Z,t,B,0,p,0,G,m,g);x.subtractCoordinates(l,0,f,y);N+=6*c;b=O._createExtrudeGeometry(p,{positions:l,elevation:Z,normals:t,heights:B},h);a=new ja(b,e+"path"+a);a.singleUse=!0;r.push(a);n.push(O._material);a=q.mat4f64.create();
  q.mat4.translate(a,a,y);v.push(a)}};var O=this;for(a=0;a<u.length;++a)b(a);if(0<r.length){var I=new la({geometries:r,materials:n,transformations:v,castShadow:!0,metadata:{layerUid:this._context.layer.uid,graphicUid:f},idHint:e}),L=function(a){var b=k._context.stage.view.getEdgeView();if(b){b.removeObject(a);k._edgeStageObjects.delete(a);var c=k._createEdgeMaterial(b);P.isSome(c)&&(k._edgeStageObjects.add(a),b.addObject(a,[c],{slicePlaneEnabled:k._context.slicePlaneEnabled}))}};L(I);f=new ea(this,
  I,r,null,null,function(a,b,c,d){a=a.stageObject;M.spatialReference=c.spatialReference;for(var h=a.getGeometryRecords(),k=h.length,e="absolute-height"!==b.mode,p=0,g=0;g<k;g++){var f=h[g].geometry,n=h[g].transformation;E[0]=n[12];E[1]=n[13];E[2]=n[14];f.invalidateBoundingInfo();for(var m=f.data.getVertexAttr(),f=m[B.VertexAttrConstants.POSITION].data,n=m[B.VertexAttrConstants.SIZE].data,m=m.mapPos.data,q=f.length/3,l=0,r=0,u=!1,v=0,w=0;w<q;w++){M.x=m[r];M.y=m[r+1];M.z=m[r+2];K[0]=f[l];K[1]=f[l+1];
  K[2]=f[l+2];var t=x.computeElevation(c,M,b,d,e?Y:null);e&&(v+=Y.terrainElevation);J[0]=f[l]+E[0];J[1]=f[l+1]+E[1];J[2]=f[l+2]+E[2];d.setAltitude(t+n[l/3],J);f[l]=J[0]-E[0];f[l+1]=J[1]-E[1];f[l+2]=J[2]-E[2];t=.01/d.unitInMeters;if(Math.abs(K[0]-f[l])>t||Math.abs(K[1]-f[l+1])>t||Math.abs(K[2]-f[l+2])>t)u=!0;r+=3;l+=3}u&&a.geometryVertexAttrsUpdated(g);p+=v/q}b=p/k;L(I);return b},d);f.alignedTerrainElevation=c.terrainElevation;f.needsElevationUpdates=x.needsElevationUpdates3D(d.mode);return f}}return null};
  d.prototype._createExtrudeGeometry=function(a,b,c){for(var d=a.length,f=new Uint32Array(d),e=0;e<d;e++)f[e]=0;d={};e={};d[B.VertexAttrConstants.POSITION]=a;d[B.VertexAttrConstants.NORMAL]=a;d[B.VertexAttrConstants.COLOR]=f;e[B.VertexAttrConstants.POSITION]={size:3,data:b.positions};e[B.VertexAttrConstants.NORMAL]={size:3,data:b.normals};e[B.VertexAttrConstants.COLOR]={size:4,data:c};e[B.VertexAttrConstants.SIZE]={size:1,data:b.heights};b.elevation&&(e.mapPos={size:3,data:b.elevation},d.mapPos=a);
  return new ka(e,d)};d.prototype._createEdgeMaterial=function(a){var b={opacity:this._getLayerOpacity()};return ha.createMaterial(a,this.symbol,b)};return d}(fa);var F=q.vec3f64.create(),I=q.vec3f64.create(),U=q.vec3f64.create(),V=q.vec3f64.create(),W=q.vec3f64.create(),X=q.vec3f64.create(),K=q.vec3f64.create(),E=q.vec3f64.create();return L});