@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.41 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{EventEmitter as r}from"../../../../core/Evented.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as i,expand as a,intersects as c}from"../../../../geometry/support/aaBoundingRect.js";import{TaskPriority as p}from"../../../support/Scheduler.js";import{Yield as d}from"../../../support/Yield.js";let l=class extends t{constructor(e){super(e),this._tileGeometryUpdateExtent=i(),this._tileGeometryUpdateSpatialReference=null,this.events=new r,this.updating=!1}initialize(){this.addHandles([this.surface.on("elevation-change",e=>this._tileGeometryChanged(e)),this.scheduler.registerTask(p.SURFACE_GEOMETRY_UPDATES,this)])}get readyToRun(){return this.updating}runTask(){return this.updating?(this._tileGeometryUpdateSpatialReference&&this._centerIntersectsExtent(this._tileGeometryUpdateExtent,this._tileGeometryUpdateSpatialReference)&&this.events.emit("request-update",u),i(this._tileGeometryUpdateExtent),this._set("updating",!1),d):d}_tileGeometryChanged(e){this._tileGeometryUpdateSpatialReference=e.spatialReference,a(this._tileGeometryUpdateExtent,e.extent,this._tileGeometryUpdateExtent),this._set("updating",!0)}_furthestCenterOnSurface(){let e=this.centerOnSurfaces[0];for(let t=1;t<this.centerOnSurfaces.length;t++){const r=this.centerOnSurfaces[t];r.distance>e.distance&&(e=r)}return e}_centerIntersectsExtent(e,t){const r=this.state.contentCamera.eye,s=f,o=this._furthestCenterOnSurface();return this.renderCoordsHelper.fromRenderCoords(r,h,t),this.renderCoordsHelper.fromRenderCoords(o.renderLocation,m,t),h[0]<m[0]?(s[0]=h[0],s[2]=m[0]):(s[0]=m[0],s[2]=h[0]),h[1]<m[1]?(s[1]=h[1],s[3]=m[1]):(s[1]=m[1],s[3]=h[1]),c(s,e)}};e([s({constructOnly:!0})],l.prototype,"state",void 0),e([s({constructOnly:!0})],l.prototype,"centerOnSurfaces",void 0),e([s({constructOnly:!0})],l.prototype,"renderCoordsHelper",void 0),e([s({constructOnly:!0})],l.prototype,"scheduler",void 0),e([s({constructOnly:!0})],l.prototype,"surface",void 0),e([s({readOnly:!0})],l.prototype,"updating",void 0),l=e([o("esri.views.3d.support.pointsOfInterest.SurfaceGeometryUpdates")],l);const u={},h=n(),m=n(),f=i();export{l as SurfaceGeometryUpdates};