Initial commit

This commit is contained in:
Dominic Zimmer
2020-04-16 14:40:46 +02:00
commit 85d23c8c95
6 changed files with 206 additions and 0 deletions

BIN
static/empty.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

41
static/index.html Normal file
View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<title>leafblade Minecraft Server</title>
<meta charset="UTF-8" />
<style type="text/css">
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
}
@media (max-width:768px) {
#overlay { width: 100% }
}
</style>
<script type="text/javascript">
</script>
</head>
<body>
<div id="container"></div>
this is the base site
</div>
</body>
</html>

41
static/ui.html Normal file
View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<title>leafblade Minecraft Server</title>
<meta charset="UTF-8" />
<style type="text/css">
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
}
@media (max-width:768px) {
#overlay { width: 100% }
}
</style>
<script type="text/javascript">
</script>
</head>
<body>
<div id="container"></div>
this is the UI
</div>
</body>
</html>

View File

@@ -0,0 +1,75 @@
function Unmined() {
this.map = function (mapId, options, regions) {
const minMapX = options.minRegionX * 512,
minMapY = options.minRegionZ * 512,
mapWidth = (options.maxRegionX + 1 - options.minRegionX) * 512,
mapHeight = (options.maxRegionZ + 1 - options.minRegionZ) * 512,
zoomOffset = 0 - options.minZoom,
unminedLayer = new L.TileLayer.Functional(
function (view) {
const zoom = view.zoom - zoomOffset,
zoomFactor = Math.pow(2, zoom),
tileSize = 256,
minTileX = Math.floor(minMapX * zoomFactor / tileSize),
minTileY = Math.floor(minMapY * zoomFactor / tileSize),
maxTileX = Math.ceil((minMapX + mapWidth) * zoomFactor / tileSize) - 1,
maxTileY = Math.ceil((minMapY + mapHeight) * zoomFactor / tileSize) - 1,
tileX = view.tile.column,
tileY = view.tile.row,
tileBlockSize = tileSize / zoomFactor,
tileBlockPoint = {
x: tileX * tileBlockSize,
z: tileY * tileBlockSize
};
const intersectsWithTile = function (region) {
return (tileBlockPoint.x < (region.x + 1) * 512)
&& (tileBlockPoint.x + tileBlockSize > region.x * 512)
&& (tileBlockPoint.z < (region.z + 1) * 512)
&& (tileBlockPoint.z + tileBlockSize > region.z * 512);
};
if (tileX >= minTileX
&& tileY >= minTileY
&& tileX <= maxTileX
&& tileY <= maxTileY
&& ((regions === undefined) || regions.some(intersectsWithTile))) {
return ('/static/unmined/tiles/zoom.{z}/{xd}/{yd}/tile.{x}.{y}.' + options.imageFormat)
.replace('{z}', zoom)
.replace('{yd}', '' + Math.floor(tileY / 10))
.replace('{xd}', '' + Math.floor(tileX / 10))
.replace('{y}', view.tile.row)
.replace('{x}', view.tile.column);
} else {
return "/static/empty.jpg";
}
},
{
detectRetina: false,
bounds: [[minMapX, minMapY], [minMapX + mapWidth, minMapY + mapHeight]]
});
let map = L.map(mapId, {
crs: L.CRS.Simple,
minZoom: options.minZoom + zoomOffset,
maxZoom: options.maxZoom + zoomOffset,
layers: [unminedLayer],
maxBoundsViscosity: 1.0
}).setView([0, 0], options.defaultZoom + zoomOffset);
let northWest = map.unproject([minMapX, minMapY], map.getMaxZoom());
let southEast = map.unproject([minMapX + mapWidth, minMapY + mapHeight], map.getMaxZoom());
map.setMaxBounds(new L.LatLngBounds(northWest, southEast));
return map;
}
}