@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{I3sTarget as e}from"./Intersector.js";import{IntersectorResult as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as i}from"../../webgl-engine/lib/verticalOffsetUtils.js";class r{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,t){this._needVerticalOffset=e&&1===t}intersect(r,l,o,c,a,d){const u=2===r.options.store,b=r.ray.direction;let f=e=>e,h=e=>e;const y=i(r.verticalOffset??(this._needVerticalOffset?0:null));null!=r.verticalOffset&&null!=y&&(f=e=>y.applyToMbs(e),h=e=>y.applyToObb(e));const{results:m,tolerance:p}=r,R=new n(p,d,r.options.normalRequired),g=(n,i)=>{if(0===n.childrenLoaded)return!1;const a=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null;if(a&&!h(a).intersectRay(o,b,p))return!1;const{serviceMbsInRenderSRElevationAdjusted:d}=n;return!i||!a&&d.isValid&&!s(f(d),o,b,p)||null!=n.geometryObbInRenderSR&&!h(n.geometryObbInRenderSR).intersectRay(o,b,p)||this._collection.intersect(i,o,c,y,R,(i,s,a,d)=>{if(s<0||null!=l&&!l(o,c,s))return;const b=t=>{const r=new e(this.layerViewUid,this.sublayerId,n.index,i,d);t.set(this.type,r,s,a)};if(this.isGround&&(null==m.ground.distance||s<m.ground.distance)&&b(m.ground),!r.options.isFiltered&&((null==m.min.distance||s<m.min.distance)&&b(m.min),(null==m.max.distance||s>m.max.distance)&&b(m.max),u)){const e=new t(r.ray);b(e),r.results.all.push(e)}}),!0};this._traverseNodeHierarchy(g)}}function s(e,t,n,i=0){const r=e.radius+i,s=t[0]-e.center[0],l=t[1]-e.center[1],o=t[2]-e.center[2],[c,a,d]=n,u=c*s+a*l+d*o;return u*u-(c*c+a*a+d*d)*(s*s+l*l+o*o-r*r)>=0}export{r as I3SIntersectionHandler};