diff --git a/src/controls.ts b/src/controls.ts index f940d59d..a3a22029 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -651,6 +651,24 @@ window.addEventListener('keydown', (e) => { } }) +window.addEventListener('keydown', (e) => { + if (e.code !== 'F2' || e.repeat || !isGameActive(true)) return + e.preventDefault() + const canvas = document.getElementById('viewer-canvas') as HTMLCanvasElement + if (!canvas) return + const link = document.createElement('a') + link.href = canvas.toDataURL('image/png') + const date = new Date() + link.download = `screenshot ${date.toLocaleString().replaceAll('.', '-').replace(',', '')}.png` + link.click() +}) + +window.addEventListener('keydown', (e) => { + if (e.code !== 'F1' || e.repeat || !isGameActive(true)) return + e.preventDefault() + miscUiState.showUI = !miscUiState.showUI +}) + // #region experimental debug things window.addEventListener('keydown', (e) => { if (e.code === 'F11') { diff --git a/src/globalState.ts b/src/globalState.ts index 4b62f8d6..b7dc1602 100644 --- a/src/globalState.ts +++ b/src/globalState.ts @@ -138,6 +138,7 @@ export const miscUiState = proxy({ wanOpened: false, /** wether game hud is shown (in playing state) */ gameLoaded: false, + showUI: true, loadedServerIndex: '', /** currently trying to load or loaded mc version, after all data is loaded */ loadedDataVersion: null as string | null, diff --git a/src/index.ts b/src/index.ts index 89baaa10..d02f7b92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -108,6 +108,8 @@ let renderer: THREE.WebGLRenderer try { renderer = new THREE.WebGLRenderer({ powerPreference: options.gpuPreference, + preserveDrawingBuffer: true, + logarithmicDepthBuffer: true, }) } catch (err) { console.error(err) diff --git a/src/reactUi.tsx b/src/reactUi.tsx index d86cf202..497f091f 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -143,6 +143,8 @@ const WidgetDisplay = ({ name, Component }) => { } const App = () => { + const { showUI } = useSnapshot(miscUiState) + return
@@ -154,7 +156,7 @@ const App = () => {
- + {showUI && }