mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-03 14:19:07 +02:00
core, viewer: add support for WebP output
WebP can be selected by passing `--image-format webp` on the command line. For typical Minecraft worlds, this results in a size reduction of 10-15% without increasing processing time.
This commit is contained in:
parent
bb11b29e92
commit
c23b53a8c3
11 changed files with 81 additions and 11 deletions
|
@ -73,7 +73,7 @@ function signIcon(material, kind) {
|
|||
}
|
||||
|
||||
const MinedMapLayer = L.TileLayer.extend({
|
||||
initialize: function (mipmaps, layer) {
|
||||
initialize: function (mipmaps, layer, tile_extension) {
|
||||
L.TileLayer.prototype.initialize.call(this, '', {
|
||||
detectRetina: true,
|
||||
tileSize: 512,
|
||||
|
@ -88,6 +88,7 @@ const MinedMapLayer = L.TileLayer.extend({
|
|||
|
||||
this.mipmaps = mipmaps;
|
||||
this.layer = layer;
|
||||
this.ext = tile_extension;
|
||||
},
|
||||
|
||||
createTile: function (coords, done) {
|
||||
|
@ -112,7 +113,7 @@ const MinedMapLayer = L.TileLayer.extend({
|
|||
return L.Util.emptyImageUrl;
|
||||
|
||||
|
||||
return 'data/'+this.layer+'/'+z+'/r.'+coords.x+'.'+coords.y+'.png';
|
||||
return `data/${this.layer}/${z}/r.${coords.x}.${coords.y}.${this.ext}`;
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -332,6 +333,7 @@ window.createMap = function () {
|
|||
const res = await response.json();
|
||||
const {mipmaps, spawn} = res;
|
||||
const features = res.features || {};
|
||||
const tile_extension = res.tile_extension || 'png';
|
||||
|
||||
const updateParams = function () {
|
||||
const args = parseHash();
|
||||
|
@ -369,10 +371,10 @@ window.createMap = function () {
|
|||
|
||||
const overlayMaps = {};
|
||||
|
||||
const mapLayer = new MinedMapLayer(mipmaps, 'map');
|
||||
const mapLayer = new MinedMapLayer(mipmaps, 'map', tile_extension);
|
||||
mapLayer.addTo(map);
|
||||
|
||||
const lightLayer = new MinedMapLayer(mipmaps, 'light');
|
||||
const lightLayer = new MinedMapLayer(mipmaps, 'light', tile_extension);
|
||||
overlayMaps['Illumination'] = lightLayer;
|
||||
if (params.light)
|
||||
map.addLayer(lightLayer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue