@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.36 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{watch as s,sync as i,initial as r}from"../../../../core/reactiveUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as a}from"../../../../geometry/ellipsoidUtils.js";import{FrustumExtentIntersection as p}from"../../support/FrustumExtentIntersection.js";import{TaskPriority as c}from"../../../support/Scheduler.js";import{Yield as l}from"../../../support/Yield.js";const h=1.2;let u=class extends t{constructor(e){super(e),this.suspended=!1,this._extent=null,this._extentIntersectionDirty=!0,this._isVisibleBelowSurfaceInternal=!1,this.graphicsCoreOwner=null,this.updating=!0}initialize(){const{graphicsCoreOwner:e}=this;this._extentIntersection=new p({renderCoordsHelper:e.view.renderCoordsHelper});const t=e.view,n=t.basemapTerrain,o=t.resourceController.scheduler;this.addHandles([t.on("resize",(()=>this._viewChange())),s((()=>t.state.camera),(()=>this._viewChange()),i),o.registerTask(c.FRUSTUM_VISIBILITY,this),s((()=>n.visibleElevationBounds),(()=>this._elevationBoundsChange()))]),"local"===t.viewingMode?this._isVisibleBelowSurface=!0:this.addHandles([s((()=>[n.baseOpacity,n.wireframe,t.map?.ground?.navigationConstraint?.type]),(()=>this._updateIsVisibleBelowSurface()),r)])}destroy(){this._set("graphicsCoreOwner",null),this._extent=null,this._extentIntersection=null}_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*a(e.spatialReference).radius;else{const{min:s,max:i}=e.basemapTerrain.visibleElevationBounds;t=s-Math.max(1,(i-s)*(h-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),l;this._updateExtentIntersection();const t=this.graphicsCoreOwner.view.frustum,s=a(this.graphicsCoreOwner.view.spatialReference).radius;this._set("suspended",!this._extentIntersection.isVisibleInFrustum(t,s)),e.madeProgress()}};e([n({readOnly:!0})],u.prototype,"suspended",void 0),e([n({constructOnly:!0})],u.prototype,"graphicsCoreOwner",void 0),e([n({readOnly:!0})],u.prototype,"updating",void 0),u=e([o("esri.views.3d.layers.graphics.Graphics3DFrustumVisibility")],u);export{u as Graphics3DFrustumVisibility};