/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../core/maybe","../../../chunks/vec3f64","../../../geometry/projection","../../../geometry/SpatialReference","../../../geometry/support/aaBoundingBox","../../../geometry/support/aaBoundingRect","../../../geometry/support/frustum","../../../geometry/support/spatialReferenceUtils","./PatchGeometryFactory","./Tile","../webgl-engine/materials/internal/MaterialUtil"],(function(e,t,r,n,a,i,o,s,c,l,u,h,d){"use strict";let p=function(e){function p(t,r,n){var a;return(a=e.call(this)||this).horizontalScaleFactor=1,a.extentInRenderSR=s.create(),void 0!==t&&a.init(t,r,n),a}t._inheritsLoose(p,e);var g=p.prototype;return g.init=function(t,o,s){e.prototype.init.call(this,t,o,s);const c=s.view.renderSpatialReference,u=s.spatialReference,h=r.isSome(c)&&l.isPlateCarree(c)&&u.isGeographic?this.ellipsoid.radius*Math.PI/180:1;this.horizontalScaleFactor=h;const d=this.surface.isWebMercatorOnPlateeCarree,p=this.extentInRenderSR,f=this.extent;if(d){const e=n.fromValues(f[0],f[1],0);a.projectVectorToVector(e,i.WebMercator,e,i.PlateCarree);const t=n.fromValues(f[2],f[3],0);a.projectVectorToVector(t,i.WebMercator,t,i.PlateCarree),p[0]=e[0],p[1]=e[1],p[2]=t[0],p[3]=t[1]}else for(let e=0;e<4;++e)p[e]=f[e]*h;this.centerAtSeaLevel[0]=.5*(p[0]+p[2]),this.centerAtSeaLevel[1]=.5*(p[1]+p[3]),this.centerAtSeaLevel[2]=0,this._edgeLen=Math.max(p[2]-p[0],p[3]-p[1]),this._edgeLen2=this._edgeLen*this._edgeLen,this.updateRadiusAndCenter()},g.updateRadiusAndCenter=function(){this._updateCenter();const e=this.extentInRenderSR,t=.5*(e[2]-e[0]),r=.5*(e[3]-e[1]),n=Math.sqrt(t*t+r*r),a=.5*(this.elevationBounds[0]-this.elevationBounds[1]),i=Math.max(n,a);this._center[h.CenterPosition.MIDDLE][3]=i},g._isVisible=function(e){return c.intersectsAABB(e,this._aabb())},g._aabb=function(){const e=this.extentInRenderSR;return o.wrap(e[0],e[1],this.elevationBounds[0],e[2],e[3],this.elevationBounds[1])},g.intersectsRay=function(e,t,r,n){return f[0]=1/t[0],f[1]=1/t[1],f[2]=1/t[2],d.intersectAabbInvDirBefore(this._aabb(),e,f,r,n)},g.createGeometry=function(){u.createPlanarGlobePatch(this.renderData,this.horizontalScaleFactor),this.setMemoryDirty()},g.getDefaultVerticesPerRowOnLevel=function(){return this.level<9?3:2},g.updateCornerElevations=function(){u.updateCornerElevationsPlanar(this.renderData,this.horizontalScaleFactor)},g.updateEdgeElevations=function(){u.updateEdgesElevationsAndNormalsPlanar(this.renderData,this.horizontalScaleFactor)},p}(h.Tile);const f=n.create();e.PlanarPatch=p,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
