fix(effects): снизить лаги сцены на Mac

Pixi режется по contentRect, пульт идёт в preview (12 FPS, 0.5 DPR), штампы тумана/огня/дождя прореживаются, draft темноты и маркера не чаще 20 Гц.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
     Фонтош Иван Сергеевич
2026-09-07 17:13:37 +08:00
parent 34dd39791b
commit 48a9c933af
11 changed files with 215 additions and 34 deletions
+7
View File
@@ -95,6 +95,8 @@ import { getSunbeamEffectLifeMs, playSunbeamEffectSound } from './sunbeamSfx';
/** Длительность молнии: быстрый удар + акцент в точке попадания. */
const LIGHTNING_EFFECT_MS = 840;
/** Темнота/маркер на презентацию — не чаще 20 Гц (полный canvas replay в обоих окнах). */
const OVERLAY_DRAFT_IPC_MS = 50;
function dispositionMakeKey(d: NpcDisposition): string {
if (d === 'hostile') return 'npcs.makeHostile';
@@ -305,6 +307,7 @@ export function ControlApp() {
const brushCursorElRef = useRef<HTMLDivElement | null>(null);
const cursorPosRef = useRef<{ x: number; y: number } | null>(null);
const draftPaintRafRef = useRef(0);
const overlayDraftIpcAtRef = useRef(0);
const effectsOverlayRef = useRef<PixiEffectsOverlayHandle | null>(null);
const [explosionDraft, setExplosionDraft] = useState<ExplosionInstance | null>(null);
const draftMetaRef = useRef<{ createdAtMs: number; seed: number } | null>(null);
@@ -1387,6 +1390,9 @@ export function ControlApp() {
draftPaintRafRef.current = 0;
pushDraftToPixi();
const b = brushRef.current;
const now = performance.now();
if (now - overlayDraftIpcAtRef.current < OVERLAY_DRAFT_IPC_MS) return;
overlayDraftIpcAtRef.current = now;
if (
(b?.tool === 'exploreBrush' || b?.tool === 'closeBrush') &&
b.points
@@ -2512,6 +2518,7 @@ export function ControlApp() {
<PixiEffectsOverlay
ref={effectsOverlayRef}
state={fxState}
perfProfile="preview"
style={{ zIndex: 6 }}
viewport={
previewContentRect