1

Split into layers

This commit is contained in:
Evan Pratten 2024-02-01 22:30:04 -05:00
parent 218b8a5401
commit 0356693fba
43 changed files with 70 additions and 28 deletions

@ -1,8 +1,13 @@
import re
import json
import argparse
from pathlib import Path
TILES_DIR = Path(__file__).parent / "tiles"
ap = argparse.ArgumentParser()
ap.add_argument("type", type=str, help="Type of the map", choices=["surface", "caves"])
args = ap.parse_args()
TILES_DIR = Path(__file__).parent / "tiles" / args.type
tiles = list(TILES_DIR.glob("*.png"))
TILE_PARTS_RE = re.compile(r"([\d\-]+)_([\d\-]+)_x([\d\-]+)_z([\d\-]+).png")

@ -1,30 +1,52 @@
const TILE_SIZE = 1024;
const TILES = [
{ "chunk_x": 0, "chunk_z": 4, "x": -4096, "z": -512, "image": "0_4_x-4096_z-512.png" },
{ "chunk_x": 1, "chunk_z": 1, "x": -3072, "z": -3584, "image": "1_1_x-3072_z-3584.png" },
{ "chunk_x": 1, "chunk_z": 2, "x": -3072, "z": -2560, "image": "1_2_x-3072_z-2560.png" },
{ "chunk_x": 1, "chunk_z": 3, "x": -3072, "z": -1536, "image": "1_3_x-3072_z-1536.png" },
{ "chunk_x": 1, "chunk_z": 4, "x": -3072, "z": -512, "image": "1_4_x-3072_z-512.png" },
{ "chunk_x": 2, "chunk_z": 0, "x": -2048, "z": -4608, "image": "2_0_x-2048_z-4608.png" },
{ "chunk_x": 2, "chunk_z": 1, "x": -2048, "z": -3584, "image": "2_1_x-2048_z-3584.png" },
{ "chunk_x": 2, "chunk_z": 2, "x": -2048, "z": -2560, "image": "2_2_x-2048_z-2560.png" },
{ "chunk_x": 2, "chunk_z": 3, "x": -2048, "z": -1536, "image": "2_3_x-2048_z-1536.png" },
{ "chunk_x": 2, "chunk_z": 4, "x": -2048, "z": -512, "image": "2_4_x-2048_z-512.png" },
{ "chunk_x": 2, "chunk_z": 5, "x": -2048, "z": 512, "image": "2_5_x-2048_z512.png" },
{ "chunk_x": 3, "chunk_z": 0, "x": -1024, "z": -4608, "image": "3_0_x-1024_z-4608.png" },
{ "chunk_x": 3, "chunk_z": 1, "x": -1024, "z": -3584, "image": "3_1_x-1024_z-3584.png" },
{ "chunk_x": 3, "chunk_z": 2, "x": -1024, "z": -2560, "image": "3_2_x-1024_z-2560.png" },
{ "chunk_x": 3, "chunk_z": 3, "x": -1024, "z": -1536, "image": "3_3_x-1024_z-1536.png" },
{ "chunk_x": 3, "chunk_z": 4, "x": -1024, "z": -512, "image": "3_4_x-1024_z-512.png" },
{ "chunk_x": 3, "chunk_z": 5, "x": -1024, "z": 512, "image": "3_5_x-1024_z512.png" },
{ "chunk_x": 4, "chunk_z": 2, "x": 0, "z": -2560, "image": "4_2_x0_z-2560.png" },
{ "chunk_x": 4, "chunk_z": 3, "x": 0, "z": -1536, "image": "4_3_x0_z-1536.png" },
{ "chunk_x": 4, "chunk_z": 4, "x": 0, "z": -512, "image": "4_4_x0_z-512.png" },
{ "chunk_x": 4, "chunk_z": 5, "x": 0, "z": 512, "image": "4_5_x0_z512.png" },
{ "chunk_x": 5, "chunk_z": 4, "x": 1024, "z": -512, "image": "5_4_x1024_z-512.png" },
{ "chunk_x": 5, "chunk_z": 5, "x": 1024, "z": 512, "image": "5_5_x1024_z512.png" }
]
const TILES = {
surface: [
{ "chunk_x": 0, "chunk_z": 4, "x": -4096, "z": -512, "image": "0_4_x-4096_z-512.png" },
{ "chunk_x": 1, "chunk_z": 1, "x": -3072, "z": -3584, "image": "1_1_x-3072_z-3584.png" },
{ "chunk_x": 1, "chunk_z": 2, "x": -3072, "z": -2560, "image": "1_2_x-3072_z-2560.png" },
{ "chunk_x": 1, "chunk_z": 3, "x": -3072, "z": -1536, "image": "1_3_x-3072_z-1536.png" },
{ "chunk_x": 1, "chunk_z": 4, "x": -3072, "z": -512, "image": "1_4_x-3072_z-512.png" },
{ "chunk_x": 2, "chunk_z": 0, "x": -2048, "z": -4608, "image": "2_0_x-2048_z-4608.png" },
{ "chunk_x": 2, "chunk_z": 1, "x": -2048, "z": -3584, "image": "2_1_x-2048_z-3584.png" },
{ "chunk_x": 2, "chunk_z": 2, "x": -2048, "z": -2560, "image": "2_2_x-2048_z-2560.png" },
{ "chunk_x": 2, "chunk_z": 3, "x": -2048, "z": -1536, "image": "2_3_x-2048_z-1536.png" },
{ "chunk_x": 2, "chunk_z": 4, "x": -2048, "z": -512, "image": "2_4_x-2048_z-512.png" },
{ "chunk_x": 2, "chunk_z": 5, "x": -2048, "z": 512, "image": "2_5_x-2048_z512.png" },
{ "chunk_x": 3, "chunk_z": 0, "x": -1024, "z": -4608, "image": "3_0_x-1024_z-4608.png" },
{ "chunk_x": 3, "chunk_z": 1, "x": -1024, "z": -3584, "image": "3_1_x-1024_z-3584.png" },
{ "chunk_x": 3, "chunk_z": 2, "x": -1024, "z": -2560, "image": "3_2_x-1024_z-2560.png" },
{ "chunk_x": 3, "chunk_z": 3, "x": -1024, "z": -1536, "image": "3_3_x-1024_z-1536.png" },
{ "chunk_x": 3, "chunk_z": 4, "x": -1024, "z": -512, "image": "3_4_x-1024_z-512.png" },
{ "chunk_x": 3, "chunk_z": 5, "x": -1024, "z": 512, "image": "3_5_x-1024_z512.png" },
{ "chunk_x": 4, "chunk_z": 2, "x": 0, "z": -2560, "image": "4_2_x0_z-2560.png" },
{ "chunk_x": 4, "chunk_z": 3, "x": 0, "z": -1536, "image": "4_3_x0_z-1536.png" },
{ "chunk_x": 4, "chunk_z": 4, "x": 0, "z": -512, "image": "4_4_x0_z-512.png" },
{ "chunk_x": 4, "chunk_z": 5, "x": 0, "z": 512, "image": "4_5_x0_z512.png" },
{ "chunk_x": 5, "chunk_z": 4, "x": 1024, "z": -512, "image": "5_4_x1024_z-512.png" },
{ "chunk_x": 5, "chunk_z": 5, "x": 1024, "z": 512, "image": "5_5_x1024_z512.png" }
],
caves: [
{ "chunk_x": 0, "chunk_z": 1, "x": -2560, "z": -3584, "image": "0_1_x-2560_z-3584.png" },
{ "chunk_x": 0, "chunk_z": 2, "x": -2560, "z": -2560, "image": "0_2_x-2560_z-2560.png" },
{ "chunk_x": 0, "chunk_z": 3, "x": -2560, "z": -1536, "image": "0_3_x-2560_z-1536.png" },
{ "chunk_x": 0, "chunk_z": 4, "x": -2560, "z": -512, "image": "0_4_x-2560_z-512.png" },
{ "chunk_x": 0, "chunk_z": 5, "x": -2560, "z": 512, "image": "0_5_x-2560_z512.png" },
{ "chunk_x": 1, "chunk_z": 0, "x": -1536, "z": -4608, "image": "1_0_x-1536_z-4608.png" },
{ "chunk_x": 1, "chunk_z": 1, "x": -1536, "z": -3584, "image": "1_1_x-1536_z-3584.png" },
{ "chunk_x": 1, "chunk_z": 2, "x": -1536, "z": -2560, "image": "1_2_x-1536_z-2560.png" },
{ "chunk_x": 1, "chunk_z": 3, "x": -1536, "z": -1536, "image": "1_3_x-1536_z-1536.png" },
{ "chunk_x": 1, "chunk_z": 4, "x": -1536, "z": -512, "image": "1_4_x-1536_z-512.png" },
{ "chunk_x": 1, "chunk_z": 5, "x": -1536, "z": 512, "image": "1_5_x-1536_z512.png" },
{ "chunk_x": 2, "chunk_z": 1, "x": -512, "z": -3584, "image": "2_1_x-512_z-3584.png" },
{ "chunk_x": 2, "chunk_z": 2, "x": -512, "z": -2560, "image": "2_2_x-512_z-2560.png" },
{ "chunk_x": 2, "chunk_z": 3, "x": -512, "z": -1536, "image": "2_3_x-512_z-1536.png" },
{ "chunk_x": 2, "chunk_z": 4, "x": -512, "z": -512, "image": "2_4_x-512_z-512.png" },
{ "chunk_x": 2, "chunk_z": 5, "x": -512, "z": 512, "image": "2_5_x-512_z512.png" },
{ "chunk_x": 3, "chunk_z": 4, "x": 512, "z": -512, "image": "3_4_x512_z-512.png" },
{ "chunk_x": 3, "chunk_z": 5, "x": 512, "z": 512, "image": "3_5_x512_z512.png" }
]
}
// Set up the map
var map = L.map('map', {
@ -34,12 +56,27 @@ var map = L.map('map', {
backgroundColor: '#000000',
});
// Create the tile layers
var caves = L.layerGroup();
var surface = L.layerGroup().addTo(map);
// Add each tile to the map
TILES.forEach(tile => {
TILES.surface.forEach(tile => {
var bounds = [[tile.z * -1, tile.x], [(tile.z + TILE_SIZE) * -1, tile.x + TILE_SIZE]];
var image = L.imageOverlay(`/map-data/minecraft/mc-sdf-org/tiles/${tile.image}`, bounds).addTo(map);
var image = L.imageOverlay(`/map-data/minecraft/mc-sdf-org/tiles/surface/${tile.image}`, bounds).addTo(surface);
});
TILES.caves.forEach(tile => {
var bounds = [[tile.z * -1, tile.x], [(tile.z + TILE_SIZE) * -1, tile.x + TILE_SIZE]];
var image = L.imageOverlay(`/map-data/minecraft/mc-sdf-org/tiles/caves/${tile.image}`, bounds).addTo(caves);
});
// Ad a layer selector
L.control.layers({
"Caves": caves,
"Surface": surface,
}).addTo(map);
map.fitBounds([
[-1024, -1024],
[1024, 1024]

Binary file not shown.

After

(image error) Size: 7.2 KiB

Binary file not shown.

After

(image error) Size: 185 KiB

Binary file not shown.

After

(image error) Size: 302 KiB

Binary file not shown.

After

(image error) Size: 175 KiB

Binary file not shown.

After

(image error) Size: 80 KiB

Binary file not shown.

After

(image error) Size: 81 KiB

Binary file not shown.

After

(image error) Size: 56 KiB

Binary file not shown.

After

(image error) Size: 469 KiB

Binary file not shown.

After

(image error) Size: 421 KiB

Binary file not shown.

After

(image error) Size: 828 KiB

Binary file not shown.

After

(image error) Size: 211 KiB

Binary file not shown.

After

(image error) Size: 9.2 KiB

Binary file not shown.

After

(image error) Size: 426 KiB

Binary file not shown.

After

(image error) Size: 597 KiB

Binary file not shown.

After

(image error) Size: 970 KiB

Binary file not shown.

After

(image error) Size: 266 KiB

Binary file not shown.

After

(image error) Size: 23 KiB

Binary file not shown.

After

(image error) Size: 139 KiB