Release v0.1.4 with terrain rescanning and owner-published map updates
All checks were successful
Deploy MineGeo to Dokploy / deploy (push) Successful in 6m26s
All checks were successful
Deploy MineGeo to Dokploy / deploy (push) Successful in 6m26s
This commit is contained in:
@@ -4,7 +4,12 @@ import { randomUUID, createHash } from "node:crypto";
|
||||
import { mkdir, writeFile, readFile, readdir, rm } from "node:fs/promises";
|
||||
import { gunzipSync } from "node:zlib";
|
||||
import sharp from "sharp";
|
||||
import { datasetSchema, faces, type TerrainSnapshot } from "../shared/protocol";
|
||||
import {
|
||||
datasetSchema,
|
||||
faces,
|
||||
usesTerrainRenderer,
|
||||
type TerrainSnapshot,
|
||||
} from "../shared/protocol";
|
||||
import { processFabricImages } from "../lib/fabric-images";
|
||||
import { renderSnapshot } from "../renderer/render.mjs";
|
||||
import type { Database } from "../shared/database";
|
||||
@@ -151,13 +156,15 @@ async function processJob(job: {
|
||||
.single(),
|
||||
);
|
||||
const manifest = datasetSchema.parse(input.manifest);
|
||||
const fabricTerrain =
|
||||
manifest.source === "fabric" && usesTerrainRenderer(manifest);
|
||||
const assets = manifest.assets.filter(
|
||||
(a) =>
|
||||
!mapOnly ||
|
||||
a.path ===
|
||||
(manifest.mediaFormat
|
||||
? "map.webp"
|
||||
: manifest.source === "plugin"
|
||||
: manifest.source === "plugin" || fabricTerrain
|
||||
? "terrain.json.gz"
|
||||
: "map.png"),
|
||||
);
|
||||
@@ -201,7 +208,7 @@ async function processJob(job: {
|
||||
progress: (percent) =>
|
||||
progress(20 + percent * 0.7, "Validating imported map images"),
|
||||
});
|
||||
} else if (manifest.source === "plugin") {
|
||||
} else if (manifest.source === "plugin" || fabricTerrain) {
|
||||
await progress(20, "Reading the terrain snapshot");
|
||||
const compressed = await readFile(`${directory}/raw/terrain.json.gz`);
|
||||
const terrain = JSON.parse(
|
||||
@@ -250,23 +257,33 @@ async function processJob(job: {
|
||||
);
|
||||
const report = await renderSnapshot(
|
||||
terrain,
|
||||
mapOnly ? [] : (manifest.availableViewpoints ?? manifest.viewpoints),
|
||||
mapOnly || fabricTerrain
|
||||
? []
|
||||
: (manifest.availableViewpoints ?? manifest.viewpoints),
|
||||
output,
|
||||
{
|
||||
size: Number(process.env.MINEGEO_FACE_SIZE || 1024),
|
||||
minecraftVersion: manifest.minecraftVersion,
|
||||
signal: abort.signal,
|
||||
onProgress: ({ percent, message }) => progress(percent, message),
|
||||
onProgress: ({ percent, message }) =>
|
||||
progress(fabricTerrain ? 20 + percent * 0.5 : percent, message),
|
||||
},
|
||||
);
|
||||
console.log(`Rendered ${job.dataset_id}: ${JSON.stringify(report)}`);
|
||||
} else {
|
||||
await progress(25, "Compressing the captured map");
|
||||
await sharp(await readFile(`${directory}/raw/map.png`), {
|
||||
limitInputPixels: 16777216,
|
||||
})
|
||||
.webp({ lossless: true })
|
||||
.toFile(`${output}/map.webp`);
|
||||
}
|
||||
if (!manifest.mediaFormat && manifest.source === "fabric") {
|
||||
await progress(
|
||||
fabricTerrain ? 65 : 25,
|
||||
fabricTerrain
|
||||
? "Processing captured panoramas"
|
||||
: "Compressing the captured map",
|
||||
);
|
||||
if (!fabricTerrain)
|
||||
await sharp(await readFile(`${directory}/raw/map.png`), {
|
||||
limitInputPixels: 16777216,
|
||||
})
|
||||
.webp({ lossless: true })
|
||||
.toFile(`${output}/map.webp`);
|
||||
let processedFaces = 0;
|
||||
for (const point of mapOnly
|
||||
? []
|
||||
@@ -295,8 +312,8 @@ async function processJob(job: {
|
||||
.webp({ quality: 76 })
|
||||
.toFile(`${output}/${point.id}/preview.webp`);
|
||||
await progress(
|
||||
35 +
|
||||
(55 * ++processedFaces) /
|
||||
(fabricTerrain ? 65 : 35) +
|
||||
((fabricTerrain ? 25 : 55) * ++processedFaces) /
|
||||
(manifest.viewpoints.length * faces.length),
|
||||
`Compressing panorama faces ${processedFaces}/${manifest.viewpoints.length * faces.length}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user