UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.32 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{ViewingMode as e}from"../../../ViewingMode.js";import{isValidMbs as t}from"./I3SUtil.js";import{I3sTarget as i}from"./Intersector.js";import{StoreResults as n}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{IntersectorResult as r}from"../../webgl-engine/lib/IntersectorResult.js";import{IntersectorType as s}from"../../webgl-engine/lib/IntersectorType.js";import{MeshIntersectionOptions as l}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as o}from"../../webgl-engine/lib/verticalOffsetUtils.js";class c{constructor(e){this.type=s.I3S,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(t,i){this._needVerticalOffset=t&&i===e.Global}intersect(e,s,c,d,u,b){const f=e.results,m=e.options.store===n.ALL,h=e.ray.direction,p=e.tolerance;let y=e=>e,g=e=>e;const I=o(e.verticalOffset??(this._needVerticalOffset?0:null));null!=e.verticalOffset&&null!=I&&(y=e=>I.applyToMbs(e),g=e=>I.applyToObb(e));const R=new l(b,e.options.normalRequired),w=(n,l)=>{if(0===n.childrenLoaded)return!1;const o=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null;return!(o&&!g(o).intersectRay(c,h,p))&&(!l||!o&&t(n.serviceMbsInRenderSR)&&!a(y(n.serviceMbsInRenderSR),c,h,p)||null!=n.geometryObbInRenderSR&&!g(n.geometryObbInRenderSR).intersectRay(c,h,p)||this._collection.intersect(l,c,d,p,I,R,((t,l,o,a)=>{if(l<0||null!=s&&!s(c,d,l))return;const u=e=>{const r=new i(this.layerViewUid,this.sublayerId,n.index,t,a);e.set(this.type,r,l,o)};if(this.isGround&&(null==f.ground.distance||l<f.ground.distance)&&u(f.ground),!e.options.isFiltered&&((null==f.min.distance||l<f.min.distance)&&u(f.min),(null==f.max.distance||l>f.max.distance)&&u(f.max),m)){const t=new r(e.ray);u(t),e.results.all.push(t)}})),!0)};this._traverseNodeHierarchy(w)}}function a(e,t,i,n=0){const r=e[3]+n,s=t[0]-e[0],l=t[1]-e[1],o=t[2]-e[2],c=i[0],a=i[1],d=i[2],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{c as I3SIntersectionHandler};