-
Notifications
You must be signed in to change notification settings - Fork 1
/
slow_down_mouse_wheel_zoom.js
25 lines (21 loc) · 1.12 KB
/
slow_down_mouse_wheel_zoom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var viewer = new Cesium.Viewer("cesiumContainer");
//Based code on https://gist.github.com/scothis
var eventHandler, mousePosition;
//Standart zoom fonksiyonunu iptal eder.
viewer.scene.screenSpaceCameraController.enableZoom = false;
eventHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
//İmlecin son hareket noktasının koordinatını hesaplar.
eventHandler.setInputAction(function (event) {
mousePosition = event.endPosition;
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
//Kamera yüksekliği ile tekerlek yaklaştırma katsayısını çarp, 2000'e böl, o oranda yaklaş.
eventHandler.setInputAction(function (wheelZoomAmount) {
var cameraHeight, directionToZoom, zoomAmount, maximumHeight;
if (mousePosition) {
maximumHeight = viewer.scene.globe.ellipsoid.maximumRadius * 4;
cameraHeight = viewer.camera.positionCartographic.height || maximumHeight;
directionToZoom = viewer.camera.getPickRay(mousePosition).direction;
zoomAmount = wheelZoomAmount * cameraHeight / 2000;
viewer.camera.move(directionToZoom, zoomAmount);
}
}, Cesium.ScreenSpaceEventType.WHEEL);