@@ -28,7 +28,7 @@ import {MouseZoomControls} from "./mouse/MouseZoomControls";
2828import { MouseRotateControls } from "./mouse/MouseRotateControls" ;
2929import { MouseAngleControls } from "./mouse/MouseAngleControls" ;
3030import { MathUtils , Vector2 , Vector3 } from "three" ;
31- import { Manager , Pan , Pinch , Rotate , Tap , DIRECTION_ALL , DIRECTION_VERTICAL } from "hammerjs" ;
31+ import { DIRECTION_ALL , DIRECTION_VERTICAL , Manager , Pan , Pinch , Rotate , Tap } from "hammerjs" ;
3232import { softClamp } from "../../util/Utils" ;
3333import { MapHeightControls } from "./MapHeightControls" ;
3434import { KeyMoveControls } from "./keyboard/KeyMoveControls" ;
@@ -39,10 +39,10 @@ import {TouchMoveControls} from "./touch/TouchMoveControls";
3939import { TouchRotateControls } from "./touch/TouchRotateControls" ;
4040import { TouchAngleControls } from "./touch/TouchAngleControls" ;
4141import { TouchZoomControls } from "./touch/TouchZoomControls" ;
42- import { PlayerMarker } from "../../markers/PlayerMarker" ;
4342import { reactive } from "vue" ;
4443
4544const HALF_PI = Math . PI * 0.5 ;
45+ const HALF_PI_DIV = 1 / HALF_PI ;
4646
4747export class MapControls {
4848
@@ -173,7 +173,7 @@ export class MapControls {
173173 this . manager . distance = softClamp ( this . manager . distance , this . minDistance , this . maxDistance , 0.8 ) ;
174174
175175 // max angle for current distance
176- let maxAngleForZoom = this . getMaxPerspectiveAngleForDistance ( this . manager . distance ) ;
176+ let maxAngleForZoom = MapControls . getMaxPerspectiveAngleForDistance ( this . manager . distance ) ;
177177
178178 // rotation
179179 this . mouseRotate . update ( delta , map ) ;
@@ -215,10 +215,15 @@ export class MapControls {
215215 this . touchZoom . reset ( ) ;
216216 }
217217
218- getMaxPerspectiveAngleForDistance ( distance ) {
218+ static getMaxPerspectiveAngleForDistance ( distance ) {
219219 return MathUtils . clamp ( ( 1 - Math . pow ( Math . max ( distance - 5 , 0.001 ) * 0.0005 , 0.5 ) ) * HALF_PI , 0 , HALF_PI )
220220 }
221221
222+ // getMaxPerspectiveAngleForDistance but in reverse (its simple maths, they said)
223+ static getMaxDistanceForPerspectiveAngle ( angle ) {
224+ return Math . pow ( - ( angle * HALF_PI_DIV ) + 1 , 2 ) * 2000 + 5 ;
225+ }
226+
222227 initializeHammer ( ) {
223228 let touchTap = new Tap ( { event : 'tap' , pointers : 1 , taps : 1 , threshold : 5 } ) ;
224229 let touchMove = new Pan ( { event : 'move' , pointers : 1 , direction : DIRECTION_ALL , threshold : 0 } ) ;
0 commit comments