From 59cfe1c37753aab1d85e410302a13b2ac2b98dc7 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Sat, 21 Nov 2026 22:30:57 +0900 Subject: [PATCH] =?UTF-8?q?3D=20=EB=A6=AC=ED=94=8C=EB=A0=88=EC=9D=B4=201?= =?UTF-8?q?=EC=9D=B8=EC=B9=AD=20=EC=8B=9C=EC=95=BC:=20=EC=84=B8=EB=A1=9C?= =?UTF-8?q?=2070=C2=B0=20=EA=B3=A0=EC=A0=95=20=EB=8C=80=EC=8B=A0=20?= =?UTF-8?q?=EA=B2=8C=EC=9E=84=EC=B2=98=EB=9F=BC=20=EA=B0=80=EB=A1=9C=20103?= =?UTF-8?q?=C2=B0=20(16:9=20=EA=B2=8C=EC=9E=84=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=EC=9D=84=20=EC=B0=BD=EC=97=90=20=EA=BD=89=20=EC=B0=A8=EA=B2=8C?= =?UTF-8?q?=20=EC=9E=98=EB=9D=BC=20=EB=B3=B4=EC=97=AC=20=EC=A4=8C=20?= =?UTF-8?q?=E2=80=94=20=EA=B0=80=EB=A1=9C=EB=A1=9C=20=EA=B8=B4=20=EC=B0=BD?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=95=BD=20120=C2=B0=20=EA=B9=8C=EC=A7=80?= =?UTF-8?q?=20=EB=84=93=EC=96=B4=EC=A7=80=EB=8D=98=20=EA=B2=83)=20=C2=B7?= =?UTF-8?q?=20=EC=A4=8C=EC=9D=80=20tan=20=EB=B0=B0=EC=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- site/server/test/replay-director.test.ts | 22 +++++++++++++++++++++- site/web/src/components/ReplayViewer.tsx | 4 ++-- site/web/src/lib/director.ts | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/site/server/test/replay-director.test.ts b/site/server/test/replay-director.test.ts index fea1b67..46ab911 100644 --- a/site/server/test/replay-director.test.ts +++ b/site/server/test/replay-director.test.ts @@ -4,7 +4,7 @@ import assert from 'node:assert/strict'; import type { ReplayFile } from '../../web/src/lib/replay.ts'; import { buildDirector, shotIndexAt, FIGHT_LEAD, type Shot } from '../../web/src/lib/director.ts'; import { boardAt, boardIndex, loadoutAt, sideSwaps, teamScoreAt } from '../../web/src/lib/scoreboard.ts'; -import { fitDistance } from '../../web/src/lib/director.ts'; +import { fitDistance, gameFov } from '../../web/src/lib/director.ts'; import * as THREE from '../../web/node_modules/three/build/three.module.js'; // 선수 0·1·4 아군, 2·3·5 상대. 라운드 1: 구매 0~30초, 교전 30초~, 끝 90초. 라운드 2: 100초~ (공수 교대: 시작 자리가 100m 옮겨 감) @@ -180,3 +180,23 @@ test('전략 보기 카메라: 시야각 · 화면비 · 기울기를 넣어 구 assert.ok(edge > 0.84, `너무 멀다 ${edge}`); } }); + +test('1인칭 시야: 창이 넓어도 게임처럼 가로 103° · 좁은 창은 게임 세로 시야 · 줌은 배율만큼 좁아진다', () => { + const rad = (d: number) => (d * Math.PI) / 180; + const hfov = (aspect: number, zoom = 1) => (2 * Math.atan(Math.tan(rad(gameFov(aspect, zoom) / 2)) * aspect) * 180) / Math.PI; + // 16:9 = 게임 화면 그대로 (가로 103°, 세로 약 70.5°) + assert.ok(Math.abs(hfov(16 / 9) - 103) < 1e-9); + assert.ok(Math.abs(gameFov(16 / 9) - 70.53) < 0.01); + // 가로로 긴 창 (노트북의 리플레이 창 비율 2.5 등): 가로가 103° 를 넘지 않는다 (예전엔 세로 70° 고정이라 약 120°) + for (const a of [2, 2.5, 3.2]) assert.ok(Math.abs(hfov(a) - 103) < 1e-9, `화면비 ${a}: ${hfov(a)}`); + // 좁은 창: 게임 세로 시야 그대로, 가로는 103° 보다 좁다 + for (const a of [1, 1.5]) { + assert.ok(Math.abs(gameFov(a) - gameFov(16 / 9)) < 1e-9); + assert.ok(hfov(a) < 103); + } + // 줌: 화면 가운데 물체가 배율만큼 크게 (tan 이 배율만큼 작아진다) + for (const z of [1.25, 2.5, 5]) { + const k = Math.tan(rad(gameFov(2.5) / 2)) / Math.tan(rad(gameFov(2.5, z) / 2)); + assert.ok(Math.abs(k - z) < 1e-9, `배율 ${z}: ${k}`); + } +}); diff --git a/site/web/src/components/ReplayViewer.tsx b/site/web/src/components/ReplayViewer.tsx index 7358c36..5f4b2b0 100644 --- a/site/web/src/components/ReplayViewer.tsx +++ b/site/web/src/components/ReplayViewer.tsx @@ -16,7 +16,7 @@ import CrosshairPanel from './CrosshairPanel'; import { buildAnimIndex, rigInput } from '../lib/replayAnim'; import { abilityLook, type AbilityLook } from '../lib/abilities'; import { loadVfxDb, vfxCoverage, VfxObject, type Place, type VfxDb } from '../lib/vfx'; -import { buildDirector, fitDistance, shotIndexAt, SHOT_LABEL } from '../lib/director'; +import { buildDirector, fitDistance, gameFov, shotIndexAt, SHOT_LABEL } from '../lib/director'; import { boardIndex } from '../lib/scoreboard'; import ReplayScoreboard from './ReplayScoreboard'; @@ -1028,7 +1028,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) { } // 1인칭 팔 · 총: 들고 있는 무기 · 꺼낸 때 · 사격 · 재장전 · 줌 · 걷기 const fp = p && !isDead(replay, selIdx, t) ? fpState(selIdx, t) : null; - const zoomFov = fp ? 70 / (fp.zoom === 0 ? 1 : fp.sniper ? (fp.zoom >= 2 ? 5 : 2.5) : 1.25) : 70; + const zoomFov = gameFov(camera.aspect, fp ? (fp.zoom === 0 ? 1 : fp.sniper ? (fp.zoom >= 2 ? 5 : 2.5) : 1.25) : 1); if (camera.fov !== zoomFov) { camera.fov = zoomFov; camera.updateProjectionMatrix(); diff --git a/site/web/src/lib/director.ts b/site/web/src/lib/director.ts index ade6518..e1b7e99 100644 --- a/site/web/src/lib/director.ts +++ b/site/web/src/lib/director.ts @@ -299,3 +299,17 @@ export function fitDistance(points: V3[], target: V3, dir: V3, fovDeg: number, a } return need; } + +/** 발로란트 시야: 16:9 화면에서 가로 103° (바꿀 수 없음) */ +export const GAME_HFOV = 103; +const GAME_TAN_H = Math.tan(((GAME_HFOV / 2) * Math.PI) / 180); + +/** + * 1인칭 세로 시야각(three.js fov). 게임 화면(16:9 · 가로 103°)을 이 창 비율에 꽉 차게 잘라 보여 준다: + * 16:9 보다 넓은 창은 가로 103° 를 지키고(위아래가 잘림), 좁은 창은 게임 세로 시야(약 70.5°)를 지킨다(양옆이 잘림). + * 그래서 어느 창에서도 게임보다 넓게 보이지 않는다. zoom 은 배율 (정조준 1.25 · 저격 2.5 · 5) + */ +export function gameFov(aspect: number, zoom = 1): number { + const tv = GAME_TAN_H / Math.max(aspect, 16 / 9) / zoom; + return (2 * Math.atan(tv) * 180) / Math.PI; +}