@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 5.21 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import{clamp as i}from"../../../../core/mathUtils.js";import{createScreenPointArray as r}from"../../../../core/screenUtils.js";import{subclass as e}from"../../../../core/accessorSupport/decorators.js";import{copy as s,distance as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as o,subtract as h,length as c,scale as m,add as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as l}from"../../../../geometry/ellipsoidUtils.js";import{create as u,fromPoints as P}from"../../../../geometry/support/axisAngle.js";import{Sphere as y}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as C,applyAll as g}from"../../camera/constraintUtils.js";import{ConstraintOptions as d}from"../../camera/constraintUtils/ConstraintOptions.js";import{applySurfaceCollisionConstraint as f}from"../../camera/constraintUtils/surfaceCollision.js";import{InteractiveController as v}from"./InteractiveController.js";import{normalizeCoordinate as R,pickPointAndInitSphere as w,excludeTerrain as D,inferNavigationMode as k,zoomPivotDistanceClamp as j,getTiltScaleFactor as A,maxZoomPivotDistanceModifier as b,pivotSearchAreaSize as x,distanceComparisonTolerance as M,sphereOrPlanePointFromScreenPoint as O,applyRotation as U}from"../utils/navigationUtils.js";import{fromScreenAtEye as z}from"../../support/geometryUtils/ray.js";const H=12;let B=class extends v{constructor(){super(...arguments),this._pickPoint=_(),this._tmpP0=a(),this._panAxisAngle=u(),this._tmpRayDir=_(),this._tmpRayDirPick=_(),this._targetOnSphere=_(),this._navigationMode=1,this._tmpRay={origin:_(),direction:_()},this.dragBeginPoint=r(),this._normalizedAnchorPoint=a(),this._constraintOptions=new d(7,1,0,this.startCamera),this._sphere=new y,this._hasPickPoint=!1}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.running)return;s(this.dragBeginPoint,t),R(this.startCamera,t,this._normalizedAnchorPoint);const r=l(this.view.spatialReference),e=w(this._intersectionHelper,this.startCamera,t,r.radius,0,this.view.basemapTerrain.invisible?D:{});if(this._navigationMode=k(this.startCamera,t,this.view.renderCoordsHelper,this.view.viewingMode),1===this._navigationMode)this._hasPickPoint=!!e.scenePickPoint,this._pickPoint=e.scenePickPoint??this._pickPoint,this._sphere=e.sphere;else{let r;z(this.startCamera,t,this._tmpRay),o(this._tmpRay.direction,this._tmpRay.direction),null!=e.scenePickPoint&&(h(this._tmpRayDirPick,this.startCamera.eye,e.scenePickPoint),r=c(this._tmpRayDirPick));const s=Math.abs(this.view.camera.position.z);this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,F);const n=i(A(F,this._tmpRay.direction,b)*s,j[0],j[1]),a=this.view.stage.renderView.getMinimalDepthForArea(null,t[0],t[1],this.view.state.camera,x);let _=null!=a?a:n;null!=r&&(_=Math.min(_,r)),this._hasPickPoint=!0,m(this._tmpRay.direction,this._tmpRay.direction,_),p(this._pickPoint,this._tmpRay.origin,this._tmpRay.direction)}}update(t){if(this.running){if(this.currentCamera.eye=this.startCamera.eye,this.currentCamera.center=this.startCamera.center,this.currentCamera.up=this.startCamera.up,1===this._navigationMode){h(this._tmpRayDir,this.currentCamera.center,this.currentCamera.eye);const i=c(this._tmpRayDir);R(this.currentCamera,t,this._tmpP0);const r=(this._normalizedAnchorPoint[1]-this._tmpP0[1])*H;let e=i*2**r;const s=this.view.state.constraints.minimumPoiDistance;if(r<0&&e<s&&(e=s),Math.abs(i-e)<M)return;if(this._hasPickPoint&&e<i){const t=1-(1-e/i)*(1-this._sphere.radius/c(this.currentCamera.center));this.currentCamera.center=m(S,this.currentCamera.center,t)}m(this._tmpRayDir,this._tmpRayDir,-e/i),this.currentCamera.eye=p(S,this.currentCamera.center,this._tmpRayDir),this._constraintOptions.interactionFactor=C(n(this.dragBeginPoint,t)),g(this.view,this.currentCamera,this._constraintOptions),this._hasPickPoint&&(O(this._sphere,this.currentCamera,this.dragBeginPoint,this._targetOnSphere),P(this._pickPoint,this._targetOnSphere,this._panAxisAngle),U(this.currentCamera,this._sphere.center,this._panAxisAngle))}else{const i=c(this._tmpRay.direction);R(this.currentCamera,t,this._tmpP0);const r=(this._normalizedAnchorPoint[1]-this._tmpP0[1])*H;let e=i*2**r;const s=this.view.state.constraints.minimumPoiDistance;if(r<0&&e<s&&(e=s),Math.abs(i-e)<M)return;m(this._tmpRayDir,this._tmpRay.direction,1-e/i),this.currentCamera.eye=p(S,this.currentCamera.eye,this._tmpRayDir),this.currentCamera.center=p(S,this.currentCamera.center,this._tmpRayDir),o(this._tmpRayDir,this._tmpRayDir),this._constraintOptions.interactionDirection=this._tmpRayDir,g(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}f(this.view,this.currentCamera),this.commitCamera()}}finish(){this.running&&this.finishController()}};B=t([e("esri.views.3d.state.controllers.ZoomControllerGlobal")],B);const S=_(),F=_();export{B as ZoomControllerGlobal};