diff --git a/site/web/src/components/ReplayViewer.tsx b/site/web/src/components/ReplayViewer.tsx index 576b66f..39ec375 100644 --- a/site/web/src/components/ReplayViewer.tsx +++ b/site/web/src/components/ReplayViewer.tsx @@ -624,6 +624,9 @@ export default function ReplayViewer({ m, replay, sync }: Props) { const a = samplePlayer(tr, t, replay.sampleMs * 6); const b = samplePlayer(tr, t - 200, replay.sampleMs * 6); const moving = !!a && !!b && Math.hypot(a.x - b.x, a.y - b.y) > 30; + // 스파이크 설치 중 (이어지는 동작 Plant 구간) + let activateMs: number | null = null; + for (const [a0, a1, k] of animIx.actions[p]) if (k === 'Plant' && a0 <= t && t <= a1) activateMs = t - a0; return { kind, zoom, @@ -634,6 +637,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) { reloadMs, ads: zoom > 0, walkMs: moving ? t : null, + activateMs: kind === 'Spike' ? activateMs : null, }, }; }; diff --git a/site/web/src/lib/viewmodel.ts b/site/web/src/lib/viewmodel.ts index 4e3df49..e9cf41d 100644 --- a/site/web/src/lib/viewmodel.ts +++ b/site/web/src/lib/viewmodel.ts @@ -51,6 +51,8 @@ export interface VmInput { ads: boolean; /** 걷는 중이면 걸은 시간 (반복 동작 위치) */ walkMs: number | null; + /** 스파이크 설치 시작 뒤 (설치하는 동안만) */ + activateMs?: number | null; } function findBone(root: THREE.Object3D, name: string): THREE.Object3D | null { @@ -157,8 +159,9 @@ export class Viewmodel { // 눈 = 팔 Camera 뼈 (대기 자세) this.play(this.armsMixer, this.armClips.get('idle'), 0, false); arms.updateMatrixWorld(true); + // 팔 공간 좌표로 (root 에 이전 요원 · 무기의 변환이 남아 있어도 같은 값) const cam = findBone(arms, 'Camera'); - const cp = cam ? new THREE.Vector3().setFromMatrixPosition(cam.matrixWorld) : new THREE.Vector3(0, 0, 166); + const cp = cam ? arms.worldToLocal(new THREE.Vector3().setFromMatrixPosition(cam.matrixWorld)) : new THREE.Vector3(0, 0, 166); this.root.matrix.copy(UE_TO_VIEW).multiply(new THREE.Matrix4().makeTranslation(-cp.x, -cp.y, -cp.z)); this.root.matrixWorldNeedsUpdate = true; } @@ -181,14 +184,15 @@ export class Viewmodel { return true; } - /** 시각만으로 자세: 꺼내기 > 재장전 > 사격 > 걷기 > 정조준 > 대기 */ + /** 시각만으로 자세: 스파이크 설치 > 꺼내기 > 재장전 > 사격 > 걷기 > 정조준 > 대기 (설치 시작 때 스파이크를 꺼내므로 설치가 먼저) */ pose(i: VmInput) { if (!this.armsMixer || !this.gunMixer) return; const dur = (n: string) => (this.armClips.get(n)?.duration ?? 0) * 1000; let role = 'idle'; let ms = 0; let loop = false; - if (i.equipMs != null && i.equipMs < dur('equip')) [role, ms] = ['equip', i.equipMs]; + if (i.activateMs != null && this.armClips.has('activate')) [role, ms] = ['activate', i.activateMs]; + else if (i.equipMs != null && i.equipMs < dur('equip')) [role, ms] = ['equip', i.equipMs]; else if (i.reloadMs != null && i.reloadMs < dur('reload')) [role, ms] = ['reload', i.reloadMs]; else if (i.shotMs != null && i.shotMs < dur('fire')) [role, ms] = ['fire', i.shotMs]; else if (i.walkMs != null && this.armClips.has('walk') && !i.ads) [role, ms, loop] = ['walk', i.walkMs, true];