@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 1.81 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{sub as e,normalize as t}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Tiles3DTarget as n}from"../i3s/Intersector.js";import{ElevationRange as s}from"../../support/ElevationRange.js";import{IntersectorResult as r}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as o,computeInvDir as l,intersectAabbInvDir as a}from"../../webgl-engine/lib/RayIntersections.js";class c{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.isGround=!0,this.layerViewUid=e.uid}intersect(s,c,d,m,p,f){if(s.options.filteredLayerViewUids.includes(this.layerView.uid))return;const{results:g,tolerance:h}=s,w=2===s.options.store,{componentObjectCollection:b}=this.layerView.view.stage.renderView,y=new o(h,f,s.options.normalRequired),V=l(d,m,u),R=e(i(),m,d),j=t(i(),R),v=(e,t,i)=>{if(t>=0){if(null!=c&&!c(d,m,t))return;const e=e=>{const s=new n(this.layerView.uid);e.set(this.type,s,t,i)};if(this.isGround&&(null==g.ground.distance||t<g.ground.distance)&&e(g.ground),s.options.isFiltered)return;if((null==g.min.distance||t<g.min.distance)&&e(g.min),(null==g.max.distance||t>g.max.distance)&&e(g.max),w){const t=new r(s.ray);e(t),s.results.all.push(t)}}};this.layerView.forEachTile(e=>{if(!e.boundingVolumeIntersectsRay(d,j))return;const{componentObjects:t}=e;for(const i of t)a(i.aabbInWorldCoordinates,d,V,0)&&b.intersect(i,d,m,null,y,v)})}getElevationRange(e){let t=null;return this.layerView.forEachTile(i=>{t?.contains(i.elevationRange)||i.boundingVolumeIntersectsSphere(e)&&(t||(t=new s),t.expandElevationRange(i.elevationRange))}),t||(t=new s(0,0)),t}}const u=i();export{c as Tiles3DMeshIntersectionHandler};