Skip to content

Commit

Permalink
calculate and use frames per second in handle zoom func
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemckinstry committed Sep 23, 2024
1 parent b1c1963 commit 6712b1d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/engine/Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,18 @@ function handleZoom(
const maxHeight = object.maximumZoomDistance;

const minDistance = distanceMeasure - minHeight;
let zoomRate = zoomFactor * minDistance;

const timeStamps = object._scene.frameState?.timeStamps;
let fpsMultiplier = 1;
if (timeStamps?.length === 10) {
const elapsedTime = (timeStamps[0] - timeStamps[9]) / 9;
const fps = 1 / (elapsedTime / 1000);
// target refresh rate of 30hz
fpsMultiplier = 30 / fps;
}

let zoomRate = zoomFactor * minDistance * fpsMultiplier;

zoomRate = CesiumMath.clamp(
zoomRate,
object._minimumZoomRate,
Expand Down

0 comments on commit 6712b1d

Please sign in to comment.