UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 5.27 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{property as o,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as n,normalize as p,cross as a,negate as l,add as c,scale as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,fromValues as u,fromArray as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import v from"../../../../geometry/Point.js";import{rotateBy as g}from"./viewshedToolUtils.js";var S;let R=S=class extends t{constructor(e){super(e),this.observerRenderSpaceOverride=null,this.needUpdateByFeature=!1}get observer(){return this.viewshed.observer??new v}get effectiveObserverRenderSpace(){return this.observerRenderSpaceOverride??this.observerRenderSpace}get effectiveObserver(){return this.renderSpaceToPoint(this.effectiveObserverRenderSpace,this.observer.spatialReference)}get effectiveTargetRenderSpace(){return this._computeTargetRenderSpace(this.effectiveObserverRenderSpace)}get farDistance(){return this.viewshed.farDistance}get farDistanceRenderSpace(){return this.farDistance/this.metersPerUnit}get heading(){return this.viewshed.heading}get tilt(){return this.viewshed.tilt}get feature(){return this.viewshed.feature}get tiltParallelToSurface(){return this.tilt-90}get horizontalFieldOfView(){return this.viewshed.horizontalFieldOfView}get verticalFieldOfView(){return this.viewshed.verticalFieldOfView}get observerRenderSpace(){return this._pointToRenderSpace(this.observer,d())}get target(){const e=this.targetRenderSpace;return this.renderSpaceToPoint(e,this.observer.spatialReference)}get targetRenderSpace(){return this._computeTargetRenderSpace(this.observerRenderSpace)}get targetDirection(){const e=n(d(),this.targetRenderSpace,this.observerRenderSpace);return p(e,e)}get tiltedUpVector(){const e=g(d(),this.upVector,-r(this.tiltParallelToSurface),this.leftVector);return p(e,e)}get _basis(){return this.renderCoordsHelper.basisMatrixAtPosition(this.observerRenderSpace,s())}get upVector(){const e=this._basis;return u(e[8],e[9],e[10])}get northVector(){const e=this._basis;return u(e[4],e[5],e[6])}get leftVector(){const e=this.upVector,t=g(d(),this.northVector,-r(this.heading),e);return a(t,e,t)}get rightVector(){return l(d(),this.leftVector)}clone(){return new S({renderCoordsHelper:this.renderCoordsHelper,viewshed:this.viewshed.clone()})}get valid(){return this.viewshed.valid}get metersPerUnit(){return this.renderCoordsHelper.spatialReference.metersPerUnit}pointOnSphere(e,t,o){const{observerRenderSpace:i,targetRenderSpace:s}=this,p=n(m,s,i);return g(p,p,-r(t),this.leftVector),g(p,p,-r(e),this.tiltedUpVector),c(o,p,i)}cornerPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(-t,r,e.topLeft),this.pointOnSphere(t,r,e.topRight),this.pointOnSphere(-t,-r,e.bottomLeft),this.pointOnSphere(t,-r,e.bottomRight)}arcCentersPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(0,r,e.top),this.pointOnSphere(0,-r,e.bottom),this.pointOnSphere(-t,0,e.left),this.pointOnSphere(t,0,e.right)}parallelCenterPoints(e){const t=this.observerRenderSpace,o=this.farDistanceRenderSpace*Math.sin(r(this.verticalFieldOfView/2)),i=h(m,this.tiltedUpVector,o);c(e.top,t,i),n(e.bottom,t,i)}renderSpaceToPoint(e,t){const r=m;return this.renderCoordsHelper.fromRenderCoords(e,r,t),new v(r[0],r[1],r[2],t)}_pointToRenderSpace(e,t){const r=f(e.toArray());return this.renderCoordsHelper.toRenderCoords(r,e.spatialReference,t),t}_computeTargetRenderSpace(e){const{leftVector:t,northVector:o,upVector:i}=this,s=this.farDistanceRenderSpace,n=d();return h(n,o,s),g(n,n,-r(this.heading),i),g(n,n,-r(this.tiltParallelToSurface),t),c(n,e,n),n}};e([o()],R.prototype,"renderCoordsHelper",void 0),e([o()],R.prototype,"viewshed",void 0),e([o()],R.prototype,"observerRenderSpaceOverride",void 0),e([o()],R.prototype,"needUpdateByFeature",void 0),e([o()],R.prototype,"observer",null),e([o()],R.prototype,"effectiveObserverRenderSpace",null),e([o()],R.prototype,"effectiveObserver",null),e([o()],R.prototype,"effectiveTargetRenderSpace",null),e([o()],R.prototype,"farDistance",null),e([o()],R.prototype,"farDistanceRenderSpace",null),e([o()],R.prototype,"heading",null),e([o()],R.prototype,"tilt",null),e([o()],R.prototype,"feature",null),e([o()],R.prototype,"tiltParallelToSurface",null),e([o()],R.prototype,"horizontalFieldOfView",null),e([o()],R.prototype,"verticalFieldOfView",null),e([o()],R.prototype,"observerRenderSpace",null),e([o()],R.prototype,"target",null),e([o()],R.prototype,"targetRenderSpace",null),e([o()],R.prototype,"targetDirection",null),e([o()],R.prototype,"tiltedUpVector",null),e([o()],R.prototype,"_basis",null),e([o()],R.prototype,"upVector",null),e([o()],R.prototype,"northVector",null),e([o()],R.prototype,"leftVector",null),e([o()],R.prototype,"rightVector",null),e([o()],R.prototype,"valid",null),e([o()],R.prototype,"metersPerUnit",null),R=S=e([i("esri.views.3d.analysis.Viewshed.ViewshedComputedData")],R);const m=d();export{R as ViewshedComputedData};