발로란트 맵 3D: 모든 맵을 Riot CDN 에서 바로 추출해 3D 리플레이에 붙임 · 매핑 업데이트 자동 적용

- tools/map-extract (C#, CUE4Parse 고정 커밋): 게임 파일을 받지 않고 매니페스트 조각만 HTTP Range 로 읽어
  맵 22개(일반 13 · 팀 데스매치 5 · 스커미시 3 · 어빌리티 드래프트)를 월드 좌표 glb 로. 3.1분 · 587MB 받음
- scripts/pack.py (gltfpack -cc + gzip, 맵당 0.5~4.6MB) · update.sh (uedb 매핑 · 라이브 패치 확인 → 매핑 보관 →
  추출 → .5 data/maps3d 반영) · install.sh (systemd 사용자 타이머 30분, 메모리 6GB 상한)
- 사이트 서버: GET /site/maps3d* (로그인 필요, gzip 그대로). CSP 에 'wasm-unsafe-eval' (meshopt 압축 풀기만)
- 3D 재생기: 맵 3D 위에 선수 표시, 천장 자르기(자동 · 없음 · 직접), 높이 색칠. 맵이 없거나 실패하면 미니맵
- 리플레이 칸: 리플레이를 아직 안 보내는 앱 버전이면 그렇게 안내
- 테스트: maps3d.test.ts 2개, CSP 테스트 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-17 14:01:22 +09:00
parent 86f422e8f0
commit 0c1e726168
23 changed files with 1350 additions and 9 deletions

View File

@@ -25,7 +25,9 @@ export function ReplayPanel({ m }: { m: MatchDetail }) {
};
}, [open, m.id, replay]);
const sync = useMemo(() => (replay ? computeSync(m, replay) : null), [m, replay]);
const missing = err instanceof ApiError && err.status === 404;
// replay_not_found: 앱이 리플레이를 못 찾음. 다른 404: 이 앱 버전에는 리플레이 기능이 아직 없음
const missing = err instanceof ApiError && err.status === 404 && err.code === 'replay_not_found';
const appTooOld = err instanceof ApiError && err.status === 404 && err.code === 'Not Found'; // Fastify 기본 404 (경로 없음)
return (
<Panel
className={`replay-panel${open ? ' open' : ''}`}
@@ -44,6 +46,8 @@ export function ReplayPanel({ m }: { m: MatchDetail }) {
<div className="dim small">
이 경기 리플레이가 아직 없습니다. 발로란트 경력 탭에서 이 경기의 리플레이를 내려받으면 게임 PC 앱이 찾아서 변환합니다 (몇 초 걸림).
</div>
) : appTooOld ? (
<div className="dim small">지금 게임 PC 앱 버전은 아직 리플레이를 보내지 않습니다. 리플레이 자동 변환이 들어간 앱으로 업데이트하면 볼 수 있습니다.</div>
) : err ? (
<div className="dim small">리플레이를 불러오지 못했습니다: {err instanceof Error ? err.message : String(err)}</div>
) : !replay || !sync ? (

View File

@@ -7,10 +7,12 @@ import { settings, useSettings } from '../store/settings';
import { useData } from '../store/app';
import { fmtClock } from '../lib/format';
import { isDead, roundAt, samplePlayer, type ReplayFile, type ReplaySync } from '../lib/replay';
import { findMap3d, loadMap3d, mapMaterial, worldMatrix } from '../lib/map3d';
/**
* 3D 리플레이 (발로란트 .vrf → tools/replay-extract → gvr-replay JSON).
* 바닥은 미니맵, 선수는 실제 높이(z)에 세운다. 맵 벽 · 지형 3D 모델은 없다.
* 맵은 게임 파일에서 뽑은 3D 모양(tools/map-extract, 사이트 서버 /site/maps3d)을 쓰고, 없으면 미니맵 바닥만 깐다.
* 위에서 내려다볼 수 있게 천장 높이 위는 잘라 낸다 (자동: 고른 선수 · 가장 높은 선수 머리 위).
* 시계는 플레이어 "현장 모드"(대화를 실제 시각대로 겹쳐 재생)와 같은 값을 쓴다:
* 기록 시각 ts = recordedAt + t + sync.offset
* 그래서 재생 · 멈춤 · 시간 옮기기 · 배속이 대화와 같이 움직인다.
@@ -21,6 +23,12 @@ const VEX = 1; // 높이 배율 (1 = 실제 비율)
const ALLY = 0x3fb6ff;
const ENEMY = 0xff4d5e;
const RATES = [0.5, 1, 1.5, 2];
/** 자동 천장: 선수(몸 중심) 위로 이만큼(cm) 남기고 자른다 */
const CEIL_ABOVE = 380;
type MapState = { state: 'none' | 'loading' | 'ready' | 'error'; progress?: number };
/** 천장 자르기: 자동 · 끔 · 직접(가장 낮은 층에서 cm) */
type Ceil = { mode: 'auto' } | { mode: 'off' } | { mode: 'manual'; cm: number };
type T4 = { xMultiplier: number; yMultiplier: number; xScalarToAdd: number; yScalarToAdd: number };
@@ -85,6 +93,12 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
selRef.current = sel;
followRef.current = follow;
const resetCam = useRef<() => void>(() => {});
const [map3d, setMap3d] = useState<MapState>({ state: 'none' });
const [ceil, setCeil] = useState<Ceil>({ mode: 'auto' });
const ceilRef = useRef(ceil);
ceilRef.current = ceil;
/** 지금 자르는 높이 (가장 낮은 층에서 cm, 화면 표시용) */
const [ceilNow, setCeilNow] = useState<number | null>(null);
// 바닥(미니맵) 높이: 선수 높이의 하위 5% (떨어져 죽은 기록은 뺀다)
const zBase = useMemo(() => {
@@ -93,6 +107,12 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
zs.sort((a, b) => a - b);
return zs.length ? zs[Math.floor(zs.length * 0.05)] : 0;
}, [replay]);
// 선수가 간 가장 높은 곳 (천장 직접 조절 범위)
const zTop = useMemo(() => {
let top = zBase;
for (const p of replay.players) for (let i = 0; i < p.track.z.length; i += 20) if (p.track.z[i] > top) top = p.track.z[i];
return top;
}, [replay, zBase]);
const T = (m.mapTransform && 'valorant' in m.mapTransform ? m.mapTransform.valorant : null) as T4 | null;
// 리플레이 선수 ↔ 경기 기록 선수 (puuid)
@@ -164,6 +184,35 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
grid.position.y = -0.05;
scene.add(grid);
// 맵 3D 모양: 받으면 미니맵 바닥 · 선수 그림자를 숨긴다. 천장 위는 잘라 낸다
renderer.localClippingEnabled = true;
const hPerCm = Math.abs(T.xMultiplier) * S * VEX;
const clip = new THREE.Plane(new THREE.Vector3(0, -1, 0), 1e6);
let clipY = 1e6;
let mapReady = false;
const mapGroup = new THREE.Group();
mapGroup.matrixAutoUpdate = false;
mapGroup.matrix.copy(worldMatrix(T, S, zBase, VEX));
scene.add(mapGroup);
let disposed = false;
setMap3d({ state: 'loading', progress: 0 });
void findMap3d(m.map.id)
.then((info) => {
if (disposed) return;
if (!info) return setMap3d({ state: 'none' });
const mat = mapMaterial(clip, { lo: 0, hi: Math.max(8, (zTop - zBase + 600) * hPerCm) });
return loadMap3d(info.url, mat, (p) => !disposed && setMap3d({ state: 'loading', progress: p })).then((obj) => {
if (disposed) return;
mapGroup.add(obj);
mapGroup.updateMatrixWorld(true);
mapReady = true;
floor.visible = false;
grid.visible = false;
setMap3d({ state: 'ready' });
});
})
.catch(() => !disposed && setMap3d({ state: 'error' }));
// 선수
const views: PlayerView[] = roster.map((r) => {
const color = r.ally ? ALLY : ENEMY;
@@ -301,7 +350,8 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
v.group.visible = v.drop.visible = v.shadow.visible = false;
continue;
}
v.group.visible = v.drop.visible = v.shadow.visible = true;
v.group.visible = true;
v.drop.visible = v.shadow.visible = !mapReady;
v.group.position.copy(toWorld(p.x, p.y, Math.max(p.z, zBase - 400), zBase));
v.shadow.position.set(v.group.position.x, 0.04, v.group.position.z);
const dp = v.drop.geometry.getAttribute('position') as THREE.BufferAttribute;
@@ -319,6 +369,19 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
v.voice.visible = speaking.has(v.idx) && !dead;
v.ring.visible = v.idx === selIdx;
}
// 천장 자르기
const cm = ceilRef.current;
let want = 1e6;
if (mapReady && cm.mode === 'manual') want = cm.cm * hPerCm;
else if (mapReady && cm.mode === 'auto') {
const sv = selIdx != null ? views[selIdx] : null;
let top = -Infinity;
if (sv?.group.visible) top = sv.group.position.y;
else for (const v of views) if (v.group.visible && !isDead(replay, v.idx, t)) top = Math.max(top, v.group.position.y);
if (top > -Infinity) want = top + CEIL_ABOVE * hPerCm;
}
clipY = clipY > 1e5 || want > 1e5 ? want : clipY + (want - clipY) * 0.12;
clip.constant = clipY;
// 경로
if (selIdx != null) {
const tr = replay.players[selIdx].track;
@@ -381,11 +444,16 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
renderer.render(scene, camera);
if (now - lastUi > 100) {
lastUi = now;
setCeilNow((c) => {
const v = clipY > 1e5 ? null : Math.round(clipY / hPerCm / 10) * 10;
return c === v ? c : v;
});
setUi((u) => (Math.abs(u.t - t) < 50 && u.playing === (inScene && ps.playing) ? u : { t, playing: inScene && ps.playing }));
}
};
raf = requestAnimationFrame(frame);
return () => {
disposed = true;
cancelAnimationFrame(raf);
ro.disconnect();
renderer.domElement.removeEventListener('pointerdown', onDown);
@@ -404,7 +472,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
renderer.domElement.remove();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [m, replay, base, roster, playerByUser, zBase]);
}, [m, replay, base, roster, playerByUser, zBase, zTop]);
const inScene = () => player.state.mode === 'scene' && player.state.scene?.label === REPLAY_SCENE_LABEL;
const seek = (t: number) => {
@@ -443,6 +511,8 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
<div className="r3d-hud tl">
<b>{rd ? `R${rd.num}` : ''}</b> <span className="mono">{clock}</span>
{mr && <span className="muted"> · {mr.score.ally}:{mr.score.enemy} 후 {mr.win ? '승리' : '패배'}</span>}
{map3d.state === 'loading' && <div className="muted small">맵 3D 불러오는 중 {Math.round((map3d.progress ?? 0) * 100)}%</div>}
{map3d.state === 'error' && <div className="muted small">맵 3D 를 불러오지 못해 미니맵으로 보여 줍니다</div>}
</div>
<div className="r3d-hud tr">
{feed.map(([kt, ki, vi]) => (
@@ -485,6 +555,26 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
<button className="chip mono" onClick={() => settings.set({ rate: RATES[(RATES.indexOf(cfg.rate) + 1) % RATES.length] ?? 1 })} title="재생 속도">
{cfg.rate}x
</button>
{map3d.state === 'ready' && (
<span className="r3d-ceil" title="위에서 보이게 이 높이 위(지붕 · 위층)는 잘라 냅니다">
<button
className={`chip${ceil.mode === 'auto' ? ' on' : ''}`}
onClick={() => setCeil((c) => (c.mode === 'auto' ? { mode: 'off' } : { mode: 'auto' }))}
title="자동: 고른 선수(없으면 가장 높은 선수) 머리 위까지 보이게"
>
천장 {ceil.mode === 'auto' ? '자동' : ceil.mode === 'off' ? '없음' : `${Math.round(ceil.cm / 100)}m`}
</button>
<input
type="range"
min={0}
max={Math.round(zTop - zBase + 800)}
step={50}
value={ceil.mode === 'manual' ? ceil.cm : ceilNow ?? Math.round(zTop - zBase + 800)}
onChange={(e) => setCeil({ mode: 'manual', cm: Number(e.target.value) })}
aria-label="천장 높이"
/>
</span>
)}
<button className="chip" onClick={() => resetCam.current()} title="카메라 처음 위치로">전체 보기</button>
</div>
<div className="r3d-foot muted">