UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.73 kB
import{isSome as e}from"../../../core/maybe.js";import{f as t,c as r}from"../../../chunks/vec3f64.js";import{projectVectorToVector as i}from"../../../geometry/projection.js";import a from"../../../geometry/SpatialReference.js";import{wrap as s}from"../../../geometry/support/aaBoundingBox.js";import{create as o}from"../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as n}from"../../../geometry/support/spatialReferenceUtils.js";import{TileFrustumVisibility as c}from"./interfaces.js";import{createPlanarGlobePatch as l,updateCornersPlanar as h,updateEdgesAndCornersPlanar as m}from"./PatchGeometryFactory.js";import{Tile as d,CenterPosition as u}from"./Tile.js";import{intersectAabbInvDirBefore as p}from"../webgl-engine/materials/internal/MaterialUtil.js";class f extends d{get horizontalScale(){return this._horizontalScaleFactor}constructor(e,t,r){super(),this._horizontalScaleFactor=1,this._extentInRenderSR=o(),void 0!==e&&this.init(e,t,r)}init(r,s,o){super.init(r,s,o);const c=o.view.renderSpatialReference,l=o.spatialReference,h=e(c)&&n(c)&&e(l)&&l.isGeographic?this.ellipsoid.radius*Math.PI/180:1;this._horizontalScaleFactor=h;const m=this.surface.isWebMercatorOnPlateeCarree,d=this._extentInRenderSR,u=this.extent;if(m){const e=t(u[0],u[1],0);i(e,a.WebMercator,e,a.PlateCarree);const r=t(u[2],u[3],0);i(r,a.WebMercator,r,a.PlateCarree),d[0]=e[0],d[1]=e[1],d[2]=r[0],d[3]=r[1]}else for(let e=0;e<4;++e)d[e]=u[e]*h;this.centerAtSeaLevel[0]=.5*(d[0]+d[2]),this.centerAtSeaLevel[1]=.5*(d[1]+d[3]),this.centerAtSeaLevel[2]=0,this._edgeLen=Math.max(d[2]-d[0],d[3]-d[1]),this._edgeLen2=this._edgeLen*this._edgeLen,this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateCenter();const e=this._extentInRenderSR,t=.5*(e[2]-e[0]),r=.5*(e[3]-e[1]),i=Math.sqrt(t*t+r*r),a=.5*(this.elevationBounds[0]-this.elevationBounds[1]),s=Math.max(i,a);this._center[u.MIDDLE][3]=s}_calculateFrustumVisibilityStatus(e){const t=this._aabb(),r=t[0],i=t[1],a=t[2],s=t[3],o=t[4],n=t[5];let l=!0;for(let h=0;h<6;h++){const t=e[h],m=t[0],d=t[1],u=t[2],p=t[3];if(m*(m>0?r:s)+d*(d>0?i:o)+u*(u>0?a:n)+p>=0)return c.OUTSIDE;l=l&&m*(m<0?r:s)+d*(d<0?i:o)+u*(u<0?a:n)+p<=0}return l?c.INSIDE:c.INTERSECTS}_aabb(){const e=this._extentInRenderSR;return s(e[0],e[1],this.elevationBounds[0],e[2],e[3],this.elevationBounds[1])}intersectsRay(e,t,r,i){return S[0]=1/t[0],S[1]=1/t[1],S[2]=1/t[2],p(this._aabb(),e,S,r,i)}createGeometry(){l(this.renderData,this._horizontalScaleFactor),this.setMemoryDirty()}getDefaultVerticesPerSide(){return this.level<9?3:2}updateCornerElevations(){h(this.renderData,this._horizontalScaleFactor)}updateEdgeElevations(){m(this.renderData,this._horizontalScaleFactor)}}const S=r();export{f as PlanarPatch};