improve performance on high resolution monitor, fix main menu blur on safari, version 1.1.1

This commit is contained in:
LabyStudio
2022-06-17 07:11:50 +02:00
parent 410346427f
commit daf317291d
3 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ import UUID from "../util/UUID.js";
export default class Minecraft {
static VERSION = "1.1.0"
static VERSION = "1.1.1"
static URL_GITHUB = "https://github.com/labystudio/js-minecraft";
static PROTOCOL_VERSION = 758;
@@ -159,11 +159,15 @@ export default class GuiMainMenu extends GuiScreen {
this.camera.rotation.order = 'ZYX';
// Apply blur
this.minecraft.window.canvas2d.style.backdropFilter = "blur(10px)";
let style = this.minecraft.window.canvas2d.style;
style.backdropFilter = "blur(10px)";
style.webkitBackdropFilter = "blur(10px)";
}
onClose() {
// Remove blur
this.minecraft.window.canvas2d.style.backdropFilter = "";
let style = this.minecraft.window.canvas2d.style;
style.backdropFilter = "";
style.webkitBackdropFilter = "";
}
}
@@ -1,5 +1,7 @@
export default class ScreenRenderer {
static UPSCALE = 3;
constructor(minecraft, window) {
this.minecraft = minecraft;
this.window = window;
@@ -9,8 +11,8 @@ export default class ScreenRenderer {
this.resolution = this.minecraft.isInGame() ? 1 : this.minecraft.window.scaleFactor; // Increase resolution for the splash text
// Update camera size
this.window.canvas2d.width = this.window.width * this.resolution;
this.window.canvas2d.height = this.window.height * this.resolution;
this.window.canvas2d.width = this.window.width * ScreenRenderer.UPSCALE;
this.window.canvas2d.height = this.window.height * ScreenRenderer.UPSCALE;
// Get context stack of 2d canvas
this.stack2d = this.window.canvas2d.getContext('2d');
@@ -24,7 +26,7 @@ export default class ScreenRenderer {
let mouseY = this.minecraft.window.mouseY;
this.stack2d.save();
this.stack2d.scale(this.resolution, this.resolution, this.resolution);
this.stack2d.scale(ScreenRenderer.UPSCALE, ScreenRenderer.UPSCALE, ScreenRenderer.UPSCALE);
// Reset 2d canvas
this.stack2d.clearRect(0, 0, this.window.width, this.window.height);