3D 리플레이 1인칭 시야: 세로 70° 고정 대신 게임처럼 가로 103° (16:9 게임 화면을 창에 꽉 차게 잘라 보여 줌 — 가로로 긴 창에서 약 120° 까지 넓어지던 것) · 줌은 tan 배율
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user