UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.92 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{clamp as t}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.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 n}from"../../../../core/accessorSupport/decorators/subclass.js";import{e as c,G as a,c as p,m as d,d as l,n as u}from"../../../../chunks/vec32.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import m from"../../../../geometry/Point.js";import{wrap as f}from"../../../../geometry/support/ray.js";import{PointOfInterest as g}from"./PointOfInterest.js";import{PaddingSide as y}from"../../webgl-engine/lib/rendererUtils.js";import{PropertiesPool as P}from"../../../support/PropertiesPool.js";import{TaskPriority as _}from"../../../support/Scheduler.js";import{Yield as j}from"../../../support/Yield.js";const L=Array;let O=class extends g{constructor(e){super(e),this._propertiesPool=new P({location:m,renderLocation:L},this),this._dirty=!0,this.renderLocation=this._propertiesPool.get("renderLocation")}initialize(){this.addHandles([o((()=>this.centerOnSurface.renderLocation),(()=>this.updateRenderLocation())),o((()=>this.state.contentCamera),(()=>this.updateRenderLocation()))]),this.scheduler&&this.addHandles(this.scheduler.registerTask(_.POINT_OF_INTEREST_FREQUENT,this))}destroy(){this._propertiesPool=r(this._propertiesPool)}get updating(){return this._dirty||this.centerOnSurface.updating}get location(){const e=this._propertiesPool.get("location");return e.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,e),e}get worldUnitsPerContentPixel(){const{camera:e,contentPixelRatio:t}=this.state;return e.computeRenderPixelSizeAt(this.renderLocation)*(e.pixelRatio/t)}get running(){return this._dirty}runTask(){const e=this._get("renderLocation"),r=this.centerOnSurface.renderLocation,o=this.renderCoordsHelper,i=this.state.contentCamera;this._dirty=!1,o.worldUpAtPosition(r,S);const s=Math.max(0,(Math.acos(c(S,i.viewForward))-.5*Math.PI)*(i.aboveGround?1:-1));if(Number.isNaN(s)){if(!e||!a(e,r)){const e=this._propertiesPool.get("renderLocation");p(e,r),this._set("renderLocation",e)}return j}const n=1-t(s/(.5*Math.PI),0,1),l=n*n*n;this._calculateScreenHorizontalEdgeOnSurface(C);const u=this._propertiesPool.get("renderLocation");return d(u,r,C,l),e&&a(e,u)||this._set("renderLocation",u),j}_calculateScreenHorizontalEdgeOnSurface(e){const t=this.state.contentCamera,r=t.getRenderCenter(i());if(r[1]=t.aboveGround?t.padding[y.BOTTOM]:t.fullHeight-t.padding[y.TOP],this.estimateSurfaceIntersectionAtRenderPoint(r,e))return e;const o=this.renderCoordsHelper.getAltitude(this.centerOnSurface.renderLocation);if(t.unprojectFromRenderScreen(r,R)){l(R,R,t.eye);const r=u(R,R);if(this.renderCoordsHelper.intersectInfiniteManifold(f(t.eye,r),o,e))return e}return this.renderCoordsHelper.setAltitude(e,o,t.eye)}updateRenderLocation(){this._dirty=!0}};e([s()],O.prototype,"_dirty",void 0),e([s({constructOnly:!0})],O.prototype,"scheduler",void 0),e([s({constructOnly:!0})],O.prototype,"centerOnSurface",void 0),e([s({constructOnly:!0})],O.prototype,"estimateSurfaceIntersectionAtRenderPoint",void 0),e([s()],O.prototype,"updating",null),e([s()],O.prototype,"location",null),e([s()],O.prototype,"renderLocation",void 0),e([s()],O.prototype,"worldUnitsPerContentPixel",null),O=e([n("esri.views.3d.support.pointsOfInterest.Focus")],O);const S=h(),R=h(),C=h();export{O as Focus};