From f08c7946a03fd99fecf19536010b0ef6b8e18818 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Tue, 12 Nov 2024 20:59:26 +0100 Subject: [PATCH] Add setting for a default sky-light per map --- .../de/bluecolored/bluemap/common/config/MapConfig.java | 1 + .../resources/de/bluecolored/bluemap/config/maps/map.conf | 6 ++++++ common/webapp/src/js/MapViewer.js | 1 + common/webapp/src/js/map/Map.js | 2 ++ .../java/de/bluecolored/bluemap/core/map/MapSettings.java | 2 ++ .../bluecolored/bluemap/core/map/MapSettingsSerializer.java | 3 ++- 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java b/common/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java index 4463d4b2..7497c641 100644 --- a/common/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java +++ b/common/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java @@ -54,6 +54,7 @@ public class MapConfig implements MapSettings { private String voidColor = "#000000"; private float ambientLight = 0; + private float skyLight = 1; private int removeCavesBelowY = 55; private int caveDetectionOceanFloor = 10000; diff --git a/common/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf b/common/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf index 993eac9e..176fd79e 100644 --- a/common/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf +++ b/common/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf @@ -38,6 +38,12 @@ sky-color: "${sky-color}" # Default is "#000000" void-color: "${void-color}" +# Defines the initial sky-light-strength the map will be set to when it is opened. +# 0 is no sky-light, 1 is fully lighted. +# You can change this at any time. +# Default is 1 +sky-light: 1 + # Defines the ambient light-strength that every block is receiving, regardless of the sunlight/blocklight. # 0 is no ambient light, 1 is fully lighted. # You can change this at any time. diff --git a/common/webapp/src/js/MapViewer.js b/common/webapp/src/js/MapViewer.js index 868b4563..db2e6fe7 100644 --- a/common/webapp/src/js/MapViewer.js +++ b/common/webapp/src/js/MapViewer.js @@ -413,6 +413,7 @@ export class MapViewer { this.data.uniforms.skyColor.value = map.data.skyColor; this.data.uniforms.voidColor.value = map.data.voidColor; this.data.uniforms.ambientLight.value = map.data.ambientLight; + this.data.uniforms.sunlightStrength.value = map.data.skyLight; this.data.uniforms.hiresTileMap.value.map = map.hiresTileManager.tileMap.texture; this.data.uniforms.hiresTileMap.value.scale.set(map.data.hires.tileSize.x, map.data.hires.tileSize.z); this.data.uniforms.hiresTileMap.value.translate.set(map.data.hires.translate.x, map.data.hires.translate.z); diff --git a/common/webapp/src/js/map/Map.js b/common/webapp/src/js/map/Map.js index 7aa48b26..33ab9d49 100644 --- a/common/webapp/src/js/map/Map.js +++ b/common/webapp/src/js/map/Map.js @@ -68,6 +68,7 @@ export class Map { skyColor: new Color(), voidColor: new Color(0, 0, 0), ambientLight: 0, + skyLight: 1, hires: { tileSize: {x: 32, z: 32}, scale: {x: 1, z: 1}, @@ -181,6 +182,7 @@ export class Map { } this.data.ambientLight = worldSettings.ambientLight ? worldSettings.ambientLight : this.data.ambientLight; + this.data.skyLight = worldSettings.skyLight ? worldSettings.skyLight : this.data.skyLight; if (worldSettings.hires === undefined) worldSettings.hires = {}; if (worldSettings.lowres === undefined) worldSettings.lowres = {}; diff --git a/core/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java b/core/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java index bc76e7ff..ca41539e 100644 --- a/core/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java +++ b/core/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java @@ -50,4 +50,6 @@ public interface MapSettings extends RenderSettings { int getLodFactor(); + float getSkyLight(); + } diff --git a/core/src/main/java/de/bluecolored/bluemap/core/map/MapSettingsSerializer.java b/core/src/main/java/de/bluecolored/bluemap/core/map/MapSettingsSerializer.java index 630d5134..edecd22e 100644 --- a/core/src/main/java/de/bluecolored/bluemap/core/map/MapSettingsSerializer.java +++ b/core/src/main/java/de/bluecolored/bluemap/core/map/MapSettingsSerializer.java @@ -79,8 +79,9 @@ public JsonElement serialize(BmMap map, Type typeOfSrc, JsonSerializationContext Color voidColor = new Color().parse(map.getMapSettings().getVoidColor()); root.add("voidColor", context.serialize(voidColor)); - // ambientLight + // light root.addProperty("ambientLight", map.getMapSettings().getAmbientLight()); + root.addProperty("skyLight", map.getMapSettings().getSkyLight()); return root; }