diff --git a/frontend/src/utils/gameView.test.ts b/frontend/src/utils/gameView.test.ts index 09f06c3..b218a9c 100644 --- a/frontend/src/utils/gameView.test.ts +++ b/frontend/src/utils/gameView.test.ts @@ -31,20 +31,20 @@ describe('gameViewGeometry', () => { ]) }) - it('uses the tablet camera zoom levels around the crop center', () => { + it('keeps 0.5x full-frame while higher zoom levels crop around the center', () => { const wideGeometry = gameViewGeometry(1920, 1080, 540, 720, 0.5) expect(Array.from(wideGeometry.textureCoordinates)).toEqual([ - expect.closeTo(0.08, 2), + expect.closeTo(0.29, 2), 0, - expect.closeTo(0.92, 2), + expect.closeTo(0.71, 2), 0, - expect.closeTo(0.08, 2), + expect.closeTo(0.29, 2), 1, - expect.closeTo(0.92, 2), + expect.closeTo(0.71, 2), 1, ]) expect(Array.from(wideGeometry.positions)).toEqual([ - -1, -0.5, 1, -0.5, -1, 0.5, 1, 0.5, + -1, -1, 1, -1, -1, 1, 1, 1, ]) const zoomedGeometry = gameViewGeometry(1920, 1080, 540, 720, 2) diff --git a/frontend/src/utils/gameView.ts b/frontend/src/utils/gameView.ts index b23e492..9dd0ef1 100644 --- a/frontend/src/utils/gameView.ts +++ b/frontend/src/utils/gameView.ts @@ -58,9 +58,7 @@ export function gameViewGeometry( bottom = 1 - top } - const baseWidth = right - left - const baseHeight = bottom - top - const normalizedZoom = Math.min(3, Math.max(0.5, zoom)) + const normalizedZoom = Math.min(3, Math.max(1, zoom)) const centerX = (left + right) / 2 const centerY = (top + bottom) / 2 left = Math.max(0, centerX + (left - centerX) / normalizedZoom) @@ -68,26 +66,8 @@ export function gameViewGeometry( top = Math.max(0, centerY + (top - centerY) / normalizedZoom) bottom = Math.min(1, centerY + (bottom - centerY) / normalizedZoom) - const positionScaleX = Math.min( - 1, - (normalizedZoom * (right - left)) / baseWidth, - ) - const positionScaleY = Math.min( - 1, - (normalizedZoom * (bottom - top)) / baseHeight, - ) - return { - positions: new Float32Array([ - -positionScaleX, - -positionScaleY, - positionScaleX, - -positionScaleY, - -positionScaleX, - positionScaleY, - positionScaleX, - positionScaleY, - ]), + positions: new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), textureCoordinates: new Float32Array([ left, top, diff --git a/frontend/src/views/apps/CameraApp.vue b/frontend/src/views/apps/CameraApp.vue index 7fa7fd8..dce9f32 100644 --- a/frontend/src/views/apps/CameraApp.vue +++ b/frontend/src/views/apps/CameraApp.vue @@ -232,6 +232,7 @@ function setZoom(zoom: (typeof zoomLevels)[number]): void { selectedZoom.value = zoom resizeGameView() window.postMessage({ data: { zoom }, type: 'camera:zoom' }, '*') + void nuiCall('camera:setZoom', { zoom }) } function resizeGameView(entry?: ResizeObserverEntry): void { @@ -392,7 +393,7 @@ onBeforeUnmount(() => {