add panorama overlay

This commit is contained in:
LabyStudio
2022-05-13 09:27:57 +02:00
parent 0ab30b867d
commit 83a01043c2
2 changed files with 22 additions and 9 deletions
+8
View File
@@ -36,6 +36,14 @@ export default class Gui {
stack.restore();
}
drawGradientRect(stack, left, top, right, bottom, color1, color2) {
let gradient = stack.createLinearGradient(left + (right - left) / 2, top, left + (right - left) / 2, bottom - top);
gradient.addColorStop(0, color1);
gradient.addColorStop(1, color2);
stack.fillStyle = gradient;
stack.fillRect(left, top, right - left, bottom - top);
}
drawTexture(stack, texture, x, y, width, height, alpha = 1.0) {
Gui.drawSprite(stack, texture, 0, 0, 256, 256, x, y, width, height, alpha);
}
@@ -46,6 +46,20 @@ export default class GuiMainMenu extends GuiScreen {
let x = this.width / 2 - logoWidth / 2;
let y = 30;
let rotationX = Math.sin((this.panoramaTimer + partialTicks) / 400.0) * 25.0 + 20.0;
let rotationY = -(this.panoramaTimer + partialTicks) * 0.1;
// Draw panorama
this.camera.aspect = this.width / this.height;
this.camera.rotation.x = -MathHelper.toRadians(rotationX + 180);
this.camera.rotation.y = -MathHelper.toRadians(rotationY - 180);
this.camera.updateProjectionMatrix();
this.minecraft.worldRenderer.webRenderer.render(this.scene, this.camera);
// Draw panorama overlay
this.drawGradientRect(stack, 0, 0, this.width, this.height, 'rgba(255,255,255,0.5)', 'rgb(255,255,255,0)');
this.drawGradientRect(stack, 0, 0, this.width, this.height, 'rgb(0,0,0,0)', 'rgb(0,0,0,0.5)');
// Draw logo
this.drawLogo(stack, x, y);
@@ -61,15 +75,6 @@ export default class GuiMainMenu extends GuiScreen {
// Draw splash text
this.drawSplash(stack);
let rotationX = Math.sin((this.panoramaTimer + partialTicks) / 400.0) * 25.0 + 20.0;
let rotationY = -(this.panoramaTimer + partialTicks) * 0.1;
this.camera.aspect = this.width / this.height;
this.camera.rotation.x = -MathHelper.toRadians(rotationX + 180);
this.camera.rotation.y = -MathHelper.toRadians(rotationY - 180);
this.camera.updateProjectionMatrix();
this.minecraft.worldRenderer.webRenderer.render(this.scene, this.camera);
}
updateScreen() {