Skip to content

Commit 83a0104

Browse files
committed
add panorama overlay
1 parent 0ab30b8 commit 83a0104

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

Diff for: src/js/net/minecraft/client/gui/Gui.js

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export default class Gui {
3636
stack.restore();
3737
}
3838

39+
drawGradientRect(stack, left, top, right, bottom, color1, color2) {
40+
let gradient = stack.createLinearGradient(left + (right - left) / 2, top, left + (right - left) / 2, bottom - top);
41+
gradient.addColorStop(0, color1);
42+
gradient.addColorStop(1, color2);
43+
stack.fillStyle = gradient;
44+
stack.fillRect(left, top, right - left, bottom - top);
45+
}
46+
3947
drawTexture(stack, texture, x, y, width, height, alpha = 1.0) {
4048
Gui.drawSprite(stack, texture, 0, 0, 256, 256, x, y, width, height, alpha);
4149
}

Diff for: src/js/net/minecraft/client/gui/screens/GuiMainMenu.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ export default class GuiMainMenu extends GuiScreen {
4646
let x = this.width / 2 - logoWidth / 2;
4747
let y = 30;
4848

49+
let rotationX = Math.sin((this.panoramaTimer + partialTicks) / 400.0) * 25.0 + 20.0;
50+
let rotationY = -(this.panoramaTimer + partialTicks) * 0.1;
51+
52+
// Draw panorama
53+
this.camera.aspect = this.width / this.height;
54+
this.camera.rotation.x = -MathHelper.toRadians(rotationX + 180);
55+
this.camera.rotation.y = -MathHelper.toRadians(rotationY - 180);
56+
this.camera.updateProjectionMatrix();
57+
this.minecraft.worldRenderer.webRenderer.render(this.scene, this.camera);
58+
59+
// Draw panorama overlay
60+
this.drawGradientRect(stack, 0, 0, this.width, this.height, 'rgba(255,255,255,0.5)', 'rgb(255,255,255,0)');
61+
this.drawGradientRect(stack, 0, 0, this.width, this.height, 'rgb(0,0,0,0)', 'rgb(0,0,0,0.5)');
62+
4963
// Draw logo
5064
this.drawLogo(stack, x, y);
5165

@@ -61,15 +75,6 @@ export default class GuiMainMenu extends GuiScreen {
6175

6276
// Draw splash text
6377
this.drawSplash(stack);
64-
65-
let rotationX = Math.sin((this.panoramaTimer + partialTicks) / 400.0) * 25.0 + 20.0;
66-
let rotationY = -(this.panoramaTimer + partialTicks) * 0.1;
67-
68-
this.camera.aspect = this.width / this.height;
69-
this.camera.rotation.x = -MathHelper.toRadians(rotationX + 180);
70-
this.camera.rotation.y = -MathHelper.toRadians(rotationY - 180);
71-
this.camera.updateProjectionMatrix();
72-
this.minecraft.worldRenderer.webRenderer.render(this.scene, this.camera);
7378
}
7479

7580
updateScreen() {

0 commit comments

Comments
 (0)