UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 3.67 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{screenPointObjectToArray as r}from"../../../../core/screenUtils.js";import{property as i,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{copy as o,normalize as s,scaleAndAdd as a,scale as l,add as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as m,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import u from"../../../../geometry/Point.js";import{copy as d,fromPoints as f,create as g}from"../../../../geometry/support/ray.js";import{sv2d as y}from"../../../../geometry/support/vectorStacks.js";import{LineOfSightIntersectionResult as w,lineOfSightIntersectionContextGround as h,LineOfSightIntersectionContextGraphic as v}from"./LineOfSightIntersectionResult.js";import{fromScreen as j}from"../../support/geometryUtils/ray.js";import{isTerrainIntersectorResult as I,isIntegratedMeshIntersectorResult as b}from"../../terrain/Intersector.js";import{Intersector as P}from"../../webgl-engine/lib/Intersector.js";import{toGraphic as x}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{terrainId as U}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{isIntegratedMeshLayerView as L}from"../../../support/layerViewUtils.js";let R=class extends t{constructor(e){super(e)}initialize(){this.intersector=new P(this.view.state.viewingMode),this.intersector.options.hud=!1,this.intersector.options.store=0}get _integratedMeshLayerViews(){return this.view.allLayerViews.items.filter(L)}get _terrainIntersectionOptionsLayerUids(){return new Set([U,...this._integratedMeshLayerViews.map(e=>e.uid)])}getScreenPointIntersection(e){const t=r(e,y.get()),i=j(this.view.state.camera,t,M);return this._getRayIntersection(i)}_getRayIntersection(e,t){const{view:r,intersector:i}=this;if(null==e||null==r.sceneIntersectionHelper)return null;i.options.store=0,r.sceneIntersectionHelper.intersectToolIntersectorRay(e,i,t);const n=i.results.min;if(null==n.target)return null;const o=p();if(!n.getIntersectionPoint(o))return null;if(null!=t?.maxDistance&&!n.withinDistance(t.maxDistance))return null;const s=r.renderCoordsHelper.fromRenderCoords(o,new u({spatialReference:r.spatialReference})),a=m(n.normal);if(I(n))return new w({context:h,id:n.target.lij.slice(),mapPoint:s,renderPoint:o,normal:a,ray:d(e)});if(b(r,n))return new w({context:h,id:`${n.target.layerViewUid}`,mapPoint:s,renderPoint:o,normal:a,ray:d(e)});const l=x(n,r);if(null!=l){const{layer:t}=l,r=l.getObjectId()??l.uid;return new w({context:new v(l),id:`${t?.uid}/${r}`,mapPoint:s,renderPoint:o,normal:a,ray:d(e)})}const c="layerViewUid"in n.target?`${n.target.layerViewUid}`:"";return new w({context:null,id:c,mapPoint:s,renderPoint:o,normal:a,ray:d(e)})}updateFromGroundIntersection(e,t,r){const i=V,n=_,p=O;o(n,e),this.view.renderCoordsHelper.worldUpAtPosition(n,p),s(p,p);const u=this.view.groundView?.visibleElevationRange,d=(t>=0?1:-1)*((u?Math.abs(u.maxElevation-u.minElevation):100)+Math.abs(t)),g=.001*d;a(i,n,p,d-g),a(n,n,p,g),f(i,n,M);const y=this._getRayIntersection(M,{include:this._terrainIntersectionOptionsLayerUids,maxDistance:d});if(null!=y){const e=S;return l(e,p,t),c(r,y.renderPoint,e),m(y.normal)}return o(r,e),null}};e([i()],R.prototype,"view",void 0),e([i()],R.prototype,"intersector",void 0),e([i()],R.prototype,"_integratedMeshLayerViews",null),e([i()],R.prototype,"_terrainIntersectionOptionsLayerUids",null),R=e([n("esri.views.3d.analysis.LineOfSight.LineOfSightRayIntersector")],R);const V=p(),_=p(),O=p(),S=p(),M=g();export{R as LineOfSightRayIntersector};