mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
viewer: sort signs at the same x/z coordinates from top to bottom
This commit is contained in:
parent
31de0dc0bd
commit
76df56c9ce
1 changed files with 13 additions and 9 deletions
|
@ -279,26 +279,30 @@ function loadSigns(signLayer) {
|
||||||
for (const sign of res.signs) {
|
for (const sign of res.signs) {
|
||||||
const key = `${sign.x},${sign.z}`;
|
const key = `${sign.x},${sign.z}`;
|
||||||
const group = groups[key] ??= [];
|
const group = groups[key] ??= [];
|
||||||
group[sign.y] = sign;
|
group.push(sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [key, group] of Object.entries(groups)) {
|
for (const [key, group] of Object.entries(groups)) {
|
||||||
const popup = document.createElement('div');
|
const popup = document.createElement('div');
|
||||||
|
|
||||||
let material = 'oak'; /* Default material */
|
let material;
|
||||||
let kind = 'sign';
|
let kind;
|
||||||
|
|
||||||
group.forEach((sign) => {
|
// Sort from top to bottom
|
||||||
|
group.sort((a, b) => b.y - a.y);
|
||||||
|
|
||||||
|
for (const sign of group) {
|
||||||
popup.appendChild(createSign(sign, false));
|
popup.appendChild(createSign(sign, false));
|
||||||
|
|
||||||
if (sign.back_text)
|
if (sign.back_text)
|
||||||
popup.appendChild(createSign(sign, true));
|
popup.appendChild(createSign(sign, true));
|
||||||
|
|
||||||
if (sign.material)
|
material ??= sign.material;
|
||||||
material = sign.material;
|
kind ??= sign.kind;
|
||||||
if (sign.kind)
|
}
|
||||||
kind = sign.kind;
|
|
||||||
});
|
// Default material
|
||||||
|
material ??= 'oak';
|
||||||
|
|
||||||
const [x, z] = key.split(',').map((i) => +i);
|
const [x, z] = key.split(',').map((i) => +i);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue