UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.42 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 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,g as c,f as a}from"../../../../chunks/vec32.js";import{create as l,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import m from"../../../../geometry/Point.js";import{copy as u,fromPoints as f,create as d}from"../../../../geometry/support/ray.js";import{sv2d as g}from"../../../../geometry/support/vectorStacks.js";import{getObjectId as y}from"../../../../layers/graphics/dehydratedFeatures.js";import{LineOfSightIntersectionResult as h}from"./LineOfSightIntersectionResult.js";import{fromScreen as j}from"../../support/geometryUtils/ray.js";import{isTerrainIntersectorResult as I}from"../../terrain/Intersector.js";import{Intersector as w}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as b}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{IntersectorType as v}from"../../webgl-engine/lib/IntersectorType.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=new w(this.view.state.viewingMode),this.intersector.options.hud=!1,this.intersector.options.store=b.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=b.MIN,t.sceneIntersectionHelper.intersectToolIntersectorRay(e,o,r);const s=o.results.min;if(null==s.target)return null;const n=l();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=p(s.normal);if(I(s))return new h({type:v.TERRAIN,id:s.target.lij.slice(),mapPoint:i,renderPoint:n,normal:c,ray:u(e),graphic:null});const a=R(s,t);if(null==a)return null;const{layer:f,sourceLayer:d}=a,g="scene"===d?.type?y(a,d.objectIdField):a.uid;return new h({type:v.OBJECT,id:`${f?.uid}/${g}`,mapPoint:i,renderPoint:n,normal:c,ray:u(e),graphic:a})}updateFromGroundIntersection(e,r,t){const o=L,s=S,l=x,m=C;n(s,e),this.view.renderCoordsHelper.worldUpAtPosition(s,l),i(l,l);const u=this.view.basemapTerrain.visibleElevationBounds,d=(r>=0?1:-1)*((u?Math.abs(u.max-u.min):100)+Math.abs(r));c(m,l,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,l,r),a(t,g.renderPoint,e),p(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=l(),S=l(),x=l(),C=l(),O=d();export{P as LineOfSightRayIntersector};