From 73103eda3b77240ba7eaa90ee3b2436a15b7bdcb Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Sun, 19 Nov 2023 13:42:56 +0100 Subject: [PATCH] Improve redraw-trigger on settings-changes --- .../src/components/ControlBar/DayNightSwitch.vue | 1 + .../webapp/src/components/Menu/SettingsMenu.vue | 6 +++--- BlueMapCommon/webapp/src/js/MapViewer.js | 13 +++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/BlueMapCommon/webapp/src/components/ControlBar/DayNightSwitch.vue b/BlueMapCommon/webapp/src/components/ControlBar/DayNightSwitch.vue index 246b1d6d..dcc7378c 100644 --- a/BlueMapCommon/webapp/src/components/ControlBar/DayNightSwitch.vue +++ b/BlueMapCommon/webapp/src/components/ControlBar/DayNightSwitch.vue @@ -43,6 +43,7 @@ export default { animation = animate(t => { let u = EasingFunctions.easeOutQuad(t); this.mapViewer.uniforms.sunlightStrength.value = startValue * (1-u) + targetValue * u; + this.$bluemap.mapViewer.redraw(); }, 300); } } diff --git a/BlueMapCommon/webapp/src/components/Menu/SettingsMenu.vue b/BlueMapCommon/webapp/src/components/Menu/SettingsMenu.vue index 702714ac..155f2e61 100644 --- a/BlueMapCommon/webapp/src/components/Menu/SettingsMenu.vue +++ b/BlueMapCommon/webapp/src/components/Menu/SettingsMenu.vue @@ -8,15 +8,15 @@ {{$t('lighting.sunlight')}} + @update="mapViewer.uniforms.sunlightStrength.value = $event; $bluemap.mapViewer.redraw()">{{$t('lighting.sunlight')}} {{$t('lighting.ambientLight')}} + @update="mapViewer.uniforms.ambientLight.value = $event; $bluemap.mapViewer.redraw()">{{$t('lighting.ambientLight')}} {{stage.name}} diff --git a/BlueMapCommon/webapp/src/js/MapViewer.js b/BlueMapCommon/webapp/src/js/MapViewer.js index 9e789b1d..2fc80713 100644 --- a/BlueMapCommon/webapp/src/js/MapViewer.js +++ b/BlueMapCommon/webapp/src/js/MapViewer.js @@ -114,8 +114,8 @@ export class MapViewer { this.lastFrame = 0; this.lastRedrawChange = 0; - events.addEventListener("bluemapCameraMoved", () => this.lastRedrawChange = Date.now()) - events.addEventListener("bluemapTileLoaded", () => this.lastRedrawChange = Date.now()) + events.addEventListener("bluemapCameraMoved", this.redraw) + events.addEventListener("bluemapTileLoaded", this.redraw) // initialize this.initializeRootElement(); @@ -163,6 +163,8 @@ export class MapViewer { this.camera.aspect = this.rootElement.clientWidth / this.rootElement.clientHeight; this.camera.updateProjectionMatrix(); + + this.redraw(); }; /** @@ -264,6 +266,13 @@ export class MapViewer { } } + /** + * Call to wake up the render-loop and render on high-fps for a while + */ + redraw = () => { + this.lastRedrawChange = Date.now(); + } + /** * @private * The render-loop to update and possibly render a new frame.