Skip to content

Commit

Permalink
Add setting for a default sky-light per map
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Nov 12, 2024
1 parent 8b1c5ab commit f08c794
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions common/webapp/src/js/MapViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions common/webapp/src/js/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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 = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ public interface MapSettings extends RenderSettings {

int getLodFactor();

float getSkyLight();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f08c794

Please sign in to comment.