mirror of
https://github.com/BlueMap-Minecraft/BlueMapWeb.git
synced 2024-11-28 04:45:13 +01:00
Fix hight-map readings
This commit is contained in:
parent
bb4928c72f
commit
a9d9cb991b
@ -405,8 +405,16 @@ export class Map {
|
||||
const texture = tile.model.material.uniforms?.textureImage?.value?.image;
|
||||
if (texture == null) continue;
|
||||
|
||||
const color = getPixel(texture, x - tileX * scaledTileSize.x, z - tileZ * scaledTileSize.z + this.data.lowres.tileSize.z);
|
||||
return color[2];
|
||||
const color = getPixel(texture, x - tileX * scaledTileSize.x, z - tileZ * scaledTileSize.z + this.data.lowres.tileSize.z + 1);
|
||||
|
||||
let heightUnsigned = color[1] * 256.0 + color[2];
|
||||
if (heightUnsigned >= 32768.0) {
|
||||
return -(65535.0 - heightUnsigned);
|
||||
} else {
|
||||
return heightUnsigned;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -387,6 +387,6 @@ pixel.height = 1;
|
||||
const pixelContext = pixel.getContext('2d');
|
||||
|
||||
export const getPixel = (img, x, y) => {
|
||||
pixelContext.drawImage(img, x, y, 1, 1, 0, 0, 1, 1);
|
||||
pixelContext.drawImage(img, Math.floor(x), Math.floor(y), 1, 1, 0, 0, 1, 1);
|
||||
return pixelContext.getImageData(0, 0, 1, 1).data;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user