UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 3.31 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import s from"../../../../core/Handles.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{watch as r,sync as n,initial as o}from"../../../../core/reactiveUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as h}from"../../../../geometry/ellipsoidUtils.js";import{FrustumExtentIntersection as l}from"../../support/FrustumExtentIntersection.js";import{TaskPriority as p,Task as u}from"../../../support/Scheduler.js";const d=1.2;let _=class extends t{constructor(e){super(e),this.suspended=!1,this._extent=null,this._extentIntersectionDirty=!0,this._isVisibleBelowSurfaceInternal=!1,this._handles=new s,this.graphicsCoreOwner=null,this.updating=!0}initialize(){const{graphicsCoreOwner:e}=this;this._extentIntersection=new l({renderCoordsHelper:e.view.renderCoordsHelper});const t=e.view,s=t.basemapTerrain,i=t.resourceController.scheduler;this._handles.add([t.on("resize",(()=>this._viewChange())),r((()=>t.state.camera),(()=>this._viewChange()),n),i.registerTask(p.FRUSTUM_VISIBILITY,this),r((()=>s.visibleElevationBounds),(()=>this._elevationBoundsChange()))]),"local"===t.viewingMode?this._isVisibleBelowSurface=!0:this._handles.add([r((()=>[s.baseOpacity,s.wireframe,t.map?.ground?.navigationConstraint?.type]),(()=>this._updateIsVisibleBelowSurface()),o)])}destroy(){this._set("graphicsCoreOwner",null),this._extent=null,this._extentIntersection=null,this._handles=i(this._handles)}_setDirty(){this.updating||this._set("updating",!0)}setExtent(e){this._extent=e,this._extentIntersectionDirty=!0,this._setDirty()}_viewChange(){this._setDirty()}_elevationBoundsChange(){this._setDirty(),this._extentIntersectionDirty=!0}set _isVisibleBelowSurface(e){this._isVisibleBelowSurfaceInternal=e,this._setDirty(),this._extentIntersectionDirty=!0}_updateIsVisibleBelowSurface(){const e=this.graphicsCoreOwner.view,t=e.basemapTerrain,s="local"===e.viewingMode,i="none"===e.map.ground?.navigationConstraint?.type;this._isVisibleBelowSurface=s||!t.opaque||i}_updateExtentIntersection(){if(!this._extentIntersectionDirty)return;this._extentIntersectionDirty=!1;const e=this.graphicsCoreOwner.view;let t;if(this._isVisibleBelowSurfaceInternal)t=-.3*h(e.spatialReference).radius;else{const{min:s,max:i}=e.basemapTerrain.visibleElevationBounds;t=s-Math.max(1,(i-s)*(d-1))}this._extentIntersection.update(this._extent,e.spatialReference,t)}get running(){return this.updating}runTask(e){if(this._set("updating",!1),!this._extent)return this._set("suspended",!1),u.YIELD;this._updateExtentIntersection();const t=this.graphicsCoreOwner.view.frustum,s=h(this.graphicsCoreOwner.view.spatialReference).radius;this._set("suspended",!this._extentIntersection.isVisibleInFrustum(t,s)),e.madeProgress()}};e([a({readOnly:!0})],_.prototype,"suspended",void 0),e([a({constructOnly:!0})],_.prototype,"graphicsCoreOwner",void 0),e([a({readOnly:!0})],_.prototype,"updating",void 0),_=e([c("esri.views.3d.layers.graphics.Graphics3DFrustumVisibility")],_);const m=_;export{m as default};