@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 11.1 kB
JavaScript
import{_ as t}from"../../../../../chunks/tslib.es6.js";import{cyclicalPI as i}from"../../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../../core/mathUtils.js";import{isNone as n,isSome as s}from"../../../../../core/maybe.js";import{createScreenPointArray as o,screenPointObjectToArray as r,createRenderScreenPointArray3 as a}from"../../../../../core/screenUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/Error.js";import"../../../../../core/has.js";import{subclass as m}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as h,d as c}from"../../../../../chunks/vec2.js";import{c as p,o as _,l,b as u,n as d,a as g,g as P,e as v}from"../../../../../chunks/vec3.js";import{c as C}from"../../../../../chunks/vec3f64.js";import{getReferenceEllipsoid as M}from"../../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as S}from"../../../../../geometry/support/axisAngle.js";import{create as w,fromPositionAndNormal as b,normal as f}from"../../../../../geometry/support/plane.js";import{c as j}from"../../../../../chunks/sphere.js";import{pixelDistanceToInteractionFactor as y,applyAll as E}from"../../../camera/constraintUtils.js";import{ConstraintTypes as O}from"../../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as A}from"../../../camera/constraintUtils/InteractionType.js";import{TiltMode as k}from"../../../camera/constraintUtils/TiltMode.js";import{ExponentialFalloff as z}from"../../../input/util.js";import{InteractiveController as R}from"../InteractiveController.js";import{PanPlanarMomentumController as x}from"../momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as T}from"../momentum/PanSphericalMomentumController.js";import{RotationMomentumController as H}from"../momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as U}from"../momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as F}from"../momentum/ZoomSphericalMomentumController.js";import{NavigationMode as D,pickPointAndInitSphere as I,contentIntersectorOptions as L,SpherePickPointFallback as Z,decideNavigationMode as N,sphereOrPlanePointFromScreenPoint as B,PAN_DISTANCE_MODIFIER as G,MIN_HEIGHT_LIMIT as V,SCREEN_PIXEL_AREA as q,intersectPlaneFromScreenPointAtEye as J,applyZoomOnSphere as K,preserveHeadingThreshold as Q,applyPanSphericalPreserveHeading as W,applyPanSphericalDirectRotation as X,normalizeRotationDelta as Y,applyRotation as $,applyPanPlanar as tt,applyZoomToPoint as it}from"../../utils/navigationUtils.js";import{Camera as et}from"../../../webgl-engine/lib/Camera.js";import{PanPlanarMomentumEstimator as nt}from"../../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as st}from"../../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as ot}from"../../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as rt}from"../../../../navigation/ZoomMomentumEstimator.js";let at=class extends R{constructor(){super(...arguments),this._smoothRotation=new z(.05),this._rotationAxis=C(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=w(),this._beginRadius=0,this._smoothScaling=new z(.05),this._zoomCenterScreen=o(),this._zoomMomentumEstimator=new rt,this._rotationMomentumEstimator=new ot,this._panSphericalMomentumEstimator=new st,this._panPlanarMomentumEstimator=new nt,this._adjustedSphere=j(),this._tmp3d=C(),this._tmpScreenPointArray=o(),this._beginScreenPoint=o(),this._beginScenePoint=C(),this._screenPickPoint=o(),this._scenePickPoint=C(),this._mode=D.Horizontal,this._sphere=j(),this._pointerCount=0,this._tmpInteractionDirection=C(),this._constraintOptions={selection:O.ALL,interactionType:A.NONE,interactionFactor:0,interactionStartCamera:new et,interactionDirection:null,tiltMode:k.TUMBLE}}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.active)return;const s=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=s,this._rotationMomentumEstimator.enabled=s,this._panPlanarMomentumEstimator.enabled=s,this._panSphericalMomentumEstimator.enabled=s,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._smoothRotation.reset(),r(t.center,this._screenPickPoint),h(this._beginScreenPoint,this._screenPickPoint);const o=M(this.view.spatialReference),a=I(this._intersectionHelper,this.startCamera,this._screenPickPoint,o,Z.Silhouette,0===this.view.map.ground.opacity?L:{});n(a.scenePickPoint)||(this._scenePickPoint=a.scenePickPoint,this._sphere=a.sphere,p(this._beginScenePoint,this._scenePickPoint),this._mode=N(this.startCamera,this._screenPickPoint,o),this._mode===D.Vertical&&this._preparePlanarPanMode(t,a.hasGeometryIntersection),this._constraintOptions.interactionStartCamera?.copyFrom(this.startCamera))}update(t){if(!this.active)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;this._mode===D.Horizontal?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this._zoomMomentumEstimator.evaluateMomentum();if(i)return this._mode===D.Horizontal?new F({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere[3]}):new U({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this._rotationMomentumEstimator.evaluateMomentum();if(e)return new H({view:this.view,momentum:e,center:this._sphere,axis:this._rotationAxis});if(this._mode===D.Horizontal){const t=this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new T({view:this.view,momentum:t})}else{const t=this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new x({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=_(this._tmp3d,this.startCamera.viewForward);b(this._scenePickPoint,e,this._panningPlane);const n=o(this._screenPickPoint[0],0),m=C(),h=l(this.startCamera.eye);this._adjustedSphere[3]=h<this._sphere[3]?h-100:this._sphere[3],B(this._adjustedSphere,this.startCamera,n,m);const c=a();this.startCamera.projectToRenderScreen(m,c);const M=C(),S=C(),w=C();u(M,this._scenePickPoint,this.currentCamera.eye);const j=l(M);d(M,M);const y=G*Math.max(Math.abs(this.view.camera.position.z),V),E=this.view._stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,q);let O=s(E)?E:y;O=i?Math.min(O,j):O,p(w,g(S,this.currentCamera.eye,P(S,M,O))),this._panningPlane[3]=-v(f(this._panningPlane),w),this.startCamera.center=g(S,this.startCamera.eye,P(S,this.startCamera.viewForward,O));const A=r(t.center,this._tmpScreenPointArray);J(this._panningPlane,this.startCamera,A,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),K(this._sphere,this.currentCamera,this._smoothScaling.value),r(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=A.ZOOM,this._constraintOptions.interactionFactor=y(t.radius-this._beginRadius),E(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=r(t.center,this._tmpScreenPointArray);B(this._sphere,this.currentCamera,i,this._tmp3d),Q(this._beginScenePoint,v(this.currentCamera.up,this._beginScenePoint),this._sphere[3],this._beginHeading,this.view.camera.tilt,this.startCamera)?(W(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(X(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere[3],this.view.camera.tilt)),this._constraintOptions.interactionType=A.PAN,this._constraintOptions.interactionFactor=y(c(this._screenPickPoint,i)),E(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){d(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||_(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+Y(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),$(this.currentCamera,this._sphere,S(this._rotationAxis,s)),this._constraintOptions.interactionType=A.TUMBLE,this._constraintOptions.interactionFactor=y(t.radius*e),E(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=r(t.center,this._tmpScreenPointArray);J(this._panningPlane,this.currentCamera,i,this._tmp3d)&&(tt(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=A.PAN,this._constraintOptions.interactionFactor=y(c(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),E(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),it(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=A.ZOOM,this._constraintOptions.interactionFactor=y(t.radius-this._beginRadius),E(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){p(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||_(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=Y(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const o=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(o,.001*t.timestamp),$(this.currentCamera,this._sphere,S(this._rotationAxis,o)),this._constraintOptions.interactionType=A.TUMBLE,this._constraintOptions.interactionFactor=y(t.radius*o),E(this.view,this.currentCamera,this._constraintOptions)}};at=t([m("esri.views.3d.state.controllers.global.PinchAndPanController")],at);export{at as PinchAndPanController};