From 2d69836887920dae8172d80bf958e5790faa31d5 Mon Sep 17 00:00:00 2001 From: David Camp Date: Thu, 7 Aug 2025 21:05:35 -0700 Subject: [PATCH] reduce overhead by not spamming updates when stationary --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 80bb024..671b52a 100644 --- a/index.js +++ b/index.js @@ -504,10 +504,14 @@ function redrawDynamics(){ // Placing it after culling means that if the user fast travels the map won't snap to them until manually scrolled to near their position. if(MapData.layers.gps && marker.type === 'player') { //This works fine - MapData.view.x = -marker.position.x * MapData.view.scale + mapCanvas.width * 0.5; - //This does not + let newX = -marker.position.x * MapData.view.scale + mapCanvas.width * 0.5; + if(Math.abs(MapData.view.x - newX) >= 10) { // Needs some tuning, but the idea is to not keep calling the map update _constantly_ when stationary. + MapData.view.x = newX; + MapData.view.dirty = true; + } + //This calculation does not // MapData.view.y = -marker.position.z * MapData.view.scale; - MapData.view.dirty = true; + } if(marker.hidden || (marker.minZoom && MapData.view.scale < marker.minZoom) || (marker.maxZoom && MapData.view.scale > marker.maxZoom)) continue;