Make the map refresh every step player take

Greetings,
I wrote a map system that can update explored/visible/war-fog during every step player take, as the following figure shown:
rmmv.png

Because I modified $dataMap.data each step player take, I have to refresh the map. Now I am calling this to do the job:
Code:
SceneManager.goto(Scene_Map);

But the problem is that it causes a slightly lag during every update, which makes game experience just not smooth enough, is there a way to only update $dataMap.data without reloading the whole map?
I'd be more inclined to try $gameMap.refresh(), but I'm not sure how you wrote your fog of war bit. You could also try using SceneManager._scene, which should access the current scene.
I'd be more inclined to try $gameMap.refresh()
I have tried every $gameMap.refreshXXX() method but no luck. My fog of war is added to the 1st decoration layer of map.

You could also try using SceneManager._scene, which should access the current scene.
Yes, I can get the current scene, but also seems like non of scene.refreshXXX() function works for this.

BTW, I found that whenever player walk causes map to scroll (update the map so player can stay at the center of the screen), the map do refresh. But I don't know where to find the function this mechanism works (looks like this behavior does not live in Game_Map.scrollXXX() function), anyone has any ideas?
It would probably be good if we can see how you modified the data... TBH though, I would suggest just making filter layers than modifying the data for a fog of war system..
It would probably be good if we can see how you modified the data...
Let me try describe the algorithm: (this algorithm will be executed every player step, so $dataMap.data updates)
Code:
for (tile in $dataMap.data) {
  if (player_can_see(tile)) {
    tile = original_tile_block;
  } else if (has_explored(tile)) {
    tile = original_tile_block + fog decoration;
  } else {
    tile = black;
  }
}

TBH though, I would suggest just making filter layers than modifying the data for a fog of war system..
What do you mean by "filter layers"?
Like showing a black image on top of the tile that is supposed to be hidden from view and a slightly transparent black image for tiles that need to be slightly visible. Im not sure though about its effects performance-wise.

BTW there is a plugin here somewhere that allows temporary changing of a specific tile in the map in-game, you might want to check how it does it because I think you can copy the idea of its implementation since it probably also modifies the tile data array. Im unsure of the plugin's name though.
I found a way to refresh the map without so much lag! Although still doesn't know if there's any drawback using this methods:
Code:
var scene = SceneManager._scene;
scene.removeChild(scene._fadeSprite);
scene.removeChild(scene._mapNameWindow);
scene.removeChild(scene._windowLayer);
scene.removeChild(scene._spriteset);
scene.createDisplayObjects();

Original thread: https://forums.rpgmakerweb.com/threads/make-the-map-refresh-every-step-player-take.110695/