3D 리플레이 실감 2단계: 게임 스킬 효과 추출(Abilities.cs: Cascade 파티클 · 메시 · 텍스처 → abilities.json) · 사이트 파티클 재생기(lib/vfx.ts: 시간만으로 계산 · 연막 돔 · 장판 칸 · 투사체 꼬리 · 설치물 메시) · maps3d json/png 제공 · update.sh/pack.py 연결
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import { findMap3d, loadMap3d, mapMaterial, worldMatrix } from '../lib/map3d';
|
||||
import { AgentRig, isGun, loadAgent, loadAnims, loadWeapon } from '../lib/agents3d';
|
||||
import { buildAnimIndex, rigInput } from '../lib/replayAnim';
|
||||
import { abilityLook, type AbilityLook } from '../lib/abilities';
|
||||
import { loadVfxDb, vfxCoverage, VfxObject, type Place, type VfxDb } from '../lib/vfx';
|
||||
|
||||
/**
|
||||
* 3D 리플레이 (발로란트 .vrf → tools/replay-extract → gvr-replay JSON).
|
||||
@@ -472,6 +473,40 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
||||
};
|
||||
// 움직이는 스킬 경로 (투사체 · 드론 · 분신): objects 번호 → 경로
|
||||
const pathOf = new Map((replay.objectPaths ?? []).map((p) => [p.o, p]));
|
||||
// 게임 파일 스킬 효과 (lib/vfx.ts: 메시 · 파티클). 받으면 종류별 모양 대신 쓴다.
|
||||
// 요루 분신 · 스파이크는 지금 그리는 것(요원 몸 애니메이션 · 스파이크 3D)을 두고 효과만 더한다
|
||||
let vfxDb: VfxDb | null = null;
|
||||
let vfxKinds: ('full' | 'partial' | 'none')[] = [];
|
||||
const vfxObjs = new Map<number, VfxObject>();
|
||||
const vfxGroup = new THREE.Group();
|
||||
agentsGroup.add(vfxGroup);
|
||||
void loadVfxDb().then((db) => {
|
||||
if (!db || disposed) return;
|
||||
vfxDb = db;
|
||||
vfxKinds = replay.objectKinds.map((k) => vfxCoverage(db, k));
|
||||
});
|
||||
const KEEP_OWN = /^(Pawn_Stealth_4_Decoy|TimedBomb_C)/;
|
||||
const camUE = new THREE.Vector3();
|
||||
const invAgents = new THREE.Matrix4();
|
||||
const deg = (r: number) => (r * 180) / Math.PI;
|
||||
const placeOf = (i: number) => {
|
||||
const o = replay.objects[i];
|
||||
const path = pathOf.get(i);
|
||||
const still: Place = { x: o[3], y: o[4], z: o[5], yaw: o[7] ?? 0, pitch: 0 };
|
||||
if (!path || path.t.length < 2) return { at: (_t: number) => still, speed: 0 };
|
||||
const n = path.t.length;
|
||||
const dist = path.x.slice(1).reduce((d, x, k) => d + Math.hypot(x - path.x[k], path.y[k + 1] - path.y[k], path.z[k + 1] - path.z[k]), 0);
|
||||
const speed = dist / Math.max(0.05, (path.t[n - 1] - path.t[0]) / 1000);
|
||||
return {
|
||||
speed,
|
||||
at: (tMs: number): Place => {
|
||||
const pp = samplePath(path, Math.max(path.t[0], Math.min(path.t[n - 1], tMs)));
|
||||
if (!pp) return still;
|
||||
const h = Math.hypot(pp.vx, pp.vy);
|
||||
return { x: pp.x, y: pp.y, z: pp.z, yaw: pp.yaw ?? (h > 1 ? deg(Math.atan2(pp.vy, pp.vx)) : still.yaw), pitch: h > 1 || Math.abs(pp.vz) > 1 ? deg(Math.atan2(pp.vz, h)) : 0 };
|
||||
},
|
||||
};
|
||||
};
|
||||
const setOpacity = (ov: ObjView, k: number) => {
|
||||
for (const m of ov.mats) {
|
||||
const base = (m.userData.baseOpacity ??= m.opacity) as number;
|
||||
@@ -722,10 +757,33 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
||||
}
|
||||
}
|
||||
// 스킬 · 설치물: 생긴 뒤 사라질 때까지 (모르면 종류별 기본 시간). 날아가는 것은 던진 자리에 잠깐만
|
||||
invAgents.copy(agentsGroup.matrixWorld).invert();
|
||||
camUE.copy(camera.position).applyMatrix4(invAgents);
|
||||
for (let i = 0; i < replay.objects.length; i++) {
|
||||
const [t0, t1, kind] = replay.objects[i];
|
||||
const ov0 = objViews.get(i);
|
||||
const end = ov0 ? ov0.end : t1 >= t0 ? t1 : t0 + abilityLook(replay.objectKinds[kind] ?? '').defaultMs;
|
||||
if (vfxDb && vfxKinds[kind] && vfxKinds[kind] !== 'none') {
|
||||
const cls = replay.objectKinds[kind] ?? '';
|
||||
const own = KEEP_OWN.test(cls) || vfxKinds[kind] === 'partial';
|
||||
let vo = vfxObjs.get(i);
|
||||
const near = t >= t0 - 100 && t <= end + 6000;
|
||||
if (near && !vo) {
|
||||
const pl = placeOf(i);
|
||||
const owner = replay.objects[i][6];
|
||||
vo = new VfxObject(vfxDb, { cls, t0, end, team: roster[owner]?.ally ? 'ally' : 'enemy', projectile: /^Projectile_/.test(cls), placeAt: pl.at, speed: pl.speed }, vfxGroup, i + 1, !own);
|
||||
vfxObjs.set(i, vo);
|
||||
} else if (!near && vo) {
|
||||
vo.dispose();
|
||||
vfxObjs.delete(i);
|
||||
vo = undefined;
|
||||
}
|
||||
vo?.update(t, camUE);
|
||||
if (!own) {
|
||||
if (ov0) ov0.obj.visible = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const on = t >= t0 && t <= end;
|
||||
if (!on) {
|
||||
if (ov0) {
|
||||
@@ -829,6 +887,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
|
||||
renderer.domElement.removeEventListener('blur', onBlur);
|
||||
controls.dispose();
|
||||
for (const v of views) v.rig?.dispose();
|
||||
for (const vo of vfxObjs.values()) vo.dispose();
|
||||
scene.traverse((o) => {
|
||||
const mesh = o as THREE.Mesh;
|
||||
mesh.geometry?.dispose?.();
|
||||
|
||||
Reference in New Issue
Block a user