Skip to content

Commit 4d58cc2

Browse files
committed
Add per-map view-settings and optimized flat-view only maps
1 parent f08c794 commit 4d58cc2

File tree

21 files changed

+812
-480
lines changed

21 files changed

+812
-480
lines changed

common/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ private static class Settings {
123123

124124
private boolean useCookies = true;
125125

126-
private boolean enableFreeFlight = true;
127126
private boolean defaultToFlatView = false;
128127

129128
private String startLocation = null;
@@ -150,7 +149,6 @@ private static class Settings {
150149

151150
public void setFrom(WebappConfig config) {
152151
this.useCookies = config.isUseCookies();
153-
this.enableFreeFlight = config.isEnableFreeFlight();
154152
this.defaultToFlatView = config.isDefaultToFlatView();
155153
this.startLocation = config.getStartLocation().orElse(null);
156154
this.resolutionDefault = config.getResolutionDefault();

common/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public class MapConfig implements MapSettings {
7575

7676
private boolean renderEdges = true;
7777

78-
private boolean saveHiresLayer = true;
78+
private boolean enablePerspectiveView = true;
79+
private boolean enableFlatView = true;
80+
private boolean enableFreeFlightView = true;
81+
private boolean enableHires = true;
7982

8083
private String storage = "file";
8184

common/src/main/java/de/bluecolored/bluemap/common/config/WebappConfig.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public class WebappConfig {
4242

4343
private boolean useCookies = true;
4444

45-
private boolean enableFreeFlight = true;
4645
private boolean defaultToFlatView = false;
4746

4847
private String startLocation = null;
@@ -82,10 +81,6 @@ public boolean isUseCookies() {
8281
return useCookies;
8382
}
8483

85-
public boolean isEnableFreeFlight() {
86-
return enableFreeFlight;
87-
}
88-
8984
public boolean isDefaultToFlatView() {
9085
return defaultToFlatView;
9186
}

common/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,28 @@ min-inhabited-time: 0
9696
# Default is true
9797
render-edges: true
9898

99-
# Whether the hires-layer will be saved to the storage.
99+
# Whether the perspective view will be enabled for this map.
100+
# Changing this to true requires a re-render of the map, only if the hires-layer is enabled and free-flight view is disabled.
101+
# Default is true
102+
enable-perspective-view: true
103+
104+
# Whether the flat (isometric, top-down) view will be enabled for this map.
105+
# Having only flat-view enabled while disabling free-flight and perspective will speed up the render and reduce the maps storage-size.
106+
# Default is true
107+
enable-flat-view: true
108+
109+
# Whether the free-flight view will be enabled for this map.
110+
# Changing this to true requires a re-render of the map, only if the hires-layer is enabled and perspective view is disabled.
111+
# Default is true
112+
enable-free-flight-view: true
113+
114+
# Whether the hires-layer will be enabled.
100115
# Disabling this will speed up rendering and reduce the size of the map-files a lot.
101116
# But you will not be able to see the full 3d-models if you zoom in on the map.
102117
# Changing this to false will not remove any existing tiles, existing tiles just won't get updated anymore.
103118
# Changing this to true will require a re-render of the map.
104119
# Default is true
105-
save-hires-layer: true
120+
enable-hires: true
106121

107122
# This defines the storage-config that will be used to save this map.
108123
# You can find your storage configs next to this config file in the 'storages'-folder.

common/src/main/resources/de/bluecolored/bluemap/config/webapp.conf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ update-settings-file: true
2222
# Default is true
2323
use-cookies: true
2424

25-
# If the free-flight-mode in the web-application is enabled or not.
26-
# Default is true
27-
enable-free-flight: true
28-
2925
# If the webapp will default to flat-view instead of perspective-view.
3026
# Default is false
3127
default-to-flat-view: false

common/webapp/src/components/ControlBar/ControlsSwitch.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
2-
<div class="controls-switch">
3-
<SvgButton :active="isPerspectiveView" @action="setPerspectiveView" :title="$t('controls.perspective.tooltip')">
2+
<div class="controls-switch" v-if="showViewControls">
3+
<SvgButton v-if="mapViewer.map.perspectiveView" :active="isPerspectiveView" @action="setPerspectiveView" :title="$t('controls.perspective.tooltip')">
44
<svg viewBox="0 0 30 30">
55
<path d="M19.475,10.574c-0.166-0.021-0.337-0.036-0.51-0.045c-0.174-0.009-0.35-0.013-0.525-0.011
66
c-0.176,0.002-0.353,0.01-0.526,0.024c-0.175,0.015-0.347,0.036-0.515,0.063l-13.39,2.189
@@ -13,12 +13,12 @@
1313
c-0.116-0.051-0.243-0.097-0.381-0.138c-0.137-0.041-0.283-0.078-0.438-0.108C19.803,10.621,19.641,10.595,19.475,10.574"/>
1414
</svg>
1515
</SvgButton>
16-
<SvgButton :active="isFlatView" @action="setFlatView" :title="$t('controls.flatView.tooltip')">
16+
<SvgButton v-if="mapViewer.map.flatView" :active="isFlatView" @action="setFlatView" :title="$t('controls.flatView.tooltip')">
1717
<svg viewBox="0 0 30 30">
1818
<path d="M22.371,4.158c1.65,0,3,1.35,3,3v15.684c0,1.65-1.35,3-3,3H7.629c-1.65,0-3-1.35-3-3V7.158c0-1.65,1.35-3,3-3H22.371z"/>
1919
</svg>
2020
</SvgButton>
21-
<SvgButton v-if="controls.enableFreeFlight" :active="isFreeFlight" @action="setFreeFlight" :title="$t('controls.freeFlight.tooltip')">
21+
<SvgButton v-if="mapViewer.map.freeFlightView" :active="isFreeFlight" @action="setFreeFlight" :title="$t('controls.freeFlight.tooltip')">
2222
<svg viewBox="0 0 30 30">
2323
<path d="M21.927,11.253c-0.256-0.487-0.915-0.885-1.465-0.885h-2.004c-0.55,0-0.726-0.356-0.39-0.792c0,0,0.698-0.905,0.698-2.041
2424
c0-2.08-1.687-3.767-3.767-3.767s-3.767,1.687-3.767,3.767c0,1.136,0.698,2.041,0.698,2.041c0.336,0.436,0.161,0.794-0.389,0.797
@@ -40,6 +40,7 @@
4040
data() {
4141
return {
4242
controls: this.$bluemap.appState.controls,
43+
mapViewer: this.$bluemap.mapViewer.data
4344
}
4445
},
4546
computed: {
@@ -51,6 +52,10 @@
5152
},
5253
isFreeFlight() {
5354
return this.controls.state === "free";
55+
},
56+
showViewControls() {
57+
if (!this.mapViewer.map) return 0;
58+
return this.mapViewer.map.views.length > 1;
5459
}
5560
},
5661
methods: {

common/webapp/src/components/Menu/SettingsMenu.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<div>
33
<Group :title="$t('controls.title')">
4-
<SimpleButton :active="appState.controls.state === 'perspective'" @action="$bluemap.setPerspectiveView(500, appState.controls.state === 'free' ? 100 : 0)">{{$t('controls.perspective.button')}}</SimpleButton>
5-
<SimpleButton :active="appState.controls.state === 'flat'" @action="$bluemap.setFlatView(500, appState.controls.state === 'free' ? 100 : 0)">{{$t('controls.flatView.button')}}</SimpleButton>
6-
<SimpleButton v-if="appState.controls.enableFreeFlight" :active="appState.controls.state === 'free'" @action="$bluemap.setFreeFlight(500)">{{$t('controls.freeFlight.button')}}</SimpleButton>
4+
<SimpleButton v-if="mapViewer.map.perspectiveView" :active="appState.controls.state === 'perspective'" @action="$bluemap.setPerspectiveView(500, appState.controls.state === 'free' ? 100 : 0)">{{$t('controls.perspective.button')}}</SimpleButton>
5+
<SimpleButton v-if="mapViewer.map.flatView" :active="appState.controls.state === 'flat'" @action="$bluemap.setFlatView(500, appState.controls.state === 'free' ? 100 : 0)">{{$t('controls.flatView.button')}}</SimpleButton>
6+
<SimpleButton v-if="mapViewer.map.freeFlightView" :active="appState.controls.state === 'free'" @action="$bluemap.setFreeFlight(500)">{{$t('controls.freeFlight.button')}}</SimpleButton>
77
</Group>
88

99
<Group :title="$t('lighting.title')">

common/webapp/src/js/BlueMapApp.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export class BlueMapApp {
5959
/** @type {{
6060
* version: string,
6161
* useCookies: boolean,
62-
* enableFreeFlight: boolean,
6362
* defaultToFlatView: boolean,
6463
* resolutionDefault: number,
6564
* minZoomDistance: number,
@@ -96,7 +95,6 @@ export class BlueMapApp {
9695
mouseSensitivity: 1,
9796
showZoomButtons: true,
9897
invertMouse: false,
99-
enableFreeFlight: false,
10098
pauseTileLoading: false
10199
},
102100
menu: this.mainMenu,
@@ -139,7 +137,6 @@ export class BlueMapApp {
139137
await this.getSettings();
140138
this.mapControls.minDistance = this.settings.minZoomDistance;
141139
this.mapControls.maxDistance = this.settings.maxZoomDistance;
142-
this.appState.controls.enableFreeFlight = this.settings.enableFreeFlight;
143140

144141
// load settings-styles
145142
if (this.settings.styles) for (let styleUrl of this.settings.styles) {
@@ -259,7 +256,9 @@ export class BlueMapApp {
259256

260257
await this.mapViewer.switchMap(map)
261258

262-
if (resetCamera) this.resetCamera();
259+
if (resetCamera || !this.mapViewer.map.hasView(this.appState.controls.state))
260+
this.resetCamera();
261+
263262
this.updatePageAddress();
264263

265264
await Promise.all([
@@ -283,10 +282,18 @@ export class BlueMapApp {
283282

284283
controls.controls = this.mapControls;
285284
this.appState.controls.state = "perspective";
286-
if (this.settings.defaultToFlatView) {
285+
286+
if (this.settings.defaultToFlatView && map.hasView("flat")) {
287287
this.setFlatView();
288288
}
289289

290+
else if (!map.hasView("perspective")) {
291+
if (map.hasView("flat"))
292+
this.setFlatView();
293+
else
294+
this.setFreeFlight();
295+
}
296+
290297
this.updatePageAddress();
291298
}
292299

@@ -328,7 +335,6 @@ export class BlueMapApp {
328335
this.settings = {
329336
version: "?",
330337
useCookies: false,
331-
enableFreeFlight: true,
332338
defaultToFlatView: false,
333339
resolutionDefault: 1.0,
334340
minZoomDistance: 5,
@@ -451,6 +457,7 @@ export class BlueMapApp {
451457

452458
setPerspectiveView(transition = 0, minDistance = 5) {
453459
if (!this.mapViewer.map) return;
460+
if (!this.mapViewer.map.data.perspectiveView) return;
454461
if (this.viewAnimation) this.viewAnimation.cancel();
455462

456463
let cm = this.mapViewer.controlsManager;
@@ -488,6 +495,7 @@ export class BlueMapApp {
488495

489496
setFlatView(transition = 0, minDistance = 5) {
490497
if (!this.mapViewer.map) return;
498+
if (!this.mapViewer.map.data.flatView) return;
491499
if (this.viewAnimation) this.viewAnimation.cancel();
492500

493501
let cm = this.mapViewer.controlsManager;
@@ -521,7 +529,7 @@ export class BlueMapApp {
521529

522530
setFreeFlight(transition = 0, targetY = undefined) {
523531
if (!this.mapViewer.map) return;
524-
if (!this.settings.enableFreeFlight) return this.setPerspectiveView(transition);
532+
if (!this.mapViewer.map.data.freeFlightView) return;
525533
if (this.viewAnimation) this.viewAnimation.cancel();
526534

527535
let cm = this.mapViewer.controlsManager;

common/webapp/src/js/map/Map.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ export class Map {
7878
tileSize: {x: 32, z: 32},
7979
lodFactor: 5,
8080
lodCount: 3
81-
}
81+
},
82+
perspectiveView: false,
83+
flatView: false,
84+
freeFlightView: false,
85+
views: ["perspective", "flat", "free"]
8286
});
8387

8488
this.raycaster = new Raycaster();
@@ -198,6 +202,15 @@ export class Map {
198202
lodCount: worldSettings.lowres.lodCount !== undefined ? worldSettings.lowres.lodCount : this.data.lowres.lodCount
199203
};
200204

205+
this.data.perspectiveView = worldSettings.perspectiveView !== undefined ? worldSettings.perspectiveView : this.data.perspectiveView;
206+
this.data.flatView = worldSettings.flatView !== undefined ? worldSettings.flatView : this.data.flatView;
207+
this.data.freeFlightView = worldSettings.freeFlightView !== undefined ? worldSettings.freeFlightView : this.data.freeFlightView;
208+
209+
this.data.views = [];
210+
if (this.data.perspectiveView) this.data.views.push("perspective");
211+
if (this.data.flatView) this.data.views.push("flat");
212+
if (this.data.freeFlightView) this.data.views.push("free");
213+
201214
alert(this.events, `Settings for map '${this.data.id}' loaded.`, "fine");
202215
});
203216
}
@@ -472,6 +485,10 @@ export class Map {
472485
return false;
473486
}
474487

488+
hasView(view) {
489+
return this.data.views.some(v => v === view)
490+
}
491+
475492
dispose() {
476493
this.unload();
477494
}

core/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,22 @@ public interface MapSettings extends RenderSettings {
5252

5353
float getSkyLight();
5454

55+
boolean isEnablePerspectiveView();
56+
57+
boolean isEnableFlatView();
58+
59+
boolean isEnableFreeFlightView();
60+
61+
boolean isEnableHires();
62+
63+
@Override
64+
default boolean isSaveHiresLayer() {
65+
return isEnableHires();
66+
}
67+
68+
@Override
69+
default boolean isRenderTopOnly() {
70+
return !isEnableHires() || (!isEnablePerspectiveView() && !isEnableFreeFlightView());
71+
}
72+
5573
}

0 commit comments

Comments
 (0)