UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 4.18 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../../../../chunks/tslib.es6.js";import{clamp as i}from"../../../../core/mathUtils.js";import{createScreenPointArray as s}from"../../../../core/screenUtils.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{copy as e,distance as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{d as o,l as m,n as h,e as c,g as p,f as _,u as l,c as u,m as f}from"../../../../chunks/vec32.js";import{create as C,fromValues as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as g,fromPositionAndNormal as D}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as j,applyAll as y}from"../../camera/constraintUtils.js";import{ConstraintOptions as v}from"../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as O}from"../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as d}from"../../camera/constraintUtils/InteractionType.js";import{getVoxelWasm as b}from"../../layers/VoxelWasm.js";import{InteractiveController as w}from"./InteractiveController.js";import{normalizeCoordinate as M,excludeTerrain as I,distanceClampValues as N,pivotDistanceModifier as R,screenPixelArea as x,intersectPlaneFromScreenPoint as U}from"../utils/navigationUtils.js";let A=class extends w{constructor(){super(...arguments),this._tmpP=C(),this._tmpDir=C(),this._tmpN=C(),this._tmpP0=n(),this._tmpPOI=C(),this._tmpRayDir=C(),this.dragBeginPoint=s(),this._normalizedAnchorPoint=n(),this._constraintOptions=new v(O.ALL,d.ZOOM,0,this.startCamera,C()),this._plane=g()}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.running)return;e(this.dragBeginPoint,t),M(this.startCamera,t,this._normalizedAnchorPoint);const s=this._intersectionHelper.intersectScreenFreePointFallback(t,this._tmpP,this.view.basemapTerrain.invisible?I:{});o(this._tmpDir,this._tmpP,this.startCamera.eye);const r=m(this._tmpDir);h(this._tmpDir,this._tmpDir);const a=Math.abs(this.view.camera.position.z);let n=i(Math.min(R,1/Math.abs(c(L,this._tmpDir)))*a,N[0],N[1]);const u=this.view.stage.renderView.getMinimalDepthForArea(b(this.view),t[0],t[1],this.view.state.camera,x);n=null!=u?u:n,n=s?Math.min(n,r):n,p(this._tmpDir,this._tmpDir,n),_(this._tmpP,this.startCamera.eye,this._tmpDir),o(this._tmpN,this.startCamera.eye,this.startCamera.center),h(this._tmpN,this._tmpN),this._tmpN[1]<0&&l(this._tmpN,this._tmpN),D(this._tmpP,this._tmpN,this._plane)}update(t){if(!this.running)return;U(this._plane,this.currentCamera,this.dragBeginPoint,this._tmpPOI)||u(this._tmpPOI,this.currentCamera.center),M(this.currentCamera,t,this._tmpP0);let i=4*(this._tmpP0[1]-this._normalizedAnchorPoint[1]);e(this._normalizedAnchorPoint,this._tmpP0),o(this._tmpRayDir,this._tmpPOI,this.currentCamera.eye);const s=m(this._tmpRayDir);let r=s*(1-i);this._constraintOptions.interactionDirection&&(u(this._constraintOptions.interactionDirection,this._tmpRayDir),p(this._constraintOptions.interactionDirection,this._constraintOptions.interactionDirection,Math.sign(i)/s));const n=this.view.state.constraints.minimumPoiDistance;i>=0&&r<n&&(r=n,i=-(r-s)/s),Math.abs(s-r)<1e-6||(p(this._tmpRayDir,this._tmpRayDir,i),this.currentCamera.eye=_(z,this.currentCamera.eye,this._tmpRayDir),f(z,this.currentCamera.center,this._tmpPOI,i),this._tmpPOI[2]>this.startCamera.center[2]?z[2]=Math.max(this.startCamera.center[2],z[2]):z[2]=Math.min(this.startCamera.center[2],z[2]),this.currentCamera.center=z,this._constraintOptions.interactionFactor=j(a(this.dragBeginPoint,t)),y(this.view,this.currentCamera,this._constraintOptions),this.commitCamera())}finish(){this.running&&this.finishController()}};A=t([r("esri.views.3d.state.controllers.ZoomControllerLocal")],A);const z=C(),L=P(0,0,1);export{A as ZoomControllerLocal};