Improve redraw-trigger on settings-changes

This commit is contained in:
Lukas Rieger (Blue) 2023-11-19 13:42:56 +01:00
parent 77c1e42009
commit 73103eda3b
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
3 changed files with 15 additions and 5 deletions

View File

@ -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);
}
}

View File

@ -8,15 +8,15 @@
<Group :title="$t('lighting.title')">
<Slider :value="mapViewer.uniforms.sunlightStrength.value" :min="0" :max="1" :step="0.01"
@update="mapViewer.uniforms.sunlightStrength.value = $event">{{$t('lighting.sunlight')}}</Slider>
@update="mapViewer.uniforms.sunlightStrength.value = $event; $bluemap.mapViewer.redraw()">{{$t('lighting.sunlight')}}</Slider>
<Slider :value="mapViewer.uniforms.ambientLight.value" :min="0" :max="1" :step="0.01"
@update="mapViewer.uniforms.ambientLight.value = $event">{{$t('lighting.ambientLight')}}</Slider>
@update="mapViewer.uniforms.ambientLight.value = $event; $bluemap.mapViewer.redraw()">{{$t('lighting.ambientLight')}}</Slider>
</Group>
<Group :title="$t('resolution.title')">
<SimpleButton v-for="stage of qualityStages" :key="stage.name"
:active="mapViewer.superSampling === stage.value"
@action="$bluemap.mapViewer.superSampling = stage.value; $bluemap.saveUserSettings();"
@action="$bluemap.mapViewer.superSampling = stage.value; $bluemap.saveUserSettings(); $bluemap.mapViewer.redraw()"
>{{stage.name}}</SimpleButton>
</Group>

View File

@ -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.