UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.68 kB
/* 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 r from"../../../../core/Evented.js";import{property as s}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{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as n,expand as c,intersects as a}from"../../../../geometry/support/aaBoundingRect.js";import{TaskPriority as p}from"../../../support/Scheduler.js";import{Yield as d}from"../../../support/Yield.js";let u=class extends t{constructor(e){super(e),this._tileGeometryUpdateExtent=n(),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 running(){return this.updating}runTask(){return this.updating?(this._tileGeometryUpdateSpatialReference&&this._centerIntersectsExtent(this._tileGeometryUpdateExtent,this._tileGeometryUpdateSpatialReference)&&this.events.emit("request-update",l),n(this._tileGeometryUpdateExtent),this._set("updating",!1),d):d}_tileGeometryChanged(e){this._tileGeometryUpdateSpatialReference=e.spatialReference,c(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]),a(s,e)}};e([s({constructOnly:!0})],u.prototype,"state",void 0),e([s({constructOnly:!0})],u.prototype,"centerOnSurfaces",void 0),e([s({constructOnly:!0})],u.prototype,"renderCoordsHelper",void 0),e([s({constructOnly:!0})],u.prototype,"scheduler",void 0),e([s({constructOnly:!0})],u.prototype,"surface",void 0),e([s({readOnly:!0})],u.prototype,"updating",void 0),u=e([o("esri.views.3d.support.pointsOfInterest.SurfaceGeometryUpdates")],u);const l={},h=i(),m=i(),f=n();export{u as SurfaceGeometryUpdates};