UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.08 kB
import{_ as t}from"../../../../chunks/tslib.es6.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{on as o}from"../../../../core/reactiveUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{i as n,k as a,c as d}from"../../../../chunks/vec3.js";import{c as l}from"../../../../chunks/vec3f64.js";import c from"../../../../geometry/Point.js";import{ViewingMode as p}from"../../../ViewingMode.js";import{distanceToScale as h}from"../cameraUtils.js";import{PropertiesPool as u}from"../PropertiesPool.js";import{PointOfInterest as m}from"./PointOfInterest.js";import{Task as y}from"../../../support/Scheduler.js";const _=Array;let g=class extends m{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new u({location:c,renderLocation:_},this),this._estimatedSurfaceAltitude=0,this._pendingElevationQueryController=null,this.renderLocation=l(),this._tmpPoint=new c}initialize(){if(this.scheduler&&this.handles.add(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.handles.add(o((()=>this.map?.ground?.layers),"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t,this.state.spatialReference),t}get scale(){const t=this._camera,e=n(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return h(r,e,0)}get updating(){return this._dirty||null!=this._pendingElevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._pendingElevationQueryController;t&&(this._pendingElevationQueryController=null,t.abort(),this.notifyChange("updating"))}get running(){return!this._pendingElevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map||!this.map.ground)return this._updateSurfaceAltitude(0),y.YIELD;const t=this.state.spatialReference;this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint,t);const e=(this._tmpPoint.z??0)>C&&this.renderCoordsHelper.viewingMode===p.Global&&(t.isWGS84||t.isWebMercator);let o=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:o.signal,cache:this.cache,minDemResolution:e?v:0}).then((t=>this._updateSurfaceAltitude(t.geometry.z??0))).catch((t=>{r(t)||this._updateSurfaceAltitude(0)})).catch((()=>{})).then((()=>{this._pendingElevationQueryController===o&&(this._pendingElevationQueryController=null,this.notifyChange("updating")),o=null})),this._pendingElevationQueryController=o,y.YIELD}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(f,this._estimatedSurfaceAltitude,this._camera.eye),a(this._get("renderLocation"),f)||(this._set("renderLocation",d(this._propertiesPool.get("renderLocation"),f)),this.notifyChange("renderLocation"))}};t([i({constructOnly:!0})],g.prototype,"scheduler",void 0),t([i({constructOnly:!0})],g.prototype,"cache",void 0),t([i({constructOnly:!0})],g.prototype,"task",void 0),t([i({readOnly:!0})],g.prototype,"location",null),t([i({constructOnly:!0})],g.prototype,"map",void 0),t([i({readOnly:!0})],g.prototype,"renderLocation",void 0),t([i({readOnly:!0})],g.prototype,"scale",null),t([i({readOnly:!0})],g.prototype,"updating",null),g=t([s("esri.views.3d.support.CameraOnSurface")],g);const f=l(),C=1e5,v=1e6;export{g as CameraOnSurface};