3D 리플레이: 1인칭 · 자유시점 카메라, 선수가 들고 있는 총 (변환기 equips · 이름표 · 킬 피드)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import { player } from '../store/player';
|
|||||||
import { settings, useSettings } from '../store/settings';
|
import { settings, useSettings } from '../store/settings';
|
||||||
import { useData } from '../store/app';
|
import { useData } from '../store/app';
|
||||||
import { fmtClock } from '../lib/format';
|
import { fmtClock } from '../lib/format';
|
||||||
import { isDead, roundAt, samplePlayer, type ReplayFile, type ReplaySync } from '../lib/replay';
|
import { equipAt, equipLabel, equipTracks, isDead, roundAt, samplePlayer, type ReplayFile, type ReplaySync } from '../lib/replay';
|
||||||
import { findMap3d, loadMap3d, mapMaterial, worldMatrix } from '../lib/map3d';
|
import { findMap3d, loadMap3d, mapMaterial, worldMatrix } from '../lib/map3d';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +25,15 @@ const ENEMY = 0xff4d5e;
|
|||||||
const RATES = [0.5, 1, 1.5, 2];
|
const RATES = [0.5, 1, 1.5, 2];
|
||||||
/** 자동 천장: 선수(몸 중심) 위로 이만큼(cm) 남기고 자른다 */
|
/** 자동 천장: 선수(몸 중심) 위로 이만큼(cm) 남기고 자른다 */
|
||||||
const CEIL_ABOVE = 380;
|
const CEIL_ABOVE = 380;
|
||||||
|
/** 리플레이 선수 위치(캡슐 중심)에서 눈 · 발까지 (cm) */
|
||||||
|
const EYE_CM = 60;
|
||||||
|
const FOOT_CM = 90;
|
||||||
|
/** 1인칭 · 자유시점에서는 선수 표시를 실제 크기 가깝게 줄인다 */
|
||||||
|
const REAL_SCALE = 0.5;
|
||||||
|
|
||||||
|
/** 카메라: 위에서 보기(돌리기) · 1인칭(고른 선수 눈) · 자유시점(WASD) */
|
||||||
|
type CamMode = 'top' | 'fp' | 'free';
|
||||||
|
const CAM_LABEL: Record<CamMode, string> = { top: '위에서', fp: '1인칭', free: '자유시점' };
|
||||||
|
|
||||||
type MapState = { state: 'none' | 'loading' | 'ready' | 'error'; progress?: number };
|
type MapState = { state: 'none' | 'loading' | 'ready' | 'error'; progress?: number };
|
||||||
/** 천장 자르기: 자동 · 끔 · 직접(가장 낮은 층에서 cm) */
|
/** 천장 자르기: 자동 · 끔 · 직접(가장 낮은 층에서 cm) */
|
||||||
@@ -39,6 +48,14 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function labelSprite(text: string, color: string) {
|
function labelSprite(text: string, color: string) {
|
||||||
|
const { tex, aspect } = labelTexture(text, color);
|
||||||
|
const sp = new THREE.Sprite(new THREE.SpriteMaterial({ map: tex, depthTest: false, transparent: true }));
|
||||||
|
sp.scale.set(aspect * 2.2, 2.2, 1);
|
||||||
|
sp.renderOrder = 10;
|
||||||
|
return sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
function labelTexture(text: string, color: string) {
|
||||||
const c = document.createElement('canvas');
|
const c = document.createElement('canvas');
|
||||||
const ctx = c.getContext('2d')!;
|
const ctx = c.getContext('2d')!;
|
||||||
const font = '600 44px Pretendard, "Noto Sans KR", sans-serif';
|
const font = '600 44px Pretendard, "Noto Sans KR", sans-serif';
|
||||||
@@ -56,10 +73,7 @@ function labelSprite(text: string, color: string) {
|
|||||||
ctx.fillText(text, 18, 36);
|
ctx.fillText(text, 18, 36);
|
||||||
const tex = new THREE.CanvasTexture(c);
|
const tex = new THREE.CanvasTexture(c);
|
||||||
tex.colorSpace = THREE.SRGBColorSpace;
|
tex.colorSpace = THREE.SRGBColorSpace;
|
||||||
const sp = new THREE.Sprite(new THREE.SpriteMaterial({ map: tex, depthTest: false, transparent: true }));
|
return { tex, aspect: w / 68 };
|
||||||
sp.scale.set((w / 68) * 2.2, 2.2, 1);
|
|
||||||
sp.renderOrder = 10;
|
|
||||||
return sp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PlayerView {
|
interface PlayerView {
|
||||||
@@ -71,6 +85,9 @@ interface PlayerView {
|
|||||||
body: THREE.Mesh;
|
body: THREE.Mesh;
|
||||||
cone: THREE.Mesh;
|
cone: THREE.Mesh;
|
||||||
label: THREE.Sprite;
|
label: THREE.Sprite;
|
||||||
|
/** 들고 있는 것 (총 이름) */
|
||||||
|
weapon: THREE.Sprite;
|
||||||
|
weaponKind: number;
|
||||||
voice: THREE.Sprite;
|
voice: THREE.Sprite;
|
||||||
ring: THREE.Mesh;
|
ring: THREE.Mesh;
|
||||||
/** 바닥(미니맵)까지 내린 선과 그림자 점: 높이가 있어도 평면 위치가 보이게 */
|
/** 바닥(미니맵)까지 내린 선과 그림자 점: 높이가 있어도 평면 위치가 보이게 */
|
||||||
@@ -88,6 +105,9 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
const [ui, setUi] = useState({ t: firstCombat, playing: false });
|
const [ui, setUi] = useState({ t: firstCombat, playing: false });
|
||||||
const [sel, setSel] = useState<number | null>(null);
|
const [sel, setSel] = useState<number | null>(null);
|
||||||
const [follow, setFollow] = useState(false);
|
const [follow, setFollow] = useState(false);
|
||||||
|
const [cam, setCam] = useState<CamMode>('top');
|
||||||
|
const camRef = useRef(cam);
|
||||||
|
camRef.current = cam;
|
||||||
const selRef = useRef(sel);
|
const selRef = useRef(sel);
|
||||||
const followRef = useRef(follow);
|
const followRef = useRef(follow);
|
||||||
selRef.current = sel;
|
selRef.current = sel;
|
||||||
@@ -115,6 +135,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
}, [replay, zBase]);
|
}, [replay, zBase]);
|
||||||
const T = (m.mapTransform && 'valorant' in m.mapTransform ? m.mapTransform.valorant : null) as T4 | null;
|
const T = (m.mapTransform && 'valorant' in m.mapTransform ? m.mapTransform.valorant : null) as T4 | null;
|
||||||
|
|
||||||
|
const equipByPlayer = useMemo(() => equipTracks(replay), [replay]);
|
||||||
// 리플레이 선수 ↔ 경기 기록 선수 (puuid)
|
// 리플레이 선수 ↔ 경기 기록 선수 (puuid)
|
||||||
const roster = useMemo(
|
const roster = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -148,6 +169,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
mount.appendChild(renderer.domElement);
|
mount.appendChild(renderer.domElement);
|
||||||
const scene = new THREE.Scene();
|
const scene = new THREE.Scene();
|
||||||
const camera = new THREE.PerspectiveCamera(45, 1, 0.5, 2000);
|
const camera = new THREE.PerspectiveCamera(45, 1, 0.5, 2000);
|
||||||
|
renderer.domElement.tabIndex = 0; // 자유시점 키보드
|
||||||
const controls = new OrbitControls(camera, renderer.domElement);
|
const controls = new OrbitControls(camera, renderer.domElement);
|
||||||
controls.enableDamping = true;
|
controls.enableDamping = true;
|
||||||
controls.maxPolarAngle = Math.PI * 0.49;
|
controls.maxPolarAngle = Math.PI * 0.49;
|
||||||
@@ -228,6 +250,10 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
const label = labelSprite(r.info?.character?.name ? `${r.name} · ${r.info.character.name}` : r.name, r.ally ? '#8fd8ff' : '#ff9aa5');
|
const label = labelSprite(r.info?.character?.name ? `${r.name} · ${r.info.character.name}` : r.name, r.ally ? '#8fd8ff' : '#ff9aa5');
|
||||||
label.position.y = 4.4;
|
label.position.y = 4.4;
|
||||||
label.userData.idx = r.idx;
|
label.userData.idx = r.idx;
|
||||||
|
const weapon = new THREE.Sprite(new THREE.SpriteMaterial({ depthTest: false, transparent: true }));
|
||||||
|
weapon.position.y = 2.75;
|
||||||
|
weapon.renderOrder = 10;
|
||||||
|
weapon.visible = false;
|
||||||
const voice = labelSprite('🔊 말하는 중', '#ffe08a');
|
const voice = labelSprite('🔊 말하는 중', '#ffe08a');
|
||||||
voice.position.y = 6.6;
|
voice.position.y = 6.6;
|
||||||
voice.visible = false;
|
voice.visible = false;
|
||||||
@@ -235,7 +261,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
ring.rotation.x = -Math.PI / 2;
|
ring.rotation.x = -Math.PI / 2;
|
||||||
ring.position.y = 0.05;
|
ring.position.y = 0.05;
|
||||||
ring.visible = false;
|
ring.visible = false;
|
||||||
group.add(body, cone, label, voice, ring);
|
group.add(body, cone, label, weapon, voice, ring);
|
||||||
scene.add(group);
|
scene.add(group);
|
||||||
const dropGeo = new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3()]);
|
const dropGeo = new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3()]);
|
||||||
const drop = new THREE.Line(dropGeo, new THREE.LineBasicMaterial({ color, transparent: true, opacity: 0.7 }));
|
const drop = new THREE.Line(dropGeo, new THREE.LineBasicMaterial({ color, transparent: true, opacity: 0.7 }));
|
||||||
@@ -243,9 +269,27 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
const shadow = new THREE.Mesh(new THREE.CircleGeometry(0.75, 20), new THREE.MeshBasicMaterial({ color, transparent: true, opacity: 0.85 }));
|
const shadow = new THREE.Mesh(new THREE.CircleGeometry(0.75, 20), new THREE.MeshBasicMaterial({ color, transparent: true, opacity: 0.85 }));
|
||||||
shadow.rotation.x = -Math.PI / 2;
|
shadow.rotation.x = -Math.PI / 2;
|
||||||
scene.add(drop, shadow);
|
scene.add(drop, shadow);
|
||||||
return { idx: r.idx, info: r.info, name: r.name, ally: r.ally, group, body, cone, label, voice, ring, drop, shadow };
|
return { idx: r.idx, info: r.info, name: r.name, ally: r.ally, group, body, cone, label, weapon, weaponKind: -2, voice, ring, drop, shadow };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 총 이름표 (같은 글자는 텍스처 하나)
|
||||||
|
const weaponTex = new Map<string, { tex: THREE.Texture; aspect: number }>();
|
||||||
|
const setWeapon = (v: PlayerView, kind: number) => {
|
||||||
|
if (v.weaponKind === kind) return;
|
||||||
|
v.weaponKind = kind;
|
||||||
|
const text = equipLabel(replay.equipKinds?.[kind]);
|
||||||
|
if (!text) {
|
||||||
|
v.weapon.visible = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let lt = weaponTex.get(text);
|
||||||
|
if (!lt) weaponTex.set(text, (lt = labelTexture(`🔫 ${text}`, '#ffe9b0')));
|
||||||
|
v.weapon.material.map = lt.tex;
|
||||||
|
v.weapon.material.needsUpdate = true;
|
||||||
|
v.weapon.scale.set(lt.aspect * 1.6, 1.6, 1);
|
||||||
|
v.weapon.visible = true;
|
||||||
|
};
|
||||||
|
|
||||||
// 선택한 선수 이동 경로 (최근 6초)
|
// 선택한 선수 이동 경로 (최근 6초)
|
||||||
const trailGeo = new THREE.BufferGeometry();
|
const trailGeo = new THREE.BufferGeometry();
|
||||||
trailGeo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(3 * 80), 3));
|
trailGeo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(3 * 80), 3));
|
||||||
@@ -312,26 +356,81 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
// 선수 눌러서 고르기
|
// 선수 눌러서 고르기
|
||||||
const ray = new THREE.Raycaster();
|
const ray = new THREE.Raycaster();
|
||||||
const down = { x: 0, y: 0 };
|
const down = { x: 0, y: 0 };
|
||||||
|
// 자유시점: 끌어서 둘러보기, WASD 이동 · Q/E 아래/위 · Shift 빠르게
|
||||||
|
const free = { yaw: 0, pitch: -0.6, drag: false, lx: 0, ly: 0, keys: new Set<string>() };
|
||||||
const onDown = (e: PointerEvent) => {
|
const onDown = (e: PointerEvent) => {
|
||||||
down.x = e.clientX;
|
down.x = e.clientX;
|
||||||
down.y = e.clientY;
|
down.y = e.clientY;
|
||||||
|
if (camRef.current === 'free') {
|
||||||
|
free.drag = true;
|
||||||
|
free.lx = e.clientX;
|
||||||
|
free.ly = e.clientY;
|
||||||
|
renderer.domElement.setPointerCapture(e.pointerId);
|
||||||
|
}
|
||||||
|
renderer.domElement.focus({ preventScroll: true });
|
||||||
};
|
};
|
||||||
|
const onMove = (e: PointerEvent) => {
|
||||||
|
if (!free.drag || camRef.current !== 'free') return;
|
||||||
|
free.yaw -= (e.clientX - free.lx) * 0.004;
|
||||||
|
free.pitch = Math.max(-1.55, Math.min(1.55, free.pitch - (e.clientY - free.ly) * 0.004));
|
||||||
|
free.lx = e.clientX;
|
||||||
|
free.ly = e.clientY;
|
||||||
|
};
|
||||||
|
const MOVE_KEYS = new Set(['KeyW', 'KeyA', 'KeyS', 'KeyD', 'KeyQ', 'KeyE', 'ShiftLeft', 'ShiftRight', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']);
|
||||||
|
const onKey = (e: KeyboardEvent) => {
|
||||||
|
if (camRef.current !== 'free' || !MOVE_KEYS.has(e.code)) return;
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.type === 'keydown') free.keys.add(e.code);
|
||||||
|
else free.keys.delete(e.code);
|
||||||
|
};
|
||||||
|
const onBlur = () => free.keys.clear();
|
||||||
const onUp = (e: PointerEvent) => {
|
const onUp = (e: PointerEvent) => {
|
||||||
|
free.drag = false;
|
||||||
if (Math.hypot(e.clientX - down.x, e.clientY - down.y) > 5) return; // 끌기(회전)는 고르기 아님
|
if (Math.hypot(e.clientX - down.x, e.clientY - down.y) > 5) return; // 끌기(회전)는 고르기 아님
|
||||||
const r = renderer.domElement.getBoundingClientRect();
|
const r = renderer.domElement.getBoundingClientRect();
|
||||||
ray.setFromCamera(new THREE.Vector2(((e.clientX - r.left) / r.width) * 2 - 1, -((e.clientY - r.top) / r.height) * 2 + 1), camera);
|
ray.setFromCamera(new THREE.Vector2(((e.clientX - r.left) / r.width) * 2 - 1, -((e.clientY - r.top) / r.height) * 2 + 1), camera);
|
||||||
// 몸통은 위에서 보면 작아서 이름표를 눌러도 고른다
|
// 몸통은 위에서 보면 작아서 이름표를 눌러도 고른다
|
||||||
const hit = ray.intersectObjects(views.flatMap((v) => (v.group.visible ? [v.body, v.label] : [])))[0];
|
const hit = ray.intersectObjects(views.flatMap((v) => (v.group.visible ? [v.body, v.label] : [])))[0];
|
||||||
setSel(hit ? (hit.object.userData.idx as number) : null);
|
// 1인칭에서는 빈 곳을 눌러도 보던 선수를 놓지 않는다
|
||||||
|
if (hit) setSel(hit.object.userData.idx as number);
|
||||||
|
else if (camRef.current !== 'fp') setSel(null);
|
||||||
};
|
};
|
||||||
renderer.domElement.addEventListener('pointerdown', onDown);
|
renderer.domElement.addEventListener('pointerdown', onDown);
|
||||||
renderer.domElement.addEventListener('pointerup', onUp);
|
renderer.domElement.addEventListener('pointerup', onUp);
|
||||||
|
renderer.domElement.addEventListener('pointermove', onMove);
|
||||||
|
renderer.domElement.addEventListener('keydown', onKey);
|
||||||
|
renderer.domElement.addEventListener('keyup', onKey);
|
||||||
|
renderer.domElement.addEventListener('blur', onBlur);
|
||||||
|
|
||||||
let raf = 0;
|
let raf = 0;
|
||||||
let lastUi = 0;
|
let lastUi = 0;
|
||||||
|
let lastNow = 0;
|
||||||
|
let lastMode: CamMode = 'top';
|
||||||
const tmp = new THREE.Vector3();
|
const tmp = new THREE.Vector3();
|
||||||
|
const euler = new THREE.Euler(0, 0, 0, 'YXZ');
|
||||||
const frame = (now: number) => {
|
const frame = (now: number) => {
|
||||||
raf = requestAnimationFrame(frame);
|
raf = requestAnimationFrame(frame);
|
||||||
|
const dt = lastNow ? Math.min(0.1, (now - lastNow) / 1000) : 0;
|
||||||
|
lastNow = now;
|
||||||
|
const mode = camRef.current;
|
||||||
|
if (mode !== lastMode) {
|
||||||
|
controls.enabled = mode === 'top';
|
||||||
|
camera.near = mode === 'top' ? 0.5 : 0.01;
|
||||||
|
camera.far = mode === 'top' ? 2000 : 600;
|
||||||
|
camera.fov = mode === 'fp' ? 70 : 45;
|
||||||
|
camera.updateProjectionMatrix();
|
||||||
|
if (mode === 'top') resetCam.current();
|
||||||
|
if (mode === 'free') {
|
||||||
|
// 지금 보던 방향에서 시작
|
||||||
|
euler.setFromQuaternion(camera.quaternion);
|
||||||
|
free.yaw = euler.y;
|
||||||
|
free.pitch = euler.x;
|
||||||
|
}
|
||||||
|
free.keys.clear();
|
||||||
|
lastMode = mode;
|
||||||
|
}
|
||||||
|
const real = mode !== 'top';
|
||||||
const ps = player.state;
|
const ps = player.state;
|
||||||
const inScene = ps.mode === 'scene' && ps.scene?.label === REPLAY_SCENE_LABEL && ps.sceneTs != null;
|
const inScene = ps.mode === 'scene' && ps.scene?.label === REPLAY_SCENE_LABEL && ps.sceneTs != null;
|
||||||
const t = inScene ? ps.sceneTs! - base : localT.current;
|
const t = inScene ? ps.sceneTs! - base : localT.current;
|
||||||
@@ -351,9 +450,11 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
v.group.visible = v.drop.visible = v.shadow.visible = false;
|
v.group.visible = v.drop.visible = v.shadow.visible = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
v.group.visible = true;
|
// 1인칭으로 보는 선수 자신은 숨긴다
|
||||||
v.drop.visible = v.shadow.visible = !mapReady;
|
v.group.visible = !(mode === 'fp' && v.idx === selRef.current);
|
||||||
v.group.position.copy(toWorld(p.x, p.y, Math.max(p.z, zBase - 400), zBase));
|
v.drop.visible = v.shadow.visible = !mapReady && !real;
|
||||||
|
v.group.position.copy(toWorld(p.x, p.y, Math.max(p.z, zBase - 400) - (real ? FOOT_CM : 0), zBase));
|
||||||
|
v.group.scale.setScalar(real ? REAL_SCALE : 1);
|
||||||
v.shadow.position.set(v.group.position.x, 0.04, v.group.position.z);
|
v.shadow.position.set(v.group.position.x, 0.04, v.group.position.z);
|
||||||
const dp = v.drop.geometry.getAttribute('position') as THREE.BufferAttribute;
|
const dp = v.drop.geometry.getAttribute('position') as THREE.BufferAttribute;
|
||||||
dp.setXYZ(0, v.group.position.x, v.group.position.y, v.group.position.z);
|
dp.setXYZ(0, v.group.position.x, v.group.position.y, v.group.position.z);
|
||||||
@@ -368,13 +469,16 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
v.label.material.opacity = dead ? 0.35 : 1;
|
v.label.material.opacity = dead ? 0.35 : 1;
|
||||||
(v.shadow.material as THREE.MeshBasicMaterial).opacity = dead ? 0.25 : 0.85;
|
(v.shadow.material as THREE.MeshBasicMaterial).opacity = dead ? 0.25 : 0.85;
|
||||||
v.voice.visible = speaking.has(v.idx) && !dead;
|
v.voice.visible = speaking.has(v.idx) && !dead;
|
||||||
|
setWeapon(v, dead ? -1 : equipAt(equipByPlayer[v.idx], t));
|
||||||
|
v.weapon.material.opacity = v.label.material.opacity;
|
||||||
v.ring.visible = v.idx === selIdx;
|
v.ring.visible = v.idx === selIdx;
|
||||||
}
|
}
|
||||||
// 천장 자르기
|
// 천장 자르기
|
||||||
const cm = ceilRef.current;
|
const cm = ceilRef.current;
|
||||||
let want = 1e6;
|
let want = 1e6;
|
||||||
if (mapReady && cm.mode === 'manual') want = cm.cm * hPerCm;
|
if (mode === 'fp') want = 1e6;
|
||||||
else if (mapReady && cm.mode === 'auto') {
|
else if (mapReady && cm.mode === 'manual') want = cm.cm * hPerCm;
|
||||||
|
else if (mapReady && cm.mode === 'auto' && mode === 'top') {
|
||||||
const sv = selIdx != null ? views[selIdx] : null;
|
const sv = selIdx != null ? views[selIdx] : null;
|
||||||
let top = -Infinity;
|
let top = -Infinity;
|
||||||
if (sv?.group.visible) top = sv.group.position.y;
|
if (sv?.group.visible) top = sv.group.position.y;
|
||||||
@@ -397,7 +501,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
trailGeo.setDrawRange(0, n);
|
trailGeo.setDrawRange(0, n);
|
||||||
pos.needsUpdate = true;
|
pos.needsUpdate = true;
|
||||||
trail.visible = n > 1;
|
trail.visible = n > 1;
|
||||||
if (followRef.current && views[selIdx].group.visible) {
|
if (mode === 'top' && followRef.current && views[selIdx].group.visible) {
|
||||||
const target = views[selIdx].group.position;
|
const target = views[selIdx].group.position;
|
||||||
tmp.copy(target).sub(controls.target);
|
tmp.copy(target).sub(controls.target);
|
||||||
controls.target.add(tmp.multiplyScalar(0.15));
|
controls.target.add(tmp.multiplyScalar(0.15));
|
||||||
@@ -441,7 +545,24 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
if (mesh) mesh.visible = false;
|
if (mesh) mesh.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
controls.update();
|
if (mode === 'fp' && selIdx != null) {
|
||||||
|
// 고른 선수 눈 위치에서 보는 방향 (yaw · pitch) 으로
|
||||||
|
const p = samplePlayer(replay.players[selIdx].track, t, replay.sampleMs * 6);
|
||||||
|
if (p) {
|
||||||
|
const eye = toWorld(p.x, p.y, p.z + EYE_CM, zBase);
|
||||||
|
const d = dirOf(p.yaw);
|
||||||
|
const pr = (Math.max(-89, Math.min(89, p.pitch)) * Math.PI) / 180;
|
||||||
|
camera.position.copy(eye);
|
||||||
|
camera.lookAt(eye.x + d.x * Math.cos(pr), eye.y + Math.sin(pr), eye.z + d.z * Math.cos(pr));
|
||||||
|
}
|
||||||
|
} else if (mode === 'free') {
|
||||||
|
euler.set(free.pitch, free.yaw, 0, 'YXZ');
|
||||||
|
camera.quaternion.setFromEuler(euler);
|
||||||
|
const k = free.keys;
|
||||||
|
const speed = (k.has('ShiftLeft') || k.has('ShiftRight') ? 40 : 12) * dt;
|
||||||
|
tmp.set((k.has('KeyD') || k.has('ArrowRight') ? 1 : 0) - (k.has('KeyA') || k.has('ArrowLeft') ? 1 : 0), (k.has('KeyE') ? 1 : 0) - (k.has('KeyQ') ? 1 : 0), (k.has('KeyS') || k.has('ArrowDown') ? 1 : 0) - (k.has('KeyW') || k.has('ArrowUp') ? 1 : 0));
|
||||||
|
if (tmp.lengthSq() > 0) camera.position.add(tmp.normalize().multiplyScalar(speed).applyQuaternion(camera.quaternion));
|
||||||
|
} else controls.update();
|
||||||
renderer.render(scene, camera);
|
renderer.render(scene, camera);
|
||||||
if (now - lastUi > 100) {
|
if (now - lastUi > 100) {
|
||||||
lastUi = now;
|
lastUi = now;
|
||||||
@@ -459,6 +580,10 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
ro.disconnect();
|
ro.disconnect();
|
||||||
renderer.domElement.removeEventListener('pointerdown', onDown);
|
renderer.domElement.removeEventListener('pointerdown', onDown);
|
||||||
renderer.domElement.removeEventListener('pointerup', onUp);
|
renderer.domElement.removeEventListener('pointerup', onUp);
|
||||||
|
renderer.domElement.removeEventListener('pointermove', onMove);
|
||||||
|
renderer.domElement.removeEventListener('keydown', onKey);
|
||||||
|
renderer.domElement.removeEventListener('keyup', onKey);
|
||||||
|
renderer.domElement.removeEventListener('blur', onBlur);
|
||||||
controls.dispose();
|
controls.dispose();
|
||||||
scene.traverse((o) => {
|
scene.traverse((o) => {
|
||||||
const mesh = o as THREE.Mesh;
|
const mesh = o as THREE.Mesh;
|
||||||
@@ -473,7 +598,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
renderer.domElement.remove();
|
renderer.domElement.remove();
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [m, replay, base, roster, playerByUser, zBase, zTop]);
|
}, [m, replay, base, roster, playerByUser, zBase, zTop, equipByPlayer]);
|
||||||
|
|
||||||
const inScene = () => player.state.mode === 'scene' && player.state.scene?.label === REPLAY_SCENE_LABEL;
|
const inScene = () => player.state.mode === 'scene' && player.state.scene?.label === REPLAY_SCENE_LABEL;
|
||||||
const seek = (t: number) => {
|
const seek = (t: number) => {
|
||||||
@@ -498,6 +623,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
const captions = m.utterances.filter((u) => !u.noise && u.text && u.ts <= ts && ts <= u.endTs + 1500).slice(-3);
|
const captions = m.utterances.filter((u) => !u.noise && u.text && u.ts <= ts && ts <= u.endTs + 1500).slice(-3);
|
||||||
const feed = replay.kills.filter(([kt]) => kt <= ui.t && ui.t - kt < 6000).slice(-5);
|
const feed = replay.kills.filter(([kt]) => kt <= ui.t && ui.t - kt < 6000).slice(-5);
|
||||||
const selInfo = sel != null ? roster[sel] : null;
|
const selInfo = sel != null ? roster[sel] : null;
|
||||||
|
const selEquip = sel != null ? equipLabel(replay.equipKinds?.[equipAt(equipByPlayer[sel], ui.t)]) : null;
|
||||||
const selPos = sel != null ? samplePlayer(replay.players[sel].track, ui.t, replay.sampleMs * 6) : null;
|
const selPos = sel != null ? samplePlayer(replay.players[sel].track, ui.t, replay.sampleMs * 6) : null;
|
||||||
const jumpRound = (dir: -1 | 1) => {
|
const jumpRound = (dir: -1 | 1) => {
|
||||||
const i = rd ? replay.rounds.indexOf(rd) : 0;
|
const i = rd ? replay.rounds.indexOf(rd) : 0;
|
||||||
@@ -505,6 +631,15 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
if (to) seek(to.combat >= 0 ? to.combat - 3000 : to.buy);
|
if (to) seek(to.combat >= 0 ? to.combat - 3000 : to.buy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const chooseCam = (c: CamMode) => {
|
||||||
|
// 1인칭은 고른 선수가 있어야 한다: 없으면 지금 살아 있는 첫 아군
|
||||||
|
if (c === 'fp' && sel == null) {
|
||||||
|
const alive = roster.find((r) => r.ally && samplePlayer(replay.players[r.idx].track, ui.t, replay.sampleMs * 6) && !isDead(replay, r.idx, ui.t)) ?? roster[0];
|
||||||
|
if (alive) setSel(alive.idx);
|
||||||
|
}
|
||||||
|
setCam(c);
|
||||||
|
};
|
||||||
|
|
||||||
if (!T) return <div className="map-missing">이 경기에는 미니맵 좌표 정보가 없어 3D 리플레이를 그릴 수 없습니다</div>;
|
if (!T) return <div className="map-missing">이 경기에는 미니맵 좌표 정보가 없어 3D 리플레이를 그릴 수 없습니다</div>;
|
||||||
return (
|
return (
|
||||||
<div className="r3d">
|
<div className="r3d">
|
||||||
@@ -518,7 +653,12 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
<div className="r3d-hud tr">
|
<div className="r3d-hud tr">
|
||||||
{feed.map(([kt, ki, vi]) => (
|
{feed.map(([kt, ki, vi]) => (
|
||||||
<div key={`${kt}:${vi}`} className="r3d-kill">
|
<div key={`${kt}:${vi}`} className="r3d-kill">
|
||||||
<span className={roster[ki]?.ally ? 'a' : 'e'}>{roster[ki]?.name ?? '?'}</span> ✕ <span className={roster[vi]?.ally ? 'a' : 'e'}>{roster[vi]?.name ?? '?'}</span>
|
<span className={roster[ki]?.ally ? 'a' : 'e'}>{roster[ki]?.name ?? '?'}</span>
|
||||||
|
{(() => {
|
||||||
|
const w = ki >= 0 ? equipLabel(replay.equipKinds?.[equipAt(equipByPlayer[ki], kt)]) : null;
|
||||||
|
return w ? <span className="muted"> [{w}]</span> : null;
|
||||||
|
})()}{' '}
|
||||||
|
✕ <span className={roster[vi]?.ally ? 'a' : 'e'}>{roster[vi]?.name ?? '?'}</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -531,14 +671,29 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{selInfo && (
|
{cam === 'fp' && <div className="r3d-cross" />}
|
||||||
|
{cam === 'free' && <div className="r3d-hud bl muted small">끌기: 둘러보기 · W A S D: 이동 · Q / E: 아래 / 위 · Shift: 빠르게 (화면을 한 번 누른 뒤)</div>}
|
||||||
|
{selInfo && cam !== 'free' && (
|
||||||
<div className="r3d-hud bl">
|
<div className="r3d-hud bl">
|
||||||
<b className={selInfo.ally ? 'a' : 'e'}>{selInfo.name}</b>
|
<b className={selInfo.ally ? 'a' : 'e'}>{selInfo.name}</b>
|
||||||
{selInfo.info?.character?.name && <span className="muted"> · {selInfo.info.character.name}</span>}
|
{selInfo.info?.character?.name && <span className="muted"> · {selInfo.info.character.name}</span>}
|
||||||
|
{selEquip && <div>🔫 {selEquip}</div>}
|
||||||
{selPos && <div className="mono muted">가장 낮은 층보다 {Math.max(0, Math.round((selPos.z - zBase) / 100))}m 위 · 보는 방향 {Math.round(((selPos.yaw % 360) + 360) % 360)}°</div>}
|
{selPos && <div className="mono muted">가장 낮은 층보다 {Math.max(0, Math.round((selPos.z - zBase) / 100))}m 위 · 보는 방향 {Math.round(((selPos.yaw % 360) + 360) % 360)}°</div>}
|
||||||
<label className="r3d-follow">
|
{cam === 'top' && (
|
||||||
<input type="checkbox" checked={follow} onChange={(e) => setFollow(e.target.checked)} /> 따라가기
|
<label className="r3d-follow">
|
||||||
</label>
|
<input type="checkbox" checked={follow} onChange={(e) => setFollow(e.target.checked)} /> 따라가기
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
{cam === 'fp' && (
|
||||||
|
<select className="r3d-pick" value={sel ?? ''} onChange={(e) => setSel(Number(e.target.value))} aria-label="1인칭으로 볼 선수">
|
||||||
|
{roster.map((r) => (
|
||||||
|
<option key={r.idx} value={r.idx}>
|
||||||
|
{r.ally ? '아군' : '상대'} · {r.name}
|
||||||
|
{r.info?.character?.name ? ` (${r.info.character.name})` : ''}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -576,10 +731,21 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<button className="chip" onClick={() => resetCam.current()} title="카메라 처음 위치로">전체 보기</button>
|
<span className="r3d-cams" role="group" aria-label="카메라">
|
||||||
|
{(['top', 'fp', 'free'] as CamMode[]).map((c) => (
|
||||||
|
<button key={c} className={`chip${cam === c ? ' on' : ''}`} onClick={() => chooseCam(c)} aria-pressed={cam === c}>
|
||||||
|
{CAM_LABEL[c]}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
{cam === 'top' && (
|
||||||
|
<button className="chip" onClick={() => resetCam.current()} title="카메라 처음 위치로">
|
||||||
|
전체 보기
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="r3d-foot muted">
|
<div className="r3d-foot muted">
|
||||||
마우스 왼쪽 끌기: 회전 · 오른쪽 끌기: 이동 · 휠: 확대 · 선수 클릭: 선택 ·{' '}
|
{cam === 'top' ? '마우스 왼쪽 끌기: 회전 · 오른쪽 끌기: 이동 · 휠: 확대 · 선수 클릭: 선택' : cam === 'fp' ? '1인칭: 고른 선수 눈높이 · 다른 선수를 누르면 그 선수로' : '자유시점: 끌어서 둘러보기 · WASD 이동'} ·{' '}
|
||||||
{sync.matched >= 3
|
{sync.matched >= 3
|
||||||
? `대화 동기화: 킬 ${sync.matched}개로 맞춤 (최대 오차 ${((sync.spreadMs ?? 0) / 1000).toFixed(2)}초)`
|
? `대화 동기화: 킬 ${sync.matched}개로 맞춤 (최대 오차 ${((sync.spreadMs ?? 0) / 1000).toFixed(2)}초)`
|
||||||
: '대화 동기화: 라운드 시작으로 대략 맞춤'}
|
: '대화 동기화: 라운드 시작으로 대략 맞춤'}
|
||||||
|
|||||||
@@ -21,6 +21,45 @@ export interface ReplayFile {
|
|||||||
/** [t0, t1, kind, x, y, z, owner] */
|
/** [t0, t1, kind, x, y, z, owner] */
|
||||||
objects: [number, number, number, number, number, number, number][];
|
objects: [number, number, number, number, number, number, number][];
|
||||||
objectKinds: string[];
|
objectKinds: string[];
|
||||||
|
/** 들고 있는 것이 바뀐 시각 [t, player, kind] (변환기 새 버전부터. 옛 리플레이 JSON 에는 없다) */
|
||||||
|
equips?: [number, number, number][];
|
||||||
|
equipKinds?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const WEAPON_KO: Record<string, string> = {
|
||||||
|
Classic: '클래식', Shorty: '쇼티', Frenzy: '프렌지', Ghost: '고스트', Sheriff: '셰리프', 'Compact Pistol': '밴딧',
|
||||||
|
Stinger: '스팅어', Spectre: '스펙터', Bucky: '버키', Judge: '저지', Bulldog: '불독', Guardian: '가디언', Phantom: '팬텀', Vandal: '밴달',
|
||||||
|
Marshal: '마셜', Outlaw: '아웃로', Operator: '오퍼레이터', Ares: '아레스', Odin: '오딘',
|
||||||
|
Melee: '칼', Spike: '스파이크', Unarmed: '맨손', Headhunter: '헤드헌터', 'Tour de Force': '투르 드 포스', Bomb_Defuser_C: '스파이크 해체',
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 들고 있는 것 이름 (한국어). 스킬은 "스킬", 모르면 null */
|
||||||
|
export function equipLabel(kind: string | undefined): string | null {
|
||||||
|
if (!kind) return null;
|
||||||
|
if (WEAPON_KO[kind]) return WEAPON_KO[kind];
|
||||||
|
if (/^Ability_/.test(kind)) return '스킬';
|
||||||
|
if (/Unarmed/.test(kind)) return null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 선수별 [t, kind] 목록 (시간 순) */
|
||||||
|
export function equipTracks(r: ReplayFile): [number, number][][] {
|
||||||
|
const out: [number, number][][] = r.players.map(() => []);
|
||||||
|
for (const [t, p, k] of r.equips ?? []) out[p]?.push([t, k]);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** t 시점에 들고 있던 것 (kind 번호, 없으면 -1) */
|
||||||
|
export function equipAt(track: [number, number][] | undefined, t: number): number {
|
||||||
|
if (!track?.length || t < track[0][0]) return -1;
|
||||||
|
let lo = 0;
|
||||||
|
let hi = track.length - 1;
|
||||||
|
while (lo < hi) {
|
||||||
|
const mid = (lo + hi + 1) >> 1;
|
||||||
|
if (track[mid][0] <= t) lo = mid;
|
||||||
|
else hi = mid - 1;
|
||||||
|
}
|
||||||
|
return track[lo][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +137,7 @@ export function samplePlayer(tr: ReplayFile['players'][number]['track'], t: numb
|
|||||||
}
|
}
|
||||||
const i = lo;
|
const i = lo;
|
||||||
const j = Math.min(i + 1, T.length - 1);
|
const j = Math.min(i + 1, T.length - 1);
|
||||||
if (t - T[i] > gapMs) return { x: tr.x[i], y: tr.y[i], z: tr.z[i], yaw: tr.yaw[i], pitch: tr.pitch[i], stale: true };
|
if (t - T[i] > gapMs) return { x: tr.x[i], y: tr.y[i], z: tr.z[i], yaw: tr.yaw[i], pitch: signedDeg(tr.pitch[i]), stale: true };
|
||||||
const span = T[j] - T[i];
|
const span = T[j] - T[i];
|
||||||
const k = j === i || span > gapMs || span <= 0 ? 0 : Math.min(1, Math.max(0, (t - T[i]) / span));
|
const k = j === i || span > gapMs || span <= 0 ? 0 : Math.min(1, Math.max(0, (t - T[i]) / span));
|
||||||
let dy = tr.yaw[j] - tr.yaw[i];
|
let dy = tr.yaw[j] - tr.yaw[i];
|
||||||
@@ -109,11 +148,17 @@ export function samplePlayer(tr: ReplayFile['players'][number]['track'], t: numb
|
|||||||
y: tr.y[i] + (tr.y[j] - tr.y[i]) * k,
|
y: tr.y[i] + (tr.y[j] - tr.y[i]) * k,
|
||||||
z: tr.z[i] + (tr.z[j] - tr.z[i]) * k,
|
z: tr.z[i] + (tr.z[j] - tr.z[i]) * k,
|
||||||
yaw: tr.yaw[i] + dy * k,
|
yaw: tr.yaw[i] + dy * k,
|
||||||
pitch: tr.pitch[i] + (tr.pitch[j] - tr.pitch[i]) * k,
|
pitch: signedDeg(tr.pitch[i]) + (signedDeg(tr.pitch[j]) - signedDeg(tr.pitch[i])) * k,
|
||||||
stale: false,
|
stale: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 게임 각도(0~360) → -180~180 (아래를 보면 음수) */
|
||||||
|
function signedDeg(a: number) {
|
||||||
|
const v = ((a % 360) + 360) % 360;
|
||||||
|
return v > 180 ? v - 360 : v;
|
||||||
|
}
|
||||||
|
|
||||||
/** t 가 속한 라운드 (구매 단계 시작 기준) */
|
/** t 가 속한 라운드 (구매 단계 시작 기준) */
|
||||||
export function roundAt(r: ReplayFile, t: number) {
|
export function roundAt(r: ReplayFile, t: number) {
|
||||||
let cur = r.rounds[0] ?? null;
|
let cur = r.rounds[0] ?? null;
|
||||||
|
|||||||
@@ -4070,6 +4070,36 @@ button.match:hover {
|
|||||||
.r3d-foot {
|
.r3d-foot {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
.r3d-cams {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
.r3d-pick {
|
||||||
|
display: block;
|
||||||
|
margin-top: 6px;
|
||||||
|
max-width: 260px;
|
||||||
|
background: rgba(8, 14, 20, 0.85);
|
||||||
|
color: inherit;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 3px 6px;
|
||||||
|
}
|
||||||
|
.r3d-cross {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
margin: -3px 0 0 -3px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #7dffb0;
|
||||||
|
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
.r3d-stage canvas:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
.r3d-ceil {
|
.r3d-ceil {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
|||||||
private readonly Dictionary<uint, int> _closedAt = [];
|
private readonly Dictionary<uint, int> _closedAt = [];
|
||||||
private readonly Dictionary<uint, uint> _objectOwner = [];
|
private readonly Dictionary<uint, uint> _objectOwner = [];
|
||||||
private readonly Dictionary<string, int> _stats = [];
|
private readonly Dictionary<string, int> _stats = [];
|
||||||
|
// 들고 있는 것: 장비 액터 → 이름 (총은 파서 목록 이름, 나머지는 클래스 이름), 캐릭터별 바뀐 시각
|
||||||
|
private readonly Dictionary<uint, string> _equipName = [];
|
||||||
|
private readonly List<(int T, uint Character, uint Equip)> _equips = [];
|
||||||
|
private readonly List<(int T, uint State, string Name)> _shotEquips = [];
|
||||||
|
|
||||||
private static int Ms(float seconds) => (int)Math.Round(seconds * 1000.0);
|
private static int Ms(float seconds) => (int)Math.Round(seconds * 1000.0);
|
||||||
private static int R(double v) => (int)Math.Round(v);
|
private static int R(double v) => (int)Math.Round(v);
|
||||||
@@ -53,6 +57,8 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
|||||||
if (s.ArchetypePath is { } arch)
|
if (s.ArchetypePath is { } arch)
|
||||||
{
|
{
|
||||||
_archetypeByActor[s.ActorNetGuid] = arch;
|
_archetypeByActor[s.ActorNetGuid] = arch;
|
||||||
|
if (ValorantEquippableResolver.TryResolve(s.ActorNetGuid, [s.ReplicationClassPath, s.ArchetypePath, s.ActorPath], out var eq) && eq.Name is { } en)
|
||||||
|
_equipName[s.ActorNetGuid] = en;
|
||||||
Count("spawn " + Simplify(arch));
|
Count("spawn " + Simplify(arch));
|
||||||
if (s.Location is { } loc && ObjectClass().IsMatch(arch) && !arch.EndsWith("_PC_C"))
|
if (s.Location is { } loc && ObjectClass().IsMatch(arch) && !arch.EndsWith("_PC_C"))
|
||||||
_objects.Add((Ms(s.TimeSeconds), s.ActorNetGuid, Simplify(arch), R(loc.X), R(loc.Y), R(loc.Z)));
|
_objects.Add((Ms(s.TimeSeconds), s.ActorNetGuid, Simplify(arch), R(loc.X), R(loc.Y), R(loc.Z)));
|
||||||
@@ -83,6 +89,15 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
|||||||
case BombGameStateDescriptor gs when gs.HasDecoded(nameof(BombGameStateDescriptor.MatchID)) && !string.IsNullOrEmpty(gs.MatchID):
|
case BombGameStateDescriptor gs when gs.HasDecoded(nameof(BombGameStateDescriptor.MatchID)) && !string.IsNullOrEmpty(gs.MatchID):
|
||||||
_matchId ??= gs.MatchID;
|
_matchId ??= gs.MatchID;
|
||||||
break;
|
break;
|
||||||
|
case AresInventoryDescriptor inv:
|
||||||
|
{
|
||||||
|
var ch = inv.HasDecoded(nameof(AresInventoryDescriptor.Character)) && inv.Character.NetGuid != 0 ? inv.Character.NetGuid : x.ActorNetGuid;
|
||||||
|
uint eq = 0;
|
||||||
|
if (inv.HasDecoded(nameof(AresInventoryDescriptor.CurrentEquippable))) eq = inv.CurrentEquippable.NetGuid;
|
||||||
|
else if (inv.HasDecoded(nameof(AresInventoryDescriptor.NewCurrentEquippable))) eq = inv.NewCurrentEquippable.NetGuid;
|
||||||
|
if (eq != 0) _equips.Add((Ms(x.TimeSeconds), ch, eq));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case BombPlayerStateDescriptor ps:
|
case BombPlayerStateDescriptor ps:
|
||||||
if (ps.HasDecoded(nameof(BombPlayerStateDescriptor.Subject)) && !string.IsNullOrEmpty(ps.Subject))
|
if (ps.HasDecoded(nameof(BombPlayerStateDescriptor.Subject)) && !string.IsNullOrEmpty(ps.Subject))
|
||||||
_subjectByState[x.ActorNetGuid] = ps.Subject!;
|
_subjectByState[x.ActorNetGuid] = ps.Subject!;
|
||||||
@@ -105,6 +120,8 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
|||||||
private void OnRpc(RpcReceived r)
|
private void OnRpc(RpcReceived r)
|
||||||
{
|
{
|
||||||
var t = Ms(r.TimeSeconds);
|
var t = Ms(r.TimeSeconds);
|
||||||
|
if (ValorantEquippableResolver.TryResolveClassNetCachePath(r.ClassPath, r.ActorNetGuid, out var eq) && eq.Name is { } en)
|
||||||
|
_equipName.TryAdd(r.ActorNetGuid, en);
|
||||||
switch (r.Payload)
|
switch (r.Payload)
|
||||||
{
|
{
|
||||||
case ClientGamePhaseBeginParameters p:
|
case ClientGamePhaseBeginParameters p:
|
||||||
@@ -152,6 +169,11 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
|||||||
pitch = Math.Atan2(v.Z, Math.Sqrt(v.X * v.X + v.Y * v.Y)) * 180 / Math.PI;
|
pitch = Math.Atan2(v.Z, Math.Sqrt(v.X * v.X + v.Y * v.Y)) * 180 / Math.PI;
|
||||||
}
|
}
|
||||||
_shots.Add((Ms(s.TimeSeconds), state, R(loc.X), R(loc.Y), R(loc.Z), R(yaw), R(pitch)));
|
_shots.Add((Ms(s.TimeSeconds), state, R(loc.X), R(loc.Y), R(loc.Z), R(yaw), R(pitch)));
|
||||||
|
if (shot.Equippable is { Name: { } en })
|
||||||
|
{
|
||||||
|
_shotEquips.Add((Ms(s.TimeSeconds), state, en));
|
||||||
|
if (shot.Equippable.NetGuid != 0) _equipName.TryAdd(shot.Equippable.NetGuid, en);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string Simplify(string archetype) => archetype.StartsWith("Default__") ? archetype[9..] : archetype;
|
private static string Simplify(string archetype) => archetype.StartsWith("Default__") ? archetype[9..] : archetype;
|
||||||
@@ -245,8 +267,41 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
|||||||
objects.Add([o.T0, _closedAt.TryGetValue(o.Actor, out var t1) && t1 >= o.T0 ? t1 : -1, k, o.X, o.Y, o.Z, owner]);
|
objects.Add([o.T0, _closedAt.TryGetValue(o.Actor, out var t1) && t1 >= o.T0 ? t1 : -1, k, o.X, o.Y, o.Z, owner]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 들고 있는 것: [t, 선수, 종류]. 같은 선수가 같은 것을 다시 들면 뺀다
|
||||||
|
var equipKinds = new List<string>();
|
||||||
|
var equipKindIndex = new Dictionary<string, int>();
|
||||||
|
int EquipKind(string name)
|
||||||
|
{
|
||||||
|
if (!equipKindIndex.TryGetValue(name, out var k)) { k = equipKinds.Count; equipKinds.Add(name); equipKindIndex[name] = k; }
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
var equipRows = new List<(int T, int P, string Name)>();
|
||||||
|
foreach (var (t, ch, eq) in _equips)
|
||||||
|
{
|
||||||
|
if (!indexByCharacter.TryGetValue(ch, out var pi)) continue;
|
||||||
|
var name = _equipName.TryGetValue(eq, out var n) ? n : _archetypeByActor.TryGetValue(eq, out var a) ? Simplify(a) : null;
|
||||||
|
if (name != null) equipRows.Add((t, pi, name));
|
||||||
|
}
|
||||||
|
// 인벤토리 기록이 없는 선수는 사격 무기로 채운다
|
||||||
|
var hasInv = equipRows.Select(e => e.P).ToHashSet();
|
||||||
|
foreach (var (t, st, name) in _shotEquips)
|
||||||
|
{
|
||||||
|
var pi = PlayerOfState(st);
|
||||||
|
if (pi >= 0 && !hasInv.Contains(pi)) equipRows.Add((t, pi, name));
|
||||||
|
}
|
||||||
|
var equips = new List<int[]>();
|
||||||
|
var lastByPlayer = new Dictionary<int, string>();
|
||||||
|
foreach (var e in equipRows.OrderBy(e => e.T))
|
||||||
|
{
|
||||||
|
if (lastByPlayer.TryGetValue(e.P, out var last) && last == e.Name) continue;
|
||||||
|
lastByPlayer[e.P] = e.Name;
|
||||||
|
equips.Add([e.T, e.P, EquipKind(e.Name)]);
|
||||||
|
}
|
||||||
|
|
||||||
return new ReplayFile
|
return new ReplayFile
|
||||||
{
|
{
|
||||||
|
Equips = equips,
|
||||||
|
EquipKinds = equipKinds,
|
||||||
MatchId = _matchId,
|
MatchId = _matchId,
|
||||||
Map = _map,
|
Map = _map,
|
||||||
Build = branch?.Replace("++Ares-Core+", ""),
|
Build = branch?.Replace("++Ares-Core+", ""),
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ public sealed class ReplayFile
|
|||||||
/// 스킬 · 설치물 [t0, t1, kind 번호, x, y, z, player] (t1 = 사라진 시각, 모르면 -1)
|
/// 스킬 · 설치물 [t0, t1, kind 번호, x, y, z, player] (t1 = 사라진 시각, 모르면 -1)
|
||||||
public List<int[]> Objects { get; set; } = [];
|
public List<int[]> Objects { get; set; } = [];
|
||||||
public List<string> ObjectKinds { get; set; } = [];
|
public List<string> ObjectKinds { get; set; } = [];
|
||||||
|
/// 들고 있는 것이 바뀐 시각 [t, player, kind 번호]. 총은 영어 이름(Vandal 등), 칼은 Melee, 스파이크는 Spike, 스킬은 클래스 이름
|
||||||
|
public List<int[]> Equips { get; set; } = [];
|
||||||
|
public List<string> EquipKinds { get; set; } = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ReplayPlayer
|
public sealed class ReplayPlayer
|
||||||
|
|||||||
Reference in New Issue
Block a user