UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) • 8.56 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o,asinClamped as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as i}from"../../../../core/screenUtils.js";import{fromRotation as a,exactEquals as s,rotate as c,multiply as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as m,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{distance as h,length as M,dot as g,subtract as y,transformMat4 as d,add as b,normalize as x,squaredDistance as j,copy as v,cross as P,scale as z,lerp as w,set as I}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as A}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as S,fromPoints as T,axis as U,wrapAxisAngle as G}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as R,vectorCoordinates as k}from"../../../../geometry/support/coordinateSystem.js";import{create as E,fromNormalAndOffset as H,intersectRay as q}from"../../../../geometry/support/plane.js";import{Sphere as C}from"../../../../geometry/support/sphere.js";import{sm4d as F,sv3d as O}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as W,fromScreen as B}from"../../support/geometryUtils/ray.js";import{intersectScreen as D}from"../../support/geometryUtils/sphere.js";import J from"../../webgl/RenderCamera.js";import{terrainId as K}from"../../webgl-engine/lib/verticalOffsetUtils.js";const L=30,N=[1,3e8],Q=8,V=[200,1508e5],X=5,Y=50,Z=5,$=10,_=80,tt=90,et=1e-6,nt={exclude:new Set([K])};function ot(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function rt(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function it(t,e,n){const o=a(F.get(),n[3],U(n));null==o||s(o,m)||(y(ne,t.eye,e),d(ne,ne,o),t.eye=b(ne,ne,e),y(ne,t.center,e),d(ne,ne,o),t.center=b(ne,ne,e),t.up=d(ne,t.up,o))}function at(t,e,n,o){return q(t,B(e,n,ce),o)}function st(t,e,n,o){return q(t,W(e,n,ce),o)}function ct(t,e,n,o){const r=O.get();let i=1-n;y(r,e,t.eye);const a=M(r);let s=a*(1-i);i>=0&&s<o&&(s=o,i=-(s-a)/a),Math.abs(a-s)<et||(z(r,r,i),t.eye=b(ne,t.eye,r),t.center=w(ne,t.center,e,i))}function lt(t,e,n){e.getScreenCenter(mt),D(t,e,mt,ne)&&(e.center=ne);const o=e.distance,r=o*n;if(Math.abs(o-r)<et)return;const i=z(O.get(),e.viewForward,r);e.eye=y(ne,e.center,i)}const mt=i();function ut(t,e){I(e,0,0,0);for(const n of t)b(e,e,n);z(e,e,1/t.length)}function ft(t,e,n,o){return Math.sin(t/M(e))*(n+o.radius)}function pt(t,e,n,o){return ft(Math.PI/2,e,n,o)+(t-Math.PI/2)}const ht={Elevation:3e4,Angle:e(16)},Mt=e(80);function gt(t,e,n,o,r,i){const a=A(),s=new C;let c=!0,l=!0;const{eye:m}=e;return t.intersectScreen(n,a,i)&&Bt(m,a,o)?s.radius=M(a):(l=!1,e.aboveGround&&0!==r?s.radius=Math.max(M(e.center),.9*o):s.radius=M(e.eye)-e.relativeElevation,1===r?xt(s,e,n,a):c=D(s,e,n,a)),{sphere:s,scenePickPoint:c?a:null,hasGeometryIntersection:l}}function yt(t,e,n,o){const r=t.relativeElevation;if(r>ht.Elevation&&"global"===o)return 1;W(t,e,le);const i=Math.sign(r),a=n.worldUpAtPosition(t.eye,ne);return-i*g(a,le.direction)<Math.sin(ht.Angle)*M(le.direction)?0:1}function dt(t,e,n){y(bt,n,e),t.eye=y(ne,t.eye,bt),t.center=y(ne,t.center,bt)}const bt=A();function xt(t,e,n,o){const r=W(e,n,ce);return null!=r&&(t.closestPointOnSilhouette(r,jt),t.intersectRay(r,o)?!(j(jt,r.origin)<j(o,r.origin))||(v(o,jt),!1):(y(vt,e.eye,e.center),x(vt,vt),H(vt,-g(x(vt,vt),jt),Pt),q(Pt,r,o),!1))}const jt=A(),vt=A(),Pt=E();function zt(i,a,s,c,l,m){let u=0;if(P(ie,i,a),y(oe,i,a),M(i)<=l||!c.aboveGround){P(s,oe,c.eye);const f=g(i,a)/(M(i)*M(a));if(f<.9999)u=o(f);else{const t=M(P(A(),i,a))/(M(i)*M(a));u=r(t)}const p=Math.cos(n(t.normalize(e(m)),0,Mt));u=-u-Math.max(0,M(a)-l)/(p*l)}else y(wt,c.eye,c.center),P(s,oe,wt),u=-M(oe)/l;return x(s,s),z(s,s,M(ie)),u}const wt=A();function It(r,i,a,s){let c,l;const m=Math.cos(n(t.normalize(e(s)),0,Mt));return c=i>a?-(i-a)/(m*a):i<-a?Math.PI-(i+a)/(m*a):o(i/a),l=r>a?-(r-a)/(m*a):r<-a?Math.PI-(r+a)/(m*a):o(r/a),(l-c)*a}function At(t,e,n,o,r,i,a,s,c,l){const m=It(t[2],e[2],i.radius,s),u=c?It(t[0],e[0],i.radius,180):e[0]-t[0],p=Math.sin(a)*u-Math.cos(a)*m,h=Math.cos(a)*u+Math.sin(a)*m;x(ne,r);const M=c?p/Math.sqrt(Math.abs(i.radius**2-g(n,ne)**2)):p/i.radius,y=h/Math.sqrt(Math.abs(i.radius**2-g(n,o)**2));f(l,M,y)}function St(t,e,n,o,r,i,a,s,c,l){P(ie,t,e),R(i.up,i.eye,Lt,Nt,Qt),R([0,0,1],i.eye,Dt,Jt,Kt),v(n,Jt),v(o,Dt),x(n,n),z(n,n,M(ie)),k(t,x(Nt,Nt),x(Qt,Qt),x(Lt,Lt),Vt),k(e,Nt,Qt,Lt,Xt),At(Vt,Xt,t,Dt,Jt,a,s,c,l,r)}function Tt(t,e,n,o,r,i,s){a($t,r,o),a(_t,s,i),l(te,$t,_t),y(e,t,n),d(e,e,te),b(e,e,n)}function Ut(t,e,n,o,r,i){a($t,o,n),a(_t,i,r),l(te,$t,_t),y(ne,t.eye,e),d(ne,ne,te),t.eye=b(ne,ne,e),y(ne,t.center,e),d(ne,ne,te),t.center=b(ne,ne,e),y(ne,t.up,e),d(ne,ne,te),t.up=b(ne,ne,e)}const Gt={Pole:.95,Angle:e(18),Tilt:45,TiltHysteresisMargin:1e-7};let Rt=!1;function kt(t,e,n,o,r,i){const a=Math.abs(o)>Math.PI-Gt.Angle||Math.abs(o)<Gt.Angle,s=(Math.abs(t[2])<n*Gt.Pole||Math.abs(e)>n)&&i;return a&&s?!Rt&&r<Gt.Tilt-Gt.TiltHysteresisMargin?Rt=!0:Rt&&r>Gt.Tilt+Gt.TiltHysteresisMargin&&(Rt=!1):Rt=!1,Rt}function Et(t,e,n,o,r,i){if(i)T(n,o,Zt),it(e,t.center,Zt);else{const i=zt(n,o,ae,e,t.radius,r);it(e,t.center,G(ae,i))}}function Ht(t,e,n,o,r,i,a){const s=a?20:1,c=1e-12;let l,m;v(ee,o),re.copyFrom(e);for(let u=0;u<s&&j(n,ee)>c&&(l=j(n,ee),St(n,ee,Jt,Dt,Yt,re,t,r,i,a),Ut(re,t.center,Dt,Yt[1],Jt,Yt[0]),Tt(ee,ee,t.center,Dt,Yt[1],Jt,Yt[0]),m=j(n,ee),m<l||0===u);u++)e.copyFrom(re)}function qt(n,o,r,i,a,s,c){kt(r,g(o.up,r),n.radius,-t.normalize(e(a)),s,o.aboveGround)?Ht(n,o,r,i,-t.normalize(e(a)),s,c):Et(n,o,r,i,s,c)}function Ct(t,e,n,o,r,i){const{eye:a}=t;R([0,0,1],a,Dt,Jt,Kt);const s=e.translation[0]*n.pan,l="zoom"===r.mode?0:e.translation[1]*n.pan,m=Math.max(Math.sqrt(Math.abs(1-g(t.center,Dt)**2/M(t.center)**2)),.5),u=(Math.sin(i)*l+Math.cos(i)*s)/m,f=-Math.cos(i)*l+Math.sin(i)*s;switch(c(o.pan.matrix,o.pan.matrix,u,Dt),o.pan.enabled=!0,r.mode){case"pan":c(o.pan.matrix,o.pan.matrix,f,Jt),o.pan.enabled=!0;break;case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Ft(t,e,n,o,r){const{eye:i,viewRight:a}=t,s=P(O.get(),a,i),l=e.translation[0]*n.pan;switch(0!==l&&(c(o.pan.matrix,o.pan.matrix,-l,s),o.pan.enabled=!0),r.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(c(o.pan.matrix,o.pan.matrix,t,a),o.pan.enabled=!0);break}case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Ot(n,o,r,i,a,s,c,l,m){kt(n.center,g(n.up,n.center),M(n.center),-t.normalize(e(s)),c,o.aboveGround)?Ct(o,r,i,l,m,-t.normalize(e(a))):Ft(o,r,i,l,m)}function Wt(t,e,n=1/0){const o=Math.abs(g(t,e));return Math.min(n,1/o)}function Bt(t,e,n){const o=h(t,e),r=M(t);return o<Math.max(r,n)}const Dt=A(),Jt=A(),Kt=A(),Lt=A(),Nt=A(),Qt=A(),Vt=A(),Xt=A(),Yt=p(),Zt=S(),$t=u(),_t=u(),te=u(),ee=A(),ne=A(),oe=A();let re=new J;const ie=A(),ae=A();function se(){re=new J}const ce={origin:A(),direction:A()},le={origin:A(),direction:A()};export{Mt as TiltThresholdPanningSpeed,ht as VerticalPanTresholds,dt as applyPanPlanar,Et as applyPanSphericalDirectRotation,Ht as applyPanSphericalPreserveHeading,it as applyRotation,Ut as applyRotationWithTwoAxes,lt as applyZoomOnSphere,ct as applyZoomToPoint,ut as centroid,se as cleanupNavigationUtils,et as distanceComparisonTolerance,nt as excludeTerrain,Wt as getTiltScaleFactor,yt as inferNavigationMode,at as intersectPlaneFromScreenPoint,st as intersectPlaneFromScreenPointAtEye,Bt as isHitOnSamePlanetSide,It as lengthFromPoints,X as maxPanDistanceModifier,Z as maxRotatePivotDistanceModifier,L as maxZoomPivotDistanceModifier,Q as maxZoomStepDistanceModifier,Y as minPinchAndPanCameraHeight,$ as minRotatePivotDistance,ot as normalizeCoordinate,rt as normalizeRotationDelta,pt as offSurfaceTiltToEyeTiltGlobal,ft as onSurfaceTiltToEyeTiltGlobal,Ot as panMotionToRotationMatrix,qt as panToPosition,gt as pickPointAndInitSphere,_ as pivotSearchAreaSize,Gt as preservingHeadingThresholds,tt as rotatePivotSearchAreaSize,Tt as rotatePointAroundTwoAxes,zt as rotationAngleAndAxisDirectRotation,St as rotationAnglesAndAxesHeadingPreserving,At as rotationAnglesHeadingPreserving,kt as shouldPreserveHeading,xt as sphereOrPlanePointFromScreenPoint,N as zoomPivotDistanceClamp,V as zoomStepDistanceClamp};