Skip to content

Commit

Permalink
Improve redraw-trigger on settings-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Nov 19, 2023
1 parent 77c1e42 commit 73103ed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions BlueMapCommon/webapp/src/components/Menu/SettingsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
13 changes: 11 additions & 2 deletions BlueMapCommon/webapp/src/js/MapViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -163,6 +163,8 @@ export class MapViewer {

this.camera.aspect = this.rootElement.clientWidth / this.rootElement.clientHeight;
this.camera.updateProjectionMatrix();

this.redraw();
};

/**
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 73103ed

Please sign in to comment.