3D 리플레이: 요원 3D 몸(뼈대 · 텍스처 · 공용 걷기/달리기 + 총 든 자세) · 총 22종 추출, 재생기가 원기둥 대신 요원과 손에 든 총을 그림

- map-extract agents: 요원 30명 agent_<코드>.glb (위/아래 몸 애니메이션 분리, ACL 풀기용 CUE4Parse-Natives 를 g++ 로 빌드), 무기 weapon_<이름>.glb
- pack.py: 요원 · 무기도 압축해 index.json agents · weapons
- 사이트: AgentRig (이동 방향 · 속도로 다리 애니메이션 섞기, 오른손에 총), 1인칭 · 자유시점에서 이름표 작게

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-17 20:25:27 +09:00
parent d87f4ade27
commit f8f585f230
12 changed files with 849 additions and 10 deletions

View File

@@ -8,6 +8,7 @@ import { useData } from '../store/app';
import { fmtClock } from '../lib/format';
import { equipAt, equipLabel, equipTracks, isDead, roundAt, samplePlayer, type ReplayFile, type ReplaySync } from '../lib/replay';
import { findMap3d, loadMap3d, mapMaterial, worldMatrix } from '../lib/map3d';
import { AgentRig, loadAgent } from '../lib/agents3d';
/**
* 3D 리플레이 (발로란트 .vrf → tools/replay-extract → gvr-replay JSON).
@@ -28,8 +29,11 @@ const CEIL_ABOVE = 380;
/** 리플레이 선수 위치(캡슐 중심)에서 눈 · 발까지 (cm) */
const EYE_CM = 60;
const FOOT_CM = 90;
/** 1인칭 · 자유시점에서는 선수 표시를 실제 크기 가깝게 줄인다 */
const REAL_SCALE = 0.5;
/** 1인칭 · 자유시점에서는 선수 표시(이름표 · 원기둥)를 줄이고 머리 위(이 높이, cm)로 올린다 */
const REAL_SCALE = 0.2;
const REAL_LABEL_CM = 190;
/** 위에서 볼 때 요원 몸을 이만큼 키운다 (맵 전체를 볼 때도 보이게) */
const TOP_MODEL_SCALE = 1.8;
/** 카메라: 위에서 보기(돌리기) · 1인칭(고른 선수 눈) · 자유시점(WASD) */
type CamMode = 'top' | 'fp' | 'free';
@@ -93,6 +97,8 @@ interface PlayerView {
/** 바닥(미니맵)까지 내린 선과 그림자 점: 높이가 있어도 평면 위치가 보이게 */
drop: THREE.Line;
shadow: THREE.Mesh;
/** 요원 3D 몸 (게임 파일에서 뽑은 것, 받기 전 · 없으면 null → 원기둥) */
rig: AgentRig | null;
}
export default function ReplayViewer({ m, replay, sync }: Props) {
@@ -269,9 +275,28 @@ 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 }));
shadow.rotation.x = -Math.PI / 2;
scene.add(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 };
return { idx: r.idx, info: r.info, name: r.name, ally: r.ally, group, body, cone, label, weapon, weaponKind: -2, voice, ring, drop, shadow, rig: null };
});
// 요원 3D 몸: UE 좌표(cm) 그대로 두고 맵과 같은 행렬로 옮긴다
const agentsGroup = new THREE.Group();
agentsGroup.matrixAutoUpdate = false;
agentsGroup.matrix.copy(worldMatrix(T, S, zBase, VEX));
scene.add(agentsGroup);
for (const v of views) {
const cls = replay.players[v.idx].character;
if (!cls) continue;
void loadAgent(cls)
.then((g) => {
if (!g || disposed) return;
v.rig = new AgentRig(g);
agentsGroup.add(v.rig.root);
agentsGroup.updateMatrixWorld(true);
})
.catch(() => {});
}
let prevT = localT.current;
// 총 이름표 (같은 글자는 텍스처 하나)
const weaponTex = new Map<string, { tex: THREE.Texture; aspect: number }>();
const setWeapon = (v: PlayerView, kind: number) => {
@@ -403,6 +428,8 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
renderer.domElement.addEventListener('keyup', onKey);
renderer.domElement.addEventListener('blur', onBlur);
// 개발 확인용 (목 서버 스크린샷 스크립트가 카메라를 옮긴다)
if (import.meta.env.DEV) (window as unknown as { __r3d: unknown }).__r3d = { camera, controls, views, scene, free };
let raf = 0;
let lastUi = 0;
let lastNow = 0;
@@ -436,6 +463,9 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
const t = inScene ? ps.sceneTs! - base : localT.current;
if (!inScene) localT.current = t;
const ts = base + t;
// 리플레이 시간 흐름 (애니메이션용, 시간을 크게 옮기면 0)
const dtR = t - prevT >= 0 && t - prevT < 1000 ? (t - prevT) / 1000 : 0;
prevT = t;
// 지금 말하는 사람
const speaking = new Set<number>();
for (const u of m.utterances) if (u.ts <= ts && ts <= u.endTs && !u.noise) {
@@ -453,7 +483,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
// 1인칭으로 보는 선수 자신은 숨긴다
v.group.visible = !(mode === 'fp' && v.idx === selRef.current);
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.position.copy(toWorld(p.x, p.y, Math.max(p.z, zBase - 400) + (real ? REAL_LABEL_CM - 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);
const dp = v.drop.geometry.getAttribute('position') as THREE.BufferAttribute;
@@ -469,8 +499,30 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
v.label.material.opacity = dead ? 0.35 : 1;
(v.shadow.material as THREE.MeshBasicMaterial).opacity = dead ? 0.25 : 0.85;
v.voice.visible = speaking.has(v.idx) && !dead;
setWeapon(v, dead ? -1 : equipAt(equipByPlayer[v.idx], t));
const kind = dead ? -1 : equipAt(equipByPlayer[v.idx], t);
setWeapon(v, kind);
v.weapon.material.opacity = v.label.material.opacity;
if (v.rig) {
// 몸이 있으면 원기둥 대신. 죽으면 몸을 숨긴다 (죽은 자리는 X 표시)
v.body.visible = v.cone.visible = false;
const rr = v.rig.root;
rr.visible = v.group.visible && !dead;
rr.position.set(p.x, p.y, Math.max(p.z, zBase - 400) - FOOT_CM);
rr.rotation.set(0, 0, (p.yaw * Math.PI) / 180);
rr.scale.setScalar(real ? 1 : TOP_MODEL_SCALE);
if (rr.visible) {
const q = samplePlayer(tr, t - 150, replay.sampleMs * 6);
const vx = q ? ((p.x - q.x) * 1000) / 150 : 0;
const vy = q ? ((p.y - q.y) * 1000) / 150 : 0;
const a = (p.yaw * Math.PI) / 180;
const ek = replay.equipKinds?.[kind];
v.rig.setWeapon(ek && !/^Ability_|Unarmed|Bomb_Defuser/.test(ek) ? ek : null);
v.rig.update(dtR, vx * Math.cos(a) + vy * Math.sin(a), -vx * Math.sin(a) + vy * Math.cos(a), p.pitch);
}
} else {
v.body.visible = true;
v.cone.visible = true;
}
v.ring.visible = v.idx === selIdx;
}
// 천장 자르기
@@ -531,7 +583,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
if (on) {
const age = t - k.t;
const s = age < 600 ? 1 + (600 - age) / 300 : 1;
k.mk.scale.setScalar(s);
k.mk.scale.setScalar(s * (real ? 0.25 : 1));
}
}
// 스킬 · 설치물: 생긴 뒤 사라질 때까지 (사라진 시각을 모르면 12초)
@@ -585,6 +637,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
renderer.domElement.removeEventListener('keyup', onKey);
renderer.domElement.removeEventListener('blur', onBlur);
controls.dispose();
for (const v of views) v.rig?.dispose();
scene.traverse((o) => {
const mesh = o as THREE.Mesh;
mesh.geometry?.dispose?.();