@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.37 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{screenPointObjectToArray as t}from"../../../../core/screenUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as n,n as i,h as c,g as a}from"../../../../chunks/vec32.js";import{clone as l,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import m from"../../../../geometry/Point.js";import{create as u,copy as d,fromPoints as f}from"../../../../geometry/support/ray.js";import{sv2d as g}from"../../../../geometry/support/vectorStacks.js";import{getObjectId as h}from"../../../../layers/graphics/dehydratedFeatures.js";import{LineOfSightIntersectionResult as y}from"./LineOfSightIntersectionResult.js";import{fromScreen as j}from"../../support/geometryUtils/ray.js";import{isTerrainIntersectorResult as I}from"../../terrain/Intersector.js";import{newIntersector as w}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as v,IntersectorType as b}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{toGraphic as R}from"../../webgl-engine/lib/intersectorUtilsConversions.js";let P=class extends r{constructor(e){super(e),this._terrainIntersectionOptionsLayerUids=new Set(["terrain"])}initialize(){this.intersector=w(this.view.state.viewingMode),this.intersector.options.hud=!1,this.intersector.options.store=v.MIN}getScreenPointIntersection(e){const r=t(e,g.get()),o=j(this.view.state.camera,r,O);return this._getRayIntersection(o)}_getRayIntersection(e,r){const{view:t,intersector:o}=this;if(null==e||null==t.sceneIntersectionHelper)return null;o.options.store=v.MIN,t.sceneIntersectionHelper.intersectToolIntersectorRay(e,o,r);const s=o.results.min;if(null==s.target)return null;const n=p();if(!s.getIntersectionPoint(n))return null;if(null!=r?.maxDistance&&!s.withinDistance(r.maxDistance))return null;const i=t.renderCoordsHelper.fromRenderCoords(n,new m({spatialReference:t.spatialReference})),c=l(s.normal);if(I(s))return new y({type:b.TERRAIN,id:s.target.lij.slice(),mapPoint:i,renderPoint:n,normal:c,ray:d(e),graphic:null});const a=R(s,t);if(null==a)return null;const{layer:u,sourceLayer:f}=a,g="scene"===f?.type?h(a,f.objectIdField):a.uid;return new y({type:b.OBJECT,id:`${u?.uid}/${g}`,mapPoint:i,renderPoint:n,normal:c,ray:d(e),graphic:a})}updateFromGroundIntersection(e,r,t){const o=L,s=S,p=x,m=C;n(s,e),this.view.renderCoordsHelper.worldUpAtPosition(s,p),i(p,p);const u=this.view.basemapTerrain.visibleElevationBounds,d=(r>=0?1:-1)*((u?Math.abs(u.max-u.min):100)+Math.abs(r));c(m,p,d),a(o,s,m),f(o,s,O);const g=this._getRayIntersection(O,{include:this._terrainIntersectionOptionsLayerUids,maxDistance:d});if(null!=g){const e=C;return c(e,p,r),a(t,g.renderPoint,e),l(g.normal)}return n(t,e),null}};e([o()],P.prototype,"view",void 0),e([o()],P.prototype,"intersector",void 0),P=e([s("esri.views.3d.analysis.LineOfSight.LineOfSightRayIntersector")],P);const L=p(),S=p(),x=p(),C=p(),O=u();export{P as LineOfSightRayIntersector};